Completed
Push — release-2.1 ( 4c82a0...64d581 )
by Rick
09:29
created
Themes/default/Display.template.php 1 patch
Braces   +202 added lines, -137 removed lines patch added patch discarded remove patch
@@ -51,11 +51,13 @@  discard block
 block discarded – undo
51 51
 				<p>';
52 52
 
53 53
 		// Show just numbers...?
54
-		if ($settings['display_who_viewing'] == 1)
55
-				echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members'];
54
+		if ($settings['display_who_viewing'] == 1) {
55
+						echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members'];
56
+		}
56 57
 		// Or show the actual people viewing the topic?
57
-		else
58
-			echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
58
+		else {
59
+					echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
60
+		}
59 61
 
60 62
 		// Now show how many guests are here too.
61 63
 		echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], '
@@ -93,10 +95,11 @@  discard block
 block discarded – undo
93 95
 						<dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt>
94 96
 						<dd class="statsbar', $option['voted_this'] ? ' voted' : '', '">';
95 97
 
96
-				if ($context['allow_results_view'])
97
-					echo '
98
+				if ($context['allow_results_view']) {
99
+									echo '
98 100
 							', $option['bar_ndt'], '
99 101
 							<span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>';
102
+				}
100 103
 
101 104
 				echo '
102 105
 						</dd>';
@@ -105,9 +108,10 @@  discard block
 block discarded – undo
105 108
 			echo '
106 109
 					</dl>';
107 110
 
108
-			if ($context['allow_results_view'])
109
-				echo '
111
+			if ($context['allow_results_view']) {
112
+							echo '
110 113
 						<p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>';
114
+			}
111 115
 		}
112 116
 		// They are allowed to vote! Go to it!
113 117
 		else
@@ -116,17 +120,19 @@  discard block
 block discarded – undo
116 120
 						<form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">';
117 121
 
118 122
 			// Show a warning if they are allowed more than one option.
119
-			if ($context['poll']['allowed_warning'])
120
-				echo '
123
+			if ($context['poll']['allowed_warning']) {
124
+							echo '
121 125
 							<p class="smallpadding">', $context['poll']['allowed_warning'], '</p>';
126
+			}
122 127
 
123 128
 			echo '
124 129
 							<ul class="options">';
125 130
 
126 131
 			// Show each option with its button - a radio likely.
127
-			foreach ($context['poll']['options'] as $option)
128
-				echo '
132
+			foreach ($context['poll']['options'] as $option) {
133
+							echo '
129 134
 								<li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>';
135
+			}
130 136
 
131 137
 			echo '
132 138
 							</ul>
@@ -138,9 +144,10 @@  discard block
 block discarded – undo
138 144
 		}
139 145
 
140 146
 		// Is the clock ticking?
141
-		if (!empty($context['poll']['expire_time']))
142
-			echo '
147
+		if (!empty($context['poll']['expire_time'])) {
148
+					echo '
143 149
 						<p><strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '</p>';
150
+		}
144 151
 
145 152
 		echo '
146 153
 					</div>
@@ -164,11 +171,12 @@  discard block
 block discarded – undo
164 171
 			<div class="information">
165 172
 				<ul>';
166 173
 
167
-		foreach ($context['linked_calendar_events'] as $event)
168
-			echo '
174
+		foreach ($context['linked_calendar_events'] as $event) {
175
+					echo '
169 176
 					<li>
170 177
 						', ($event['can_edit'] ? '<a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify"></span></a> ' : ''), '<strong>', $event['title'], '</strong>: ', $event['start_date'], ($event['start_date'] != $event['end_date'] ? ' - ' . $event['end_date'] : ''), '
171 178
 					</li>';
179
+		}
172 180
 
173 181
 		echo '
174 182
 				</ul>
@@ -203,8 +211,9 @@  discard block
 block discarded – undo
203 211
 	$context['removableMessageIDs'] = array();
204 212
 
205 213
 	// Get all the messages...
206
-	while ($message = $context['get_message']())
207
-		template_single_post($message);
214
+	while ($message = $context['get_message']()) {
215
+			template_single_post($message);
216
+	}
208 217
 
209 218
 	echo '
210 219
 				</form>
@@ -241,8 +250,9 @@  discard block
 block discarded – undo
241 250
 			<div id="display_jump_to">&nbsp;</div>';
242 251
 
243 252
 	// Show quickreply
244
-	if ($context['can_reply'])
245
-	template_quickreply();
253
+	if ($context['can_reply']) {
254
+		template_quickreply();
255
+	}
246 256
 
247 257
 	// User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device.
248 258
 	echo '
@@ -255,8 +265,8 @@  discard block
 block discarded – undo
255 265
 			</div>';
256 266
 
257 267
 	// Show the moderation button & pop only if user can moderate
258
-	if ($context['can_moderate_forum'] || $context['user']['is_mod'])
259
-		echo '
268
+	if ($context['can_moderate_forum'] || $context['user']['is_mod']) {
269
+			echo '
260 270
 			<div id="mobile_moderation" class="popup_container">
261 271
 				<div class="popup_window description">
262 272
 					<div class="popup_heading">', $txt['mobile_moderation'],'
@@ -266,6 +276,7 @@  discard block
 block discarded – undo
266 276
 					</div>
267 277
 				</div>
268 278
 			</div>';
279
+	}
269 280
 
270 281
 		echo '
271 282
 				<script>';
@@ -389,9 +400,10 @@  discard block
 block discarded – undo
389 400
 						});
390 401
 					}';
391 402
 
392
-	if (!empty($context['ignoredMsgs']))
393
-		echo '
403
+	if (!empty($context['ignoredMsgs'])) {
404
+			echo '
394 405
 					ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');';
406
+	}
395 407
 
396 408
 	echo '
397 409
 				</script>';
@@ -408,8 +420,9 @@  discard block
 block discarded – undo
408 420
 
409 421
 	$ignoring = false;
410 422
 
411
-	if ($message['can_remove'])
412
-		$context['removableMessageIDs'][] = $message['id'];
423
+	if ($message['can_remove']) {
424
+			$context['removableMessageIDs'][] = $message['id'];
425
+	}
413 426
 
414 427
 	// Are we ignoring this message?
415 428
 	if (!empty($message['is_ignored']))
@@ -435,9 +448,10 @@  discard block
 block discarded – undo
435 448
 							<div class="custom_fields_above_member">
436 449
 								<ul class="nolist">';
437 450
 
438
-		foreach ($message['custom_fields']['above_member'] as $custom)
439
-			echo '
451
+		foreach ($message['custom_fields']['above_member'] as $custom) {
452
+					echo '
440 453
 									<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
454
+		}
441 455
 
442 456
 		echo '
443 457
 								</ul>
@@ -448,9 +462,10 @@  discard block
 block discarded – undo
448 462
 									<h4>';
449 463
 
450 464
 	// Show online and offline buttons?
451
-	if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
452
-		echo '
465
+	if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) {
466
+			echo '
453 467
 								', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>', $context['can_send_pm'] ? '</a>' : '';
468
+	}
454 469
 
455 470
 
456 471
 	// Show a link to the member's profile.
@@ -463,51 +478,59 @@  discard block
 block discarded – undo
463 478
 
464 479
 
465 480
 	// Show the user's avatar.
466
-	if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
467
-		echo '
481
+	if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) {
482
+			echo '
468 483
 								<li class="avatar">
469 484
 									<a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a>
470 485
 								</li>';
486
+	}
471 487
 
472 488
 	// Are there any custom fields below the avatar?
473
-	if (!empty($message['custom_fields']['below_avatar']))
474
-		foreach ($message['custom_fields']['below_avatar'] as $custom)
489
+	if (!empty($message['custom_fields']['below_avatar'])) {
490
+			foreach ($message['custom_fields']['below_avatar'] as $custom)
475 491
 			echo '
476 492
 								<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
493
+	}
477 494
 
478 495
 	// Show the post group icons, but not for guests.
479
-	if (!$message['member']['is_guest'])
480
-		echo '
496
+	if (!$message['member']['is_guest']) {
497
+			echo '
481 498
 								<li class="icons">', $message['member']['group_icons'], '</li>';
499
+	}
482 500
 
483 501
 	// Show the member's primary group (like 'Administrator') if they have one.
484
-	if (!empty($message['member']['group']))
485
-		echo '
502
+	if (!empty($message['member']['group'])) {
503
+			echo '
486 504
 								<li class="membergroup">', $message['member']['group'], '</li>';
505
+	}
487 506
 
488 507
 	// Show the member's custom title, if they have one.
489
-	if (!empty($message['member']['title']))
490
-		echo '
508
+	if (!empty($message['member']['title'])) {
509
+			echo '
491 510
 								<li class="title">', $message['member']['title'], '</li>';
511
+	}
492 512
 
493 513
 	// Don't show these things for guests.
494 514
 	if (!$message['member']['is_guest'])
495 515
 	{
496 516
 
497 517
 		// Show the post group if and only if they have no other group or the option is on, and they are in a post group.
498
-		if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group']))
499
-			echo '
518
+		if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) {
519
+					echo '
500 520
 								<li class="postgroup">', $message['member']['post_group'], '</li>';
521
+		}
501 522
 
502 523
 		// Show how many posts they have made.
503
-		if (!isset($context['disabled_fields']['posts']))
504
-			echo '
524
+		if (!isset($context['disabled_fields']['posts'])) {
525
+					echo '
505 526
 								<li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>';
527
+		}
506 528
 
507 529
 		// Show their personal text?
508
-		if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb']))
509
-			echo '
530
+		if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) {
531
+					echo '
510 532
 								<li class="blurb">', $message['member']['blurb'], '</li>';
533
+		}
511 534
 
512 535
 		// Any custom fields to show as icons?
513 536
 		if (!empty($message['custom_fields']['icons']))
@@ -516,9 +539,10 @@  discard block
 block discarded – undo
516 539
 								<li class="im_icons">
517 540
 									<ol>';
518 541
 
519
-			foreach ($message['custom_fields']['icons'] as $custom)
520
-				echo '
542
+			foreach ($message['custom_fields']['icons'] as $custom) {
543
+							echo '
521 544
 										<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
545
+			}
522 546
 
523 547
 			echo '
524 548
 									</ol>
@@ -533,19 +557,22 @@  discard block
 block discarded – undo
533 557
 									<ol class="profile_icons">';
534 558
 
535 559
 			// Don't show an icon if they haven't specified a website.
536
-			if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website']))
537
-				echo '
560
+			if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) {
561
+							echo '
538 562
 										<li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
563
+			}
539 564
 
540 565
 			// Since we know this person isn't a guest, you *can* message them.
541
-			if ($context['can_send_pm'])
542
-				echo '
566
+			if ($context['can_send_pm']) {
567
+							echo '
543 568
 										<li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>';
569
+			}
544 570
 
545 571
 			// Show the email if necessary
546
-			if (!empty($message['member']['email']) && $message['member']['show_email'])
547
-				echo '
572
+			if (!empty($message['member']['email']) && $message['member']['show_email']) {
573
+							echo '
548 574
 										<li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>';
575
+			}
549 576
 
550 577
 				echo '
551 578
 									</ol>
@@ -553,48 +580,56 @@  discard block
 block discarded – undo
553 580
 		}
554 581
 
555 582
 		// Any custom fields for standard placement?
556
-		if (!empty($message['custom_fields']['standard']))
557
-			foreach ($message['custom_fields']['standard'] as $custom)
583
+		if (!empty($message['custom_fields']['standard'])) {
584
+					foreach ($message['custom_fields']['standard'] as $custom)
558 585
 				echo '
559 586
 								<li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>';
587
+		}
560 588
 
561 589
 	}
562 590
 	// Otherwise, show the guest's email.
563
-	elseif (!empty($message['member']['email']) && $message['member']['show_email'])
564
-		echo '
591
+	elseif (!empty($message['member']['email']) && $message['member']['show_email']) {
592
+			echo '
565 593
 								<li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>';
594
+	}
566 595
 
567 596
 	// Show the IP to this user for this post - because you can moderate?
568
-	if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip']))
569
-		echo '
597
+	if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) {
598
+			echo '
570 599
 								<li class="poster_ip"><a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></li>';
600
+	}
571 601
 
572 602
 	// Or, should we show it because this is you?
573
-	elseif ($message['can_see_ip'])
574
-		echo '
603
+	elseif ($message['can_see_ip']) {
604
+			echo '
575 605
 								<li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a></li>';
606
+	}
576 607
 
577 608
 	// Okay, are you at least logged in? Then we can show something about why IPs are logged...
578
-	elseif (!$context['user']['is_guest'])
579
-		echo '
609
+	elseif (!$context['user']['is_guest']) {
610
+			echo '
580 611
 								<li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>';
612
+	}
581 613
 
582 614
 	// Otherwise, you see NOTHING!
583
-	else
584
-		echo '
615
+	else {
616
+			echo '
585 617
 								<li class="poster_ip">', $txt['logged'], '</li>';
618
+	}
586 619
 
587 620
 	// Are we showing the warning status?
588 621
 	// Don't show these things for guests.
589
-	if (!$message['member']['is_guest'] && $message['member']['can_see_warning'])
590
-		echo '
622
+	if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) {
623
+			echo '
591 624
 								<li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span> ', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>';
625
+	}
592 626
 
593 627
 	// Are there any custom fields to show at the bottom of the poster info?
594
-	if (!empty($message['custom_fields']['bottom_poster']))
595
-		foreach ($message['custom_fields']['bottom_poster'] as $custom)
628
+	if (!empty($message['custom_fields']['bottom_poster'])) {
629
+			foreach ($message['custom_fields']['bottom_poster'] as $custom)
596 630
 			echo '
597 631
 									<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
632
+	}
598 633
 
599 634
 	// Poster info ends.
600 635
 	echo '
@@ -623,9 +658,10 @@  discard block
 block discarded – undo
623 658
 	echo '
624 659
 									<span class="smalltext modified" id="modified_', $message['id'], '">';
625 660
 
626
-	if (!empty($modSettings['show_modify']) && !empty($message['modified']['name']))
627
-		echo
661
+	if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) {
662
+			echo
628 663
 										$message['modified']['last_edit_text'];
664
+	}
629 665
 
630 666
 	echo '
631 667
 									</span>';
@@ -636,22 +672,24 @@  discard block
 block discarded – undo
636 672
 							</div>';
637 673
 
638 674
 	// Ignoring this user? Hide the post.
639
-	if ($ignoring)
640
-		echo '
675
+	if ($ignoring) {
676
+			echo '
641 677
 							<div id="msg_', $message['id'], '_ignored_prompt">
642 678
 								', $txt['ignoring_user'], '
643 679
 								<a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a>
644 680
 							</div>';
681
+	}
645 682
 
646 683
 	// Show the post itself, finally!
647 684
 	echo '
648 685
 							<div class="post">';
649 686
 
650
-	if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id'])
651
-		echo '
687
+	if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) {
688
+			echo '
652 689
 								<div class="approve_post">
653 690
 									', $txt['post_awaiting_approval'], '
654 691
 								</div>';
692
+	}
655 693
 	echo '
656 694
 								<div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '>', $message['body'], '</div>
657 695
 							</div>';
@@ -668,9 +706,9 @@  discard block
 block discarded – undo
668 706
 		foreach ($message['attachment'] as $attachment)
669 707
 		{
670 708
 			// Do we want this attachment to not be showed here?
671
-			if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']]))
672
-				continue;
673
-			elseif (!$div_output)
709
+			if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) {
710
+							continue;
711
+			} elseif (!$div_output)
674 712
 			{
675 713
 				$div_output = true;
676 714
 
@@ -686,9 +724,10 @@  discard block
 block discarded – undo
686 724
 								<fieldset>
687 725
 									<legend>', $txt['attach_awaiting_approve'];
688 726
 
689
-				if ($context['can_approve'])
690
-					echo '
727
+				if ($context['can_approve']) {
728
+									echo '
691 729
 										&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]';
730
+				}
692 731
 
693 732
 				echo '
694 733
 									</legend>';
@@ -702,12 +741,13 @@  discard block
 block discarded – undo
702 741
 				echo '
703 742
 										<div class="attachments_top">';
704 743
 
705
-				if ($attachment['thumbnail']['has_thumb'])
706
-					echo '
744
+				if ($attachment['thumbnail']['has_thumb']) {
745
+									echo '
707 746
 											<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" class="atc_img"></a>';
708
-				else
709
-					echo '
747
+				} else {
748
+									echo '
710 749
 											<img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">';
750
+				}
711 751
 
712 752
 				echo '
713 753
 										</div>';
@@ -717,9 +757,10 @@  discard block
 block discarded – undo
717 757
 										<div class="attachments_bot">
718 758
 											<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*">&nbsp;' . $attachment['name'] . '</a> ';
719 759
 
720
-			if (!$attachment['is_approved'] && $context['can_approve'])
721
-				echo '
760
+			if (!$attachment['is_approved'] && $context['can_approve']) {
761
+							echo '
722 762
 											[<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>]&nbsp;|&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] ';
763
+			}
723 764
 			echo '
724 765
 											<br>', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . '<br>' . sprintf($txt['attach_viewed'], $attachment['downloads']) : '<br>' . sprintf($txt['attach_downloaded'], $attachment['downloads'])), '
725 766
 										</div>';
@@ -728,33 +769,38 @@  discard block
 block discarded – undo
728 769
 									</div>';
729 770
 
730 771
 			// Next attachment line ?
731
-			if (++$i % $attachments_per_line === 0)
732
-				echo '
772
+			if (++$i % $attachments_per_line === 0) {
773
+							echo '
733 774
 									<br>';
775
+			}
734 776
 		}
735 777
 
736 778
 		// If we had unapproved attachments clean up.
737
-		if ($last_approved_state == 0)
738
-			echo '
779
+		if ($last_approved_state == 0) {
780
+					echo '
739 781
 								</fieldset>';
782
+		}
740 783
 
741 784
 		// Only do this if we output a div above - otherwise it'll break things
742
-		if ($div_output)
743
-			echo '
785
+		if ($div_output) {
786
+					echo '
744 787
 							</div>';
788
+		}
745 789
 	}
746 790
 
747 791
 	// And stuff below the attachments.
748
-	if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote'])
749
-	echo '
792
+	if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) {
793
+		echo '
750 794
 							<div class="under_message">';
795
+	}
751 796
 
752 797
 	// Maybe they want to report this post to the moderator(s)?
753
-	if ($context['can_report_moderator'])
754
-		echo '
798
+	if ($context['can_report_moderator']) {
799
+			echo '
755 800
 								<ul class="floatright smalltext">
756 801
 									<li class="report_link"><a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a></li>
757 802
 								</ul>';
803
+	}
758 804
 
759 805
 	// What about likes?
760 806
 	if (!empty($modSettings['enable_likes']))
@@ -795,78 +841,91 @@  discard block
 block discarded – undo
795 841
 								<ul class="quickbuttons">';
796 842
 
797 843
 		// Can they quote? if so they can select and quote as well!
798
-		if ($context['can_quote'])
799
-			echo '
844
+		if ($context['can_quote']) {
845
+					echo '
800 846
 									<li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>
801 847
 									<li style="display:none;" id="quoteSelected_', $message['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li>';
848
+		}
802 849
 
803 850
 		// Can the user modify the contents of this post? Show the modify inline image.
804
-		if ($message['can_modify'])
805
-			echo '
851
+		if ($message['can_modify']) {
852
+					echo '
806 853
 									<li class="quick_edit"><a title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\', \'', !empty($modSettings['toggle_subject']), '\')"><span class="generic_icons quick_edit_button"></span>', $txt['quick_edit'], '</a></li>';
854
+		}
807 855
 
808
-		if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
809
-			echo '
856
+		if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) {
857
+					echo '
810 858
 									<li class="post_options">', $txt['post_options'];
859
+		}
811 860
 
812 861
 		echo '
813 862
 										<ul>';
814 863
 
815 864
 		// Can the user modify the contents of this post?
816
-		if ($message['can_modify'])
817
-			echo '
865
+		if ($message['can_modify']) {
866
+					echo '
818 867
 											<li><a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '"><span class="generic_icons modify_button"></span>', $txt['modify'], '</a></li>';
868
+		}
819 869
 
820 870
 		// How about... even... remove it entirely?!
821
-		if ($context['can_delete'] && ($context['topic_first_message'] == $message['id']))
822
-			echo '
871
+		if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) {
872
+					echo '
823 873
 											<li><a href="', $scripturl, '?action=removetopic2;topic=', $context['current_topic'], '.', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['are_sure_remove_topic'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove_topic'],'</a></li>';
824
-		elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id']))
825
-			echo '
874
+		} elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) {
875
+					echo '
826 876
 											<li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message_question'] ,'" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
877
+		}
827 878
 
828 879
 		// What about splitting it off the rest of the topic?
829
-		if ($context['can_split'] && !empty($context['real_num_replies']))
830
-			echo '
880
+		if ($context['can_split'] && !empty($context['real_num_replies'])) {
881
+					echo '
831 882
 											<li><a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '"><span class="generic_icons split_button"></span>', $txt['split'], '</a></li>';
883
+		}
832 884
 
833 885
 		// Can we issue a warning because of this post? Remember, we can't give guests warnings.
834
-		if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest'])
835
-			echo '
886
+		if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) {
887
+					echo '
836 888
 											<li><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '"><span class="generic_icons warn_button"></span>', $txt['issue_warning'], '</a></li>';
889
+		}
837 890
 
838 891
 		// Can we restore topics?
839
-		if ($context['can_restore_msg'])
840
-			echo '
892
+		if ($context['can_restore_msg']) {
893
+					echo '
841 894
 											<li><a href="', $scripturl, '?action=restoretopic;msgs=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons restore_button"></span>', $txt['restore_message'], '</a></li>';
895
+		}
842 896
 
843 897
 		// Maybe we can approve it, maybe we should?
844
-		if ($message['can_approve'])
845
-			echo '
898
+		if ($message['can_approve']) {
899
+					echo '
846 900
 											<li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons approve_button"></span>', $txt['approve'], '</a></li>';
901
+		}
847 902
 
848 903
 		// Maybe we can unapprove it?
849
-		if ($message['can_unapprove'])
850
-			echo '
904
+		if ($message['can_unapprove']) {
905
+					echo '
851 906
 											<li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons unapprove_button"></span>', $txt['unapprove'], '</a></li>';
907
+		}
852 908
 
853 909
 		echo '
854 910
 										</ul>
855 911
 									</li>';
856 912
 
857 913
 		// Show a checkbox for quick moderation?
858
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove'])
859
-			echo '
914
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) {
915
+					echo '
860 916
 									<li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>';
917
+		}
861 918
 
862
-		if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
863
-			echo '
919
+		if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) {
920
+					echo '
864 921
 								</ul>';
922
+		}
865 923
 	}
866 924
 
867
-	if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote'])
868
-	echo '
925
+	if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) {
926
+		echo '
869 927
 							</div>';
928
+	}
870 929
 
871 930
 	echo '
872 931
 						</div>
@@ -879,9 +938,10 @@  discard block
 block discarded – undo
879 938
 							<div class="custom_fields_above_signature">
880 939
 								<ul class="nolist">';
881 940
 
882
-		foreach ($message['custom_fields']['above_signature'] as $custom)
883
-			echo '
941
+		foreach ($message['custom_fields']['above_signature'] as $custom) {
942
+					echo '
884 943
 									<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
944
+		}
885 945
 
886 946
 		echo '
887 947
 								</ul>
@@ -889,9 +949,10 @@  discard block
 block discarded – undo
889 949
 	}
890 950
 
891 951
 	// Show the member's signature?
892
-	if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
893
-		echo '
952
+	if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) {
953
+			echo '
894 954
 							<div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '>', $message['member']['signature'], '</div>';
955
+	}
895 956
 
896 957
 
897 958
 	// Are there any custom profile fields for below the signature?
@@ -901,9 +962,10 @@  discard block
 block discarded – undo
901 962
 							<div class="custom_fields_below_signature">
902 963
 								<ul class="nolist">';
903 964
 
904
-		foreach ($message['custom_fields']['below_signature'] as $custom)
905
-			echo '
965
+		foreach ($message['custom_fields']['below_signature'] as $custom) {
966
+					echo '
906 967
 									<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
968
+		}
907 969
 
908 970
 		echo '
909 971
 								</ul>
@@ -951,8 +1013,8 @@  discard block
 block discarded – undo
951 1013
 						<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">';
952 1014
 
953 1015
 		// Guests just need more.
954
-		if ($context['user']['is_guest'])
955
-			echo '
1016
+		if ($context['user']['is_guest']) {
1017
+					echo '
956 1018
 						<dl id="post_header">
957 1019
 							<dt>
958 1020
 								', $txt['name'], ':
@@ -967,6 +1029,7 @@  discard block
 block discarded – undo
967 1029
 								<input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" class="input_text" required>
968 1030
 							</dd>
969 1031
 						</dl>';
1032
+		}
970 1033
 
971 1034
 		echo '
972 1035
 						', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), '
@@ -1014,8 +1077,8 @@  discard block
 block discarded – undo
1014 1077
 		<br class="clear">';
1015 1078
 
1016 1079
 	// draft autosave available and the user has it enabled?
1017
-	if (!empty($context['drafts_autosave']))
1018
-		echo '
1080
+	if (!empty($context['drafts_autosave'])) {
1081
+			echo '
1019 1082
 			<script>
1020 1083
 				var oDraftAutoSave = new smf_DraftAutoSave({
1021 1084
 					sSelf: \'oDraftAutoSave\',
@@ -1027,10 +1090,12 @@  discard block
 block discarded – undo
1027 1090
 					iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), '
1028 1091
 				});
1029 1092
 			</script>';
1093
+	}
1030 1094
 
