Completed
Pull Request — release-2.1 (#3835)
by Martyn
09:20
created
Sources/Stats.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -555,7 +555,7 @@
 block discarded – undo
555 555
 				'subject' => $row_liked_message['subject'],
556 556
 				'num' => $row_liked_message['likes'],
557 557
 				'href' => $scripturl . '?msg=' . $row_liked_message['id_msg'],
558
-				'link' => '<a href="' . $scripturl . '?msg=' . $row_liked_message['id_msg'] .'">' . $row_liked_message['subject'] . '</a>'
558
+				'link' => '<a href="' . $scripturl . '?msg=' . $row_liked_message['id_msg'] . '">' . $row_liked_message['subject'] . '</a>'
559 559
 			);
560 560
 
561 561
 			if ($max_liked_message < $row_liked_message['likes'])
Please login to merge, or discard this 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 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * 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(
@@ -220,8 +225,9 @@  discard block
 block discarded – undo
220 225
 			'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
221 226
 		);
222 227
 
223
-		if ($max_num_posts < $row_members['posts'])
224
-			$max_num_posts = $row_members['posts'];
228
+		if ($max_num_posts < $row_members['posts']) {
229
+					$max_num_posts = $row_members['posts'];
230
+		}
225 231
 	}
226 232
 	$smcFunc['db_free_result']($members_result);
227 233
 
@@ -257,8 +263,9 @@  discard block
 block discarded – undo
257 263
 			'link' => '<a href="' . $scripturl . '?board=' . $row_board['id_board'] . '.0">' . $row_board['name'] . '</a>'
258 264
 		);
259 265
 
260
-		if ($max_num_posts < $row_board['num_posts'])
261
-			$max_num_posts = $row_board['num_posts'];
266
+		if ($max_num_posts < $row_board['num_posts']) {
267
+					$max_num_posts = $row_board['num_posts'];
268
+		}
262 269
 	}
263 270
 	$smcFunc['db_free_result']($boards_result);
264 271
 
@@ -284,12 +291,13 @@  discard block
 block discarded – undo
284 291
 			)
285 292
 		);
286 293
 		$topic_ids = array();
287
-		while ($row = $smcFunc['db_fetch_assoc']($request))
288
-			$topic_ids[] = $row['id_topic'];
294
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
295
+					$topic_ids[] = $row['id_topic'];
296
+		}
289 297
 		$smcFunc['db_free_result']($request);
298
+	} else {
299
+			$topic_ids = array();
290 300
 	}
291
-	else
292
-		$topic_ids = array();
293 301
 
294 302
 	// Topic replies top 10.
295 303
 	$topic_reply_result = $smcFunc['db_query']('', '
@@ -329,8 +337,9 @@  discard block
 block discarded – undo
329 337
 			'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_reply['id_topic'] . '.0">' . $row_topic_reply['subject'] . '</a>'
330 338
 		);
331 339
 
332
-		if ($max_num_replies < $row_topic_reply['num_replies'])
333
-			$max_num_replies = $row_topic_reply['num_replies'];
340
+		if ($max_num_replies < $row_topic_reply['num_replies']) {
341
+					$max_num_replies = $row_topic_reply['num_replies'];
342
+		}
334 343
 	}
335 344
 	$smcFunc['db_free_result']($topic_reply_result);
336 345
 
@@ -354,12 +363,13 @@  discard block
 block discarded – undo
354 363
 			)
355 364
 		);
356 365
 		$topic_ids = array();
357
-		while ($row = $smcFunc['db_fetch_assoc']($request))
358
-			$topic_ids[] = $row['id_topic'];
366
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
367
+					$topic_ids[] = $row['id_topic'];
368
+		}
359 369
 		$smcFunc['db_free_result']($request);
370
+	} else {
371
+			$topic_ids = array();
360 372
 	}
361
-	else
362
-		$topic_ids = array();
363 373
 
364 374
 	// Topic views top 10.
365 375
 	$topic_view_result = $smcFunc['db_query']('', '
@@ -399,8 +409,9 @@  discard block
 block discarded – undo
399 409
 			'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_views['id_topic'] . '.0">' . $row_topic_views['subject'] . '</a>'
400 410
 		);
401 411
 
402
-		if ($max_num < $row_topic_views['num_views'])
403
-			$max_num = $row_topic_views['num_views'];
412
+		if ($max_num < $row_topic_views['num_views']) {
413
+					$max_num = $row_topic_views['num_views'];
414
+		}
404 415
 	}
405 416
 	$smcFunc['db_free_result']($topic_view_result);
406 417
 
@@ -425,15 +436,17 @@  discard block
 block discarded – undo
425 436
 			)
426 437
 		);
427 438
 		$members = array();
428
-		while ($row = $smcFunc['db_fetch_assoc']($request))
429
-			$members[$row['id_member_started']] = $row['hits'];
439
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
440
+					$members[$row['id_member_started']] = $row['hits'];
441
+		}
430 442
 		$smcFunc['db_free_result']($request);
431 443
 
432 444
 		cache_put_data('stats_top_starters', $members, 360);
433 445
 	}
434 446
 
435
-	if (empty($members))
436
-		$members = array(0 => 0);
447
+	if (empty($members)) {
448
+			$members = array(0 => 0);
449
+	}
437 450
 
438 451
 	// Topic poster top 10.
439 452
 	$members_result = $smcFunc['db_query']('', '
@@ -458,8 +471,9 @@  discard block
 block discarded – undo
458 471
 			'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
459 472
 		);
460 473
 
461
-		if ($max_num < $members[$row_members['id_member']])
462
-			$max_num = $members[$row_members['id_member']];
474
+		if ($max_num < $members[$row_members['id_member']]) {
475
+					$max_num = $members[$row_members['id_member']];
476
+		}
463 477
 	}
464 478
 	ksort($context['stats_blocks']['starters']);
465 479
 	$smcFunc['db_free_result']($members_result);
@@ -488,8 +502,9 @@  discard block
 block discarded – undo
488 502
 	while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
489 503
 	{
490 504
 		$temp2[] = (int) $row_members['id_member'];
491
-		if (count($context['stats_blocks']['time_online']) >= 10)
492
-			continue;
505
+		if (count($context['stats_blocks']['time_online']) >= 10) {
506
+					continue;
507
+		}
493 508
 
494 509
 		// Figure out the days, hours and minutes.
495 510
 		$timeDays = floor($row_members['total_time_logged_in'] / 86400);
@@ -497,10 +512,12 @@  discard block
 block discarded – undo
497 512
 
498 513
 		// Figure out which things to show... (days, hours, minutes, etc.)
499 514
 		$timelogged = '';
500
-		if ($timeDays > 0)
501
-			$timelogged .= $timeDays . $txt['totalTimeLogged5'];
502
-		if ($timeHours > 0)
503
-			$timelogged .= $timeHours . $txt['totalTimeLogged6'];
515
+		if ($timeDays > 0) {
516
+					$timelogged .= $timeDays . $txt['totalTimeLogged5'];
517
+		}
518
+		if ($timeHours > 0) {
519
+					$timelogged .= $timeHours . $txt['totalTimeLogged6'];
520
+		}
504 521
 		$timelogged .= floor(($row_members['total_time_logged_in'] % 3600) / 60) . $txt['totalTimeLogged7'];
505 522
 
506 523
 		$context['stats_blocks']['time_online'][] = array(
@@ -512,17 +529,20 @@  discard block
 block discarded – undo
512 529
 			'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
513 530
 		);
514 531
 
515
-		if ($max_time_online < $row_members['total_time_logged_in'])
516
-			$max_time_online = $row_members['total_time_logged_in'];
532
+		if ($max_time_online < $row_members['total_time_logged_in']) {
533
+					$max_time_online = $row_members['total_time_logged_in'];
534
+		}
517 535
 	}
518 536
 	$smcFunc['db_free_result']($members_result);
519 537
 
520
-	foreach ($context['stats_blocks']['time_online'] as $i => $member)
521
-		$context['stats_blocks']['time_online'][$i]['percent'] = round(($member['seconds_online'] * 100) / $max_time_online);
538
+	foreach ($context['stats_blocks']['time_online'] as $i => $member) {
539
+			$context['stats_blocks']['time_online'][$i]['percent'] = round(($member['seconds_online'] * 100) / $max_time_online);
540
+	}
522 541
 
523 542
 	// Cache the ones we found for a bit, just so we don't have to look again.
524
-	if ($temp !== $temp2)
525
-		cache_put_data('stats_total_time_members', $temp2, 480);
543
+	if ($temp !== $temp2) {
544
+			cache_put_data('stats_total_time_members', $temp2, 480);
545
+	}
526 546
 
527 547
 	// Likes.
528 548
 	if (!empty($modSettings['enable_likes']))
@@ -558,13 +578,15 @@  discard block
 block discarded – undo
558 578
 				'link' => '<a href="' . $scripturl . '?msg=' . $row_liked_message['id_msg'] .'">' . $row_liked_message['subject'] . '</a>'
559 579
 			);
560 580
 
561
-			if ($max_liked_message < $row_liked_message['likes'])
562
-				$max_liked_message = $row_liked_message['likes'];
581
+			if ($max_liked_message < $row_liked_message['likes']) {
582
+							$max_liked_message = $row_liked_message['likes'];
583
+			}
563 584
 		}
564 585
 		$smcFunc['db_free_result']($liked_messages);
565 586
 
566
-		foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages)
567
-			$context['stats_blocks']['liked_messages'][$i]['percent'] = round(($liked_messages['num'] * 100) / $max_liked_message);
587
+		foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages) {
588
+					$context['stats_blocks']['liked_messages'][$i]['percent'] = round(($liked_messages['num'] * 100) / $max_liked_message);
589
+		}
568 590
 
569 591
 		// Liked users top 10.
570 592
 		$context['stats_blocks']['liked_users'] = array();
@@ -595,14 +617,16 @@  discard block
 block discarded – undo
595 617
 				'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_liked_users['liked_user'] . '">' . $row_liked_users['real_name'] . '</a>',
596 618
 			);
597 619
 
598
-			if ($max_liked_users < $row_liked_users['count'])
599
-				$max_liked_users = $row_liked_users['count'];
620
+			if ($max_liked_users < $row_liked_users['count']) {
621
+							$max_liked_users = $row_liked_users['count'];
622
+			}
600 623
 		}
601 624
 
602 625
 		$smcFunc['db_free_result']($liked_users);
603 626
 
604
-		foreach ($context['stats_blocks']['liked_users'] as $i => $liked_users)
605
-			$context['stats_blocks']['liked_users'][$i]['percent'] = round(($liked_users['num'] * 100) / $max_liked_users);
627
+		foreach ($context['stats_blocks']['liked_users'] as $i => $liked_users) {
628
+					$context['stats_blocks']['liked_users'][$i]['percent'] = round(($liked_users['num'] * 100) / $max_liked_users);
629
+		}
606 630
 	}
607 631
 
608 632
 	// Activity by month.
@@ -620,8 +644,8 @@  discard block
 block discarded – undo
620 644
 		$ID_MONTH = $row_months['stats_year'] . sprintf('%02d', $row_months['stats_month']);
621 645
 		$expanded = !empty($_SESSION['expanded_stats'][$row_months['stats_year']]) && in_array($row_months['stats_month'], $_SESSION['expanded_stats'][$row_months['stats_year']]);
622 646
 
623
-		if (!isset($context['yearly'][$row_months['stats_year']]))
624
-			$context['yearly'][$row_months['stats_year']] = array(
647
+		if (!isset($context['yearly'][$row_months['stats_year']])) {
648
+					$context['yearly'][$row_months['stats_year']] = array(
625 649
 				'year' => $row_months['stats_year'],
626 650
 				'new_topics' => 0,
627 651
 				'new_posts' => 0,
@@ -633,6 +657,7 @@  discard block
 block discarded – undo
633 657
 				'expanded' => false,
634 658
 				'current_year' => $row_months['stats_year'] == date('Y'),
635 659
 			);
660
+		}
636 661
 
637 662
 		$context['yearly'][$row_months['stats_year']]['months'][(int) $row_months['stats_month']] = array(
638 663
 			'id' => $ID_MONTH,
@@ -678,26 +703,30 @@  discard block
 block discarded – undo
678 703
 		$context['yearly'][$year]['hits'] = comma_format($data['hits']);
679 704
 
680 705
 		// Keep a list of collapsed years.
681
-		if (!$data['expanded'] && !$data['current_year'])
682
-			$context['collapsed_years'][] = $year;
706
+		if (!$data['expanded'] && !$data['current_year']) {
707
+					$context['collapsed_years'][] = $year;
708
+		}
683 709
 	}
684 710
 
685
-	if (empty($_SESSION['expanded_stats']))
686
-		return;
711
+	if (empty($_SESSION['expanded_stats'])) {
712
+			return;
713
+	}
687 714
 
688 715
 	$condition_text = array();
689 716
 	$condition_params = array();
690
-	foreach ($_SESSION['expanded_stats'] as $year => $months)
691
-		if (!empty($months))
717
+	foreach ($_SESSION['expanded_stats'] as $year => $months) {
718
+			if (!empty($months))
692 719
 		{
693 720
 			$condition_text[] = 'YEAR(date) = {int:year_' . $year . '} AND MONTH(date) IN ({array_int:months_' . $year . '})';
721
+	}
694 722
 			$condition_params['year_' . $year] = $year;
695 723
 			$condition_params['months_' . $year] = $months;
696 724
 		}
697 725
 
698 726
 	// No daily stats to even look at?
699
-	if (empty($condition_text))
700
-		return;
727
+	if (empty($condition_text)) {
728
+			return;
729
+	}
701 730
 
702 731
 	getDailyStats(implode(' OR ', $condition_text), $condition_params);
703 732
 
@@ -723,8 +752,8 @@  discard block
 block discarded – undo
723 752
 		ORDER BY stats_day ASC',
724 753
 		$condition_parameters
725 754
 	);
