Completed
Push — release-2.1 ( bcefe7...327bb3 )
by Jeremy
07:48
created
Sources/Stats.php 1 patch
Braces   +112 added lines, -78 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Display some useful/interesting board statistics.
@@ -30,8 +31,9 @@  discard block
 block discarded – undo
30 31
 
31 32
 	isAllowedTo('view_stats');
32 33
 	// Page disabled - redirect them out
33
-	if (empty($modSettings['trackStats']))
34
-		fatal_lang_error('feature_disabled', true);
34
+	if (empty($modSettings['trackStats'])) {
35
+			fatal_lang_error('feature_disabled', true);
36
+	}
35 37
 
36 38
 	if (!empty($_REQUEST['expand']))
37 39
 	{
@@ -39,31 +41,34 @@  discard block
 block discarded – undo
39 41
 
40 42
 		$month = (int) substr($_REQUEST['expand'], 4);
41 43
 		$year = (int) substr($_REQUEST['expand'], 0, 4);
42
-		if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12)
43
-			$_SESSION['expanded_stats'][$year][] = $month;
44
-	}
45
-	elseif (!empty($_REQUEST['collapse']))
44
+		if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12) {
45
+					$_SESSION['expanded_stats'][$year][] = $month;
46
+		}
47
+	} elseif (!empty($_REQUEST['collapse']))
46 48
 	{
47 49
 		$context['robot_no_index'] = true;
48 50
 
49 51
 		$month = (int) substr($_REQUEST['collapse'], 4);
50 52
 		$year = (int) substr($_REQUEST['collapse'], 0, 4);
51
-		if (!empty($_SESSION['expanded_stats'][$year]))
52
-			$_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month));
53
+		if (!empty($_SESSION['expanded_stats'][$year])) {
54
+					$_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month));
55
+		}
53 56
 	}
54 57
 
55 58
 	// Handle the XMLHttpRequest.
56 59
 	if (isset($_REQUEST['xml']))
57 60
 	{
58 61
 		// Collapsing stats only needs adjustments of the session variables.
59
-		if (!empty($_REQUEST['collapse']))
60
-			obExit(false);
62
+		if (!empty($_REQUEST['collapse'])) {
63
+					obExit(false);
64
+		}
61 65
 
62 66
 		$context['sub_template'] = 'stats';
63 67
 		$context['yearly'] = array();
64 68
 
65
-		if (empty($month) || empty($year))
66
-			return;
69
+		if (empty($month) || empty($year)) {
70
+					return;
71
+		}
67 72
 
68 73
 		getDailyStats('YEAR(date) = {int:year} AND MONTH(date) = {int:month}', array('year' => $year, 'month' => $month));
69 74
 		$context['yearly'][$year]['months'][$month]['date'] = array(
@@ -221,8 +226,9 @@  discard block
 block discarded – undo
221 226
 			'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
222 227
 		);
223 228
 
224
-		if ($max_num_posts < $row_members['posts'])
225
-			$max_num_posts = $row_members['posts'];
229
+		if ($max_num_posts < $row_members['posts']) {
230
+					$max_num_posts = $row_members['posts'];
231
+		}
226 232
 	}
227 233
 	$smcFunc['db_free_result']($members_result);
228 234
 
@@ -258,8 +264,9 @@  discard block
 block discarded – undo
258 264
 			'link' => '<a href="' . $scripturl . '?board=' . $row_board['id_board'] . '.0">' . $row_board['name'] . '</a>'
259 265
 		);
260 266
 
261
-		if ($max_num_posts < $row_board['num_posts'])
262
-			$max_num_posts = $row_board['num_posts'];
267
+		if ($max_num_posts < $row_board['num_posts']) {
268
+					$max_num_posts = $row_board['num_posts'];
269
+		}
263 270
 	}
264 271
 	$smcFunc['db_free_result']($boards_result);
265 272
 
@@ -285,12 +292,13 @@  discard block
 block discarded – undo
285 292
 			)
286 293
 		);
287 294
 		$topic_ids = array();
288
-		while ($row = $smcFunc['db_fetch_assoc']($request))
289
-			$topic_ids[] = $row['id_topic'];
295
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
296
+					$topic_ids[] = $row['id_topic'];
297
+		}
290 298
 		$smcFunc['db_free_result']($request);
299
+	} else {
300
+			$topic_ids = array();
291 301
 	}
292
-	else
293
-		$topic_ids = array();
294 302
 
295 303
 	// Topic replies top 10.
296 304
 	$topic_reply_result = $smcFunc['db_query']('', '
@@ -330,8 +338,9 @@  discard block
 block discarded – undo
330 338
 			'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_reply['id_topic'] . '.0">' . $row_topic_reply['subject'] . '</a>'
331 339
 		);
332 340
 
333
-		if ($max_num_replies < $row_topic_reply['num_replies'])
334
-			$max_num_replies = $row_topic_reply['num_replies'];
341
+		if ($max_num_replies < $row_topic_reply['num_replies']) {
342
+					$max_num_replies = $row_topic_reply['num_replies'];
343
+		}
335 344
 	}
336 345
 	$smcFunc['db_free_result']($topic_reply_result);
337 346
 
@@ -355,12 +364,13 @@  discard block
 block discarded – undo
355 364
 			)
356 365
 		);
357 366
 		$topic_ids = array();
358
-		while ($row = $smcFunc['db_fetch_assoc']($request))
359
-			$topic_ids[] = $row['id_topic'];
367
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
368
+					$topic_ids[] = $row['id_topic'];
369
+		}
360 370
 		$smcFunc['db_free_result']($request);
371
+	} else {
372
+			$topic_ids = array();
361 373
 	}
362
-	else
363
-		$topic_ids = array();
364 374
 
365 375
 	// Topic views top 10.
366 376
 	$topic_view_result = $smcFunc['db_query']('', '
@@ -400,8 +410,9 @@  discard block
 block discarded – undo
400 410
 			'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_views['id_topic'] . '.0">' . $row_topic_views['subject'] . '</a>'
401 411
 		);
402 412
 
403
-		if ($max_num < $row_topic_views['num_views'])
404
-			$max_num = $row_topic_views['num_views'];
413
+		if ($max_num < $row_topic_views['num_views']) {
414
+					$max_num = $row_topic_views['num_views'];
415
+		}
405 416
 	}
406 417
 	$smcFunc['db_free_result']($topic_view_result);
407 418
 
@@ -426,15 +437,17 @@  discard block
 block discarded – undo
426 437
 			)
427 438
 		);
428 439
 		$members = array();
429
-		while ($row = $smcFunc['db_fetch_assoc']($request))
430
-			$members[$row['id_member_started']] = $row['hits'];
440
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
441
+					$members[$row['id_member_started']] = $row['hits'];
442
+		}
431 443
 		$smcFunc['db_free_result']($request);
432 444
 
433 445
 		cache_put_data('stats_top_starters', $members, 360);
434 446
 	}
435 447
 
436
-	if (empty($members))
437
-		$members = array(0 => 0);
448
+	if (empty($members)) {
449
+			$members = array(0 => 0);
450
+	}
438 451
 
439 452
 	// Topic poster top 10.
440 453
 	$members_result = $smcFunc['db_query']('', '
@@ -459,8 +472,9 @@  discard block
 block discarded – undo
459 472
 			'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
460 473
 		);
461 474
 
462
-		if ($max_num < $members[$row_members['id_member']])
463
-			$max_num = $members[$row_members['id_member']];
475
+		if ($max_num < $members[$row_members['id_member']]) {
476
+					$max_num = $members[$row_members['id_member']];
477
+		}
464 478
 	}
465 479
 	ksort($context['stats_blocks']['starters']);
466 480
 	$smcFunc['db_free_result']($members_result);
@@ -489,8 +503,9 @@  discard block
 block discarded – undo
489 503
 	while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
490 504
 	{
491 505
 		$temp2[] = (int) $row_members['id_member'];
492
-		if (count($context['stats_blocks']['time_online']) >= 10)
493
-			continue;
506
+		if (count($context['stats_blocks']['time_online']) >= 10) {
507
+					continue;
508
+		}
494 509
 
495 510
 		// Figure out the days, hours and minutes.
496 511
 		$timeDays = floor($row_members['total_time_logged_in'] / 86400);
@@ -498,10 +513,12 @@  discard block
 block discarded – undo
498 513
 
499 514
 		// Figure out which things to show... (days, hours, minutes, etc.)
500 515
 		$timelogged = '';
501
-		if ($timeDays > 0)
502
-			$timelogged .= $timeDays . $txt['totalTimeLogged5'];
503
-		if ($timeHours > 0)
504
-			$timelogged .= $timeHours . $txt['totalTimeLogged6'];
516
+		if ($timeDays > 0) {
517
+					$timelogged .= $timeDays . $txt['totalTimeLogged5'];
518
+		}
519
+		if ($timeHours > 0) {
520
+					$timelogged .= $timeHours . $txt['totalTimeLogged6'];
521
+		}
505 522
 		$timelogged .= floor(($row_members['total_time_logged_in'] % 3600) / 60) . $txt['totalTimeLogged7'];
506 523
 
507 524
 		$context['stats_blocks']['time_online'][] = array(
@@ -513,17 +530,20 @@  discard block
 block discarded – undo
513 530
 			'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
514 531
 		);
515 532
 
516
-		if ($max_time_online < $row_members['total_time_logged_in'])
517
-			$max_time_online = $row_members['total_time_logged_in'];
533
+		if ($max_time_online < $row_members['total_time_logged_in']) {
534
+					$max_time_online = $row_members['total_time_logged_in'];
535
+		}
518 536
 	}
519 537
 	$smcFunc['db_free_result']($members_result);
520 538
 
521
-	foreach ($context['stats_blocks']['time_online'] as $i => $member)
522
-		$context['stats_blocks']['time_online'][$i]['percent'] = round(($member['seconds_online'] * 100) / $max_time_online);
539
+	foreach ($context['stats_blocks']['time_online'] as $i => $member) {
540
+			$context['stats_blocks']['time_online'][$i]['percent'] = round(($member['seconds_online'] * 100) / $max_time_online);
541
+	}
523 542
 
524 543
 	// Cache the ones we found for a bit, just so we don't have to look again.
525
-	if ($temp !== $temp2)
526
-		cache_put_data('stats_total_time_members', $temp2, 480);
544
+	if ($temp !== $temp2) {
545
+			cache_put_data('stats_total_time_members', $temp2, 480);
546
+	}
527 547
 
528 548
 	// Likes.
529 549
 	if (!empty($modSettings['enable_likes']))
@@ -559,13 +579,15 @@  discard block
 block discarded – undo
559 579
 				'link' => '<a href="' . $scripturl . '?msg=' . $row_liked_message['id_msg'] .'">' . $row_liked_message['subject'] . '</a>'
560 580
 			);
561 581
 
562
-			if ($max_liked_message < $row_liked_message['likes'])
563
-				$max_liked_message = $row_liked_message['likes'];
582
+			if ($max_liked_message < $row_liked_message['likes']) {
583
+							$max_liked_message = $row_liked_message['likes'];
584
+			}
564 585
 		}
565 586
 		$smcFunc['db_free_result']($liked_messages);
566 587
 
567
-		foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages)
568
-			$context['stats_blocks']['liked_messages'][$i]['percent'] = round(($liked_messages['num'] * 100) / $max_liked_message);
588
+		foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages) {
589
+					$context['stats_blocks']['liked_messages'][$i]['percent'] = round(($liked_messages['num'] * 100) / $max_liked_message);
590
+		}
569 591
 
570 592
 		// Liked users top 10.
571 593
 		$context['stats_blocks']['liked_users'] = array();
@@ -596,14 +618,16 @@  discard block
 block discarded – undo
596 618
 				'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_liked_users['liked_user'] . '">' . $row_liked_users['real_name'] . '</a>',
597 619
 			);
598 620
 
599
-			if ($max_liked_users < $row_liked_users['count'])
600
-				$max_liked_users = $row_liked_users['count'];
621
+			if ($max_liked_users < $row_liked_users['count']) {
622
+							$max_liked_users = $row_liked_users['count'];
623
+			}
601 624
 		}
602 625
 
603 626
 		$smcFunc['db_free_result']($liked_users);
604 627
 
605
-		foreach ($context['stats_blocks']['liked_users'] as $i => $liked_users)
606
-			$context['stats_blocks']['liked_users'][$i]['percent'] = round(($liked_users['num'] * 100) / $max_liked_users);
628
+		foreach ($context['stats_blocks']['liked_users'] as $i => $liked_users) {
629
+					$context['stats_blocks']['liked_users'][$i]['percent'] = round(($liked_users['num'] * 100) / $max_liked_users);
630
+		}
607 631
 	}
608 632
 
609 633
 	// Activity by month.
@@ -621,8 +645,8 @@  discard block
 block discarded – undo
621 645
 		$ID_MONTH = $row_months['stats_year'] . sprintf('%02d', $row_months['stats_month']);
622 646
 		$expanded = !empty($_SESSION['expanded_stats'][$row_months['stats_year']]) && in_array($row_months['stats_month'], $_SESSION['expanded_stats'][$row_months['stats_year']]);
623 647
 
624
-		if (!isset($context['yearly'][$row_months['stats_year']]))
625
-			$context['yearly'][$row_months['stats_year']] = array(
648
+		if (!isset($context['yearly'][$row_months['stats_year']])) {
649
+					$context['yearly'][$row_months['stats_year']] = array(
626 650
 				'year' => $row_months['stats_year'],
627 651
 				'new_topics' => 0,
628 652
 				'new_posts' => 0,
@@ -634,6 +658,7 @@  discard block
 block discarded – undo
634 658
 				'expanded' => false,
635 659
 				'current_year' => $row_months['stats_year'] == date('Y'),
636 660
 			);
661
+		}
637 662
 
638 663
 		$context['yearly'][$row_months['stats_year']]['months'][(int) $row_months['stats_month']] = array(
639 664
 			'id' => $ID_MONTH,
@@ -679,29 +704,33 @@  discard block
 block discarded – undo
679 704
 		$context['yearly'][$year]['hits'] = comma_format($data['hits']);
680 705
 
681 706
 		// Keep a list of collapsed years.
682
-		if (!$data['expanded'] && !$data['current_year'])
683
-			$context['collapsed_years'][] = $year;
707
+		if (!$data['expanded'] && !$data['current_year']) {
708
+					$context['collapsed_years'][] = $year;
709
+		}
684 710
 	}
685 711
 
686 712
 	// Custom stats (just add a template_layer to add it to the template!)
687 713
 	call_integration_hook('integrate_forum_stats');
688 714
 
689
-	if (empty($_SESSION['expanded_stats']))
690
-		return;
715
+	if (empty($_SESSION['expanded_stats'])) {
716
+			return;
717
+	}
691 718
 
692 719
 	$condition_text = array();
693 720
 	$condition_params = array();
694
-	foreach ($_SESSION['expanded_stats'] as $year => $months)
695
-		if (!empty($months))
721
+	foreach ($_SESSION['expanded_stats'] as $year => $months) {
722
+			if (!empty($months))
696 723
 		{
697 724
 			$condition_text[] = 'YEAR(date) = {int:year_' . $year . '} AND MONTH(date) IN ({array_int:months_' . $year . '})';
725
+	}
698 726
 			$condition_params['year_' . $year] = $year;
699 727
 			$condition_params['months_' . $year] = $months;
700 728
 		}
701 729
 
702 730
 	// No daily stats to even look at?
703
-	if (empty($condition_text))
704
-		return;
731
+	if (empty($condition_text)) {
732
+			return;
733
+	}
705 734
 
706 735
 	getDailyStats(implode(' OR ', $condition_text), $condition_params);
707 736
 }
@@ -724,8 +753,8 @@  discard block
 block discarded – undo
724 753
 		ORDER BY stats_day ASC',
725 754
 		$condition_parameters
726 755
 	);
727
-	while ($row_days = $smcFunc['db_fetch_assoc']($days_result))
728
-		$context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array(
756
+	while ($row_days = $smcFunc['db_fetch_assoc']($days_result)) {
757
+			$context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array(
729 758
 			'day' => sprintf('%02d', $row_days['stats_day']),
730 759
 			'month' => sprintf('%02d', $row_days['stats_month']),
731 760
 			'year' => $row_days['stats_year'],
@@ -735,6 +764,7 @@  discard block
 block discarded – undo
735 764
 			'most_members_online' => comma_format($row_days['most_on']),
736 765
 			'hits' => comma_format($row_days['hits'])
737 766
 		);
767
+	}
738 768
 	$smcFunc['db_free_result']($days_result);
739 769
 }
740 770
 
@@ -752,16 +782,19 @@  discard block
 block discarded – undo
752 782
 	global $modSettings, $user_info, $forum_version, $sourcedir;
753 783
 
754 784
 	// First, is it disabled?
755
-	if (empty($modSettings['enable_sm_stats']) || empty($modSettings['sm_stats_key']))
756
-		die();
785
+	if (empty($modSettings['enable_sm_stats']) || empty($modSettings['sm_stats_key'])) {
786
+			die();
787
+	}
757 788
 
758 789
 	// Are we saying who we are, and are we right? (OR an admin)
759
-	if (!$user_info['is_admin'] && (!isset($_GET['sid']) || $_GET['sid'] != $modSettings['sm_stats_key']))
760
-		die();
790
+	if (!$user_info['is_admin'] && (!isset($_GET['sid']) || $_GET['sid'] != $modSettings['sm_stats_key'])) {
791
+			die();
792
+	}
761 793
 
762 794
 	// Verify the referer...
763
-	if (!$user_info['is_admin'] && (!isset($_SERVER['HTTP_REFERER']) || md5($_SERVER['HTTP_REFERER']) != '746cb59a1a0d5cf4bd240e5a67c73085'))
764
-		die();
795
+	if (!$user_info['is_admin'] && (!isset($_SERVER['HTTP_REFERER']) || md5($_SERVER['HTTP_REFERER']) != '746cb59a1a0d5cf4bd240e5a67c73085')) {
796
+			die();
797
+	}
765 798
 
766 799
 	// Get some server versions.
767 800
 	require_once($sourcedir . '/Subs-Admin.php');
@@ -787,16 +820,17 @@  discard block
 block discarded – undo
787 820
 	);
788 821
 
789 822
 	// Encode all the data, for security.
790
-	foreach ($stats_to_send as $k => $v)
791
-		$stats_to_send[$k] = urlencode($k) . '=' . urlencode($v);
823
+	foreach ($stats_to_send as $k => $v) {
824
+			$stats_to_send[$k] = urlencode($k) . '=' . urlencode($v);
825
+	}
792 826
 
793 827
 	// Turn this into the query string!
794 828
 	$stats_to_send = implode('&', $stats_to_send);
795 829
 
796 830
 	// If we're an admin, just plonk them out.
797
-	if ($user_info['is_admin'])
798
-		echo $stats_to_send;
799
-	else
831
+	if ($user_info['is_admin']) {
832
+			echo $stats_to_send;
833
+	} else
800 834
 	{
801 835
 		// Connect to the collection script.
802 836
 		$fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr);
Please login to merge, or discard this patch.
Sources/ManageServer.php 1 patch
Braces   +315 added lines, -243 removed lines patch added patch discarded remove patch
@@ -59,8 +59,9 @@  discard block
 block discarded – undo
59 59
  * @version 2.1 Beta 4
60 60
  */
61 61
 
62
-if (!defined('SMF'))
62
+if (!defined('SMF')) {
63 63
 	die('No direct access...');
64
+}
64 65
 