1031
-	if ($context['show_spellchecking'])
1032
-		echo '
1095
+	if ($context['show_spellchecking']) {
1096
+			echo '
1033 1097
 			<form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow"><input type="hidden" name="spellstring" value=""></form>';
1098
+	}
1034 1099
 
1035 1100
 	echo '
1036 1101
 				<script>
Please login to merge, or discard this patch.
Themes/default/index.template.php 1 patch
Braces   +87 added lines, -59 removed lines patch added patch discarded remove patch
@@ -72,9 +72,10 @@  discard block
 block discarded – undo
72 72
 
73 73
 	// Allow css/js files to be disable for this specific theme.
74 74
 	// Add the identifier as an array key. IE array('smf_script'); Some external files might not add identifiers, on those cases SMF uses its filename as reference.
75
-	if (!isset($settings['disable_files']))
76
-		$settings['disable_files'] = array();
77
-}
75
+	if (!isset($settings['disable_files'])) {
76
+			$settings['disable_files'] = array();
77
+	}
78
+	}
78 79
 
79 80
 /**
80 81
  * The main sub template above the content.
@@ -111,8 +112,9 @@  discard block
 block discarded – undo
111 112
 		echo '
112 113
 	<meta';
113 114
 
114
-		foreach ($meta_tag as $meta_key => $meta_value)
115
-			echo ' ', $meta_key, '="', $meta_value, '"';
115
+		foreach ($meta_tag as $meta_key => $meta_value) {
116
+					echo ' ', $meta_key, '="', $meta_value, '"';
117
+		}
116 118
 
117 119
 		echo '>';
118 120
 	}
@@ -123,14 +125,16 @@  discard block
 block discarded – undo
123 125
 	<meta name="theme-color" content="#557EA0">';
124 126
 
125 127
 	// Please don't index these Mr Robot.
126
-	if (!empty($context['robot_no_index']))
127
-		echo '
128
+	if (!empty($context['robot_no_index'])) {
129
+			echo '
128 130
 	<meta name="robots" content="noindex">';
131
+	}
129 132
 
130 133
 	// Present a canonical url for search engines to prevent duplicate content in their indices.
131
-	if (!empty($context['canonical_url']))
132
-		echo '
134
+	if (!empty($context['canonical_url'])) {
135
+			echo '
133 136
 	<link rel="canonical" href="', $context['canonical_url'], '">';
137
+	}
134 138
 
135 139
 	// Show all the relative links, such as help, search, contents, and the like.
136 140
 	echo '
@@ -139,10 +143,11 @@  discard block
 block discarded – undo
139 143
 	<link rel="search" href="' . $scripturl . '?action=search">' : '');
140 144
 
141 145
 	// If RSS feeds are enabled, advertise the presence of one.
142
-	if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged']))
143
-		echo '
146
+	if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) {
147
+			echo '
144 148
 	<link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?type=rss2;action=.xml">
145 149
 	<link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['atom'], '" href="', $scripturl, '?type=atom;action=.xml">';
150
+	}
146 151
 
147 152
 	// If we're viewing a topic, these should be the previous and next topics, respectively.
148 153
 	if (!empty($context['links']['next']))
@@ -158,9 +163,10 @@  discard block
 block discarded – undo
158 163
 	}
159 164
 
160 165
 	// If we're in a board, or a topic for that matter, the index will be the board's index.
161
-	if (!empty($context['current_board']))
162
-		echo '
166
+	if (!empty($context['current_board'])) {
167
+			echo '
163 168
 	<link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0">';
169
+	}
164 170
 
165 171
 	// Output any remaining HTML headers. (from mods, maybe?)
166 172
 	echo $context['html_headers'];
@@ -191,8 +197,9 @@  discard block
 block discarded – undo
191 197
 		<ul class="floatleft" id="top_info">
192 198
 			<li>
193 199
 				<a href="', $scripturl, '?action=profile"', !empty($context['self_profile']) ? ' class="active"' : '', ' id="profile_menu_top" onclick="return false;">';
194
-					if (!empty($context['user']['avatar']))
195
-						echo $context['user']['avatar']['image'];
200
+					if (!empty($context['user']['avatar'])) {
201
+											echo $context['user']['avatar']['image'];
202
+					}
196 203
 					echo $context['user']['name'], '</a>
197 204
 				<div id="profile_menu" class="top_menu"></div>
198 205
 			</li>';
@@ -219,11 +226,12 @@  discard block
 block discarded – undo
219 226
 		</ul>';
220 227
 	}
221 228
 	// Otherwise they're a guest. Ask them to either register or login.
222
-	else
223
-		echo '
229
+	else {
230
+			echo '
224 231
 		<ul class="floatleft welcome">
225 232
 			<li>', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'), '</li>
226 233
 		</ul>';
234
+	}
227 235
 
228 236
 	if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1)
229 237
 	{
@@ -231,9 +239,10 @@  discard block
 block discarded – undo
231 239
 		<form id="languages_form" method="get" class="floatright">
232 240
 			<select id="language_select" name="language" onchange="this.form.submit()">';
233 241
 
234
-		foreach ($context['languages'] as $language)
235
-			echo '
242
+		foreach ($context['languages'] as $language) {
243
+					echo '
236 244
 				<option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', str_replace('-utf8', '', $language['name']), '</option>';
245
+		}
237 246
 
238 247
 		echo '
239 248
 			</select>
@@ -257,31 +266,36 @@  discard block
 block discarded – undo
257 266
 				<option value="all"', ($selected == 'all' ? ' selected' : ''), '>', $txt['search_entireforum'], ' </option>';
258 267
 
259 268
 		// Can't limit it to a specific topic if we are not in one
260
-		if (!empty($context['current_topic']))
261
-			echo '
269
+		if (!empty($context['current_topic'])) {
270
+					echo '
262 271
 				<option value="topic"', ($selected == 'current_topic' ? ' selected' : ''), '>', $txt['search_thistopic'], '</option>';
272
+		}
263 273
 
264 274
 		// Can't limit it to a specific board if we are not in one
265
-		if (!empty($context['current_board']))
266
-			echo '
275
+		if (!empty($context['current_board'])) {
276
+					echo '
267 277
 				<option value="board"', ($selected == 'current_board' ? ' selected' : ''), '>', $txt['search_thisbrd'], '</option>';
278
+		}
268 279
 		
269 280
 		// Can't search for members if we can't see the memberlist
270
-		if (!empty($context['allow_memberlist']))
271
-			echo '
281
+		if (!empty($context['allow_memberlist'])) {
282
+					echo '
272 283
 				<option value="members"', ($selected == 'members' ? ' selected' : ''), '>', $txt['search_members'], ' </option>';
284
+		}
273 285
 				
274 286
 		echo '
275 287
 			</select>';
276 288
 
277 289
 		// Search within current topic?
278
-		if (!empty($context['current_topic']))
279
-			echo '
290
+		if (!empty($context['current_topic'])) {
291
+					echo '
280 292
 			<input type="hidden" name="sd_topic" value="', $context['current_topic'], '">';
293
+		}
281 294
 		// If we're on a certain board, limit it to this board ;).
282
-		elseif (!empty($context['current_board']))
283
-			echo '
295
+		elseif (!empty($context['current_board'])) {
296
+					echo '
284 297
 			<input type="hidden" name="sd_brd" value="', $context['current_board'], '">';
298
+		}
285 299
 
286 300
 		echo '
287 301
 			<input type="submit" name="search2" value="', $txt['search'], '" class="button_submit">
@@ -311,12 +325,13 @@  discard block
 block discarded – undo
311 325
 						', $context['current_time'], '
312 326
 					</div>';
313 327
 	// Show a random news item? (or you could pick one from news_lines...)
314
-	if (!empty($settings['enable_news']) && !empty($context['random_news_line']))
315
-		echo '
328
+	if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) {
329
+			echo '
316 330
 					<div class="news">
317 331
 						<h2>', $txt['news'], ': </h2>
318 332
 						<p>', $context['random_news_line'], '</p>
319 333
 					</div>';
334
+	}
320 335
 
321 336
 	echo '
322 337
 					<hr class="clear">
@@ -379,9 +394,10 @@  discard block
 block discarded – undo
379 394
 		</ul>';
380 395
 
381 396
 	// Show the load time?
382
-	if ($context['show_load_time'])
383
-		echo '
397
+	if ($context['show_load_time']) {
398
+			echo '
384 399
 		<p>', sprintf($txt['page_created_full'], $context['load_time'], $context['load_queries']), '</p>';
400
+	}
385 401
 
386 402
 	echo '
387 403
 	</div>';
@@ -411,19 +427,21 @@  discard block
 block discarded – undo
411 427
 	global $context, $shown_linktree, $scripturl, $txt;
412 428
 
413 429
 	// If linktree is empty, just return - also allow an override.
414
-	if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show))
415
-		return;
430
+	if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) {
431
+			return;
432
+	}
416 433
 
417 434
 	echo '
418 435
 				<div class="navigate_section">
419 436
 					<ul>';
420 437
 
421
-	if ($context['user']['is_logged'])
422
-	echo '
438
+	if ($context['user']['is_logged']) {
439
+		echo '
423 440
 						<li class="unread_links">
424 441
 							<a href="', $scripturl, '?action=unread" title="', $txt['unread_since_visit'], '">', $txt['view_unread_category'], '</a>
425 442
 							<a href="', $scripturl, '?action=unreadreplies" title="', $txt['show_unread_replies'], '">', $txt['unread_replies'], '</a>
426 443
 						</li>';
444
+	}
427 445
 
428 446
 	// Each tree item has a URL and name. Some may have extra_before and extra_after.
429 447
 	foreach ($context['linktree'] as $link_num => $tree)
@@ -434,25 +452,29 @@  discard block
 block discarded – undo
434 452
 		// Don't show a separator for the first one.
435 453
 		// Better here. Always points to the next level when the linktree breaks to a second line.
436 454
 		// Picked a better looking HTML entity, and added support for RTL plus a span for styling.
437
-		if ($link_num != 0)
438
-			echo '
455
+		if ($link_num != 0) {
456
+					echo '
439 457
 							<span class="dividers">', $context['right_to_left'] ? ' &#9668; ' : ' &#9658; ', '</span>';
458
+		}
440 459
 
441 460
 		// Show something before the link?
442
-		if (isset($tree['extra_before']))
443
-			echo $tree['extra_before'], ' ';
461
+		if (isset($tree['extra_before'])) {
462
+					echo $tree['extra_before'], ' ';
463
+		}
444 464
 
445 465
 		// Show the link, including a URL if it should have one.
446
-		if (isset($tree['url']))
447
-			echo '
466
+		if (isset($tree['url'])) {
467
+					echo '
448 468
 					<a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>';
449
-		else
450
-			echo '
469
+		} else {
470
+					echo '
451 471
 					<span>' . $tree['name'] . '</span>';
472
+		}
452 473
 
453 474
 		// Show something after the link...?
454
-		if (isset($tree['extra_after']))
455
-			echo ' ', $tree['extra_after'];
475
+		if (isset($tree['extra_after'])) {
476
+					echo ' ', $tree['extra_after'];
477
+		}
456 478
 
457 479
 		echo '
458 480
 						</li>';
@@ -502,13 +524,14 @@  discard block
 block discarded – undo
502 524
 					echo '
503 525
 									<ul>';
504 526
 
505
-					foreach ($childbutton['sub_buttons'] as $grandchildbutton)
506
-						echo '
527
+					foreach ($childbutton['sub_buttons'] as $grandchildbutton) {
528
+											echo '
507 529
 										<li>
508 530
 											<a href="', $grandchildbutton['href'], '"' , isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '>
509 531
 												', $grandchildbutton['title'], '
510 532
 											</a>
511 533
 										</li>';
534
+					}
512 535
 
513 536
 					echo '
514 537
 									</ul>';
@@ -539,8 +562,9 @@  discard block
 block discarded – undo
539 562
 {
540 563
 	global $context, $txt;
541 564
 
542
-	if (!is_array($strip_options))
543
-		$strip_options = array();
565
+	if (!is_array($strip_options)) {
566
+			$strip_options = array();
567
+	}
544 568
 
545 569
 	// Create the buttons...
546 570
 	$buttons = array();
@@ -549,8 +573,9 @@  discard block
 block discarded – undo
549 573
 		// As of 2.1, the 'test' for each button happens while the array is being generated. The extra 'test' check here is deprecated but kept for backward compatibility (update your mods, folks!)
550 574
 		if (!isset($value['test']) || !empty($context[$value['test']]))
551 575
 		{
552
-			if (!isset($value['id']))
553
-				$value['id'] = $key;
576
+			if (!isset($value['id'])) {
577
+							$value['id'] = $key;
578
+			}
554 579
 
555 580
 			$button = '
556 581
 				<a class="button button_strip_' . $key . (!empty($value['active']) ? ' active' : '') . (isset($value['class']) ? ' '. $value['class'] : '') . '" ' . (!empty($value['url']) ? 'href="'. $value['url'] .'"' : '') . ' ' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '>' . $txt[$value['text']] . '</a>';
@@ -563,13 +588,15 @@  discard block
 block discarded – undo
563 588
 							<div class="overview">';
564 589
 				foreach ($value['sub_buttons'] as $element)
565 590
 				{
566
-					if (isset($element['test']) && empty($context[$element['test']]))
567
-						continue;
591
+					if (isset($element['test']) && empty($context[$element['test']])) {
592
+											continue;
593
+					}
568 594
 
569 595
 					$button .= '
570 596
 								<a href="' . $element['url'] . '"><strong>' . $txt[$element['text']] . '</strong>';
571
-					if (isset($txt[$element['text'] . '_desc']))
572
-						$button .= '<br /><span>' . $txt[$element['text'] . '_desc'] . '</span>';
597
+					if (isset($txt[$element['text'] . '_desc'])) {
598
+											$button .= '<br /><span>' . $txt[$element['text'] . '_desc'] . '</span>';
599
+					}
573 600
 					$button .= '</a>';
574 601
 				}
575 602
 				$button .= '
@@ -583,8 +610,9 @@  discard block
 block discarded – undo
583 610
 	}
584 611
 
585 612
 	// No buttons? No button strip either.
586
-	if (empty($buttons))
587
-		return;
613
+	if (empty($buttons)) {
614
+			return;
615
+	}
588 616
 
589 617
 	echo '
590 618
 		<div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"': ''), '>
Please login to merge, or discard this patch.
Themes/default/Printpage.template.php 1 patch
Braces   +12 added lines, -9 removed lines patch added patch discarded remove patch
@@ -145,11 +145,12 @@  discard block
 block discarded – undo
145 145
 				<div class="question">', $txt['poll_question'], ': <strong>', $context['poll']['question'], '</strong>';
146 146
 
147 147
 		$options = 1;
148
-		foreach ($context['poll']['options'] as $option)
149
-			echo '
148
+		foreach ($context['poll']['options'] as $option) {
149
+					echo '
150 150
 					<div class="', $option['voted_this'] ? 'voted' : '', '">', $txt['option'], ' ', $options++, ': <strong>', $option['option'], '</strong>
151 151
 						', $context['allow_poll_view'] ? $txt['votes'] . ': ' . $option['votes'] . '' : '', '
152 152
 					</div>';
153
+		}
153 154
 
154 155
 		echo '
155 156
 			</div>';
@@ -171,9 +172,10 @@  discard block
 block discarded – undo
171 172
 			echo '
172 173
 				<hr>';
173 174
 
174
-			foreach ($context['printattach'][$post['id_msg']] as $attach)
175
-				echo '
175
+			foreach ($context['printattach'][$post['id_msg']] as $attach) {
176
+							echo '
176 177
 					<img width="' . $attach['width'] . '" height="' . $attach['height'] . '" src="', $scripturl . '?action=dlattach;topic=' . $topic . '.0;attach=' . $attach['id_attach'] . '" alt="">';
178
+			}
177 179
 		}
178 180
 
179 181
 		echo '
@@ -213,11 +215,12 @@  discard block
 block discarded – undo
213 215
 		<div class="print_options">';
214 216
 
215 217
 	// which option is set, text or text&images
216
-	if (isset($_REQUEST['images']))
217
-		echo '
218
+	if (isset($_REQUEST['images'])) {
219
+			echo '
218 220
 			<a href="', $url_text, '">', $txt['print_page_text'], '</a> | <strong><a href="', $url_images, '">', $txt['print_page_images'], '</a></strong>';
219
-	else
220
-		echo '
221
+	} else {
222
+			echo '
221 223
 			<strong><a href="', $url_text, '">', $txt['print_page_text'], '</a></strong> | <a href="', $url_images, '">', $txt['print_page_images'], '</a>';
222
-}
224
+	}
225
+	}
223 226
 ?>
224 227
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Subs-Db-mysql.php 1 patch
Braces   +225 added lines, -164 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  *  Maps the implementations in this file (smf_db_function_name)
@@ -33,8 +34,8 @@  discard block
 block discarded – undo
33 34
 	global $smcFunc, $mysql_set_mode;
34 35
 
35 36
 	// Map some database specific functions, only do this once.
36
-	if (!isset($smcFunc['db_fetch_assoc']) || $smcFunc['db_fetch_assoc'] != 'mysql_fetch_assoc')
37
-		$smcFunc += array(
37
+	if (!isset($smcFunc['db_fetch_assoc']) || $smcFunc['db_fetch_assoc'] != 'mysql_fetch_assoc') {
38
+			$smcFunc += array(
38 39
 			'db_query' => 'smf_db_query',
39 40
 			'db_quote' => 'smf_db_quote',
40 41
 			'db_fetch_assoc' => 'mysql_fetch_assoc',
@@ -58,36 +59,42 @@  discard block
 block discarded – undo
58 59
 			'db_escape_wildcard_string' => 'smf_db_escape_wildcard_string',
59 60
 			'db_is_resource' => 'is_resource',
60 61
 		);
62
+	}
61 63
 
62
-	if (!empty($db_options['port']))
63
-		$db_server .= ':' . $db_options['port'];
64
+	if (!empty($db_options['port'])) {
65
+			$db_server .= ':' . $db_options['port'];
66
+	}
64 67
 	
65 68
 	$flags = 2; //#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
66 69
 
67
-	if (!empty($db_options['persist']))
68
-		$connection = @mysql_pconnect($db_server, $db_user, $db_passwd, $flags);
69
-	else
70
-		$connection = @mysql_connect($db_server, $db_user, $db_passwd, false, $flags);
70
+	if (!empty($db_options['persist'])) {
71
+			$connection = @mysql_pconnect($db_server, $db_user, $db_passwd, $flags);
72
+	} else {
73
+			$connection = @mysql_connect($db_server, $db_user, $db_passwd, false, $flags);
74
+	}
71 75
 
72 76
 	// Something's wrong, show an error if its fatal (which we assume it is)
73 77
 	if (!$connection)
74 78
 	{
75
-		if (!empty($db_options['non_fatal']))
76
-			return null;
77
-		else
78
-			display_db_error();
79
+		if (!empty($db_options['non_fatal'])) {
80
+					return null;
81
+		} else {
82
+					display_db_error();
83
+		}
79 84
 	}
80 85
 
81 86
 	// Select the database, unless told not to
82
-	if (empty($db_options['dont_select_db']) && !@mysql_select_db($db_name, $connection) && empty($db_options['non_fatal']))
83
-		display_db_error();
87
+	if (empty($db_options['dont_select_db']) && !@mysql_select_db($db_name, $connection) && empty($db_options['non_fatal'])) {
88
+			display_db_error();
89
+	}
84 90
 
85 91
 	// This makes it possible to have SMF automatically change the sql_mode and autocommit if needed.
86
-	if (isset($mysql_set_mode) && $mysql_set_mode === true)
87
-		$smcFunc['db_query']('', 'SET sql_mode = \'\', AUTOCOMMIT = 1',
92
+	if (isset($mysql_set_mode) && $mysql_set_mode === true) {
93
+			$smcFunc['db_query']('', 'SET sql_mode = \'\', AUTOCOMMIT = 1',
88 94
 		array(),
89 95
 		false
90 96
 	);
97
+	}
91 98
 
92 99
 	return $connection;
93 100
 }
@@ -134,37 +141,46 @@  discard block
 block discarded – undo
134 141
 	list ($values, $connection) = $db_callback;
135 142
 
136 143
 	// Connection gone???  This should *never* happen at this point, yet it does :'(
137
-	if (!is_resource($connection))
138
-		display_db_error();
144
+	if (!is_resource($connection)) {
145
+			display_db_error();
146
+	}
139 147
 
140
-	if ($matches[1] === 'db_prefix')
141
-		return $db_prefix;
148
+	if ($matches[1] === 'db_prefix') {
149
+			return $db_prefix;
150
+	}
142 151
 
143
-	if ($matches[1] === 'query_see_board')
144
-		return $user_info['query_see_board'];
152
+	if ($matches[1] === 'query_see_board') {
153
+			return $user_info['query_see_board'];
154
+	}
145 155
 
146
-	if ($matches[1] === 'query_wanna_see_board')
147
-		return $user_info['query_wanna_see_board'];
156
+	if ($matches[1] === 'query_wanna_see_board') {
157
+			return $user_info['query_wanna_see_board'];
158
+	}
148 159
 
149
-	if ($matches[1] === 'empty')
150
-		return '\'\'';
160
+	if ($matches[1] === 'empty') {
161
+			return '\'\'';
162
+	}
151 163
 
152
-	if (!isset($matches[2]))
153
-		smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
164
+	if (!isset($matches[2])) {
165
+			smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
166
+	}
154 167
 
155
-	if ($matches[1] === 'literal')
156
-		return '\'' . mysql_real_escape_string($matches[2], $connection) . '\'';
168
+	if ($matches[1] === 'literal') {
169
+			return '\'' . mysql_real_escape_string($matches[2], $connection) . '\'';
170
+	}
157 171
 
158
-	if (!isset($values[$matches[2]]))
159
-		smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__);
172
+	if (!isset($values[$matches[2]])) {
173
+			smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__);
174
+	}
160 175
 
161 176
 	$replacement = $values[$matches[2]];
162 177
 
163 178
 	switch ($matches[1])
164 179
 	{
165 180
 		case 'int':
166
-			if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement)
167
-				smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
181
+			if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) {
182
+							smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
183
+			}
168 184
 			return (string) (int) $replacement;
169 185
 		break;
170 186
 
@@ -176,49 +192,55 @@  discard block
 block discarded – undo
176 192
 		case 'array_int':
177 193
 			if (is_array($replacement))
178 194
 			{
179
-				if (empty($replacement))
180
-					smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
195
+				if (empty($replacement)) {
196
+									smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
197
+				}
181 198
 
182 199
 				foreach ($replacement as $key => $value)
183 200
 				{
184
-					if (!is_numeric($value) || (string) $value !== (string) (int) $value)
185
-						smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
201
+					if (!is_numeric($value) || (string) $value !== (string) (int) $value) {
202
+											smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
203
+					}
186 204
 
187 205
 					$replacement[$key] = (string) (int) $value;
188 206
 				}
189 207
 
190 208
 				return implode(', ', $replacement);
209
+			} else {
210
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
191 211
 			}
192
-			else
193
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
194 212
 
195 213
 		break;
196 214
 
197 215
 		case 'array_string':
198 216
 			if (is_array($replacement))
199 217
 			{
200
-				if (empty($replacement))
201
-					smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
218
+				if (empty($replacement)) {
219
+									smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
220
+				}
202 221
 
203
-				foreach ($replacement as $key => $value)
204
-					$replacement[$key] = sprintf('\'%1$s\'', mysql_real_escape_string($value, $connection));
222
+				foreach ($replacement as $key => $value) {
223
+									$replacement[$key] = sprintf('\'%1$s\'', mysql_real_escape_string($value, $connection));
224
+				}
205 225
 
206 226
 				return implode(', ', $replacement);
227
+			} else {
228
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
207 229
 			}
208
-			else
209
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
210 230
 		break;
211 231
 
212 232
 		case 'date':
213
-			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1)
214
-				return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]);
215
-			else
216
-				smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
233
+			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) {
234
+							return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]);
235
+			} else {
236
+							smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
237
+			}
217 238
 		break;
218 239
 
219 240
 		case 'float':
220
-			if (!is_numeric($replacement))
221
-				smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
241
+			if (!is_numeric($replacement)) {
242
+							smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
243
+			}
222 244
 			return (string) (float) $replacement;
223 245
 		break;
224 246
 
@@ -232,10 +254,12 @@  discard block
 block discarded – undo
232 254
 		break;
233 255
 
234 256
 		case 'inet':
235
-			if ($replacement == 'null' || $replacement == '')
236
-				return 'null';
237
-			if (!isValidIP($replacement))
238
-				smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
257
+			if ($replacement == 'null' || $replacement == '') {
258
+							return 'null';
259
+			}
260
+			if (!isValidIP($replacement)) {
261
+							smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
262
+			}
239 263
 			//we don't use the native support of mysql > 5.6.2
240 264
 			return sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($replacement)));
241 265
 		break;
@@ -243,22 +267,25 @@  discard block
 block discarded – undo
243 267
 		case 'array_inet':
244 268
 			if (is_array($replacement))
245 269
 			{
246
-				if (empty($replacement))
247
-					smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
270
+				if (empty($replacement)) {
271
+									smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
272
+				}
248 273
 
249 274
 				foreach ($replacement as $key => $value)
250 275
 				{
251
-					if ($replacement == 'null' || $replacement == '')
252
-						$replacement[$key] = 'null';
253
-					if (!isValidIP($value))
254
-						smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
276
+					if ($replacement == 'null' || $replacement == '') {
277
+											$replacement[$key] = 'null';
278
+					}
279
+					if (!isValidIP($value)) {
280
+											smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
281
+					}
255 282
 					$replacement[$key] =  sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($value)));
256 283
 				}
257 284
 
258 285
 				return implode(', ', $replacement);
286
+			} else {
287
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
259 288
 			}
260
-			else
261
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
262 289
 		break;
263 290
 
264 291
 		default:
@@ -329,18 +356,20 @@  discard block
 block discarded – undo
329 356
 	// One more query....
330 357
 	$db_count = !isset($db_count) ? 1 : $db_count + 1;
331 358
 
332
-	if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override']))
333
-		smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__);
359
+	if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) {
360
+			smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__);
361
+	}
334 362
 
335 363
 	// Use "ORDER BY null" to prevent Mysql doing filesorts for Group By clauses without an Order By
336 364
 	if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string))
337 365
 	{
338 366
 		// Add before LIMIT
339
-		if ($pos = strpos($db_string, 'LIMIT '))
340
-			$db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string));
341
-		else
342
-			// Append it.
367
+		if ($pos = strpos($db_string, 'LIMIT ')) {
368
+					$db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string));
369
+		} else {
370
+					// Append it.
343 371
 			$db_string .= "\n\t\t\tORDER BY null";
372
+		}
344 373
 	}
345 374
 
346 375
 	if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false))
@@ -362,8 +391,9 @@  discard block
 block discarded – undo
362 391
 		list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__);
363 392
 
364 393
 		// Initialize $db_cache if not already initialized.
365
-		if (!isset($db_cache))
366
-			$db_cache = array();
394
+		if (!isset($db_cache)) {
395
+					$db_cache = array();
396
+		}
367 397
 
368 398
 		if (!empty($_SESSION['debug_redirect']))
369 399
 		{
@@ -389,17 +419,18 @@  discard block
 block discarded – undo
389 419
 		while (true)
390 420
 		{
391 421
 			$pos = strpos($db_string, '\'', $pos + 1);
392
-			if ($pos === false)
393
-				break;
422
+			if ($pos === false) {
423
+							break;
424
+			}
394 425
 			$clean .= substr($db_string, $old_pos, $pos - $old_pos);
395 426
 
396 427
 			while (true)
397 428
 			{
398 429
 				$pos1 = strpos($db_string, '\'', $pos + 1);
399 430
 				$pos2 = strpos($db_string, '\\', $pos + 1);
400
-				if ($pos1 === false)
401
-					break;
402
-				elseif ($pos2 == false || $pos2 > $pos1)
431
+				if ($pos1 === false) {
432
+									break;
433
+				} elseif ($pos2 == false || $pos2 > $pos1)
403 434
 				{
404 435
 					$pos = $pos1;
405 436
 					break;
@@ -415,29 +446,35 @@  discard block
 block discarded – undo
415 446
 		$clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean)));
416 447
 
417 448
 		// Comments?  We don't use comments in our queries, we leave 'em outside!
418
-		if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false)
419
-			$fail = true;
449
+		if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) {
450
+					$fail = true;
451
+		}
420 452
 		// Trying to change passwords, slow us down, or something?
421
-		elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0)
422
-			$fail = true;
423
-		elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0)
424
-			$fail = true;
453
+		elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) {
454
+					$fail = true;
455
+		} elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) {
456
+					$fail = true;
457
+		}
425 458
 
426
-		if (!empty($fail) && function_exists('log_error'))
427
-			smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__);
459
+		if (!empty($fail) && function_exists('log_error')) {
460
+					smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__);
461
+		}
428 462
 	}
429 463
 
430
-	if (empty($db_unbuffered))
431
-		$ret = @mysql_query($db_string, $connection);
432
-	else
433
-		$ret = @mysql_unbuffered_query($db_string, $connection);
464
+	if (empty($db_unbuffered)) {
465
+			$ret = @mysql_query($db_string, $connection);
466
+	} else {
467
+			$ret = @mysql_unbuffered_query($db_string, $connection);
468
+	}
434 469
 
435
-	if ($ret === false && empty($db_values['db_error_skip']))
436
-		$ret = smf_db_error($db_string, $connection);
470
+	if ($ret === false && empty($db_values['db_error_skip'])) {
471
+			$ret = smf_db_error($db_string, $connection);
472
+	}
437 473
 
438 474
 	// Debugging.
439
-	if (isset($db_show_debug) && $db_show_debug === true)
440
-		$db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
475
+	if (isset($db_show_debug) && $db_show_debug === true) {
476
+			$db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
477
+	}
441 478
 
442 479
 	return $ret;
443 480
 }
@@ -486,12 +523,13 @@  discard block
 block discarded – undo
486 523
 	// Decide which connection to use
487 524
 	$connection = $connection === null ? $db_connection : $connection;
488 525
 
489
-	if ($type == 'begin')
490
-		return @mysql_query('BEGIN', $connection);
491
-	elseif ($type == 'rollback')
492
-		return @mysql_query('ROLLBACK', $connection);
493
-	elseif ($type == 'commit')
494
-		return @mysql_query('COMMIT', $connection);
526
+	if ($type == 'begin') {
527
+			return @mysql_query('BEGIN', $connection);
528
+	} elseif ($type == 'rollback') {
529
+			return @mysql_query('ROLLBACK', $connection);
530
+	} elseif ($type == 'commit') {
531
+			return @mysql_query('COMMIT', $connection);
532
+	}
495 533
 
496 534
 	return false;
497 535
 }
@@ -531,8 +569,9 @@  discard block
 block discarded – undo
531 569
 	//    2013: Lost connection to server during query.
532 570
 
533 571
 	// Log the error.
534
-	if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error'))
535
-		log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line);
572
+	if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) {
573
+			log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line);
574
+	}
536 575
 
537 576
 	// Database error auto fixing ;).
538 577
 	if (function_exists('cache_get_data') && (!isset($modSettings['autoFixDatabase']) || $modSettings['autoFixDatabase'] == '1'))
@@ -541,8 +580,9 @@  discard block
 block discarded – undo
541 580
 		$old_cache = @$modSettings['cache_enable'];
542 581
 		$modSettings['cache_enable'] = '1';
543 582
 
544
-		if (($temp = cache_get_data('db_last_error', 600)) !== null)
545
-			$db_last_error = max(@$db_last_error, $temp);
583
+		if (($temp = cache_get_data('db_last_error', 600)) !== null) {
584
+					$db_last_error = max(@$db_last_error, $temp);
585
+		}
546 586
 
547 587
 		if (@$db_last_error < time() - 3600 * 24 * 3)
548 588
 		{
@@ -558,8 +598,9 @@  discard block
 block discarded – undo
558 598
 					foreach ($tables as $table)
559 599
 					{
560 600
 						// Now, it's still theoretically possible this could be an injection.  So backtick it!
561
-						if (trim($table) != '')
562
-							$fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`';
601
+						if (trim($table) != '') {
602
+													$fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`';
603
+						}
563 604
 					}
564 605
 				}
565 606
 
@@ -568,8 +609,9 @@  discard block
 block discarded – undo
568 609
 			// Table crashed.  Let's try to fix it.
569 610
 			elseif ($query_errno == 1016)
570 611
 			{
571
-				if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0)
572
-					$fix_tables = array('`' . $match[1] . '`');
612
+				if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) {
613
+									$fix_tables = array('`' . $match[1] . '`');
614
+				}
573 615
 			}
574 616
 			// Indexes crashed.  Should be easy to fix!
575 617
 			elseif ($query_errno == 1034 || $query_errno == 1035)
@@ -588,13 +630,15 @@  discard block
 block discarded – undo
588 630
 
589 631
 			// Make a note of the REPAIR...
590 632
 			cache_put_data('db_last_error', time(), 600);
591
-			if (($temp = cache_get_data('db_last_error', 600)) === null)
592
-				updateSettingsFile(array('db_last_error' => time()));
633
+			if (($temp = cache_get_data('db_last_error', 600)) === null) {
634
+							updateSettingsFile(array('db_last_error' => time()));
635
+			}
593 636
 
594 637
 			// Attempt to find and repair the broken table.
595
-			foreach ($fix_tables as $table)
596
-				$smcFunc['db_query']('', "
638
+			foreach ($fix_tables as $table) {
639
+							$smcFunc['db_query']('', "
597 640
 					REPAIR TABLE $table", false, false);
641
+			}
598 642
 
599 643
 			// And send off an email!
600 644
 			sendmail($webmaster_email, $txt['database_error'], $txt['tried_to_repair'], null, 'dberror');
@@ -603,11 +647,12 @@  discard block
 block discarded – undo
603 647
 
604 648
 			// Try the query again...?
605 649
 			$ret = $smcFunc['db_query']('', $db_string, false, false);
606
-			if ($ret !== false)
607
-				return $ret;
650
+			if ($ret !== false) {
651
+							return $ret;
652
+			}
653
+		} else {
654
+					$modSettings['cache_enable'] = $old_cache;
608 655
 		}
609
-		else
610
-			$modSettings['cache_enable'] = $old_cache;
611 656
 
612 657
 		// Check for the "lost connection" or "deadlock found" errors - and try it just one more time.
613 658
 		if (in_array($query_errno, array(1205, 1213, 2006, 2013)))
@@ -617,22 +662,25 @@  discard block
 block discarded – undo
617 662
 				// Are we in SSI mode?  If so try that username and password first
618 663
 				if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
619 664
 				{
620
-					if (empty($db_persist))
621
-						$db_connection = @mysql_connect($db_server, $ssi_db_user, $ssi_db_passwd);
622
-					else
623
-						$db_connection = @mysql_pconnect($db_server, $ssi_db_user, $ssi_db_passwd);
665
+					if (empty($db_persist)) {
666
+											$db_connection = @mysql_connect($db_server, $ssi_db_user, $ssi_db_passwd);
667
+					} else {
668
+											$db_connection = @mysql_pconnect($db_server, $ssi_db_user, $ssi_db_passwd);
669
+					}
624 670
 				}
625 671
 				// Fall back to the regular username and password if need be
626 672
 				if (!$db_connection)
627 673
 				{
628
-					if (empty($db_persist))
629
-						$db_connection = @mysql_connect($db_server, $db_user, $db_passwd);
630
-					else
631
-						$db_connection = @mysql_pconnect($db_server, $db_user, $db_passwd);
674
+					if (empty($db_persist)) {
675
+											$db_connection = @mysql_connect($db_server, $db_user, $db_passwd);
676
+					} else {
677
+											$db_connection = @mysql_pconnect($db_server, $db_user, $db_passwd);
678
+					}
632 679
 				}
633 680
 
634
-				if (!$db_connection || !@mysql_select_db($db_name, $db_connection))
635
-					$db_connection = false;
681
+				if (!$db_connection || !@mysql_select_db($db_name, $db_connection)) {
682
+									$db_connection = false;
683
+				}
636 684
 			}
637 685
 
638 686
 			if ($db_connection)
@@ -643,24 +691,27 @@  discard block
 block discarded – undo
643 691
 					$ret = $smcFunc['db_query']('', $db_string, false, false);
644 692
 
645 693
 					$new_errno = mysql_errno($db_connection);
646
-					if ($ret !== false || in_array($new_errno, array(1205, 1213)))
647
-						break;
694
+					if ($ret !== false || in_array($new_errno, array(1205, 1213))) {
695
+											break;
696
+					}
648 697
 				}
649 698
 
650 699
 				// If it failed again, shucks to be you... we're not trying it over and over.
651
-				if ($ret !== false)
652
-					return $ret;
700
+				if ($ret !== false) {
701
+									return $ret;
702
+				}
653 703
 			}
654 704
 		}
655 705
 		// Are they out of space, perhaps?
656 706
 		elseif ($query_errno == 1030 && (strpos($query_error, ' -1 ') !== false || strpos($query_error, ' 28 ') !== false || strpos($query_error, ' 12 ') !== false))
657 707
 		{
658
-			if (!isset($txt))
659
-				$query_error .= ' - check database storage space.';
660
-			else
708
+			if (!isset($txt)) {
709
+							$query_error .= ' - check database storage space.';
710
+			} else
661 711
 			{
662
-				if (!isset($txt['mysql_error_space']))
663
-					loadLanguage('Errors');
712
+				if (!isset($txt['mysql_error_space'])) {
713
+									loadLanguage('Errors');
714
+				}
664 715
 
665 716
 				$query_error .= !isset($txt['mysql_error_space']) ? ' - check database storage space.' : $txt['mysql_error_space'];
666 717
 			}
@@ -668,15 +719,17 @@  discard block
 block discarded – undo
668 719
 	}
669 720
 
670 721
 	// Nothing's defined yet... just die with it.
671
-	if (empty($context) || empty($txt))
672
-		die($query_error);
722
+	if (empty($context) || empty($txt)) {
723
+			die($query_error);
724
+	}
673 725
 
674 726
 	// Show an error message, if possible.
675 727
 	$context['error_title'] = $txt['database_error'];
676
-	if (allowedTo('admin_forum'))
677
-		$context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line;
678
-	else
679
-		$context['error_message'] = $txt['try_again'];
728
+	if (allowedTo('admin_forum')) {
729
+			$context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line;
730
+	} else {
731
+			$context['error_message'] = $txt['try_again'];
732
+	}
680 733
 
681 734
 	if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true)
682 735
 	{
@@ -705,25 +758,28 @@  discard block
 block discarded – undo
705 758
 	$connection = $connection === null ? $db_connection : $connection;
706 759
 
707 760
 	// With nothing to insert, simply return.
708
-	if (empty($data))
709
-		return;
761
+	if (empty($data)) {
762
+			return;
763
+	}
710 764
 
711 765
 	// Replace the prefix holder with the actual prefix.
712 766
 	$table = str_replace('{db_prefix}', $db_prefix, $table);
713 767
 
714 768
 	// Inserting data as a single row can be done as a single array.
715
-	if (!is_array($data[array_rand($data)]))
716
-		$data = array($data);
769
+	if (!is_array($data[array_rand($data)])) {
770
+			$data = array($data);
771
+	}
717 772
 
718 773
 	// Create the mold for a single row insert.
719 774
 	$insertData = '(';
720 775
 	foreach ($columns as $columnName => $type)
721 776
 	{
722 777
 		// Are we restricting the length?
723
-		if (strpos($type, 'string-') !== false)
724
-			$insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
725
-		else
726
-			$insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName);
778
+		if (strpos($type, 'string-') !== false) {
779
+					$insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
780
+		} else {
781
+					$insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName);
782
+		}
727 783
 	}
728 784
 	$insertData = substr($insertData, 0, -2) . ')';
729 785
 
@@ -732,8 +788,9 @@  discard block
 block discarded – undo
732 788
 
733 789
 	// Here's where the variables are injected to the query.
734 790
 	$insertRows = array();
735
-	foreach ($data as $dataRow)
736
-		$insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection);
791
+	foreach ($data as $dataRow) {
792
+			$insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection);
793
+	}
737 794
 
738 795
 	// Determine the method of insertion.
739 796
 	$queryTitle = $method == 'replace' ? 'REPLACE' : ($method == 'ignore' ? 'INSERT IGNORE' : 'INSERT');
@@ -764,8 +821,9 @@  discard block
 block discarded – undo
764 821
  */