726
-	while ($row_days = $smcFunc['db_fetch_assoc']($days_result))
727
-		$context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array(
755
+	while ($row_days = $smcFunc['db_fetch_assoc']($days_result)) {
756
+			$context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array(
728 757
 			'day' => sprintf('%02d', $row_days['stats_day']),
729 758
 			'month' => sprintf('%02d', $row_days['stats_month']),
730 759
 			'year' => $row_days['stats_year'],
@@ -734,6 +763,7 @@  discard block
 block discarded – undo
734 763
 			'most_members_online' => comma_format($row_days['most_on']),
735 764
 			'hits' => comma_format($row_days['hits'])
736 765
 		);
766
+	}
737 767
 	$smcFunc['db_free_result']($days_result);
738 768
 }
739 769
 
@@ -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['allow_sm_stats']))
756
-		die();
785
+	if (empty($modSettings['allow_sm_stats'])) {
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['allow_sm_stats']))
760
-		die();
790
+	if (!$user_info['is_admin'] && (!isset($_GET['sid']) || $_GET['sid'] != $modSettings['allow_sm_stats'])) {
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/ManageErrors.php 1 patch
Braces   +49 added lines, -38 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * View the forum's error log.
@@ -30,8 +31,9 @@  discard block
 block discarded – undo
30 31
 	global $scripturl, $txt, $context, $modSettings, $user_profile, $filter, $smcFunc;
31 32
 
32 33
 	// Viewing contents of a file?
33
-	if (isset($_GET['file']))
34
-		return ViewFile();
34
+	if (isset($_GET['file'])) {
35
+			return ViewFile();
36
+	}
35 37
 
36 38
 	// Check for the administrative permission to do this.
37 39
 	isAllowedTo('admin_forum');
@@ -85,8 +87,8 @@  discard block
 block discarded – undo
85 87
 	);
86 88
 
87 89
 	// Set up the filtering...
88
-	if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']]))
89
-		$filter = array(
90
+	if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) {
91
+			$filter = array(
90 92
 			'variable' => $_GET['filter'],
91 93
 			'value' => array(
92 94
 				'sql' => in_array($_GET['filter'], array('message', 'url', 'file')) ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : $smcFunc['db_escape_wildcard_string']($_GET['value']),
@@ -94,10 +96,12 @@  discard block
 block discarded – undo
94 96
 			'href' => ';filter=' . $_GET['filter'] . ';value=' . $_GET['value'],
95 97
 			'entity' => $filters[$_GET['filter']]['txt']
96 98
 		);
99
+	}
97 100
 
98 101
 	// Deleting, are we?
99
-	if (isset($_POST['delall']) || isset($_POST['delete']))
100
-		deleteErrors();
102
+	if (isset($_POST['delall']) || isset($_POST['delete'])) {
103
+			deleteErrors();
104
+	}
101 105
 
102 106
 	// Just how many errors are there?
103 107
 	$result = $smcFunc['db_query']('', '
@@ -112,12 +116,14 @@  discard block
 block discarded – undo
112 116
 	$smcFunc['db_free_result']($result);
113 117
 
114 118
 	// If this filter is empty...
115
-	if ($num_errors == 0 && isset($filter))
116
-		redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : ''));
119
+	if ($num_errors == 0 && isset($filter)) {
120
+			redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : ''));
121
+	}
117 122
 
118 123
 	// Clean up start.
119
-	if (!isset($_GET['start']) || $_GET['start'] < 0)
120
-		$_GET['start'] = 0;
124
+	if (!isset($_GET['start']) || $_GET['start'] < 0) {
125
+			$_GET['start'] = 0;
126
+	}
121 127
 
122 128
 	// Do we want to reverse error listing?
123 129
 	$context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up';
@@ -127,9 +133,9 @@  discard block
 block discarded – undo
127 133
 	$context['start'] = $_GET['start'];
128 134
 
129 135
 	// Update the error count
130
-	if (!isset($filter))
131
-		$context['num_errors'] = $num_errors;
132
-	else
136
+	if (!isset($filter)) {
137
+			$context['num_errors'] = $num_errors;
138
+	} else
133 139
 	{
134 140
 		// We want all errors, not just the number of filtered messages...
135 141
 		$query = $smcFunc['db_query']('', '
@@ -161,8 +167,9 @@  discard block
 block discarded – undo
161 167
 	for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i ++)
162 168
 	{
163 169
 		$search_message = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '%', $smcFunc['db_escape_wildcard_string']($row['message']));
164
-		if ($search_message == $filter['value']['sql'])
165
-			$search_message = $smcFunc['db_escape_wildcard_string']($row['message']);
170
+		if ($search_message == $filter['value']['sql']) {
171
+					$search_message = $smcFunc['db_escape_wildcard_string']($row['message']);
172
+		}
166 173
 		$show_message = strtr(strtr(preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $row['message']), array("\r" => '', '<br>' => "\n", '<' => '&lt;', '>' => '&gt;', '"' => '&quot;')), array("\n" => '<br>'));
167 174
 
168 175
 		$context['errors'][$row['id_error']] = array(
@@ -221,8 +228,9 @@  discard block
 block discarded – undo
221 228
 				'members' => count($members),
222 229
 			)
223 230
 		);
224
-		while ($row = $smcFunc['db_fetch_assoc']($request))
225
-			$members[$row['id_member']] = $row;
231
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
232
+					$members[$row['id_member']] = $row;
233
+		}
226 234
 		$smcFunc['db_free_result']($request);
227 235
 
228 236
 		// This is a guest...
@@ -254,20 +262,18 @@  discard block
 block discarded – undo
254 262
 			$id = $filter['value']['sql'];
255 263
 			loadMemberData($id, false, 'minimal');
256 264
 			$context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>';
257
-		}
258
-		elseif ($filter['variable'] == 'url')
259
-			$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\'';
260
-		elseif ($filter['variable'] == 'message')
265
+		} elseif ($filter['variable'] == 'url') {
266
+					$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\'';
267
+		} elseif ($filter['variable'] == 'message')
261 268
 		{
262 269
 			$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '&lt;br /&gt;' => '<br>', "\t" => '&nbsp;&nbsp;&nbsp;', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\'';
263 270
 			$context['filter']['value']['html'] = preg_replace('~&amp;lt;span class=&amp;quot;remove&amp;quot;&amp;gt;(.+?)&amp;lt;/span&amp;gt;~', '$1', $context['filter']['value']['html']);
264
-		}
265
-		elseif ($filter['variable'] == 'error_type')
271
+		} elseif ($filter['variable'] == 'error_type')
266 272
 		{
267 273
 			$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '&lt;br /&gt;' => '<br>', "\t" => '&nbsp;&nbsp;&nbsp;', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\'';
274
+		} else {
275
+					$context['filter']['value']['html'] = &$filter['value']['sql'];
268 276
 		}
269
-		else
270
-			$context['filter']['value']['html'] = &$filter['value']['sql'];
271 277
 	}
272 278
 
273 279
 	$context['error_types'] = array();
@@ -308,10 +314,11 @@  discard block
 block discarded – undo
308 314
 	$context['error_types']['all']['label'] .= ' (' . $sum . ')';
309 315
 
310 316
 	// Finally, work out what is the last tab!
311
-	if (isset($context['error_types'][$sum]))
312
-		$context['error_types'][$sum]['is_last'] = true;
313
-	else
314
-		$context['error_types']['all']['is_last'] = true;
317
+	if (isset($context['error_types'][$sum])) {
318
+			$context['error_types'][$sum]['is_last'] = true;
319
+	} else {
320
+			$context['error_types']['all']['is_last'] = true;
321
+	}
315 322
 
316 323
 	// And this is pretty basic ;).
317 324
 	$context['page_title'] = $txt['errlog'];
@@ -337,21 +344,23 @@  discard block
 block discarded – undo
337 344
 	validateToken('admin-el');
338 345
 
339 346
 	// Delete all or just some?
340
-	if (isset($_POST['delall']) && !isset($filter))
341
-		$smcFunc['db_query']('truncate_table', '
347
+	if (isset($_POST['delall']) && !isset($filter)) {
348
+			$smcFunc['db_query']('truncate_table', '
342 349
 			TRUNCATE {db_prefix}log_errors',
343 350
 			array(
344 351
 			)
345 352
 		);
353
+	}
346 354
 	// Deleting all with a filter?
347
-	elseif (isset($_POST['delall']) && isset($filter))
348
-		$smcFunc['db_query']('', '
355
+	elseif (isset($_POST['delall']) && isset($filter)) {
356
+			$smcFunc['db_query']('', '
349 357
 			DELETE FROM {db_prefix}log_errors
350 358
 			WHERE ' . $filter['variable'] . ' LIKE {string:filter}',
351 359
 			array(
352 360
 				'filter' => $filter['value']['sql'],
353 361
 			)
354 362
 		);
363
+	}
355 364
 	// Just specific errors?
356 365
 	elseif (!empty($_POST['delete']))
357 366
 	{
@@ -397,15 +406,17 @@  discard block
 block discarded – undo
397 406
 	$line = isset($_REQUEST['line']) ? (int) $_REQUEST['line'] : 0;
398 407
 
399 408
 	// Make sure the file we are looking for is one they are allowed to look at
400
-	if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file))
401
-		fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file)));
409
+	if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) {
410
+			fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file)));
411
+	}
402 412
 
403 413
 	// get the min and max lines
404 414
 	$min = $line - 20 <= 0 ? 1 : $line - 20;
405 415
 	$max = $line + 21; // One additional line to make everything work out correctly
406 416
 
407
-	if ($max <= 0 || $min >= $max)
408
-		fatal_lang_error('error_bad_line');
417
+	if ($max <= 0 || $min >= $max) {
418
+			fatal_lang_error('error_bad_line');
419
+	}
409 420
 
410 421
 	$file_data = explode('<br />', highlight_php_code($smcFunc['htmlspecialchars'](implode('', file($file)))));
411 422
 
Please login to merge, or discard this patch.
Sources/News.php 2 patches
Braces   +239 added lines, -185 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Outputs xml data representing recent information or a profile.
@@ -37,8 +38,9 @@  discard block
 block discarded – undo
37 38
 	global $query_this_board, $smcFunc, $forum_version;
38 39
 
39 40
 	// If it's not enabled, die.
40
-	if (empty($modSettings['xmlnews_enable']))
41
-		obExit(false);
41
+	if (empty($modSettings['xmlnews_enable'])) {
42
+			obExit(false);
43
+	}
42 44
 
43 45
 	loadLanguage('Stats');
44 46
 
@@ -53,8 +55,9 @@  discard block
 block discarded – undo
53 55
 	if (!empty($_REQUEST['c']) && empty($board))
54 56
 	{
55 57
 		$_REQUEST['c'] = explode(',', $_REQUEST['c']);
56
-		foreach ($_REQUEST['c'] as $i => $c)
57
-			$_REQUEST['c'][$i] = (int) $c;
58
+		foreach ($_REQUEST['c'] as $i => $c) {
59
+					$_REQUEST['c'][$i] = (int) $c;
60
+		}
58 61
 
59 62
 		if (count($_REQUEST['c']) == 1)
60 63
 		{
@@ -90,18 +93,20 @@  discard block
 block discarded – undo
90 93
 		}
91 94
 		$smcFunc['db_free_result']($request);
92 95
 
93
-		if (!empty($boards))
94
-			$query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')';
96
+		if (!empty($boards)) {
97
+					$query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')';
98
+		}
95 99
 
96 100
 		// Try to limit the number of messages we look through.
97
-		if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15)
98
-			$context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $_GET['limit'] * 5);
99
-	}
100
-	elseif (!empty($_REQUEST['boards']))
101
+		if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15) {
102
+					$context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $_GET['limit'] * 5);
103
+		}
104
+	} elseif (!empty($_REQUEST['boards']))
101 105
 	{
102 106
 		$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
103
-		foreach ($_REQUEST['boards'] as $i => $b)
104
-			$_REQUEST['boards'][$i] = (int) $b;
107
+		foreach ($_REQUEST['boards'] as $i => $b) {
108
+					$_REQUEST['boards'][$i] = (int) $b;
109
+		}
105 110
 
106 111
 		$request = $smcFunc['db_query']('', '
107 112
 			SELECT b.id_board, b.num_posts, b.name
@@ -117,29 +122,32 @@  discard block
 block discarded – undo
117 122
 
118 123
 		// Either the board specified doesn't exist or you have no access.
119 124
 		$num_boards = $smcFunc['db_num_rows']($request);
120
-		if ($num_boards == 0)
121
-			fatal_lang_error('no_board');
125
+		if ($num_boards == 0) {
126
+					fatal_lang_error('no_board');
127
+		}
122 128
 
123 129
 		$total_posts = 0;
124 130
 		$boards = array();
125 131
 		while ($row = $smcFunc['db_fetch_assoc']($request))
126 132
 		{
127
-			if ($num_boards == 1)
128
-				$feed_title = ' - ' . strip_tags($row['name']);
133
+			if ($num_boards == 1) {
134
+							$feed_title = ' - ' . strip_tags($row['name']);
135
+			}
129 136
 
130 137
 			$boards[] = $row['id_board'];
131 138
 			$total_posts += $row['num_posts'];
132 139
 		}
133 140
 		$smcFunc['db_free_result']($request);
134 141
 
135
-		if (!empty($boards))
136
-			$query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')';
142
+		if (!empty($boards)) {
143
+					$query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')';
144
+		}
137 145
 
138 146
 		// The more boards, the more we're going to look through...
139
-		if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12)
140
-			$context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $_GET['limit'] * 5);
141
-	}
142
-	elseif (!empty($board))
147
+		if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12) {
148
+					$context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $_GET['limit'] * 5);
149
+		}
150
+	} elseif (!empty($board))
143 151
 	{
144 152
 		$request = $smcFunc['db_query']('', '
145 153
 			SELECT num_posts
@@ -158,10 +166,10 @@  discard block
 block discarded – undo
158 166
 		$query_this_board = 'b.id_board = ' . $board;
159 167
 
160 168
 		// Try to look through just a few messages, if at all possible.
161
-		if ($total_posts > 80 && $total_posts > $modSettings['totalMessages'] / 10)
162
-			$context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $_GET['limit'] * 5);
163
-	}
164
-	else
169
+		if ($total_posts > 80 && $total_posts > $modSettings['totalMessages'] / 10) {
170
+					$context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $_GET['limit'] * 5);
171
+		}
172
+	} else
165 173
 	{
166 174
 		$query_this_board = '{query_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
167 175
 			AND b.id_board != ' . $modSettings['recycle_board'] : '');
@@ -184,30 +192,35 @@  discard block
 block discarded – undo
184 192
 	// Easy adding of sub actions
185 193
  	call_integration_hook('integrate_xmlfeeds', array(&$subActions));
186 194
 
187
-	if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']]))
188
-		$_GET['sa'] = 'recent';
195
+	if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']])) {
196
+			$_GET['sa'] = 'recent';
197
+	}
189 198
 