65 66
 /**
66 67
  * This is the main dispatcher. Sets up all the available sub-actions, all the tabs and selects
@@ -111,10 +112,11 @@  discard block
 block discarded – undo
111 112
 	$settings_not_writable = !is_writable($boarddir . '/Settings.php');
112 113
 	$settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
113 114
 
114
-	if ($settings_not_writable)
115
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
116
-	elseif ($settings_backup_fail)
117
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
115
+	if ($settings_not_writable) {
116
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
117
+	} elseif ($settings_backup_fail) {
118
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
119
+	}
118 120
 
119 121
 	$context['settings_not_writable'] = $settings_not_writable;
120 122
 
@@ -142,10 +144,11 @@  discard block
 block discarded – undo
142 144
 
143 145
 	// If no cert, force_ssl must remain 0
144 146
 	require_once($sourcedir . '/Subs.php');
145
-	if (!ssl_cert_found($boardurl) && empty($modSettings['force_ssl']))
146
-		$disable_force_ssl = true;
147
-	else
148
-		$disable_force_ssl = false;
147
+	if (!ssl_cert_found($boardurl) && empty($modSettings['force_ssl'])) {
148
+			$disable_force_ssl = true;
149
+	} else {
150
+			$disable_force_ssl = false;
151
+	}
149 152
 
150 153
 	/* If you're writing a mod, it's a bad idea to add things here....
151 154
 	For each option:
@@ -174,8 +177,9 @@  discard block
 block discarded – undo
174 177
 
175 178
 	call_integration_hook('integrate_general_settings', array(&$config_vars));
176 179
 
177
-	if ($return_config)
178
-		return $config_vars;
180
+	if ($return_config) {
181
+			return $config_vars;
182
+	}
179 183
 
180 184
 	// Setup the template stuff.
181 185
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=general;save';
@@ -192,16 +196,18 @@  discard block
 block discarded – undo
192 196
 			$registerSMStats = registerSMStats();
193 197
 
194 198
 			// Failed to register, disable it again.
195
-			if (empty($registerSMStats))
196
-				$_POST['enable_sm_stats'] = 0;
199
+			if (empty($registerSMStats)) {
200
+							$_POST['enable_sm_stats'] = 0;
201
+			}
197 202
 		}
198 203
 
199 204
 		// Ensure all URLs are aligned with the new force_ssl setting
200 205
 		// Treat unset like 0
201
-		if (isset($_POST['force_ssl']))
202
-			AlignURLsWithSSLSetting($_POST['force_ssl']);
203
-		else
204
-			AlignURLsWithSSLSetting(0);
206
+		if (isset($_POST['force_ssl'])) {
207
+					AlignURLsWithSSLSetting($_POST['force_ssl']);
208
+		} else {
209
+					AlignURLsWithSSLSetting(0);
210
+		}
205 211
 
206 212
 		saveSettings($config_vars);
207 213
 		$_SESSION['adm-save'] = true;
@@ -254,10 +260,11 @@  discard block
 block discarded – undo
254 260
 	require_once($sourcedir . '/Subs-Admin.php');
255 261
 
256 262
 	// Check $boardurl
257
-	if (!empty($new_force_ssl))
258
-		$newval = strtr($boardurl, array('http://' => 'https://'));
259
-	else
260
-		$newval = strtr($boardurl, array('https://' => 'http://'));
263
+	if (!empty($new_force_ssl)) {
264
+			$newval = strtr($boardurl, array('http://' => 'https://'));
265
+	} else {
266
+			$newval = strtr($boardurl, array('https://' => 'http://'));
267
+	}
261 268
 	updateSettingsFile(array('boardurl' => '\'' . addslashes($newval) . '\''));
262 269
 
263 270
 	$new_settings = array();
@@ -265,20 +272,22 @@  discard block
 block discarded – undo
265 272
 	// Check $smileys_url, but only if it points to a subfolder of $boardurl
266 273
 	if (BoardurlMatch($modSettings['smileys_url']))
267 274
 	{
268
-		if (!empty($new_force_ssl))
269
-			$newval = strtr($modSettings['smileys_url'], array('http://' => 'https://'));
270
-		else
271
-			$newval = strtr($modSettings['smileys_url'], array('https://' => 'http://'));
275
+		if (!empty($new_force_ssl)) {
276
+					$newval = strtr($modSettings['smileys_url'], array('http://' => 'https://'));
277
+		} else {
278
+					$newval = strtr($modSettings['smileys_url'], array('https://' => 'http://'));
279
+		}
272 280
 		$new_settings['smileys_url'] = $newval;
273 281
 	}
274 282
 
275 283
 	// Check $avatar_url, but only if it points to a subfolder of $boardurl
276 284
 	if (BoardurlMatch($modSettings['avatar_url']))
277 285
 	{
278
-		if (!empty($new_force_ssl))
279
-			$newval = strtr($modSettings['avatar_url'], array('http://' => 'https://'));
280
-		else
281
-			$newval = strtr($modSettings['avatar_url'], array('https://' => 'http://'));
286
+		if (!empty($new_force_ssl)) {
287
+					$newval = strtr($modSettings['avatar_url'], array('http://' => 'https://'));
288
+		} else {
289
+					$newval = strtr($modSettings['avatar_url'], array('https://' => 'http://'));
290
+		}
282 291
 		$new_settings['avatar_url'] = $newval;
283 292
 	}
284 293
 
@@ -286,16 +295,18 @@  discard block
 block discarded – undo
286 295
 	// This one had been optional in the past, make sure it is set first
287 296
 	if (isset($modSettings['custom_avatar_url']) && BoardurlMatch($modSettings['custom_avatar_url']))
288 297
 	{
289
-		if (!empty($new_force_ssl))
290
-			$newval = strtr($modSettings['custom_avatar_url'], array('http://' => 'https://'));
291
-		else
292
-			$newval = strtr($modSettings['custom_avatar_url'], array('https://' => 'http://'));
298
+		if (!empty($new_force_ssl)) {
299
+					$newval = strtr($modSettings['custom_avatar_url'], array('http://' => 'https://'));
300
+		} else {
301
+					$newval = strtr($modSettings['custom_avatar_url'], array('https://' => 'http://'));
302
+		}
293 303
 		$new_settings['custom_avatar_url'] = $newval;
294 304
 	}
295 305
 
296 306
 	// Save updates to the settings table
297
-	if (!empty($new_settings))
298
-		updateSettings($new_settings, true);
307
+	if (!empty($new_settings)) {
308
+			updateSettings($new_settings, true);
309
+	}
299 310
 
300 311
 	// Now we move onto the themes.
301 312
 	// First, get a list of theme URLs...
@@ -316,10 +327,11 @@  discard block
 block discarded – undo
316 327
 		// First check to see if it points to a subfolder of $boardurl
317 328
 		if (BoardurlMatch($row['value']))
318 329
 		{
319
-			if (!empty($new_force_ssl))
320
-				$newval = strtr($row['value'], array('http://' => 'https://'));
321
-			else
322
-				$newval = strtr($row['value'], array('https://' => 'http://'));
330
+			if (!empty($new_force_ssl)) {
331
+							$newval = strtr($row['value'], array('http://' => 'https://'));
332
+			} else {
333
+							$newval = strtr($row['value'], array('https://' => 'http://'));
334
+			}
323 335
 			$smcFunc['db_query']('', '
324 336
 				UPDATE {db_prefix}themes
325 337
 				   SET value = {string:theme_val}
@@ -359,11 +371,12 @@  discard block
 block discarded – undo
359 371
 
360 372
 	// If leftmost portion of path matches boardurl, return true
361 373
 	$result = strpos($urlpath, $boardurlpath);
362
-	if ($result === false || $result != 0)
363
-		return false;
364
-	else
365
-		return true;
366
-}
374
+	if ($result === false || $result != 0) {
375
+			return false;
376
+	} else {
377
+			return true;
378
+	}
379
+	}
367 380
 
368 381
 /**
369 382
  * Basic database and paths settings - database name, host, etc.
@@ -402,8 +415,9 @@  discard block
 block discarded – undo
402 415
 		$request = $smcFunc['db_query']('', 'SELECT cfgname FROM pg_ts_config', array());
403 416
 		$fts_language = array();
404 417
 
405
-		while ($row = $smcFunc['db_fetch_assoc']($request))
406
-			$fts_language[$row['cfgname']] = $row['cfgname'];
418
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
419
+					$fts_language[$row['cfgname']] = $row['cfgname'];
420
+		}
407 421
 
408 422
 		$config_vars = array_merge ($config_vars, array(
409 423
 				'',
@@ -415,20 +429,22 @@  discard block
 block discarded – undo
415 429
 
416 430
 	call_integration_hook('integrate_database_settings', array(&$config_vars));
417 431
 
418
-	if ($return_config)
419
-		return $config_vars;
432
+	if ($return_config) {
433
+			return $config_vars;
434
+	}
420 435
 
421 436
 	// Setup the template stuff.
422 437
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=database;save';
423 438
 	$context['settings_title'] = $txt['database_settings'];
424 439
 	$context['save_disabled'] = $context['settings_not_writable'];
425 440
 
426
-	if (!$smcFunc['db_allow_persistent']())
427
-		addInlineJavaScript('
441
+	if (!$smcFunc['db_allow_persistent']()) {
442
+			addInlineJavaScript('
428 443
 			$(function()
429 444
 			{
430 445
 				$("#db_persist").prop("disabled", true);
431 446
 			});', true);
447
+	}
432 448
 
433 449
 	// Saving settings?
434 450
 	if (isset($_REQUEST['save']))
@@ -498,13 +514,15 @@  discard block
 block discarded – undo
498 514
 		hideGlobalCookies();
499 515
 	});', true);
500 516
 
501
-	if (empty($user_settings['tfa_secret']))
502
-		addInlineJavaScript('');
517
+	if (empty($user_settings['tfa_secret'])) {
518
+			addInlineJavaScript('');
519
+	}
503 520
 
504 521
 	call_integration_hook('integrate_cookie_settings', array(&$config_vars));
505 522
 
506
-	if ($return_config)
507
-		return $config_vars;
523
+	if ($return_config) {
524
+			return $config_vars;
525
+	}
508 526
 
509 527
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cookie;save';
510 528
 	$context['settings_title'] = $txt['cookies_sessions_settings'];
@@ -515,14 +533,17 @@  discard block
 block discarded – undo
515 533
 		call_integration_hook('integrate_save_cookie_settings');
516 534
 
517 535
 		// Local and global do not play nicely together.
518
-		if (!empty($_POST['localCookies']) && empty($_POST['globalCookies']))
519
-			unset ($_POST['globalCookies']);
536
+		if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) {
537
+					unset ($_POST['globalCookies']);
538
+		}
520 539
 
521
-		if (empty($modSettings['localCookies']) != empty($_POST['localCookies']) || empty($modSettings['globalCookies']) != empty($_POST['globalCookies']))
522
-			$scope_changed = true;
540
+		if (empty($modSettings['localCookies']) != empty($_POST['localCookies']) || empty($modSettings['globalCookies']) != empty($_POST['globalCookies'])) {
541
+					$scope_changed = true;
542
+		}
523 543
 
524
-		if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false)
525
-			fatal_lang_error('invalid_cookie_domain', false);
544
+		if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) {
545
+					fatal_lang_error('invalid_cookie_domain', false);
546
+		}
526 547
 
527 548
 		saveSettings($config_vars);
528 549
 
@@ -605,8 +626,9 @@  discard block
 block discarded – undo
605 626
 
606 627
 	call_integration_hook('integrate_general_security_settings', array(&$config_vars));
607 628
 
608
-	if ($return_config)
609
-		return $config_vars;
629
+	if ($return_config) {
630
+			return $config_vars;
631
+	}
610 632
 
611 633
 	// Saving?
612 634
 	if (isset($_GET['save']))
@@ -645,8 +667,7 @@  discard block
 block discarded – undo
645 667
 		$txt['cache_settings_message'] = $txt['detected_no_caching'];
646 668
 		$cache_level = array($txt['cache_off']);
647 669
 		$detected['none'] = $txt['cache_off'];
648
-	}
649
-	else
670
+	} else
650 671
 	{
651 672
 		$txt['cache_settings_message'] = sprintf($txt['detected_accelerators'], implode(', ', $detected));
652 673
 		$cache_level = array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']);
@@ -683,8 +704,9 @@  discard block
 block discarded – undo
683 704
 			}
684 705
 		}
685 706
 	}
686
-	if ($return_config)
687
-		return $config_vars;
707
+	if ($return_config) {
708
+			return $config_vars;
709
+	}
688 710
 
689 711
 	// Saving again?
690 712
 	if (isset($_GET['save']))
@@ -712,8 +734,9 @@  discard block
 block discarded – undo
712 734
 	$context['save_disabled'] = $context['settings_not_writable'];
713 735
 
714 736
 	// Decide what message to show.
715
-	if (!$context['save_disabled'])
716
-		$context['settings_message'] = $txt['caching_information'];
737
+	if (!$context['save_disabled']) {
738
+			$context['settings_message'] = $txt['caching_information'];
739
+	}
717 740
 
718 741
 	// Prepare the template.
719 742
 	prepareServerSettingsContext($config_vars);
@@ -736,24 +759,25 @@  discard block
 block discarded – undo
736 759
 	if (stripos(PHP_OS, 'win') === 0)
737 760
 	{
738 761
 		$context['settings_message'] = $txt['loadavg_disabled_windows'];
739
-		if (isset($_GET['save']))
740
-			$_SESSION['adm-save'] = $txt['loadavg_disabled_windows'];
741
-	}
742
-	elseif (stripos(PHP_OS, 'darwin') === 0)
762
+		if (isset($_GET['save'])) {
763
+					$_SESSION['adm-save'] = $txt['loadavg_disabled_windows'];
764
+		}
765
+	} elseif (stripos(PHP_OS, 'darwin') === 0)
743 766
 	{
744 767
 		$context['settings_message'] = $txt['loadavg_disabled_osx'];
745
-		if (isset($_GET['save']))
746
-			$_SESSION['adm-save'] = $txt['loadavg_disabled_osx'];
747
-	}
748
-	else
768
+		if (isset($_GET['save'])) {
769
+					$_SESSION['adm-save'] = $txt['loadavg_disabled_osx'];
770
+		}
771
+	} else
749 772
 	{
750 773
 		$modSettings['load_average'] = @file_get_contents('/proc/loadavg');
751
-		if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0)
752
-			$modSettings['load_average'] = (float) $matches[1];
753
-		elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0)
754
-			$modSettings['load_average'] = (float) $matches[1];
755
-		else
756
-			unset($modSettings['load_average']);
774
+		if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) {
775
+					$modSettings['load_average'] = (float) $matches[1];
776
+		} elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) {
777
+					$modSettings['load_average'] = (float) $matches[1];
778
+		} else {
779
+					unset($modSettings['load_average']);
780
+		}
757 781
 
758 782
 		if (!empty($modSettings['load_average']) || (isset($modSettings['load_average']) && $modSettings['load_average'] === 0.0))
759 783
 		{
@@ -789,8 +813,9 @@  discard block
 block discarded – undo
789 813
 
790 814
 	call_integration_hook('integrate_loadavg_settings', array(&$config_vars));
791 815
 
792
-	if ($return_config)
793
-		return $config_vars;
816
+	if ($return_config) {
817
+			return $config_vars;
818
+	}
794 819
 
795 820
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=loads;save';
796 821
 	$context['settings_title'] = $txt['load_balancing_settings'];
@@ -801,24 +826,27 @@  discard block
 block discarded – undo
801 826
 		// Stupidity is not allowed.
802 827
 		foreach ($_POST as $key => $value)
803 828
 		{
804
-			if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values)))
805
-				continue;
806
-			else
807
-				$_POST[$key] = (float) $value;
808
-
809
-			if ($key == 'loadavg_auto_opt' && $value <= 1)
810
-				$_POST['loadavg_auto_opt'] = 1.0;
811
-			elseif ($key == 'loadavg_forum' && $value < 10)
812
-				$_POST['loadavg_forum'] = 10.0;
813
-			elseif ($value < 2)
814
-				$_POST[$key] = 2.0;
829
+			if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) {
830
+							continue;
831
+			} else {
832
+							$_POST[$key] = (float) $value;
833
+			}
834
+
835
+			if ($key == 'loadavg_auto_opt' && $value <= 1) {
836
+							$_POST['loadavg_auto_opt'] = 1.0;
837
+			} elseif ($key == 'loadavg_forum' && $value < 10) {
838
+							$_POST['loadavg_forum'] = 10.0;
839
+			} elseif ($value < 2) {
840
+							$_POST[$key] = 2.0;
841
+			}
815 842
 		}
816 843
 
817 844
 		call_integration_hook('integrate_save_loadavg_settings');
818 845
 
819 846
 		saveDBSettings($config_vars);
820
-		if (!isset($_SESSION['adm-save']))
821
-			$_SESSION['adm-save'] = true;
847
+		if (!isset($_SESSION['adm-save'])) {
848
+					$_SESSION['adm-save'] = true;
849
+		}
822 850
 		redirectexit('action=admin;area=serversettings;sa=loads;' . $context['session_var'] . '=' . $context['session_id']);
823 851
 	}
824 852
 
@@ -854,10 +882,11 @@  discard block
 block discarded – undo
854 882
 
855 883
 	if (isset($_SESSION['adm-save']))
856 884
 	{
857
-		if ($_SESSION['adm-save'] === true)
858
-			$context['saved_successful'] = true;
859
-		else
860
-			$context['saved_failed'] = $_SESSION['adm-save'];
885
+		if ($_SESSION['adm-save'] === true) {
886
+					$context['saved_successful'] = true;
887
+		} else {
888
+					$context['saved_failed'] = $_SESSION['adm-save'];
889
+		}
861 890
 
862 891
 		unset($_SESSION['adm-save']);
863 892
 	}
@@ -865,9 +894,9 @@  discard block
 block discarded – undo
865 894
 	$context['config_vars'] = array();
866 895
 	foreach ($config_vars as $identifier => $config_var)
867 896
 	{
868
-		if (!is_array($config_var) || !isset($config_var[1]))
869
-			$context['config_vars'][] = $config_var;
870
-		else
897
+		if (!is_array($config_var) || !isset($config_var[1])) {
898
+					$context['config_vars'][] = $config_var;
899
+		} else
871 900
 		{
872 901
 			$varname = $config_var[0];
873 902
 			global $$varname;
@@ -902,16 +931,19 @@  discard block
 block discarded – undo
902 931
 			if ($config_var[3] == 'int' || $config_var[3] == 'float')
903 932
 			{
904 933
 				// Default to a min of 0 if one isn't set
905
-				if (isset($config_var['min']))
906
-					$context['config_vars'][$config_var[0]]['min'] = $config_var['min'];
907
-				else
908
-					$context['config_vars'][$config_var[0]]['min'] = 0;
934
+				if (isset($config_var['min'])) {
935
+									$context['config_vars'][$config_var[0]]['min'] = $config_var['min'];
936
+				} else {
937
+									$context['config_vars'][$config_var[0]]['min'] = 0;
938
+				}
909 939
 
910
-				if (isset($config_var['max']))
911
-					$context['config_vars'][$config_var[0]]['max'] = $config_var['max'];
940
+				if (isset($config_var['max'])) {
941
+									$context['config_vars'][$config_var[0]]['max'] = $config_var['max'];
942
+				}
912 943
 
913
-				if (isset($config_var['step']))
914
-					$context['config_vars'][$config_var[0]]['step'] = $config_var['step'];
944
+				if (isset($config_var['step'])) {
945
+									$context['config_vars'][$config_var[0]]['step'] = $config_var['step'];
946
+				}
915 947
 			}
916 948
 
917 949
 			// If this is a select box handle any data.
@@ -919,12 +951,13 @@  discard block
 block discarded – undo
919 951
 			{
920 952
 				// If it's associative
921 953
 				$config_values = array_values($config_var[4]);
922
-				if (isset($config_values[0]) && is_array($config_values[0]))
923
-					$context['config_vars'][$config_var[0]]['data'] = $config_var[4];
924
-				else
954
+				if (isset($config_values[0]) && is_array($config_values[0])) {
955
+									$context['config_vars'][$config_var[0]]['data'] = $config_var[4];
956
+				} else
925 957
 				{
926
-					foreach ($config_var[4] as $key => $item)
927
-						$context['config_vars'][$config_var[0]]['data'][] = array($key, $item);
958
+					foreach ($config_var[4] as $key => $item) {
959
+											$context['config_vars'][$config_var[0]]['data'][] = array($key, $item);
960
+					}
928 961
 				}
929 962
 			}
930 963
 		}
@@ -949,10 +982,11 @@  discard block
 block discarded – undo
949 982
 
950 983
 	if (isset($_SESSION['adm-save']))
951 984
 	{
952
-		if ($_SESSION['adm-save'] === true)
953
-			$context['saved_successful'] = true;
954
-		else
955
-			$context['saved_failed'] = $_SESSION['adm-save'];
985
+		if ($_SESSION['adm-save'] === true) {
986
+					$context['saved_successful'] = true;
987
+		} else {
988
+					$context['saved_failed'] = $_SESSION['adm-save'];
989
+		}
956 990
 
957 991
 		unset($_SESSION['adm-save']);
958 992
 	}
@@ -964,26 +998,30 @@  discard block
 block discarded – undo
964 998
 	foreach ($config_vars as $config_var)
965 999
 	{
966 1000
 		// HR?
967
-		if (!is_array($config_var))
968
-			$context['config_vars'][] = $config_var;
969
-		else
1001
+		if (!is_array($config_var)) {
1002
+					$context['config_vars'][] = $config_var;
1003
+		} else
970 1004
 		{
971 1005
 			// If it has no name it doesn't have any purpose!
972
-			if (empty($config_var[1]))
973
-				continue;
1006
+			if (empty($config_var[1])) {
1007
+							continue;
1008
+			}
974 1009
 
975 1010
 			// Special case for inline permissions
976
-			if ($config_var[0] == 'permissions' && allowedTo('manage_permissions'))
977
-				$inlinePermissions[] = $config_var[1];
978
-			elseif ($config_var[0] == 'permissions')
979
-				continue;
1011
+			if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) {
1012
+							$inlinePermissions[] = $config_var[1];
1013
+			} elseif ($config_var[0] == 'permissions') {
1014
+							continue;
1015
+			}
980 1016
 
981
-			if ($config_var[0] == 'boards')
982
-				$board_list = true;
1017
+			if ($config_var[0] == 'boards') {
1018
+							$board_list = true;
1019
+			}
983 1020
 
984 1021
 			// Are we showing the BBC selection box?
985
-			if ($config_var[0] == 'bbc')
986
-				$bbcChoice[] = $config_var[1];
1022
+			if ($config_var[0] == 'bbc') {
1023
+							$bbcChoice[] = $config_var[1];
1024
+			}
987 1025
 
988 1026
 			// We need to do some parsing of the value before we pass it in.
989 1027
 			if (isset($modSettings[$config_var[1]]))
@@ -1002,8 +1040,7 @@  discard block
 block discarded – undo
1002 1040
 					default:
1003 1041
 						$value = $smcFunc['htmlspecialchars']($modSettings[$config_var[1]]);
1004 1042
 				}
1005
-			}
1006
-			else
1043
+			} else
1007 1044
 			{
1008 1045
 				// Darn, it's empty. What type is expected?
1009 1046
 				switch ($config_var[0])
@@ -1043,16 +1080,19 @@  discard block
 block discarded – undo
1043 1080
 			if ($config_var[0] == 'int' || $config_var[0] == 'float')
1044 1081
 			{
1045 1082
 				// Default to a min of 0 if one isn't set
1046
-				if (isset($config_var['min']))
1047
-					$context['config_vars'][$config_var[1]]['min'] = $config_var['min'];
1048
-				else
1049
-					$context['config_vars'][$config_var[1]]['min'] = 0;
1083
+				if (isset($config_var['min'])) {
1084
+									$context['config_vars'][$config_var[1]]['min'] = $config_var['min'];
1085
+				} else {
1086
+									$context['config_vars'][$config_var[1]]['min'] = 0;
1087
+				}
1050 1088
 
1051
-				if (isset($config_var['max']))
1052
-					$context['config_vars'][$config_var[1]]['max'] = $config_var['max'];
1089
+				if (isset($config_var['max'])) {
1090
+									$context['config_vars'][$config_var[1]]['max'] = $config_var['max'];
1091
+				}
1053 1092
 
1054
-				if (isset($config_var['step']))
1055
-					$context['config_vars'][$config_var[1]]['step'] = $config_var['step'];
1093
+				if (isset($config_var['step'])) {
1094
+									$context['config_vars'][$config_var[1]]['step'] = $config_var['step'];
1095
+				}
1056 1096
 			}
1057 1097
 
1058 1098
 			// If this is a select box handle any data.
@@ -1066,12 +1106,13 @@  discard block
 block discarded – undo
1066 1106
 				}
1067 1107
 
1068 1108
 				// If it's associative
1069
-				if (isset($config_var[2][0]) && is_array($config_var[2][0]))
1070
-					$context['config_vars'][$config_var[1]]['data'] = $config_var[2];
1071
-				else
1109
+				if (isset($config_var[2][0]) && is_array($config_var[2][0])) {
1110
+									$context['config_vars'][$config_var[1]]['data'] = $config_var[2];
1111
+				} else
1072 1112
 				{
1073
-					foreach ($config_var[2] as $key => $item)
1074
-						$context['config_vars'][$config_var[1]]['data'][] = array($key, $item);
1113
+					foreach ($config_var[2] as $key => $item) {
1114
+											$context['config_vars'][$config_var[1]]['data'][] = array($key, $item);
1115
+					}
1075 1116
 				}
1076 1117
 			}
1077 1118
 
@@ -1080,17 +1121,19 @@  discard block
 block discarded – undo
1080 1121
 			{
1081 1122
 				if (!is_numeric($k))
1082 1123
 				{
1083
-					if (substr($k, 0, 2) == 'on')
1084
-						$context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"';
1085
-					else
1086
-						$context['config_vars'][$config_var[1]][$k] = $v;
1124
+					if (substr($k, 0, 2) == 'on') {
1125
+											$context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"';
1126
+					} else {
1127
+											$context['config_vars'][$config_var[1]][$k] = $v;
1128
+					}
1087 1129
 				}
1088 1130
 
1089 1131
 				// See if there are any other labels that might fit?
1090
-				if (isset($txt['setting_' . $config_var[1]]))
1091
-					$context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]];
1092
-				elseif (isset($txt['groups_' . $config_var[1]]))
1093
-					$context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]];
1132
+				if (isset($txt['setting_' . $config_var[1]])) {
1133
+									$context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]];
1134
+				} elseif (isset($txt['groups_' . $config_var[1]])) {
1135
+									$context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]];
1136
+				}
1094 1137
 			}
1095 1138
 
1096 1139
 			// Set the subtext in case it's part of the label.
@@ -1123,8 +1166,9 @@  discard block
 block discarded – undo
1123 1166
 		// What are the options, eh?
1124 1167
 		$temp = parse_bbc(false);
1125 1168
 		$bbcTags = array();
1126
-		foreach ($temp as $tag)
1127
-			$bbcTags[] = $tag['tag'];
1169
+		foreach ($temp as $tag) {
1170
+					$bbcTags[] = $tag['tag'];
1171
+		}
1128 1172
 
1129 1173
 		$bbcTags = array_unique($bbcTags);
1130 1174
 		$totalTags = count($bbcTags);
@@ -1139,8 +1183,9 @@  discard block
 block discarded – undo
1139 1183
 		$col = 0; $i = 0;
1140 1184
 		foreach ($bbcTags as $tag)
1141 1185
 		{
1142
-			if ($i % $tagsPerColumn == 0 && $i != 0)
1143
-				$col++;
1186
+			if ($i % $tagsPerColumn == 0 && $i != 0) {
1187
+							$col++;
1188
+			}
1144 1189
 
1145 1190
 			$context['bbc_columns'][$col][] = array(
1146 1191
 				'tag' => $tag,
@@ -1183,18 +1228,21 @@  discard block
 block discarded – undo
1183 1228
 	validateToken('admin-ssc');
1184 1229
 
1185 1230
 	// Fix the darn stupid cookiename! (more may not be allowed, but these for sure!)
1186
-	if (isset($_POST['cookiename']))
1187
-		$_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']);
1231
+	if (isset($_POST['cookiename'])) {
1232
+			$_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']);
1233
+	}
1188 1234
 
1189 1235
 	// Fix the forum's URL if necessary.
1190 1236
 	if (isset($_POST['boardurl']))
1191 1237
 	{
1192
-		if (substr($_POST['boardurl'], -10) == '/index.php')
1193
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1194
-		elseif (substr($_POST['boardurl'], -1) == '/')
1195
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1196
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
1197
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1238
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
1239
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1240
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
1241
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1242
+		}
1243
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
1244
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1245
+		}
1198 1246
 	}
1199 1247
 
1200 1248
 	// Any passwords?
@@ -1229,21 +1277,21 @@  discard block
 block discarded – undo
1229 1277
 	// Figure out which config vars we're saving here...
1230 1278
 	foreach ($config_vars as $var)
1231 1279
 	{
1232
-		if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]])))
1233
-			continue;
1280
+		if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) {
1281
+					continue;
1282
+		}
1234 1283
 
1235 1284
 		$config_var = $var[0];
1236 1285
 
1237 1286
 		if (in_array($config_var, $config_passwords))
1238 1287
 		{
1239
-			if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1])
1240
-				$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\'';
1241
-		}
1242
-		elseif (in_array($config_var, $config_strs))
1288
+			if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) {
1289
+							$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\'';
1290
+			}
1291
+		} elseif (in_array($config_var, $config_strs))
1243 1292
 		{
1244 1293
 			$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var], '\'\\') . '\'';
1245
-		}
1246
-		elseif (in_array($config_var, $config_ints))
1294
+		} elseif (in_array($config_var, $config_ints))
1247 1295
 		{
1248 1296
 			$new_settings[$config_var] = (int) $_POST[$config_var];
1249 1297
 
@@ -1252,17 +1300,17 @@  discard block
 block discarded – undo
1252 1300
 			$new_settings[$config_var] = max($min, $new_settings[$config_var]);
1253 1301
 
1254 1302
 			// Is there a max value for this as well?
1255
-			if (isset($var['max']))
1256
-				$new_settings[$config_var] = min($var['max'], $new_settings[$config_var]);
1257
-		}
1258
-		elseif (in_array($config_var, $config_bools))
1303
+			if (isset($var['max'])) {
1304
+							$new_settings[$config_var] = min($var['max'], $new_settings[$config_var]);
1305
+			}
1306
+		} elseif (in_array($config_var, $config_bools))
1259 1307
 		{
1260
-			if (!empty($_POST[$config_var]))
1261
-				$new_settings[$config_var] = '1';
1262
-			else
1263
-				$new_settings[$config_var] = '0';
1264
-		}
1265
-		else
1308
+			if (!empty($_POST[$config_var])) {
1309
+							$new_settings[$config_var] = '1';
1310
+			} else {
1311
+							$new_settings[$config_var] = '0';
1312
+			}
1313
+		} else
1266 1314
 		{
1267 1315
 			// This shouldn't happen, but it might...
1268 1316
 			fatal_error('Unknown config_var \'' . $config_var . '\'');
@@ -1278,30 +1326,35 @@  discard block
 block discarded – undo
1278 1326
 	foreach ($config_vars as $config_var)
1279 1327
 	{
1280 1328
 		// We just saved the file-based settings, so skip their definitions.
1281
-		if (!is_array($config_var) || $config_var[2] == 'file')
1282
-			continue;
1329
+		if (!is_array($config_var) || $config_var[2] == 'file') {
1330
+					continue;
1331
+		}
1283 1332
 
1284 1333
 		$new_setting = array($config_var[3], $config_var[0]);
1285 1334
 
1286 1335
 		// Select options need carried over, too.
1287
-		if (isset($config_var[4]))
1288
-			$new_setting[] = $config_var[4];
1336
+		if (isset($config_var[4])) {
1337
+					$new_setting[] = $config_var[4];
1338
+		}
1289 1339
 
1290 1340
 		// Include min and max if necessary
1291
-		if (isset($config_var['min']))
1292
-			$new_setting['min'] = $config_var['min'];
1341
+		if (isset($config_var['min'])) {
1342
+					$new_setting['min'] = $config_var['min'];
1343
+		}
1293 1344
 
1294
-		if (isset($config_var['max']))
1295
-			$new_setting['max'] = $config_var['max'];
1345
+		if (isset($config_var['max'])) {
1346
+					$new_setting['max'] = $config_var['max'];
1347
+		}
1296 1348
 
1297 1349
 		// Rewrite the definition a bit.
1298 1350
 		$new_settings[] = $new_setting;
1299 1351
 	}
1300 1352
 
1301 1353
 	// Save the new database-based settings, if any.
1302
-	if (!empty($new_settings))
1303
-		saveDBSettings($new_settings);
1304
-}
1354
+	if (!empty($new_settings)) {
1355
+			saveDBSettings($new_settings);
1356
+	}
1357
+	}
1305 1358
 
1306 1359
 /**
1307 1360
  * Helper function for saving database settings.
@@ -1319,22 +1372,25 @@  discard block
 block discarded – undo
1319 1372
 	$inlinePermissions = array();
1320 1373
 	foreach ($config_vars as $var)
1321 1374
 	{
1322
-		if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags']))))
1323
-			continue;
1375
+		if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) {
1376
+					continue;
1377
+		}
1324 1378
 
1325 1379
 		// Checkboxes!
1326
-		elseif ($var[0] == 'check')
1327
-			$setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0';
1380
+		elseif ($var[0] == 'check') {
1381
+					$setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0';
1382
+		}
1328 1383
 		// Select boxes!
1329
-		elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2])))
1330
-			$setArray[$var[1]] = $_POST[$var[1]];
1331
-		elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array())
1384
+		elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) {
1385
+					$setArray[$var[1]] = $_POST[$var[1]];
1386
+		} elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array())
1332 1387
 		{
1333 1388
 			// For security purposes we validate this line by line.
1334 1389
 			$lOptions = array();
1335
-			foreach ($_POST[$var[1]] as $invar)
1336
-				if (in_array($invar, array_keys($var[2])))
1390
+			foreach ($_POST[$var[1]] as $invar) {
1391
+							if (in_array($invar, array_keys($var[2])))
1337 1392
 					$lOptions[] = $invar;
1393
+			}
1338 1394
 
1339 1395
 			$setArray[$var[1]] = $smcFunc['json_encode']($lOptions);
1340 1396
 		}
@@ -1348,18 +1404,20 @@  discard block
 block discarded – undo
1348 1404
 				$request = $smcFunc['db_query']('', '
1349 1405
 					SELECT id_board
1350 1406
 					FROM {db_prefix}boards');
1351
-				while ($row = $smcFunc['db_fetch_row']($request))
1352
-					$board_list[$row[0]] = true;
1407
+				while ($row = $smcFunc['db_fetch_row']($request)) {
1408
+									$board_list[$row[0]] = true;
1409
+				}
1353 1410
 
1354 1411
 				$smcFunc['db_free_result']($request);
1355 1412
 			}
1356 1413
 
1357 1414
 			$lOptions = array();
1358 1415
 
1359
-			if (!empty($_POST[$var[1]]))
1360
-				foreach ($_POST[$var[1]] as $invar => $dummy)
1416
+			if (!empty($_POST[$var[1]])) {
1417
+							foreach ($_POST[$var[1]] as $invar => $dummy)
1361 1418
 					if (isset($board_list[$invar]))
1362 1419
 						$lOptions[] = $invar;
1420
+			}
1363 1421
 
1364 1422
 			$setArray[$var[1]] = !empty($lOptions) ? implode(',', $lOptions) : '';
1365 1423
 		}
@@ -1373,8 +1431,9 @@  discard block
 block discarded – undo
1373 1431
 			$setArray[$var[1]] = max($min, $setArray[$var[1]]);
1374 1432
 
1375 1433
 			// Do we have a max value for this as well?
1376
-			if (isset($var['max']))
1377
-				$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1434
+			if (isset($var['max'])) {
1435
+							$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1436
+			}
1378 1437
 		}
1379 1438
 		// Floating point!
1380 1439
 		elseif ($var[0] == 'float')
@@ -1386,39 +1445,46 @@  discard block
 block discarded – undo
1386 1445
 			$setArray[$var[1]] = max($min, $setArray[$var[1]]);
1387 1446
 
1388 1447
 			// Do we have a max value for this as well?
1389
-			if (isset($var['max']))
1390
-				$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1448
+			if (isset($var['max'])) {
1449
+							$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1450
+			}
1391 1451
 		}
1392 1452
 		// Text!
1393
-		elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time')))
1394
-			$setArray[$var[1]] = $_POST[$var[1]];
1453
+		elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) {
1454
+					$setArray[$var[1]] = $_POST[$var[1]];
1455
+		}
1395 1456
 		// Passwords!
1396 1457
 		elseif ($var[0] == 'password')
1397 1458
 		{
1398
-			if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1])
1399
-				$setArray[$var[1]] = $_POST[$var[1]][0];
1459
+			if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) {
1460
+							$setArray[$var[1]] = $_POST[$var[1]][0];
1461
+			}
1400 1462
 		}
1401 1463
 		// BBC.
1402 1464
 		elseif ($var[0] == 'bbc')
1403 1465
 		{
1404 1466
 			$bbcTags = array();
1405
-			foreach (parse_bbc(false) as $tag)
1406
-				$bbcTags[] = $tag['tag'];
1467
+			foreach (parse_bbc(false) as $tag) {
1468
+							$bbcTags[] = $tag['tag'];
1469
+			}
1407 1470
 
1408
-			if (!isset($_POST[$var[1] . '_enabledTags']))
1409
-				$_POST[$var[1] . '_enabledTags'] = array();
1410
-			elseif (!is_array($_POST[$var[1] . '_enabledTags']))
1411
-				$_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']);
1471
+			if (!isset($_POST[$var[1] . '_enabledTags'])) {
1472
+							$_POST[$var[1] . '_enabledTags'] = array();
1473
+			} elseif (!is_array($_POST[$var[1] . '_enabledTags'])) {
1474
+							$_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']);
1475
+			}
1412 1476
 
1413 1477
 			$setArray[$var[1]] = implode(',', array_diff($bbcTags, $_POST[$var[1] . '_enabledTags']));
1414 1478
 		}
1415 1479
 		// Permissions?
1416
-		elseif ($var[0] == 'permissions')
1417
-			$inlinePermissions[] = $var[1];
1480
+		elseif ($var[0] == 'permissions') {
1481
+					$inlinePermissions[] = $var[1];
1482
+		}
1418 1483
 	}
1419 1484
 
1420
-	if (!empty($setArray))
1421
-		updateSettings($setArray);
1485
+	if (!empty($setArray)) {
1486
+			updateSettings($setArray);
1487
+	}
1422 1488
 
1423 1489
 	// If we have inline permissions we need to save them.
1424 1490
 	if (!empty($inlinePermissions) && allowedTo('manage_permissions'))
@@ -1455,18 +1521,21 @@  discard block
 block discarded – undo
1455 1521
 	// put all of it into an array
1456 1522
 	foreach ($info_lines as $line)
1457 1523
 	{
1458
-		if (preg_match('~(' . $remove . ')~', $line))
1459
-			continue;
1524
+		if (preg_match('~(' . $remove . ')~', $line)) {
1525
+					continue;
1526
+		}
1460 1527
 
1461 1528
 		// new category?
1462
-		if (strpos($line, '<h2>') !== false)
1463
-			$category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category;
1529
+		if (strpos($line, '<h2>') !== false) {
1530
+					$category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category;
1531
+		}
1464 1532
 
1465 1533
 		// load it as setting => value or the old setting local master
1466
-		if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val))
1467
-			$pinfo[$category][$val[1]] = $val[2];
1468
-		elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val))
1469
-			$pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]);
1534
+		if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) {
1535
+					$pinfo[$category][$val[1]] = $val[2];
1536
+		} elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) {
1537
+					$pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]);
1538
+		}
1470 1539
 	}
1471 1540
 
1472 1541
 	// load it in to context and display it
@@ -1501,8 +1570,9 @@  discard block
 block discarded – undo
1501 1570
 				$testAPI = new $cache_class_name();
1502 1571
 
1503 1572
 				// No Support?  NEXT!
1504
-				if (!$testAPI->isSupported(true))
1505
-					continue;
1573
+				if (!$testAPI->isSupported(true)) {
1574
+									continue;
1575
+				}
1506 1576
 
1507 1577
 				$apis[$tryCache] = isset($txt[$tryCache . '_cache']) ? $txt[$tryCache . '_cache'] : $tryCache;
1508 1578
 			}
@@ -1527,8 +1597,9 @@  discard block
 block discarded – undo
1527 1597
 	global $modSettings, $boardurl, $smcFunc;
1528 1598
 
1529 1599
 	// Already have a key?  Can't register again.
1530
-	if (!empty($modSettings['sm_stats_key']))
1531
-		return true;
1600
+	if (!empty($modSettings['sm_stats_key'])) {
1601
+			return true;
1602
+	}
1532 1603
 
1533 1604
 	$fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr);
1534 1605
 	if ($fp)
@@ -1539,8 +1610,9 @@  discard block
 block discarded – undo
1539 1610
 		fwrite($fp, $out);
1540 1611
 
1541 1612
 		$return_data = '';
1542
-		while (!feof($fp))
1543
-			$return_data .= fgets($fp, 128);
1613
+		while (!feof($fp)) {
1614
+					$return_data .= fgets($fp, 128);
1615
+		}
1544 1616
 
1545 1617
 		fclose($fp);
1546 1618
 
Please login to merge, or discard this patch.
Sources/ManageBans.php 1 patch
Braces   +257 added lines, -207 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Ban center. The main entrance point for all ban center functions.
@@ -120,10 +121,11 @@  discard block
 block discarded – undo
120 121
 	}
121 122
 
122 123
 	// Create a date string so we don't overload them with date info.
123
-	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
124
-		$context['ban_time_format'] = $user_info['time_format'];
125
-	else
126
-		$context['ban_time_format'] = $matches[0];
124
+	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
125
+			$context['ban_time_format'] = $user_info['time_format'];
126
+	} else {
127
+			$context['ban_time_format'] = $matches[0];
128
+	}
127 129
 
128 130
 	$listOptions = array(
129 131
 		'id' => 'ban_list',
@@ -201,16 +203,19 @@  discard block
 block discarded – undo
201 203
 					'function' => function($rowData) use ($txt)
202 204
 					{
203 205
 						// This ban never expires...whahaha.
204
-						if ($rowData['expire_time'] === null)
205
-							return $txt['never'];
206
+						if ($rowData['expire_time'] === null) {
207
+													return $txt['never'];
208
+						}
206 209
 
207 210
 						// This ban has already expired.
208
-						elseif ($rowData['expire_time'] < time())
209
-							return sprintf('<span class="red">%1$s</span>', $txt['ban_expired']);
211
+						elseif ($rowData['expire_time'] < time()) {
212
+													return sprintf('<span class="red">%1$s</span>', $txt['ban_expired']);
213
+						}
210 214
 
211 215
 						// Still need to wait a few days for this ban to expire.
212
-						else
213
-							return sprintf('%1$d&nbsp;%2$s', ceil(($rowData['expire_time'] - time()) / (60 * 60 * 24)), $txt['ban_days']);
216
+						else {
217
+													return sprintf('%1$d&nbsp;%2$s', ceil(($rowData['expire_time'] - time()) / (60 * 60 * 24)), $txt['ban_days']);
218
+						}
214 219
 					},
215 220
 				),
216 221
 				'sort' => array(
@@ -320,8 +325,9 @@  discard block
 block discarded – undo
320 325
 		)
321 326
 	);
322 327
 	$bans = array();
323
-	while ($row = $smcFunc['db_fetch_assoc']($request))
324
-		$bans[] = $row;
328
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
329
+			$bans[] = $row;
330
+	}
325 331
 
326 332
 	$smcFunc['db_free_result']($request);
327 333
 
@@ -363,8 +369,9 @@  discard block
 block discarded – undo
363 369
 {
364 370
 	global $txt, $modSettings, $context, $scripturl, $smcFunc, $sourcedir;
365 371
 
366
-	if ((isset($_POST['add_ban']) || isset($_POST['modify_ban']) || isset($_POST['remove_selection'])) && empty($context['ban_errors']))
367
-		BanEdit2();
372
+	if ((isset($_POST['add_ban']) || isset($_POST['modify_ban']) || isset($_POST['remove_selection'])) && empty($context['ban_errors'])) {
373
+			BanEdit2();
374
+	}
368 375
 
369 376
 	$ban_group_id = isset($context['ban']['id']) ? $context['ban']['id'] : (isset($_REQUEST['bg']) ? (int) $_REQUEST['bg'] : 0);
370 377
 
@@ -373,11 +380,10 @@  discard block
 block discarded – undo
373 380
 	createToken('admin-bet');
374 381
 	$context['form_url'] = $scripturl . '?action=admin;area=ban;sa=edit';
375 382
 
376
-	if (!empty($context['ban_errors']))
377
-		foreach ($context['ban_errors'] as $error)
383
+	if (!empty($context['ban_errors'])) {
384
+			foreach ($context['ban_errors'] as $error)
378 385
 			$context['error_messages'][$error] = $txt[$error];
379
-
380
-	else
386
+	} else
381 387
 	{
382 388
 		// If we're editing an existing ban, get it from the database.
383 389
 		if (!empty($ban_group_id))
@@ -413,12 +419,13 @@  discard block
 block discarded – undo
413 419
 						'data' => array(
414 420
 							'function' => function($ban_item) use ($txt)
415 421
 							{
416
-								if (in_array($ban_item['type'], array('ip', 'hostname', 'email')))
417
-									return '<strong>' . $txt[$ban_item['type']] . ':</strong>&nbsp;' . $ban_item[$ban_item['type']];
418
-								elseif ($ban_item['type'] == 'user')
419
-									return '<strong>' . $txt['username'] . ':</strong>&nbsp;' . $ban_item['user']['link'];
420
-								else
421
-									return '<strong>' . $txt['unknown'] . ':</strong>&nbsp;' . $ban_item['no_bantype_selected'];
422
+								if (in_array($ban_item['type'], array('ip', 'hostname', 'email'))) {
423
+																	return '<strong>' . $txt[$ban_item['type']] . ':</strong>&nbsp;' . $ban_item[$ban_item['type']];
424
+								} elseif ($ban_item['type'] == 'user') {
425
+																	return '<strong>' . $txt['username'] . ':</strong>&nbsp;' . $ban_item['user']['link'];
426
+								} else {
427
+																	return '<strong>' . $txt['unknown'] . ':</strong>&nbsp;' . $ban_item['no_bantype_selected'];
428
+								}
422 429
 							},
423 430
 							'style' => 'text-align: left;',
424 431
 						),
@@ -556,8 +563,9 @@  discard block
 block discarded – undo
556 563
 					$context['ban']['from_user'] = true;
557 564
 
558 565
 					// Would be nice if we could also ban the hostname.
559
-					if ((preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $context['ban_suggestions']['main_ip']) == 1 || isValidIPv6($context['ban_suggestions']['main_ip'])) && empty($modSettings['disableHostnameLookup']))
560
-						$context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']);
566
+					if ((preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $context['ban_suggestions']['main_ip']) == 1 || isValidIPv6($context['ban_suggestions']['main_ip'])) && empty($modSettings['disableHostnameLookup'])) {
567
+											$context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']);
568
+					}
561 569
 
562 570
 					$context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']);
563 571
 				}
@@ -625,8 +633,9 @@  discard block
 block discarded – undo
625 633
 			'items_per_page' => $items_per_page,
626 634
 		)
627 635
 	);
628
-	if ($smcFunc['db_num_rows']($request) == 0)
629
-		fatal_lang_error('ban_not_found', false);
636
+	if ($smcFunc['db_num_rows']($request) == 0) {
637
+			fatal_lang_error('ban_not_found', false);
638
+	}
630 639
 
631 640
 	while ($row = $smcFunc['db_fetch_assoc']($request))
632 641
 	{
@@ -663,18 +672,15 @@  discard block
 block discarded – undo
663 672
 			{
664 673
 				$ban_items[$row['id_ban']]['type'] = 'ip';
665 674
 				$ban_items[$row['id_ban']]['ip'] = range2ip($row['ip_low'], $row['ip_high']);
666
-			}
667
-			elseif (!empty($row['hostname']))
675
+			} elseif (!empty($row['hostname']))
668 676
 			{
669 677
 				$ban_items[$row['id_ban']]['type'] = 'hostname';
670 678
 				$ban_items[$row['id_ban']]['hostname'] = str_replace('%', '*', $row['hostname']);
671
-			}
672
-			elseif (!empty($row['email_address']))
679
+			} elseif (!empty($row['email_address']))
673 680
 			{
674 681
 				$ban_items[$row['id_ban']]['type'] = 'email';
675 682
 				$ban_items[$row['id_ban']]['email'] = str_replace('%', '*', $row['email_address']);
676
-			}
677
-			elseif (!empty($row['id_member']))
683
+			} elseif (!empty($row['id_member']))
678 684
 			{
679 685
 				$ban_items[$row['id_ban']]['type'] = 'user';
680 686
 				$ban_items[$row['id_ban']]['user'] = array(
@@ -740,9 +746,10 @@  discard block
 block discarded – undo
740 746
 	$search_list += array('ips_in_messages' => 'banLoadAdditionalIPsMember', 'ips_in_errors' => 'banLoadAdditionalIPsError');
741 747
 
742 748
 	$return = array();
743
-	foreach ($search_list as $key => $callable)
744
-		if (is_callable($callable))
749
+	foreach ($search_list as $key => $callable) {
750
+			if (is_callable($callable))
745 751
 			$return[$key] = call_user_func($callable, $member_id);
752
+	}
746 753
 
747 754
 	return $return;
748 755
 }
@@ -767,8 +774,9 @@  discard block
 block discarded – undo
767 774
 			'current_user' => $member_id,
768 775
 		)
769 776
 	);
770
-	while ($row = $smcFunc['db_fetch_assoc']($request))
771
-		$message_ips[] = inet_dtop($row['poster_ip']);
777
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
778
+			$message_ips[] = inet_dtop($row['poster_ip']);
779
+	}
772 780
 	$smcFunc['db_free_result']($request);
773 781
 
774 782
 	return $message_ips;
@@ -793,8 +801,9 @@  discard block
 block discarded – undo
793 801
 			'current_user' => $member_id,
794 802
 		)
795 803
 	);
796
-	while ($row = $smcFunc['db_fetch_assoc']($request))
797
-	    $error_ips[] = inet_dtop($row['ip']);
804
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
805
+		    $error_ips[] = inet_dtop($row['ip']);
806
+	}
798 807
 	$smcFunc['db_free_result']($request);
799 808
 
800 809
 	return $error_ips;
@@ -835,11 +844,13 @@  discard block
 block discarded – undo
835 844
 		$ban_info['cannot']['login'] = !empty($ban_info['full_ban']) || empty($_POST['cannot_login']) ? 0 : 1;
836 845
 
837 846
 		// Adding a new ban group
838
-		if (empty($_REQUEST['bg']))
839
-			$ban_group_id = insertBanGroup($ban_info);
847
+		if (empty($_REQUEST['bg'])) {
848
+					$ban_group_id = insertBanGroup($ban_info);
849
+		}
840 850
 		// Editing an existing ban group
841
-		else
842
-			$ban_group_id = updateBanGroup($ban_info);
851
+		else {
852
+					$ban_group_id = updateBanGroup($ban_info);
853
+		}
843 854
 
844 855
 		if (is_numeric($ban_group_id))
845 856
 		{
@@ -850,9 +861,10 @@  discard block
 block discarded – undo
850 861
 		$context['ban'] = $ban_info;
851 862
 	}
852 863
 
853
-	if (isset($_POST['ban_suggestions']))
854
-		// @TODO: is $_REQUEST['bi'] ever set?
864
+	if (isset($_POST['ban_suggestions'])) {
865
+			// @TODO: is $_REQUEST['bi'] ever set?
855 866
 		$saved_triggers = saveTriggers($_POST['ban_suggestions'], $ban_info['id'], isset($_REQUEST['u']) ? (int) $_REQUEST['u'] : 0, isset($_REQUEST['bi']) ? (int) $_REQUEST['bi'] : 0);
867
+	}
856 868
 
857 869
 	// Something went wrong somewhere... Oh well, let's go back.
858 870
 	if (!empty($context['ban_errors']))
@@ -862,8 +874,9 @@  discard block
 block discarded – undo
862 874
 		$context['ban_suggestions'] = array_merge($context['ban_suggestions'], getMemberData((int) $_REQUEST['u']));
863 875
 
864 876
 		// Not strictly necessary, but it's nice
865
-		if (!empty($context['ban_suggestions']['member']['id']))
866
-			$context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']);
877
+		if (!empty($context['ban_suggestions']['member']['id'])) {
878
+					$context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']);
879
+		}
867 880
 		return BanEdit();
868 881
 	}
869 882
 	$context['ban_suggestions']['saved_triggers'] = !empty($saved_triggers) ? $saved_triggers : array();
@@ -910,10 +923,11 @@  discard block
 block discarded – undo
910 923
 
911 924
 	foreach ($suggestions as $key => $value)
912 925
 	{
913
-		if (is_array($value))
914
-			$triggers[$key] = $value;
915
-		else
916
-			$triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : '';
926
+		if (is_array($value)) {
927
+					$triggers[$key] = $value;
928
+		} else {
929
+					$triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : '';
930
+		}
917 931
 	}
918 932
 
919 933
 	$ban_triggers = validateTriggers($triggers);
@@ -921,16 +935,18 @@  discard block
 block discarded – undo
921 935
 	// Time to save!
922 936
 	if (!empty($ban_triggers['ban_triggers']) && empty($context['ban_errors']))
923 937
 	{
924
-		if (empty($ban_id))
925
-			addTriggers($ban_group, $ban_triggers['ban_triggers'], $ban_triggers['log_info']);
926
-		else
927
-			updateTriggers($ban_id, $ban_group, array_shift($ban_triggers['ban_triggers']), $ban_triggers['log_info']);
938
+		if (empty($ban_id)) {
939
+					addTriggers($ban_group, $ban_triggers['ban_triggers'], $ban_triggers['log_info']);
940
+		} else {
941
+					updateTriggers($ban_id, $ban_group, array_shift($ban_triggers['ban_triggers']), $ban_triggers['log_info']);
942
+		}
943
+	}
944
+	if (!empty($context['ban_errors'])) {
945
+			return $triggers;
946
+	} else {
947
+			return false;
948
+	}
928 949
 	}
929
-	if (!empty($context['ban_errors']))
930
-		return $triggers;
931
-	else
932
-		return false;
933
-}
934 950
 
935 951
 /**
936 952
  * This function removes a bunch of triggers based on ids
@@ -944,14 +960,17 @@  discard block
 block discarded – undo
944 960
 {
945 961
 	global $smcFunc, $scripturl;
946 962
 
947
-	if ($group_id !== false)
948
-		$group_id = (int) $group_id;
963
+	if ($group_id !== false) {
964
+			$group_id = (int) $group_id;
965
+	}
949 966
 
950
-	if (empty($group_id) && empty($items_ids))
951
-		return false;
967
+	if (empty($group_id) && empty($items_ids)) {
968
+			return false;
969
+	}
952 970
 
953
-	if (!is_array($items_ids))
954
-		$items_ids = array($items_ids);
971
+	if (!is_array($items_ids)) {
972
+			$items_ids = array($items_ids);
973
+	}
955 974
 
956 975
 	$log_info = array();
957 976
 	$ban_items = array();
@@ -989,8 +1008,7 @@  discard block
 block discarded – undo
989 1008
 					'bantype' => ($is_range ? 'ip_range' : 'main_ip'),
990 1009
 					'value' => $ban_items[$row['id_ban']]['ip'],
991 1010
 				);
992
-			}
993
-			elseif (!empty($row['hostname']))
1011
+			} elseif (!empty($row['hostname']))
994 1012
 			{
995 1013
 				$ban_items[$row['id_ban']]['type'] = 'hostname';
996 1014
 				$ban_items[$row['id_ban']]['hostname'] = str_replace('%', '*', $row['hostname']);
@@ -998,8 +1016,7 @@  discard block
 block discarded – undo
998 1016
 					'bantype' => 'hostname',
999 1017
 					'value' => $row['hostname'],
1000 1018
 				);
1001
-			}
1002
-			elseif (!empty($row['email_address']))
1019
+			} elseif (!empty($row['email_address']))
1003 1020
 			{
1004 1021
 				$ban_items[$row['id_ban']]['type'] = 'email';
1005 1022
 				$ban_items[$row['id_ban']]['email'] = str_replace('%', '*', $row['email_address']);
@@ -1007,8 +1024,7 @@  discard block
 block discarded – undo
1007 1024
 					'bantype' => 'email',
1008 1025
 					'value' => $ban_items[$row['id_ban']]['email'],
1009 1026
 				);
1010
-			}
1011
-			elseif (!empty($row['id_member']))
1027
+			} elseif (!empty($row['id_member']))
1012 1028
 			{
1013 1029
 				$ban_items[$row['id_ban']]['type'] = 'user';
1014 1030
 				$ban_items[$row['id_ban']]['user'] = array(
@@ -1041,8 +1057,7 @@  discard block
 block discarded – undo
1041 1057
 				'ban_group' => $group_id,
1042 1058
 			)
1043 1059
 		);
1044
-	}
1045
-	elseif (!empty($items_ids))
1060
+	} elseif (!empty($items_ids))
1046 1061
 	{
1047 1062
 		$smcFunc['db_query']('', '
1048 1063
 			DELETE FROM {db_prefix}ban_items
@@ -1067,13 +1082,15 @@  discard block
 block discarded – undo
1067 1082
 {
1068 1083
 	global $smcFunc;
1069 1084
 
1070
-	if (!is_array($group_ids))
1071
-		$group_ids = array($group_ids);
1085
+	if (!is_array($group_ids)) {
1086
+			$group_ids = array($group_ids);
1087
+	}
1072 1088
 
1073 1089
 	$group_ids = array_unique($group_ids);
1074 1090
 
1075
-	if (empty($group_ids))
1076
-		return false;
1091
+	if (empty($group_ids)) {
1092
+			return false;
1093
+	}
1077 1094
 
1078 1095
 	$smcFunc['db_query']('', '
1079 1096
 		DELETE FROM {db_prefix}ban_groups
@@ -1097,21 +1114,23 @@  discard block
 block discarded – undo
1097 1114
 {
1098 1115
 	global $smcFunc;
1099 1116
 
1100
-	if (empty($ids))
1101
-		$smcFunc['db_query']('truncate_table', '
1117
+	if (empty($ids)) {
1118
+			$smcFunc['db_query']('truncate_table', '
1102 1119
 			TRUNCATE {db_prefix}log_banned',
1103 1120
 			array(
1104 1121
 			)
1105 1122
 		);
1106
-	else
1123
+	} else
1107 1124
 	{
1108
-		if (!is_array($ids))
1109
-			$ids = array($ids);
1125
+		if (!is_array($ids)) {
1126
+					$ids = array($ids);
1127
+		}
1110 1128
 
1111 1129
 		$ids = array_unique($ids);
1112 1130
 
1113
-		if (empty($ids))
1114
-			return false;
1131
+		if (empty($ids)) {
1132
+					return false;
1133
+		}
1115 1134
 
1116 1135
 		$smcFunc['db_query']('', '
1117 1136
 			DELETE FROM {db_prefix}log_banned
@@ -1137,8 +1156,9 @@  discard block
 block discarded – undo
1137 1156
 {
1138 1157
 	global $context, $smcFunc;
1139 1158
 
1140
-	if (empty($triggers))
1141
-		$context['ban_erros'][] = 'ban_empty_triggers';
1159
+	if (empty($triggers)) {
1160
+			$context['ban_erros'][] = 'ban_empty_triggers';
1161
+	}
1142 1162
 
1143 1163
 	$ban_triggers = array();
1144 1164
 	$log_info = array();
@@ -1147,39 +1167,39 @@  discard block
 block discarded – undo
1147 1167
 	{
1148 1168
 		if (!empty($value))
1149 1169
 		{
1150
-			if ($key == 'member')
1151
-				continue;
1170
+			if ($key == 'member') {
1171
+							continue;
1172
+			}
1152 1173
 
1153 1174
 			if ($key == 'main_ip')
1154 1175
 			{
1155 1176
 				$value = trim($value);
1156 1177
 				$ip_parts = ip2range($value);
1157
-				if (!checkExistingTriggerIP($ip_parts, $value))
1158
-					$context['ban_erros'][] = 'invalid_ip';
1159
-				else
1178
+				if (!checkExistingTriggerIP($ip_parts, $value)) {
1179
+									$context['ban_erros'][] = 'invalid_ip';
1180
+				} else
1160 1181
 				{
1161 1182
 					$ban_triggers['main_ip'] = array(
1162 1183
 						'ip_low' => $ip_parts['low'],
1163 1184
 						'ip_high' => $ip_parts['high']
1164 1185
 					);
1165 1186
 				}
1166
-			}
1167
-			elseif ($key == 'hostname')
1187
+			} elseif ($key == 'hostname')
1168 1188
 			{
1169
-				if (preg_match('/[^\w.\-*]/', $value) == 1)
1170
-					$context['ban_erros'][] = 'invalid_hostname';
1171
-				else
1189
+				if (preg_match('/[^\w.\-*]/', $value) == 1) {
1190
+									$context['ban_erros'][] = 'invalid_hostname';
1191
+				} else
1172 1192
 				{
1173 1193
 					// Replace the * wildcard by a MySQL wildcard %.
1174 1194
 					$value = substr(str_replace('*', '%', $value), 0, 255);
1175 1195
 
1176 1196
 					$ban_triggers['hostname']['hostname'] = $value;
1177 1197
 				}
1178
-			}
1179
-			elseif ($key == 'email')
1198
+			} elseif ($key == 'email')
1180 1199
 			{
1181
-				if (preg_match('/[^\w.\-\+*@]/', $value) == 1)
1182
-					$context['ban_erros'][] = 'invalid_email';
1200
+				if (preg_match('/[^\w.\-\+*@]/', $value) == 1) {
1201
+									$context['ban_erros'][] = 'invalid_email';
1202
+				}
1183 1203
 
1184 1204
 				// Check the user is not banning an admin.
1185 1205
 				$request = $smcFunc['db_query']('', '
@@ -1193,15 +1213,15 @@  discard block
 block discarded – undo
1193 1213
 						'email' => $value,
1194 1214
 					)
1195 1215
 				);
1196
-				if ($smcFunc['db_num_rows']($request) != 0)
1197
-					$context['ban_erros'][] = 'no_ban_admin';
1216
+				if ($smcFunc['db_num_rows']($request) != 0) {
1217
+									$context['ban_erros'][] = 'no_ban_admin';
1218
+				}
1198 1219
 				$smcFunc['db_free_result']($request);
1199 1220
 
1200 1221
 				$value = substr(strtolower(str_replace('*', '%', $value)), 0, 255);
1201 1222
 
1202 1223
 				$ban_triggers['email']['email_address'] = $value;
1203
-			}
1204
-			elseif ($key == 'user')
1224
+			} elseif ($key == 'user')
1205 1225
 			{
1206 1226
 				$user = preg_replace('~&amp;#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $smcFunc['htmlspecialchars']($value, ENT_QUOTES));
1207 1227
 
@@ -1215,8 +1235,9 @@  discard block
 block discarded – undo
1215 1235
 						'username' => $user,
1216 1236
 					)
1217 1237
 				);
1218
-				if ($smcFunc['db_num_rows']($request) == 0)
1219
-					$context['ban_erros'][] = 'invalid_username';
1238
+				if ($smcFunc['db_num_rows']($request) == 0) {
1239
+									$context['ban_erros'][] = 'invalid_username';
1240
+				}
1220 1241
 				list ($value, $isAdmin) = $smcFunc['db_fetch_row']($request);
1221 1242
 				$smcFunc['db_free_result']($request);
1222 1243
 
@@ -1224,25 +1245,25 @@  discard block
 block discarded – undo
1224 1245
 				{
1225 1246
 					unset($value);
1226 1247
 					$context['ban_erros'][] = 'no_ban_admin';
1248
+				} else {
1249
+									$ban_triggers['user']['id_member'] = $value;
1227 1250
 				}
1228
-				else
1229
-					$ban_triggers['user']['id_member'] = $value;
1230
-			}
1231
-			elseif (in_array($key, array('ips_in_messages', 'ips_in_errors')))
1251
+			} elseif (in_array($key, array('ips_in_messages', 'ips_in_errors')))
1232 1252
 			{
1233 1253
 				// Special case, those two are arrays themselves
1234 1254
 				$values = array_unique($value);
1235 1255
 				// Don't add the main IP again.
1236
-				if (isset($triggers['main_ip']))
1237
-					$values = array_diff($values, array($triggers['main_ip']));
1256
+				if (isset($triggers['main_ip'])) {
1257
+									$values = array_diff($values, array($triggers['main_ip']));
1258
+				}
1238 1259
 				unset($value);
1239 1260
 				foreach ($values as $val)
1240 1261
 				{
1241 1262
 					$val = trim($val);
1242 1263
 					$ip_parts = ip2range($val);
1243
-					if (!checkExistingTriggerIP($ip_parts, $val))
1244
-						$context['ban_erros'][] = 'invalid_ip';
1245
-					else
1264
+					if (!checkExistingTriggerIP($ip_parts, $val)) {
1265
+											$context['ban_erros'][] = 'invalid_ip';
1266
+					} else
1246 1267
 					{
1247 1268
 						$ban_triggers[$key][] = array(
1248 1269
 							'ip_low' => $ip_parts['low'],
@@ -1255,15 +1276,16 @@  discard block
 block discarded – undo
1255 1276
 						);
1256 1277
 					}
1257 1278
 				}
1279
+			} else {
1280
+							$context['ban_erros'][] = 'no_bantype_selected';
1258 1281
 			}
1259
-			else
1260
-				$context['ban_erros'][] = 'no_bantype_selected';
1261 1282
 
1262
-			if (isset($value) && !is_array($value))
1263
-				$log_info[] = array(
1283
+			if (isset($value) && !is_array($value)) {
1284
+							$log_info[] = array(
1264 1285
 					'value' => $value,
1265 1286
 					'bantype' => $key,
1266 1287
 				);
1288
+			}
1267 1289
 		}
1268 1290
 	}
1269 1291
 	return array('ban_triggers' => $ban_triggers, 'log_info' => $log_info);
@@ -1283,8 +1305,9 @@  discard block
 block discarded – undo
1283 1305
 {
1284 1306
 	global $smcFunc, $context;
1285 1307
 
1286
-	if (empty($group_id))
1287
-		$context['ban_errors'][] = 'ban_id_empty';
1308
+	if (empty($group_id)) {
1309
+			$context['ban_errors'][] = 'ban_id_empty';
1310
+	}
1288 1311
 
1289 1312
 	// Preset all values that are required.
1290 1313
 	$values = array(
@@ -1309,18 +1332,21 @@  discard block
 block discarded – undo
1309 1332
 	foreach ($triggers as $key => $trigger)
1310 1333
 	{
1311 1334
 		// Exceptions, exceptions, exceptions...always exceptions... :P
1312
-		if (in_array($key, array('ips_in_messages', 'ips_in_errors')))
1313
-			foreach ($trigger as $real_trigger)
1335
+		if (in_array($key, array('ips_in_messages', 'ips_in_errors'))) {
1336
+					foreach ($trigger as $real_trigger)
1314 1337
 				$insertTriggers[] = array_merge($values, $real_trigger);
1315
-		else
1316
-			$insertTriggers[] = array_merge($values, $trigger);
1338
+		} else {
1339
+					$insertTriggers[] = array_merge($values, $trigger);
1340
+		}
1317 1341
 	}
1318 1342
 
1319
-	if (empty($insertTriggers))
1320
-		$context['ban_errors'][] = 'ban_no_triggers';
1343
+	if (empty($insertTriggers)) {
1344
+			$context['ban_errors'][] = 'ban_no_triggers';
1345
+	}
1321 1346
 
1322
-	if (!empty($context['ban_errors']))
1323
-		return false;
1347
+	if (!empty($context['ban_errors'])) {
1348
+			return false;
1349
+	}
1324 1350
 
1325 1351
 	$smcFunc['db_insert']('',
1326 1352
 		'{db_prefix}ban_items',
@@ -1348,15 +1374,19 @@  discard block
 block discarded – undo
1348 1374
 {
1349 1375
 	global $smcFunc, $context;
1350 1376
 
1351
-	if (empty($ban_item))
1352
-		$context['ban_errors'][] = 'ban_ban_item_empty';
1353
-	if (empty($group_id))
1354
-		$context['ban_errors'][] = 'ban_id_empty';
1355
-	if (empty($trigger))
1356
-		$context['ban_errors'][] = 'ban_no_triggers';
1377
+	if (empty($ban_item)) {
1378
+			$context['ban_errors'][] = 'ban_ban_item_empty';
1379
+	}
1380
+	if (empty($group_id)) {
1381
+			$context['ban_errors'][] = 'ban_id_empty';
1382
+	}
1383
+	if (empty($trigger)) {
1384
+			$context['ban_errors'][] = 'ban_no_triggers';
1385
+	}
1357 1386
 
1358
-	if (!empty($context['ban_errors']))
1359
-		return;
1387
+	if (!empty($context['ban_errors'])) {
1388
+			return;
1389
+	}
1360 1390
 
1361 1391
 	// Preset all values that are required.
1362 1392
 	$values = array(
@@ -1397,8 +1427,9 @@  discard block
 block discarded – undo
1397 1427
  */