765 822
 function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null)
766 823
 {
767
-	if (empty($log_message))
768
-		$log_message = $error_message;
824
+	if (empty($log_message)) {
825
+			$log_message = $error_message;
826
+	}
769 827
 
770 828
 	foreach (debug_backtrace() as $step)
771 829
 	{
@@ -784,12 +842,14 @@  discard block
 block discarded – undo
784 842
 	}
785 843
 
786 844
 	// A special case - we want the file and line numbers for debugging.
787
-	if ($error_type == 'return')
788
-		return array($file, $line);
845
+	if ($error_type == 'return') {
846
+			return array($file, $line);
847
+	}
789 848
 
790 849
 	// Is always a critical error.
791
-	if (function_exists('log_error'))
792
-		log_error($log_message, 'critical', $file, $line);
850
+	if (function_exists('log_error')) {
851
+			log_error($log_message, 'critical', $file, $line);
852
+	}
793 853
 
794 854
 	if (function_exists('fatal_error'))
795 855
 	{
@@ -797,12 +857,12 @@  discard block
 block discarded – undo
797 857
 
798 858
 		// Cannot continue...
799 859
 		exit;
860
+	} elseif ($error_type) {
861
+			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
862
+	} else {
863
+			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
864
+	}
800 865
 	}
801
-	elseif ($error_type)
802
-		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
803
-	else
804
-		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
805
-}
806 866
 