190 199
 	// We only want some information, not all of it.
191 200
 	$cachekey = array($xml_format, $_GET['action'], $_GET['limit'], $_GET['sa']);
192
-	foreach (array('board', 'boards', 'c') as $var)
193
-		if (isset($_REQUEST[$var]))
201
+	foreach (array('board', 'boards', 'c') as $var) {
202
+			if (isset($_REQUEST[$var]))
194 203
 			$cachekey[] = $_REQUEST[$var];
204
+	}
195 205
 	$cachekey = md5(json_encode($cachekey) . (!empty($query_this_board) ? $query_this_board : ''));
196 206
 	$cache_t = microtime();
197 207
 
198 208
 	// Get the associative array representing the xml.
199
-	if (!empty($modSettings['cache_enable']) && (!$user_info['is_guest'] || $modSettings['cache_enable'] >= 3))
200
-		$xml = cache_get_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240);
209
+	if (!empty($modSettings['cache_enable']) && (!$user_info['is_guest'] || $modSettings['cache_enable'] >= 3)) {
210
+			$xml = cache_get_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240);
211
+	}
201 212
 	if (empty($xml))
202 213
 	{
203 214
 		$call = call_helper($subActions[$_GET['sa']][0], true);
204 215
 
205
-		if (!empty($call))
206
-			$xml = call_user_func($call, $xml_format);
216
+		if (!empty($call)) {
217
+					$xml = call_user_func($call, $xml_format);
218
+		}
207 219
 
208 220
 		if (!empty($modSettings['cache_enable']) && (($user_info['is_guest'] && $modSettings['cache_enable'] >= 3)
209
-		|| (!$user_info['is_guest'] && (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.2))))
210
-			cache_put_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml, 240);
221
+		|| (!$user_info['is_guest'] && (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.2)))) {
222
+					cache_put_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml, 240);
223
+		}
211 224
 	}
212 225
 
213 226
 	$feed_title = $smcFunc['htmlspecialchars'](strip_tags($context['forum_name'])) . (isset($feed_title) ? $feed_title : '');
@@ -218,19 +231,21 @@  discard block
 block discarded – undo
218 231
 
219 232
 	// This is an xml file....
220 233
 	ob_end_clean();
221
-	if (!empty($modSettings['enableCompressedOutput']))
222
-		@ob_start('ob_gzhandler');
223
-	else
224
-		ob_start();
234
+	if (!empty($modSettings['enableCompressedOutput'])) {
235
+			@ob_start('ob_gzhandler');
236
+	} else {
237
+			ob_start();
238
+	}
225 239
 