1398 1428
 function logTriggersUpdates($logs, $new = true, $removal = false)
1399 1429
 {
1400
-	if (empty($logs))
1401
-		return;
1430
+	if (empty($logs)) {
1431
+			return;
1432
+	}
1402 1433
 
1403 1434
 	$log_name_map = array(
1404 1435
 		'main_ip' => 'ip_range',
@@ -1409,14 +1440,15 @@  discard block
 block discarded – undo
1409 1440
 	);
1410 1441
 
1411 1442
 	// Log the addion of the ban entries into the moderation log.
1412
-	foreach ($logs as $log)
1413
-		logAction('ban' . ($removal == true ? 'remove' : ''), array(
1443
+	foreach ($logs as $log) {
1444
+			logAction('ban' . ($removal == true ? 'remove' : ''), array(
1414 1445
 			$log_name_map[$log['bantype']] => $log['value'],
1415 1446
 			'new' => empty($new) ? 0 : 1,
1416 1447
 			'remove' => empty($removal) ? 0 : 1,
1417 1448
 			'type' => $log['bantype'],
1418 1449
 		));
1419
-}
1450
+	}
1451
+	}
1420 1452
 
1421 1453
 /**
1422 1454
  * Updates an existing ban group
@@ -1430,12 +1462,15 @@  discard block
 block discarded – undo
1430 1462
 {
1431 1463
 	global $smcFunc, $context;
1432 1464
 
1433
-	if (empty($ban_info['name']))
1434
-		$context['ban_errors'][] = 'ban_name_empty';
1435
-	if (empty($ban_info['id']))
1436
-		$context['ban_errors'][] = 'ban_id_empty';
1437
-	if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login']))
1438
-		$context['ban_errors'][] = 'ban_unknown_restriction_type';
1465
+	if (empty($ban_info['name'])) {
1466
+			$context['ban_errors'][] = 'ban_name_empty';
1467
+	}
1468
+	if (empty($ban_info['id'])) {
1469
+			$context['ban_errors'][] = 'ban_id_empty';
1470
+	}
1471
+	if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) {
1472
+			$context['ban_errors'][] = 'ban_unknown_restriction_type';
1473
+	}
1439 1474
 
1440 1475
 	if (!empty($ban_info['id']))
1441 1476
 	{
@@ -1450,8 +1485,9 @@  discard block
 block discarded – undo
1450 1485
 			)
1451 1486
 		);
1452 1487
 
1453
-		if ($smcFunc['db_num_rows']($request) == 0)
1454
-			$context['ban_errors'][] = 'ban_not_found';
1488
+		if ($smcFunc['db_num_rows']($request) == 0) {
1489
+					$context['ban_errors'][] = 'ban_not_found';
1490
+		}
1455 1491
 		$smcFunc['db_free_result']($request);
1456 1492
 	}
1457 1493
 
@@ -1469,13 +1505,15 @@  discard block
 block discarded – undo
1469 1505
 				'new_ban_name' => $ban_info['name'],
1470 1506
 			)
1471 1507
 		);
1472
-		if ($smcFunc['db_num_rows']($request) != 0)
1473
-			$context['ban_errors'][] = 'ban_name_exists';
1508
+		if ($smcFunc['db_num_rows']($request) != 0) {
1509
+					$context['ban_errors'][] = 'ban_name_exists';
1510
+		}
1474 1511
 		$smcFunc['db_free_result']($request);
1475 1512
 	}
1476 1513
 
1477
-	if (!empty($context['ban_errors']))
1478
-		return $ban_info['id'];
1514
+	if (!empty($context['ban_errors'])) {
1515
+			return $ban_info['id'];
1516
+	}
1479 1517
 
1480 1518
 	$smcFunc['db_query']('', '
1481 1519
 		UPDATE {db_prefix}ban_groups
@@ -1519,10 +1557,12 @@  discard block
 block discarded – undo
1519 1557
 {
1520 1558
 	global $smcFunc, $context;
1521 1559
 
1522
-	if (empty($ban_info['name']))
1523
-		$context['ban_errors'][] = 'ban_name_empty';
1524
-	if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login']))
1525
-		$context['ban_errors'][] = 'ban_unknown_restriction_type';
1560
+	if (empty($ban_info['name'])) {
1561
+			$context['ban_errors'][] = 'ban_name_empty';
1562
+	}
1563
+	if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) {
1564
+			$context['ban_errors'][] = 'ban_unknown_restriction_type';
1565
+	}
1526 1566
 
1527 1567
 	if (!empty($ban_info['name']))
1528 1568
 	{
@@ -1537,13 +1577,15 @@  discard block
 block discarded – undo
1537 1577
 			)
1538 1578
 		);
1539 1579
 
1540
-		if ($smcFunc['db_num_rows']($request) == 1)
1541
-			$context['ban_errors'][] = 'ban_name_exists';
1580
+		if ($smcFunc['db_num_rows']($request) == 1) {
1581
+					$context['ban_errors'][] = 'ban_name_exists';
1582
+		}
1542 1583
 		$smcFunc['db_free_result']($request);
1543 1584
 	}
1544 1585
 
1545
-	if (!empty($context['ban_errors']))
1546
-		return;
1586
+	if (!empty($context['ban_errors'])) {
1587
+			return;
1588
+	}
1547 1589
 
1548 1590
 	// Yes yes, we're ready to add now.
1549 1591
 	$ban_info['id'] = $smcFunc['db_insert']('',
@@ -1560,8 +1602,9 @@  discard block
 block discarded – undo
1560 1602
 		1
1561 1603
 	);
1562 1604
 
1563
-	if (empty($ban_info['id']))
1564
-		$context['ban_errors'][] = 'impossible_insert_new_bangroup';
1605
+	if (empty($ban_info['id'])) {
1606
+			$context['ban_errors'][] = 'impossible_insert_new_bangroup';
1607
+	}
1565 1608
 
1566 1609
 	return $ban_info['id'];
1567 1610
 }
@@ -1586,24 +1629,24 @@  discard block
 block discarded – undo
1586 1629
 	$ban_group = isset($_REQUEST['bg']) ? (int) $_REQUEST['bg'] : 0;
1587 1630
 	$ban_id = isset($_REQUEST['bi']) ? (int) $_REQUEST['bi'] : 0;
1588 1631
 
1589
-	if (empty($ban_group))
1590
-		fatal_lang_error('ban_not_found', false);
1632
+	if (empty($ban_group)) {
1633
+			fatal_lang_error('ban_not_found', false);
1634
+	}
1591 1635
 
1592 1636
 	if (isset($_POST['add_new_trigger']) && !empty($_POST['ban_suggestions']))
1593 1637
 	{
1594 1638
 		saveTriggers($_POST['ban_suggestions'], $ban_group, 0, $ban_id);
1595 1639
 		redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : ''));
1596
-	}
1597
-	elseif (isset($_POST['edit_trigger']) && !empty($_POST['ban_suggestions']))
1640
+	} elseif (isset($_POST['edit_trigger']) && !empty($_POST['ban_suggestions']))
1598 1641
 	{
1599 1642
 		// The first replaces the old one, the others are added new (simplification, otherwise it would require another query and some work...)
1600 1643
 		saveTriggers(array_shift($_POST['ban_suggestions']), $ban_group, 0, $ban_id);
1601
-		if (!empty($_POST['ban_suggestions']))
1602
-			saveTriggers($_POST['ban_suggestions'], $ban_group);
1644
+		if (!empty($_POST['ban_suggestions'])) {
1645
+					saveTriggers($_POST['ban_suggestions'], $ban_group);
1646
+		}
1603 1647
 
1604 1648
 		redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : ''));
1605
-	}
1606
-	elseif (isset($_POST['edit_trigger']))
1649
+	} elseif (isset($_POST['edit_trigger']))
1607 1650
 	{
1608 1651
 		removeBanTriggers($ban_id);
1609 1652
 		redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : ''));
@@ -1634,8 +1677,7 @@  discard block
 block discarded – undo
1634 1677
 			),
1635 1678
 			'is_new' => true,
1636 1679
 		);
1637
-	}
1638
-	else
1680
+	} else
1639 1681
 	{
1640 1682
 		$request = $smcFunc['db_query']('', '
1641 1683
 			SELECT
@@ -1652,8 +1694,9 @@  discard block
 block discarded – undo
1652 1694
 				'ban_group' => $ban_group,
1653 1695
 			)
1654 1696
 		);
1655
-		if ($smcFunc['db_num_rows']($request) == 0)
1656
-			fatal_lang_error('ban_not_found', false);
1697
+		if ($smcFunc['db_num_rows']($request) == 0) {
1698
+					fatal_lang_error('ban_not_found', false);
1699
+		}
1657 1700
 		$row = $smcFunc['db_fetch_assoc']($request);
1658 1701
 		$smcFunc['db_free_result']($request);
1659 1702
 
@@ -1702,8 +1745,9 @@  discard block
 block discarded – undo
1702 1745
 		removeBanTriggers($_POST['remove']);
1703 1746
 
1704 1747
 		// Rehabilitate some members.
1705
-		if ($_REQUEST['entity'] == 'member')
1706
-			updateBanMembers();
1748
+		if ($_REQUEST['entity'] == 'member') {
1749
+					updateBanMembers();
1750
+		}
1707 1751
 
1708 1752
 		// Make sure the ban cache is refreshed.
1709 1753
 		updateSettings(array('banLastUpdated' => time()));
@@ -1816,8 +1860,7 @@  discard block
 block discarded – undo
1816 1860
 			'default' => 'bi.ip_low, bi.ip_high, bi.ip_low',
1817 1861
 			'reverse' => 'bi.ip_low DESC, bi.ip_high DESC',
1818 1862
 		);
1819
-	}
1820
-	elseif ($context['selected_entity'] === 'hostname')
1863
+	} elseif ($context['selected_entity'] === 'hostname')
1821 1864
 	{
1822 1865
 		$listOptions['columns']['banned_entity']['data'] = array(
1823 1866
 			'function' => function($rowData) use ($smcFunc)
@@ -1829,8 +1872,7 @@  discard block
 block discarded – undo
1829 1872
 			'default' => 'bi.hostname',
1830 1873
 			'reverse' => 'bi.hostname DESC',
1831 1874
 		);
1832
-	}
1833
-	elseif ($context['selected_entity'] === 'email')
1875
+	} elseif ($context['selected_entity'] === 'email')
1834 1876
 	{
1835 1877
 		$listOptions['columns']['banned_entity']['data'] = array(
1836 1878
 			'function' => function($rowData) use ($smcFunc)
@@ -1842,8 +1884,7 @@  discard block
 block discarded – undo
1842 1884
 			'default' => 'bi.email_address',
1843 1885
 			'reverse' => 'bi.email_address DESC',
1844 1886
 		);
1845
-	}
1846
-	elseif ($context['selected_entity'] === 'member')
1887
+	} elseif ($context['selected_entity'] === 'member')
1847 1888
 	{
1848 1889
 		$listOptions['columns']['banned_entity']['data'] = array(
1849 1890
 			'sprintf' => array(
@@ -1907,8 +1948,9 @@  discard block
 block discarded – undo
1907 1948
 		)
1908 1949
 	);
1909 1950
 	$ban_triggers = array();
1910
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1911
-		$ban_triggers[] = $row;
1951
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1952
+			$ban_triggers[] = $row;
1953
+	}
1912 1954
 	$smcFunc['db_free_result']($request);
1913 1955
 
1914 1956
 	return $ban_triggers;
@@ -1964,8 +2006,9 @@  discard block
 block discarded – undo
1964 2006
 		validateToken('admin-bl');
1965 2007
 
1966 2008
 		// 'Delete all entries' button was pressed.
1967
-		if (!empty($_POST['removeAll']))
1968
-			removeBanLogs();
2009
+		if (!empty($_POST['removeAll'])) {
2010
+					removeBanLogs();
2011
+		}
1969 2012
 		// 'Delete selection' button was pressed.
1970 2013
 		else
1971 2014
 		{
@@ -2174,12 +2217,15 @@  discard block
 block discarded – undo
2174 2217
 	$low = inet_dtop($low);
2175 2218
 	$high = inet_dtop($high);
2176 2219
 
2177
-	if ($low == '255.255.255.255') return 'unknown';
2178
-	if ($low == $high)
2179
-	    return $low;
2180
-	else
2181
-	    return $low . '-' . $high;
2182
-}
2220
+	if ($low == '255.255.255.255') {
2221
+		return 'unknown';
2222
+	}
2223
+	if ($low == $high) {
2224
+		    return $low;
2225
+	} else {
2226
+		    return $low . '-' . $high;
2227
+	}
2228
+	}
2183 2229
 
2184 2230
 /**
2185 2231
  * Checks whether a given IP range already exists in the trigger list.
@@ -2255,15 +2301,17 @@  discard block
 block discarded – undo
2255 2301
 	$memberEmailWild = array();
2256 2302
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2257 2303
 	{
2258
-		if ($row['id_member'])
2259
-			$memberIDs[$row['id_member']] = $row['id_member'];
2304
+		if ($row['id_member']) {
2305
+					$memberIDs[$row['id_member']] = $row['id_member'];
2306
+		}
2260 2307
 		if ($row['email_address'])
2261 2308
 		{
2262 2309
 			// Does it have a wildcard - if so we can't do a IN on it.
2263
-			if (strpos($row['email_address'], '%') !== false)
2264
-				$memberEmailWild[$row['email_address']] = $row['email_address'];
2265
-			else
2266
-				$memberEmails[$row['email_address']] = $row['email_address'];
2310
+			if (strpos($row['email_address'], '%') !== false) {
2311
+							$memberEmailWild[$row['email_address']] = $row['email_address'];
2312
+			} else {
2313
+							$memberEmails[$row['email_address']] = $row['email_address'];
2314
+			}
2267 2315
 		}
2268 2316
 	}
2269 2317
 	$smcFunc['db_free_result']($request);
@@ -2314,14 +2362,15 @@  discard block
 block discarded – undo
2314 2362
 	}
2315 2363
 
2316 2364
 	// We welcome our new members in the realm of the banned.
2317
-	if (!empty($newMembers))
2318
-		$smcFunc['db_query']('', '
2365
+	if (!empty($newMembers)) {
2366
+			$smcFunc['db_query']('', '
2319 2367
 			DELETE FROM {db_prefix}log_online
2320 2368
 			WHERE id_member IN ({array_int:new_banned_members})',
2321 2369
 			array(
2322 2370
 				'new_banned_members' => $newMembers,
2323 2371
 			)
2324 2372
 		);
2373
+	}
2325 2374
 
2326 2375
 	// Find members that are wrongfully marked as banned.
2327 2376
 	$request = $smcFunc['db_query']('', '
@@ -2348,9 +2397,10 @@  discard block
 block discarded – undo
2348 2397
 	}
2349 2398
 	$smcFunc['db_free_result']($request);
2350 2399
 
2351
-	if (!empty($updates))
2352
-		foreach ($updates as $newStatus => $members)
2400
+	if (!empty($updates)) {
2401
+			foreach ($updates as $newStatus => $members)
2353 2402
 			updateMemberData($members, array('is_activated' => $newStatus));
2403
+	}
2354 2404
 
2355 2405
 	// Update the latest member and our total members as banning may change them.
2356 2406
 	updateStats('member');
Please login to merge, or discard this patch.
Themes/default/ReportedContent.template.php 1 patch
Braces   +66 added lines, -44 removed lines patch added patch discarded remove patch
@@ -18,11 +18,12 @@  discard block
 block discarded – undo
18 18
 	global $context, $txt, $scripturl;
19 19
 
20 20
 	// Let them know the action was a success.
21
-	if (!empty($context['report_post_action']))
22
-		echo '
21
+	if (!empty($context['report_post_action'])) {
22
+			echo '
23 23
 	<div class="infobox">
24 24
 		', $txt['report_action_' . $context['report_post_action']], '
25 25
 	</div>';
26
+	}
26 27
 
27 28
 	echo '
28 29
 	<form id="reported_posts" action="', $scripturl, '?action=moderate;area=reportedposts;sa=show', $context['view_closed'] ? ';closed' : '', ';start=', $context['start'], '" method="post" accept-charset="', $context['character_set'], '">
@@ -52,8 +53,9 @@  discard block
 block discarded – undo
52 53
 
53 54
 		// Prepare the comments...
54 55
 		$comments = array();
55
-		foreach ($report['comments'] as $comment)
56
-			$comments[$comment['member']['id']] = $comment['member']['link'];
56
+		foreach ($report['comments'] as $comment) {
57
+					$comments[$comment['member']['id']] = $comment['member']['link'];
58
+		}
57 59
 
58 60
 		echo '
59 61
 				', $txt['mc_reportedp_reported_by'], ': ', implode(', ', $comments), '
@@ -69,18 +71,21 @@  discard block
 block discarded – undo
69 71
 				<li><a href="', $scripturl, '?action=moderate;area=reportedposts;sa=handle;closed=', (int) !$report['closed'], ';rid=', $report['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['mod-report-closed_token_var'], '=', $context['mod-report-closed_token'], '">', $close_button, '</a></li>';
70 72
 
71 73
 		// Delete message button.
72
-		if (!$report['closed'] && (is_array($context['report_remove_any_boards']) && in_array($report['topic']['id_board'], $context['report_remove_any_boards'])))
73
-			echo '
74
+		if (!$report['closed'] && (is_array($context['report_remove_any_boards']) && in_array($report['topic']['id_board'], $context['report_remove_any_boards']))) {
75
+					echo '
74 76
 				<li><a href="', $scripturl, '?action=deletemsg;topic=', $report['topic']['id'], '.0;msg=', $report['topic']['id_msg'], ';modcenter;', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['mc_reportedp_delete_confirm'], '" class="you_sure">', $delete_button, '</a></li>';
77
+		}
75 78
 
76 79
 		// Ban this user button.
77
-		if (!$report['closed'] && !empty($context['report_manage_bans']))
78
-			echo '
80
+		if (!$report['closed'] && !empty($context['report_manage_bans'])) {
81
+					echo '
79 82
 				<li><a href="', $scripturl, '?action=admin;area=ban;sa=add', (!empty($report['author']['id']) ? ';u=' . $report['author']['id'] : ';msg=' . $report['topic']['id_msg']), ';', $context['session_var'], '=', $context['session_id'], '">', $ban_button, '</a></li>';
83
+		}
80 84
 
81
-		if (!$context['view_closed'])
82
-			echo '
85
+		if (!$context['view_closed']) {
86
+					echo '
83 87
 				<li><input type="checkbox" name="close[]" value="' . $report['id'] . '"></li>';
88
+		}
84 89
 
85 90
 		echo '
86 91
 			</ul>
@@ -88,18 +93,20 @@  discard block
 block discarded – undo
88 93
 	}
89 94
 
90 95
 	// Were none found?
91
-	if (empty($context['reports']))
92
-		echo '
96
+	if (empty($context['reports'])) {
97
+			echo '
93 98
 		<div class="windowbg">
94 99
 			<p class="centertext">', $txt['mc_reportedp_none_found'], '</p>
95 100
 		</div>';
101
+	}
96 102
 
97 103
 	echo '
98 104
 		<div class="pagesection">';
99 105
 
100
-	if (!empty($context['total_reports']) && $context['total_reports'] >= $context['reports_how_many'])
101
-		echo '
106
+	if (!empty($context['total_reports']) && $context['total_reports'] >= $context['reports_how_many']) {
107
+			echo '
102 108
 			<div class="pagelinks floatleft">' . $context['page_index'] . '</div>';
109
+	}
103 110
 
104 111
 	echo '
105 112
 			<div class="floatright">', !$context['view_closed'] ? '
@@ -130,18 +137,20 @@  discard block
 block discarded – undo
130 137
 			<div class="modbox">
131 138
 				<ul>';
132 139
 
133
-	foreach ($context['reported_posts'] as $report)
134
-		echo '
140
+	foreach ($context['reported_posts'] as $report) {
141
+			echo '
135 142
 					<li class="smalltext">
136 143
 						<a href="', $report['report_href'], '">', $report['subject'], '</a> ', $txt['mc_reportedp_by'], ' ', $report['author']['link'], '
137 144
 					</li>';
145
+	}
138 146
 
139 147
 	// Don't have any watched users right now?
140
-	if (empty($context['reported_posts']))
141
-		echo '
148
+	if (empty($context['reported_posts'])) {
149
+			echo '
142 150
 					<li>
143 151
 						<strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong>
144 152
 					</li>';
153
+	}
145 154
 
146 155
 	echo '
147 156
 				</ul>
@@ -189,11 +198,12 @@  discard block
 block discarded – undo
189 198
 	global $context, $scripturl, $txt;
190 199
 
191 200
 	// Let them know the action was a success.
192
-	if (!empty($context['report_post_action']))
193
-		echo '
201
+	if (!empty($context['report_post_action'])) {
202
+			echo '
194 203
 	<div class="infobox">
195 204
 		', $txt['report_action_' . $context['report_post_action']], '
196 205
 	</div>';
206
+	}
197 207
 
198 208
 	echo '
199 209
 	<div id="modcenter">
@@ -229,14 +239,15 @@  discard block
 block discarded – undo
229 239
 				<h3 class="catbg">', $txt['mc_modreport_whoreported_title'], '</h3>
230 240
 			</div>';
231 241
 
232
-	foreach ($context['report']['comments'] as $comment)
233
-		echo '
242
+	foreach ($context['report']['comments'] as $comment) {
243
+			echo '
234 244
 			<div class="windowbg">
235 245
 				<p class="smalltext">
236 246
 					', sprintf($txt['mc_modreport_whoreported_data'], $comment['member']['link'] . (empty($comment['member']['id']) && !empty($comment['member']['ip']) ? ' (' . $comment['member']['ip'] . ')' : ''), $comment['time']), '
237 247
 				</p>
238 248
 				<p>', $comment['message'], '</p>
239 249
 			</div>';
250
+	}
240 251
 
241 252
 	echo '
242 253
 			<br>
@@ -245,11 +256,12 @@  discard block
 block discarded – undo
245 256
 			</div>
246 257
 			<div>';
247 258
 
248
-	if (empty($context['report']['mod_comments']))
249
-		echo '
259
+	if (empty($context['report']['mod_comments'])) {
260
+			echo '
250 261
 				<div class="information">
251 262
 					<p class="centertext">', $txt['mc_modreport_no_mod_comment'], '</p>
252 263
 				</div>';
264
+	}
253 265
 
254 266
 	foreach ($context['report']['mod_comments'] as $comment)
255 267
 	{
@@ -335,18 +347,20 @@  discard block
 block discarded – undo
335 347
 			<div class="modbox">
336 348
 				<ul>';
337 349
 
338
-	foreach ($context['reported_members'] as $report)
339
-		echo '
350
+	foreach ($context['reported_members'] as $report) {
351
+			echo '
340 352
 					<li class="smalltext">
341 353
 						<a href="', $report['report_href'], '">', $report['user_name'], '</a>
342 354
 					</li>';
355
+	}
343 356
 
344 357
 	// Don't have any reported members right now?
345
-	if (empty($context['reported_members']))
346
-		echo '
358
+	if (empty($context['reported_members'])) {
359
+			echo '
347 360
 					<li>
348 361
 						<strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong>
349 362
 					</li>';
363
+	}
350 364
 
351 365
 	echo '
352 366
 				</ul>
@@ -394,11 +408,12 @@  discard block
 block discarded – undo
394 408
 	global $context, $txt, $scripturl;
395 409
 
396 410
 	// Let them know the action was a success.
397
-	if (!empty($context['report_post_action']) && !empty($txt['report_action_' . $context['report_post_action']]))
398
-		echo '
411
+	if (!empty($context['report_post_action']) && !empty($txt['report_action_' . $context['report_post_action']])) {
412
+			echo '
399 413
 	<div class="infobox">
400 414
 		', $txt['report_action_' . $context['report_post_action']], '
401 415
 	</div>';
416
+	}
402 417
 
403 418
 	echo '
404 419
 	<form id="reported_members" action="', $scripturl, '?action=moderate;area=reportedmembers;sa=show', $context['view_closed'] ? ';closed' : '', ';start=', $context['start'], '" method="post" accept-charset="', $context['character_set'], '">
@@ -430,8 +445,9 @@  discard block
 block discarded – undo
430 445
 
431 446
 		// Prepare the comments...
432 447
 		$comments = array();
433
-		foreach ($report['comments'] as $comment)
434
-			$comments[$comment['member']['id']] = $comment['member']['link'];
448
+		foreach ($report['comments'] as $comment) {
449
+					$comments[$comment['member']['id']] = $comment['member']['link'];
450
+		}
435 451
 
436 452
 		echo '
437 453
 				', $txt['mc_reportedp_reported_by'], ': ', implode(', ', $comments), '
@@ -443,13 +459,15 @@  discard block
 block discarded – undo
443 459
 				<li><a href="', $scripturl, '?action=moderate;area=reportedmembers;sa=handle;closed=', (int) !$report['closed'], ';rid=', $report['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['mod-report-closed_token_var'], '=', $context['mod-report-closed_token'], '">', $close_button, '</a></li>';
444 460
 
445 461
 		// Ban this user button.
446
-		if (!$report['closed'] && !empty($context['report_manage_bans']) && !empty($report['user']['id']))
447
-			echo '
462
+		if (!$report['closed'] && !empty($context['report_manage_bans']) && !empty($report['user']['id'])) {
463
+					echo '
448 464
 				<li><a href="', $scripturl, '?action=admin;area=ban;sa=add;u=', $report['user']['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $ban_button, '</a></li>';
465
+		}
449 466
 
450
-		if (!$context['view_closed'])
451
-			echo '
467
+		if (!$context['view_closed']) {
468
+					echo '
452 469
 				<li><input type="checkbox" name="close[]" value="' . $report['id'] . '"></li>';
470
+		}
453 471
 
454 472
 			echo '
455 473
 			</ul>
@@ -457,11 +475,12 @@  discard block
 block discarded – undo
457 475
 	}
458 476
 
459 477
 	// Were none found?
460
-	if (empty($context['reports']))
461
-		echo '
478
+	if (empty($context['reports'])) {
479
+			echo '
462 480
 		<div class="windowbg">
463 481
 			<p class="centertext">', $txt['mc_reportedp_none_found'], '</p>
464 482
 		</div>';
483
+	}
465 484
 
466 485
 	echo '
467 486
 		<div class="pagesection">
@@ -482,11 +501,12 @@  discard block
 block discarded – undo
482 501
 	global $context, $scripturl, $txt;
483 502
 
484 503
 	// Let them know the action was a success.
485
-	if (!empty($context['report_post_action']))
486
-		echo '
504
+	if (!empty($context['report_post_action'])) {
505
+			echo '
487 506
 	<div class="infobox">
488 507
 		', $txt['report_action_' . $context['report_post_action']], '
489 508
 	</div>';
509
+	}
490 510
 
491 511
 	echo '
492 512
 	<div id="modcenter">
@@ -519,14 +539,15 @@  discard block
 block discarded – undo
519 539
 				<h3 class="catbg">', $txt['mc_memberreport_whoreported_title'], '</h3>
520 540
 			</div>';
521 541
 
522
-	foreach ($context['report']['comments'] as $comment)
523
-		echo '
542
+	foreach ($context['report']['comments'] as $comment) {
543
+			echo '
524 544
 			<div class="windowbg">
525 545
 				<p class="smalltext">
526 546
 					', sprintf($txt['mc_modreport_whoreported_data'], $comment['member']['link'] . (empty($comment['member']['id']) && !empty($comment['member']['ip']) ? ' (' . $comment['member']['ip'] . ')' : ''), $comment['time']), '
527 547
 				</p>
528 548
 				<p>', $comment['message'], '</p>
529 549
 			</div>';
550
+	}
530 551
 
531 552
 	echo '
532 553
 			<br>
@@ -535,11 +556,12 @@  discard block
 block discarded – undo
535 556
 			</div>
536 557
 			<div>';
537 558
 
538
-	if (empty($context['report']['mod_comments']))
539
-		echo '
559
+	if (empty($context['report']['mod_comments'])) {
560
+			echo '
540 561
 				<div class="information">
541 562
 					<p class="centertext">', $txt['mc_modreport_no_mod_comment'], '</p>
542 563
 				</div>';
564
+	}
543 565
 
544 566
 	foreach ($context['report']['mod_comments'] as $comment)
545 567
 	{
Please login to merge, or discard this patch.
Themes/default/ManageCalendar.template.php 1 patch
Braces   +14 added lines, -10 removed lines patch added patch discarded remove patch
@@ -40,9 +40,10 @@  discard block
 block discarded – undo
40 40
 							<option value="0000"', $context['holiday']['year'] == '0000' ? ' selected' : '', '>', $txt['every_year'], '</option>';
41 41
 
42 42
 	// Show a list of all the years we allow...
43
-	for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++)
44
-		echo '
43
+	for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++) {
44
+			echo '
45 45
 							<option value="', $year, '"', $year == $context['holiday']['year'] ? ' selected' : '', '>', $year, '</option>';
46
+	}
46 47
 
47 48
 	echo '
48 49
 						</select>
@@ -50,9 +51,10 @@  discard block
 block discarded – undo
50 51
 						<select name="month" id="month" onchange="generateDays();">';
51 52
 
52 53
 	// There are 12 months per year - ensure that they all get listed.
53
-	for ($month = 1; $month <= 12; $month++)
54
-		echo '
54
+	for ($month = 1; $month <= 12; $month++) {
55
+			echo '
55 56
 							<option value="', $month, '"', $month == $context['holiday']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>';
57
+	}
56 58
 
57 59
 	echo '
58 60
 						</select>
@@ -60,23 +62,25 @@  discard block
 block discarded – undo
60 62
 						<select name="day" id="day" onchange="generateDays();">';
61 63
 
62 64
 	// This prints out all the days in the current month - this changes dynamically as we switch months.
63
-	for ($day = 1; $day <= $context['holiday']['last_day']; $day++)
64
-		echo '
65
+	for ($day = 1; $day <= $context['holiday']['last_day']; $day++) {
66
+			echo '
65 67
 							<option value="', $day, '"', $day == $context['holiday']['day'] ? ' selected' : '', '>', $day, '</option>';
68
+	}
66 69
 
67 70
 	echo '
68 71
 						</select>
69 72
 					</dd>
70 73
 				</dl>';
71 74
 
72
-	if ($context['is_new'])
73
-		echo '
75
+	if ($context['is_new']) {
76
+			echo '
74 77
 				<input type="submit" value="', $txt['holidays_button_add'], '" class="button">';
75
-	else
76
-		echo '
78
+	} else {
79
+			echo '
77 80
 				<input type="submit" name="edit" value="', $txt['holidays_button_edit'], '" class="button">
78 81
 				<input type="submit" name="delete" value="', $txt['holidays_button_remove'], '" class="button">
79 82
 				<input type="hidden" name="holiday" value="', $context['holiday']['id'], '">';
83
+	}
80 84
 	echo '
81 85
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
82 86
 			</div><!-- .windowbg -->
Please login to merge, or discard this patch.
Themes/default/MoveTopic.template.php 1 patch
Braces   +32 added lines, -23 removed lines patch added patch discarded remove patch
@@ -37,9 +37,10 @@  discard block
 block discarded – undo
37 37
 		echo '
38 38
 								<optgroup label="', $category['name'], '">';
39 39
 
40
-		foreach ($category['boards'] as $board)
41
-			echo '
40
+		foreach ($category['boards'] as $board) {
41
+					echo '
42 42
 									<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', $board['id'] == $context['current_board'] ? ' disabled' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level']-1) . '=&gt; ' : '', $board['name'], '</option>';
43
+		}
43 44
 		echo '
44 45
 								</optgroup>';
45 46
 	}
@@ -70,9 +71,10 @@  discard block
 block discarded – undo
70 71
 				</div><!-- .move_topic -->
71 72
 			</div><!-- .windowbg -->';
72 73
 
73
-	if ($context['back_to_topic'])
74
-		echo '
74
+	if ($context['back_to_topic']) {
75
+			echo '
75 76
 			<input type="hidden" name="goback" value="1">';
77
+	}
76 78
 
77 79
 	echo '
78 80
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -125,10 +127,10 @@  discard block
 block discarded – undo
125 127
 									<option value="86400">', $txt['two_months'], '</option>
126 128
 								</select>
127 129
 							</dd>';
128
-	}
129
-	else
130
-		echo '
130
+	} else {
131
+			echo '
131 132
 							<input type="hidden" name="redirect_expires" value="0">';
133
+	}
132 134
 
133 135
 	echo '
134 136
 						</dl>
@@ -207,9 +209,10 @@  discard block
 block discarded – undo
207 209
 			echo '
208 210
 							<optgroup label="', $cat['name'], '">';
209 211
 
210
-			foreach ($cat['boards'] as $board)
211
-				echo '
212
+			foreach ($cat['boards'] as $board) {
213
+							echo '
212 214
 								<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
215
+			}
213 216
 
214 217
 			echo '
215 218
 							</optgroup>';
@@ -219,9 +222,9 @@  discard block
 block discarded – undo
219 222
 						<input type="hidden" name="from" value="' . $context['origin_topic'] . '">
220 223
 						<input type="submit" value="', $txt['go'], '" class="button">
221 224
 					</form>';
225
+	} else {
226
+			echo $txt['target_below'];
222 227
 	}
223
-	else
224
-		echo $txt['target_below'];
225 228
 
226 229
 	echo '		</h4>
227 230
 			</div><!-- .title_bar -->
@@ -239,12 +242,13 @@  discard block
 block discarded – undo
239 242
 
240 243
 		$merge_button = create_button('merge', 'merge', '');
241 244
 
242
-		foreach ($context['topics'] as $topic)
243
-			echo '
245
+		foreach ($context['topics'] as $topic) {
246
+					echo '
244 247
 						<li>
245 248
 							<a href="', $scripturl, '?action=mergetopics;sa=options;board=', $context['current_board'], '.0;from=', $context['origin_topic'], ';to=', $topic['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $merge_button, '</a>
246 249
 							<a href="', $scripturl, '?topic=', $topic['id'], '.0" target="_blank" rel="noopener">', $topic['subject'], '</a> ', $txt['started_by'], ' ', $topic['poster']['link'], '
247 250
 						</li>';
251
+		}
248 252
 
249 253
 		echo '
250 254
 					</ul>
@@ -255,9 +259,10 @@  discard block
 block discarded – undo
255 259
 				</div>';
256 260
 	}
257 261
 	// Just a nice "There aren't any topics" message
258
-	else
259
-		echo '
262
+	else {
263
+			echo '
260 264
 				<div class="windowbg">', $txt['topic_alert_none'], '</div>';
265
+	}
261 266
 
262 267
 	echo '
263 268
 				<br>
@@ -307,8 +312,8 @@  discard block
 block discarded – undo
307 312
 				</thead>
308 313
 				<tbody>';
309 314
 
310
-	foreach ($context['topics'] as $topic)
311
-		echo '
315
+	foreach ($context['topics'] as $topic) {
316
+			echo '
312 317
 					<tr class="windowbg">
313 318
 						<td>
314 319
 							<input type="checkbox" name="topics[]" value="' . $topic['id'] . '" checked>
@@ -328,6 +333,7 @@  discard block
 block discarded – undo
328 333
 							<input type="checkbox" name="notifications[]" value="' . $topic['id'] . '" checked>
329 334
 						</td>
330 335
 					</tr>';
336
+	}
331 337
 	echo '
332 338
 				</tbody>
333 339
 			</table>
@@ -337,9 +343,10 @@  discard block
 block discarded – undo
337 343
 					<legend>', $txt['merge_select_subject'], '</legend>
338 344
 					<select name="subject" onchange="this.form.custom_subject.style.display = (this.options[this.selectedIndex].value != 0) ? \'none\': \'\' ;">';
339 345
 
340
-	foreach ($context['topics'] as $topic)
341
-		echo '
346
+	foreach ($context['topics'] as $topic) {
347
+			echo '
342 348
 						<option value="', $topic['id'], '"' . ($topic['selected'] ? ' selected' : '') . '>', $topic['subject'], '</option>';
349
+	}
343 350
 	echo '
344 351
 						<option value="0">', $txt['merge_custom_subject'], ':</option>
345 352
 					</select>
@@ -358,11 +365,12 @@  discard block
 block discarded – undo
358 365
 					<legend>', $txt['merge_select_target_board'], '</legend>
359 366
 					<ul>';
360 367
 
361
-		foreach ($context['boards'] as $board)
362
-			echo '
368
+		foreach ($context['boards'] as $board) {
369
+					echo '
363 370
 						<li>
364 371
 							<input type="radio" name="board" value="' . $board['id'] . '"' . ($board['selected'] ? ' checked' : '') . '> ' . $board['name'] . '
365 372
 						</li>';
373
+		}
366 374
 		echo '
367 375
 					</ul>
368 376
 				</fieldset>';
@@ -374,11 +382,12 @@  discard block
 block discarded – undo
374 382
 					<legend>' . $txt['merge_select_poll'] . '</legend>
375 383
 					<ul>';
376 384
 
377
-		foreach ($context['polls'] as $poll)
378
-			echo '
385
+		foreach ($context['polls'] as $poll) {
386
+					echo '
379 387
 						<li>
380 388
 							<input type="radio" name="poll" value="' . $poll['id'] . '"' . ($poll['selected'] ? ' checked' : '') . '> ' . $poll['question'] . ' (' . $txt['topic'] . ': <a href="' . $scripturl . '?topic=' . $poll['topic']['id'] . '.0" target="_blank" rel="noopener">' . $poll['topic']['subject'] . '</a>)
381 389
 						</li>';
390
+		}
382 391
 		echo '
383 392
 						<li>
384 393
 							<input type="radio" name="poll" value="-1"> (' . $txt['merge_no_poll'] . ')
Please login to merge, or discard this patch.
Themes/default/Calendar.template.php 1 patch
Braces   +222 added lines, -162 removed lines patch added patch discarded remove patch
@@ -22,30 +22,32 @@  discard block
 block discarded – undo
22 22
 		<div id="calendar">';
23 23
 
24 24
 	// Show the mini-blocks if they're enabled.
25
-	if (empty($context['blocks_disabled']))
26
-		echo '
25
+	if (empty($context['blocks_disabled'])) {
26
+			echo '
27 27
 			<div id="month_grid">
28 28
 				', template_show_month_grid('prev', true), '
29 29
 				', template_show_month_grid('current', true), '
30 30
 				', template_show_month_grid('next', true), '
31 31
 			</div>';
32
+	}
32 33
 
33 34
 	// What view are we showing?
34
-	if ($context['calendar_view'] == 'viewlist')
35
-		echo '
35
+	if ($context['calendar_view'] == 'viewlist') {
36
+			echo '
36 37
 			<div id="main_grid">
37 38
 				', template_show_upcoming_list('main'), '
38 39
 			</div>';
39
-	elseif ($context['calendar_view'] == 'viewweek')
40
-		echo '
40
+	} elseif ($context['calendar_view'] == 'viewweek') {
41
+			echo '
41 42
 			<div id="main_grid">
42 43
 				', template_show_week_grid('main'), '
43 44
 			</div>';
44
-	else
45
-		echo '
45
+	} else {
46
+			echo '
46 47
 			<div id="main_grid">
47 48
 				', template_show_month_grid('main'), '
48 49
 			</div>';
50
+	}
49 51
 
50 52
 	// Close our wrapper.
51 53
 	echo '
@@ -64,20 +66,22 @@  discard block
 block discarded – undo
64 66
 	global $context, $scripturl, $txt;
65 67
 
66 68
 	// Bail out if we have nothing to work with
67
-	if (!isset($context['calendar_grid_' . $grid_name]))
68
-		return false;
69
+	if (!isset($context['calendar_grid_' . $grid_name])) {
70
+			return false;
71
+	}
69 72
 
70 73
 	// Protect programmer sanity
71 74
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
72 75
 
73 76
 	// Do we want a title?
74
-	if (empty($calendar_data['disable_title']))
75
-		echo '
77
+	if (empty($calendar_data['disable_title'])) {
78
+			echo '
76 79
 			<div class="cat_bar">
77 80
 				<h3 class="catbg centertext largetext">
78 81
 					<a href="', $scripturl, '?action=calendar;viewlist;year=', $calendar_data['start_year'], ';month=', $calendar_data['start_month'], ';day=', $calendar_data['start_day'], '">', $txt['calendar_upcoming'], '</a>
79 82
 				</h3>
80 83
 			</div>';
84
+	}
81 85
 
82 86
 	// Give the user some controls to work with
83 87
 	template_calendar_top($calendar_data);
@@ -100,11 +104,13 @@  discard block
 block discarded – undo
100 104
 					<li class="windowbg">
101 105
 						<strong class="event_title">', $event['link'], '</strong>';
102 106
 
103
-				if ($event['can_edit'])
104
-					echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
107
+				if ($event['can_edit']) {
108
+									echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
109
+				}
105 110
 
106
-				if ($event['can_export'])
107
-					echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
111
+				if ($event['can_export']) {
112
+									echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
113
+				}
108 114
 
109 115
 				echo '
110 116
 						<br>';
@@ -112,14 +118,14 @@  discard block
 block discarded – undo
112 118
 				if (!empty($event['allday']))
113 119
 				{
114 120
 					echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : '';
115
-				}
116
-				else
121
+				} else
117 122
 				{
118 123
 					// Display event info relative to user's local timezone
119 124
 					echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
120 125
 
121
-					if ($event['start_date_local'] != $event['end_date_local'])
122
-						echo trim($event['end_date_local']) . ', ';
126
+					if ($event['start_date_local'] != $event['end_date_local']) {
127
+											echo trim($event['end_date_local']) . ', ';
128
+					}
123 129
 
124 130
 					echo trim($event['end_time_local']);
125 131
 
@@ -128,23 +134,27 @@  discard block
 block discarded – undo
128 134
 					{
129 135
 						echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">';
130 136
 
131
-						if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig'])
132
-							echo trim($event['start_date_orig']), ', ';
137
+						if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) {
138
+													echo trim($event['start_date_orig']), ', ';
139
+						}
133 140
 
134 141
 						echo trim($event['start_time_orig']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
135 142
 
136
-						if ($event['start_date_orig'] != $event['end_date_orig'])
137
-							echo trim($event['end_date_orig']) . ', ';
143
+						if ($event['start_date_orig'] != $event['end_date_orig']) {
144
+													echo trim($event['end_date_orig']) . ', ';
145
+						}
138 146
 
139 147
 						echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)';
140 148
 					}
141 149
 					// Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion
142
-					else
143
-						echo ' ', $event['tz_abbrev'], '</time>';
150
+					else {
151
+											echo ' ', $event['tz_abbrev'], '</time>';
152
+					}
144 153
 				}
145 154
 
146
-				if (!empty($event['location']))
147
-					echo '<br>', $event['location'];
155
+				if (!empty($event['location'])) {
156
+									echo '<br>', $event['location'];
157
+				}
148 158
 
149 159
 				echo '
150 160
 					</li>';
@@ -176,8 +186,9 @@  discard block
 block discarded – undo
176 186
 
177 187
 			$birthdays = array();
178 188
 
179
-			foreach ($date as $member)
180
-				$birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>';
189
+			foreach ($date as $member) {
190
+							$birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>';
191
+			}
181 192
 
182 193
 			echo implode(', ', $birthdays);
183 194
 
@@ -208,8 +219,9 @@  discard block
 block discarded – undo
208 219
 			$date_local = $date['date_local'];
209 220
 			unset($date['date_local']);
210 221
 
211
-			foreach ($date as $holiday)
212
-				$holidays[] = $holiday . ' (' . $date_local . ')';
222
+			foreach ($date as $holiday) {
223
+							$holidays[] = $holiday . ' (' . $date_local . ')';
224
+			}
213 225
 		}
214 226
 
215 227
 		echo implode(', ', $holidays);
@@ -233,17 +245,19 @@  discard block
 block discarded – undo
233 245
 	global $context, $txt, $scripturl, $modSettings;
234 246
 
235 247
 	// If the grid doesn't exist, no point in proceeding.
236
-	if (!isset($context['calendar_grid_' . $grid_name]))
237
-		return false;
248
+	if (!isset($context['calendar_grid_' . $grid_name])) {
249
+			return false;
250
+	}
238 251
 
239 252
 	// A handy little pointer variable.
240 253
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
241 254
 
242 255
 	// Some conditions for whether or not we should show the week links *here*.
243
-	if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false)))
244
-		$show_week_links = true;
245
-	else
246
-		$show_week_links = false;
256
+	if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) {
257
+			$show_week_links = true;
258
+	} else {
259
+			$show_week_links = false;
260
+	}
247 261
 
248 262
 	// Assuming that we've not disabled it, show the title block!
249 263
 	if (empty($calendar_data['disable_title']))
@@ -253,18 +267,20 @@  discard block
 block discarded – undo
253 267
 				<h3 class="catbg centertext largetext">';
254 268
 
255 269
 		// Previous Link: If we're showing prev / next and it's not a mini-calendar.
256
-		if (empty($calendar_data['previous_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false)
257
-			echo '
270
+		if (empty($calendar_data['previous_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) {
271
+					echo '
258 272
 					<span class="floatleft">
259 273
 						<a href="', $calendar_data['previous_calendar']['href'], '">&#171;</a>
260 274
 					</span>';
275
+		}
261 276
 
262 277
 		// Next Link: if we're showing prev / next and it's not a mini-calendar.
263
-		if (empty($calendar_data['next_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false)
264
-			echo '
278
+		if (empty($calendar_data['next_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) {
279
+					echo '
265 280
 					<span class="floatright">
266 281
 						<a href="', $calendar_data['next_calendar']['href'], '">&#187;</a>
267 282
 					</span>';
283
+		}
268 284
 
269 285
 		// Arguably the most exciting part, the title!
270 286
 		echo '
@@ -274,8 +290,9 @@  discard block
 block discarded – undo
274 290
 	}
275 291
 
276 292
 	// Show the controls on main grids
277
-	if ($is_mini === false)
278
-		template_calendar_top($calendar_data);
293
+	if ($is_mini === false) {
294
+			template_calendar_top($calendar_data);
295
+	}
279 296
 
280 297
 	// Finally, the main calendar table.
281 298
 	echo '
@@ -288,14 +305,16 @@  discard block
 block discarded – undo
288 305
 				<tr>';
289 306
 
290 307
 		// If we're showing week links, there's an extra column ahead of the week links, so let's think ahead and be prepared!
291
-		if ($show_week_links === true)
292
-			echo '
308
+		if ($show_week_links === true) {
309
+					echo '
293 310
 					<th></th>';
311
+		}
294 312
 
295 313
 		// Now, loop through each actual day of the week.
296
-		foreach ($calendar_data['week_days'] as $day)
297
-			echo '
314
+		foreach ($calendar_data['week_days'] as $day) {
315
+					echo '
298 316
 					<th class="days" scope="col">', !empty($calendar_data['short_day_titles']) || $is_mini === true ? $txt['days_short'][$day] : $txt['days'][$day], '</th>';
317
+		}
299 318
 
300 319
 		echo '
301 320
 				</tr>';
@@ -313,11 +332,12 @@  discard block
 block discarded – undo
313 332
 				<tr class="days_wrapper">';
314 333
 
315 334
 		// This is where we add the actual week link, if enabled on this location.
316
-		if ($show_week_links === true)
317
-			echo '
335
+		if ($show_week_links === true) {
336
+					echo '
318 337
 					<td class="windowbg weeks">
319 338
 						<a href="', $scripturl, '?action=calendar;viewweek;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $week['days'][0]['day'], '" title="', $txt['calendar_view_week'], '">&#187;</a>
320 339
 					</td>';
340
+		}
321 341
 
322 342
 		// Now loop through each day in the week we're on.
323 343
 		foreach ($week['days'] as $day)
@@ -333,27 +353,29 @@  discard block
 block discarded – undo
333 353
 				// Additional classes are given for events, holidays, and birthdays.
334 354
 				if (!empty($day['events']) && !empty($calendar_data['highlight']['events']))
335 355
 				{
336
-					if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3)))
337
-						$classes[] = 'events';
338
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3)))
339
-						$classes[] = 'events';
356
+					if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) {
357
+											$classes[] = 'events';
358
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) {
359
+											$classes[] = 'events';
360
+					}
340 361
 				}
341 362
 				if (!empty($day['holidays']) && !empty($calendar_data['highlight']['holidays']))
342 363
 				{
343
-					if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3)))
344
-						$classes[] = 'holidays';
345
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3)))
346
-						$classes[] = 'holidays';
364
+					if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) {
365
+											$classes[] = 'holidays';
366
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) {
367
+											$classes[] = 'holidays';
368
+					}
347 369
 				}
348 370
 				if (!empty($day['birthdays']) && !empty($calendar_data['highlight']['birthdays']))
349 371
 				{
350
-					if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3)))
351
-						$classes[] = 'birthdays';
352
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3)))
353
-						$classes[] = 'birthdays';
372
+					if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) {
373
+											$classes[] = 'birthdays';
374
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) {
375
+											$classes[] = 'birthdays';
376
+					}
354 377
 				}
355
-			}
356
-			else
378
+			} else
357 379
 			{
358 380
 				// Default Classes (either compact or comfortable and disabled).
359 381
 				$classes[] = !empty($calendar_data['size']) && $calendar_data['size'] == 'small' ? 'compact' : 'comfortable';
@@ -371,25 +393,27 @@  discard block
 block discarded – undo
371 393
 				$title_prefix = !empty($day['is_first_of_month']) && $context['current_month'] == $calendar_data['current_month'] && $is_mini === false ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$calendar_data['current_month']] . ' ' : $txt['months_titles'][$calendar_data['current_month']] . ' ') : '';
372 394
 
373 395
 				// The actual day number - be it a link, or just plain old text!
374
-				if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
375
-					echo '
396
+				if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) {
397
+									echo '
376 398
 						<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
377
-				elseif ($is_mini)
378
-					echo '
399
+				} elseif ($is_mini) {
400
+									echo '
379 401
 						<a href="', $scripturl, '?action=calendar;', $context['calendar_view'], ';year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
380
-				else
381
-					echo '
402
+				} else {
403
+									echo '
382 404
 						<span class="day_text">', $title_prefix, $day['day'], '</span>';
405
+				}
383 406
 
384 407
 				// A lot of stuff, we're not showing on mini-calendars to conserve space.
385 408
 				if ($is_mini === false)
386 409
 				{
387 410
 					// Holidays are always fun, let's show them!
388
-					if (!empty($day['holidays']))
389
-						echo '
411
+					if (!empty($day['holidays'])) {
412
+											echo '
390 413
 						<div class="smalltext holiday">
391 414
 							<span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '
392 415
 						</div>';
416
+					}
393 417
 
394 418
 					// Happy Birthday Dear Member!
395 419
 					if (!empty($day['birthdays']))
@@ -407,15 +431,17 @@  discard block
 block discarded – undo
407 431
 							echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] || ($count == 10 && $use_js_hide) ? '' : ', ';
408 432
 
409 433
 							// 9...10! Let's stop there.
410
-							if ($birthday_count == 10 && $use_js_hide)
411
-								// !!TODO - Inline CSS and JavaScript should be moved.
434
+							if ($birthday_count == 10 && $use_js_hide) {
435
+															// !!TODO - Inline CSS and JavaScript should be moved.
412 436
 								echo '<span class="hidelink" id="bdhidelink_', $day['day'], '">...<br><a href="', $scripturl, '?action=calendar;month=', $calendar_data['current_month'], ';year=', $calendar_data['current_year'], ';showbd" onclick="document.getElementById(\'bdhide_', $day['day'], '\').style.display = \'\'; document.getElementById(\'bdhidelink_', $day['day'], '\').style.display = \'none\'; return false;">(', sprintf($txt['calendar_click_all'], count($day['birthdays'])), ')</a></span><span id="bdhide_', $day['day'], '" style="display: none;">, ';
437
+							}
413 438
 
414 439
 							++$birthday_count;
415 440
 						}
416
-						if ($use_js_hide)
417
-							echo '
441
+						if ($use_js_hide) {
442
+													echo '
418 443
 							</span>';
444
+						}
419 445
 
420 446
 						echo '
421 447
 						</div><!-- .smalltext -->';
@@ -426,8 +452,9 @@  discard block
 block discarded – undo
426 452
 					{
427 453
 						// Sort events by start time (all day events will be listed first)
428 454
 						uasort($day['events'], function($a, $b) {
429
-							if ($a['start_timestamp'] == $b['start_timestamp'])
430
-								return 0;
455
+							if ($a['start_timestamp'] == $b['start_timestamp']) {
456
+															return 0;
457
+							}
431 458
 
432 459
 							return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
433 460
 						});
@@ -447,20 +474,22 @@  discard block
 block discarded – undo
447 474
 								', $event['link'], '<br>
448 475
 								<span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">';
449 476
 
450
-							if (!empty($event['start_time_local']) && $event['starts_today'] == true)
451
-								echo trim(str_replace(':00 ', ' ', $event['start_time_local']));
452
-							elseif (!empty($event['end_time_local']) && $event['ends_today'] == true)
453
-								echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local']));
454
-							elseif (!empty($event['allday']))
455
-								echo $txt['calendar_allday'];
477
+							if (!empty($event['start_time_local']) && $event['starts_today'] == true) {
478
+															echo trim(str_replace(':00 ', ' ', $event['start_time_local']));
479
+							} elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) {
480
+															echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local']));
481
+							} elseif (!empty($event['allday'])) {
482
+															echo $txt['calendar_allday'];
483
+							}
456 484
 
457 485
 							echo '
458 486
 								</span>';
459 487
 
460
-							if (!empty($event['location']))
461
-								echo '
488
+							if (!empty($event['location'])) {
489
+															echo '
462 490
 								<br>
463 491
 								<span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
492
+							}
464 493
 
465 494
 							if ($event['can_edit'] || $event['can_export'])
466 495
 							{
@@ -468,18 +497,20 @@  discard block
 block discarded – undo
468 497
 								<span class="modify_event_links">';
469 498
 
470 499
 								// If they can edit the event, show an icon they can click on....
471
-								if ($event['can_edit'])
472
-									echo '
500
+								if ($event['can_edit']) {
501
+																	echo '
473 502
 									<a class="modify_event" href="', $event['modify_href'], '">
474 503
 										<span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span>
475 504
 									</a>';
505
+								}
476 506
 
477 507
 								// Exporting!
478
-								if ($event['can_export'])
479
-									echo '
508
+								if ($event['can_export']) {
509
+																	echo '
480 510
 									<a class="modify_event" href="', $event['export_href'], '">
481 511
 										<span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span>
482 512
 									</a>';
513
+								}
483 514
 
484 515
 								echo '
485 516
 								</span><br class="clear">';
@@ -498,10 +529,11 @@  discard block
 block discarded – undo
498 529
 			// Otherwise, assuming it's not a mini-calendar, we can show previous / next month days!
499 530
 			elseif ($is_mini === false)
500 531
 			{
501
-				if (empty($current_month_started) && !empty($context['calendar_grid_prev']))
502
-					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>';
503
-				elseif (!empty($current_month_started) && !empty($context['calendar_grid_next']))
504
-					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>';
532
+				if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) {
533
+									echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>';
534
+				} elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) {
535
+									echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>';
536
+				}
505 537
 			}
506 538
 
507 539
 			// Close this day and increase var count.
@@ -531,8 +563,9 @@  discard block
 block discarded – undo
531 563
 	global $context, $txt, $scripturl, $modSettings;
532 564
 
533 565
 	// We might have no reason to proceed, if the variable isn't there.
534
-	if (!isset($context['calendar_grid_' . $grid_name]))
535
-		return false;
566
+	if (!isset($context['calendar_grid_' . $grid_name])) {
567
+			return false;
568
+	}
536 569
 
537 570
 	// Handy pointer.
538 571
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
@@ -549,22 +582,25 @@  discard block
 block discarded – undo
549 582
 					<h3 class="catbg centertext largetext">';
550 583
 
551 584
 			// Previous Week Link...
552
-			if (empty($calendar_data['previous_calendar']['disabled']) && !empty($calendar_data['show_next_prev']))
553
-				echo '
585
+			if (empty($calendar_data['previous_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) {
586
+							echo '
554 587
 						<span class="floatleft">
555 588
 							<a href="', $calendar_data['previous_week']['href'], '">&#171;</a>
556 589
 						</span>';
590
+			}
557 591
 
558 592
 			// Next Week Link...
559
-			if (empty($calendar_data['next_calendar']['disabled']) && !empty($calendar_data['show_next_prev']))
560
-				echo '
593
+			if (empty($calendar_data['next_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) {
594
+							echo '
561 595
 						<span class="floatright">
562 596
 							<a href="', $calendar_data['next_week']['href'], '">&#187;</a>
563 597
 						</span>';
598
+			}
564 599
 
565 600
 			// The Month Title + Week Number...
566
-			if (!empty($calendar_data['week_title']))
567
-				echo $calendar_data['week_title'];
601
+			if (!empty($calendar_data['week_title'])) {
602
+							echo $calendar_data['week_title'];
603
+			}
568 604
 
569 605
 			echo '
570 606
 					</h3>
@@ -605,11 +641,12 @@  discard block
 block discarded – undo
605 641
 						<td class="', implode(' ', $classes), ' act_day">';
606 642
 
607 643
 			// Should the day number be a link?
608
-			if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
609
-				echo '
644
+			if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) {
645
+							echo '
610 646
 							<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>';
611
-			else
612
-				echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
647
+			} else {
648
+							echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
649
+			}
613 650
 
614 651
 			echo '
615 652
 						</td>
@@ -620,8 +657,9 @@  discard block
 block discarded – undo
620 657
 			{
621 658
 				// Sort events by start time (all day events will be listed first)
622 659
 				uasort($day['events'], function($a, $b) {
623
-					if ($a['start_timestamp'] == $b['start_timestamp'])
624
-						return 0;
660
+					if ($a['start_timestamp'] == $b['start_timestamp']) {
661
+											return 0;
662
+					}
625 663
 					return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
626 664
 				});
627 665
 
@@ -635,35 +673,39 @@  discard block
 block discarded – undo
635 673
 					echo $event['link'], '<br>
636 674
 								<span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">';
637 675
 
638
-					if (!empty($event['start_time_local']))
639
-						echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' &ndash; ' . trim($event['end_time_local']) : '';
640
-					else
641
-						echo $txt['calendar_allday'];
676
+					if (!empty($event['start_time_local'])) {
677
+											echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' &ndash; ' . trim($event['end_time_local']) : '';
678
+					} else {
679
+											echo $txt['calendar_allday'];
680
+					}
642 681
 
643 682
 					echo '
644 683
 								</span>';
645 684
 
646
-					if (!empty($event['location']))
647
-						echo '<br>
685
+					if (!empty($event['location'])) {
686
+											echo '<br>
648 687
 								<span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
688
+					}
649 689
 
650 690
 					if (!empty($event_icons_needed))
651 691
 					{
652 692
 						echo ' <span class="modify_event_links">';
653 693
 
654 694
 						// If they can edit the event, show a star they can click on....
655
-						if (!empty($event['can_edit']))
656
-							echo '
695
+						if (!empty($event['can_edit'])) {
696
+													echo '
657 697
 									<a class="modify_event" href="', $event['modify_href'], '">
658 698
 										<span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span>
659 699
 									</a>';
700
+						}
660 701
 
661 702
 						// Can we export? Sweet.
662
-						if (!empty($event['can_export']))
663
-							echo '
703
+						if (!empty($event['can_export'])) {
704
+													echo '
664 705
 									<a class="modify_event" href="', $event['export_href'], '">
665 706
 										<span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span>
666 707
 									</a>';
708
+						}
667 709
 
668 710
 						echo '
669 711
 								</span><br class="clear">';
@@ -681,22 +723,23 @@  discard block
 block discarded – undo
681 723
 							</div>
682 724
 							<br class="clear">';
683 725
 				}
684
-			}
685
-			else
726
+			} else
686 727
 			{
687
-				if (!empty($context['can_post']))
688
-					echo '
728
+				if (!empty($context['can_post'])) {
729
+									echo '
689 730
 							<div class="week_add_event">
690 731
 								<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['calendar_post_event'], '</a>
691 732
 							</div>';
733
+				}
692 734
 			}
693 735
 			echo '
694 736
 						</td>
695 737
 						<td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col" data-css-prefix="' . $txt['calendar_prompt'] . ' ">';
696 738
 
697 739
 			// Show any holidays!
698
-			if (!empty($day['holidays']))
699
-				echo implode('<br>', $day['holidays']);
740
+			if (!empty($day['holidays'])) {
741
+							echo implode('<br>', $day['holidays']);
742
+			}
700 743
 
701 744
 			echo '
702 745
 						</td>
@@ -705,11 +748,12 @@  discard block
 block discarded – undo
705 748
 			// Show any birthdays...
706 749
 			if (!empty($day['birthdays']))
707 750
 			{
708
-				foreach ($day['birthdays'] as $member)
709
-					echo '
751
+				foreach ($day['birthdays'] as $member) {
752
+									echo '
710 753
 							<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], '</a>
711 754
 							', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '
712 755
 							', $member['is_last'] ? '' : '<br>';
756
+				}
713 757
 			}
714 758
 			echo '
715 759
 						</td>
@@ -755,26 +799,27 @@  discard block
 block discarded – undo
755 799
 				<input type="text" name="end_date" id="end_date" maxlength="10" value="', $calendar_data['end_date'], '" tabindex="', $context['tabindex']++, '" class="date_input end" data-type="date">
756 800
 				<input type="submit" class="button" style="float:none" id="view_button" value="', $txt['view'], '">
757 801
 			</form>';
758
-	}
759
-	else
802
+	} else
760 803
 	{
761 804
 		echo'
762 805
 			<form action="', $scripturl, '?action=calendar" id="calendar_navigation" method="post" accept-charset="', $context['character_set'], '">
763 806
 				<select name="month" id="input_month">';
764 807
 
765 808
 		// Show a select box with all the months.
766
-		foreach ($txt['months_short'] as $number => $month)
767
-			echo '
809
+		foreach ($txt['months_short'] as $number => $month) {
810
+					echo '
768 811
 					<option value="', $number, '"', $number == $context['current_month'] ? ' selected' : '', '>', $month, '</option>';
812
+		}
769 813
 
770 814
 		echo '
771 815
 				</select>
772 816
 				<select name="year">';
773 817
 
774 818
 		// Show a link for every year...
775
-		for ($year = $context['calendar_resources']['min_year']; $year <= $context['calendar_resources']['max_year']; $year++)
776
-			echo '
819
+		for ($year = $context['calendar_resources']['min_year']; $year <= $context['calendar_resources']['max_year']; $year++) {
820
+					echo '
777 821
 					<option value="', $year, '"', $year == $context['current_year'] ? ' selected' : '', '>', $year, '</option>';
822
+		}
778 823
 
779 824
 		echo '
780 825
 				</select>
@@ -796,9 +841,10 @@  discard block
 block discarded – undo
796 841
 	echo '
797 842
 		<form action="', $scripturl, '?action=calendar;sa=post" method="post" name="postevent" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);">';
798 843
 
799
-	if (!empty($context['event']['new']))
800
-		echo '
844
+	if (!empty($context['event']['new'])) {
845
+			echo '
801 846
 			<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">';
847
+	}
802 848
 
803 849
 	// Start the main table.
804 850
 	echo '
@@ -809,8 +855,8 @@  discard block
 block discarded – undo
809 855
 					</h3>
810 856
 				</div>';
811 857
 
812
-	if (!empty($context['post_error']['messages']))
813
-		echo '
858
+	if (!empty($context['post_error']['messages'])) {
859
+			echo '
814 860
 				<div class="errorbox">
815 861
 					<dl class="event_error">
816 862
 						<dt>
@@ -821,6 +867,7 @@  discard block
 block discarded – undo
821 867
 						</dt>
822 868
 					</dl>
823 869
 				</div>';
870
+	}
824 871
 
825 872
 	echo '
826 873
 				<div class="roundframe noup">
@@ -848,9 +895,10 @@  discard block
 block discarded – undo
848 895
 			echo '
849 896
 									<optgroup label="', $category['name'], '">';
850 897
 
851
-			foreach ($category['boards'] as $board)
852
-				echo '
898
+			foreach ($category['boards'] as $board) {
899
+							echo '
853 900
 										<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
901
+			}
854 902
 			echo '
855 903
 									</optgroup>';
856 904
 		}
@@ -886,9 +934,10 @@  discard block
 block discarded – undo
886 934
 								<span class="label">', $txt['calendar_timezone'], '</span>
887 935
 								<select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>';
888 936
 
889
-	foreach ($context['all_timezones'] as $tz => $tzname)
890
-		echo '
937
+	foreach ($context['all_timezones'] as $tz => $tzname) {
938
+			echo '
891 939
 									<option', is_numeric($tz) ? ' value="" disabled' : ' value="' . $tz . '"', $tz === $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>';
940
+	}
892 941
 
893 942
 	echo '
894 943
 								</select>
@@ -904,9 +953,10 @@  discard block
 block discarded – undo
904 953
 					<input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button">';
905 954
 
906 955
 	// Delete button?
907
-	if (empty($context['event']['new']))
908
-		echo '
956
+	if (empty($context['event']['new'])) {
957
+			echo '
909 958
 					<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button you_sure">';
959
+	}
910 960
 
911 961
 	echo '
912 962
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -934,9 +984,10 @@  discard block
 block discarded – undo
934 984
 		echo '
935 985
 				<td style="padding-', $alt ? 'right' : 'left', ': 1.5em;">';
936 986
 
937
-		foreach ($v as $i)
938
-			echo '
987
+		foreach ($v as $i) {
988
+					echo '
939 989
 					<img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '"><br>';
990
+		}
940 991
 
941 992
 		echo '
942 993
 				</td>';
@@ -957,9 +1008,10 @@  discard block
 block discarded – undo
957 1008
 
958 1009
 	foreach ($context['clockicons'] as $t => $v)
959 1010
 	{
960
-		foreach ($v as $i)
961
-			echo '
1011
+		foreach ($v as $i) {
1012
+					echo '
962 1013
 			icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1014
+		}
963 1015
 	}
964 1016
 
965 1017
 	echo '
@@ -984,13 +1036,14 @@  discard block
 block discarded – undo
984 1036
 
985 1037
 	foreach ($context['clockicons'] as $t => $v)
986 1038
 	{
987
-		foreach ($v as $i)
988
-			echo '
1039
+		foreach ($v as $i) {
1040
+					echo '
989 1041
 				if (', $t, ' >= ', $i, ')
990 1042
 				{
991 1043
 					turnon.push("', $t, '_', $i, '");
992 1044
 					', $t, ' -= ', $i, ';
993 1045
 				}';
1046
+		}
994 1047
 	}
995 1048
 
996 1049
 	echo '
@@ -1034,9 +1087,10 @@  discard block
 block discarded – undo
1034 1087
 			<tr class="windowbg">
1035 1088
 				<td>';
1036 1089
 
1037
-		foreach ($v as $i)
1038
-			echo '
1090
+		foreach ($v as $i) {
1091
+					echo '
1039 1092
 					<img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '" style="padding: 2px;">';
1093
+		}
1040 1094
 
1041 1095
 		echo '
1042 1096
 				</td>
@@ -1058,9 +1112,10 @@  discard block
 block discarded – undo
1058 1112
 
1059 1113
 	foreach ($context['clockicons'] as $t => $v)
1060 1114
 	{
1061
-		foreach ($v as $i)
1062
-			echo '
1115
+		foreach ($v as $i) {
1116
+					echo '
1063 1117
 			icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1118
+		}
1064 1119
 	}
1065 1120
 
1066 1121
 	echo '
@@ -1077,13 +1132,14 @@  discard block
 block discarded – undo
1077 1132
 
1078 1133
 	foreach ($context['clockicons'] as $t => $v)
1079 1134
 	{
1080
-		foreach ($v as $i)
1081
-			echo '
1135
+		foreach ($v as $i) {
1136
+					echo '
1082 1137
 				if (', $t, ' >= ', $i, ')
1083 1138
 				{
1084 1139
 					turnon.push("', $t, '_', $i, '");
1085 1140
 					', $t, ' -= ', $i, ';
1086 1141
 				}';
1142
+		}
1087 1143
 	}
1088 1144
 
1089 1145
 	echo '
@@ -1127,9 +1183,10 @@  discard block
 block discarded – undo
1127 1183
 			<tr class="windowbg">
1128 1184
 				<td>';
1129 1185
 
1130
-		foreach ($v as $i)
1131
-			echo '
1186
+		foreach ($v as $i) {
1187
+					echo '
1132 1188
 					<img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '" style="padding: 2px;">';
1189
+		}
1133 1190
 
1134 1191
 		echo '
1135 1192
 				</td>
@@ -1145,9 +1202,10 @@  discard block
 block discarded – undo
1145 1202
 
1146 1203
 	foreach ($context['clockicons'] as $t => $v)
1147 1204
 	{
1148
-		foreach ($v as $i)
1149
-			echo '
1205
+		foreach ($v as $i) {
1206
+					echo '
1150 1207
 			icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1208
+		}
1151 1209
 	}
1152 1210
 
1153 1211
 	echo '
@@ -1168,13 +1226,14 @@  discard block
 block discarded – undo
1168 1226
 
1169 1227
 	foreach ($context['clockicons'] as $t => $v)
1170 1228
 	{
1171
-		foreach ($v as $i)
1172
-		echo '
1229
+		foreach ($v as $i) {
1230
+				echo '
1173 1231
 				if (', $t, ' >= ', $i, ')
1174 1232
 				{
1175 1233
 					turnon.push("', $t, '_', $i, '");
1176 1234
 					', $t, ' -= ', $i, ';
1177 1235
 				}';
1236
+		}
1178 1237
 	}
1179 1238
 
1180 1239
 	echo '
@@ -1218,9 +1277,10 @@  discard block
 block discarded – undo
1218 1277
 			<tr class="windowbg">
1219 1278
 				<td>';
1220 1279
 
1221
-		foreach ($v as $i)
1222
-			echo '
1280
+		foreach ($v as $i) {
1281
+					echo '
1223 1282
 					<img src="', $i ? $context['onimg'] : $context['offimg'], '" alt="" style="padding: 2px;">';
1283
+		}
1224 1284
 
1225 1285
 		echo '
1226 1286
 				</td>
Please login to merge, or discard this patch.
Themes/default/Memberlist.template.php 1 patch
Braces   +30 added lines, -20 removed lines patch added patch discarded remove patch
@@ -27,9 +27,10 @@  discard block
 block discarded – undo
27 27
 			<h3 class="catbg">
28 28
 				<span class="floatleft">', $txt['members_list'], '</span>';
29 29
 
30
-	if (!isset($context['old_search']))
31
-		echo '
30
+	if (!isset($context['old_search'])) {
31
+			echo '
32 32
 				<span class="floatright">', $context['letter_links'], '</span>';
33
+	}
33 34
 	echo '
34 35
 			</h3>
35 36
 		</div>';
@@ -44,20 +45,23 @@  discard block
 block discarded – undo
44 45
 	foreach ($context['columns'] as $key => $column)
45 46
 	{
46 47
 		// @TODO maybe find something nicer?
47
-		if ($key == 'email_address' && !$context['can_send_email'])
48
-			continue;
48
+		if ($key == 'email_address' && !$context['can_send_email']) {
49
+					continue;
50
+		}
49 51
 
50 52
 		// This is a selected column, so underline it or some such.
51
-		if ($column['selected'])
52
-			echo '
53
+		if ($column['selected']) {
54
+					echo '
53 55
 						<th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', ' selected" style="width: auto;"' . (isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '') . '>
54 56
 							<a href="' . $column['href'] . '" rel="nofollow">' . $column['label'] . '</a><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></th>';
57
+		}
55 58
 
56 59
 		// This is just some column... show the link and be done with it.
57
-		else
58
-			echo '
60
+		else {
61
+					echo '
59 62
 						<th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', '"', isset($column['width']) ? ' style="width: ' . $column['width'] . '"' : '', isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '', '>
60 63
 						', $column['link'], '</th>';
64
+		}
61 65
 	}
62 66
 
63 67
 	echo '
@@ -77,9 +81,10 @@  discard block
 block discarded – undo
77 81
 						</td>
78 82
 						<td class="real_name lefttext">', $member['link'], '</td>';
79 83
 
80
-			if (!isset($context['disabled_fields']['website']))
81
-				echo '
84
+			if (!isset($context['disabled_fields']['website'])) {
85
+							echo '
82 86
 						<td class="website_url centertext">', $member['website']['url'] != '' ? '<a href="' . $member['website']['url'] . '" target="_blank" rel="noopener"><span class="generic_icons www" title="' . $member['website']['title'] . '"></span></a>' : '', '</td>';
87
+			}
83 88
 
84 89
 			// Group and date.
85 90
 			echo '
@@ -92,32 +97,35 @@  discard block
 block discarded – undo
92 97
 						<td class="post_count centertext">', $member['posts'], '</td>
93 98
 						<td class="statsbar">';
94 99
 
95
-				if (!empty($member['post_percent']))
96
-					echo '
100
+				if (!empty($member['post_percent'])) {
101
+									echo '
97 102
 							<div class="generic_bar">
98 103
 								<div class="bar" style="width: ', $member['post_percent'], '%;"></div>
99 104
 							</div>';
105
+				}
100 106
 
101 107
 				echo '
102 108
 						</td>';
103 109
 			}
104 110
 
105 111
 			// Show custom fields marked to be shown here
106
-			if (!empty($context['custom_profile_fields']['columns']))
107
-				foreach ($context['custom_profile_fields']['columns'] as $key => $column)
112
+			if (!empty($context['custom_profile_fields']['columns'])) {
113
+							foreach ($context['custom_profile_fields']['columns'] as $key => $column)
108 114
 					echo '
109 115
 						<td class="' , $key , ' centertext">', $member['options'][$key], '</td>';
116
+			}
110 117
 
111 118
 			echo '
112 119
 					</tr>';
113 120
 		}
114 121
 	}
115 122
 	// No members?
116
-	else
117
-		echo '
123
+	else {
124
+			echo '
118 125
 					<tr>
119 126
 						<td colspan="', $context['colspan'], '" class="windowbg">', $txt['search_no_results'], '</td>
120 127
 					</tr>';
128
+	}
121 129
 
122 130
 	echo '
123 131
 				</tbody>
@@ -130,11 +138,12 @@  discard block
 block discarded – undo
130 138
 			<div class="pagelinks floatleft">', $context['page_index'], '</div>';
131 139
 
132 140
 	// If it is displaying the result of a search show a "search again" link to edit their criteria.
133
-	if (isset($context['old_search']))
134
-		echo '
141
+	if (isset($context['old_search'])) {
142
+			echo '
135 143
 			<div class="buttonlist floatright">
136 144
 				<a class="button" href="', $scripturl, '?action=mlist;sa=search;search=', $context['old_search_value'], '">', $txt['mlist_search_again'], '</a>
137 145
 			</div>';
146
+	}
138 147
 	echo '
139 148
 		</div>
140 149
 	</div><!-- #memberlist -->';
@@ -174,12 +183,13 @@  discard block
 block discarded – undo
174 183
 					<dd>
175 184
 						<ul>';
176 185
 
177
-	foreach ($context['search_fields'] as $id => $title)
178
-		echo '
186
+	foreach ($context['search_fields'] as $id => $title) {
187
+			echo '
179 188
 							<li>
180 189
 								<input type="checkbox" name="fields[]" id="fields-', $id, '" value="', $id, '"', in_array($id, $context['search_defaults']) ? ' checked' : '', '>
181 190
 								<label for="fields-', $id, '">', $title, '</label>
182 191
 							</li>';
192
+	}
183 193
 
184 194
 	echo '
185 195
 						</ul>
Please login to merge, or discard this patch.
Sources/Register.php 1 patch
Braces   +182 added lines, -132 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 4
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
  * Begin the registration process.
@@ -29,19 +30,23 @@  discard block
 block discarded – undo
29 30
 	global $language, $scripturl, $smcFunc, $sourcedir, $cur_profile;
30 31
 
31 32
 	// Is this an incoming AJAX check?
32
-	if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck')
33
-		return RegisterCheckUsername();
33
+	if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') {
34
+			return RegisterCheckUsername();
35
+	}
34 36
 
35 37
 	// Check if the administrator has it disabled.
36
-	if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3')
37
-		fatal_lang_error('registration_disabled', false);
38
+	if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') {
39
+			fatal_lang_error('registration_disabled', false);
40
+	}
38 41
 
39 42
 	// If this user is an admin - redirect them to the admin registration page.
40
-	if (allowedTo('moderate_forum') && !$user_info['is_guest'])
41
-		redirectexit('action=admin;area=regcenter;sa=register');
43
+	if (allowedTo('moderate_forum') && !$user_info['is_guest']) {
44
+			redirectexit('action=admin;area=regcenter;sa=register');
45
+	}
42 46
 	// You are not a guest, so you are a member - and members don't get to register twice!
43
-	elseif (empty($user_info['is_guest']))
44
-		redirectexit();
47
+	elseif (empty($user_info['is_guest'])) {
48
+			redirectexit();
49
+	}
45 50
 
46 51
 	loadLanguage('Login');
47 52
 	loadTemplate('Register');
@@ -82,16 +87,18 @@  discard block
 block discarded – undo
82 87
 		}
83 88
 	}
84 89
 	// Make sure they don't squeeze through without agreeing.
85
-	elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement'])
86
-		$current_step = 1;
90
+	elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) {
91
+			$current_step = 1;
92
+	}
87 93
 
88 94
 	// Show the user the right form.
89 95
 	$context['sub_template'] = $current_step == 1 ? 'registration_agreement' : 'registration_form';
90 96
 	$context['page_title'] = $current_step == 1 ? $txt['registration_agreement'] : $txt['registration_form'];
91 97
 
92 98
 	// Kinda need this.
93
-	if ($context['sub_template'] == 'registration_form')
94
-		loadJavaScriptFile('register.js', array('defer' => false, 'minimize' => true), 'smf_register');
99
+	if ($context['sub_template'] == 'registration_form') {
100
+			loadJavaScriptFile('register.js', array('defer' => false, 'minimize' => true), 'smf_register');
101
+	}
95 102
 
96 103
 	// Add the register chain to the link tree.
97 104
 	$context['linktree'][] = array(
@@ -100,24 +107,26 @@  discard block
 block discarded – undo
100 107
 	);
101 108
 
102 109
 	// Prepare the time gate! Do it like so, in case later steps want to reset the limit for any reason, but make sure the time is the current one.
103
-	if (!isset($_SESSION['register']))
104
-		$_SESSION['register'] = array(
110
+	if (!isset($_SESSION['register'])) {
111
+			$_SESSION['register'] = array(
105 112
 			'timenow' => time(),
106 113
 			'limit' => 10, // minimum number of seconds required on this page for registration
107 114
 		);
108
-	else
109
-		$_SESSION['register']['timenow'] = time();
115
+	} else {
116
+			$_SESSION['register']['timenow'] = time();
117
+	}
110 118
 
111 119
 	// If you have to agree to the agreement, it needs to be fetched from the file.
112 120
 	if ($context['require_agreement'])
113 121
 	{
114 122
 		// Have we got a localized one?
115
-		if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt'))
116
-			$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']);
117
-		elseif (file_exists($boarddir . '/agreement.txt'))
118
-			$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement');
119
-		else
120
-			$context['agreement'] = '';
123
+		if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) {
124
+					$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']);
125
+		} elseif (file_exists($boarddir . '/agreement.txt')) {
126
+					$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement');
127
+		} else {
128
+					$context['agreement'] = '';
129
+		}
121 130
 
122 131
 		// Nothing to show, lets disable registration and inform the admin of this error
123 132
 		if (empty($context['agreement']))
@@ -133,8 +142,9 @@  discard block
 block discarded – undo
133 142
 		$selectedLanguage = empty($_SESSION['language']) ? $language : $_SESSION['language'];
134 143
 
135 144
 		// Do we have any languages?
136
-		if (empty($context['languages']))
137
-			getLanguages();
145
+		if (empty($context['languages'])) {
146
+					getLanguages();
147
+		}
138 148
 
139 149
 		// Try to find our selected language.
140 150
 		foreach ($context['languages'] as $key => $lang)
@@ -142,8 +152,9 @@  discard block
 block discarded – undo
142 152
 			$context['languages'][$key]['name'] = strtr($lang['name'], array('-utf8' => ''));
143 153
 
144 154
 			// Found it!
145
-			if ($selectedLanguage == $lang['filename'])
146
-				$context['languages'][$key]['selected'] = true;
155
+			if ($selectedLanguage == $lang['filename']) {
156
+							$context['languages'][$key]['selected'] = true;
157
+			}
147 158
 		}
148 159
 	}
149 160
 
@@ -170,16 +181,19 @@  discard block
 block discarded – undo
170 181
 		if (in_array('website', $reg_fields))
171 182
 		{
172 183
 			unset($reg_fields['website']);
173
-			if (isset($_POST['website_title']))
174
-				$cur_profile['website_title'] = $smcFunc['htmlspecialchars']($_POST['website_title']);
175
-			if (isset($_POST['website_url']))
176
-				$cur_profile['website_url'] = $smcFunc['htmlspecialchars']($_POST['website_url']);
184
+			if (isset($_POST['website_title'])) {
185
+							$cur_profile['website_title'] = $smcFunc['htmlspecialchars']($_POST['website_title']);
186
+			}
187
+			if (isset($_POST['website_url'])) {
188
+							$cur_profile['website_url'] = $smcFunc['htmlspecialchars']($_POST['website_url']);
189
+			}
177 190
 		}
178 191
 
179 192
 		// We might have had some submissions on this front - go check.
180
-		foreach ($reg_fields as $field)
181
-			if (isset($_POST[$field]))
193
+		foreach ($reg_fields as $field) {
194
+					if (isset($_POST[$field]))
182 195
 				$cur_profile[$field] = $smcFunc['htmlspecialchars']($_POST[$field]);
196
+		}
183 197
 
184 198
 		// Load all the fields in question.
185 199
 		setupProfileContext($reg_fields);
@@ -196,8 +210,9 @@  discard block
 block discarded – undo
196 210
 		$context['visual_verification_id'] = $verificationOptions['id'];
197 211
 	}
198 212
 	// Otherwise we have nothing to show.
199
-	else
200
-		$context['visual_verification'] = false;
213
+	else {
214
+			$context['visual_verification'] = false;
215
+	}
201 216
 
202 217
 
203 218
 	$context += array(
@@ -208,8 +223,9 @@  discard block
 block discarded – undo
208 223
 
209 224
 	// Were there any errors?
210 225
 	$context['registration_errors'] = array();
211
-	if (!empty($reg_errors))
212
-		$context['registration_errors'] = $reg_errors;
226
+	if (!empty($reg_errors)) {
227
+			$context['registration_errors'] = $reg_errors;
228
+	}
213 229
 
214 230
 	createToken('register');
215 231
 }
@@ -226,27 +242,32 @@  discard block
 block discarded – undo
226 242
 	validateToken('register');
227 243
 
228 244
 	// Check to ensure we're forcing SSL for authentication
229
-	if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
230
-		fatal_lang_error('register_ssl_required');
245
+	if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
246
+			fatal_lang_error('register_ssl_required');
247
+	}
231 248
 
232 249
 	// Start collecting together any errors.
233 250
 	$reg_errors = array();
234 251
 
235 252
 	// You can't register if it's disabled.
236
-	if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3)
237
-		fatal_lang_error('registration_disabled', false);
253
+	if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) {
254
+			fatal_lang_error('registration_disabled', false);
255
+	}
238 256
 
239 257
 	// Well, if you don't agree, you can't register.
240
-	if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed']))
241
-		redirectexit();
258
+	if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) {
259
+			redirectexit();
260
+	}
242 261
 
243 262
 	// Make sure they came from *somewhere*, have a session.
244
-	if (!isset($_SESSION['old_url']))
245
-		redirectexit('action=signup');
263
+	if (!isset($_SESSION['old_url'])) {
264
+			redirectexit('action=signup');
265
+	}
246 266
 
247 267
 	// If we don't require an agreement, we need a extra check for coppa.
248
-	if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge']))
249
-		$_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']);
268
+	if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) {
269
+			$_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']);
270
+	}
250 271
 	// Are they under age, and under age users are banned?
251 272
 	if (!empty($modSettings['coppaAge']) && empty($modSettings['coppaType']) && empty($_SESSION['skip_coppa']))
252 273
 	{
@@ -255,8 +276,9 @@  discard block
 block discarded – undo
255 276
 	}
256 277
 
257 278
 	// Check the time gate for miscreants. First make sure they came from somewhere that actually set it up.
258
-	if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit']))
259
-		redirectexit('action=signup');
279
+	if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) {
280
+			redirectexit('action=signup');
281
+	}
260 282
 	// Failing that, check the time on it.
261 283
 	if (time() - $_SESSION['register']['timenow'] < $_SESSION['register']['limit'])
262 284
 	{
@@ -276,8 +298,9 @@  discard block
 block discarded – undo
276 298
 		if (is_array($context['visual_verification']))
277 299
 		{
278 300
 			loadLanguage('Errors');
279
-			foreach ($context['visual_verification'] as $error)
280
-				$reg_errors[] = $txt['error_' . $error];
301
+			foreach ($context['visual_verification'] as $error) {
302
+							$reg_errors[] = $txt['error_' . $error];
303
+			}
281 304
 		}
282 305
 	}
283 306
 
@@ -286,14 +309,16 @@  discard block
 block discarded – undo
286 309
 		if (!is_array($_POST[$key]))
287 310
 		{
288 311
 			// For UTF-8, replace any kind of space with a normal space, and remove any kind of control character (incl. "\n" and "\r"), then trim.
289
-			if ($context['utf8'])
290
-				$_POST[$key] = $smcFunc['htmltrim'](preg_replace(array('~\p{Z}+~u', '~\p{C}+~u'), array(' ', ''), $_POST[$key]));
312
+			if ($context['utf8']) {
313
+							$_POST[$key] = $smcFunc['htmltrim'](preg_replace(array('~\p{Z}+~u', '~\p{C}+~u'), array(' ', ''), $_POST[$key]));
314
+			}
291 315
 			// Otherwise, just remove "\n" and "\r", then trim.
292
-			else
293
-				$_POST[$key] = $smcFunc['htmltrim'](str_replace(array("\n", "\r"), '', $_POST[$key]));
316
+			else {
317
+							$_POST[$key] = $smcFunc['htmltrim'](str_replace(array("\n", "\r"), '', $_POST[$key]));
318
+			}
319
+		} else {
320
+					$_POST[$key] = htmltrim__recursive($_POST[$key]);
294 321
 		}
295
-		else
296
-			$_POST[$key] = htmltrim__recursive($_POST[$key]);
297 322
 	}
298 323
 
299 324
 	// Collect all extra registration fields someone might have filled in.
@@ -328,13 +353,15 @@  discard block
 block discarded – undo
328 353
 			$possible_strings = array_merge(array('website_url', 'website_title'), $possible_strings);
329 354
 
330 355
 			// Make sure their website URL is squeaky clean
331
-			if (isset($_POST['website_url']))
332
-				$_POST['website_url'] = (string) validate_iri(sanitize_iri($_POST['website_url']));
356
+			if (isset($_POST['website_url'])) {
357
+							$_POST['website_url'] = (string) validate_iri(sanitize_iri($_POST['website_url']));
358
+			}
333 359
 		}
334 360
 	}
335 361
 
336
-	if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '')
337
-		$_POST['secret_answer'] = md5($_POST['secret_answer']);
362
+	if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') {
363
+			$_POST['secret_answer'] = md5($_POST['secret_answer']);
364
+	}
338 365
 
339 366
 	// Needed for isReservedName() and registerMember().
340 367
 	require_once($sourcedir . '/Subs-Members.php');
@@ -343,8 +370,9 @@  discard block
 block discarded – undo
343 370
 	if (isset($_POST['real_name']))
344 371
 	{
345 372
 		// Are you already allowed to edit the displayed name?
346
-		if (allowedTo('profile_displayed_name') || allowedTo('moderate_forum'))
347
-			$canEditDisplayName = true;
373
+		if (allowedTo('profile_displayed_name') || allowedTo('moderate_forum')) {
374
+					$canEditDisplayName = true;
375
+		}
348 376
 
349 377
 		// If you are a guest, will you be allowed to once you register?
350 378
 		else
@@ -363,32 +391,37 @@  discard block
 block discarded – undo
363 391
 		}
364 392
 
365 393
 		// Only set it if you can and if we are sure it is good
366
-		if ($canEditDisplayName && $smcFunc['htmltrim']($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60)
367
-				$possible_strings[] = 'real_name';
394
+		if ($canEditDisplayName && $smcFunc['htmltrim']($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60) {
395
+						$possible_strings[] = 'real_name';
396
+		}
368 397
 	}
369 398
 
370 399
 	// Handle a string as a birthdate...
371
-	if (isset($_POST['birthdate']) && $_POST['birthdate'] != '')
372
-		$_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate']));
400
+	if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') {
401
+			$_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate']));
402
+	}
373 403
 	// Or birthdate parts...
374
-	elseif (!empty($_POST['bday1']) && !empty($_POST['bday2']))
375
-		$_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']);
404
+	elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) {
405
+			$_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']);
406
+	}
376 407
 
377 408
 	// Validate the passed language file.
378 409
 	if (isset($_POST['lngfile']) && !empty($modSettings['userLanguage']))
379 410
 	{
380 411
 		// Do we have any languages?
381
-		if (empty($context['languages']))
382
-			getLanguages();
412
+		if (empty($context['languages'])) {
413
+					getLanguages();
414
+		}
383 415
 
384 416
 		// Did we find it?
385
-		if (isset($context['languages'][$_POST['lngfile']]))
386
-			$_SESSION['language'] = $_POST['lngfile'];
387
-		else
417
+		if (isset($context['languages'][$_POST['lngfile']])) {
418
+					$_SESSION['language'] = $_POST['lngfile'];
419
+		} else {
420
+					unset($_POST['lngfile']);
421
+		}
422
+	} else {
388 423
 			unset($_POST['lngfile']);
389 424
 	}
390
-	else
391
-		unset($_POST['lngfile']);
392 425
 
393 426
 	// Set the options needed for registration.
394 427
 	$regOptions = array(
@@ -408,22 +441,27 @@  discard block
 block discarded – undo
408 441
 	);
409 442
 
410 443
 	// Include the additional options that might have been filled in.
411
-	foreach ($possible_strings as $var)
412
-		if (isset($_POST[$var]))
444
+	foreach ($possible_strings as $var) {
445
+			if (isset($_POST[$var]))
413 446
 			$regOptions['extra_register_vars'][$var] = $smcFunc['htmlspecialchars']($_POST[$var], ENT_QUOTES);
414
-	foreach ($possible_ints as $var)
415
-		if (isset($_POST[$var]))
447
+	}
448
+	foreach ($possible_ints as $var) {
449
+			if (isset($_POST[$var]))
416 450
 			$regOptions['extra_register_vars'][$var] = (int) $_POST[$var];
417
-	foreach ($possible_floats as $var)
418
-		if (isset($_POST[$var]))
451
+	}
452
+	foreach ($possible_floats as $var) {
453
+			if (isset($_POST[$var]))
419 454
 			$regOptions['extra_register_vars'][$var] = (float) $_POST[$var];
420
-	foreach ($possible_bools as $var)
421
-		if (isset($_POST[$var]))
455
+	}
456
+	foreach ($possible_bools as $var) {
457
+			if (isset($_POST[$var]))
422 458
 			$regOptions['extra_register_vars'][$var] = empty($_POST[$var]) ? 0 : 1;
459
+	}
423 460
 
424 461
 	// Registration options are always default options...
425
-	if (isset($_POST['default_options']))
426
-		$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
462
+	if (isset($_POST['default_options'])) {
463
+			$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
464
+	}
427 465
 	$regOptions['theme_vars'] = isset($_POST['options']) && is_array($_POST['options']) ? $_POST['options'] : array();
428 466
 
429 467
 	// Make sure they are clean, dammit!
@@ -443,12 +481,14 @@  discard block
 block discarded – undo
443 481
 	while ($row = $smcFunc['db_fetch_assoc']($request))
444 482
 	{
445 483
 		// Don't allow overriding of the theme variables.
446
-		if (isset($regOptions['theme_vars'][$row['col_name']]))
447
-			unset($regOptions['theme_vars'][$row['col_name']]);
484
+		if (isset($regOptions['theme_vars'][$row['col_name']])) {
485
+					unset($regOptions['theme_vars'][$row['col_name']]);
486
+		}
448 487
 
449 488
 		// Not actually showing it then?
450
-		if (!$row['show_reg'])
451
-			continue;
489
+		if (!$row['show_reg']) {
490
+					continue;
491
+		}
452 492
 
453 493
 		// Prepare the value!
454 494
 		$value = isset($_POST['customfield'][$row['col_name']]) ? trim($_POST['customfield'][$row['col_name']]) : '';
@@ -457,24 +497,27 @@  discard block
 block discarded – undo
457 497
 		if (!in_array($row['field_type'], array('check', 'select', 'radio')))
458 498
 		{
459 499
 			// Is it too long?
460
-			if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value))
461
-				$custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length']));
500
+			if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value)) {
501
+							$custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length']));
502
+			}
462 503
 
463 504
 			// Any masks to apply?
464 505
 			if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none')
465 506
 			{
466
-				if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255))
467
-					$custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name']));
468
-				elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value))
469
-					$custom_field_errors[] = array('custom_field_not_number', array($row['field_name']));
470
-				elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0)
471
-					$custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name']));
507
+				if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) {
508
+									$custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name']));
509
+				} elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value)) {
510
+									$custom_field_errors[] = array('custom_field_not_number', array($row['field_name']));
511
+				} elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) {
512
+									$custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name']));
513
+				}
472 514
 			}
473 515
 		}
474 516
 
475 517
 		// Is this required but not there?
476
-		if (trim($value) == '' && $row['show_reg'] > 1)
477
-			$custom_field_errors[] = array('custom_field_empty', array($row['field_name']));
518
+		if (trim($value) == '' && $row['show_reg'] > 1) {
519
+					$custom_field_errors[] = array('custom_field_empty', array($row['field_name']));
520
+		}
478 521
 	}
479 522
 	$smcFunc['db_free_result']($request);
480 523
 
@@ -482,8 +525,9 @@  discard block
 block discarded – undo
482 525
 	if (!empty($custom_field_errors))
483 526
 	{
484 527
 		loadLanguage('Errors');
485
-		foreach ($custom_field_errors as $error)
486
-			$reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]);
528
+		foreach ($custom_field_errors as $error) {
529
+					$reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]);
530
+		}
487 531
 	}
488 532
 
489 533
 	// Lets check for other errors before trying to register the member.
@@ -528,8 +572,9 @@  discard block
 block discarded – undo
528 572
 	}
529 573
 
530 574
 	// If COPPA has been selected then things get complicated, setup the template.
531
-	if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa']))
532
-		redirectexit('action=coppa;member=' . $memberID);
575
+	if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) {
576
+			redirectexit('action=coppa;member=' . $memberID);
577
+	}
533 578
 	// Basic template variable setup.
534 579
 	elseif (!empty($modSettings['registration_method']))
535 580
 	{
@@ -541,8 +586,7 @@  discard block
 block discarded – undo
541 586
 			'sub_template' => 'after',
542 587
 			'description' => $modSettings['registration_method'] == 2 ? $txt['approval_after_registration'] : $txt['activate_after_registration']
543 588
 		);
544
-	}
545
-	else
589
+	} else
546 590
 	{
547 591
 		call_integration_hook('integrate_activate', array($regOptions['username']));
548 592
 
@@ -562,16 +606,18 @@  discard block
 block discarded – undo
562 606
 	global $context, $txt, $modSettings, $scripturl, $sourcedir, $smcFunc, $language, $user_info;
563 607
 
564 608
 	// Logged in users should not bother to activate their accounts
565
-	if (!empty($user_info['id']))
566
-		redirectexit();
609
+	if (!empty($user_info['id'])) {
610
+			redirectexit();
611
+	}
567 612
 
568 613
 	loadLanguage('Login');
569 614
 	loadTemplate('Login');
570 615
 
571 616
 	if (empty($_REQUEST['u']) && empty($_POST['user']))
572 617
 	{
573
-		if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3')
574
-			fatal_lang_error('no_access', false);
618
+		if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3') {
619
+					fatal_lang_error('no_access', false);
620
+		}
575 621
 
576 622
 		$context['member_id'] = 0;
577 623
 		$context['sub_template'] = 'resend';
@@ -611,11 +657,13 @@  discard block
 block discarded – undo
611 657
 	// Change their email address? (they probably tried a fake one first :P.)
612 658
 	if (isset($_POST['new_email'], $_REQUEST['passwd']) && hash_password($row['member_name'], $_REQUEST['passwd']) == $row['passwd'] && ($row['is_activated'] == 0 || $row['is_activated'] == 2))
613 659
 	{
614
-		if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3)
615
-			fatal_lang_error('no_access', false);
660
+		if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3) {
661
+					fatal_lang_error('no_access', false);
662
+		}
616 663
 
617
-		if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL))
618
-			fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false);
664
+		if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) {
665
+					fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false);
666
+		}
619 667
 
620 668
 		// Make sure their email isn't banned.
621 669
 		isBannedEmail($_POST['new_email'], 'cannot_register', $txt['ban_register_prohibited']);
@@ -631,8 +679,9 @@  discard block
 block discarded – undo
631 679
 			)
632 680
 		);
633 681
 
634
-		if ($smcFunc['db_num_rows']($request) != 0)
635
-			fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email'])));
682
+		if ($smcFunc['db_num_rows']($request) != 0) {
683
+					fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email'])));
684
+		}
636 685
 		$smcFunc['db_free_result']($request);
637 686
 
638 687
 		updateMemberData($row['id_member'], array('email_address' => $_POST['new_email']));
@@ -670,9 +719,9 @@  discard block
 block discarded – undo
670 719
 	// Quit if this code is not right.
671 720
 	if (empty($_REQUEST['code']) || $row['validation_code'] != $_REQUEST['code'])
672 721
 	{
673
-		if (!empty($row['is_activated']))
674
-			fatal_lang_error('already_activated', false);
675
-		elseif ($row['validation_code'] == '')
722
+		if (!empty($row['is_activated'])) {
723
+					fatal_lang_error('already_activated', false);
724
+		} elseif ($row['validation_code'] == '')
676 725
 		{
677 726
 			loadLanguage('Profile');
678 727
 			fatal_error(sprintf($txt['registration_not_approved'], $scripturl . '?action=activate;user=' . $row['member_name']), false);
@@ -722,8 +771,9 @@  discard block
 block discarded – undo
722 771
 	loadTemplate('Register');
723 772
 
724 773
 	// No User ID??
725
-	if (!isset($_GET['member']))
726
-		fatal_lang_error('no_access', false);
774
+	if (!isset($_GET['member'])) {
775
+			fatal_lang_error('no_access', false);
776
+	}
727 777
 
728 778
 	// Get the user details...
729 779
 	$request = $smcFunc['db_query']('', '
@@ -736,8 +786,9 @@  discard block
 block discarded – undo
736 786
 			'is_coppa' => 5,
737 787
 		)
738 788
 	);
739
-	if ($smcFunc['db_num_rows']($request) == 0)
740
-		fatal_lang_error('no_access', false);
789
+	if ($smcFunc['db_num_rows']($request) == 0) {
790
+			fatal_lang_error('no_access', false);
791
+	}
741 792
 	list ($username) = $smcFunc['db_fetch_row']($request);
742 793
 	$smcFunc['db_free_result']($request);
743 794
 
@@ -775,8 +826,7 @@  discard block
 block discarded – undo
775 826
 			echo $data;
776 827
 			obExit(false);
777 828
 		}
778
-	}
779
-	else
829
+	} else
780 830
 	{
781 831
 		$context += array(
782 832
 			'page_title' => $txt['coppa_title'],
@@ -829,8 +879,9 @@  discard block
 block discarded – undo
829 879
 	{
830 880
 		require_once($sourcedir . '/Subs-Graphics.php');
831 881
 
832
-		if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code))
833
-			send_http_status(400);
882
+		if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) {
883
+					send_http_status(400);
884
+		}
834 885
 
835 886
 		// Otherwise just show a pre-defined letter.
836 887
 		elseif (isset($_REQUEST['letter']))
@@ -848,14 +899,13 @@  discard block
 block discarded – undo
848 899
 			header('content-type: image/gif');
849 900
 			die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B");
850 901
 		}
851
-	}
852
-
853
-	elseif ($_REQUEST['format'] === '.wav')
902
+	} elseif ($_REQUEST['format'] === '.wav')
854 903
 	{
855 904
 		require_once($sourcedir . '/Subs-Sound.php');
856 905
 
857
-		if (!createWaveFile($code))
858
-			send_http_status(400);
906
+		if (!createWaveFile($code)) {
907
+					send_http_status(400);
908
+		}
859 909
 	}
860 910
 
861 911
 	// We all die one day...
Please login to merge, or discard this patch.