807 867
 /**
808 868
  * Escape the LIKE wildcards so that they match the character and not the wildcard.
@@ -819,10 +879,11 @@  discard block
 block discarded – undo
819 879
 		'\\' => '\\\\',
820 880
 	);
821 881
 
822
-	if ($translate_human_wildcards)
823
-		$replacements += array(
882
+	if ($translate_human_wildcards) {
883
+			$replacements += array(
824 884
 			'*' => '%',
825 885
 		);
886
+	}
826 887
 
827 888
 	return strtr($string, $replacements);
828 889
 }
Please login to merge, or discard this patch.
Sources/Memberlist.php 1 patch
Braces   +78 added lines, -61 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
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
  * Shows a listing of registered members.
@@ -110,8 +111,9 @@  discard block
 block discarded – undo
110 111
 
111 112
 	$context['custom_profile_fields'] = getCustFieldsMList();
112 113
 
113
-	if (!empty($context['custom_profile_fields']['columns']))
114
-		$context['columns'] += $context['custom_profile_fields']['columns'];
114
+	if (!empty($context['custom_profile_fields']['columns'])) {
115
+			$context['columns'] += $context['custom_profile_fields']['columns'];
116
+	}
115 117
 
116 118
 	$context['colspan'] = 0;
117 119
 	$context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array();
@@ -147,12 +149,12 @@  discard block
 block discarded – undo
147 149
 	call_integration_hook('integrate_memberlist_buttons');
148 150
 
149 151
 	// Jump to the sub action.
150
-	if (isset($subActions[$context['listing_by']]))
151
-		call_helper($subActions[$context['listing_by']][1]);
152
-
153
-	else
154
-		call_helper($subActions['all'][1]);
155
-}
152
+	if (isset($subActions[$context['listing_by']])) {
153
+			call_helper($subActions[$context['listing_by']][1]);
154
+	} else {
155
+			call_helper($subActions['all'][1]);
156
+	}
157
+	}
156 158
 
157 159
 /**
158 160
  * List all members, page by page, with sorting.
@@ -177,8 +179,9 @@  discard block
 block discarded – undo
177 179
 	if ($use_cache)
178 180
 	{
179 181
 		// Maybe there's something cached already.
180
-		if (!empty($modSettings['memberlist_cache']))
181
-			$memberlist_cache = smf_json_decode($modSettings['memberlist_cache'], true);
182
+		if (!empty($modSettings['memberlist_cache'])) {
183
+					$memberlist_cache = smf_json_decode($modSettings['memberlist_cache'], true);
184
+		}
182 185
 
183 186
 		// The chunk size for the cached index.
184 187
 		$cache_step_size = 500;
@@ -234,13 +237,15 @@  discard block
 block discarded – undo
234 237
 	}
235 238
 
236 239
 	// Set defaults for sort (real_name) and start. (0)
237
-	if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']]))
238
-		$_REQUEST['sort'] = 'real_name';
240
+	if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) {
241
+			$_REQUEST['sort'] = 'real_name';
242
+	}
239 243
 
240 244
 	if (!is_numeric($_REQUEST['start']))
241 245
 	{
242
-		if (preg_match('~^[^\'\\\\/]~' . ($context['utf8'] ? 'u' : ''), $smcFunc['strtolower']($_REQUEST['start']), $match) === 0)
243
-			fatal_error('Hacker?', false);
246
+		if (preg_match('~^[^\'\\\\/]~' . ($context['utf8'] ? 'u' : ''), $smcFunc['strtolower']($_REQUEST['start']), $match) === 0) {
247
+					fatal_error('Hacker?', false);
248
+		}
244 249
 
245 250
 		$_REQUEST['start'] = $match[0];
246 251
 
@@ -259,16 +264,18 @@  discard block
 block discarded – undo
259 264
 	}
260 265
 
261 266
 	$context['letter_links'] = '';
262
-	for ($i = 97; $i < 123; $i++)
263
-		$context['letter_links'] .= '<a href="' . $scripturl . '?action=mlist;sa=all;start=' . chr($i) . '#letter' . chr($i) . '">' . strtoupper(chr($i)) . '</a> ';
267
+	for ($i = 97; $i < 123; $i++) {
268
+			$context['letter_links'] .= '<a href="' . $scripturl . '?action=mlist;sa=all;start=' . chr($i) . '#letter' . chr($i) . '">' . strtoupper(chr($i)) . '</a> ';
269
+	}
264 270
 
265 271
 	// Sort out the column information.
266 272
 	foreach ($context['columns'] as $col => $column_details)
267 273
 	{
268 274
 		$context['columns'][$col]['href'] = $scripturl . '?action=mlist;sort=' . $col . ';start=0';
269 275
 
270
-		if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev'])))
271
-			$context['columns'][$col]['href'] .= ';desc';
276
+		if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) {
277
+					$context['columns'][$col]['href'] .= ';desc';
278
+		}
272 279
 
273 280
 		$context['columns'][$col]['link'] = '<a href="' . $context['columns'][$col]['href'] . '" rel="nofollow">' . $context['columns'][$col]['label'] . '</a>';
274 281
 		$context['columns'][$col]['selected'] = $_REQUEST['sort'] == $col;
@@ -317,8 +324,9 @@  discard block
 block discarded – undo
317 324
 	elseif ($use_cache && $_REQUEST['sort'] === 'real_name')
318 325
 	{
319 326
 		$first_offset = floor(($memberlist_cache['num_members'] - $modSettings['defaultMaxMembers'] - $_REQUEST['start']) / $cache_step_size) * $cache_step_size;
320
-		if ($first_offset < 0)
321
-			$first_offset = 0;
327
+		if ($first_offset < 0) {
328
+					$first_offset = 0;
329
+		}
322 330
 		$second_offset = ceil(($memberlist_cache['num_members'] - $_REQUEST['start']) / $cache_step_size) * $cache_step_size;
323 331
 
324 332
 		$where = 'mem.real_name BETWEEN {string:real_name_low} AND {string:real_name_high}';
@@ -395,12 +403,13 @@  discard block
 block discarded – undo
395 403
 		)
396 404
 	);
397 405
 	$context['custom_search_fields'] = array();
398
-	while ($row = $smcFunc['db_fetch_assoc']($request))
399
-		$context['custom_search_fields'][$row['col_name']] = array(
406
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
407
+			$context['custom_search_fields'][$row['col_name']] = array(
400 408
 			'colname' => $row['col_name'],
401 409
 			'name' => $row['field_name'],
402 410
 			'desc' => $row['field_desc'],
403 411
 		);
412
+	}
404 413
 	$smcFunc['db_free_result']($request);
405 414
 
406 415
 	// They're searching..
@@ -413,23 +422,27 @@  discard block
 block discarded – undo
413 422
 		$context['old_search_value'] = urlencode($_REQUEST['search']);
414 423
 
415 424
 		// No fields?  Use default...
416
-		if (empty($_POST['fields']))
417
-			$_POST['fields'] = array('name');
425
+		if (empty($_POST['fields'])) {
426
+					$_POST['fields'] = array('name');
427
+		}
418 428
 
419 429
 		// Set defaults for how the results are sorted
420
-		if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']]))
421
-			$_REQUEST['sort'] = 'real_name';
430
+		if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) {
431
+					$_REQUEST['sort'] = 'real_name';
432
+		}
422 433
 
423 434
 		// Build the column link / sort information.
424 435
 		foreach ($context['columns'] as $col => $column_details)
425 436
 		{
426 437
 			$context['columns'][$col]['href'] = $scripturl . '?action=mlist;sa=search;start=0;sort=' . $col;
427 438
 
428
-			if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev'])))
429
-				$context['columns'][$col]['href'] .= ';desc';
439
+			if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) {
440
+							$context['columns'][$col]['href'] .= ';desc';
441
+			}
430 442
 
431
-			if (isset($_POST['search']) && isset($_POST['fields']))
432
-				$context['columns'][$col]['href'] .= ';search=' . $_POST['search'] . ';fields=' . implode(',', $_POST['fields']);
443
+			if (isset($_POST['search']) && isset($_POST['fields'])) {
444
+							$context['columns'][$col]['href'] .= ';search=' . $_POST['search'] . ';fields=' . implode(',', $_POST['fields']);
445
+			}
433 446
 
434 447
 			$context['columns'][$col]['link'] = '<a href="' . $context['columns'][$col]['href'] . '" rel="nofollow">' . $context['columns'][$col]['label'] . '</a>';
435 448
 			$context['columns'][$col]['selected'] = $_REQUEST['sort'] == $col;
@@ -452,8 +465,7 @@  discard block
 block discarded – undo
452 465
 		{
453 466
 			$fields = allowedTo('moderate_forum') ? array('member_name', 'real_name') : array('real_name');
454 467
 			$search_fields[] = 'name';
455
-		}
456
-		else
468
+		} else
457 469
 		{
458 470
 			$fields = array();
459 471
 			$search_fields = array();
@@ -478,9 +490,10 @@  discard block
 block discarded – undo
478 490
 			$search_fields[] = 'email';
479 491
 		}
480 492
 
481
-		if ($smcFunc['db_case_sensitive'])
482
-			foreach ($fields as $key => $field)
493
+		if ($smcFunc['db_case_sensitive']) {
494
+					foreach ($fields as $key => $field)
483 495
 				$fields[$key] = 'LOWER(' . $field . ')';
496
+		}
484 497
 
485 498
 		$customJoin = array();
486 499
 		$customCount = 10;
@@ -499,8 +512,9 @@  discard block
 block discarded – undo
499 512
 		}
500 513
 
501 514
 		// No search fields? That means you're trying to hack things
502
-		if (empty($search_fields))
503
-			fatal_lang_error('invalid_search_string', false);
515
+		if (empty($search_fields)) {
516
+					fatal_lang_error('invalid_search_string', false);
517
+		}
504 518
 
505 519
 		$query = $_POST['search'] == '' ? '= {string:blank_string}' : ($smcFunc['db_case_sensitive'] ? 'LIKE LOWER({string:search})' : 'LIKE {string:search}');
506 520
 
@@ -538,8 +552,7 @@  discard block
 block discarded – undo
538 552
 		);
539 553
 		printMemberListRows($request);
540 554
 		$smcFunc['db_free_result']($request);
541
-	}
542
-	else
555
+	} else
543 556
 	{
544 557
 		// These are all the possible fields.
545 558
 		$context['search_fields'] = array(
@@ -554,14 +567,14 @@  discard block
 block discarded – undo
554 567
 		{
555 568
 			unset($context['search_fields']['email']);
556 569
 			$context['search_defaults'] = array('name');
557
-		}
558
-		else
570
+		} else
559 571
 		{
560 572
 			$context['search_defaults'] = array('name', 'email');
561 573
 		}
562 574
 
563
-		foreach ($context['custom_search_fields'] as $field)
564
-			$context['search_fields']['cust_' . $field['colname']] = sprintf($txt['mlist_search_by'], $field['name']);
575
+		foreach ($context['custom_search_fields'] as $field) {
576
+					$context['search_fields']['cust_' . $field['colname']] = sprintf($txt['mlist_search_by'], $field['name']);
577
+		}
565 578
 
566 579
 		$context['sub_template'] = 'search';
567 580
 		$context['old_search'] = isset($_GET['search']) ? $_GET['search'] : (isset($_POST['search']) ? $smcFunc['htmlspecialchars']($_POST['search']) : '');
@@ -603,12 +616,14 @@  discard block
 block discarded – undo
603 616
 	$smcFunc['db_free_result']($result);
604 617
 
605 618
 	// Avoid division by zero...
606
-	if ($most_posts == 0)
607
-		$most_posts = 1;
619
+	if ($most_posts == 0) {
620
+			$most_posts = 1;
621
+	}
608 622
 
609 623
 	$members = array();
610
-	while ($row = $smcFunc['db_fetch_assoc']($request))
611
-		$members[] = $row['id_member'];
624
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
625
+			$members[] = $row['id_member'];
626
+	}
612 627
 
613 628
 	// Load all the members for display.
614 629
 	loadMemberData($members);
@@ -616,8 +631,9 @@  discard block
 block discarded – undo
616 631
 	$context['members'] = array();
617 632
 	foreach ($members as $member)
618 633
 	{
619
-		if (!loadMemberContext($member))
620
-			continue;
634
+		if (!loadMemberContext($member)) {
635
+					continue;
636
+		}
621 637
 
622 638
 		$context['members'][$member] = $memberContext[$member];
623 639
 		$context['members'][$member]['post_percent'] = round(($context['members'][$member]['real_posts'] * 100) / $most_posts);
@@ -634,20 +650,21 @@  discard block
 block discarded – undo
634 650
 					continue;
635 651
 				}
636 652
 
637
-				if ($column['bbc'] && !empty($context['members'][$member]['options'][$key]))
638
-					$context['members'][$member]['options'][$key] = strip_tags(parse_bbc($context['members'][$member]['options'][$key]));
639
-
640
-				elseif ($column['type'] == 'check')
641
-					$context['members'][$member]['options'][$key] = $context['members'][$member]['options'][$key] == 0 ? $txt['no'] : $txt['yes'];
653
+				if ($column['bbc'] && !empty($context['members'][$member]['options'][$key])) {
654
+									$context['members'][$member]['options'][$key] = strip_tags(parse_bbc($context['members'][$member]['options'][$key]));
655
+				} elseif ($column['type'] == 'check') {
656
+									$context['members'][$member]['options'][$key] = $context['members'][$member]['options'][$key] == 0 ? $txt['no'] : $txt['yes'];
657
+				}
642 658
 
643 659
 				// Enclosing the user input within some other text?
644
-				if (!empty($column['enclose']))
645
-					$context['members'][$member]['options'][$key] = strtr($column['enclose'], array(
660
+				if (!empty($column['enclose'])) {
661
+									$context['members'][$member]['options'][$key] = strtr($column['enclose'], array(
646 662
 						'{SCRIPTURL}' => $scripturl,
647 663
 						'{IMAGES_URL}' => $settings['images_url'],
648 664
 						'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
649 665
 						'{INPUT}' => $context['members'][$member]['options'][$key],
650 666
 					));
667
+				}
651 668
 			}
652 669
 		}
653 670
 	}
@@ -688,17 +705,17 @@  discard block
 block discarded – undo
688 705
 		);
689 706
 
690 707
 		// Get the right sort method depending on the cust field type.
691
-		if ($row['field_type'] != 'check')
692
-			$cpf['columns'][$row['col_name']]['sort'] = array(
708
+		if ($row['field_type'] != 'check') {
709
+					$cpf['columns'][$row['col_name']]['sort'] = array(
693 710
 				'down' => 'LENGTH(t' . $row['col_name'] . '.value) > 0 ASC, COALESCE(t' . $row['col_name'] . '.value, "") DESC',
694 711
 				'up' => 'LENGTH(t' . $row['col_name'] . '.value) > 0 DESC, COALESCE(t' . $row['col_name'] . '.value, "") ASC'
695 712
 			);
696
-
697
-		else
698
-			$cpf['columns'][$row['col_name']]['sort'] = array(
713
+		} else {
714
+					$cpf['columns'][$row['col_name']]['sort'] = array(
699 715
 				'down' => 't' . $row['col_name'] . '.value DESC',
700 716
 				'up' => 't' . $row['col_name'] . '.value ASC'
701 717
 			);
718
+		}
702 719
 
703 720
 		$cpf['join'][$row['col_name']] = 'LEFT JOIN {db_prefix}themes AS t' .  $row['col_name'] . ' ON (t' .  $row['col_name'] . '.variable = {literal:' .  $row['col_name'] . '} AND t' .  $row['col_name'] . '.id_theme = 1 AND t' .  $row['col_name'] . '.id_member = mem.id_member)';
704 721
 	}
Please login to merge, or discard this patch.
Sources/Logging.php 1 patch
Braces   +134 added lines, -96 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Put this user in the online log.
@@ -33,8 +34,9 @@  discard block
 block discarded – undo
33 34
 		// Don't update for every page - this isn't wholly accurate but who cares.
34 35
 		if ($topic)
35 36
 		{
36
-			if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic)
37
-				$force = false;
37
+			if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) {
38
+							$force = false;
39
+			}
38 40
 			$_SESSION['last_topic_id'] = $topic;
39 41
 		}
40 42
 	}
@@ -47,22 +49,24 @@  discard block
 block discarded – undo
47 49
 	}
48 50
 
49 51
 	// Don't mark them as online more than every so often.
50
-	if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force)
51
-		return;
52
+	if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) {
53
+			return;
54
+	}
52 55
 
53 56
 	if (!empty($modSettings['who_enabled']))
54 57
 	{
55 58
 		$serialized = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']);
56 59
 
57 60
 		// In the case of a dlattach action, session_var may not be set.
58
-		if (!isset($context['session_var']))
59
-			$context['session_var'] = $_SESSION['session_var'];
61
+		if (!isset($context['session_var'])) {
62
+					$context['session_var'] = $_SESSION['session_var'];
63
+		}
60 64
 
61 65
 		unset($serialized['sesc'], $serialized[$context['session_var']]);
62 66
 		$serialized = json_encode($serialized);
67
+	} else {
68
+			$serialized = '';
63 69
 	}
64
-	else
65
-		$serialized = '';
66 70
 
67 71
 	// Guests use 0, members use their session ID.
68 72
 	$session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id();
@@ -102,17 +106,18 @@  discard block
 block discarded – undo
102 106
 		);
103 107
 
104 108
 		// Guess it got deleted.
105
-		if ($smcFunc['db_affected_rows']() == 0)
109
+		if ($smcFunc['db_affected_rows']() == 0) {
110
+					$_SESSION['log_time'] = 0;
111
+		}
112
+	} else {
106 113
 			$_SESSION['log_time'] = 0;
107 114
 	}
108
-	else
109
-		$_SESSION['log_time'] = 0;
110 115
 
111 116
 	// Otherwise, we have to delete and insert.
112 117
 	if (empty($_SESSION['log_time']))
113 118
 	{
114
-		if ($do_delete || !empty($user_info['id']))
115
-			$smcFunc['db_query']('', '
119
+		if ($do_delete || !empty($user_info['id'])) {
120
+					$smcFunc['db_query']('', '
116 121
 				DELETE FROM {db_prefix}log_online
117 122
 				WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'),
118 123
 				array(
@@ -120,6 +125,7 @@  discard block
 block discarded – undo
120 125
 					'log_time' => time() - $modSettings['lastActive'] * 60,
121 126
 				)
122 127
 			);
128
+		}
123 129
 
124 130
 		$smcFunc['db_insert']($do_delete ? 'ignore' : 'replace',
125 131
 			'{db_prefix}log_online',
@@ -133,21 +139,24 @@  discard block
 block discarded – undo
133 139
 	$_SESSION['log_time'] = time();
134 140
 
135 141
 	// Well, they are online now.
136
-	if (empty($_SESSION['timeOnlineUpdated']))
137
-		$_SESSION['timeOnlineUpdated'] = time();
142
+	if (empty($_SESSION['timeOnlineUpdated'])) {
143
+			$_SESSION['timeOnlineUpdated'] = time();
144
+	}
138 145
 
139 146
 	// Set their login time, if not already done within the last minute.
140 147
 	if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa'))))
141 148
 	{
142 149
 		// Don't count longer than 15 minutes.
143
-		if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15)
144
-			$_SESSION['timeOnlineUpdated'] = time();
150
+		if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) {
151
+					$_SESSION['timeOnlineUpdated'] = time();
152
+		}
145 153
 
146 154
 		$user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated'];
147 155
 		updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in']));
148 156
 
149
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
150
-			cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60);
157
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
158
+					cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60);
159
+		}
151 160
 
152 161
 		$user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated'];
153 162
 		$_SESSION['timeOnlineUpdated'] = time();
@@ -184,8 +193,7 @@  discard block
 block discarded – undo
184 193
 			// Oops. maybe we have no more disk space left, or some other troubles, troubles...
185 194
 			// Copy the file back and run for your life!
186 195
 			@copy($boarddir . '/db_last_error_bak.php', $boarddir . '/db_last_error.php');
187
-		}
188
-		else
196
+		} else
189 197
 		{
190 198
 			@touch($boarddir . '/' . 'Settings.php');
191 199
 			return true;
@@ -205,22 +213,27 @@  discard block
 block discarded – undo
205 213
 	global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt;
206 214
 
207 215
 	// Add to Settings.php if you want to show the debugging information.
208
-	if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery'))
209
-		return;
216
+	if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) {
217
+			return;
218
+	}
210 219
 
211
-	if (empty($_SESSION['view_queries']))
212
-		$_SESSION['view_queries'] = 0;
213
-	if (empty($context['debug']['language_files']))
214
-		$context['debug']['language_files'] = array();
215
-	if (empty($context['debug']['sheets']))
216
-		$context['debug']['sheets'] = array();
220
+	if (empty($_SESSION['view_queries'])) {
221
+			$_SESSION['view_queries'] = 0;
222
+	}
223
+	if (empty($context['debug']['language_files'])) {
224
+			$context['debug']['language_files'] = array();
225
+	}
226
+	if (empty($context['debug']['sheets'])) {
227
+			$context['debug']['sheets'] = array();
228
+	}
217 229
 
218 230
 	$files = get_included_files();
219 231
 	$total_size = 0;
220 232
 	for ($i = 0, $n = count($files); $i < $n; $i++)
221 233
 	{
222
-		if (file_exists($files[$i]))
223
-			$total_size += filesize($files[$i]);
234
+		if (file_exists($files[$i])) {
235
+					$total_size += filesize($files[$i]);
236
+		}
224 237
 		$files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)'));
225 238
 	}
226 239
 
@@ -229,8 +242,9 @@  discard block
 block discarded – undo
229 242
 	{
230 243
 		foreach ($db_cache as $q => $qq)
231 244
 		{
232
-			if (!empty($qq['w']))
233
-				$warnings += count($qq['w']);
245
+			if (!empty($qq['w'])) {
246
+							$warnings += count($qq['w']);
247
+			}
234 248
 		}
235 249
 
236 250
 		$_SESSION['debug'] = &$db_cache;
@@ -251,12 +265,14 @@  discard block
 block discarded – undo
251 265
 	',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),'
252 266
 	', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>';
253 267
 
254
-	if (function_exists('memory_get_peak_usage'))
255
-		echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>';
268
+	if (function_exists('memory_get_peak_usage')) {
269
+			echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>';
270
+	}
256 271
 
257 272
 	// What tokens are active?
258
-	if (isset($_SESSION['token']))
259
-		echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>';
273
+	if (isset($_SESSION['token'])) {
274
+			echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>';
275
+	}
260 276
 
261 277
 	if (!empty($modSettings['cache_enable']) && !empty($cache_hits))
262 278
 	{
@@ -269,10 +285,12 @@  discard block
 block discarded – undo
269 285
 			$total_t += $cache_hit['t'];
270 286
 			$total_s += $cache_hit['s'];
271 287
 		}
272
-		if (!isset($cache_misses))
273
-			$cache_misses = array();
274
-		foreach ($cache_misses as $missed)
275
-			$missed_entires[] = $missed['d'] . ' ' . $missed['k'];
288
+		if (!isset($cache_misses)) {
289
+					$cache_misses = array();
290
+		}
291
+		foreach ($cache_misses as $missed) {
292
+					$missed_entires[] = $missed['d'] . ' ' . $missed['k'];
293
+		}
276 294
 
277 295
 		echo '
278 296
 	', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br>
@@ -283,38 +301,44 @@  discard block
 block discarded – undo
283 301
 	<a href="', $scripturl, '?action=viewquery" target="_blank" class="new_win">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br>
284 302
 	<br>';
285 303
 
286
-	if ($_SESSION['view_queries'] == 1 && !empty($db_cache))
287
-		foreach ($db_cache as $q => $qq)
304
+	if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) {
305
+			foreach ($db_cache as $q => $qq)
288 306
 		{
289 307
 			$is_select = strpos(trim($qq['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($qq['q'])) != 0;
308
+	}
290 309
 			// Temporary tables created in earlier queries are not explainable.
291 310
 			if ($is_select)
292 311
 			{
293
-				foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp)
294
-					if (strpos(trim($qq['q']), $tmp) !== false)
312
+				foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) {
313
+									if (strpos(trim($qq['q']), $tmp) !== false)
295 314
 					{
296 315
 						$is_select = false;
316
+				}
297 317
 						break;
298 318
 					}
299 319
 			}
300 320
 			// But actual creation of the temporary tables are.
301
-			elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0)
302
-				$is_select = true;
321
+			elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) {
322
+							$is_select = true;
323
+			}
303 324
 
304 325
 			// Make the filenames look a bit better.
305
-			if (isset($qq['f']))
306
-				$qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']);
326
+			if (isset($qq['f'])) {
327
+							$qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']);
328
+			}
307 329
 
308 330
 			echo '
309 331
 	<strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" class="new_win" style="text-decoration: none;">' : '', nl2br(str_replace("\t", '&nbsp;&nbsp;&nbsp;', $smcFunc['htmlspecialchars'](ltrim($qq['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br>
310 332
 	&nbsp;&nbsp;&nbsp;';
311
-			if (!empty($qq['f']) && !empty($qq['l']))
312
-				echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']);
333
+			if (!empty($qq['f']) && !empty($qq['l'])) {
334
+							echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']);
335
+			}
313 336
 
314
-			if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at']))
315
-				echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>';
316
-			elseif (isset($qq['t']))
317
-				echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>';
337
+			if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) {
338
+							echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>';
339
+			} elseif (isset($qq['t'])) {
340
+							echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>';
341
+			}
318 342
 			echo '
319 343
 	<br>';
320 344
 		}
@@ -339,12 +363,14 @@  discard block
 block discarded – undo
339 363
 	global $modSettings, $smcFunc;
340 364
 	static $cache_stats = array();
341 365
 
342
-	if (empty($modSettings['trackStats']))
343
-		return false;
344
-	if (!empty($stats))
345
-		return $cache_stats = array_merge($cache_stats, $stats);
346
-	elseif (empty($cache_stats))
347
-		return false;
366
+	if (empty($modSettings['trackStats'])) {
367
+			return false;
368
+	}
369
+	if (!empty($stats)) {
370
+			return $cache_stats = array_merge($cache_stats, $stats);
371
+	} elseif (empty($cache_stats)) {
372
+			return false;
373
+	}
348 374
 
349 375
 	$setStringUpdate = '';
350 376
 	$insert_keys = array();
@@ -357,10 +383,11 @@  discard block
 block discarded – undo
357 383
 		$setStringUpdate .= '
358 384
 			' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ',';
359 385
 
360
-		if ($change === '+')
361
-			$cache_stats[$field] = 1;
362
-		else
363
-			$update_parameters[$field] = $change;
386
+		if ($change === '+') {
387
+					$cache_stats[$field] = 1;
388
+		} else {
389
+					$update_parameters[$field] = $change;
390
+		}
364 391
 		$insert_keys[$field] = 'int';
365 392
 	}
366 393
 
@@ -424,43 +451,50 @@  discard block
 block discarded – undo
424 451
 	);
425 452
 
426 453
 	// Make sure this particular log is enabled first...
427
-	if (empty($modSettings['modlog_enabled']))
428
-		unset ($log_types['moderate']);
429
-	if (empty($modSettings['userlog_enabled']))
430
-		unset ($log_types['user']);
431
-	if (empty($modSettings['adminlog_enabled']))
432
-		unset ($log_types['admin']);
454
+	if (empty($modSettings['modlog_enabled'])) {
455
+			unset ($log_types['moderate']);
456
+	}
457
+	if (empty($modSettings['userlog_enabled'])) {
458
+			unset ($log_types['user']);
459
+	}
460
+	if (empty($modSettings['adminlog_enabled'])) {
461
+			unset ($log_types['admin']);
462
+	}
433 463
 
434 464
 	call_integration_hook('integrate_log_types', array(&$log_types));
435 465
 
436 466
 	foreach ($logs as $log)
437 467
 	{
438
-		if (!isset($log_types[$log['log_type']]))
439
-			return false;
468
+		if (!isset($log_types[$log['log_type']])) {
469
+					return false;
470
+		}
440 471
 
441
-		if (!is_array($log['extra']))
442
-			trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE);
472
+		if (!is_array($log['extra'])) {
473
+					trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE);
474
+		}
443 475
 
444 476
 		// Pull out the parts we want to store separately, but also make sure that the data is proper
445 477
 		if (isset($log['extra']['topic']))
446 478
 		{
447
-			if (!is_numeric($log['extra']['topic']))
448
-				trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE);
479
+			if (!is_numeric($log['extra']['topic'])) {
480
+							trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE);
481
+			}
449 482
 			$topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic'];
450 483
 			unset($log['extra']['topic']);
484
+		} else {
485
+					$topic_id = 0;
451 486
 		}
452
-		else
453
-			$topic_id = 0;
454 487
 
455 488
 		if (isset($log['extra']['message']))
456 489
 		{
457
-			if (!is_numeric($log['extra']['message']))
458
-				trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE);
490
+			if (!is_numeric($log['extra']['message'])) {
491
+							trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE);
492
+			}
459 493
 			$msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message'];
460 494
 			unset($log['extra']['message']);
495
+		} else {
496
+					$msg_id = 0;
461 497
 		}
462
-		else
463
-			$msg_id = 0;
464 498
 
465 499
 		// @todo cache this?
466 500
 		// Is there an associated report on this?
@@ -487,23 +521,26 @@  discard block
 block discarded – undo
487 521
 			$smcFunc['db_free_result']($request);
488 522
 		}
489 523
 
490
-		if (isset($log['extra']['member']) && !is_numeric($log['extra']['member']))
491
-			trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE);
524
+		if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) {
525
+					trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE);
526
+		}
492 527
 
493 528
 		if (isset($log['extra']['board']))
494 529
 		{
495
-			if (!is_numeric($log['extra']['board']))
496
-				trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE);
530
+			if (!is_numeric($log['extra']['board'])) {
531
+							trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE);
532
+			}
497 533
 			$board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board'];
498 534
 			unset($log['extra']['board']);
535
+		} else {
536
+					$board_id = 0;
499 537
 		}
500
-		else
501
-			$board_id = 0;
502 538
 
503 539
 		if (isset($log['extra']['board_to']))
504 540
 		{
505
-			if (!is_numeric($log['extra']['board_to']))
506
-				trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE);
541
+			if (!is_numeric($log['extra']['board_to'])) {
542
+							trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE);
543
+			}
507 544
 			if (empty($board_id))
508 545
 			{
509 546
 				$board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to'];
@@ -511,10 +548,11 @@  discard block
 block discarded – undo
511 548
 			}
512 549
 		}
513 550
 
514
-		if (isset($log['extra']['member_affected']))
515
-			$memID = $log['extra']['member_affected'];
516
-		else
517
-			$memID = $user_info['id'];
551
+		if (isset($log['extra']['member_affected'])) {
552
+					$memID = $log['extra']['member_affected'];
553
+		} else {
554
+					$memID = $user_info['id'];
555
+		}
518 556
 
519 557
 		$inserts[] = array(
520 558
 			time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'],
Please login to merge, or discard this patch.
Sources/Subs-Themes.php 1 patch
Braces   +67 added lines, -46 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Gets a single theme's info.
@@ -27,8 +28,9 @@  discard block
 block discarded – undo
27 28
 	global $smcFunc, $modSettings;
28 29
 
29 30
 	// No data, no fun!
30
-	if (empty($id))
31
-		return false;
31
+	if (empty($id)) {
32
+			return false;
33
+	}
32 34
 
33 35
 	// Make sure $id is an int.
34 36
 	$id = (int) $id;
@@ -171,8 +173,9 @@  discard block
 block discarded – undo
171 173
 	global $sourcedir, $forum_version, $txt, $scripturl, $context;
172 174
 	global $explicit_images;
173 175
 
174
-	if (empty($path))
175
-		return false;
176
+	if (empty($path)) {
177
+			return false;
178
+	}
176 179
 
177 180
 	$xml_data = array();
178 181
 	$explicit_images = false;
@@ -229,9 +232,10 @@  discard block
 block discarded – undo
229 232
 	);
230 233
 
231 234
 	// Assign the values to be stored.
232
-	foreach ($xml_elements as $var => $name)
233
-		if (!empty($theme_info_xml[$name]))
235
+	foreach ($xml_elements as $var => $name) {
236
+			if (!empty($theme_info_xml[$name]))
234 237
 			$xml_data[$var] = $theme_info_xml[$name];
238
+	}
235 239
 
236 240
 	// Add the supported versions.
237 241
 	$xml_data['install_for'] = $install_versions;
@@ -243,8 +247,9 @@  discard block
 block discarded – undo
243 247
 		$explicit_images = true;
244 248
 	}
245 249
 
246
-	if (!empty($theme_info_xml['extra']))
247
-		$xml_data += smf_json_decode($theme_info_xml['extra'], true);
250
+	if (!empty($theme_info_xml['extra'])) {
251
+			$xml_data += smf_json_decode($theme_info_xml['extra'], true);
252
+	}
248 253
 
249 254
 	return $xml_data;
250 255
 }
@@ -262,12 +267,14 @@  discard block
 block discarded – undo
262 267
 	global $settings, $explicit_images;
263 268
 
264 269
 	// External use? no problem!
265
-	if ($to_install)
266
-		$context['to_install'] = $to_install;
270
+	if ($to_install) {
271
+			$context['to_install'] = $to_install;
272
+	}
267 273
 
268 274
 	// One last check.
269
-	if (empty($context['to_install']['theme_dir']) || basename($context['to_install']['theme_dir']) == 'Themes')
270
-		fatal_lang_error('theme_install_invalid_dir', false);
275
+	if (empty($context['to_install']['theme_dir']) || basename($context['to_install']['theme_dir']) == 'Themes') {
276
+			fatal_lang_error('theme_install_invalid_dir', false);
277
+	}
271 278
 
272 279
 	// OK, is this a newer version of an already installed theme?
273 280
 	if (!empty($context['to_install']['version']))
@@ -292,8 +299,8 @@  discard block
 block discarded – undo
292 299
 		$smcFunc['db_free_result']($request);
293 300
 
294 301
 		// Got something, lets figure it out what to do next.
295
-		if (!empty($to_update) && !empty($to_update['version']))
296
-			switch (compareVersions($context['to_install']['version'], $to_update['version']))
302
+		if (!empty($to_update) && !empty($to_update['version'])) {
303
+					switch (compareVersions($context['to_install']['version'], $to_update['version']))
297 304
 			{
298 305
 				case 1: // Got a newer version, update the old entry.
299 306
 					$smcFunc['db_query']('', '
@@ -307,6 +314,7 @@  discard block
 block discarded – undo
307 314
 							'id_theme' => $to_update['id_theme'],
308 315
 						)
309 316
 					);
317
+		}
310 318
 
311 319
 					// Done with the update, tell the user about it.
312 320
 					$context['to_install']['updated'] = true;
@@ -372,13 +380,15 @@  discard block
 block discarded – undo
372 380
 				$context['to_install']['base_theme_url'] = $temp['theme_url'];
373 381
 				$context['to_install']['base_theme_dir'] = $temp['theme_dir'];
374 382
 
375
-				if (empty($explicit_images) && !empty($context['to_install']['base_theme_url']))
376
-					$context['to_install']['theme_url'] = $context['to_install']['base_theme_url'];
383
+				if (empty($explicit_images) && !empty($context['to_install']['base_theme_url'])) {
384
+									$context['to_install']['theme_url'] = $context['to_install']['base_theme_url'];
385
+				}
377 386
 			}
378 387
 
379 388
 			// Nope, sorry, couldn't find any theme already installed.
380
-			else
381
-				fatal_lang_error('package_get_error_theme_no_based_on_found', false, $context['to_install']['based_on']);
389
+			else {
390
+							fatal_lang_error('package_get_error_theme_no_based_on_found', false, $context['to_install']['based_on']);
391
+			}
382 392
 		}
383 393
 
384 394
 		unset($context['to_install']['based_on']);
@@ -401,16 +411,18 @@  discard block
 block discarded – undo
401 411
 	call_integration_hook('integrate_theme_install', array(&$context['to_install'], $id_theme));
402 412
 
403 413
 	$inserts = array();
404
-	foreach ($context['to_install'] as $var => $val)
405
-		$inserts[] = array($id_theme, $var, $val);
414
+	foreach ($context['to_install'] as $var => $val) {
415
+			$inserts[] = array($id_theme, $var, $val);
416
+	}
406 417
 
407
-	if (!empty($inserts))
408
-		$smcFunc['db_insert']('insert',
418
+	if (!empty($inserts)) {
419
+			$smcFunc['db_insert']('insert',
409 420
 			'{db_prefix}themes',
410 421
 			array('id_theme' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'),
411 422
 			$inserts,
412 423
 			array('id_theme', 'variable')
413 424
 		);
425
+	}
414 426
 
415 427
 	// Update the known and enable Theme's settings.
416 428
 	$known = strtr($modSettings['knownThemes'] . ',' . $id_theme, array(',,' => ','));
@@ -429,21 +441,24 @@  discard block
 block discarded – undo
429 441
  */