226
-	if ($xml_format == 'smf' || isset($_REQUEST['debug']))
227
-		header('Content-Type: text/xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
228
-	elseif ($xml_format == 'rss' || $xml_format == 'rss2')
229
-		header('Content-Type: application/rss+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
230
-	elseif ($xml_format == 'atom')
231
-		header('Content-Type: application/atom+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
232
-	elseif ($xml_format == 'rdf')
233
-		header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
240
+	if ($xml_format == 'smf' || isset($_REQUEST['debug'])) {
241
+			header('Content-Type: text/xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
242
+	} elseif ($xml_format == 'rss' || $xml_format == 'rss2') {
243
+			header('Content-Type: application/rss+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
244
+	} elseif ($xml_format == 'atom') {
245
+			header('Content-Type: application/atom+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
246
+	} elseif ($xml_format == 'rdf') {
247
+			header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
248
+	}
234 249
 
235 250
 	// First, output the xml header.
236 251
 	echo '<?xml version="1.0" encoding="', $context['character_set'], '"?' . '>';
@@ -247,8 +262,9 @@  discard block
 block discarded – undo
247 262
 		<description>', cdata_parse(strip_tags($txt['xml_rss_desc'])), '</description>';
248 263
 
249 264
 		// RSS2 calls for this.
250
-		if ($xml_format == 'rss2')
251
-			echo '<atom:link rel="self" type="application/rss+xml" href="', $scripturl, '?action=.xml', !empty($_GET['sa']) ? ';sa=' . $_GET['sa'] : '', ';type=rss2" />';
265
+		if ($xml_format == 'rss2') {
266
+					echo '<atom:link rel="self" type="application/rss+xml" href="', $scripturl, '?action=.xml', !empty($_GET['sa']) ? ';sa=' . $_GET['sa'] : '', ';type=rss2" />';
267
+		}
252 268
 
253 269
 		// Output all of the associative array, start indenting with 2 tabs, and name everything "item".
254 270
 		dumpTags($xml, 2, 'item', $xml_format);
@@ -257,12 +273,12 @@  discard block
 block discarded – undo
257 273
 		echo '
258 274
 	</channel>
259 275
 </rss>';
260
-	}
261
-	elseif ($xml_format == 'atom')
276
+	} elseif ($xml_format == 'atom')
262 277
 	{
263
-		foreach ($_REQUEST as $var => $val)
264
-			if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit')))
278
+		foreach ($_REQUEST as $var => $val) {
279
+					if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit')))
265 280
 				$url_parts[] = $var . '=' . (is_array($_REQUEST[$var]) ? implode(',', $_REQUEST[$var]) : $_REQUEST[$var]);
281
+		}
266 282
 
267 283
 		echo '
268 284
 <feed xmlns="http://www.w3.org/2005/Atom">
@@ -283,8 +299,7 @@  discard block
 block discarded – undo
283 299
 
284 300
 		echo '
285 301
 </feed>';
286
-	}
287
-	elseif ($xml_format == 'rdf')
302
+	} elseif ($xml_format == 'rdf')
288 303
 	{
289 304
 		echo '
290 305
 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://purl.org/rss/1.0/">
@@ -295,9 +310,10 @@  discard block
 block discarded – undo
295 310
 		<items>
296 311
 			<rdf:Seq>';
297 312
 
298
-		foreach ($xml as $item)
299
-			echo '
313
+		foreach ($xml as $item) {
314
+					echo '
300 315
 				<rdf:li rdf:resource="', $item['link'], '" />';
316
+		}
301 317
 
302 318
 		echo '
303 319
 			</rdf:Seq>
@@ -337,13 +353,15 @@  discard block
 block discarded – undo
337 353
 {
338 354
 	global $modSettings, $context, $scripturl;
339 355
 
340
-	if (substr($val, 0, strlen($scripturl)) != $scripturl)
341
-		return $val;
356
+	if (substr($val, 0, strlen($scripturl)) != $scripturl) {
357
+			return $val;
358
+	}
342 359
 
343 360
 	call_integration_hook('integrate_fix_url', array(&$val));
344 361
 
345
-	if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd']))
346
-		return $val;
362
+	if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd'])) {
363
+			return $val;
364
+	}
347 365
 
348 366
 	$val = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$~', function ($m) use ($scripturl)
349 367
 		{
@@ -365,8 +383,9 @@  discard block
 block discarded – undo
365 383
 	global $smcFunc;
366 384
 
367 385
 	// Do we even need to do this?
368
-	if (strpbrk($data, '<>&') == false)
369
-		return $data;
386
+	if (strpbrk($data, '<>&') == false) {
387
+			return $data;
388
+	}
370 389
 
371 390
 	$cdata = '<![CDATA[';
372 391
 
@@ -376,49 +395,55 @@  discard block
 block discarded – undo
376 395
 			$smcFunc['strpos']($data, '&', $pos),
377 396
 			$smcFunc['strpos']($data, ']', $pos),
378 397
 		);
379
-		if ($ns != '')
380
-			$positions[] = $smcFunc['strpos']($data, '<', $pos);
398
+		if ($ns != '') {
399
+					$positions[] = $smcFunc['strpos']($data, '<', $pos);
400
+		}
381 401
 		foreach ($positions as $k => $dummy)
382 402
 		{
383
-			if ($dummy === false)
384
-				unset($positions[$k]);
403
+			if ($dummy === false) {
404
+							unset($positions[$k]);
405
+			}
385 406
 		}
386 407
 
387 408
 		$old = $pos;
388 409
 		$pos = empty($positions) ? $n : min($positions);
389 410
 
390
-		if ($pos - $old > 0)
391
-			$cdata .= $smcFunc['substr']($data, $old, $pos - $old);
392
-		if ($pos >= $n)
393
-			break;
411
+		if ($pos - $old > 0) {
412
+					$cdata .= $smcFunc['substr']($data, $old, $pos - $old);
413
+		}
414
+		if ($pos >= $n) {
415
+					break;
416
+		}
394 417
 
395 418
 		if ($smcFunc['substr']($data, $pos, 1) == '<')
396 419
 		{
397 420
 			$pos2 = $smcFunc['strpos']($data, '>', $pos);
398
-			if ($pos2 === false)
399
-				$pos2 = $n;
400
-			if ($smcFunc['substr']($data, $pos + 1, 1) == '/')
401
-				$cdata .= ']]></' . $ns . ':' . $smcFunc['substr']($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA[';
402
-			else
403
-				$cdata .= ']]><' . $ns . ':' . $smcFunc['substr']($data, $pos + 1, $pos2 - $pos) . '<![CDATA[';
421
+			if ($pos2 === false) {
422
+							$pos2 = $n;
423
+			}
424
+			if ($smcFunc['substr']($data, $pos + 1, 1) == '/') {
425
+							$cdata .= ']]></' . $ns . ':' . $smcFunc['substr']($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA[';
426
+			} else {
427
+							$cdata .= ']]><' . $ns . ':' . $smcFunc['substr']($data, $pos + 1, $pos2 - $pos) . '<![CDATA[';
428
+			}
404 429
 			$pos = $pos2 + 1;
405
-		}
406
-		elseif ($smcFunc['substr']($data, $pos, 1) == ']')
430
+		} elseif ($smcFunc['substr']($data, $pos, 1) == ']')
407 431
 		{
408 432
 			$cdata .= ']]>&#093;<![CDATA[';
409 433
 			$pos++;
410
-		}
411
-		elseif ($smcFunc['substr']($data, $pos, 1) == '&')
434
+		} elseif ($smcFunc['substr']($data, $pos, 1) == '&')
412 435
 		{
413 436
 			$pos2 = $smcFunc['strpos']($data, ';', $pos);
414
-			if ($pos2 === false)
415
-				$pos2 = $n;
437
+			if ($pos2 === false) {
438
+							$pos2 = $n;
439
+			}
416 440
 			$ent = $smcFunc['substr']($data, $pos + 1, $pos2 - $pos - 1);
417 441
 
418
-			if ($smcFunc['substr']($data, $pos + 1, 1) == '#')
419
-				$cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA[';
420
-			elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot')))
421
-				$cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA[';
442
+			if ($smcFunc['substr']($data, $pos + 1, 1) == '#') {
443
+							$cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA[';
444
+			} elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot'))) {
445
+							$cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA[';
446
+			}
422 447
 
423 448
 			$pos = $pos2 + 1;
424 449
 		}
@@ -456,19 +481,22 @@  discard block
 block discarded – undo
456 481
 		'gender',
457 482
 		'blurb',
458 483
 	);
459
-	if ($xml_format != 'atom')
460
-		$keysToCdata[] = 'category';
484
+	if ($xml_format != 'atom') {
485
+			$keysToCdata[] = 'category';
486
+	}
461 487
 
462 488
 	// For every array in the data...
463 489
 	foreach ($data as $key => $val)
464 490
 	{
465 491
 		// Skip it, it's been set to null.
466
-		if ($val === null)
467
-			continue;
492
+		if ($val === null) {
493
+					continue;
494
+		}
468 495
 
469 496
 		// If the value should maybe be CDATA, do that now.
470
-		if (!is_array($val) && in_array($key, $keysToCdata))
471
-			$val = cdata_parse($val);
497
+		if (!is_array($val) && in_array($key, $keysToCdata)) {
498
+					$val = cdata_parse($val);
499
+		}
472 500
 
473 501
 		// If a tag was passed, use it instead of the key.
474 502
 		$key = isset($tag) ? $tag : $key;
@@ -484,11 +512,11 @@  discard block
 block discarded – undo
484 512
 		}
485 513
 
486 514
 		// If it's empty/0/nothing simply output an empty tag.
487
-		if ($val == '')
488
-			echo '<', $key, ' />';
489
-		elseif ($xml_format == 'atom' && $key == 'category')
490
-			echo '<', $key, ' term="', $val, '" />';
491
-		else
515
+		if ($val == '') {
516
+					echo '<', $key, ' />';
517
+		} elseif ($xml_format == 'atom' && $key == 'category') {
518
+					echo '<', $key, ' term="', $val, '" />';
519
+		} else
492 520
 		{
493 521
 			// Beginning tag.
494 522
 			if ($xml_format == 'rdf' && $key == 'item' && isset($val['link']))
@@ -496,11 +524,11 @@  discard block
 block discarded – undo
496 524
 				echo '<', $key, ' rdf:about="', fix_possible_url($val['link']), '">';
497 525
 				echo "\n", str_repeat("\t", $i + 1);
498 526
 				echo '<dc:format>text/html</dc:format>';
527
+			} elseif ($xml_format == 'atom' && $key == 'summary') {
528
+							echo '<', $key, ' type="html">';
529
+			} else {
530
+							echo '<', $key, '>';
499 531
 			}
500
-			elseif ($xml_format == 'atom' && $key == 'summary')
501
-				echo '<', $key, ' type="html">';
502
-			else
503
-				echo '<', $key, '>';
504 532
 
505 533
 			// The element's value.
506 534
 			if (is_array($val))
@@ -510,11 +538,13 @@  discard block
 block discarded – undo
510 538
 				echo "\n", str_repeat("\t", $i);
511 539
 			}
512 540
 			// A string with returns in it.... show this as a multiline element.
513
-			elseif (strpos($val, "\n") !== false || preg_match('~<br ?/?' . '>~', $val) !== false)
514
-				echo "\n", fix_possible_url($val), "\n", str_repeat("\t", $i);
541
+			elseif (strpos($val, "\n") !== false || preg_match('~<br ?/?' . '>~', $val) !== false) {
542
+							echo "\n", fix_possible_url($val), "\n", str_repeat("\t", $i);
543
+			}
515 544
 			// A simple string.
516
-			else
517
-				echo fix_possible_url($val);
545
+			else {
546
+							echo fix_possible_url($val);
547
+			}
518 548
 
519 549
 			// Ending tag.
520 550
 			echo '</', $key, '>';
@@ -534,8 +564,9 @@  discard block
 block discarded – undo
534 564
 {
535 565
 	global $scripturl, $smcFunc;
536 566
 
537
-	if (!allowedTo('view_mlist'))
538
-		return array();
567
+	if (!allowedTo('view_mlist')) {
568
+			return array();
569
+	}
539 570
 
540 571
 	// Find the most recent members.
541 572
 	$request = $smcFunc['db_query']('', '
@@ -551,35 +582,37 @@  discard block
 block discarded – undo
551 582
 	while ($row = $smcFunc['db_fetch_assoc']($request))
552 583
 	{
553 584
 		// Make the data look rss-ish.
554
-		if ($xml_format == 'rss' || $xml_format == 'rss2')
555
-			$data[] = array(
585
+		if ($xml_format == 'rss' || $xml_format == 'rss2') {
586
+					$data[] = array(
556 587
 				'title' => $row['real_name'],
557 588
 				'link' => $scripturl . '?action=profile;u=' . $row['id_member'],
558 589
 				'comments' => $scripturl . '?action=pm;sa=send;u=' . $row['id_member'],
559 590
 				'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['date_registered']),
560 591
 				'guid' => $scripturl . '?action=profile;u=' . $row['id_member'],
561 592
 			);
562
-		elseif ($xml_format == 'rdf')
563
-			$data[] = array(
593
+		} elseif ($xml_format == 'rdf') {
594
+					$data[] = array(
564 595
 				'title' => $row['real_name'],
565 596
 				'link' => $scripturl . '?action=profile;u=' . $row['id_member'],
566 597
 			);
567
-		elseif ($xml_format == 'atom')
568
-			$data[] = array(
598
+		} elseif ($xml_format == 'atom') {
599
+					$data[] = array(
569 600
 				'title' => $row['real_name'],
570 601
 				'link' => $scripturl . '?action=profile;u=' . $row['id_member'],
571 602
 				'published' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $row['date_registered']),
572 603
 				'updated' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $row['last_login']),
573 604
 				'id' => $scripturl . '?action=profile;u=' . $row['id_member'],
574 605
 			);
606
+		}
575 607
 		// More logical format for the data, but harder to apply.
576
-		else
577
-			$data[] = array(
608
+		else {
609
+					$data[] = array(
578 610
 				'name' => $row['real_name'],
579 611
 				'time' => $smcFunc['htmlspecialchars'](strip_tags(timeformat($row['date_registered']))),
580 612
 				'id' => $row['id_member'],
581 613
 				'link' => $scripturl . '?action=profile;u=' . $row['id_member']
582 614
 			);
615
+		}
583 616
 	}
584 617
 	$smcFunc['db_free_result']($request);
585 618
 
@@ -640,22 +673,24 @@  discard block
 block discarded – undo
640 673
 		if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit'])
641 674
 		{
642 675
 			$smcFunc['db_free_result']($request);
643
-			if (empty($_REQUEST['boards']) && empty($board))
644
-				unset($context['optimize_msg']['lowest']);
645
-			else
646
-				$context['optimize_msg']['lowest'] = 'm.id_msg >= t.id_first_msg';
676
+			if (empty($_REQUEST['boards']) && empty($board)) {
677
+							unset($context['optimize_msg']['lowest']);
678
+			} else {
679
+							$context['optimize_msg']['lowest'] = 'm.id_msg >= t.id_first_msg';
680
+			}
647 681
 			$context['optimize_msg']['highest'] = 'm.id_msg <= t.id_last_msg';
648 682
 			$loops++;
683
+		} else {
684
+					$done = true;
649 685
 		}
650
-		else
651
-			$done = true;
652 686
 	}
653 687
 	$data = array();
654 688
 	while ($row = $smcFunc['db_fetch_assoc']($request))
655 689
 	{
656 690
 		// Limit the length of the message, if the option is set.
657
-		if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen'])
658
-			$row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...';
691
+		if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) {
692
+					$row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...';
693
+		}
659 694
 
660 695
 		$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
661 696
 
@@ -663,8 +698,8 @@  discard block
 block discarded – undo
663 698
 		censorText($row['subject']);
664 699
 
665 700
 		// Being news, this actually makes sense in rss format.
666
-		if ($xml_format == 'rss' || $xml_format == 'rss2')
667
-			$data[] = array(
701
+		if ($xml_format == 'rss' || $xml_format == 'rss2') {
702
+					$data[] = array(
668 703
 				'title' => $row['subject'],
669 704
 				'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
670 705
 				'description' => $row['body'],
@@ -674,14 +709,14 @@  discard block
 block discarded – undo
674 709
 				'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['poster_time']),
675 710
 				'guid' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
676 711
 			);
677
-		elseif ($xml_format == 'rdf')
678
-			$data[] = array(
712
+		} elseif ($xml_format == 'rdf') {
713
+					$data[] = array(
679 714
 				'title' => $row['subject'],
680 715
 				'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
681 716
 				'description' => $row['body'],
682 717
 			);
683
-		elseif ($xml_format == 'atom')
684
-			$data[] = array(
718
+		} elseif ($xml_format == 'atom') {
719
+					$data[] = array(
685 720
 				'title' => $row['subject'],
686 721
 				'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
687 722
 				'summary' => $row['body'],
@@ -695,9 +730,10 @@  discard block
 block discarded – undo
695 730
 				'updated' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', empty($row['modified_time']) ? $row['poster_time'] : $row['modified_time']),
696 731
 				'id' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
697 732
 			);
733
+		}
698 734
 		// The biggest difference here is more information.
699
-		else
700
-			$data[] = array(
735
+		else {
736
+					$data[] = array(
701 737
 				'time' => $smcFunc['htmlspecialchars'](strip_tags(timeformat($row['poster_time']))),
702 738
 				'id' => $row['id_topic'],
703 739
 				'subject' => $row['subject'],
@@ -715,6 +751,7 @@  discard block
 block discarded – undo
715 751
 				),
716 752
 				'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
717 753
 			);
754
+		}
718 755
 	}
719 756
 	$smcFunc['db_free_result']($request);
720 757
 
@@ -761,22 +798,25 @@  discard block
 block discarded – undo
761 798
 		if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit'])
762 799
 		{
763 800
 			$smcFunc['db_free_result']($request);
764
-			if (empty($_REQUEST['boards']) && empty($board))
765
-				unset($context['optimize_msg']['lowest']);
766
-			else
767
-				$context['optimize_msg']['lowest'] = $loops ? 'm.id_msg >= t.id_first_msg' : 'm.id_msg >= (t.id_last_msg - t.id_first_msg) / 2';
801
+			if (empty($_REQUEST['boards']) && empty($board)) {
802
+							unset($context['optimize_msg']['lowest']);
803
+			} else {
804
+							$context['optimize_msg']['lowest'] = $loops ? 'm.id_msg >= t.id_first_msg' : 'm.id_msg >= (t.id_last_msg - t.id_first_msg) / 2';
805
+			}
768 806
 			$loops++;
807
+		} else {
808
+					$done = true;
769 809
 		}
770
-		else
771
-			$done = true;
772 810
 	}
773 811
 	$messages = array();
774
-	while ($row = $smcFunc['db_fetch_assoc']($request))
775
-		$messages[] = $row['id_msg'];
812
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
813
+			$messages[] = $row['id_msg'];
814
+	}
776 815
 	$smcFunc['db_free_result']($request);
777 816
 
778
-	if (empty($messages))
779
-		return array();
817
+	if (empty($messages)) {
818
+			return array();
819
+	}
780 820
 
781 821
 	// Find the most recent posts this user can see.
782 822
 	$request = $smcFunc['db_query']('', '
@@ -806,8 +846,9 @@  discard block
 block discarded – undo
806 846
 	while ($row = $smcFunc['db_fetch_assoc']($request))
807 847
 	{
808 848
 		// Limit the length of the message, if the option is set.
809
-		if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen'])
810
-			$row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...';
849
+		if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) {
850
+					$row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...';
851
+		}
811 852
 
812 853
 		$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
813 854
 
@@ -815,8 +856,8 @@  discard block
 block discarded – undo
815 856
 		censorText($row['subject']);
816 857
 
817 858
 		// Doesn't work as well as news, but it kinda does..
818
-		if ($xml_format == 'rss' || $xml_format == 'rss2')
819
-			$data[] = array(
859
+		if ($xml_format == 'rss' || $xml_format == 'rss2') {
860
+					$data[] = array(
820 861
 				'title' => $row['subject'],
821 862
 				'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'],
822 863
 				'description' => $row['body'],
@@ -826,14 +867,14 @@  discard block
 block discarded – undo
826 867
 				'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['poster_time']),
827 868
 				'guid' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg']
828 869
 			);
829
-		elseif ($xml_format == 'rdf')
830
-			$data[] = array(
870
+		} elseif ($xml_format == 'rdf') {
871
+					$data[] = array(
831 872
 				'title' => $row['subject'],
832 873
 				'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'],
833 874
 				'description' => $row['body'],
834 875
 			);
835
-		elseif ($xml_format == 'atom')
836
-			$data[] = array(
876
+		} elseif ($xml_format == 'atom') {
877
+					$data[] = array(
837 878
 				'title' => $row['subject'],
838 879
 				'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'],
839 880
 				'summary' => $row['body'],
@@ -847,9 +888,10 @@  discard block
 block discarded – undo
847 888
 				'updated' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', empty($row['modified_time']) ? $row['poster_time'] : $row['modified_time']),
848 889
 				'id' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'],
849 890
 			);
891
+		}
850 892
 		// A lot of information here.  Should be enough to please the rss-ers.
851
-		else
852
-			$data[] = array(
893
+		else {
894
+					$data[] = array(
853 895
 				'time' => $smcFunc['htmlspecialchars'](strip_tags(timeformat($row['poster_time']))),
854 896
 				'id' => $row['id_msg'],
855 897
 				'subject' => $row['subject'],
@@ -876,6 +918,7 @@  discard block
 block discarded – undo
876 918
 				),
877 919
 				'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg']
878 920
 			);
921
+		}
879 922
 	}
880 923
 	$smcFunc['db_free_result']($request);
881 924
 
@@ -895,20 +938,22 @@  discard block
 block discarded – undo
895 938
 	global $scripturl, $memberContext, $user_profile, $user_info;
896 939
 
897 940
 	// You must input a valid user....
898
-	if (empty($_GET['u']) || !loadMemberData((int) $_GET['u']))
899
-		return array();
941
+	if (empty($_GET['u']) || !loadMemberData((int) $_GET['u'])) {
942
+			return array();
943
+	}
900 944
 
901 945
 	// Make sure the id is a number and not "I like trying to hack the database".
902 946
 	$_GET['u'] = (int) $_GET['u'];
903 947
 	// Load the member's contextual information!
904
-	if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view'))
905
-		return array();
948
+	if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view')) {
949
+			return array();
950
+	}
906 951
 
907 952
 	// Okay, I admit it, I'm lazy.  Stupid $_GET['u'] is long and hard to type.
908 953
 	$profile = &$memberContext[$_GET['u']];
909 954
 
910
-	if ($xml_format == 'rss' || $xml_format == 'rss2')
911
-		$data = array(array(
955
+	if ($xml_format == 'rss' || $xml_format == 'rss2') {
956
+			$data = array(array(
912 957
 			'title' => $profile['name'],
913 958
 			'link' => $scripturl . '?action=profile;u=' . $profile['id'],
914 959
 			'description' => isset($profile['group']) ? $profile['group'] : $profile['post_group'],
@@ -916,14 +961,14 @@  discard block
 block discarded – undo
916 961
 			'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $user_profile[$profile['id']]['date_registered']),
917 962
 			'guid' => $scripturl . '?action=profile;u=' . $profile['id'],
918 963
 		));
919
-	elseif ($xml_format == 'rdf')
920
-		$data = array(array(
964
+	} elseif ($xml_format == 'rdf') {
965
+			$data = array(array(
921 966
 			'title' => $profile['name'],
922 967
 			'link' => $scripturl . '?action=profile;u=' . $profile['id'],
923 968
 			'description' => isset($profile['group']) ? $profile['group'] : $profile['post_group'],
924 969
 		));
925
-	elseif ($xml_format == 'atom')
926
-		$data[] = array(
970
+	} elseif ($xml_format == 'atom') {
971
+			$data[] = array(
927 972
 			'title' => $profile['name'],
928 973
 			'link' => $scripturl . '?action=profile;u=' . $profile['id'],
929 974
 			'summary' => isset($profile['group']) ? $profile['group'] : $profile['post_group'],
@@ -937,7 +982,7 @@  discard block
 block discarded – undo
937 982
 			'id' => $scripturl . '?action=profile;u=' . $profile['id'],
938 983
 			'logo' => !empty($profile['avatar']) ? $profile['avatar']['url'] : '',
939 984
 		);
940
-	else
985
+	} else
941 986
 	{
942 987
 		$data = array(
943 988
 			'username' => $user_info['is_admin'] || $user_info['id'] == $profile['id'] ? $profile['username'] : '',
@@ -951,34 +996,43 @@  discard block
 block discarded – undo
951 996
 		);
952 997
 
953 998
 		// Everything below here might not be set, and thus maybe shouldn't be displayed.
954
-		if ($profile['gender']['name'] != '')
955
-			$data['gender'] = $profile['gender']['name'];
999
+		if ($profile['gender']['name'] != '') {
1000
+					$data['gender'] = $profile['gender']['name'];
1001
+		}
956 1002
 
957
-		if ($profile['avatar']['name'] != '')
958
-			$data['avatar'] = $profile['avatar']['url'];
1003
+		if ($profile['avatar']['name'] != '') {
1004
+					$data['avatar'] = $profile['avatar']['url'];
1005
+		}
959 1006
 
960 1007
 		// If they are online, show an empty tag... no reason to put anything inside it.
961
-		if ($profile['online']['is_online'])
962
-			$data['online'] = '';
963
-
964
-		if ($profile['signature'] != '')
965
-			$data['signature'] = $profile['signature'];
966
-		if ($profile['blurb'] != '')
967
-			$data['blurb'] = $profile['blurb'];
968
-		if ($profile['title'] != '')
969
-			$data['title'] = $profile['title'];
970
-
971
-		if ($profile['website']['title'] != '')
972
-			$data['website'] = array(
1008
+		if ($profile['online']['is_online']) {
1009
+					$data['online'] = '';
1010
+		}
1011
+
1012
+		if ($profile['signature'] != '') {
1013
+					$data['signature'] = $profile['signature'];
1014
+		}
1015
+		if ($profile['blurb'] != '') {
1016
+					$data['blurb'] = $profile['blurb'];
1017
+		}
1018
+		if ($profile['title'] != '') {
1019
+					$data['title'] = $profile['title'];
1020
+		}
1021
+
1022
+		if ($profile['website']['title'] != '') {
1023
+					$data['website'] = array(
973 1024
 				'title' => $profile['website']['title'],
974 1025
 				'link' => $profile['website']['url']
975 1026
 			);
1027
+		}
976 1028
 
977
-		if ($profile['group'] != '')
978
-			$data['position'] = $profile['group'];
1029
+		if ($profile['group'] != '') {
1030
+					$data['position'] = $profile['group'];
1031
+		}
979 1032
 
980
-		if ($profile['show_email'])
981
-			$data['email'] = $profile['email'];
1033
+		if ($profile['show_email']) {
1034
+					$data['email'] = $profile['email'];
1035
+		}
982 1036
 
983 1037
 		if (!empty($profile['birth_date']) && substr($profile['birth_date'], 0, 4) != '0000')
984 1038
 		{
Please login to merge, or discard this patch.
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -273,7 +273,6 @@
 block discarded – undo
273 273
  * Modify any setting related to topics.
274 274
  * Requires the admin_forum permission.
275 275
  * Accessed from ?action=admin;area=postsettings;sa=topics.
276
-
277 276
  * @param bool $return_config Whether or not to return the config_vars array (used for admin search)
278 277
  * @return void|array Returns nothing or returns $config_vars if $return_config is true
279 278
  * @uses Admin template, edit_topic_settings sub-template.
Please login to merge, or discard this patch.
Sources/ModerationCenter.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1799,9 +1799,9 @@
 block discarded – undo
1799 1799
 }
1800 1800
 
1801 1801
 /**
1802
-  * Callback for createList().
1803
-  * @return int The total number of warning templates
1804
-  */
1802
+ * Callback for createList().
1803
+ * @return int The total number of warning templates
1804
+ */
1805 1805
 function list_getWarningTemplateCount()
1806 1806
 {
1807 1807
 	global $smcFunc, $user_info;
Please login to merge, or discard this patch.
Braces   +139 added lines, -102 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Entry point for the moderation center.
@@ -26,8 +27,9 @@  discard block
 block discarded – undo
26 27
 	global $txt, $context, $scripturl, $modSettings, $user_info, $sourcedir, $options;
27 28
 
28 29
 	// Don't run this twice... and don't conflict with the admin bar.
29
-	if (isset($context['admin_area']))
30
-		return;
30
+	if (isset($context['admin_area'])) {
31
+			return;
32
+	}
31 33
 
32 34
 	$context['can_moderate_boards'] = $user_info['mod_cache']['bq'] != '0=1';
33 35
 	$context['can_moderate_groups'] = $user_info['mod_cache']['gq'] != '0=1';
@@ -35,8 +37,9 @@  discard block
 block discarded – undo
35 37
 	$context['can_moderate_users'] = allowedTo('moderate_forum');
36 38
 
37 39
 	// Everyone using this area must be allowed here!
38
-	if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users'])
39
-		isAllowedTo('access_mod_center');
40
+	if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) {
41
+			isAllowedTo('access_mod_center');
42
+	}
40 43
 
41 44
 	// We're gonna want a menu of some kind.
42 45
 	require_once($sourcedir . '/Subs-Menu.php');
@@ -195,8 +198,9 @@  discard block
 block discarded – undo
195 198
 	unset($moderation_areas);
196 199
 
197 200
 	// We got something - didn't we? DIDN'T WE!
198
-	if ($mod_include_data == false)
199
-		fatal_lang_error('no_access', false);
201
+	if ($mod_include_data == false) {
202
+			fatal_lang_error('no_access', false);
203
+	}
200 204
 
201 205
 	// Retain the ID information in case required by a subaction.
202 206
 	$context['moderation_menu_id'] = $context['max_menu_id'];
@@ -219,22 +223,25 @@  discard block
 block discarded – undo
219 223
 		'url' => $scripturl . '?action=moderate',
220 224
 		'name' => $txt['moderation_center'],
221 225
 	);
222
-	if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index')
223
-		$context['linktree'][] = array(
226
+	if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') {
227
+			$context['linktree'][] = array(
224 228
 			'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'],
225 229
 			'name' => $mod_include_data['label'],
226 230
 		);
227
-	if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label'])
228
-		$context['linktree'][] = array(
231
+	}
232
+	if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) {
233
+			$context['linktree'][] = array(
229 234
 			'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'] . ';sa=' . $mod_include_data['current_subsection'],
230 235
 			'name' => $mod_include_data['subsections'][$mod_include_data['current_subsection']][0],
231 236
 		);
237
+	}
232 238
 
233 239
 	// Now - finally - the bit before the encore - the main performance of course!
234 240
 	if (!$dont_call)
235 241
 	{
236
-		if (isset($mod_include_data['file']))
237
-			require_once($sourcedir . '/' . $mod_include_data['file']);
242
+		if (isset($mod_include_data['file'])) {
243
+					require_once($sourcedir . '/' . $mod_include_data['file']);
244
+		}
238 245
 
239 246
 		call_helper($mod_include_data['function']);
240 247
 	}
@@ -259,8 +266,9 @@  discard block
 block discarded – undo
259 266
 	// Load what blocks the user actually can see...
260 267
 	$valid_blocks = array();
261 268
 
262
-	if ($context['can_moderate_groups'])
263
-		$valid_blocks['g'] = 'GroupRequests';
269
+	if ($context['can_moderate_groups']) {
270
+			$valid_blocks['g'] = 'GroupRequests';
271
+	}
264 272
 	if ($context['can_moderate_boards'])
265 273
 	{
266 274
 		$valid_blocks['r'] = 'ReportedPosts';
@@ -269,8 +277,9 @@  discard block
 block discarded – undo
269 277
 	if ($context['can_moderate_users'])
270 278
 	{
271 279
 		// This falls under the category of moderating users as well...
272
-		if (!$context['can_moderate_boards'])
273
-			$valid_blocks['w'] = 'WatchedUsers';
280
+		if (!$context['can_moderate_boards']) {
281
+					$valid_blocks['w'] = 'WatchedUsers';
282
+		}
274 283
 
275 284
 		$valid_blocks['rm'] = 'ReportedMembers';
276 285
 	}
@@ -281,8 +290,9 @@  discard block
 block discarded – undo
281 290
 	foreach ($valid_blocks as $k => $block)
282 291
 	{
283 292
 		$block = 'ModBlock' . $block;
284
-		if (function_exists($block))
285
-			$context['mod_blocks'][] = $block();
293
+		if (function_exists($block)) {
294
+					$context['mod_blocks'][] = $block();
295
+		}
286 296
 	}
287 297
 
288 298
 	$context['admin_prefs'] = !empty($options['admin_preferences']) ? smf_json_decode($options['admin_preferences'], true) : array();
@@ -309,8 +319,9 @@  discard block
 block discarded – undo
309 319
 			)
310 320
 		);
311 321
 		$watched_users = array();
312
-		while ($row = $smcFunc['db_fetch_assoc']($request))
313
-			$watched_users[] = $row;
322
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
323
+					$watched_users[] = $row;
324
+		}
314 325
 		$smcFunc['db_free_result']($request);
315 326
 
316 327
 		cache_put_data('recent_user_watches', $watched_users, 240);
@@ -402,8 +413,9 @@  discard block
 block discarded – undo
402 413
 			$note_owner = $smcFunc['db_num_rows']($get_owner);
403 414
 			$smcFunc['db_free_result']($get_owner);
404 415
 
405
-			if (empty($note_owner))
406
-				fatal_lang_error('mc_notes_delete_own', false);
416
+			if (empty($note_owner)) {
417
+							fatal_lang_error('mc_notes_delete_own', false);
418
+			}
407 419
 		}
408 420
 
409 421
 		// Lets delete it.
@@ -460,12 +472,14 @@  discard block
 block discarded – undo
460 472
 			)
461 473
 		);
462 474
 		$moderator_notes = array();
463
-		while ($row = $smcFunc['db_fetch_assoc']($request))
464
-			$moderator_notes[] = $row;
475
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
476
+					$moderator_notes[] = $row;
477
+		}
465 478
 		$smcFunc['db_free_result']($request);
466 479
 
467
-		if ($offset == 0)
468
-			cache_put_data('moderator_notes', $moderator_notes, 240);
480
+		if ($offset == 0) {
481
+					cache_put_data('moderator_notes', $moderator_notes, 240);
482
+		}
469 483
 	}
470 484
 
471 485
 	// Lets construct a page index.
@@ -504,8 +518,9 @@  discard block
 block discarded – undo
504 518
 	// Got the info already?
505 519
 	$cachekey = md5(json_encode($user_info['mod_cache']['bq']));
506 520
 	$context['reported_posts'] = array();
507
-	if ($user_info['mod_cache']['bq'] == '0=1')
508
-		return 'reported_posts_block';
521
+	if ($user_info['mod_cache']['bq'] == '0=1') {
522
+			return 'reported_posts_block';
523
+	}
509 524
 
510 525
 	if (($reported_posts = cache_get_data('reported_posts_' . $cachekey, 90)) === null)
511 526
 	{
@@ -529,8 +544,9 @@  discard block
 block discarded – undo
529 544
 			)
530 545
 		);
531 546
 		$reported_posts = array();
532
-		while ($row = $smcFunc['db_fetch_assoc']($request))
533
-			$reported_posts[] = $row;
547
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
548
+					$reported_posts[] = $row;
549
+		}
534 550
 		$smcFunc['db_free_result']($request);
535 551
 
536 552
 		// Cache it.
@@ -568,8 +584,9 @@  discard block
 block discarded – undo
568 584
 
569 585
 	$context['group_requests'] = array();
570 586
 	// Make sure they can even moderate someone!
571
-	if ($user_info['mod_cache']['gq'] == '0=1')
572
-		return 'group_requests_block';
587
+	if ($user_info['mod_cache']['gq'] == '0=1') {
588
+			return 'group_requests_block';
589
+	}
573 590
 
574 591
 	// What requests are outstanding?
575 592
 	$request = $smcFunc['db_query']('', '
@@ -618,8 +635,9 @@  discard block
 block discarded – undo
618 635
 	// Got the info already?
619 636
 	$cachekey = md5(json_encode((int) allowedTo('moderate_forum')));
620 637
 	$context['reported_users'] = array();
621
-	if (!allowedTo('moderate_forum'))
622
-		return 'reported_users_block';
638
+	if (!allowedTo('moderate_forum')) {
639
+			return 'reported_users_block';
640
+	}
623 641
 
624 642
 	if (($reported_users = cache_get_data('reported_users_' . $cachekey, 90)) === null)
625 643
 	{
@@ -642,8 +660,9 @@  discard block
 block discarded – undo
642 660
 			)
643 661
 		);
644 662
 		$reported_users = array();
645
-		while ($row = $smcFunc['db_fetch_assoc']($request))
646
-			$reported_users[] = $row;
663
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
664
+					$reported_users[] = $row;
665
+		}
647 666
 		$smcFunc['db_free_result']($request);
648 667
 
649 668
 		// Cache it.
@@ -691,8 +710,9 @@  discard block
 block discarded – undo
691 710
 	isAllowedTo('moderate_forum');
692 711
 
693 712
 	// Are they wanting to view a particular report?
694
-	if (!empty($_REQUEST['report']))
695
-		return MemberReport();
713
+	if (!empty($_REQUEST['report'])) {
714
+			return MemberReport();
715
+	}
696 716
 
697 717
 	// Set up the comforting bits...
698 718
 	$context['page_title'] = $txt['mc_reported_members'];
@@ -746,15 +766,15 @@  discard block
 block discarded – undo
746 766
 		// Time to update.
747 767
 		updateSettings(array('last_mod_report_action' => time()));
748 768
 		recountOpenReports('members');
749
-	}
750
-	elseif (isset($_POST['close']) && isset($_POST['close_selected']))
769
+	} elseif (isset($_POST['close']) && isset($_POST['close_selected']))
751 770
 	{
752 771
 		checkSession();
753 772
 
754 773
 		// All the ones to update...
755 774
 		$toClose = array();
756
-		foreach ($_POST['close'] as $rid)
757
-			$toClose[] = (int) $rid;
775
+		foreach ($_POST['close'] as $rid) {
776
+					$toClose[] = (int) $rid;
777
+		}
758 778
 
759 779
 		if (!empty($toClose))
760 780
 		{
@@ -907,8 +927,9 @@  discard block
 block discarded – undo
907 927
 	global $context, $user_info;
908 928
 
909 929
 	// You need to be allowed to moderate groups...
910
-	if ($user_info['mod_cache']['gq'] == '0=1')
911
-		isAllowedTo('manage_membergroups');
930
+	if ($user_info['mod_cache']['gq'] == '0=1') {
931
+			isAllowedTo('manage_membergroups');
932
+	}
912 933
 
913 934
 	// Load the group templates.
914 935
 	loadTemplate('ModerationCenter');
@@ -919,8 +940,9 @@  discard block
 block discarded – undo
919 940
 		'view' => 'ViewGroups',
920 941
 	);
921 942
 
922
-	if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']]))
923
-		$_GET['sa'] = 'view';
943
+	if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) {
944
+			$_GET['sa'] = 'view';
945
+	}
924 946
 	$context['sub_action'] = $_GET['sa'];
925 947
 
926 948
 	// Call the relevant function.
@@ -950,8 +972,9 @@  discard block
 block discarded – undo
950 972
 			'id_notice' => $id_notice,
951 973
 		)
952 974
 	);
953
-	if ($smcFunc['db_num_rows']($request) == 0)
954
-		fatal_lang_error('no_access', false);
975
+	if ($smcFunc['db_num_rows']($request) == 0) {
976
+			fatal_lang_error('no_access', false);
977
+	}
955 978
 	list ($context['notice_body'], $context['notice_subject']) = $smcFunc['db_fetch_row']($request);
956 979
 	$smcFunc['db_free_result']($request);
957 980
 
@@ -988,18 +1011,20 @@  discard block
 block discarded – undo
988 1011
 		checkSession(!is_array($_REQUEST['delete']) ? 'get' : 'post');
989 1012
 
990 1013
 		$toDelete = array();
991
-		if (!is_array($_REQUEST['delete']))
992
-			$toDelete[] = (int) $_REQUEST['delete'];
993
-		else
994
-			foreach ($_REQUEST['delete'] as $did)
1014
+		if (!is_array($_REQUEST['delete'])) {
1015
+					$toDelete[] = (int) $_REQUEST['delete'];
1016
+		} else {
1017
+					foreach ($_REQUEST['delete'] as $did)
995 1018
 				$toDelete[] = (int) $did;
1019
+		}
996 1020
 