430 442
 function remove_dir($path)
431 443
 {
432
-	if (empty($path))
433
-		return false;
444
+	if (empty($path)) {
445
+			return false;
446
+	}
434 447
 
435 448
 	if (is_dir($path))
436 449
 	{
437 450
 		$objects = scandir($path);
438 451
 
439
-		foreach ($objects as $object)
440
-			if ($object != '.' && $object != '..')
452
+		foreach ($objects as $object) {
453
+					if ($object != '.' && $object != '..')
441 454
 			{
442 455
 				if (filetype($path .'/'. $object) == 'dir')
443 456
 					remove_dir($path .'/'.$object);
457
+		}
444 458
 
445
-				else
446
-					unlink($path .'/'. $object);
459
+				else {
460
+									unlink($path .'/'. $object);
461
+				}
447 462
 			}
448 463
 	}
449 464
 
@@ -462,8 +477,9 @@  discard block
 block discarded – undo
462 477
 	global $smcFunc, $modSettings;
463 478
 
464 479
 	// Can't delete the default theme, sorry!
465
-	if (empty($themeID) || $themeID == 1)
466
-		return false;
480
+	if (empty($themeID) || $themeID == 1) {
481
+			return false;
482
+	}
467 483
 
468 484
 	$known = explode(',', $modSettings['knownThemes']);
469 485
 	$enable = explode(',', $modSettings['enableThemes']);
@@ -513,8 +529,9 @@  discard block
 block discarded – undo
513 529
 	updateSettings(array('enableThemes' => $enable, 'knownThemes' => $known));
514 530
 
515 531
 	// Fix it if the theme was the overall default theme.
516
-	if ($modSettings['theme_guests'] == $themeID)
517
-		updateSettings(array('theme_guests' => '1'));
532
+	if ($modSettings['theme_guests'] == $themeID) {
533
+			updateSettings(array('theme_guests' => '1'));
534
+	}
518 535
 
519 536
 	return true;
520 537
 }
@@ -531,13 +548,15 @@  discard block
 block discarded – undo
531 548
 	global $scripturl, $txt, $context;
532 549
 
533 550
 	// Is it even a directory?
534
-	if (!is_dir($path))
535
-		fatal_lang_error('error_invalid_dir', 'critical');
551
+	if (!is_dir($path)) {
552
+			fatal_lang_error('error_invalid_dir', 'critical');
553
+	}
536 554
 
537 555
 	$dir = dir($path);
538 556
 	$entries = array();
539
-	while ($entry = $dir->read())
540
-		$entries[] = $entry;
557
+	while ($entry = $dir->read()) {
558
+			$entries[] = $entry;
559
+	}
541 560
 	$dir->close();
542 561
 
543 562
 	natcasesort($entries);
@@ -548,11 +567,12 @@  discard block
 block discarded – undo
548 567
 	foreach ($entries as $entry)
549 568
 	{
550 569
 		// Skip all dot files, including .htaccess.
551
-		if (substr($entry, 0, 1) == '.' || $entry == 'CVS')
552
-			continue;
570
+		if (substr($entry, 0, 1) == '.' || $entry == 'CVS') {
571
+					continue;
572
+		}
553 573
 
554
-		if (is_dir($path . '/' . $entry))
555
-			$listing1[] = array(
574
+		if (is_dir($path . '/' . $entry)) {
575
+					$listing1[] = array(
556 576
 				'filename' => $entry,
557 577
 				'is_writable' => is_writable($path . '/' . $entry),
558 578
 				'is_directory' => true,
@@ -562,13 +582,14 @@  discard block
 block discarded – undo
562 582
 				'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $relative . $entry,
563 583
 				'size' => '',
564 584
 			);
565
-		else
585
+		} else
566 586
 		{
567 587
 			$size = filesize($path . '/' . $entry);
568
-			if ($size > 2048 || $size == 1024)
569
-				$size = comma_format($size / 1024) . ' ' . $txt['themeadmin_edit_kilobytes'];
570
-			else
571
-				$size = comma_format($size) . ' ' . $txt['themeadmin_edit_bytes'];
588
+			if ($size > 2048 || $size == 1024) {
589
+							$size = comma_format($size / 1024) . ' ' . $txt['themeadmin_edit_kilobytes'];
590
+			} else {
591
+							$size = comma_format($size) . ' ' . $txt['themeadmin_edit_bytes'];
592
+			}
572 593
 
573 594
 			$listing2[] = array(
574 595
 				'filename' => $entry,
Please login to merge, or discard this patch.
Sources/Who.php 1 patch
Braces   +126 added lines, -95 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Who's online, and what are they doing?
@@ -35,8 +36,9 @@  discard block
 block discarded – undo
35 36
 	isAllowedTo('who_view');
36 37
 
37 38
 	// You can't do anything if this is off.
38
-	if (empty($modSettings['who_enabled']))
39
-		fatal_lang_error('who_off', false);
39
+	if (empty($modSettings['who_enabled'])) {
40
+			fatal_lang_error('who_off', false);
41
+	}
40 42
 
41 43
 	// Load the 'Who' template.
42 44
 	loadTemplate('Who');
@@ -71,9 +73,9 @@  discard block
 block discarded – undo
71 73
 		$show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)';
72 74
 		$show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)';
73 75
 		$context['show_methods']['spiders'] = $txt['who_show_spiders_only'];
76
+	} elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') {
77
+			unset($_SESSION['who_online_filter']);
74 78
 	}
75
-	elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders')
76
-		unset($_SESSION['who_online_filter']);
77 79
 
78 80
 	// Does the user prefer a different sort direction?
79 81
 	if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']]))
@@ -97,20 +99,24 @@  discard block
 block discarded – undo
97 99
 	$context['sort_direction'] = isset($_REQUEST['asc']) || (isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc') ? 'up' : 'down';
98 100
 
99 101
 	$conditions = array();
100
-	if (!allowedTo('moderate_forum'))
101
-		$conditions[] = '(COALESCE(mem.show_online, 1) = 1)';
102
+	if (!allowedTo('moderate_forum')) {
103
+			$conditions[] = '(COALESCE(mem.show_online, 1) = 1)';
104
+	}
102 105
 
103 106
 	// Fallback to top filter?
104
-	if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top']))
105
-		$_REQUEST['show'] = $_REQUEST['show_top'];
107
+	if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) {
108
+			$_REQUEST['show'] = $_REQUEST['show_top'];
109
+	}
106 110
 	// Does the user wish to apply a filter?
107
-	if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']]))
108
-		$context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show'];
111
+	if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) {
112
+			$context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show'];
113
+	}
109 114
 	// Perhaps we saved a filter earlier in the session?
110
-	elseif (isset($_SESSION['who_online_filter']))
111
-		$context['show_by'] = $_SESSION['who_online_filter'];
112
-	else
113
-		$context['show_by'] = 'members';
115
+	elseif (isset($_SESSION['who_online_filter'])) {
116
+			$context['show_by'] = $_SESSION['who_online_filter'];
117
+	} else {
118
+			$context['show_by'] = 'members';
119
+	}
114 120
 
115 121
 	$conditions[] = $show_methods[$context['show_by']];
116 122
 
@@ -156,8 +162,9 @@  discard block
 block discarded – undo
156 162
 	while ($row = $smcFunc['db_fetch_assoc']($request))
157 163
 	{
158 164
 		$actions = smf_json_decode($row['url'], true);
159
-		if ($actions === false)
160
-			continue;
165
+		if ($actions === false) {
166
+					continue;
167
+		}
161 168
 
162 169
 		// Send the information to the template.
163 170
 		$context['members'][$row['session']] = array(
@@ -195,8 +202,8 @@  discard block
 block discarded – undo
195 202
 	$spiderContext = array();
196 203
 	if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache']))
197 204
 	{
198
-		foreach (smf_json_decode($modSettings['spider_name_cache'], true) as $id => $name)
199
-			$spiderContext[$id] = array(
205
+		foreach (smf_json_decode($modSettings['spider_name_cache'], true) as $id => $name) {
206
+					$spiderContext[$id] = array(
200 207
 				'id' => 0,
201 208
 				'name' => $name,
202 209
 				'group' => $txt['spiders'],
@@ -205,6 +212,7 @@  discard block
 block discarded – undo
205 212
 				'email' => $name,
206 213
 				'is_guest' => true
207 214
 			);
215
+		}
208 216
 	}
209 217
 
210 218
 	$url_data = determineActions($url_data);
@@ -219,16 +227,18 @@  discard block
 block discarded – undo
219 227
 	// Put it in the context variables.
220 228
 	foreach ($context['members'] as $i => $member)
221 229
 	{
222
-		if ($member['id'] != 0)
223
-			$member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0;
230
+		if ($member['id'] != 0) {
231
+					$member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0;
232
+		}
224 233
 
225 234
 		// Keep the IP that came from the database.
226 235
 		$memberContext[$member['id']]['ip'] = $member['ip'];
227 236
 		$context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden'];
228
-		if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']]))
229
-			$context['members'][$i] += $spiderContext[$member['id_spider']];
230
-		else
231
-			$context['members'][$i] += $memberContext[$member['id']];
237
+		if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) {
238
+					$context['members'][$i] += $spiderContext[$member['id_spider']];
239
+		} else {
240
+					$context['members'][$i] += $memberContext[$member['id']];
241
+		}
232 242
 	}
233 243
 
234 244
 	// Some people can't send personal messages...
@@ -263,8 +273,9 @@  discard block
 block discarded – undo
263 273
 {
264 274
 	global $txt, $user_info, $modSettings, $smcFunc;
265 275
 
266
-	if (!allowedTo('who_view'))
267
-		return array();
276
+	if (!allowedTo('who_view')) {
277
+			return array();
278
+	}
268 279
 	loadLanguage('Who');
269 280
 
270 281
 	// Actions that require a specific permission level.
@@ -292,10 +303,11 @@  discard block
 block discarded – undo
292 303
 	);
293 304
 	call_integration_hook('who_allowed', array(&$allowedActions));
294 305
 
295
-	if (!is_array($urls))
296
-		$url_list = array(array($urls, $user_info['id']));
297
-	else
298
-		$url_list = $urls;
306
+	if (!is_array($urls)) {
307
+			$url_list = array(array($urls, $user_info['id']));
308
+	} else {
309
+			$url_list = $urls;
310
+	}
299 311
 
300 312
 	// These are done to later query these in large chunks. (instead of one by one.)
301 313
 	$topic_ids = array();
@@ -307,12 +319,14 @@  discard block
 block discarded – undo
307 319
 	{
308 320
 		// Get the request parameters..
309 321
 		$actions = smf_json_decode($url[0], true);
310
-		if ($actions === false)
311
-			continue;
322
+		if ($actions === false) {
323
+					continue;
324
+		}
312 325
 
313 326
 		// If it's the admin or moderation center, and there is an area set, use that instead.
314
-		if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area']))
315
-			$actions['action'] = $actions['area'];
327
+		if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) {
328
+					$actions['action'] = $actions['area'];
329
+		}
316 330
 
317 331
 		// Check if there was no action or the action is display.
318 332
 		if (!isset($actions['action']) || $actions['action'] == 'display')
@@ -332,12 +346,14 @@  discard block
 block discarded – undo
332 346
 				$board_ids[$actions['board']][$k] = $txt['who_board'];
333 347
 			}
334 348
 			// It's the board index!!  It must be!
335
-			else
336
-				$data[$k] = $txt['who_index'];
349
+			else {
350
+							$data[$k] = $txt['who_index'];
351
+			}
337 352
 		}
338 353
 		// Probably an error or some goon?
339
-		elseif ($actions['action'] == '')
340
-			$data[$k] = $txt['who_index'];
354
+		elseif ($actions['action'] == '') {
355
+					$data[$k] = $txt['who_index'];
356
+		}
341 357
 		// Some other normal action...?
342 358
 		else
343 359
 		{
@@ -345,23 +361,25 @@  discard block
 block discarded – undo
345 361
 			if ($actions['action'] == 'profile')
346 362
 			{
347 363
 				// Whose?  Their own?
348
-				if (empty($actions['u']))
349
-					$actions['u'] = $url[1];
364
+				if (empty($actions['u'])) {
365
+									$actions['u'] = $url[1];
366
+				}
350 367
 
351 368
 				$data[$k] = $txt['who_hidden'];
352 369
 				$profile_ids[(int) $actions['u']][$k] = $actions['u'] == $url[1] ? $txt['who_viewownprofile'] : $txt['who_viewprofile'];
353
-			}
354
-			elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board']))
370
+			} elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board']))
355 371
 			{
356 372
 				$data[$k] = $txt['who_hidden'];
357 373
 				$board_ids[(int) $actions['board']][$k] = isset($actions['poll']) ? $txt['who_poll'] : $txt['who_post'];
358 374
 			}
359 375
 			// A subaction anyone can view... if the language string is there, show it.
360
-			elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']]))
361
-				$data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']];
376
+			elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) {
377
+							$data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']];
378
+			}
362 379
 			// An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.)
363
-			elseif (isset($txt['whoall_' . $actions['action']]))
364
-				$data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']];
380
+			elseif (isset($txt['whoall_' . $actions['action']])) {
381
+							$data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']];
382
+			}
365 383
 			// Viewable if and only if they can see the board...
366 384
 			elseif (isset($txt['whotopic_' . $actions['action']]))
367 385
 			{
@@ -370,8 +388,7 @@  discard block
 block discarded – undo
370 388
 
371 389
 				$data[$k] = $txt['who_hidden'];
372 390
 				$topic_ids[$topic][$k] = $txt['whotopic_' . $actions['action']];
373
-			}
374
-			elseif (isset($txt['whopost_' . $actions['action']]))
391
+			} elseif (isset($txt['whopost_' . $actions['action']]))
375 392
 			{
376 393
 				// Find out what message they are accessing.
377 394
 				$msgid = (int) (isset($actions['msg']) ? $actions['msg'] : (isset($actions['quote']) ? $actions['quote'] : 0));
@@ -394,41 +411,46 @@  discard block
 block discarded – undo
394 411
 				$data[$k] = sprintf($txt['whopost_' . $actions['action']], $id_topic, $subject);
395 412
 				$smcFunc['db_free_result']($result);
396 413
 
397
-				if (empty($id_topic))
398
-					$data[$k] = $txt['who_hidden'];
414
+				if (empty($id_topic)) {
415
+									$data[$k] = $txt['who_hidden'];
416
+				}
399 417
 			}
400 418
 			// Viewable only by administrators.. (if it starts with whoadmin, it's admin only!)
401
-			elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']]))
402
-				$data[$k] = $txt['whoadmin_' . $actions['action']];
419
+			elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) {
420
+							$data[$k] = $txt['whoadmin_' . $actions['action']];
421
+			}
403 422
 			// Viewable by permission level.
404 423
 			elseif (isset($allowedActions[$actions['action']]))
405 424
 			{
406
-				if (allowedTo($allowedActions[$actions['action']]))
407
-					$data[$k] = $txt['whoallow_' . $actions['action']];
408
-				elseif (in_array('moderate_forum', $allowedActions[$actions['action']]))
409
-					$data[$k] = $txt['who_moderate'];
410
-				elseif (in_array('admin_forum', $allowedActions[$actions['action']]))
411
-					$data[$k] = $txt['who_admin'];
412
-				else
413
-					$data[$k] = $txt['who_hidden'];
425
+				if (allowedTo($allowedActions[$actions['action']])) {
426
+									$data[$k] = $txt['whoallow_' . $actions['action']];
427
+				} elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) {
428
+									$data[$k] = $txt['who_moderate'];
429
+				} elseif (in_array('admin_forum', $allowedActions[$actions['action']])) {
430
+									$data[$k] = $txt['who_admin'];
431
+				} else {
432
+									$data[$k] = $txt['who_hidden'];
433
+				}
434
+			} elseif (!empty($actions['action'])) {
435
+							$data[$k] = $txt['who_generic'] . ' ' . $actions['action'];
436
+			} else {
437
+							$data[$k] = $txt['who_unknown'];
414 438
 			}
415
-			elseif (!empty($actions['action']))
416
-				$data[$k] = $txt['who_generic'] . ' ' . $actions['action'];
417
-			else
418
-				$data[$k] = $txt['who_unknown'];
419 439
 		}
420 440
 
421 441
 		if (isset($actions['error']))
422 442
 		{
423
-			if (isset($txt[$actions['error']]))
424
-				$error_message = str_replace('"', '&quot;', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params']));
425
-			elseif ($actions['error'] == 'guest_login')
426
-				$error_message = str_replace('"', '&quot;', $txt['who_guest_login']);
427
-			else
428
-				$error_message = str_replace('"', '&quot;', $actions['error']);
429
-
430
-			if (!empty($error_message))
431
-				$data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>';
443
+			if (isset($txt[$actions['error']])) {
444
+							$error_message = str_replace('"', '&quot;', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params']));
445
+			} elseif ($actions['error'] == 'guest_login') {
446
+							$error_message = str_replace('"', '&quot;', $txt['who_guest_login']);
447
+			} else {
448
+							$error_message = str_replace('"', '&quot;', $actions['error']);
449
+			}
450
+
451
+			if (!empty($error_message)) {
452
+							$data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>';
453
+			}
432 454
 		}
433 455
 
434 456
 		// Maybe the action is integrated into another system?
@@ -439,12 +461,15 @@  discard block
 block discarded – undo
439 461
 				if (!empty($integrate_action))
440 462
 				{
441 463
 					$data[$k] = $integrate_action;
442
-					if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k]))
443
-						$topic_ids[(int) $actions['topic']][$k] = $integrate_action;
444
-					if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k]))
445
-						$board_ids[(int) $actions['board']][$k] = $integrate_action;
446
-					if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k]))
447
-						$profile_ids[(int) $actions['u']][$k] = $integrate_action;
464
+					if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) {
465
+											$topic_ids[(int) $actions['topic']][$k] = $integrate_action;
466
+					}
467
+					if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) {
468
+											$board_ids[(int) $actions['board']][$k] = $integrate_action;
469
+					}
470
+					if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) {
471
+											$profile_ids[(int) $actions['u']][$k] = $integrate_action;
472
+					}
448 473
 					break;
449 474
 				}
450 475
 			}
@@ -472,8 +497,9 @@  discard block
 block discarded – undo
472 497
 		while ($row = $smcFunc['db_fetch_assoc']($result))
473 498
 		{
474 499
 			// Show the topic's subject for each of the actions.
475
-			foreach ($topic_ids[$row['id_topic']] as $k => $session_text)
476
-				$data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject']));
500
+			foreach ($topic_ids[$row['id_topic']] as $k => $session_text) {
501
+							$data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject']));
502
+			}
477 503
 		}
478 504
 		$smcFunc['db_free_result']($result);
479 505
 	}
@@ -495,8 +521,9 @@  discard block
 block discarded – undo
495 521
 		while ($row = $smcFunc['db_fetch_assoc']($result))
496 522
 		{
497 523
 			// Put the board name into the string for each member...
498
-			foreach ($board_ids[$row['id_board']] as $k => $session_text)
499
-				$data[$k] = sprintf($session_text, $row['id_board'], $row['name']);
524
+			foreach ($board_ids[$row['id_board']] as $k => $session_text) {
525
+							$data[$k] = sprintf($session_text, $row['id_board'], $row['name']);
526
+			}
500 527
 		}
501 528
 		$smcFunc['db_free_result']($result);
502 529
 	}
@@ -518,23 +545,26 @@  discard block
 block discarded – undo
518 545
 		while ($row = $smcFunc['db_fetch_assoc']($result))
519 546
 		{
520 547
 			// If they aren't allowed to view this person's profile, skip it.
521
-			if (!$allow_view_any && ($user_info['id'] != $row['id_member']))
522
-				continue;
548
+			if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) {
549
+							continue;
550
+			}
523 551
 
524 552
 			// Set their action on each - session/text to sprintf.
525
-			foreach ($profile_ids[$row['id_member']] as $k => $session_text)
526
-				$data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']);
553
+			foreach ($profile_ids[$row['id_member']] as $k => $session_text) {
554
+							$data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']);
555
+			}
527 556
 		}
528 557
 		$smcFunc['db_free_result']($result);
529 558
 	}
530 559
 
531 560
 	call_integration_hook('whos_online_after', array(&$urls, &$data));
532 561
 
533
-	if (!is_array($urls))
534
-		return isset($data[0]) ? $data[0] : false;
535
-	else
536
-		return $data;
537
-}
562
+	if (!is_array($urls)) {
563
+			return isset($data[0]) ? $data[0] : false;
564
+	} else {
565
+			return $data;
566
+	}
567
+	}
538 568
 