997 1021
 		if (!empty($toDelete))
998 1022
 		{
999 1023
 			require_once($sourcedir . '/RemoveTopic.php');
1000 1024
 			// If they don't have permission we'll let it error - either way no chance of a security slip here!
1001
-			foreach ($toDelete as $did)
1002
-				removeMessage($did);
1025
+			foreach ($toDelete as $did) {
1026
+							removeMessage($did);
1027
+			}
1003 1028
 		}
1004 1029
 	}
1005 1030
 
@@ -1008,20 +1033,21 @@  discard block
 block discarded – undo
1008 1033
 	{
1009 1034
 		$approve_query = '';
1010 1035
 		$delete_boards = array();
1011
-	}
1012
-	else
1036
+	} else
1013 1037
 	{
1014 1038
 		// Still obey permissions!
1015 1039
 		$approve_boards = boardsAllowedTo('approve_posts');
1016 1040
 		$delete_boards = boardsAllowedTo('delete_any');
1017 1041
 
1018
-		if ($approve_boards == array(0))
1019
-			$approve_query = '';
1020
-		elseif (!empty($approve_boards))
1021
-			$approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')';
1042
+		if ($approve_boards == array(0)) {
1043
+					$approve_query = '';
1044
+		} elseif (!empty($approve_boards)) {
1045
+					$approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')';
1046
+		}
1022 1047
 		// Nada, zip, etc...
1023
-		else
1024
-			$approve_query = ' AND 1=0';
1048
+		else {
1049
+					$approve_query = ' AND 1=0';
1050
+		}
1025 1051
 	}
1026 1052
 
1027 1053
 	require_once($sourcedir . '/Subs-List.php');
@@ -1120,10 +1146,11 @@  discard block
 block discarded – undo
1120 1146
 				'data' => array(
1121 1147
 					'function' => function($member) use ($scripturl)
1122 1148
 					{
1123
-						if ($member['last_post_id'])
1124
-							return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>';
1125
-						else
1126
-							return $member['last_post'];
1149
+						if ($member['last_post_id']) {
1150
+													return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>';
1151
+						} else {
1152
+													return $member['last_post'];
1153
+						}
1127 1154
 					},
1128 1155
 				),
1129 1156
 			),
@@ -1251,8 +1278,9 @@  discard block
 block discarded – undo
1251 1278
 			)
1252 1279
 		);
1253 1280
 		$latest_posts = array();
1254
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1255
-			$latest_posts[$row['id_member']] = $row['last_post_id'];
1281
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1282
+					$latest_posts[$row['id_member']] = $row['last_post_id'];
1283
+		}
1256 1284
 
1257 1285
 		if (!empty($latest_posts))
1258 1286
 		{
@@ -1443,15 +1471,17 @@  discard block
 block discarded – undo
1443 1471
 	// Setup the direction stuff...
1444 1472
 	$context['order'] = isset($_REQUEST['sort']) && isset($sort_types[$_REQUEST['sort']]) ? $_REQUEST['sort'] : 'member';
1445 1473
 
1446
-	if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search']))
1447
-		$search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search'];
1448
-	else
1449
-		$search_params_string = $search_params['string'];
1474
+	if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) {
1475
+			$search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search'];
1476
+	} else {
1477
+			$search_params_string = $search_params['string'];
1478
+	}
1450 1479
 
1451
-	if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']]))
1452
-		$search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member');
1453
-	else
1454
-		$search_params_type = $search_params['type'];
1480
+	if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) {
1481
+			$search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member');
1482
+	} else {
1483
+			$search_params_type = $search_params['type'];
1484
+	}
1455 1485
 
1456 1486
 	$search_params_column = $searchTypes[$search_params_type]['sql'];
1457 1487
 	$search_params = array(
@@ -1535,9 +1565,10 @@  discard block
 block discarded – undo
1535 1565
 								' . $rowData['reason'] . '
1536 1566
 							</div>';
1537 1567
 
1538
-						if (!empty($rowData['id_notice']))
1539
-							$output .= '
1568
+						if (!empty($rowData['id_notice'])) {
1569
+													$output .= '
1540 1570
 								&nbsp;<a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $rowData['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" class="new_win" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a>';
1571
+						}
1541 1572
 						return $output;
1542 1573
 					},
1543 1574
 				),
@@ -1655,9 +1686,9 @@  discard block
 block discarded – undo
1655 1686
 	global $smcFunc, $modSettings, $context, $txt, $scripturl, $sourcedir, $user_info;
1656 1687
 
1657 1688
 	// Submitting a new one?
1658
-	if (isset($_POST['add']))
1659
-		return ModifyWarningTemplate();
1660
-	elseif (isset($_POST['delete']) && !empty($_POST['deltpl']))
1689
+	if (isset($_POST['add'])) {
1690
+			return ModifyWarningTemplate();
1691
+	} elseif (isset($_POST['delete']) && !empty($_POST['deltpl']))
1661 1692
 	{
1662 1693
 		checkSession();
1663 1694
 		validateToken('mod-wt');
@@ -1676,8 +1707,9 @@  discard block
 block discarded – undo
1676 1707
 				'current_member' => $user_info['id'],
1677 1708
 			)
1678 1709
 		);
1679
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1680
-			logAction('delete_warn_template', array('template' => $row['recipient_name']));
1710
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1711
+					logAction('delete_warn_template', array('template' => $row['recipient_name']));
1712
+		}
1681 1713
 		$smcFunc['db_free_result']($request);
1682 1714
 
1683 1715
 		// Do the deletes.
@@ -1968,16 +2000,18 @@  discard block
 block discarded – undo
1968 2000
 				);
1969 2001
 
1970 2002
 				// If it wasn't visible and now is they've effectively added it.
1971
-				if ($context['template_data']['personal'] && !$recipient_id)
1972
-					logAction('add_warn_template', array('template' => $_POST['template_title']));
2003
+				if ($context['template_data']['personal'] && !$recipient_id) {
2004
+									logAction('add_warn_template', array('template' => $_POST['template_title']));
2005
+				}
1973 2006
 				// Conversely if they made it personal it's a delete.
1974
-				elseif (!$context['template_data']['personal'] && $recipient_id)
1975
-					logAction('delete_warn_template', array('template' => $_POST['template_title']));
2007
+				elseif (!$context['template_data']['personal'] && $recipient_id) {
2008
+									logAction('delete_warn_template', array('template' => $_POST['template_title']));
2009
+				}
1976 2010
 				// Otherwise just an edit.
1977
-				else
1978
-					logAction('modify_warn_template', array('template' => $_POST['template_title']));
1979
-			}
1980
-			else
2011
+				else {
2012
+									logAction('modify_warn_template', array('template' => $_POST['template_title']));
2013
+				}
2014
+			} else
1981 2015
 			{
1982 2016
 				$smcFunc['db_insert']('',
1983 2017
 					'{db_prefix}log_comments',
@@ -1997,17 +2031,18 @@  discard block
 block discarded – undo
1997 2031
 
1998 2032
 			// Get out of town...
1999 2033
 			redirectexit('action=moderate;area=warnings;sa=templates');
2000
-		}
2001
-		else
2034
+		} else
2002 2035
 		{
2003 2036
 			$context['warning_errors'] = array();
2004 2037
 			$context['template_data']['title'] = !empty($_POST['template_title']) ? $_POST['template_title'] : '';
2005 2038
 			$context['template_data']['body'] = !empty($_POST['template_body']) ? $_POST['template_body'] : $txt['mc_warning_template_body_default'];
2006 2039
 			$context['template_data']['personal'] = !empty($_POST['make_personal']);
2007
-			if (empty($_POST['template_title']))
2008
-				$context['warning_errors'][] = $txt['mc_warning_template_error_no_title'];
2009
-			if (empty($_POST['template_body']))
2010
-				$context['warning_errors'][] = $txt['mc_warning_template_error_no_body'];
2040
+			if (empty($_POST['template_title'])) {
2041
+							$context['warning_errors'][] = $txt['mc_warning_template_error_no_title'];
2042
+			}
2043
+			if (empty($_POST['template_body'])) {
2044
+							$context['warning_errors'][] = $txt['mc_warning_template_error_no_body'];
2045
+			}
2011 2046
 		}
2012 2047
 	}
2013 2048
 
@@ -2054,8 +2089,9 @@  discard block
 block discarded – undo
2054 2089
 		// Now check other options!
2055 2090
 		$pref_binary = 0;
2056 2091
 
2057
-		if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval']))
2058
-			$pref_binary |= 4;
2092
+		if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) {
2093
+					$pref_binary |= 4;
2094
+		}
2059 2095
 
2060 2096
 		// Put it all together.
2061 2097
 		$mod_prefs = '0||' . $pref_binary;
@@ -2079,9 +2115,10 @@  discard block
 block discarded – undo
2079 2115
 	unset($_SESSION['moderate_time']);
2080 2116
 
2081 2117
 	// Clean any moderator tokens as well.
2082
-	foreach ($_SESSION['token'] as $key => $token)
2083
-		if (strpos($key, '-mod') !== false)
2118
+	foreach ($_SESSION['token'] as $key => $token) {
2119
+			if (strpos($key, '-mod') !== false)
2084 2120
 			unset($_SESSION['token'][$key]);
2121
+	}
2085 2122
 
2086 2123
 	redirectexit();
2087 2124
 }
Please login to merge, or discard this patch.
Sources/ManagePosts.php 2 patches
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -273,7 +273,6 @@
 block discarded – undo
273 273
  * Modify any setting related to topics.
274 274
  * Requires the admin_forum permission.
275 275
  * Accessed from ?action=admin;area=postsettings;sa=topics.
276
-
277 276
  * @param bool $return_config Whether or not to return the config_vars array (used for admin search)
278 277
  * @return void|array Returns nothing or returns $config_vars if $return_config is true
279 278
  * @uses Admin template, edit_topic_settings sub-template.
Please login to merge, or discard this patch.
Braces   +39 added lines, -29 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * The main entrance point for the 'Posts and topics' screen.
@@ -98,23 +99,23 @@  discard block
 block discarded – undo
98 99
 		{
99 100
 			$_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => '')));
100 101
 
101
-			foreach ($_POST['censortext'] as $c)
102
-				list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, '');
103
-		}
104
-		elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper']))
102
+			foreach ($_POST['censortext'] as $c) {
103
+							list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, '');
104
+			}
105
+		} elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper']))
105 106
 		{
106 107
 			if (is_array($_POST['censor_vulgar']))
107 108
 			{
108 109
 				foreach ($_POST['censor_vulgar'] as $i => $value)
109 110
 				{
110
-					if (trim(strtr($value, '*', ' ')) == '')
111
-						unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]);
111
+					if (trim(strtr($value, '*', ' ')) == '') {
112
+											unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]);
113
+					}
112 114
 				}
113 115
 
114 116
 				$censored_vulgar = $_POST['censor_vulgar'];
115 117
 				$censored_proper = $_POST['censor_proper'];
116
-			}
117
-			else
118
+			} else
118 119
 			{
119 120
 				$censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => '')));
120 121
 				$censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => '')));
@@ -151,12 +152,14 @@  discard block
 block discarded – undo
151 152
 	$context['censored_words'] = array();
152 153
 	for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++)
153 154
 	{
154
-		if (empty($censor_vulgar[$i]))
155
-			continue;
155
+		if (empty($censor_vulgar[$i])) {
156
+					continue;
157
+		}
156 158
 
157 159
 		// Skip it, it's either spaces or stars only.
158
-		if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '')
159
-			continue;
160
+		if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') {
161
+					continue;
162
+		}
160 163
 
161 164
 		$context['censored_words'][$smcFunc['htmlspecialchars'](trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? $smcFunc['htmlspecialchars']($censor_proper[$i]) : '';
162 165
 	}
@@ -187,10 +190,11 @@  discard block
 block discarded – undo
187 190
 
188 191
 	// Make an inline conditional a little shorter...
189 192
 	$can_spell_check = false;
190
-	if (function_exists('pspell_new'))
191
-		$can_spell_check = true;
192
-	elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))
193
-		$can_spell_check = true;
193
+	if (function_exists('pspell_new')) {
194
+			$can_spell_check = true;
195
+	} elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) {
196
+			$can_spell_check = true;
197
+	}
194 198
 
195 199
 	// All the settings...
196 200
 	$config_vars = array(
@@ -221,8 +225,9 @@  discard block
 block discarded – undo
221 225
 
222 226
 	call_integration_hook('integrate_modify_post_settings', array(&$config_vars));
223 227
 
224
-	if ($return_config)
225
-		return $config_vars;
228
+	if ($return_config) {
229
+			return $config_vars;
230
+	}
226 231
 
227 232
 	// We'll want this for our easy save.
228 233
 	require_once($sourcedir . '/ManageServer.php');
@@ -242,17 +247,20 @@  discard block
 block discarded – undo
242 247
 			db_extend('packages');
243 248
 
244 249
 			$colData = $smcFunc['db_list_columns']('{db_prefix}messages', true);
245
-			foreach ($colData as $column)
246
-				if ($column['name'] == 'body')
250
+			foreach ($colData as $column) {
251
+							if ($column['name'] == 'body')
247 252
 					$body_type = $column['type'];
253
+			}
248 254
 
249
-			if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text')
250
-				fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database'));
255
+			if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') {
256
+							fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database'));
257
+			}
251 258
 		}
252 259
 
253 260
 		// If we're changing the post preview length let's check its valid
254
-		if (!empty($_POST['preview_characters']))
255
-			$_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512);
261
+		if (!empty($_POST['preview_characters'])) {
262
+					$_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512);
263
+		}
256 264
 
257 265
 		call_integration_hook('integrate_save_post_settings');
258 266
 
@@ -313,8 +321,9 @@  discard block
 block discarded – undo
313 321
 
314 322
 	call_integration_hook('integrate_modify_topic_settings', array(&$config_vars));
315 323
 
316
-	if ($return_config)
317
-		return $config_vars;
324
+	if ($return_config) {
325
+			return $config_vars;
326
+	}
318 327
 
319 328
 	// Get the settings template ready.
320 329
 	require_once($sourcedir . '/ManageServer.php');
@@ -367,8 +376,9 @@  discard block
 block discarded – undo
367 376
 		array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']),
368 377
 	);
369 378
 
370
-	if ($return_config)
371
-		return $config_vars;
379
+	if ($return_config) {
380
+			return $config_vars;
381
+	}
372 382
 
373 383
 	// Get the settings template ready.
374 384
 	require_once($sourcedir . '/ManageServer.php');
Please login to merge, or discard this patch.
Sources/DbSearch-mysql.php 1 patch
Braces   +13 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  *  Add the file functions to the $smcFunc array.
@@ -23,14 +24,15 @@  discard block
 block discarded – undo
23 24
 {
24 25
 	global $smcFunc;
25 26
 
26
-	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query')
27
-		$smcFunc += array(
27
+	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query') {
28
+			$smcFunc += array(
28 29
 			'db_search_query' => 'smf_db_query',
29 30
 			'db_search_support' => 'smf_db_search_support',
30 31
 			'db_create_word_search' => 'smf_db_create_word_search',
31 32
 			'db_support_ignore' => true,
32 33
 		);
33
-}
34
+	}
35
+	}
34 36
 