539 569
 /**
540 570
  * It prepares credit and copyright information for the credits page or the admin page
@@ -709,8 +739,8 @@  discard block
 block discarded – undo
709 739
 	);
710 740
 
711 741
 	// Give the translators some credit for their hard work.
712
-	if (!empty($txt['translation_credits']))
713
-		$context['credits'][] = array(
742
+	if (!empty($txt['translation_credits'])) {
743
+			$context['credits'][] = array(
714 744
 			'title' => $txt['credits_groups_translation'],
715 745
 			'groups' => array(
716 746
 				array(
@@ -719,6 +749,7 @@  discard block
 block discarded – undo
719 749
 				),
720 750
 			),
721 751
 		);
752
+	}
722 753
 
723 754
 	$context['credits'][] = array(
724 755
 		'title' => $txt['credits_special'],
Please login to merge, or discard this patch.
Sources/Subs-Post.php 1 patch
Braces   +522 added lines, -389 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 3
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * Takes a message and parses it, returning nothing.
@@ -52,17 +53,19 @@  discard block
 block discarded – undo
52 53
 	$message = preg_replace('~\.{100,}~', '...', $message);
53 54
 
54 55
 	// Trim off trailing quotes - these often happen by accident.
55
-	while (substr($message, -7) == '[quote]')
56
-		$message = substr($message, 0, -7);
57
-	while (substr($message, 0, 8) == '[/quote]')
58
-		$message = substr($message, 8);
56
+	while (substr($message, -7) == '[quote]') {
57
+			$message = substr($message, 0, -7);
58
+	}
59
+	while (substr($message, 0, 8) == '[/quote]') {
60
+			$message = substr($message, 8);
61
+	}
59 62
 
60 63
 	// Find all code blocks, work out whether we'd be parsing them, then ensure they are all closed.
61 64
 	$in_tag = false;
62 65
 	$had_tag = false;
63 66
 	$codeopen = 0;
64
-	if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches))
65
-		foreach ($matches[0] as $index => $dummy)
67
+	if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) {
68
+			foreach ($matches[0] as $index => $dummy)
66 69
 		{
67 70
 			// Closing?
68 71
 			if (!empty($matches[2][$index]))
@@ -70,6 +73,7 @@  discard block
 block discarded – undo
70 73
 				// If it's closing and we're not in a tag we need to open it...
71 74
 				if (!$in_tag)
72 75
 					$codeopen = true;
76
+	}
73 77
 				// Either way we ain't in one any more.
74 78
 				$in_tag = false;
75 79
 			}
@@ -78,17 +82,20 @@  discard block
 block discarded – undo
78 82
 			{
79 83
 				$had_tag = true;
80 84
 				// If we're in a tag don't do nought!
81
-				if (!$in_tag)
82
-					$in_tag = true;
85
+				if (!$in_tag) {
86
+									$in_tag = true;
87
+				}
83 88
 			}
84 89
 		}
85 90
 
86 91
 	// If we have an open tag, close it.
87
-	if ($in_tag)
88
-		$message .= '[/code]';
92
+	if ($in_tag) {
93
+			$message .= '[/code]';
94
+	}
89 95
 	// Open any ones that need to be open, only if we've never had a tag.
90
-	if ($codeopen && !$had_tag)
91
-		$message = '[code]' . $message;
96
+	if ($codeopen && !$had_tag) {
97
+			$message = '[code]' . $message;
98
+	}
92 99
 
93 100
 	// Now that we've fixed all the code tags, let's fix the img and url tags...
94 101
 	$parts = preg_split('~(\[/code\]|\[code(?:=[^\]]+)?\])~i', $message, -1, PREG_SPLIT_DELIM_CAPTURE);
@@ -114,23 +121,26 @@  discard block
 block discarded – undo
114 121
 	fixTags($message);
115 122
 
116 123
 	// Replace /me.+?\n with [me=name]dsf[/me]\n.
117
-	if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false)
118
-		$message = preg_replace('~(\A|\n)/me(?: |&nbsp;)([^\n]*)(?:\z)?~i', '$1[me=&quot;' . $user_info['name'] . '&quot;]$2[/me]', $message);
119
-	else
120
-		$message = preg_replace('~(\A|\n)/me(?: |&nbsp;)([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message);
124
+	if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) {
125
+			$message = preg_replace('~(\A|\n)/me(?: |&nbsp;)([^\n]*)(?:\z)?~i', '$1[me=&quot;' . $user_info['name'] . '&quot;]$2[/me]', $message);
126
+	} else {
127
+			$message = preg_replace('~(\A|\n)/me(?: |&nbsp;)([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message);
128
+	}
121 129
 
122 130
 	if (!$previewing && strpos($message, '[html]') !== false)
123 131
 	{
124
-		if (allowedTo('admin_forum'))
125
-			$message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function ($m) {
132
+		if (allowedTo('admin_forum')) {
133
+					$message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function ($m) {
126 134
 				return '[html]' . strtr(un_htmlspecialchars($m), array("\n" => '&#13;', '  ' => ' &#32;', '[' => '&#91;', ']' => '&#93;')) . '[/html]';
135
+		}
127 136
 			}, $message);
128 137
 
129 138
 		// We should edit them out, or else if an admin edits the message they will get shown...
130 139
 		else
131 140
 		{
132
-			while (strpos($message, '[html]') !== false)
133
-				$message = preg_replace('~\[[/]?html\]~i', '', $message);
141
+			while (strpos($message, '[html]') !== false) {
142
+							$message = preg_replace('~\[[/]?html\]~i', '', $message);
143
+			}
134 144
 		}
135 145
 	}
136 146
 
@@ -152,10 +162,12 @@  discard block
 block discarded – undo
152 162
 
153 163
 	$list_open = substr_count($message, '[list]') + substr_count($message, '[list ');
154 164
 	$list_close = substr_count($message, '[/list]');
155
-	if ($list_close - $list_open > 0)
156
-		$message = str_repeat('[list]', $list_close - $list_open) . $message;
157
-	if ($list_open - $list_close > 0)
158
-		$message = $message . str_repeat('[/list]', $list_open - $list_close);
165
+	if ($list_close - $list_open > 0) {
166
+			$message = str_repeat('[list]', $list_close - $list_open) . $message;
167
+	}
168
+	if ($list_open - $list_close > 0) {
169
+			$message = $message . str_repeat('[/list]', $list_open - $list_close);
170
+	}
159 171
 
160 172
 	$mistake_fixes = array(
161 173
 		// Find [table]s not followed by [tr].
@@ -204,8 +216,9 @@  discard block
 block discarded – undo
204 216
 	);
205 217
 
206 218
 	// Fix up some use of tables without [tr]s, etc. (it has to be done more than once to catch it all.)
207
-	for ($j = 0; $j < 3; $j++)
208
-		$message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message);
219
+	for ($j = 0; $j < 3; $j++) {
220
+			$message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message);
221
+	}
209 222
 
210 223
 	// Remove empty bbc from the sections outside the code tags
211 224
 	$message = preg_replace('~\[[bisu]\]\s*\[/[bisu]\]~', '', $message);
@@ -213,14 +226,16 @@  discard block
 block discarded – undo
213 226
 	$message = preg_replace('~\[color=(?:#[\da-fA-F]{3}|#[\da-fA-F]{6}|[A-Za-z]{1,20}|rgb\(\d{1,3}, ?\d{1,3}, ?\d{1,3}\))\]\s*\[/color\]~', '', $message);
214 227
 
215 228
 	// Restore code blocks
216
-	if (!empty($code_tags))
217
-		$message = str_replace(array_keys($code_tags), array_values($code_tags), $message);
229
+	if (!empty($code_tags)) {
230
+			$message = str_replace(array_keys($code_tags), array_values($code_tags), $message);
231
+	}
218 232
 
219 233
 	// Restore white space entities
220
-	if (!$previewing)
221
-		$message = strtr($message, array('  ' => '&nbsp; ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));
222
-	else
223
-		$message = strtr($message, array('  ' => '&nbsp; ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));
234
+	if (!$previewing) {
235
+			$message = strtr($message, array('  ' => '&nbsp; ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));
236
+	} else {
237
+			$message = strtr($message, array('  ' => '&nbsp; ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));
238
+	}
224 239
 
225 240
 	// Now let's quickly clean up things that will slow our parser (which are common in posted code.)
226 241
 	$message = strtr($message, array('[]' => '&#91;]', '[&#039;' => '&#91;&#039;'));
@@ -263,8 +278,9 @@  discard block
 block discarded – undo
263 278
 		return "[time]" . timeformat("$m[1]", false) . "[/time]";
264 279
 	}, $message);
265 280
 
266
-	if (!empty($code_tags))
267
-		$message = str_replace(array_keys($code_tags), array_values($code_tags), $message);
281
+	if (!empty($code_tags)) {
282
+			$message = str_replace(array_keys($code_tags), array_values($code_tags), $message);
283
+	}
268 284
 
269 285
 	// Change breaks back to \n's and &nsbp; back to spaces.
270 286
 	return preg_replace('~<br( /)?' . '>~', "\n", str_replace('&nbsp;', ' ', $message));
@@ -345,8 +361,9 @@  discard block
 block discarded – undo
345 361
 	);
346 362
 
347 363
 	// Fix each type of tag.
348
-	foreach ($fixArray as $param)
349
-		fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra']));
364
+	foreach ($fixArray as $param) {
365
+			fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra']));
366
+	}
350 367
 
351 368
 	// Now fix possible security problems with images loading links automatically...
352 369
 	$message = preg_replace_callback('~(\[img.*?\])(.+?)\[/img\]~is', function ($m)
@@ -382,16 +399,19 @@  discard block
 block discarded – undo
382 399
 					$desired_height = $height;
383 400
 				}
384 401
 				// Scale it to the width...
385
-				elseif (empty($desired_width) && !empty($height))
386
-					$desired_width = (int) (($desired_height * $width) / $height);
402
+				elseif (empty($desired_width) && !empty($height)) {
403
+									$desired_width = (int) (($desired_height * $width) / $height);
404
+				}
387 405
 				// Scale if to the height.
388
-				elseif (!empty($width))
389
-					$desired_height = (int) (($desired_width * $height) / $width);
406
+				elseif (!empty($width)) {
407
+									$desired_height = (int) (($desired_width * $height) / $width);
408
+				}
390 409
 			}
391 410
 
392 411
 			// If the width and height are fine, just continue along...
393
-			if ($desired_width <= $modSettings['max_image_width'] && $desired_height <= $modSettings['max_image_height'])
394
-				continue;
412
+			if ($desired_width <= $modSettings['max_image_width'] && $desired_height <= $modSettings['max_image_height']) {
413
+							continue;
414
+			}
395 415
 
396 416
 			// Too bad, it's too wide.  Make it as wide as the maximum.
397 417
 			if ($desired_width > $modSettings['max_image_width'] && !empty($modSettings['max_image_width']))
@@ -411,8 +431,9 @@  discard block
 block discarded – undo
411 431
 		}
412 432
 
413 433
 		// If any img tags were actually changed...
414
-		if (!empty($replaces))
415
-			$message = strtr($message, $replaces);
434
+		if (!empty($replaces)) {
435
+					$message = strtr($message, $replaces);
436
+		}
416 437
 	}
417 438
 }
418 439
 
@@ -431,10 +452,11 @@  discard block
 block discarded – undo
431 452
 {
432 453
 	global $boardurl, $scripturl;
433 454
 
434
-	if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0)
435
-		$domain_url = $match[1];
436
-	else
437
-		$domain_url = $boardurl . '/';
455
+	if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) {
456
+			$domain_url = $match[1];
457
+	} else {
458
+			$domain_url = $boardurl . '/';
459
+	}
438 460
 
439 461
 	$replaces = array();
440 462
 
@@ -442,11 +464,11 @@  discard block
 block discarded – undo
442 464
 	{
443 465
 		$quoted = preg_match('~\[(' . $myTag . ')=&quot;~', $message);
444 466
 		preg_match_all('~\[(' . $myTag . ')=' . ($quoted ? '&quot;(.*?)&quot;' : '([^\]]*?)') . '\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches);
467
+	} elseif ($hasEqualSign) {
468
+			preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches);
469
+	} else {
470
+			preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches);
445 471
 	}
446
-	elseif ($hasEqualSign)
447
-		preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches);
448
-	else
449
-		preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches);
450 472
 
451 473
 	foreach ($matches[0] as $k => $dummy)
452 474
 	{
@@ -459,49 +481,53 @@  discard block
 block discarded – undo
459 481
 		foreach ($protocols as $protocol)
460 482
 		{
461 483
 			$found = strncasecmp($replace, $protocol . '://', strlen($protocol) + 3) === 0;
462
-			if ($found)
463
-				break;
484
+			if ($found) {
485
+							break;
486
+			}
464 487
 		}
465 488
 
466 489
 		if (!$found && $protocols[0] == 'http')
467 490
 		{
468
-			if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//')
469
-				$replace = $domain_url . $replace;
470
-			elseif (substr($replace, 0, 1) == '?')
471
-				$replace = $scripturl . $replace;
472
-			elseif (substr($replace, 0, 1) == '#' && $embeddedUrl)
491
+			if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') {
492
+							$replace = $domain_url . $replace;
493
+			} elseif (substr($replace, 0, 1) == '?') {
494
+							$replace = $scripturl . $replace;
495
+			} elseif (substr($replace, 0, 1) == '#' && $embeddedUrl)
473 496
 			{
474 497
 				$replace = '#' . preg_replace('~[^A-Za-z0-9_\-#]~', '', substr($replace, 1));
475 498
 				$this_tag = 'iurl';
476 499
 				$this_close = 'iurl';
500
+			} elseif (substr($replace, 0, 2) != '//') {
501
+							$replace = $protocols[0] . '://' . $replace;
477 502
 			}
478
-			elseif (substr($replace, 0, 2) != '//')
479
-				$replace = $protocols[0] . '://' . $replace;
480
-		}
481
-		elseif (!$found && $protocols[0] == 'ftp')
482
-			$replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace);
483
-		elseif (!$found)
484
-			$replace = $protocols[0] . '://' . $replace;
485
-
486
-		if ($hasEqualSign && $embeddedUrl)
487
-			$replaces[$matches[0][$k]] = '[' . $this_tag . '=&quot;' . $replace . '&quot;]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']');
488
-		elseif ($hasEqualSign)
489
-			$replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']';
490
-		elseif ($embeddedUrl)
491
-			$replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']';
492
-		else
493
-			$replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']';
503
+		} elseif (!$found && $protocols[0] == 'ftp') {
504
+					$replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace);
505
+		} elseif (!$found) {
506
+					$replace = $protocols[0] . '://' . $replace;
507
+		}
508
+
509
+		if ($hasEqualSign && $embeddedUrl) {
510
+					$replaces[$matches[0][$k]] = '[' . $this_tag . '=&quot;' . $replace . '&quot;]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']');
511
+		} elseif ($hasEqualSign) {
512
+					$replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']';
513
+		} elseif ($embeddedUrl) {
514
+					$replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']';
515
+		} else {
516
+					$replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']';
517
+		}
494 518
 	}
495 519
 
496 520
 	foreach ($replaces as $k => $v)
497 521
 	{
498
-		if ($k == $v)
499
-			unset($replaces[$k]);
522
+		if ($k == $v) {
523
+					unset($replaces[$k]);
524
+		}
500 525
 	}
501 526
 
502
-	if (!empty($replaces))
503
-		$message = strtr($message, $replaces);
504
-}
527
+	if (!empty($replaces)) {
528
+			$message = strtr($message, $replaces);
529
+	}
530
+	}
505 531
 
506 532
 /**
507 533
  * This function sends an email to the specified recipient(s).
@@ -545,8 +571,9 @@  discard block
 block discarded – undo
545 571
 	}
546 572
 
547 573
 	// Nothing left? Nothing else to do
548
-	if (empty($to_array))
549
-		return true;
574
+	if (empty($to_array)) {
575
+			return true;
576
+	}
550 577
 
551 578
 	// Once upon a time, Hotmail could not interpret non-ASCII mails.
552 579
 	// In honour of those days, it's still called the 'hotmail fix'.
@@ -563,15 +590,17 @@  discard block
 block discarded – undo
563 590
 		}
564 591
 
565 592
 		// Call this function recursively for the hotmail addresses.
566
-		if (!empty($hotmail_to))
567
-			$mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private);
593
+		if (!empty($hotmail_to)) {
594
+					$mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private);
595
+		}
568 596
 
569 597
 		// The remaining addresses no longer need the fix.
570 598
 		$hotmail_fix = false;
571 599
 
572 600
 		// No other addresses left? Return instantly.
573
-		if (empty($to_array))
574
-			return $mail_result;
601
+		if (empty($to_array)) {
602
+					return $mail_result;
603
+		}
575 604
 	}
576 605
 
577 606
 	// Get rid of entities.
@@ -596,13 +625,15 @@  discard block
 block discarded – undo
596 625
 	$headers .= 'Return-Path: ' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . $line_break;
597 626
 	$headers .= 'Date: ' . gmdate('D, d M Y H:i:s') . ' -0000' . $line_break;
598 627
 
599
-	if ($message_id !== null && empty($modSettings['mail_no_message_id']))
600
-		$headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break;
628
+	if ($message_id !== null && empty($modSettings['mail_no_message_id'])) {
629
+			$headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break;
630
+	}
601 631
 	$headers .= 'X-Mailer: SMF' . $line_break;
602 632
 
603 633
 	// Pass this to the integration before we start modifying the output -- it'll make it easier later.
604
-	if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers)), true))
605
-		return false;
634
+	if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers)), true)) {
635
+			return false;
636
+	}
606 637
 
607 638
 	// Save the original message...
608 639
 	$orig_message = $message;
@@ -651,17 +682,19 @@  discard block
 block discarded – undo
651 682
 	}
652 683
 
653 684
 	// Are we using the mail queue, if so this is where we butt in...
654
-	if ($priority != 0)
655
-		return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private);
685
+	if ($priority != 0) {
686
+			return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private);
687
+	}
656 688
 
657 689
 	// If it's a priority mail, send it now - note though that this should NOT be used for sending many at once.
658 690
 	elseif (!empty($modSettings['mail_limit']))
659 691
 	{
660 692
 		list ($last_mail_time, $mails_this_minute) = @explode('|', $modSettings['mail_recent']);
661
-		if (empty($mails_this_minute) || time() > $last_mail_time + 60)
662
-			$new_queue_stat = time() . '|' . 1;
663
-		else
664
-			$new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1);
693
+		if (empty($mails_this_minute) || time() > $last_mail_time + 60) {
694
+					$new_queue_stat = time() . '|' . 1;
695
+		} else {
696
+					$new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1);
697
+		}
665 698
 
666 699
 		updateSettings(array('mail_recent' => $new_queue_stat));
667 700
 	}
@@ -686,12 +719,13 @@  discard block
 block discarded – undo
686 719
 
687 720
 			// Wait, wait, I'm still sending here!
688 721
 			@set_time_limit(300);
689
-			if (function_exists('apache_reset_timeout'))
690
-				@apache_reset_timeout();
722
+			if (function_exists('apache_reset_timeout')) {
723
+							@apache_reset_timeout();
724
+			}
691 725
 		}
726
+	} else {
727
+			$mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers);
692 728
 	}
693
-	else
694
-		$mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers);
695 729
 
696 730
 	// Everything go smoothly?
697 731
 	return $mail_result;
@@ -717,8 +751,9 @@  discard block
 block discarded – undo
717 751
 	static $cur_insert = array();
718 752
 	static $cur_insert_len = 0;
719 753
 
720
-	if ($cur_insert_len == 0)
721
-		$cur_insert = array();
754
+	if ($cur_insert_len == 0) {
755
+			$cur_insert = array();
756
+	}
722 757
 
723 758
 	// If we're flushing, make the final inserts - also if we're near the MySQL length limit!
724 759
 	if (($flush || $cur_insert_len > 800000) && !empty($cur_insert))
@@ -793,8 +828,9 @@  discard block
 block discarded – undo
793 828
 	}
794 829
 
795 830
 	// If they are using SSI there is a good chance obExit will never be called.  So lets be nice and flush it for them.
796
-	if (SMF === 'SSI' || SMF === 'BACKGROUND')
797
-		return AddMailQueue(true);
831
+	if (SMF === 'SSI' || SMF === 'BACKGROUND') {
832
+			return AddMailQueue(true);
833
+	}
798 834
 
799 835
 	return true;
800 836
 }
@@ -827,23 +863,26 @@  discard block
 block discarded – undo
827 863
 		'sent' => array()
828 864
 	);
829 865
 
830
-	if ($from === null)
831
-		$from = array(
866
+	if ($from === null) {
867
+			$from = array(
832 868
 			'id' => $user_info['id'],
833 869
 			'name' => $user_info['name'],
834 870
 			'username' => $user_info['username']
835 871
 		);
872
+	}
836 873
 
837 874
 	// This is the one that will go in their inbox.
838 875
 	$htmlmessage = $smcFunc['htmlspecialchars']($message, ENT_QUOTES);
839 876
 	preparsecode($htmlmessage);
840 877
 	$htmlsubject = strtr($smcFunc['htmlspecialchars']($subject), array("\r" => '', "\n" => '', "\t" => ''));
841
-	if ($smcFunc['strlen']($htmlsubject) > 100)
842
-		$htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100);
878
+	if ($smcFunc['strlen']($htmlsubject) > 100) {
879
+			$htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100);
880
+	}
843 881
 
844 882
 	// Make sure is an array
845
-	if (!is_array($recipients))
846
-		$recipients = array($recipients);
883
+	if (!is_array($recipients)) {
884
+			$recipients = array($recipients);
885
+	}
847 886
 
848 887
 	// Integrated PMs
849 888
 	call_integration_hook('integrate_personal_message', array(&$recipients, &$from, &$subject, &$message));
@@ -871,21 +910,23 @@  discard block
 block discarded – undo
871 910
 				'usernames' => array_keys($usernames),
872 911
 			)
873 912
 		);
874
-		while ($row = $smcFunc['db_fetch_assoc']($request))
875
-			if (isset($usernames[$smcFunc['strtolower']($row['member_name'])]))
913
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
914
+					if (isset($usernames[$smcFunc['strtolower']($row['member_name'])]))
876 915
 				$usernames[$smcFunc['strtolower']($row['member_name'])] = $row['id_member'];
916
+		}
877 917
 		$smcFunc['db_free_result']($request);
878 918
 
879 919
 		// Replace the usernames with IDs. Drop usernames that couldn't be found.
880
-		foreach ($recipients as $rec_type => $rec)
881
-			foreach ($rec as $id => $member)
920
+		foreach ($recipients as $rec_type => $rec) {
921
+					foreach ($rec as $id => $member)
882 922
 			{
883 923
 				if (is_numeric($recipients[$rec_type][$id]))
884 924
 					continue;
925
+		}
885 926
 
886
-				if (!empty($usernames[$member]))
887
-					$recipients[$rec_type][$id] = $usernames[$member];
888
-				else
927
+				if (!empty($usernames[$member])) {
928
+									$recipients[$rec_type][$id] = $usernames[$member];
929
+				} else
889 930
 				{
890 931
 					$log['failed'][$id] = sprintf($txt['pm_error_user_not_found'], $recipients[$rec_type][$id]);
891 932
 					unset($recipients[$rec_type][$id]);
@@ -924,8 +965,9 @@  discard block
 block discarded – undo
924 965
 		foreach ($criteria as $criterium)
925 966
 		{
926 967
 			$match = false;
927
-			if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false))
928
-				$delete = true;
968
+			if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) {
969
+							$delete = true;
970
+			}
929 971
 			// If we're adding and one criteria don't match then we stop!
930 972
 			elseif (!$row['is_or'])
931 973
 			{
@@ -933,8 +975,9 @@  discard block
 block discarded – undo
933 975
 				break;
934 976
 			}
935 977
 		}
936
-		if ($delete)
937
-			$deletes[$row['id_member']] = 1;
978
+		if ($delete) {
979
+					$deletes[$row['id_member']] = 1;
980
+		}
938 981
 	}
939 982
 	$smcFunc['db_free_result']($request);
940 983
 
@@ -949,8 +992,9 @@  discard block
 block discarded – undo
949 992
 			array(
950 993
 			)
951 994
 		);
952
-		while ($row = $smcFunc['db_fetch_assoc']($request))
953
-			$message_limit_cache[$row['id_group']] = $row['max_messages'];
995
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
996
+					$message_limit_cache[$row['id_group']] = $row['max_messages'];
997
+		}
954 998
 		$smcFunc['db_free_result']($request);
955 999
 	}
956 1000
 
@@ -958,8 +1002,9 @@  discard block
 block discarded – undo
958 1002
 	require_once($sourcedir . '/Subs-Members.php');
959 1003
 	$pmReadGroups = groupsAllowedTo('pm_read');
960 1004
 
961
-	if (empty($modSettings['permission_enable_deny']))
962
-		$pmReadGroups['denied'] = array();
1005
+	if (empty($modSettings['permission_enable_deny'])) {
1006
+			$pmReadGroups['denied'] = array();
1007
+	}
963 1008
 
964 1009
 	// Load their alert preferences
965 1010
 	require_once($sourcedir . '/Subs-Notify.php');
@@ -991,8 +1036,9 @@  discard block
 block discarded – undo
991 1036
 	while ($row = $smcFunc['db_fetch_assoc']($request))
992 1037
 	{
993 1038
 		// Don't do anything for members to be deleted!
994
-		if (isset($deletes[$row['id_member']]))
995
-			continue;
1039
+		if (isset($deletes[$row['id_member']])) {
1040
+					continue;
1041
+		}
996 1042
 
997 1043
 		// Load the preferences for this member (if any)
998 1044
 		$prefs = !empty($notifyPrefs[$row['id_member']]) ? $notifyPrefs[$row['id_member']] : array();
@@ -1013,8 +1059,9 @@  discard block
 block discarded – undo
1013 1059
 		{
1014 1060
 			foreach ($groups as $id)
1015 1061
 			{
1016
-				if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id])
1017
-					$message_limit = $message_limit_cache[$id];
1062
+				if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) {
1063
+									$message_limit = $message_limit_cache[$id];
1064
+				}
1018 1065
 			}
1019 1066
 
1020 1067
 			if ($message_limit > 0 && $message_limit <= $row['instant_messages'])
@@ -1062,8 +1109,9 @@  discard block
 block discarded – undo
1062 1109
 	$smcFunc['db_free_result']($request);
1063 1110
 
1064 1111
 	// Only 'send' the message if there are any recipients left.
1065
-	if (empty($all_to))
1066
-		return $log;
1112
+	if (empty($all_to)) {
1113
+			return $log;
1114
+	}
1067 1115
 
1068 1116
 	// Insert the message itself and then grab the last insert id.
1069 1117
 	$smcFunc['db_insert']('',
@@ -1084,8 +1132,8 @@  discard block
 block discarded – undo
1084 1132
 	if (!empty($id_pm))
1085 1133
 	{
1086 1134
 		// If this is new we need to set it part of it's own conversation.
1087
-		if (empty($pm_head))
1088
-			$smcFunc['db_query']('', '
1135
+		if (empty($pm_head)) {
1136
+					$smcFunc['db_query']('', '
1089 1137
 				UPDATE {db_prefix}personal_messages
1090 1138
 				SET id_pm_head = {int:id_pm_head}
1091 1139
 				WHERE id_pm = {int:id_pm_head}',
@@ -1093,6 +1141,7 @@  discard block
 block discarded – undo
1093 1141
 					'id_pm_head' => $id_pm,
1094 1142
 				)
1095 1143
 			);
1144
+		}
1096 1145
 
1097 1146
 		// Some people think manually deleting personal_messages is fun... it's not. We protect against it though :)
1098 1147
 		$smcFunc['db_query']('', '
@@ -1108,8 +1157,9 @@  discard block
 block discarded – undo
1108 1157
 		foreach ($all_to as $to)
1109 1158
 		{
1110 1159
 			$insertRows[] = array($id_pm, $to, in_array($to, $recipients['bcc']) ? 1 : 0, isset($deletes[$to]) ? 1 : 0, 1);
1111
-			if (!in_array($to, $recipients['bcc']))
1112
-				$to_list[] = $to;
1160
+			if (!in_array($to, $recipients['bcc'])) {
1161
+							$to_list[] = $to;
1162
+			}
1113 1163
 		}
1114 1164
 
1115 1165
 		$smcFunc['db_insert']('insert',
@@ -1127,9 +1177,9 @@  discard block
 block discarded – undo
1127 1177
 	{
1128 1178
 		censorText($message);
1129 1179
 		$message = trim(un_htmlspecialchars(strip_tags(strtr(parse_bbc($smcFunc['htmlspecialchars']($message), false), array('<br>' => "\n", '</div>' => "\n", '</li>' => "\n", '&#91;' => '[', '&#93;' => ']')))));
1180
+	} else {
1181
+			$message = '';
1130 1182
 	}
1131
-	else
1132
-		$message = '';
1133 1183
 
1134 1184
 	$to_names = array();
1135 1185
 	if (count($to_list) > 1)
@@ -1142,8 +1192,9 @@  discard block
 block discarded – undo
1142 1192
 				'to_members' => $to_list,
1143 1193
 			)
1144 1194
 		);
1145
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1146
-			$to_names[] = un_htmlspecialchars($row['real_name']);
1195
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1196
+					$to_names[] = un_htmlspecialchars($row['real_name']);
1197
+		}
1147 1198
 		$smcFunc['db_free_result']($request);
1148 1199
 	}
1149 1200
 	$replacements = array(
@@ -1171,11 +1222,13 @@  discard block
 block discarded – undo
1171 1222
 	loadLanguage('index+PersonalMessage');
1172 1223
 
1173 1224
 	// Add one to their unread and read message counts.
1174
-	foreach ($all_to as $k => $id)
1175
-		if (isset($deletes[$id]))
1225
+	foreach ($all_to as $k => $id) {
1226
+			if (isset($deletes[$id]))
1176 1227
 			unset($all_to[$k]);
1177
-	if (!empty($all_to))
1178
-		updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1));
1228
+	}
1229
+	if (!empty($all_to)) {
1230
+			updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1));
1231
+	}
1179 1232
 
1180 1233
 	return $log;
1181 1234
 }
@@ -1205,15 +1258,17 @@  discard block
 block discarded – undo
1205 1258
 		// Let's, for now, assume there are only &#021;'ish characters.
1206 1259
 		$simple = true;
1207 1260
 
1208
-		foreach ($matches[1] as $entity)
1209
-			if ($entity > 128)
1261
+		foreach ($matches[1] as $entity) {
1262
+					if ($entity > 128)
1210 1263
 				$simple = false;
1264
+		}
1211 1265
 		unset($matches);
1212 1266
 
1213
-		if ($simple)
1214
-			$string = preg_replace_callback('~&#(\d{3,8});~', function ($m)
1267
+		if ($simple) {
1268
+					$string = preg_replace_callback('~&#(\d{3,8});~', function ($m)
1215 1269
 			{
1216 1270
 				return chr("$m[1]");
1271
+		}
1217 1272
 			}, $string);
1218 1273
 		else
1219 1274
 		{
@@ -1221,8 +1276,9 @@  discard block
 block discarded – undo
1221 1276
 			if (!$context['utf8'] && function_exists('iconv'))
1222 1277
 			{
1223 1278
 				$newstring = @iconv($context['character_set'], 'UTF-8', $string);
1224
-				if ($newstring)
1225
-					$string = $newstring;
1279
+				if ($newstring) {
1280
+									$string = $newstring;
1281
+				}
1226 1282
 			}
1227 1283
 
1228 1284
 			$string = preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $string);
@@ -1238,23 +1294,25 @@  discard block
 block discarded – undo
1238 1294
 		if (!$context['utf8'] && function_exists('iconv'))
1239 1295
 		{
1240 1296
 			$newstring = @iconv($context['character_set'], 'UTF-8', $string);
1241
-			if ($newstring)
1242
-				$string = $newstring;
1297
+			if ($newstring) {
1298
+							$string = $newstring;
1299
+			}
1243 1300
 		}
1244 1301
 
1245 1302
 		$entityConvert = function ($m)
1246 1303
 		{
1247 1304
 			$c = $m[1];
1248
-			if (strlen($c) === 1 && ord($c[0]) <= 0x7F)
1249
-				return $c;
1250
-			elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF)
1251
-				return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";";
1252
-			elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF)
1253
-				return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";";
1254
-			elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7)
1255
-				return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";";
1256
-			else
1257
-				return "";
1305
+			if (strlen($c) === 1 && ord($c[0]) <= 0x7F) {
1306
+							return $c;
1307
+			} elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) {
1308
+							return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";";
1309
+			} elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) {
1310
+							return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";";
1311
+			} elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) {
1312
+							return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";";
1313
+			} else {
1314
+							return "";
1315
+			}
1258 1316
 		};
1259 1317
 
1260 1318
 		// Convert all 'special' characters to HTML entities.
@@ -1268,19 +1326,20 @@  discard block
 block discarded – undo
1268 1326
 		$string = base64_encode($string);
1269 1327
 
1270 1328
 		// Show the characterset and the transfer-encoding for header strings.
1271
-		if ($with_charset)
1272
-			$string = '=?' . $charset . '?B?' . $string . '?=';
1329
+		if ($with_charset) {
1330
+					$string = '=?' . $charset . '?B?' . $string . '?=';
1331
+		}
1273 1332
 
1274 1333
 		// Break it up in lines (mail body).
1275
-		else
1276
-			$string = chunk_split($string, 76, $line_break);
1334
+		else {
1335
+					$string = chunk_split($string, 76, $line_break);
1336
+		}
1277 1337
 
1278 1338
 		return array($charset, $string, 'base64');
1339
+	} else {
1340
+			return array($charset, $string, '7bit');
1341
+	}
1279 1342
 	}
1280
-
1281
-	else
1282
-		return array($charset, $string, '7bit');
1283
-}
1284 1343
 
1285 1344
 /**
1286 1345
  * Sends mail, like mail() but over SMTP.
@@ -1304,8 +1363,9 @@  discard block
 block discarded – undo
1304 1363
 	if ($modSettings['mail_type'] == 3 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '')
1305 1364
 	{
1306 1365
 		$socket = fsockopen($modSettings['smtp_host'], 110, $errno, $errstr, 2);
1307
-		if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.'))
1308
-			$socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2);
1366
+		if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) {
1367
+					$socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2);
1368
+		}
1309 1369
 
1310 1370
 		if ($socket)
1311 1371
 		{
@@ -1326,8 +1386,9 @@  discard block
 block discarded – undo
1326 1386
 		// Maybe we can still save this?  The port might be wrong.
1327 1387
 		if (substr($modSettings['smtp_host'], 0, 4) == 'ssl:' && (empty($modSettings['smtp_port']) || $modSettings['smtp_port'] == 25))
1328 1388
 		{
1329
-			if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3))
1330
-				log_error($txt['smtp_port_ssl']);
1389
+			if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) {
1390
+							log_error($txt['smtp_port_ssl']);
1391
+			}
1331 1392
 		}
1332 1393
 
1333 1394
 		// Unable to connect!  Don't show any error message, but just log one and try to continue anyway.
@@ -1339,20 +1400,23 @@  discard block
 block discarded – undo
1339 1400
 	}
1340 1401
 
1341 1402
 	// Wait for a response of 220, without "-" continuer.
1342
-	if (!server_parse(null, $socket, '220'))
1343
-		return false;
1403
+	if (!server_parse(null, $socket, '220')) {
1404
+			return false;
1405
+	}
1344 1406
 
1345 1407
 	// Try and determine the servers name, fall back to the mail servers if not found
1346 1408
 	$helo = false;
1347
-	if (function_exists('gethostname') && gethostname() !== false)
1348
-		$helo = gethostname();
1349
-	elseif (function_exists('php_uname'))
1350
-		$helo = php_uname('n');
1351
-	elseif (array_key_exists('SERVER_NAME',$_SERVER) && !empty($_SERVER['SERVER_NAME']))
1352
-		$helo = $_SERVER['SERVER_NAME'];
1409
+	if (function_exists('gethostname') && gethostname() !== false) {
1410
+			$helo = gethostname();
1411
+	} elseif (function_exists('php_uname')) {
1412
+			$helo = php_uname('n');
1413
+	} elseif (array_key_exists('SERVER_NAME',$_SERVER) && !empty($_SERVER['SERVER_NAME'])) {
1414
+			$helo = $_SERVER['SERVER_NAME'];
1415
+	}
1353 1416
 
1354
-	if (empty($helo))
1355
-		$helo = $modSettings['smtp_host'];
1417
+	if (empty($helo)) {
1418
+			$helo = $modSettings['smtp_host'];
1419
+	}
1356 1420
 
1357 1421
 	// SMTP = 1, SMTP - STARTTLS = 2
1358 1422
 	if (in_array($modSettings['mail_type'], array(1,2)) && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '')
@@ -1364,33 +1428,39 @@  discard block
 block discarded – undo
1364 1428
 			if ($modSettings['mail_type'] == 2 && preg_match("~250( |-)STARTTLS~mi", $response))
1365 1429
 			{
1366 1430
 				// Send STARTTLS to enable encryption
1367
-				if (!server_parse('STARTTLS', $socket, '220'))
1368
-					return false;
1431
+				if (!server_parse('STARTTLS', $socket, '220')) {
1432
+									return false;
1433
+				}
1369 1434
 				// Enable the encryption
1370
-				if (!@stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT))
1371
-					return false;
1435
+				if (!@stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
1436
+									return false;
1437
+				}
1372 1438
 				// Send the EHLO command again
1373
-				if (!server_parse('EHLO ' . $helo, $socket, null) == '250')
1374
-					return false;
1439
+				if (!server_parse('EHLO ' . $helo, $socket, null) == '250') {
1440
+									return false;
1441
+				}
1375 1442
 			}
1376 1443
 
1377
-			if (!server_parse('AUTH LOGIN', $socket, '334'))
1378
-				return false;
1444
+			if (!server_parse('AUTH LOGIN', $socket, '334')) {
1445
+							return false;
1446
+			}
1379 1447
 			// Send the username and password, encoded.
1380
-			if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334'))
1381
-				return false;
1448
+			if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) {
1449
+							return false;
1450
+			}
1382 1451
 			// The password is already encoded ;)
1383
-			if (!server_parse($modSettings['smtp_password'], $socket, '235'))
1384
-				return false;
1452
+			if (!server_parse($modSettings['smtp_password'], $socket, '235')) {
1453
+							return false;
1454
+			}
1455
+		} elseif (!server_parse('HELO ' . $helo, $socket, '250')) {
1456
+					return false;
1385 1457
 		}
1386
-		elseif (!server_parse('HELO ' . $helo, $socket, '250'))
1387
-			return false;
1388
-	}
1389
-	else
1458
+	} else
1390 1459
 	{
1391 1460
 		// Just say "helo".
1392
-		if (!server_parse('HELO ' . $helo, $socket, '250'))
1393
-			return false;
1461
+		if (!server_parse('HELO ' . $helo, $socket, '250')) {
1462
+					return false;
1463
+		}
1394 1464
 	}
1395 1465
 
1396 1466
 	// Fix the message for any lines beginning with a period! (the first is ignored, you see.)
@@ -1403,31 +1473,38 @@  discard block
 block discarded – undo
1403 1473
 		// Reset the connection to send another email.
1404 1474
 		if ($i != 0)
1405 1475
 		{
1406
-			if (!server_parse('RSET', $socket, '250'))
1407
-				return false;
1476
+			if (!server_parse('RSET', $socket, '250')) {
1477
+							return false;
1478
+			}
1408 1479
 		}
1409 1480
 
1410 1481
 		// From, to, and then start the data...
1411
-		if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250'))
1412
-			return false;
1413
-		if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250'))
1414
-			return false;
1415
-		if (!server_parse('DATA', $socket, '354'))
1416
-			return false;
1482
+		if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) {
1483
+					return false;
1484
+		}
1485
+		if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) {
1486
+					return false;
1487
+		}
1488
+		if (!server_parse('DATA', $socket, '354')) {
1489
+					return false;
1490
+		}
1417 1491
 		fputs($socket, 'Subject: ' . $subject . "\r\n");
1418
-		if (strlen($mail_to) > 0)
1419
-			fputs($socket, 'To: <' . $mail_to . '>' . "\r\n");
1492
+		if (strlen($mail_to) > 0) {
1493
+					fputs($socket, 'To: <' . $mail_to . '>' . "\r\n");
1494
+		}
1420 1495
 		fputs($socket, $headers . "\r\n\r\n");
1421 1496
 		fputs($socket, $message . "\r\n");
1422 1497
 
1423 1498
 		// Send a ., or in other words "end of data".
1424
-		if (!server_parse('.', $socket, '250'))
1425
-			return false;
1499
+		if (!server_parse('.', $socket, '250')) {
1500
+					return false;
1501
+		}
1426 1502
 
1427 1503
 		// Almost done, almost done... don't stop me just yet!
1428 1504
 		@set_time_limit(300);
1429
-		if (function_exists('apache_reset_timeout'))
1430
-			@apache_reset_timeout();
1505
+		if (function_exists('apache_reset_timeout')) {
1506
+					@apache_reset_timeout();
1507
+		}
1431 1508
 	}
1432 1509
 	fputs($socket, 'QUIT' . "\r\n");
1433 1510
 	fclose($socket);
@@ -1451,8 +1528,9 @@  discard block
 block discarded – undo
1451 1528
 {
1452 1529
 	global $txt;
1453 1530
 
1454
-	if ($message !== null)
1455
-		fputs($socket, $message . "\r\n");
1531
+	if ($message !== null) {
1532
+			fputs($socket, $message . "\r\n");
1533
+	}
1456 1534
 
1457 1535
 	// No response yet.
1458 1536
 	$server_response = '';
@@ -1468,8 +1546,9 @@  discard block
 block discarded – undo
1468 1546
 		$response .= $server_response;
1469 1547
 	}
1470 1548
 
1471
-	if ($code === null)
1472
-		return substr($server_response, 0, 3);
1549
+	if ($code === null) {
1550
+			return substr($server_response, 0, 3);
1551
+	}
1473 1552
 
1474 1553
 	if (substr($server_response, 0, 3) != $code)
1475 1554
 	{
@@ -1499,8 +1578,9 @@  discard block
 block discarded – undo
1499 1578
 	// Create a pspell or enchant dictionary resource
1500 1579
 	$dict = spell_init();
1501 1580
 
1502
-	if (!isset($_POST['spellstring']) || !$dict)
1503
-		die;
1581
+	if (!isset($_POST['spellstring']) || !$dict) {
1582
+			die;
1583
+	}
1504 1584
 
1505 1585
 	// Construct a bit of Javascript code.
1506 1586
 	$context['spell_js'] = '
@@ -1518,8 +1598,9 @@  discard block
 block discarded – undo
1518 1598
 		$check_word = explode('|', $alphas[$i]);
1519 1599
 
1520 1600
 		// If the word is a known word, or spelled right...
1521
-		if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2]))
1522
-			continue;
1601
+		if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) {
1602
+					continue;
1603
+		}
1523 1604
 
1524 1605
 		// Find the word, and move up the "last occurrence" to here.
1525 1606
 		$found_words = true;
@@ -1533,20 +1614,23 @@  discard block
 block discarded – undo
1533 1614
 		if (!empty($suggestions))
1534 1615
 		{
1535 1616
 			// But first check they aren't going to be censored - no naughty words!
1536
-			foreach ($suggestions as $k => $word)
1537
-				if ($suggestions[$k] != censorText($word))
1617
+			foreach ($suggestions as $k => $word) {
1618
+							if ($suggestions[$k] != censorText($word))
1538 1619
 					unset($suggestions[$k]);
1620
+			}
1539 1621
 
1540
-			if (!empty($suggestions))
1541
-				$context['spell_js'] .= '"' . implode('", "', $suggestions) . '"';
1622
+			if (!empty($suggestions)) {
1623
+							$context['spell_js'] .= '"' . implode('", "', $suggestions) . '"';
1624
+			}
1542 1625
 		}
1543 1626
 
1544 1627
 		$context['spell_js'] .= ']),';
1545 1628
 	}
1546 1629
 
1547 1630
 	// If words were found, take off the last comma.
1548
-	if ($found_words)
1549
-		$context['spell_js'] = substr($context['spell_js'], 0, -1);
1631
+	if ($found_words) {
1632
+			$context['spell_js'] = substr($context['spell_js'], 0, -1);
1633
+	}
1550 1634
 
1551 1635
 	$context['spell_js'] .= '
1552 1636
 		);';
@@ -1581,11 +1665,13 @@  discard block
 block discarded – undo
1581 1665
 	global $user_info, $smcFunc;
1582 1666
 
1583 1667
 	// Can't do it if there's no topics.
1584
-	if (empty($topics))
1585
-		return;
1668
+	if (empty($topics)) {
1669
+			return;
1670
+	}
1586 1671
 	// It must be an array - it must!
1587
-	if (!is_array($topics))
1588
-		$topics = array($topics);
1672
+	if (!is_array($topics)) {
1673
+			$topics = array($topics);
1674
+	}
1589 1675
 
1590 1676
 	// Get the subject and body...
1591 1677
 	$result = $smcFunc['db_query']('', '
@@ -1633,14 +1719,15 @@  discard block
 block discarded – undo
1633 1719
 	}
1634 1720
 	$smcFunc['db_free_result']($result);
1635 1721
 
1636
-	if (!empty($task_rows))
1637
-		$smcFunc['db_insert']('',
1722
+	if (!empty($task_rows)) {
1723
+			$smcFunc['db_insert']('',
1638 1724
 			'{db_prefix}background_tasks',
1639 1725
 			array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
1640 1726
 			$task_rows,
1641 1727
 			array('id_task')
1642 1728
 		);
1643
-}
1729
+	}
1730
+	}
1644 1731
 
1645 1732
 /**
1646 1733
  * Create a post, either as new topic (id_topic = 0) or in an existing one.
@@ -1678,9 +1765,9 @@  discard block
 block discarded – undo
1678 1765
 	$msgOptions['send_notifications'] = isset($msgOptions['send_notifications']) ? (bool) $msgOptions['send_notifications'] : true;
1679 1766
 
1680 1767
 	// We need to know if the topic is approved. If we're told that's great - if not find out.
1681
-	if (!$modSettings['postmod_active'])
1682
-		$topicOptions['is_approved'] = true;
1683
-	elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved']))
1768
+	if (!$modSettings['postmod_active']) {
1769
+			$topicOptions['is_approved'] = true;
1770
+	} elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved']))
1684 1771
 	{
1685 1772
 		$request = $smcFunc['db_query']('', '
1686 1773
 			SELECT approved
@@ -1703,8 +1790,7 @@  discard block
 block discarded – undo
1703 1790
 			$posterOptions['id'] = 0;
1704 1791
 			$posterOptions['name'] = $txt['guest_title'];
1705 1792
 			$posterOptions['email'] = '';
1706
-		}
1707
-		elseif ($posterOptions['id'] != $user_info['id'])
1793
+		} elseif ($posterOptions['id'] != $user_info['id'])
1708 1794
 		{
1709 1795
 			$request = $smcFunc['db_query']('', '
1710 1796
 				SELECT member_name, email_address
@@ -1722,12 +1808,11 @@  discard block
 block discarded – undo
1722 1808
 				$posterOptions['id'] = 0;
1723 1809
 				$posterOptions['name'] = $txt['guest_title'];
1724 1810
 				$posterOptions['email'] = '';
1811
+			} else {
1812
+							list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request);
1725 1813
 			}
1726
-			else
1727
-				list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request);
1728 1814
 			$smcFunc['db_free_result']($request);
1729
-		}
1730
-		else
1815
+		} else
1731 1816
 		{
1732 1817
 			$posterOptions['name'] = $user_info['name'];
1733 1818
 			$posterOptions['email'] = $user_info['email'];
@@ -1737,8 +1822,9 @@  discard block
 block discarded – undo
1737 1822
 	if (!empty($modSettings['enable_mentions']))
1738 1823
 	{
1739 1824
 		$msgOptions['mentioned_members'] = Mentions::getMentionedMembers($msgOptions['body']);
1740
-		if (!empty($msgOptions['mentioned_members']))
1741
-			$msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']);
1825
+		if (!empty($msgOptions['mentioned_members'])) {
1826
+					$msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']);
1827
+		}
1742 1828
 	}
1743 1829
 
1744 1830
 	// It's do or die time: forget any user aborts!
@@ -1771,12 +1857,13 @@  discard block
 block discarded – undo
1771 1857
 	$msgOptions['id'] = $smcFunc['db_insert_id']('{db_prefix}messages', 'id_msg');
1772 1858
 
1773 1859
 	// Something went wrong creating the message...
1774
-	if (empty($msgOptions['id']))
1775
-		return false;
1860
+	if (empty($msgOptions['id'])) {
1861
+			return false;
1862
+	}
1776 1863
 
1777 1864
 	// Fix the attachments.
1778
-	if (!empty($msgOptions['attachments']))
1779
-		$smcFunc['db_query']('', '
1865
+	if (!empty($msgOptions['attachments'])) {
1866
+			$smcFunc['db_query']('', '
1780 1867
 			UPDATE {db_prefix}attachments
1781 1868
 			SET id_msg = {int:id_msg}
1782 1869
 			WHERE id_attach IN ({array_int:attachment_list})',
@@ -1785,6 +1872,7 @@  discard block
 block discarded – undo
1785 1872
 				'id_msg' => $msgOptions['id'],
1786 1873
 			)
1787 1874
 		);
1875
+	}
1788 1876
 
1789 1877
 	// What if we want to export new posts out to a CMS?
1790 1878
 	call_integration_hook('integrate_after_create_post', array($msgOptions, $topicOptions, $posterOptions, $message_columns, $message_parameters));
@@ -1862,20 +1950,23 @@  discard block
 block discarded – undo
1862 1950
 			'counter_increment' => 1,
1863 1951
 		);
1864 1952
 		$topics_columns = array();
1865
-		if ($msgOptions['approved'])
1866
-			$topics_columns = array(
1953
+		if ($msgOptions['approved']) {
1954
+					$topics_columns = array(
1867 1955
 				'id_member_updated = {int:poster_id}',
1868 1956
 				'id_last_msg = {int:id_msg}',
1869 1957
 				'num_replies = num_replies + {int:counter_increment}',
1870 1958
 			);
1871
-		else
1872
-			$topics_columns = array(
1959
+		} else {
1960
+					$topics_columns = array(
1873 1961
 				'unapproved_posts = unapproved_posts + {int:counter_increment}',
1874 1962
 			);
1875
-		if ($topicOptions['lock_mode'] !== null)
1876
-			$topics_columns[] = 'locked = {int:locked}';
1877
-		if ($topicOptions['sticky_mode'] !== null)
1878
-			$topics_columns[] = 'is_sticky = {int:is_sticky}';
1963
+		}
1964
+		if ($topicOptions['lock_mode'] !== null) {
1965
+					$topics_columns[] = 'locked = {int:locked}';
1966
+		}
1967
+		if ($topicOptions['sticky_mode'] !== null) {
1968
+					$topics_columns[] = 'is_sticky = {int:is_sticky}';
1969
+		}
1879 1970
 
1880 1971
 		call_integration_hook('integrate_modify_topic', array(&$topics_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions));
1881 1972
 
@@ -1904,8 +1995,8 @@  discard block
 block discarded – undo
1904 1995
 	);
1905 1996
 
1906 1997
 	// Increase the number of posts and topics on the board.
1907
-	if ($msgOptions['approved'])
1908
-		$smcFunc['db_query']('', '
1998
+	if ($msgOptions['approved']) {
1999
+			$smcFunc['db_query']('', '
1909 2000
 			UPDATE {db_prefix}boards
1910 2001
 			SET num_posts = num_posts + 1' . ($new_topic ? ', num_topics = num_topics + 1' : '') . '
1911 2002
 			WHERE id_board = {int:id_board}',
@@ -1913,7 +2004,7 @@  discard block
 block discarded – undo
1913 2004
 				'id_board' => $topicOptions['board'],
1914 2005
 			)
1915 2006
 		);
1916
-	else
2007
+	} else
1917 2008
 	{
1918 2009
 		$smcFunc['db_query']('', '
1919 2010
 			UPDATE {db_prefix}boards
@@ -1983,8 +2074,8 @@  discard block
 block discarded – undo
1983 2074
 		}
1984 2075
 	}
1985 2076
 
1986
-	if ($msgOptions['approved'] && empty($topicOptions['is_approved']))
1987
-		$smcFunc['db_insert']('',
2077
+	if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) {
2078
+			$smcFunc['db_insert']('',
1988 2079
 			'{db_prefix}background_tasks',
1989 2080
 			array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
1990 2081
 			array(
@@ -1996,19 +2087,22 @@  discard block
 block discarded – undo
1996 2087
 			),
1997 2088
 			array('id_task')
1998 2089
 		);
2090
+	}
1999 2091
 
2000 2092
 	// If there's a custom search index, it may need updating...
2001 2093
 	require_once($sourcedir . '/Search.php');
2002 2094
 	$searchAPI = findSearchAPI();
2003
-	if (is_callable(array($searchAPI, 'postCreated')))
2004
-		$searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions);
2095
+	if (is_callable(array($searchAPI, 'postCreated'))) {
2096
+			$searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions);
2097
+	}
2005 2098
 
2006 2099
 	// Increase the post counter for the user that created the post.
2007 2100
 	if (!empty($posterOptions['update_post_count']) && !empty($posterOptions['id']) && $msgOptions['approved'])
2008 2101
 	{
2009 2102
 		// Are you the one that happened to create this post?
2010
-		if ($user_info['id'] == $posterOptions['id'])
2011
-			$user_info['posts']++;
2103
+		if ($user_info['id'] == $posterOptions['id']) {
2104
+					$user_info['posts']++;
2105
+		}
2012 2106
 		updateMemberData($posterOptions['id'], array('posts' => '+'));
2013 2107
 	}
2014 2108
 
@@ -2016,19 +2110,21 @@  discard block
 block discarded – undo
2016 2110
 	$_SESSION['last_read_topic'] = 0;
2017 2111
 
2018 2112
 	// Better safe than sorry.
2019
-	if (isset($_SESSION['topicseen_cache'][$topicOptions['board']]))
2020
-		$_SESSION['topicseen_cache'][$topicOptions['board']]--;
2113
+	if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) {
2114
+			$_SESSION['topicseen_cache'][$topicOptions['board']]--;
2115
+	}
2021 2116
 
2022 2117
 	// Update all the stats so everyone knows about this new topic and message.
2023 2118
 	updateStats('message', true, $msgOptions['id']);
2024 2119
 
2025 2120
 	// Update the last message on the board assuming it's approved AND the topic is.
2026
-	if ($msgOptions['approved'])
2027
-		updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0);
2121
+	if ($msgOptions['approved']) {
2122
+			updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0);
2123
+	}
2028 2124
 
2029 2125
 	// Queue createPost background notification
2030
-	if ($msgOptions['send_notifications'] && $msgOptions['approved'])
2031
-		$smcFunc['db_insert']('',
2126
+	if ($msgOptions['send_notifications'] && $msgOptions['approved']) {
2127
+			$smcFunc['db_insert']('',
2032 2128
 			'{db_prefix}background_tasks',
2033 2129
 			array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
2034 2130
 			array('$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', json_encode(array(
@@ -2039,6 +2135,7 @@  discard block
 block discarded – undo
2039 2135
 			)), 0),
2040 2136
 			array('id_task')
2041 2137
 		);
2138
+	}
2042 2139
 
2043 2140
 	// Alright, done now... we can abort now, I guess... at least this much is done.
2044 2141
 	ignore_user_abort($previous_ignore_user_abort);
@@ -2065,14 +2162,18 @@  discard block
 block discarded – undo
2065 2162
 
2066 2163
 	// This is longer than it has to be, but makes it so we only set/change what we have to.
2067 2164
 	$messages_columns = array();
2068
-	if (isset($posterOptions['name']))
2069
-		$messages_columns['poster_name'] = $posterOptions['name'];
2070
-	if (isset($posterOptions['email']))
2071
-		$messages_columns['poster_email'] = $posterOptions['email'];
2072
-	if (isset($msgOptions['icon']))
2073
-		$messages_columns['icon'] = $msgOptions['icon'];
2074
-	if (isset($msgOptions['subject']))
2075
-		$messages_columns['subject'] = $msgOptions['subject'];
2165
+	if (isset($posterOptions['name'])) {
2166
+			$messages_columns['poster_name'] = $posterOptions['name'];
2167
+	}
2168
+	if (isset($posterOptions['email'])) {
2169
+			$messages_columns['poster_email'] = $posterOptions['email'];
2170
+	}
2171
+	if (isset($msgOptions['icon'])) {
2172
+			$messages_columns['icon'] = $msgOptions['icon'];
2173
+	}
2174
+	if (isset($msgOptions['subject'])) {
2175
+			$messages_columns['subject'] = $msgOptions['subject'];
2176
+	}
2076 2177
 	if (isset($msgOptions['body']))
2077 2178
 	{
2078 2179
 		$messages_columns['body'] = $msgOptions['body'];
@@ -2099,8 +2200,9 @@  discard block
 block discarded – undo
2099 2200
 		$messages_columns['modified_reason'] = $msgOptions['modify_reason'];
2100 2201
 		$messages_columns['id_msg_modified'] = $modSettings['maxMsgID'];
2101 2202
 	}
2102
-	if (isset($msgOptions['smileys_enabled']))
2103
-		$messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1;
2203
+	if (isset($msgOptions['smileys_enabled'])) {
2204
+			$messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1;
2205
+	}
2104 2206
 
2105 2207
 	// Which columns need to be ints?
2106 2208
 	$messageInts = array('modified_time', 'id_msg_modified', 'smileys_enabled');
@@ -2118,23 +2220,27 @@  discard block
 block discarded – undo
2118 2220
 		{
2119 2221
 			preg_match_all('/\[member\=([0-9]+)\]([^\[]*)\[\/member\]/U', $msgOptions['old_body'], $match);
2120 2222
 
2121
-			if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2]))
2122
-				foreach($match[1] as $i => $oldID)
2223
+			if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) {
2224
+							foreach($match[1] as $i => $oldID)
2123 2225
 					$oldmentions[$oldID] = array('id' => $oldID, 'real_name' => $match[2][$i]);
2226
+			}
2124 2227
 
2125
-			if (empty($modSettings['search_custom_index_config']))
2126
-				unset($msgOptions['old_body']);
2228
+			if (empty($modSettings['search_custom_index_config'])) {
2229
+							unset($msgOptions['old_body']);
2230
+			}
2127 2231
 		}
2128 2232
 
2129 2233
 		$mentions = Mentions::getMentionedMembers($msgOptions['body']);
2130 2234
 		$messages_columns['body'] = $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $mentions);
2131 2235
 
2132 2236
 		// Remove the poster.
2133
-		if(isset($mentions[$user_info['id']]))
2134
-			unset($mentions[$user_info['id']]);
2237
+		if(isset($mentions[$user_info['id']])) {
2238
+					unset($mentions[$user_info['id']]);
2239
+		}
2135 2240
 
2136
-		if(isset($oldmentions[$user_info['id']]))
2137
-			unset($oldmentions[$user_info['id']]);
2241
+		if(isset($oldmentions[$user_info['id']])) {
2242
+					unset($oldmentions[$user_info['id']]);
2243
+		}
2138 2244
 
2139 2245
 		if (is_array($mentions) && is_array($oldmentions) && count(array_diff_key($mentions, $oldmentions)) > 0 && count($mentions) > count($oldmentions))
2140 2246
 		{
@@ -2164,8 +2270,9 @@  discard block
 block discarded – undo
2164 2270
 	}
2165 2271
 
2166 2272
 	// Nothing to do?
2167
-	if (empty($messages_columns))
2168
-		return true;
2273
+	if (empty($messages_columns)) {
2274
+			return true;
2275
+	}
2169 2276
 
2170 2277
 	// Change the post.
2171 2278
 	$smcFunc['db_query']('', '
@@ -2226,8 +2333,9 @@  discard block
 block discarded – undo
2226 2333
 	// If there's a custom search index, it needs to be modified...
2227 2334
 	require_once($sourcedir . '/Search.php');
2228 2335
 	$searchAPI = findSearchAPI();
2229
-	if (is_callable(array($searchAPI, 'postModified')))
2230
-		$searchAPI->postModified($msgOptions, $topicOptions, $posterOptions);
2336
+	if (is_callable(array($searchAPI, 'postModified'))) {
2337
+			$searchAPI->postModified($msgOptions, $topicOptions, $posterOptions);
2338
+	}
2231 2339
 
2232 2340
 	if (isset($msgOptions['subject']))
2233 2341
 	{
@@ -2241,14 +2349,16 @@  discard block
 block discarded – undo
2241 2349
 				'id_first_msg' => $msgOptions['id'],
2242 2350
 			)
2243 2351
 		);
2244
-		if ($smcFunc['db_num_rows']($request) == 1)
2245
-			updateStats('subject', $topicOptions['id'], $msgOptions['subject']);
2352
+		if ($smcFunc['db_num_rows']($request) == 1) {
2353
+					updateStats('subject', $topicOptions['id'], $msgOptions['subject']);
2354
+		}
2246 2355
 		$smcFunc['db_free_result']($request);
2247 2356
 	}
2248 2357
 
2249 2358
 	// Finally, if we are setting the approved state we need to do much more work :(
2250
-	if ($modSettings['postmod_active'] && isset($msgOptions['approved']))
2251
-		approvePosts($msgOptions['id'], $msgOptions['approved']);
2359
+	if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) {
2360
+			approvePosts($msgOptions['id'], $msgOptions['approved']);
2361
+	}
2252 2362
 
2253 2363
 	return true;
2254 2364
 }
@@ -2265,11 +2375,13 @@  discard block
 block discarded – undo
2265 2375
 {
2266 2376
 	global $smcFunc;
2267 2377
 
2268
-	if (!is_array($msgs))
2269
-		$msgs = array($msgs);
2378
+	if (!is_array($msgs)) {
2379
+			$msgs = array($msgs);
2380
+	}
2270 2381
 
2271
-	if (empty($msgs))
2272
-		return false;
2382
+	if (empty($msgs)) {
2383
+			return false;
2384
+	}
2273 2385
 
2274 2386
 	// May as well start at the beginning, working out *what* we need to change.
2275 2387
 	$request = $smcFunc['db_query']('', '
@@ -2301,20 +2413,22 @@  discard block
 block discarded – undo
2301 2413
 		$topics[] = $row['id_topic'];
2302 2414
 
2303 2415
 		// Ensure our change array exists already.
2304
-		if (!isset($topic_changes[$row['id_topic']]))
2305
-			$topic_changes[$row['id_topic']] = array(
2416
+		if (!isset($topic_changes[$row['id_topic']])) {
2417
+					$topic_changes[$row['id_topic']] = array(
2306 2418
 				'id_last_msg' => $row['id_last_msg'],
2307 2419
 				'approved' => $row['topic_approved'],
2308 2420
 				'replies' => 0,
2309 2421
 				'unapproved_posts' => 0,
2310 2422
 			);
2311
-		if (!isset($board_changes[$row['id_board']]))
2312
-			$board_changes[$row['id_board']] = array(
2423
+		}
2424
+		if (!isset($board_changes[$row['id_board']])) {
2425
+					$board_changes[$row['id_board']] = array(
2313 2426
 				'posts' => 0,
2314 2427
 				'topics' => 0,
2315 2428
 				'unapproved_posts' => 0,
2316 2429
 				'unapproved_topics' => 0,
2317 2430
 			);
2431
+		}
2318 2432
 
2319 2433
 		// If it's the first message then the topic state changes!
2320 2434
 		if ($row['id_msg'] == $row['id_first_msg'])
@@ -2335,14 +2449,13 @@  discard block
 block discarded – undo
2335 2449
 				'poster' => $row['id_member'],
2336 2450
 				'new_topic' => true,
2337 2451
 			);
2338
-		}
2339
-		else
2452
+		} else
2340 2453
 		{
2341 2454
 			$topic_changes[$row['id_topic']]['replies'] += $approve ? 1 : -1;
2342 2455
 
2343 2456
 			// This will be a post... but don't notify unless it's not followed by approved ones.
2344
-			if ($row['id_msg'] > $row['id_last_msg'])
2345
-				$notification_posts[$row['id_topic']] = array(
2457
+			if ($row['id_msg'] > $row['id_last_msg']) {
2458
+							$notification_posts[$row['id_topic']] = array(
2346 2459
 					'id' => $row['id_msg'],
2347 2460
 					'body' => $row['body'],
2348 2461
 					'subject' => $row['subject'],
@@ -2353,28 +2466,33 @@  discard block
 block discarded – undo
2353 2466
 					'new_topic' => false,
2354 2467
 					'msg' => $row['id_msg'],
2355 2468
 				);
2469
+			}
2356 2470
 		}
2357 2471
 
2358 2472
 		// If this is being approved and id_msg is higher than the current id_last_msg then it changes.
2359
-		if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg'])
2360
-			$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg'];
2473
+		if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) {
2474
+					$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg'];
2475
+		}
2361 2476
 		// If this is being unapproved, and it's equal to the id_last_msg we need to find a new one!
2362
-		elseif (!$approve)
2363
-			// Default to the first message and then we'll override in a bit ;)
2477
+		elseif (!$approve) {
2478
+					// Default to the first message and then we'll override in a bit ;)
2364 2479
 			$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_first_msg'];
2480
+		}
2365 2481
 
2366 2482
 		$topic_changes[$row['id_topic']]['unapproved_posts'] += $approve ? -1 : 1;
2367 2483
 		$board_changes[$row['id_board']]['unapproved_posts'] += $approve ? -1 : 1;
2368 2484
 		$board_changes[$row['id_board']]['posts'] += $approve ? 1 : -1;
2369 2485
 
2370 2486
 		// Post count for the user?
2371
-		if ($row['id_member'] && empty($row['count_posts']))
2372
-			$member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1;
2487
+		if ($row['id_member'] && empty($row['count_posts'])) {
2488
+					$member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1;
2489
+		}
2373 2490
 	}
2374 2491
 	$smcFunc['db_free_result']($request);
2375 2492
 
2376
-	if (empty($msgs))
2377
-		return;
2493
+	if (empty($msgs)) {
2494
+			return;
2495
+	}
2378 2496
 
2379 2497
 	// Now we have the differences make the changes, first the easy one.
2380 2498
 	$smcFunc['db_query']('', '
@@ -2401,14 +2519,15 @@  discard block
 block discarded – undo
2401 2519
 				'approved' => 1,
2402 2520
 			)
2403 2521
 		);
2404
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2405
-			$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg'];
2522
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2523
+					$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg'];
2524
+		}
2406 2525
 		$smcFunc['db_free_result']($request);
2407 2526
 	}
2408 2527
 
2409 2528
 	// ... next the topics...
2410
-	foreach ($topic_changes as $id => $changes)
2411
-		$smcFunc['db_query']('', '
2529
+	foreach ($topic_changes as $id => $changes) {
2530
+			$smcFunc['db_query']('', '
2412 2531
 			UPDATE {db_prefix}topics
2413 2532
 			SET approved = {int:approved}, unapproved_posts = unapproved_posts + {int:unapproved_posts},
2414 2533
 				num_replies = num_replies + {int:num_replies}, id_last_msg = {int:id_last_msg}
@@ -2421,10 +2540,11 @@  discard block
 block discarded – undo
2421 2540
 				'id_topic' => $id,
2422 2541
 			)
2423 2542
 		);
2543
+	}
2424 2544
 
2425 2545
 	// ... finally the boards...
2426
-	foreach ($board_changes as $id => $changes)
2427
-		$smcFunc['db_query']('', '
2546
+	foreach ($board_changes as $id => $changes) {
2547
+			$smcFunc['db_query']('', '
2428 2548
 			UPDATE {db_prefix}boards
2429 2549
 			SET num_posts = num_posts + {int:num_posts}, unapproved_posts = unapproved_posts + {int:unapproved_posts},
2430 2550
 				num_topics = num_topics + {int:num_topics}, unapproved_topics = unapproved_topics + {int:unapproved_topics}
@@ -2437,13 +2557,14 @@  discard block
 block discarded – undo
2437 2557
 				'id_board' => $id,
2438 2558
 			)
2439 2559
 		);
2560
+	}
2440 2561
 
2441 2562
 	// Finally, least importantly, notifications!
2442 2563
 	if ($approve)
2443 2564
 	{
2444 2565
 		$task_rows = array();
2445
-		foreach (array_merge($notification_topics, $notification_posts) as $topic)
2446
-			$task_rows[] = array(
2566
+		foreach (array_merge($notification_topics, $notification_posts) as $topic) {
2567
+					$task_rows[] = array(
2447 2568
 				'$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', json_encode(array(
2448 2569
 					'msgOptions' => array(
2449 2570
 						'id' => $topic['msg'],
@@ -2461,14 +2582,16 @@  discard block
 block discarded – undo
2461 2582
 					'type' => $topic['new_topic'] ? 'topic' : 'reply',
2462 2583
 				)), 0
2463 2584
 			);
2585
+		}
2464 2586
 
2465
-		if ($notify)
2466
-			$smcFunc['db_insert']('',
2587
+		if ($notify) {
2588
+					$smcFunc['db_insert']('',
2467 2589
 				'{db_prefix}background_tasks',
2468 2590
 				array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
2469 2591
 				$task_rows,
2470 2592
 				array('id_task')
2471 2593
 			);
2594
+		}
2472 2595
 
2473 2596
 		$smcFunc['db_query']('', '
2474 2597
 			DELETE FROM {db_prefix}approval_queue
@@ -2484,8 +2607,9 @@  discard block
 block discarded – undo
2484 2607
 	else
2485 2608
 	{
2486 2609
 		$msgInserts = array();
2487
-		foreach ($msgs as $msg)
2488
-			$msgInserts[] = array($msg);
2610
+		foreach ($msgs as $msg) {
2611
+					$msgInserts[] = array($msg);
2612
+		}
2489 2613
 
2490 2614
 		$smcFunc['db_insert']('ignore',
2491 2615
 			'{db_prefix}approval_queue',
@@ -2499,9 +2623,10 @@  discard block
 block discarded – undo
2499 2623
 	updateLastMessages(array_keys($board_changes));
2500 2624
 
2501 2625
 	// Post count for the members?
2502
-	if (!empty($member_post_changes))
2503
-		foreach ($member_post_changes as $id_member => $count_change)
2626
+	if (!empty($member_post_changes)) {
2627
+			foreach ($member_post_changes as $id_member => $count_change)
2504 2628
 			updateMemberData($id_member, array('posts' => 'posts ' . ($approve ? '+' : '-') . ' ' . $count_change));
2629
+	}
2505 2630
 
2506 2631
 	return true;
2507 2632
 }
@@ -2518,11 +2643,13 @@  discard block
 block discarded – undo
2518 2643
 {
2519 2644
 	global $smcFunc;
2520 2645
 
2521
-	if (!is_array($topics))
2522
-		$topics = array($topics);
2646
+	if (!is_array($topics)) {
2647
+			$topics = array($topics);
2648
+	}
2523 2649
 
2524
-	if (empty($topics))
2525
-		return false;
2650
+	if (empty($topics)) {
2651
+			return false;
2652
+	}
2526 2653
 
2527 2654
 	$approve_type = $approve ? 0 : 1;
2528 2655
 
@@ -2538,8 +2665,9 @@  discard block
 block discarded – undo
2538 2665
 		)
2539 2666
 	);
2540 2667
 	$msgs = array();
2541
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2542
-		$msgs[] = $row['id_msg'];
2668
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2669
+			$msgs[] = $row['id_msg'];
2670
+	}
2543 2671
 	$smcFunc['db_free_result']($request);
2544 2672
 
2545 2673
 	return approvePosts($msgs, $approve);
@@ -2562,11 +2690,13 @@  discard block
 block discarded – undo
2562 2690
 	global $board_info, $board, $smcFunc;
2563 2691
 
2564 2692
 	// Please - let's be sane.
2565
-	if (empty($setboards))
2566
-		return false;
2693
+	if (empty($setboards)) {
2694
+			return false;
2695
+	}
2567 2696
 
2568
-	if (!is_array($setboards))
2569
-		$setboards = array($setboards);
2697
+	if (!is_array($setboards)) {
2698
+			$setboards = array($setboards);
2699
+	}
2570 2700
 
2571 2701
 	// If we don't know the id_msg we need to find it.
2572 2702
 	if (!$id_msg)
@@ -2584,15 +2714,16 @@  discard block
 block discarded – undo
2584 2714
 			)
2585 2715
 		);
2586 2716
 		$lastMsg = array();
2587
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2588
-			$lastMsg[$row['id_board']] = $row['id_msg'];
2717
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2718
+					$lastMsg[$row['id_board']] = $row['id_msg'];
2719
+		}
2589 2720
 		$smcFunc['db_free_result']($request);
2590
-	}
2591
-	else
2721
+	} else
2592 2722
 	{
2593 2723
 		// Just to note - there should only be one board passed if we are doing this.
2594
-		foreach ($setboards as $id_board)
2595
-			$lastMsg[$id_board] = $id_msg;
2724
+		foreach ($setboards as $id_board) {
2725
+					$lastMsg[$id_board] = $id_msg;
2726
+		}
2596 2727
 	}
2597 2728
 
2598 2729
 	$parent_boards = array();
@@ -2607,10 +2738,11 @@  discard block
 block discarded – undo
2607 2738
 			$lastModified[$id_board] = 0;
2608 2739
 		}
2609 2740
 
2610
-		if (!empty($board) && $id_board == $board)
2611
-			$parents = $board_info['parent_boards'];
2612
-		else
2613
-			$parents = getBoardParents($id_board);
2741
+		if (!empty($board) && $id_board == $board) {
2742
+					$parents = $board_info['parent_boards'];
2743
+		} else {
2744
+					$parents = getBoardParents($id_board);
2745
+		}
2614 2746
 
2615 2747
 		// Ignore any parents on the top child level.
2616 2748
 		// @todo Why?
@@ -2619,10 +2751,11 @@  discard block
 block discarded – undo
2619 2751
 			if ($parent['level'] != 0)
2620 2752
 			{
2621 2753
 				// If we're already doing this one as a board, is this a higher last modified?
2622
-				if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id])
2623
-					$lastModified[$id] = $lastModified[$id_board];
2624
-				elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board]))
2625
-					$parent_boards[$id] = $lastModified[$id_board];
2754
+				if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) {
2755
+									$lastModified[$id] = $lastModified[$id_board];
2756
+				} elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) {
2757
+									$parent_boards[$id] = $lastModified[$id_board];
2758
+				}
2626 2759
 			}
2627 2760
 		}
2628 2761
 	}
@@ -2635,23 +2768,24 @@  discard block
 block discarded – undo
2635 2768
 	// Finally, to save on queries make the changes...
2636 2769
 	foreach ($parent_boards as $id => $msg)
2637 2770
 	{
2638
-		if (!isset($parent_updates[$msg]))
2639
-			$parent_updates[$msg] = array($id);
2640
-		else
2641
-			$parent_updates[$msg][] = $id;
2771
+		if (!isset($parent_updates[$msg])) {
2772
+					$parent_updates[$msg] = array($id);
2773
+		} else {
2774
+					$parent_updates[$msg][] = $id;
2775
+		}
2642 2776
 	}
2643 2777
 
2644 2778
 	foreach ($lastMsg as $id => $msg)
2645 2779
 	{
2646
-		if (!isset($board_updates[$msg . '-' . $lastModified[$id]]))
2647
-			$board_updates[$msg . '-' . $lastModified[$id]] = array(
2780
+		if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) {
2781
+					$board_updates[$msg . '-' . $lastModified[$id]] = array(
2648 2782
 				'id' => $msg,
2649 2783
 				'updated' => $lastModified[$id],
2650 2784
 				'boards' => array($id)
2651 2785
 			);
2652
-
2653
-		else
2654
-			$board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id;
2786
+		} else {
2787
+					$board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id;
2788
+		}
2655 2789
 	}
2656 2790
 
2657 2791
 	// Now commit the changes!
@@ -2743,11 +2877,13 @@  discard block
 block discarded – undo
2743 2877
 	global $txt, $mbname, $scripturl, $settings;
2744 2878
 
2745 2879
 	// First things first, load up the email templates language file, if we need to.
2746
-	if ($loadLang)
2747
-		loadLanguage('EmailTemplates', $lang);
2880
+	if ($loadLang) {
2881
+			loadLanguage('EmailTemplates', $lang);
2882
+	}
2748 2883
 
2749
-	if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body']))
2750
-		fatal_lang_error('email_no_template', 'template', array($template));
2884
+	if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) {
2885
+			fatal_lang_error('email_no_template', 'template', array($template));
2886
+	}
2751 2887
 
2752 2888
 	$ret = array(
2753 2889
 		'subject' => $txt[$template . '_subject'],
@@ -2797,17 +2933,18 @@  discard block
 block discarded – undo
2797 2933
 function user_info_callback($matches)
2798 2934
 {
2799 2935
 	global $user_info;
2800
-	if (empty($matches[1]))
2801
-		return '';
2936
+	if (empty($matches[1])) {
2937
+			return '';
2938
+	}
2802 2939
 
2803 2940
 	$use_ref = true;
2804 2941
 	$ref = &$user_info;
2805 2942
 
2806 2943
 	foreach (explode('.', $matches[1]) as $index)
2807 2944
 	{
2808
-		if ($use_ref && isset($ref[$index]))
2809
-			$ref = &$ref[$index];
2810
-		else
2945
+		if ($use_ref && isset($ref[$index])) {
2946
+					$ref = &$ref[$index];
2947
+		} else
2811 2948
 		{
2812 2949
 			$use_ref = false;
2813 2950
 			break;
@@ -2844,8 +2981,7 @@  discard block
 block discarded – undo
2844 2981
 		if (!empty($lang_locale) && enchant_broker_dict_exists($context['enchant_broker'], $lang_locale))
2845 2982
 		{
2846 2983
 			$enchant_link = enchant_broker_request_dict($context['enchant_broker'], $lang_locale);
2847
-		}
2848
-		elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary']))
2984
+		} elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary']))
2849 2985
 		{
2850 2986
 			$enchant_link = enchant_broker_request_dict($context['enchant_broker'], $txt['lang_dictionary']);
2851 2987
 		}
@@ -2855,8 +2991,7 @@  discard block
 block discarded – undo
2855 2991
 		{
2856 2992
 			$context['provider'] = 'enchant';
2857 2993
 			return $enchant_link;
2858
-		}
2859
-		else
2994
+		} else
2860 2995
 		{
2861 2996
 			// Free up any resources used...
2862 2997
 			@enchant_broker_free($context['enchant_broker']);
@@ -2877,8 +3012,9 @@  discard block
 block discarded – undo
2877 3012
 		$pspell_link = pspell_new($txt['lang_dictionary'], $txt['lang_spelling'], '', strtr($context['character_set'], array('iso-' => 'iso', 'ISO-' => 'iso')), PSPELL_FAST | PSPELL_RUN_TOGETHER);
2878 3013
 
2879 3014
 		// Most people don't have anything but English installed... So we use English as a last resort.
2880
-		if (!$pspell_link)
2881
-			$pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER);
3015
+		if (!$pspell_link) {
3016
+					$pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER);
3017
+		}
2882 3018
 
2883 3019
 		error_reporting($old);
2884 3020
 		ob_end_clean();
@@ -2918,8 +3054,7 @@  discard block
 block discarded – undo
2918 3054
 			$word = iconv($txt['lang_character_set'], 'UTF-8', $word);
2919 3055
 		}
2920 3056
 		return enchant_dict_check($dict, $word);
2921
-	}
2922
-	elseif ($context['provider'] == 'pspell')
3057
+	} elseif ($context['provider'] == 'pspell')
2923 3058
 	{
2924 3059
 		return pspell_check($dict, $word);
2925 3060
 	}
@@ -2955,13 +3090,11 @@  discard block
 block discarded – undo
2955 3090
 			}
2956 3091
 
2957 3092
 			return $suggestions;
2958
-		}
2959
-		else
3093
+		} else
2960 3094
 		{
2961 3095
 			return enchant_dict_suggest($dict, $word);
2962 3096
 		}
2963
-	}
2964
-	elseif ($context['provider'] == 'pspell')
3097
+	} elseif ($context['provider'] == 'pspell')
2965 3098
 	{
2966 3099
 		return pspell_suggest($dict, $word);
2967 3100
 	}
Please login to merge, or discard this patch.