35 37
 /**
36 38
  * This function will tell you whether this database type supports this search type.
@@ -54,12 +56,13 @@  discard block
 block discarded – undo
54 56
 {
55 57
 	global $smcFunc;
56 58
 
57
-	if ($size == 'small')
58
-		$size = 'smallint(5)';
59
-	elseif ($size == 'medium')
60
-		$size = 'mediumint(8)';
61
-	else
62
-		$size = 'int(10)';
59
+	if ($size == 'small') {
60
+			$size = 'smallint(5)';
61
+	} elseif ($size == 'medium') {
62
+			$size = 'mediumint(8)';
63
+	} else {
64
+			$size = 'int(10)';
65
+	}
63 66
 
64 67
 	$smcFunc['db_query']('', '
65 68
 		CREATE TABLE {db_prefix}log_search_words (
Please login to merge, or discard this patch.
Sources/Notify.php 1 patch
Braces   +23 added lines, -20 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Turn off/on notification for a particular board.
@@ -34,8 +35,9 @@  discard block
 block discarded – undo
34 35
 	is_not_guest();
35 36
 
36 37
 	// You have to specify a board to turn notifications on!
37
-	if (empty($board))
38
-		fatal_lang_error('no_board', false);
38
+	if (empty($board)) {
39
+			fatal_lang_error('no_board', false);
40
+	}
39 41
 
40 42
 	// No subaction: find out what to do.
41 43
 	if (isset($_GET['mode']))
@@ -48,16 +50,16 @@  discard block
 block discarded – undo
48 50
 		require_once($sourcedir . '/Subs-Notify.php');
49 51
 		setNotifyPrefs($user_info['id'], array('board_notify_' . $board => $alertPref));
50 52
 
51
-		if ($mode > 1)
52
-			// Turn notification on.  (note this just blows smoke if it's already on.)
53
+		if ($mode > 1) {
54
+					// Turn notification on.  (note this just blows smoke if it's already on.)
53 55
 			$smcFunc['db_insert']('ignore',
54 56
 				'{db_prefix}log_notify',
55 57
 				array('id_member' => 'int', 'id_board' => 'int'),
56 58
 				array($user_info['id'], $board),
57 59
 				array('id_member', 'id_board')
58 60
 			);
59
-		else
60
-			$smcFunc['db_query']('', '
61
+		} else {
62
+					$smcFunc['db_query']('', '
61 63
 				DELETE FROM {db_prefix}log_notify
62 64
 				WHERE id_member = {int:current_member}
63 65
 				AND id_board = {int:current_board}',
@@ -66,6 +68,7 @@  discard block
 block discarded – undo
66 68
 					'current_member' => $user_info['id'],
67 69
 				)
68 70
 			);
71
+		}
69 72
 
70 73
 	}
71 74
 
@@ -81,10 +84,10 @@  discard block
 block discarded – undo
81 84
 			),
82 85
 		);
83 86
 		$context['sub_template'] = 'generic_xml';
87
+	} else {
88
+			redirectexit('board=' . $board . '.' . $_REQUEST['start']);
89
+	}
84 90
 	}
85
-	else
86
-		redirectexit('board=' . $board . '.' . $_REQUEST['start']);
87
-}
88 91
 
89 92
 /**
90 93
  * Turn off/on unread replies subscription for a topic as well as sets individual topic's alert preferences
@@ -108,8 +111,9 @@  discard block
 block discarded – undo
108 111
 			$mode = (int) $_GET['mode'];
109 112
 			$alertPref = $mode <= 1 ? 0 : ($mode == 2 ? 1 : 3);
110 113
 
111
-			if (empty($mode))
112
-				$mode = 1;
114
+			if (empty($mode)) {
115
+							$mode = 1;
116
+			}
113 117
 
114 118
 			$request = $smcFunc['db_query']('', '
115 119
 				SELECT id_member, id_topic, id_msg, unwatched
@@ -132,8 +136,7 @@  discard block
 block discarded – undo
132 136
 					'id_msg' => 0,
133 137
 					'unwatched' => empty($mode) ? 1 : 0,
134 138
 				);
135
-			}
136
-			else
139
+			} else
137 140
 			{
138 141
 				$insert = false;
139 142
 				$log['unwatched'] = empty($mode) ? 1 : 0;
@@ -160,9 +163,8 @@  discard block
 block discarded – undo
160 163
 					array($user_info['id'], $log['id_topic']),
161 164
 					array('id_member', 'id_board')
162 165
 				);
163
-			}
164
-			else
165
-				$smcFunc['db_query']('', '
166
+			} else {
167
+							$smcFunc['db_query']('', '
166 168
 					DELETE FROM {db_prefix}log_notify
167 169
 					WHERE id_topic = {int:topic}
168 170
 						AND id_member = {int:member}',
@@ -170,6 +172,7 @@  discard block
 block discarded – undo
170 172
 						'topic' => $log['id_topic'],
171 173
 						'member' => $user_info['id'],
172 174
 					));
175
+			}
173 176
 
174 177
 		}
175 178
 	}
@@ -186,9 +189,9 @@  discard block
 block discarded – undo
186 189
 			),
187 190
 		);
188 191
 		$context['sub_template'] = 'generic_xml';
192
+	} else {
193
+			redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
194
+	}
189 195
 	}
190
-	else
191
-		redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
192
-}
193 196
 
194 197
 ?>
195 198
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Attachments.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		// Just send a generic message.
77 77
 		else
78 78
 			$this->setResponse(array(
79
-				'text' => $this->_sa == 'add' ? 'attach_error_title' :   'attached_file_deleted_error',
79
+				'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error',
80 80
 				'type' => 'error',
81 81
 				'data' => false,
82 82
 			));
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 			// Gotta urlencode the filename.
405 405
 			if ($this->_attachResults)
406 406
 				foreach ($this->_attachResults as $k => $v)
407
-					$this->_attachResults[$k]['name'] =  urlencode($this->_attachResults[$k]['name']);
407
+					$this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']);
408 408
 
409 409
 			$this->_response = array(
410 410
 				'files' => $this->_attachResults ? $this->_attachResults : false,
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 			ob_start();
432 432
 
433 433
 		// Set the header.
434
-		header('Content-Type: application/json; charset='. $context['character_set'] .'');
434
+		header('Content-Type: application/json; charset=' . $context['character_set'] . '');
435 435
 
436 436
 		echo json_encode($this->_response ? $this->_response : array());
437 437
 
Please login to merge, or discard this patch.
Braces   +102 added lines, -76 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 class Attachments
20 21
 {
@@ -70,16 +71,18 @@  discard block
 block discarded – undo
70 71
 
71 72
 		$this->_sa = !empty($_REQUEST['sa']) ? $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($_REQUEST['sa'])) : false;
72 73
 
73
-		if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions))
74
-			$this->{$this->_sa}();
74
+		if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) {
75
+					$this->{$this->_sa}();
76
+		}
75 77
 
76 78
 		// Just send a generic message.
77
-		else
78
-			$this->setResponse(array(
79
+		else {
80
+					$this->setResponse(array(
79 81
 				'text' => $this->_sa == 'add' ? 'attach_error_title' :   'attached_file_deleted_error',
80 82
 				'type' => 'error',
81 83
 				'data' => false,
82 84
 			));
85
+		}
83 86
 
84 87
 		// Back to the future, oh, to the browser!
85 88
 		$this->sendResponse();
@@ -95,12 +98,13 @@  discard block
 block discarded – undo
95 98
 		$attachID = !empty($_REQUEST['attach']) && is_numeric($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : 0;
96 99
 
97 100
 		// Need something to work with.
98
-		if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID])))
99
-			return $this->setResponse(array(
101
+		if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) {
102
+					return $this->setResponse(array(
100 103
 				'text' => 'attached_file_deleted_error',
101 104
 				'type' => 'error',
102 105
 				'data' => false,
103 106
 			));
107
+		}
104 108
 
105 109
 		// Lets pass some params and see what happens :P
106 110
 		$affectedMessage = removeAttachments(array('id_attach' => $attachID), '', true, true);
@@ -121,19 +125,21 @@  discard block
 block discarded – undo
121 125
 		$result = array();
122 126
 
123 127
 		// You gotta be able to post attachments.
124
-		if (!$this->_canPostAttachment)
125
-			return $this->setResponse(array(
128
+		if (!$this->_canPostAttachment) {
129
+					return $this->setResponse(array(
126 130
 				'text' => 'attached_file_cannot',
127 131
 				'type' => 'error',
128 132
 				'data' => false,
129 133
 			));
134
+		}
130 135
 
131 136
 		// Process them at once!
132 137
 		$this->processAttachments();
133 138
 
134 139
 		// The attachments was created and moved the the right folder, time to update the DB.
135
-		if (!empty($_SESSION['temp_attachments']))
136
-			$this->createAtttach();
140
+		if (!empty($_SESSION['temp_attachments'])) {
141
+					$this->createAtttach();
142
+		}
137 143
 
138 144
 		// Set the response.
139 145
 		$this->setResponse();
@@ -146,8 +152,9 @@  discard block
 block discarded – undo
146 152
 	{
147 153
 		global $context, $modSettings, $smcFunc, $user_info, $txt;
148 154
 
149
-		if (!isset($_FILES['attachment']['name']))
150
-			$_FILES['attachment']['tmp_name'] = array();
155
+		if (!isset($_FILES['attachment']['name'])) {
156
+					$_FILES['attachment']['tmp_name'] = array();
157
+		}
151 158
 
152 159
 		// If there are attachments, calculate the total size and how many.
153 160
 		$context['attachments']['total_size'] = 0;
@@ -157,25 +164,30 @@  discard block
 block discarded – undo
157 164
 		if (isset($_REQUEST['msg']))
158 165
 		{
159 166
 			$context['attachments']['quantity'] = count($context['current_attachments']);
160
-			foreach ($context['current_attachments'] as $attachment)
161
-				$context['attachments']['total_size'] += $attachment['size'];
167
+			foreach ($context['current_attachments'] as $attachment) {
168
+							$context['attachments']['total_size'] += $attachment['size'];
169
+			}
162 170
 		}
163 171
 
164 172
 		// A bit of house keeping first.
165
-		if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1)
166
-			unset($_SESSION['temp_attachments']);
173
+		if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) {
174
+					unset($_SESSION['temp_attachments']);
175
+		}
167 176
 
168 177
 		// Our infamous SESSION var, we are gonna have soo much fun with it!
169
-		if (!isset($_SESSION['temp_attachments']))
170
-			$_SESSION['temp_attachments'] = array();
178
+		if (!isset($_SESSION['temp_attachments'])) {
179
+					$_SESSION['temp_attachments'] = array();
180
+		}
171 181
 
172 182
 		// Make sure we're uploading to the right place.
173
-		if (!empty($modSettings['automanage_attachments']))
174
-			automanage_attachments_check_directory();
183
+		if (!empty($modSettings['automanage_attachments'])) {
184
+					automanage_attachments_check_directory();
185
+		}
175 186
 
176 187
 		// Is the attachments folder actually there?
177
-		if (!empty($context['dir_creation_error']))
178
-			$this->_generalErrors[] = $context['dir_creation_error'];
188
+		if (!empty($context['dir_creation_error'])) {
189
+					$this->_generalErrors[] = $context['dir_creation_error'];
190
+		}
179 191
 
180 192
 		// The current attach folder ha some issues...
181 193
 		elseif (!is_dir($this->_attchDir))
@@ -200,13 +212,12 @@  discard block
 block discarded – undo
200 212
 			);
201 213
 			list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request);
202 214
 			$smcFunc['db_free_result']($request);
203
-		}
204
-
205
-		else
206
-			$context['attachments'] = array(
215
+		} else {
216
+					$context['attachments'] = array(
207 217
 				'quantity' => 0,
208 218
 				'total_size' => 0,
209 219
 			);
220
+		}
210 221
 
211 222
 		// Check for other general errors here.
212 223
 
@@ -214,9 +225,10 @@  discard block
 block discarded – undo
214 225
 		if (!empty($this->_generalErrors))
215 226
 		{
216 227
 			// And delete the files 'cos they ain't going nowhere.
217
-			foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
218
-				if (file_exists($_FILES['attachment']['tmp_name'][$n]))
228
+			foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) {
229
+							if (file_exists($_FILES['attachment']['tmp_name'][$n]))
219 230
 					unlink($_FILES['attachment']['tmp_name'][$n]);
231
+			}
220 232
 
221 233
 			$_FILES['attachment']['tmp_name'] = array();
222 234
 
@@ -227,26 +239,29 @@  discard block
 block discarded – undo
227 239
 		// Loop through $_FILES['attachment'] array and move each file to the current attachments folder.
228 240
 		foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
229 241
 		{
230
-			if ($_FILES['attachment']['name'][$n] == '')
231
-				continue;
242
+			if ($_FILES['attachment']['name'][$n] == '') {
243
+							continue;
244
+			}
232 245
 
233 246
 			// First, let's first check for PHP upload errors.
234 247
 			$errors = array();
235 248
 			if (!empty($_FILES['attachment']['error'][$n]))
236 249
 			{
237
-				if ($_FILES['attachment']['error'][$n] == 2)
238
-					$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
239
-
240
-				else
241
-					log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]);
250
+				if ($_FILES['attachment']['error'][$n] == 2) {
251
+									$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
252
+				} else {
253
+									log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]);
254
+				}
242 255
 
243 256
 				// Log this one, because...
244
-				if ($_FILES['attachment']['error'][$n] == 6)
245
-					log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical');
257
+				if ($_FILES['attachment']['error'][$n] == 6) {
258
+									log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical');
259
+				}
246 260
 
247 261
 				// Weird, no errors were cached, still fill out a generic one.
248
-				if (empty($errors))
249
-					$errors[] = 'attach_php_error';
262
+				if (empty($errors)) {
263
+									$errors[] = 'attach_php_error';
264
+				}
250 265
 			}
251 266
 
252 267
 			// Try to move and rename the file before doing any more checks on it.
@@ -266,16 +281,18 @@  discard block
 block discarded – undo
266 281
 				);
267 282
 
268 283
 				// Move the file to the attachments folder with a temp name for now.
269
-				if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName))
270
-					smf_chmod($destName, 0644);
284
+				if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) {
285
+									smf_chmod($destName, 0644);
286
+				}
271 287
 
272 288
 				// This is madness!!
273 289
 				else
274 290
 				{
275 291
 					// File couldn't be moved.
276 292
 					$_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout';
277
-					if (file_exists($_FILES['attachment']['tmp_name'][$n]))
278
-						unlink($_FILES['attachment']['tmp_name'][$n]);
293
+					if (file_exists($_FILES['attachment']['tmp_name'][$n])) {
294
+											unlink($_FILES['attachment']['tmp_name'][$n]);
295
+					}
279 296
 				}
280 297
 			}
281 298
 
@@ -288,13 +305,15 @@  discard block
 block discarded – undo
288 305
 					'errors' => $errors,
289 306
 				);
290 307
 
291
-				if (file_exists($_FILES['attachment']['tmp_name'][$n]))
292
-					unlink($_FILES['attachment']['tmp_name'][$n]);
308
+				if (file_exists($_FILES['attachment']['tmp_name'][$n])) {
309
+									unlink($_FILES['attachment']['tmp_name'][$n]);
310
+				}
293 311
 			}
294 312
 
295 313
 			// If there's no errors to this point. We still do need to apply some additional checks before we are finished.
296
-			if (empty($_SESSION['temp_attachments'][$attachID]['errors']))
297
-				attachmentChecks($attachID);
314
+			if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) {
315
+							attachmentChecks($attachID);
316
+			}
298 317
 		}
299 318
 
300 319
 		// Mod authors, finally a hook to hang an alternate attachment upload system upon
@@ -333,23 +352,24 @@  discard block
 block discarded – undo
333 352
 				'errors' => $attachment['errors'],
334 353
 			);
335 354
 
336
-			if (empty($attachment['errors']))
337
-				if (createAttachment($attachmentOptions))
355
+			if (empty($attachment['errors'])) {
356
+							if (createAttachment($attachmentOptions))
338 357
 				{
339 358
 					// Avoid JS getting confused.
340 359
 					$attachmentOptions['attachID'] = $attachmentOptions['id'];
360
+			}
341 361
 					unset($attachmentOptions['id']);
342 362
 
343 363
 					$_SESSION['already_attached'][$attachmentOptions['attachID']] = $attachmentOptions['attachID'];
344 364
 
345
-					if (!empty($attachmentOptions['thumb']))
346
-						$_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb'];
347
-
348
-					if ($this->_msg)
349
-						assignAttachments($_SESSION['already_attached'], $this->_msg);
350
-				}
365
+					if (!empty($attachmentOptions['thumb'])) {
366
+											$_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb'];
367
+					}
351 368
 
352
-			elseif (!empty($attachmentOptions['errors']))
369
+					if ($this->_msg) {
370
+											assignAttachments($_SESSION['already_attached'], $this->_msg);
371
+					}
372
+				} elseif (!empty($attachmentOptions['errors']))
353 373
 			{
354 374
 				// Sort out the errors for display and delete any associated files.
355 375
 				$log_these = array('attachments_no_create', 'attachments_no_write', 'attach_timeout', 'ran_out_of_space', 'cant_access_upload_path', 'attach_0_byte_file');
@@ -361,14 +381,16 @@  discard block
 block discarded – undo
361 381
 					if (!is_array($error))
362 382
 					{
363 383
 						$attachmentOptions['errors'][] = $txt[$error];
364
-						if (in_array($error, $log_these))
365
-							log_error($attachment['name'] . ': ' . $txt[$error], 'critical');
384
+						if (in_array($error, $log_these)) {
385
+													log_error($attachment['name'] . ': ' . $txt[$error], 'critical');
386
+						}
387
+					} else {
388
+											$attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]);
366 389
 					}
367
-					else
368
-						$attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]);
369 390
 				}
370
-				if (file_exists($attachment['tmp_name']))
371
-					unlink($attachment['tmp_name']);
391
+				if (file_exists($attachment['tmp_name'])) {
392
+									unlink($attachment['tmp_name']);
393
+				}
372 394
 			}
373 395
 
374 396
 			// Regardless of errors, pass the results.
@@ -376,8 +398,9 @@  discard block
 block discarded – undo
376 398
 		}
377 399
 
378 400
 		// Temp save this on the db.
379
-		if (!empty($_SESSION['already_attached']))
380
-			$this->_attachSuccess = $_SESSION['already_attached'];
401
+		if (!empty($_SESSION['already_attached'])) {
402
+					$this->_attachSuccess = $_SESSION['already_attached'];
403
+		}
381 404
 
382 405
 		unset($_SESSION['temp_attachments']);
383 406
 	}
@@ -397,14 +420,16 @@  discard block
 block discarded – undo
397 420
 		if ($this->_sa == 'add')
398 421
 		{
399 422
 			// Is there any generic errors? made some sense out of them!
400
-			if ($this->_generalErrors)
401
-				foreach ($this->_generalErrors as $k => $v)
423
+			if ($this->_generalErrors) {
424
+							foreach ($this->_generalErrors as $k => $v)
402 425
 					$this->_generalErrors[$k] = (is_array($v) ? vsprintf($txt[$v[0]], $v[1]) : $txt[$v]);
426
+			}
403 427
 
404 428
 			// Gotta urlencode the filename.
405
-			if ($this->_attachResults)
406
-				foreach ($this->_attachResults as $k => $v)
429
+			if ($this->_attachResults) {
430
+							foreach ($this->_attachResults as $k => $v)
407 431
 					$this->_attachResults[$k]['name'] =  urlencode($this->_attachResults[$k]['name']);
432
+			}
408 433
 
409 434
 			$this->_response = array(
410 435
 				'files' => $this->_attachResults ? $this->_attachResults : false,
@@ -413,9 +438,10 @@  discard block
 block discarded – undo
413 438
 		}
414 439
 
415 440
 		// Rest of us mere mortals gets no special treatment...
416
-		elseif (!empty($data))
417
-			if (!empty($data['text']) && !empty($txt[$data['text']]))
441
+		elseif (!empty($data)) {
442
+					if (!empty($data['text']) && !empty($txt[$data['text']]))
418 443
 				$this->_response['text'] = $txt[$data['text']];
444
+		}
419 445
 	}
420 446
 
421 447
 	protected function sendResponse()
@@ -424,11 +450,11 @@  discard block
 block discarded – undo
424 450
 
425 451
 		ob_end_clean();
426 452
 
427
-		if (!empty($modSettings['CompressedOutput']))
428
-			@ob_start('ob_gzhandler');
429
-
430
-		else
431
-			ob_start();
453
+		if (!empty($modSettings['CompressedOutput'])) {
454
+					@ob_start('ob_gzhandler');
455
+		} else {
456
+					ob_start();
457
+		}
432 458
 
433 459
 		// Set the header.
434 460
 		header('Content-Type: application/json; charset='. $context['character_set'] .'');
Please login to merge, or discard this patch.
Sources/CacheAPI-zend.php 1 patch
Braces   +15 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 3
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * Our Cache API class
@@ -29,8 +30,9 @@  discard block
 block discarded – undo
29 30
 
30 31
 		$supported = function_exists('zend_shm_cache_fetch') || function_exists('output_cache_get');
31 32
 
32
-		if ($test)
33
-			return $supported;
33
+		if ($test) {
34
+					return $supported;
35
+		}
34 36
 		return parent::isSupported() && $supported;
35 37
 	}
36 38
 
@@ -42,10 +44,11 @@  discard block
 block discarded – undo
42 44
 		$key = $this->prefix . strtr($key, ':/', '-_');
43 45
 
44 46
 		// Zend's pricey stuff.
45
-		if (function_exists('zend_shm_cache_fetch'))
46
-			return zend_shm_cache_fetch('SMF::' . $key);
47
-		elseif (function_exists('output_cache_get'))
48
-			return output_cache_get($key, $ttl);
47
+		if (function_exists('zend_shm_cache_fetch')) {
48
+					return zend_shm_cache_fetch('SMF::' . $key);
49
+		} elseif (function_exists('output_cache_get')) {
50
+					return output_cache_get($key, $ttl);
51
+		}
49 52
 	}
50 53
 
51 54
 	/**
@@ -55,10 +58,11 @@  discard block
 block discarded – undo
55 58
 	{
56 59
 		$key = $this->prefix . strtr($key, ':/', '-_');
57 60
 
58
-		if (function_exists('zend_shm_cache_store'))
59
-			return zend_shm_cache_store('SMF::' . $key, $value, $ttl);
60
-		elseif (function_exists('output_cache_put'))
61
-			return output_cache_put($key, $value);
61
+		if (function_exists('zend_shm_cache_store')) {
62
+					return zend_shm_cache_store('SMF::' . $key, $value, $ttl);
63
+		} elseif (function_exists('output_cache_put')) {
64
+					return output_cache_put($key, $value);
65
+		}
62 66
 	}
63 67
 
64 68
 	/**
Please login to merge, or discard this patch.