Completed
Push — release-2.1 ( 74a358...beb067 )
by
unknown
12s
created
Sources/Modlog.php 1 patch
Braces   +99 added lines, -75 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Prepares the information from the moderation log for viewing.
@@ -32,14 +33,16 @@  discard block
 block discarded – undo
32 33
 
33 34
 	// Are we looking at the moderation log or the administration log.
34 35
 	$context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1;
35
-	if ($context['log_type'] == 3)
36
-		isAllowedTo('admin_forum');
36
+	if ($context['log_type'] == 3) {
37
+			isAllowedTo('admin_forum');
38
+	}
37 39
 
38 40
 	// These change dependant on whether we are viewing the moderation or admin log.
39
-	if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin')
40
-		$context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type'];
41
-	else
42
-		$context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type'];
41
+	if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') {
42
+			$context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type'];
43
+	} else {
44
+			$context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type'];
45
+	}
43 46
 
44 47
 	$context['can_delete'] = allowedTo('admin_forum');
45 48
 
@@ -67,8 +70,7 @@  discard block
 block discarded – undo
67 70
 		$log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate';
68 71
 		logAction('clearlog_' . $log_type, array(), $log_type);
69 72
 
70
-	}
71
-	elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete'])
73
+	} elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete'])
72 74
 	{
73 75
 		checkSession();
74 76
 		validateToken('mod-ml');
@@ -114,15 +116,17 @@  discard block
 block discarded – undo
114 116
 		'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip'])
115 117
 	);
116 118
 
117
-	if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search']))
118
-		$search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search'];
119
-	else
120
-		$search_params_string = $search_params['string'];
119
+	if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) {
120
+			$search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search'];
121
+	} else {
122
+			$search_params_string = $search_params['string'];
123
+	}
121 124
 
122
-	if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']]))
123
-		$search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member');
124
-	else
125
-		$search_params_type = $search_params['type'];
125
+	if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) {
126
+			$search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member');
127
+	} else {
128
+			$search_params_type = $search_params['type'];
129
+	}
126 130
 
127 131
 	$search_params_column = $searchTypes[$search_params_type]['sql'];
128 132
 	$search_params = array(
@@ -301,15 +305,16 @@  discard block
 block discarded – undo
301 305
 	$context['default_list'] = 'moderation_log_list';
302 306
 
303 307
 	// If a hook has changed this, respect it.
304
-	if (!empty($moderation_menu_name))
305
-		$context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name;
306
-	elseif (isset($context['moderation_menu_name']))
307
-		$context[$context['moderation_menu_name']]['tab_data'] = array(
308
+	if (!empty($moderation_menu_name)) {
309
+			$context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name;
310
+	} elseif (isset($context['moderation_menu_name'])) {
311
+			$context[$context['moderation_menu_name']]['tab_data'] = array(
308 312
 			'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'],
309 313
 			'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog',
310 314
 			'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc']
311 315
 		);
312
-}
316
+	}
317
+	}
313 318
 
314 319
 /**
315 320
  * Get the number of mod log entries.
@@ -413,30 +418,35 @@  discard block
 block discarded – undo
413 418
 		// Add on some of the column stuff info
414 419
 		if (!empty($row['id_board']))
415 420
 		{
416
-			if ($row['action'] == 'move')
417
-				$row['extra']['board_to'] = $row['id_board'];
418
-			else
419
-				$row['extra']['board'] = $row['id_board'];
421
+			if ($row['action'] == 'move') {
422
+							$row['extra']['board_to'] = $row['id_board'];
423
+			} else {
424
+							$row['extra']['board'] = $row['id_board'];
425
+			}
420 426
 		}
421 427
 
422
-		if (!empty($row['id_topic']))
423
-			$row['extra']['topic'] = $row['id_topic'];
424
-		if (!empty($row['id_msg']))
425
-			$row['extra']['message'] = $row['id_msg'];
428
+		if (!empty($row['id_topic'])) {
429
+					$row['extra']['topic'] = $row['id_topic'];
430
+		}
431
+		if (!empty($row['id_msg'])) {
432
+					$row['extra']['message'] = $row['id_msg'];
433
+		}
426 434
 
427 435
 		// Is this associated with a topic?
428
-		if (isset($row['extra']['topic']))
429
-			$topics[(int) $row['extra']['topic']][] = $row['id_action'];
430
-		if (isset($row['extra']['new_topic']))
431
-			$topics[(int) $row['extra']['new_topic']][] = $row['id_action'];
436
+		if (isset($row['extra']['topic'])) {
437
+					$topics[(int) $row['extra']['topic']][] = $row['id_action'];
438
+		}
439
+		if (isset($row['extra']['new_topic'])) {
440
+					$topics[(int) $row['extra']['new_topic']][] = $row['id_action'];
441
+		}
432 442
 
433 443
 		// How about a member?
434 444
 		if (isset($row['extra']['member']))
435 445
 		{
436 446
 			// Guests don't have names!
437
-			if (empty($row['extra']['member']))
438
-				$row['extra']['member'] = $txt['modlog_parameter_guest'];
439
-			else
447
+			if (empty($row['extra']['member'])) {
448
+							$row['extra']['member'] = $txt['modlog_parameter_guest'];
449
+			} else
440 450
 			{
441 451
 				// Try to find it...
442 452
 				$members[(int) $row['extra']['member']][] = $row['id_action'];
@@ -444,35 +454,42 @@  discard block
 block discarded – undo
444 454
 		}
445 455
 
446 456
 		// Associated with a board?
447
-		if (isset($row['extra']['board_to']))
448
-			$boards[(int) $row['extra']['board_to']][] = $row['id_action'];
449
-		if (isset($row['extra']['board_from']))
450
-			$boards[(int) $row['extra']['board_from']][] = $row['id_action'];
451
-		if (isset($row['extra']['board']))
452
-			$boards[(int) $row['extra']['board']][] = $row['id_action'];
457
+		if (isset($row['extra']['board_to'])) {
458
+					$boards[(int) $row['extra']['board_to']][] = $row['id_action'];
459
+		}
460
+		if (isset($row['extra']['board_from'])) {
461
+					$boards[(int) $row['extra']['board_from']][] = $row['id_action'];
462
+		}
463
+		if (isset($row['extra']['board'])) {
464
+					$boards[(int) $row['extra']['board']][] = $row['id_action'];
465
+		}
453 466
 
454 467
 		// A message?
455
-		if (isset($row['extra']['message']))
456
-			$messages[(int) $row['extra']['message']][] = $row['id_action'];
468
+		if (isset($row['extra']['message'])) {
469
+					$messages[(int) $row['extra']['message']][] = $row['id_action'];
470
+		}
457 471
 
458 472
 		// IP Info?
459
-		if (isset($row['extra']['ip_range']))
460
-			if ($seeIP)
473
+		if (isset($row['extra']['ip_range'])) {
474
+					if ($seeIP)
461 475
 				$row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>';
462
-			else
463
-				$row['extra']['ip_range'] = $txt['logged'];
476
+		} else {
477
+							$row['extra']['ip_range'] = $txt['logged'];
478
+			}
464 479
 
465 480
 		// Email?
466
-		if (isset($row['extra']['email']))
467
-			$row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>';
481
+		if (isset($row['extra']['email'])) {
482
+					$row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>';
483
+		}
468 484
 
469 485
 		// Bans are complex.
470 486
 		if ($row['action'] == 'ban' || $row['action'] == 'banremove')
471 487
 		{
472 488
 			$row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')];
473
-			foreach (array('member', 'email', 'ip_range', 'hostname') as $type)
474
-				if (isset($row['extra'][$type]))
489
+			foreach (array('member', 'email', 'ip_range', 'hostname') as $type) {
490
+							if (isset($row['extra'][$type]))
475 491
 					$row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type];
492
+			}
476 493
 		}
477 494
 
478 495
 		// The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details.
@@ -508,12 +525,13 @@  discard block
 block discarded – undo
508 525
 			foreach ($boards[$row['id_board']] as $action)
509 526
 			{
510 527
 				// Make the board number into a link - dealing with moving too.
511
-				if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board'])
512
-					$entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
513
-				elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board'])
514
-					$entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
515
-				elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board'])
516
-					$entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
528
+				if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) {
529
+									$entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
530
+				} elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) {
531
+									$entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
532
+				} elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) {
533
+									$entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
534
+				}
517 535
 			}
518 536
 		}
519 537
 		$smcFunc['db_free_result']($request);
@@ -547,10 +565,11 @@  discard block
 block discarded – undo
547 565
 				);
548 566
 
549 567
 				// Make the topic number into a link - dealing with splitting too.
550
-				if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic'])
551
-					$this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
552
-				elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic'])
553
-					$this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
568
+				if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) {
569
+									$this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
570
+				} elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) {
571
+									$this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
572
+				}
554 573
 			}
555 574
 		}
556 575
 		$smcFunc['db_free_result']($request);
@@ -583,8 +602,9 @@  discard block
 block discarded – undo
583 602
 				);
584 603
 
585 604
 				// Make the message number into a link.
586
-				if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg'])
587
-					$this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
605
+				if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) {
606
+									$this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
607
+				}
588 608
 			}
589 609
 		}
590 610
 		$smcFunc['db_free_result']($request);
@@ -624,25 +644,29 @@  discard block
 block discarded – undo
624 644
 	foreach ($entries as $k => $entry)
625 645
 	{
626 646
 		// Make any message info links so its easier to go find that message.
627
-		if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id'])))
628
-			$entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>';
647
+		if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) {
648
+					$entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>';
649
+		}
629 650
 
630 651
 		// Mark up any deleted members, topics and boards.
631
-		foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type)
632
-			if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type]))
652
+		foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) {
653
+					if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type]))
633 654
 				$entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]);
655
+		}
634 656
 
635 657
 		if (isset($entry['extra']['report']))
636 658
 		{
637 659
 			// Member profile reports go in a different area
638
-			if (stristr($entry['action'], 'user_report'))
639
-				$entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>';
640
-			else
641
-				$entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>';
660
+			if (stristr($entry['action'], 'user_report')) {
661
+							$entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>';
662
+			} else {
663
+							$entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>';
664
+			}
642 665
 		}
643 666
 
644
-		if (empty($entries[$k]['action_text']))
645
-			$entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action'];
667
+		if (empty($entries[$k]['action_text'])) {
668
+					$entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action'];
669
+		}
646 670
 		$entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i',
647 671
 			function ($matches) use ($entries, $k)
648 672
 			{
Please login to merge, or discard this patch.
Sources/Subs-Db-postgresql.php 1 patch
Braces   +226 added lines, -167 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Maps the implementations in this file (smf_db_function_name)
@@ -34,8 +35,8 @@  discard block
 block discarded – undo
34 35
 	global $smcFunc;
35 36
 
36 37
 	// Map some database specific functions, only do this once.
37
-	if (!isset($smcFunc['db_fetch_assoc']))
38
-		$smcFunc += array(
38
+	if (!isset($smcFunc['db_fetch_assoc'])) {
39
+			$smcFunc += array(
39 40
 			'db_query' => 'smf_db_query',
40 41
 			'db_quote' => 'smf_db_quote',
41 42
 			'db_insert' => 'smf_db_insert',
@@ -62,11 +63,13 @@  discard block
 block discarded – undo
62 63
 			'db_ping' => 'pg_ping',
63 64
 			'db_fetch_all' => 'smf_db_fetch_all',
64 65
 		);
66
+	}
65 67
 
66
-	if (!empty($db_options['persist']))
67
-		$connection = @pg_pconnect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\''));
68
-	else
69
-		$connection = @pg_connect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\''));
68
+	if (!empty($db_options['persist'])) {
69
+			$connection = @pg_pconnect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\''));
70
+	} else {
71
+			$connection = @pg_connect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\''));
72
+	}
70 73
 
71 74
 	// Something's wrong, show an error if its fatal (which we assume it is)
72 75
 	if (!$connection)
@@ -74,8 +77,7 @@  discard block
 block discarded – undo
74 77
 		if (!empty($db_options['non_fatal']))
75 78
 		{
76 79
 			return null;
77
-		}
78
-		else
80
+		} else
79 81
 		{
80 82
 			display_db_error();
81 83
 		}
@@ -126,31 +128,38 @@  discard block
 block discarded – undo
126 128
 
127 129
 	list ($values, $connection) = $db_callback;
128 130
 
129
-	if ($matches[1] === 'db_prefix')
130
-		return $db_prefix;
131
+	if ($matches[1] === 'db_prefix') {
132
+			return $db_prefix;
133
+	}
131 134
 
132
-	if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false)
133
-		return $user_info[$matches[1]];
135
+	if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) {
136
+			return $user_info[$matches[1]];
137
+	}
134 138
 
135
-	if ($matches[1] === 'empty')
136
-		return '\'\'';
139
+	if ($matches[1] === 'empty') {
140
+			return '\'\'';
141
+	}
137 142
 
138
-	if (!isset($matches[2]))
139
-		smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
143
+	if (!isset($matches[2])) {
144
+			smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
145
+	}
140 146
 
141
-	if ($matches[1] === 'literal')
142
-		return '\'' . pg_escape_string($matches[2]) . '\'';
147
+	if ($matches[1] === 'literal') {
148
+			return '\'' . pg_escape_string($matches[2]) . '\'';
149
+	}
143 150
 
144
-	if (!isset($values[$matches[2]]))
145
-		smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__);
151
+	if (!isset($values[$matches[2]])) {
152
+			smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__);
153
+	}
146 154
 
147 155
 	$replacement = $values[$matches[2]];
148 156
 
149 157
 	switch ($matches[1])
150 158
 	{
151 159
 		case 'int':
152
-			if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement)
153
-				smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
160
+			if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) {
161
+							smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
162
+			}
154 163
 			return (string) (int) $replacement;
155 164
 		break;
156 165
 
@@ -162,65 +171,73 @@  discard block
 block discarded – undo
162 171
 		case 'array_int':
163 172
 			if (is_array($replacement))
164 173
 			{
165
-				if (empty($replacement))
166
-					smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
174
+				if (empty($replacement)) {
175
+									smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
176
+				}
167 177
 
168 178
 				foreach ($replacement as $key => $value)
169 179
 				{
170
-					if (!is_numeric($value) || (string) $value !== (string) (int) $value)
171
-						smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
180
+					if (!is_numeric($value) || (string) $value !== (string) (int) $value) {
181
+											smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
182
+					}
172 183
 
173 184
 					$replacement[$key] = (string) (int) $value;
174 185
 				}
175 186
 
176 187
 				return implode(', ', $replacement);
188
+			} else {
189
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
177 190
 			}
178
-			else
179
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
180 191
 
181 192
 		break;
182 193
 
183 194
 		case 'array_string':
184 195
 			if (is_array($replacement))
185 196
 			{
186
-				if (empty($replacement))
187
-					smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
197
+				if (empty($replacement)) {
198
+									smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
199
+				}
188 200
 
189
-				foreach ($replacement as $key => $value)
190
-					$replacement[$key] = sprintf('\'%1$s\'', pg_escape_string($value));
201
+				foreach ($replacement as $key => $value) {
202
+									$replacement[$key] = sprintf('\'%1$s\'', pg_escape_string($value));
203
+				}
191 204
 
192 205
 				return implode(', ', $replacement);
206
+			} else {
207
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
193 208
 			}
194
-			else
195
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
196 209
 		break;
197 210
 
198 211
 		case 'date':
199
-			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1)
200
-				return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]).'::date';
201
-			else
202
-				smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
212
+			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) {
213
+							return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]).'::date';
214
+			} else {
215
+							smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
216
+			}
203 217
 		break;
204 218
 
205 219
 		case 'time':
206
-			if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1)
207
-				return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]).'::time';
208
-			else
209
-				smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
220
+			if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) {
221
+							return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]).'::time';
222
+			} else {
223
+							smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
224
+			}
210 225
 		break;
211 226
 
212 227
 		case 'datetime':
213
-			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1)
214
-				return 'to_timestamp('.
228
+			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) {
229
+							return 'to_timestamp('.
215 230
 					sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]).
216 231
 					',\'YYYY-MM-DD HH24:MI:SS\')';
217
-			else
218
-				smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
232
+			} else {
233
+							smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
234
+			}
219 235
 		break;
220 236
 
221 237
 		case 'float':
222
-			if (!is_numeric($replacement))
223
-				smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
238
+			if (!is_numeric($replacement)) {
239
+							smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
240
+			}
224 241
 			return (string) (float) $replacement;
225 242
 		break;
226 243
 
@@ -233,31 +250,36 @@  discard block
 block discarded – undo
233 250
 		break;
234 251
 
235 252
 		case 'inet':
236
-			if ($replacement == 'null' || $replacement == '')
237
-				return 'null';
238
-			if (inet_pton($replacement) === false)
239
-				smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
253
+			if ($replacement == 'null' || $replacement == '') {
254
+							return 'null';
255
+			}
256
+			if (inet_pton($replacement) === false) {
257
+							smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
258
+			}
240 259
 			return sprintf('\'%1$s\'::inet', pg_escape_string($replacement));
241 260
 
242 261
 		case 'array_inet':
243 262
 			if (is_array($replacement))
244 263
 			{
245
-				if (empty($replacement))
246
-					smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
264
+				if (empty($replacement)) {
265
+									smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
266
+				}
247 267
 
248 268
 				foreach ($replacement as $key => $value)
249 269
 				{
250
-					if ($replacement == 'null' || $replacement == '')
251
-						$replacement[$key] = 'null';
252
-					if (!isValidIP($value))
253
-						smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
270
+					if ($replacement == 'null' || $replacement == '') {
271
+											$replacement[$key] = 'null';
272
+					}
273
+					if (!isValidIP($value)) {
274
+											smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
275
+					}
254 276
 					$replacement[$key] = sprintf('\'%1$s\'::inet', pg_escape_string($value));
255 277
 				}
256 278
 
257 279
 				return implode(', ', $replacement);
280
+			} else {
281
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
258 282
 			}
259
-			else
260
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
261 283
 		break;
262 284
 
263 285
 		default:
@@ -351,14 +373,16 @@  discard block
 block discarded – undo
351 373
 		),
352 374
 	);
353 375
 
354
-	if (isset($replacements[$identifier]))
355
-		$db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string);
376
+	if (isset($replacements[$identifier])) {
377
+			$db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string);
378
+	}
356 379
 
357 380
 	// Limits need to be a little different.
358 381
 	$db_string = preg_replace('~\sLIMIT\s(\d+|{int:.+}),\s*(\d+|{int:.+})\s*$~i', 'LIMIT $2 OFFSET $1', $db_string);
359 382
 
360
-	if (trim($db_string) == '')
361
-		return false;
383
+	if (trim($db_string) == '') {
384
+			return false;
385
+	}
362 386
 
363 387
 	// Comments that are allowed in a query are preg_removed.
364 388
 	static $allowed_comments_from = array(
@@ -378,8 +402,9 @@  discard block
 block discarded – undo
378 402
 	$db_count = !isset($db_count) ? 1 : $db_count + 1;
379 403
 	$db_replace_result = 0;
380 404
 
381
-	if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override']))
382
-		smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__);
405
+	if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) {
406
+			smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__);
407
+	}
383 408
 
384 409
 	if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false))
385 410
 	{
@@ -400,8 +425,9 @@  discard block
 block discarded – undo
400 425
 		list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__);
401 426
 
402 427
 		// Initialize $db_cache if not already initialized.
403
-		if (!isset($db_cache))
404
-			$db_cache = array();
428
+		if (!isset($db_cache)) {
429
+					$db_cache = array();
430
+		}
405 431
 
406 432
 		if (!empty($_SESSION['debug_redirect']))
407 433
 		{
@@ -427,17 +453,18 @@  discard block
 block discarded – undo
427 453
 		while (true)
428 454
 		{
429 455
 			$pos = strpos($db_string, '\'', $pos + 1);
430
-			if ($pos === false)
431
-				break;
456
+			if ($pos === false) {
457
+							break;
458
+			}
432 459
 			$clean .= substr($db_string, $old_pos, $pos - $old_pos);
433 460
 
434 461
 			while (true)
435 462
 			{
436 463
 				$pos1 = strpos($db_string, '\'', $pos + 1);
437 464
 				$pos2 = strpos($db_string, '\\', $pos + 1);
438
-				if ($pos1 === false)
439
-					break;
440
-				elseif ($pos2 === false || $pos2 > $pos1)
465
+				if ($pos1 === false) {
466
+									break;
467
+				} elseif ($pos2 === false || $pos2 > $pos1)
441 468
 				{
442 469
 					$pos = $pos1;
443 470
 					break;
@@ -453,16 +480,19 @@  discard block
 block discarded – undo
453 480
 		$clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean)));
454 481
 
455 482
 		// Comments?  We don't use comments in our queries, we leave 'em outside!
456
-		if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false)
457
-			$fail = true;
483
+		if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) {
484
+					$fail = true;
485
+		}
458 486
 		// Trying to change passwords, slow us down, or something?
459
-		elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0)
460
-			$fail = true;
461
-		elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0)
462
-			$fail = true;
487
+		elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) {
488
+					$fail = true;
489
+		} elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) {
490
+					$fail = true;
491
+		}
463 492
 
464
-		if (!empty($fail) && function_exists('log_error'))
465
-			smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__);
493
+		if (!empty($fail) && function_exists('log_error')) {
494
+					smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__);
495
+		}
466 496
 	}
467 497
 
468 498
 	// Set optimize stuff
@@ -481,18 +511,21 @@  discard block
 block discarded – undo
481 511
 
482 512
 		$db_string = $query_hints_set . $db_string;
483 513
 		
484
-		if (isset($db_show_debug) && $db_show_debug === true && $db_cache[$db_count]['q'] != '...')
485
-			$db_cache[$db_count]['q'] = "\t\t" . $db_string;
514
+		if (isset($db_show_debug) && $db_show_debug === true && $db_cache[$db_count]['q'] != '...') {
515
+					$db_cache[$db_count]['q'] = "\t\t" . $db_string;
516
+		}
486 517
 	}
487 518
 
488 519
 	$db_last_result = @pg_query($connection, $db_string);
489 520
 
490
-	if ($db_last_result === false && empty($db_values['db_error_skip']))
491
-		$db_last_result = smf_db_error($db_string, $connection);
521
+	if ($db_last_result === false && empty($db_values['db_error_skip'])) {
522
+			$db_last_result = smf_db_error($db_string, $connection);
523
+	}
492 524
 
493 525
 	// Debugging.
494
-	if (isset($db_show_debug) && $db_show_debug === true)
495
-		$db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
526
+	if (isset($db_show_debug) && $db_show_debug === true) {
527
+			$db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
528
+	}
496 529
 
497 530
 	return $db_last_result;
498 531
 }
@@ -509,10 +542,11 @@  discard block
 block discarded – undo
509 542
 {
510 543
 	global $db_last_result, $db_replace_result;
511 544
 
512
-	if ($db_replace_result)
513
-		return $db_replace_result;
514
-	elseif ($result === null && !$db_last_result)
515
-		return 0;
545
+	if ($db_replace_result) {
546
+			return $db_replace_result;
547
+	} elseif ($result === null && !$db_last_result) {
548
+			return 0;
549
+	}
516 550
 
517 551
 	return pg_affected_rows($result === null ? $db_last_result : $result);
518 552
 }
@@ -536,8 +570,9 @@  discard block
 block discarded – undo
536 570
 		array(
537 571
 		)
538 572
 	);
539
-	if (!$request)
540
-		return false;
573
+	if (!$request) {
574
+			return false;
575
+	}
541 576
 	list ($lastID) = $smcFunc['db_fetch_row']($request);
542 577
 	$smcFunc['db_free_result']($request);
543 578
 
@@ -558,12 +593,13 @@  discard block
 block discarded – undo
558 593
 	// Decide which connection to use
559 594
 	$connection = $connection === null ? $db_connection : $connection;
560 595
 
561
-	if ($type == 'begin')
562
-		return @pg_query($connection, 'BEGIN');
563
-	elseif ($type == 'rollback')
564
-		return @pg_query($connection, 'ROLLBACK');
565
-	elseif ($type == 'commit')
566
-		return @pg_query($connection, 'COMMIT');
596
+	if ($type == 'begin') {
597
+			return @pg_query($connection, 'BEGIN');
598
+	} elseif ($type == 'rollback') {
599
+			return @pg_query($connection, 'ROLLBACK');
600
+	} elseif ($type == 'commit') {
601
+			return @pg_query($connection, 'COMMIT');
602
+	}
567 603
 
568 604
 	return false;
569 605
 }
@@ -591,19 +627,22 @@  discard block
 block discarded – undo
591 627
 	$query_error = @pg_last_error($connection);
592 628
 
593 629
 	// Log the error.
594
-	if (function_exists('log_error'))
595
-		log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n" . $db_string : ''), 'database', $file, $line);
630
+	if (function_exists('log_error')) {
631
+			log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n" . $db_string : ''), 'database', $file, $line);
632
+	}
596 633
 
597 634
 	// Nothing's defined yet... just die with it.
598
-	if (empty($context) || empty($txt))
599
-		die($query_error);
635
+	if (empty($context) || empty($txt)) {
636
+			die($query_error);
637
+	}
600 638
 
601 639
 	// Show an error message, if possible.
602 640
 	$context['error_title'] = $txt['database_error'];
603
-	if (allowedTo('admin_forum'))
604
-		$context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line;
605
-	else
606
-		$context['error_message'] = $txt['try_again'];
641
+	if (allowedTo('admin_forum')) {
642
+			$context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line;
643
+	} else {
644
+			$context['error_message'] = $txt['try_again'];
645
+	}
607 646
 
608 647
 	if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true)
609 648
 	{
@@ -625,12 +664,14 @@  discard block
 block discarded – undo
625 664
 {
626 665
 	global $db_row_count;
627 666
 
628
-	if ($counter !== false)
629
-		return pg_fetch_row($request, $counter);
667
+	if ($counter !== false) {
668
+			return pg_fetch_row($request, $counter);
669
+	}
630 670
 
631 671
 	// Reset the row counter...
632
-	if (!isset($db_row_count[(int) $request]))
633
-		$db_row_count[(int) $request] = 0;
672
+	if (!isset($db_row_count[(int) $request])) {
673
+			$db_row_count[(int) $request] = 0;
674
+	}
634 675
 
635 676
 	// Return the right row.
636 677
 	return @pg_fetch_row($request, $db_row_count[(int) $request]++);
@@ -647,12 +688,14 @@  discard block
 block discarded – undo
647 688
 {
648 689
 	global $db_row_count;
649 690
 
650
-	if ($counter !== false)
651
-		return pg_fetch_assoc($request, $counter);
691
+	if ($counter !== false) {
692
+			return pg_fetch_assoc($request, $counter);
693
+	}
652 694
 
653 695
 	// Reset the row counter...
654
-	if (!isset($db_row_count[(int) $request]))
655
-		$db_row_count[(int) $request] = 0;
696
+	if (!isset($db_row_count[(int) $request])) {
697
+			$db_row_count[(int) $request] = 0;
698
+	}
656 699
 
657 700
 	// Return the right row.
658 701
 	return @pg_fetch_assoc($request, $db_row_count[(int) $request]++);
@@ -705,11 +748,13 @@  discard block
 block discarded – undo
705 748
 
706 749
 	$replace = '';
707 750
 
708
-	if (empty($data))
709
-		return;
751
+	if (empty($data)) {
752
+			return;
753
+	}
710 754
 
711
-	if (!is_array($data[array_rand($data)]))
712
-		$data = array($data);
755
+	if (!is_array($data[array_rand($data)])) {
756
+			$data = array($data);
757
+	}
713 758
 
714 759
 	// Replace the prefix holder with the actual prefix.
715 760
 	$table = str_replace('{db_prefix}', $db_prefix, $table);
@@ -728,11 +773,13 @@  discard block
 block discarded – undo
728 773
 			//pg 9.5 got replace support
729 774
 			$pg_version = $smcFunc['db_get_version']();
730 775
 			// if we got a Beta Version
731
-			if (stripos($pg_version, 'beta') !== false)
732
-				$pg_version = substr($pg_version, 0, stripos($pg_version, 'beta')) . '.0';
776
+			if (stripos($pg_version, 'beta') !== false) {
777
+							$pg_version = substr($pg_version, 0, stripos($pg_version, 'beta')) . '.0';
778
+			}
733 779
 			// or RC
734
-			if (stripos($pg_version, 'rc') !== false)
735
-				$pg_version = substr($pg_version, 0, stripos($pg_version, 'rc')) . '.0';
780
+			if (stripos($pg_version, 'rc') !== false) {
781
+							$pg_version = substr($pg_version, 0, stripos($pg_version, 'rc')) . '.0';
782
+			}
736 783
 
737 784
 			$replace_support = (version_compare($pg_version, '9.5.0', '>=') ? true : false);
738 785
 		}
@@ -751,32 +798,35 @@  discard block
 block discarded – undo
751 798
 					$key_str .= ($count_pk > 0 ? ',' : '');
752 799
 					$key_str .= $columnName;
753 800
 					$count_pk++;
754
-				}
755
-				else if ($method == 'replace') //normal field
801
+				} else if ($method == 'replace') {
802
+					//normal field
756 803
 				{
757 804
 					$col_str .= ($count > 0 ? ',' : '');
805
+				}
758 806
 					$col_str .= $columnName . ' = EXCLUDED.' . $columnName;
759 807
 					$count++;
760 808
 				}
761 809
 			}
762
-			if ($method == 'replace')
763
-				$replace = ' ON CONFLICT (' . $key_str . ') DO UPDATE SET ' . $col_str;
764
-			else
765
-				$replace = ' ON CONFLICT (' . $key_str . ') DO NOTHING';
766
-		}
767
-		else if ($method == 'replace')
810
+			if ($method == 'replace') {
811
+							$replace = ' ON CONFLICT (' . $key_str . ') DO UPDATE SET ' . $col_str;
812
+			} else {
813
+							$replace = ' ON CONFLICT (' . $key_str . ') DO NOTHING';
814
+			}
815
+		} else if ($method == 'replace')
768 816
 		{
769 817
 			foreach ($columns as $columnName => $type)
770 818
 			{
771 819
 				// Are we restricting the length?
772
-				if (strpos($type, 'string-') !== false)
773
-					$actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $count);
774
-				else
775
-					$actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $count);
820
+				if (strpos($type, 'string-') !== false) {
821
+									$actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $count);
822
+				} else {
823
+									$actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $count);
824
+				}
776 825
 
777 826
 				// A key? That's what we were looking for.
778
-				if (in_array($columnName, $keys))
779
-					$where .= (empty($where) ? '' : ' AND ') . substr($actualType, 0, -2);
827
+				if (in_array($columnName, $keys)) {
828
+									$where .= (empty($where) ? '' : ' AND ') . substr($actualType, 0, -2);
829
+				}
780 830
 				$count++;
781 831
 			}
782 832
 
@@ -812,10 +862,11 @@  discard block
 block discarded – undo
812 862
 		foreach ($columns as $columnName => $type)
813 863
 		{
814 864
 			// Are we restricting the length?
815
-			if (strpos($type, 'string-') !== false)
816
-				$insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
817
-			else
818
-				$insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName);
865
+			if (strpos($type, 'string-') !== false) {
866
+							$insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
867
+			} else {
868
+							$insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName);
869
+			}
819 870
 		}
820 871
 		$insertData = substr($insertData, 0, -2) . ')';
821 872
 
@@ -824,8 +875,9 @@  discard block
 block discarded – undo
824 875
 
825 876
 		// Here's where the variables are injected to the query.
826 877
 		$insertRows = array();
827
-		foreach ($data as $dataRow)
828
-			$insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection);
878
+		foreach ($data as $dataRow) {
879
+					$insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection);
880
+		}
829 881
 
830 882
 		// Do the insert.
831 883
 		$request = $smcFunc['db_query']('', '
@@ -842,19 +894,21 @@  discard block
 block discarded – undo
842 894
 
843 895
 		if ($with_returning && $request !== false)
844 896
 		{
845
-			if ($returnmode === 2)
846
-				$return_var = array();
897
+			if ($returnmode === 2) {
898
+							$return_var = array();
899
+			}
847 900
 
848 901
 			while(($row = $smcFunc['db_fetch_row']($request)) && $with_returning)
849 902
 			{
850
-				if (is_numeric($row[0])) // try to emulate mysql limitation
903
+				if (is_numeric($row[0])) {
904
+					// try to emulate mysql limitation
851 905
 				{
852 906
 					if ($returnmode === 1)
853 907
 						$return_var = $row[0];
854
-					elseif ($returnmode === 2)
855
-						$return_var[] = $row[0];
856
-				}
857
-				else
908
+				} elseif ($returnmode === 2) {
909
+											$return_var[] = $row[0];
910
+					}
911
+				} else
858 912
 				{
859 913
 					$with_returning = false;
860 914
 					trigger_error('trying to returning ID Field which is not a Int field', E_USER_ERROR);
@@ -863,9 +917,10 @@  discard block
 block discarded – undo
863 917
 		}
864 918
 	}
865 919
 
866
-	if ($with_returning && !empty($return_var))
867
-		return $return_var;
868
-}
920
+	if ($with_returning && !empty($return_var)) {
921
+			return $return_var;
922
+	}
923
+	}
869 924
 
870 925
 /**
871 926
  * Dummy function really. Doesn't do anything on PostgreSQL.
@@ -902,8 +957,9 @@  discard block
 block discarded – undo
902 957
  */
903 958
 function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null)
904 959
 {
905
-	if (empty($log_message))
906
-		$log_message = $error_message;
960
+	if (empty($log_message)) {
961
+			$log_message = $error_message;
962
+	}
907 963
 
908 964
 	foreach (debug_backtrace() as $step)
909 965
 	{
@@ -922,12 +978,14 @@  discard block
 block discarded – undo
922 978
 	}
923 979
 
924 980
 	// A special case - we want the file and line numbers for debugging.
925
-	if ($error_type == 'return')
926
-		return array($file, $line);
981
+	if ($error_type == 'return') {
982
+			return array($file, $line);
983
+	}
927 984
 
928 985
 	// Is always a critical error.
929
-	if (function_exists('log_error'))
930
-		log_error($log_message, 'critical', $file, $line);
986
+	if (function_exists('log_error')) {
987
+			log_error($log_message, 'critical', $file, $line);
988
+	}
931 989
 
932 990
 	if (function_exists('fatal_error'))
933 991
 	{
@@ -935,12 +993,12 @@  discard block
 block discarded – undo
935 993
 
936 994
 		// Cannot continue...
937 995
 		exit;
996
+	} elseif ($error_type) {
997
+			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
998
+	} else {
999
+			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
1000
+	}
938 1001
 	}
939
-	elseif ($error_type)
940
-		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
941
-	else
942
-		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
943
-}
944 1002
 
945 1003
 /**
946 1004
  * Escape the LIKE wildcards so that they match the character and not the wildcard.
@@ -957,10 +1015,11 @@  discard block
 block discarded – undo
957 1015
 		'\\' => '\\\\',
958 1016
 	);
959 1017
 
960
-	if ($translate_human_wildcards)
961
-		$replacements += array(
1018
+	if ($translate_human_wildcards) {
1019
+			$replacements += array(
962 1020
 			'*' => '%',
963 1021
 		);
1022
+	}
964 1023
 
965 1024
 	return strtr($string, $replacements);
966 1025
 }
Please login to merge, or discard this patch.
Sources/Subs-MembersOnline.php 1 patch
Braces   +27 added lines, -21 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Retrieve a list and several other statistics of the users currently online.
@@ -45,8 +46,9 @@  discard block
 block discarded – undo
45 46
 	}
46 47
 
47 48
 	// Not allowed sort method? Bang! Error!
48
-	elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options))
49
-		trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE);
49
+	elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) {
50
+			trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE);
51
+	}
50 52
 
51 53
 	// Initialize the array that'll be returned later on.
52 54
 	$membersOnlineStats = array(
@@ -63,8 +65,9 @@  discard block
 block discarded – undo
63 65
 	// Get any spiders if enabled.
64 66
 	$spiders = array();
65 67
 	$spider_finds = array();
66
-	if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache']))
67
-		$spiders = $smcFunc['json_decode']($modSettings['spider_name_cache'], true);
68
+	if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) {
69
+			$spiders = $smcFunc['json_decode']($modSettings['spider_name_cache'], true);
70
+	}
68 71
 
69 72
 	// Load the users online right now.
70 73
 	$request = $smcFunc['db_query']('', '
@@ -92,9 +95,7 @@  discard block
 block discarded – undo
92 95
 			$membersOnlineStats['num_guests']++;
93 96
 
94 97
 			continue;
95
-		}
96
-
97
-		elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden']))
98
+		} elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden']))
98 99
 		{
99 100
 			// Just increase the stats and don't add this hidden user to any list.
100 101
 			$membersOnlineStats['num_users_hidden']++;
@@ -102,10 +103,11 @@  discard block
 block discarded – undo
102 103
 		}
103 104
 
104 105
 		// Some basic color coding...
105
-		if (!empty($row['online_color']))
106
-			$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
107
-		else
108
-			$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
106
+		if (!empty($row['online_color'])) {
107
+					$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
108
+		} else {
109
+					$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
110
+		}
109 111
 
110 112
 		// Buddies get counted and highlighted.
111 113
 		$is_buddy = in_array($row['id_member'], $user_info['buddies']);
@@ -132,8 +134,8 @@  discard block
 block discarded – undo
132 134
 		$membersOnlineStats['list_users_online'][$row[$membersOnlineOptions['sort']] . '_' . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
133 135
 
134 136
 		// Store all distinct (primary) membergroups that are shown.
135
-		if (!isset($membersOnlineStats['online_groups'][$row['id_group']]))
136
-			$membersOnlineStats['online_groups'][$row['id_group']] = array(
137
+		if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) {
138
+					$membersOnlineStats['online_groups'][$row['id_group']] = array(
137 139
 				'id' => $row['id_group'],
138 140
 				'name' => $row['group_name'],
139 141
 				'color' => $row['online_color'],
@@ -141,6 +143,7 @@  discard block
 block discarded – undo
141 143
 				'type' => $row['group_type'],
142 144
 				'parent' => $row['id_parent'],
143 145
 			);
146
+		}
144 147
 	}
145 148
 	$smcFunc['db_free_result']($request);
146 149
 
@@ -201,11 +204,12 @@  discard block
 block discarded – undo
201 204
 	$settingsToUpdate = array();
202 205
 
203 206
 	// More members on now than ever were?  Update it!
204
-	if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline'])
205
-		$settingsToUpdate = array(
207
+	if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) {
208
+			$settingsToUpdate = array(
206 209
 			'mostOnline' => $total_users_online,
207 210
 			'mostDate' => time()
208 211
 		);
212
+	}
209 213
 
210 214
 	$date = strftime('%Y-%m-%d', forum_time(false));
211 215
 
@@ -237,8 +241,9 @@  discard block
 block discarded – undo
237 241
 		{
238 242
 			list ($modSettings['mostOnlineToday']) = $smcFunc['db_fetch_row']($request);
239 243
 
240
-			if ($total_users_online > $modSettings['mostOnlineToday'])
241
-				trackStats(array('most_on' => $total_users_online));
244
+			if ($total_users_online > $modSettings['mostOnlineToday']) {
245
+							trackStats(array('most_on' => $total_users_online));
246
+			}
242 247
 
243 248
 			$total_users_online = max($total_users_online, $modSettings['mostOnlineToday']);
244 249
 		}
@@ -255,8 +260,9 @@  discard block
 block discarded – undo
255 260
 		$settingsToUpdate['mostOnlineToday'] = $total_users_online;
256 261
 	}
257 262
 
258
-	if (!empty($settingsToUpdate))
259
-		updateSettings($settingsToUpdate);
260
-}
263
+	if (!empty($settingsToUpdate)) {
264
+			updateSettings($settingsToUpdate);
265
+	}
266
+	}
261 267
 
262 268
 ?>
263 269
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/MessageIndex.php 1 patch
Braces   +264 added lines, -197 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Show the list of topics in this board, along with any child boards.
@@ -56,8 +57,9 @@  discard block
 block discarded – undo
56 57
 
57 58
 	$context['name'] = $board_info['name'];
58 59
 	$context['description'] = $board_info['description'];
59
-	if (!empty($board_info['description']))
60
-		$context['meta_description'] = strip_tags($board_info['description']);
60
+	if (!empty($board_info['description'])) {
61
+			$context['meta_description'] = strip_tags($board_info['description']);
62
+	}
61 63
 
62 64
 	// How many topics do we have in total?
63 65
 	$board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics'];
@@ -73,12 +75,14 @@  discard block
 block discarded – undo
73 75
 		$session_name = session_name();
74 76
 		foreach ($_GET as $k => $v)
75 77
 		{
76
-			if (!in_array($k, array('board', 'start', $session_name)))
77
-				$context['robot_no_index'] = true;
78
+			if (!in_array($k, array('board', 'start', $session_name))) {
79
+							$context['robot_no_index'] = true;
80
+			}
78 81
 		}
79 82
 	}
80
-	if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0))
81
-		$context['robot_no_index'] = true;
83
+	if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) {
84
+			$context['robot_no_index'] = true;
85
+	}
82 86
 
83 87
 	// If we can view unapproved messages and there are some build up a list.
84 88
 	if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts']))
@@ -89,14 +93,16 @@  discard block
 block discarded – undo
89 93
 	}
90 94
 
91 95
 	// We only know these.
92
-	if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post')))
93
-		$_REQUEST['sort'] = 'last_post';
96
+	if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) {
97
+			$_REQUEST['sort'] = 'last_post';
98
+	}
94 99
 
95 100
 	// Make sure the starting place makes sense and construct the page index.
96
-	if (isset($_REQUEST['sort']))
97
-		$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true);
98
-	else
99
-		$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true);
101
+	if (isset($_REQUEST['sort'])) {
102
+			$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true);
103
+	} else {
104
+			$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true);
105
+	}
100 106
 	$context['start'] = &$_REQUEST['start'];
101 107
 
102 108
 	// Set a canonical URL for this page.
@@ -132,14 +138,16 @@  discard block
 block discarded – undo
132 138
 	$context['link_moderators'] = array();
133 139
 	if (!empty($board_info['moderators']))
134 140
 	{
135
-		foreach ($board_info['moderators'] as $mod)
136
-			$context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
141
+		foreach ($board_info['moderators'] as $mod) {
142
+					$context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
143
+		}
137 144
 	}
138 145
 	if (!empty($board_info['moderator_groups']))
139 146
 	{
140 147
 		// By default just tack the moderator groups onto the end of the members
141
-		foreach ($board_info['moderator_groups'] as $mod_group)
142
-			$context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>';
148
+		foreach ($board_info['moderator_groups'] as $mod_group) {
149
+					$context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>';
150
+		}
143 151
 	}
144 152
 
145 153
 	// Now we tack the info onto the end of the linktree
@@ -191,20 +199,24 @@  discard block
 block discarded – undo
191 199
 		);
192 200
 		while ($row = $smcFunc['db_fetch_assoc']($request))
193 201
 		{
194
-			if (empty($row['id_member']))
195
-				continue;
202
+			if (empty($row['id_member'])) {
203
+							continue;
204
+			}
196 205
 
197
-			if (!empty($row['online_color']))
198
-				$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
199
-			else
200
-				$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
206
+			if (!empty($row['online_color'])) {
207
+							$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
208
+			} else {
209
+							$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
210
+			}
201 211
 
202 212
 			$is_buddy = in_array($row['id_member'], $user_info['buddies']);
203
-			if ($is_buddy)
204
-				$link = '<strong>' . $link . '</strong>';
213
+			if ($is_buddy) {
214
+							$link = '<strong>' . $link . '</strong>';
215
+			}
205 216
 
206
-			if (!empty($row['show_online']) || allowedTo('moderate_forum'))
207
-				$context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
217
+			if (!empty($row['show_online']) || allowedTo('moderate_forum')) {
218
+							$context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
219
+			}
208 220
 			// @todo why are we filling this array of data that are just counted (twice) and discarded? ???
209 221
 			$context['view_members'][$row['log_time'] . $row['member_name']] = array(
210 222
 				'id' => $row['id_member'],
@@ -217,8 +229,9 @@  discard block
 block discarded – undo
217 229
 				'hidden' => empty($row['show_online']),
218 230
 			);
219 231
 
220
-			if (empty($row['show_online']))
221
-				$context['view_num_hidden']++;
232
+			if (empty($row['show_online'])) {
233
+							$context['view_num_hidden']++;
234
+			}
222 235
 		}
223 236
 		$context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']);
224 237
 		$smcFunc['db_free_result']($request);
@@ -260,8 +273,9 @@  discard block
 block discarded – undo
260 273
 	// Bring in any changes we want to make before the query.
261 274
 	call_integration_hook('integrate_pre_messageindex', array(&$sort_methods));
262 275
 
263
-	foreach ($sort_methods as $key => $val)
264
-		$context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>';
276
+	foreach ($sort_methods as $key => $val) {
277
+			$context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>';
278
+	}
265 279
 
266 280
 	// Calculate the fastest way to get the topics.
267 281
 	$start = (int) $_REQUEST['start'];
@@ -271,14 +285,15 @@  discard block
 block discarded – undo
271 285
 		$fake_ascending = true;
272 286
 		$context['maxindex'] = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? $board_info['total_topics'] - $start : $context['maxindex'];
273 287
 		$start = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? 0 : $board_info['total_topics'] - $start - $context['maxindex'];
288
+	} else {
289
+			$fake_ascending = false;
274 290
 	}
275
-	else
276
-		$fake_ascending = false;
277 291
 
278 292
 	// Setup the default topic icons...
279 293
 	$context['icon_sources'] = array();
280
-	foreach ($context['stable_icons'] as $icon)
281
-		$context['icon_sources'][$icon] = 'images_url';
294
+	foreach ($context['stable_icons'] as $icon) {
295
+			$context['icon_sources'][$icon] = 'images_url';
296
+	}
282 297
 
283 298
 	$topic_ids = array();
284 299
 	$context['topics'] = array();
@@ -316,8 +331,9 @@  discard block
 block discarded – undo
316 331
 			$message_pre_index_parameters
317 332
 		);
318 333
 		$topic_ids = array();
319
-		while ($row = $smcFunc['db_fetch_assoc']($request))
320
-			$topic_ids[] = $row['id_topic'];
334
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
335
+					$topic_ids[] = $row['id_topic'];
336
+		}
321 337
 	}
322 338
 
323 339
 	// Grab the appropriate topic information...
@@ -375,11 +391,13 @@  discard block
 block discarded – undo
375 391
 		// Begin 'printing' the message index for current board.
376 392
 		while ($row = $smcFunc['db_fetch_assoc']($result))
377 393
 		{
378
-			if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0')
379
-				continue;
394
+			if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') {
395
+							continue;
396
+			}
380 397
 
381
-			if (!$pre_query)
382
-				$topic_ids[] = $row['id_topic'];
398
+			if (!$pre_query) {
399
+							$topic_ids[] = $row['id_topic'];
400
+			}
383 401
 
384 402
 			// Reference the main color class.
385 403
 			$colorClass = 'windowbg';
@@ -389,8 +407,9 @@  discard block
 block discarded – undo
389 407
 			{
390 408
 				// Limit them to $modSettings['preview_characters'] characters
391 409
 				$row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => '&#10;')));
392
-				if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters'])
393
-					$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...';
410
+				if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) {
411
+									$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...';
412
+				}
394 413
 
395 414
 				// Censor the subject and message preview.
396 415
 				censorText($row['first_subject']);
@@ -401,27 +420,27 @@  discard block
 block discarded – undo
401 420
 				{
402 421
 					$row['last_subject'] = $row['first_subject'];
403 422
 					$row['last_body'] = $row['first_body'];
404
-				}
405
-				else
423
+				} else
406 424
 				{
407 425
 					$row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => '&#10;')));
408
-					if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters'])
409
-						$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...';
426
+					if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) {
427
+											$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...';
428
+					}
410 429
 
411 430
 					censorText($row['last_subject']);
412 431
 					censorText($row['last_body']);
413 432
 				}
414
-			}
415
-			else
433
+			} else
416 434
 			{
417 435
 				$row['first_body'] = '';
418 436
 				$row['last_body'] = '';
419 437
 				censorText($row['first_subject']);
420 438
 
421
-				if ($row['id_first_msg'] == $row['id_last_msg'])
422
-					$row['last_subject'] = $row['first_subject'];
423
-				else
424
-					censorText($row['last_subject']);
439
+				if ($row['id_first_msg'] == $row['id_last_msg']) {
440
+									$row['last_subject'] = $row['first_subject'];
441
+				} else {
442
+									censorText($row['last_subject']);
443
+				}
425 444
 			}
426 445
 
427 446
 			// Decide how many pages the topic should have.
@@ -432,42 +451,50 @@  discard block
 block discarded – undo
432 451
 				$pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false);
433 452
 
434 453
 				// If we can use all, show all.
435
-				if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages'])
436
-					$pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>';
454
+				if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) {
455
+									$pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>';
456
+				}
457
+			} else {
458
+							$pages = '';
437 459
 			}
438
-			else
439
-				$pages = '';
440 460
 
441 461
 			// We need to check the topic icons exist...
442 462
 			if (!empty($modSettings['messageIconChecks_enable']))
443 463
 			{
444
-				if (!isset($context['icon_sources'][$row['first_icon']]))
445
-					$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
446
-				if (!isset($context['icon_sources'][$row['last_icon']]))
447
-					$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
448
-			}
449
-			else
464
+				if (!isset($context['icon_sources'][$row['first_icon']])) {
465
+									$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
466
+				}
467
+				if (!isset($context['icon_sources'][$row['last_icon']])) {
468
+									$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
469
+				}
470
+			} else
450 471
 			{
451
-				if (!isset($context['icon_sources'][$row['first_icon']]))
452
-					$context['icon_sources'][$row['first_icon']] = 'images_url';
453
-				if (!isset($context['icon_sources'][$row['last_icon']]))
454
-					$context['icon_sources'][$row['last_icon']] = 'images_url';
472
+				if (!isset($context['icon_sources'][$row['first_icon']])) {
473
+									$context['icon_sources'][$row['first_icon']] = 'images_url';
474
+				}
475
+				if (!isset($context['icon_sources'][$row['last_icon']])) {
476
+									$context['icon_sources'][$row['last_icon']] = 'images_url';
477
+				}
455 478
 			}
456 479
 
457
-			if (!empty($board_info['recycle']))
458
-				$row['first_icon'] = 'recycled';
480
+			if (!empty($board_info['recycle'])) {
481
+							$row['first_icon'] = 'recycled';
482
+			}
459 483
 
460 484
 			// Is this topic pending approval, or does it have any posts pending approval?
461
-			if ($context['can_approve_posts'] && $row['unapproved_posts'])
462
-				$colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost');
485
+			if ($context['can_approve_posts'] && $row['unapproved_posts']) {
486
+							$colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost');
487
+			}
463 488
 
464 489
 			// Sticky topics should get a different color, too.
465
-			if ($row['is_sticky'])
466
-				$colorClass .= ' sticky';
490
+			if ($row['is_sticky']) {
491
+							$colorClass .= ' sticky';
492
+			}
467 493
 
468 494
 			// Locked topics get special treatment as well.
469
-			if ($row['locked'])
470
-				$colorClass .= ' locked';
495
+			if ($row['locked']) {
496
+							$colorClass .= ' locked';
497
+			}
471 498
 
472 499
 			// 'Print' the topic info.
473 500
 			$context['topics'][$row['id_topic']] = array_merge($row, array(
@@ -548,8 +575,9 @@  discard block
 block discarded – undo
548 575
 		$smcFunc['db_free_result']($result);
549 576
 
550 577
 		// Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...)
551
-		if ($fake_ascending)
552
-			$context['topics'] = array_reverse($context['topics'], true);
578
+		if ($fake_ascending) {
579
+					$context['topics'] = array_reverse($context['topics'], true);
580
+		}
553 581
 
554 582
 		if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'] && !empty($topic_ids))
555 583
 		{
@@ -566,8 +594,9 @@  discard block
 block discarded – undo
566 594
 					'limit' => count($topic_ids),
567 595
 				)
568 596
 			);
569
-			while ($row = $smcFunc['db_fetch_assoc']($result))
570
-				$context['topics'][$row['id_topic']]['is_posted_in'] = true;
597
+			while ($row = $smcFunc['db_fetch_assoc']($result)) {
598
+							$context['topics'][$row['id_topic']]['is_posted_in'] = true;
599
+			}
571 600
 			$smcFunc['db_free_result']($result);
572 601
 		}
573 602
 	}
@@ -592,9 +621,9 @@  discard block
 block discarded – undo
592 621
 		// Can we restore topics?
593 622
 		$context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']);
594 623
 
595
-		if ($user_info['is_admin'] || $modSettings['topic_move_any'])
596
-			$context['can_move_any'] = true;
597
-		else
624
+		if ($user_info['is_admin'] || $modSettings['topic_move_any']) {
625
+					$context['can_move_any'] = true;
626
+		} else
598 627
 		{
599 628
 			// We'll use this in a minute
600 629
 			$boards_allowed = boardsAllowedTo('post_new');
@@ -621,11 +650,13 @@  discard block
 block discarded – undo
621 650
 		}
622 651
 
623 652
 		// Can we use quick moderation checkboxes?
624
-		if ($options['display_quick_mod'] == 1)
625
-			$context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore'];
653
+		if ($options['display_quick_mod'] == 1) {
654
+					$context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore'];
655
+		}
626 656
 		// Or the icons?
627
-		else
628
-			$context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'];
657
+		else {
658
+					$context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'];
659
+		}
629 660
 	}
630 661
 
631 662
 	if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1)
@@ -659,13 +690,15 @@  discard block
 block discarded – undo
659 690
 			);
660 691
 
661 692
 			// We've seen all these boards now!
662
-			foreach ($board_info['parent_boards'] as $k => $dummy)
663
-				if (isset($_SESSION['topicseen_cache'][$k]))
693
+			foreach ($board_info['parent_boards'] as $k => $dummy) {
694
+							if (isset($_SESSION['topicseen_cache'][$k]))
664 695
 					unset($_SESSION['topicseen_cache'][$k]);
696
+			}
665 697
 		}
666 698
 
667
-		if (isset($_SESSION['topicseen_cache'][$board]))
668
-			unset($_SESSION['topicseen_cache'][$board]);
699
+		if (isset($_SESSION['topicseen_cache'][$board])) {
700
+					unset($_SESSION['topicseen_cache'][$board]);
701
+		}
669 702
 
670 703
 		$request = $smcFunc['db_query']('', '
671 704
 			SELECT id_topic, id_board, sent
@@ -686,8 +719,9 @@  discard block
 block discarded – undo
686 719
 				$context['is_marked_notify'] = true;
687 720
 				$board_sent = $row['sent'];
688 721
 			}
689
-			if (!empty($row['id_topic']))
690
-				$context['topics'][$row['id_topic']]['is_watched'] = true;
722
+			if (!empty($row['id_topic'])) {
723
+							$context['topics'][$row['id_topic']]['is_watched'] = true;
724
+			}
691 725
 		}
692 726
 		$smcFunc['db_free_result']($request);
693 727
 
@@ -711,8 +745,7 @@  discard block
 block discarded – undo
711 745
 		$pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array();
712 746
 		$pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0);
713 747
 		$context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1));
714
-	}
715
-	else
748
+	} else
716 749
 	{
717 750
 		$context['is_marked_notify'] = false;
718 751
 		$context['board_notification_mode'] = 1;
@@ -725,23 +758,27 @@  discard block
 block discarded – undo
725 758
 	$context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false;
726 759
 
727 760
 	// Don't want to show this forever...
728
-	if ($context['becomesUnapproved'])
729
-		unset($_SESSION['becomesUnapproved']);
761
+	if ($context['becomesUnapproved']) {
762
+			unset($_SESSION['becomesUnapproved']);
763
+	}
730 764
 
731 765
 	// Build the message index button array.
732 766
 	$context['normal_buttons'] = array();
733 767
 
734
-	if ($context['can_post_new'])
735
-		$context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true);
768
+	if ($context['can_post_new']) {
769
+			$context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true);
770
+	}
736 771
 
737
-	if ($context['can_post_poll'])
738
-		$context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll');
772
+	if ($context['can_post_poll']) {
773
+			$context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll');
774
+	}
739 775
 
740
-	if (!$context['user']['is_logged'])
741
-		$context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']);
776
+	if (!$context['user']['is_logged']) {
777
+			$context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']);
778
+	}
742 779
 
743
-	if ($context['can_mark_notify'])
744
-		$context['normal_buttons']['notify'] = array(
780
+	if ($context['can_mark_notify']) {
781
+			$context['normal_buttons']['notify'] = array(
745 782
 			'lang' => true,
746 783
 			'text' => 'notify_board_' . $context['board_notification_mode'],
747 784
 			'sub_buttons' => array(
@@ -759,6 +796,7 @@  discard block
 block discarded – undo
759 796
 				),
760 797
 			),
761 798
 		);
799
+	}
762 800
 
763 801
 	// Javascript for inline editing.
764 802
 	loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic');
@@ -780,18 +818,21 @@  discard block
 block discarded – undo
780 818
 	checkSession('request');
781 819
 
782 820
 	// Lets go straight to the restore area.
783
-	if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics']))
784
-		redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']);
821
+	if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) {
822
+			redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']);
823
+	}
785 824
 
786
-	if (isset($_SESSION['topicseen_cache']))
787
-		$_SESSION['topicseen_cache'] = array();
825
+	if (isset($_SESSION['topicseen_cache'])) {
826
+			$_SESSION['topicseen_cache'] = array();
827
+	}
788 828
 
789 829
 	// This is going to be needed to send off the notifications and for updateLastMessages().
790 830
 	require_once($sourcedir . '/Subs-Post.php');
791 831
 
792 832
 	// Remember the last board they moved things to.
793
-	if (isset($_REQUEST['move_to']))
794
-		$_SESSION['move_to_topic'] = $_REQUEST['move_to'];
833
+	if (isset($_REQUEST['move_to'])) {
834
+			$_SESSION['move_to_topic'] = $_REQUEST['move_to'];
835
+	}
795 836
 
796 837
 	// Only a few possible actions.
797 838
 	$possibleActions = array();
@@ -811,8 +852,7 @@  discard block
 block discarded – undo
811 852
 		);
812 853
 
813 854
 		$redirect_url = 'board=' . $board . '.' . $_REQUEST['start'];
814
-	}
815
-	else
855
+	} else
816 856
 	{
817 857
 		/**
818 858
 		 * @todo Ugly. There's no getting around this, is there?
@@ -830,8 +870,7 @@  discard block
 block discarded – undo
830 870
 		if (!empty($board))
831 871
 		{
832 872
 			$boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board));
833
-		}
834
-		else
873
+		} else
835 874
 		{
836 875
 			$boards_can['post_new'] = boardsAllowedTo('post_new');
837 876
 		}
@@ -842,55 +881,67 @@  discard block
 block discarded – undo
842 881
 		}
843 882
 	}
844 883
 
845
-	if (!$user_info['is_guest'])
846
-		$possibleActions[] = 'markread';
847
-	if (!empty($boards_can['make_sticky']))
848
-		$possibleActions[] = 'sticky';
849
-	if (!empty($boards_can['move_any']) || !empty($boards_can['move_own']))
850
-		$possibleActions[] = 'move';
851
-	if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own']))
852
-		$possibleActions[] = 'remove';
853
-	if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own']))
854
-		$possibleActions[] = 'lock';
855
-	if (!empty($boards_can['merge_any']))
856
-		$possibleActions[] = 'merge';
857
-	if (!empty($boards_can['approve_posts']))
858
-		$possibleActions[] = 'approve';
884
+	if (!$user_info['is_guest']) {
885
+			$possibleActions[] = 'markread';
886
+	}
887
+	if (!empty($boards_can['make_sticky'])) {
888
+			$possibleActions[] = 'sticky';
889
+	}
890
+	if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) {
891
+			$possibleActions[] = 'move';
892
+	}
893
+	if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) {
894
+			$possibleActions[] = 'remove';
895
+	}
896
+	if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) {
897
+			$possibleActions[] = 'lock';
898
+	}
899
+	if (!empty($boards_can['merge_any'])) {
900
+			$possibleActions[] = 'merge';
901
+	}
902
+	if (!empty($boards_can['approve_posts'])) {
903
+			$possibleActions[] = 'approve';
904
+	}
859 905
 
860 906
 	// Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction'].
861 907
 	// (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.)
862 908
 	if (!empty($_REQUEST['topics']))
863 909
 	{
864 910
 		// If the action isn't valid, just quit now.
865
-		if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions))
866
-			redirectexit($redirect_url);
911
+		if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) {
912
+					redirectexit($redirect_url);
913
+		}
867 914
 
868 915
 		// Merge requires all topics as one parameter and can be done at once.
869 916
 		if ($_REQUEST['qaction'] == 'merge')
870 917
 		{
871 918
 			// Merge requires at least two topics.
872
-			if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2)
873
-				redirectexit($redirect_url);
919
+			if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) {
920
+							redirectexit($redirect_url);
921
+			}
874 922
 
875 923
 			require_once($sourcedir . '/SplitTopics.php');
876 924
 			return MergeExecute($_REQUEST['topics']);
877 925
 		}
878 926
 
879 927
 		// Just convert to the other method, to make it easier.
880
-		foreach ($_REQUEST['topics'] as $topic)
881
-			$_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction'];
928
+		foreach ($_REQUEST['topics'] as $topic) {
929
+					$_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction'];
930
+		}
882 931
 	}
883 932
 
884 933
 	// Weird... how'd you get here?
885
-	if (empty($_REQUEST['actions']))
886
-		redirectexit($redirect_url);
934
+	if (empty($_REQUEST['actions'])) {
935
+			redirectexit($redirect_url);
936
+	}
887 937
 
888 938
 	// Validate each action.
889 939
 	$temp = array();
890 940
 	foreach ($_REQUEST['actions'] as $topic => $action)
891 941
 	{
892
-		if (in_array($action, $possibleActions))
893
-			$temp[(int) $topic] = $action;
942
+		if (in_array($action, $possibleActions)) {
943
+					$temp[(int) $topic] = $action;
944
+		}
894 945
 	}
895 946
 	$_REQUEST['actions'] = $temp;
896 947
 
@@ -911,27 +962,31 @@  discard block
 block discarded – undo
911 962
 		{
912 963
 			if (!empty($board))
913 964
 			{
914
-				if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts')))
915
-					unset($_REQUEST['actions'][$row['id_topic']]);
916
-			}
917
-			else
965
+				if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) {
966
+									unset($_REQUEST['actions'][$row['id_topic']]);
967
+				}
968
+			} else
918 969
 			{
919 970
 				// Don't allow them to act on unapproved posts they can't see...
920
-				if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts']))
921
-					unset($_REQUEST['actions'][$row['id_topic']]);
971
+				if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) {
972
+									unset($_REQUEST['actions'][$row['id_topic']]);
973
+				}
922 974
 				// Goodness, this is fun.  We need to validate the action.
923
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky']))
924
-					unset($_REQUEST['actions'][$row['id_topic']]);
925
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own']))))
926
-					unset($_REQUEST['actions'][$row['id_topic']]);
927
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own']))))
928
-					unset($_REQUEST['actions'][$row['id_topic']]);
975
+				elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) {
976
+									unset($_REQUEST['actions'][$row['id_topic']]);
977
+				} elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) {
978
+									unset($_REQUEST['actions'][$row['id_topic']]);
979
+				} elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) {
980
+									unset($_REQUEST['actions'][$row['id_topic']]);
981
+				}
929 982
 				// @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked'])
930
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own']))))
931
-					unset($_REQUEST['actions'][$row['id_topic']]);
983
+				elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) {
984
+									unset($_REQUEST['actions'][$row['id_topic']]);
985
+				}
932 986
 				// If the topic is approved then you need permission to approve the posts within.
933
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts']))))
934
-					unset($_REQUEST['actions'][$row['id_topic']]);
987
+				elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) {
988
+									unset($_REQUEST['actions'][$row['id_topic']]);
989
+				}
935 990
 			}
936 991
 		}
937 992
 		$smcFunc['db_free_result']($request);
@@ -949,11 +1004,11 @@  discard block
 block discarded – undo
949 1004
 	{
950 1005
 		$topic = (int) $topic;
951 1006
 
952
-		if ($action == 'markread')
953
-			$markCache[] = $topic;
954
-		elseif ($action == 'sticky')
955
-			$stickyCache[] = $topic;
956
-		elseif ($action == 'move')
1007
+		if ($action == 'markread') {
1008
+					$markCache[] = $topic;
1009
+		} elseif ($action == 'sticky') {
1010
+					$stickyCache[] = $topic;
1011
+		} elseif ($action == 'move')
957 1012
 		{
958 1013
 			require_once($sourcedir . '/MoveTopic.php');
959 1014
 			moveTopicConcurrence();
@@ -961,23 +1016,25 @@  discard block
 block discarded – undo
961 1016
 			// $moveCache[0] is the topic, $moveCache[1] is the board to move to.
962 1017
 			$moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']);
963 1018
 
964
-			if (empty($moveCache[1][$topic]))
965
-				continue;
1019
+			if (empty($moveCache[1][$topic])) {
1020
+							continue;
1021
+			}
966 1022
 
967 1023
 			$moveCache[0][] = $topic;
1024
+		} elseif ($action == 'remove') {
1025
+					$removeCache[] = $topic;
1026
+		} elseif ($action == 'lock') {
1027
+					$lockCache[] = $topic;
1028
+		} elseif ($action == 'approve') {
1029
+					$approveCache[] = $topic;
968 1030
 		}
969
-		elseif ($action == 'remove')
970
-			$removeCache[] = $topic;
971
-		elseif ($action == 'lock')
972
-			$lockCache[] = $topic;
973
-		elseif ($action == 'approve')
974
-			$approveCache[] = $topic;
975 1031
 	}
976 1032
 
977
-	if (empty($board))
978
-		$affectedBoards = array();
979
-	else
980
-		$affectedBoards = array($board => array(0, 0));
1033
+	if (empty($board)) {
1034
+			$affectedBoards = array();
1035
+	} else {
1036
+			$affectedBoards = array($board => array(0, 0));
1037
+	}
981 1038
 
982 1039
 	// Do all the stickies...
983 1040
 	if (!empty($stickyCache))
@@ -1037,14 +1094,16 @@  discard block
 block discarded – undo
1037 1094
 		{
1038 1095
 			$to = $moveCache[1][$row['id_topic']];
1039 1096
 
1040
-			if (empty($to))
1041
-				continue;
1097
+			if (empty($to)) {
1098
+							continue;
1099
+			}
1042 1100
 
1043 1101
 			// Does this topic's board count the posts or not?
1044 1102
 			$countPosts[$row['id_topic']] = empty($row['count_posts']);
1045 1103
 
1046
-			if (!isset($moveTos[$to]))
1047
-				$moveTos[$to] = array();
1104
+			if (!isset($moveTos[$to])) {
1105
+							$moveTos[$to] = array();
1106
+			}
1048 1107
 
1049 1108
 			$moveTos[$to][] = $row['id_topic'];
1050 1109
 
@@ -1058,8 +1117,9 @@  discard block
 block discarded – undo
1058 1117
 		require_once($sourcedir . '/MoveTopic.php');
1059 1118
 
1060 1119
 		// Do the actual moves...
1061
-		foreach ($moveTos as $to => $topics)
1062
-			moveTopics($topics, $to);
1120
+		foreach ($moveTos as $to => $topics) {
1121
+					moveTopics($topics, $to);
1122
+		}
1063 1123
 
1064 1124
 		// Does the post counts need to be updated?
1065 1125
 		if (!empty($moveTos))
@@ -1108,20 +1168,23 @@  discard block
 block discarded – undo
1108 1168
 
1109 1169
 				while ($row = $smcFunc['db_fetch_assoc']($request))
1110 1170
 				{
1111
-					if (!isset($members[$row['id_member']]))
1112
-						$members[$row['id_member']] = 0;
1171
+					if (!isset($members[$row['id_member']])) {
1172
+											$members[$row['id_member']] = 0;
1173
+					}
1113 1174
 
1114
-					if ($topicRecounts[$row['id_topic']] === '+')
1115
-						$members[$row['id_member']] += 1;
1116
-					else
1117
-						$members[$row['id_member']] -= 1;
1175
+					if ($topicRecounts[$row['id_topic']] === '+') {
1176
+											$members[$row['id_member']] += 1;
1177
+					} else {
1178
+											$members[$row['id_member']] -= 1;
1179
+					}
1118 1180
 				}
1119 1181
 
1120 1182
 				$smcFunc['db_free_result']($request);
1121 1183
 
1122 1184
 				// And now update them member's post counts
1123
-				foreach ($members as $id_member => $post_adj)
1124
-					updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj));
1185
+				foreach ($members as $id_member => $post_adj) {
1186
+									updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj));
1187
+				}
1125 1188
 
1126 1189
 			}
1127 1190
 		}
@@ -1201,8 +1264,9 @@  discard block
 block discarded – undo
1201 1264
 			approveTopics($approveCache);
1202 1265
 
1203 1266
 			// Time for some logging!
1204
-			foreach ($approveCache as $topic)
1205
-				logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic]));
1267
+			foreach ($approveCache as $topic) {
1268
+							logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic]));
1269
+			}
1206 1270
 		}
1207 1271
 	}
1208 1272
 
@@ -1237,8 +1301,7 @@  discard block
 block discarded – undo
1237 1301
 				$lockStatus[$row['id_topic']] = empty($row['locked']);
1238 1302
 			}
1239 1303
 			$smcFunc['db_free_result']($result);
1240
-		}
1241
-		else
1304
+		} else
1242 1305
 		{
1243 1306
 			$result = $smcFunc['db_query']('', '
1244 1307
 				SELECT id_topic, locked, id_board
@@ -1288,13 +1351,15 @@  discard block
 block discarded – undo
1288 1351
 			)
1289 1352
 		);
1290 1353
 		$logged_topics = array();
1291
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1292
-			$logged_topics[$row['id_topic']] = $row['unwatched'];
1354
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1355
+					$logged_topics[$row['id_topic']] = $row['unwatched'];
1356
+		}
1293 1357
 		$smcFunc['db_free_result']($request);
1294 1358
 
1295 1359
 		$markArray = array();
1296
-		foreach ($markCache as $topic)
1297
-			$markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0));
1360
+		foreach ($markCache as $topic) {
1361
+					$markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0));
1362
+		}
1298 1363
 
1299 1364
 		$smcFunc['db_insert']('replace',
1300 1365
 			'{db_prefix}log_topics',
@@ -1307,8 +1372,9 @@  discard block
 block discarded – undo
1307 1372
 	foreach ($moveCache as $topic)
1308 1373
 	{
1309 1374
 		// Didn't actually move anything!
1310
-		if (!isset($topic[0]))
1311
-			break;
1375
+		if (!isset($topic[0])) {
1376
+					break;
1377
+		}
1312 1378
 
1313 1379
 		logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2]));
1314 1380
 		sendNotifications($topic[0], 'move');
@@ -1330,8 +1396,9 @@  discard block
 block discarded – undo
1330 1396
 		'calendar_updated' => time(),
1331 1397
 	));
1332 1398
 
1333
-	if (!empty($affectedBoards))
1334
-		updateLastMessages(array_keys($affectedBoards));
1399
+	if (!empty($affectedBoards)) {
1400
+			updateLastMessages(array_keys($affectedBoards));
1401
+	}
1335 1402
 
1336 1403
 	redirectexit($redirect_url);
1337 1404
 }
Please login to merge, or discard this patch.
Themes/default/Profile.template.php 1 patch
Braces   +464 added lines, -346 removed lines patch added patch discarded remove patch
@@ -18,23 +18,25 @@  discard block
 block discarded – undo
18 18
 	global $context;
19 19
 
20 20
 	// Prevent Chrome from auto completing fields when viewing/editing other members profiles
21
-	if (isBrowser('is_chrome') && !$context['user']['is_owner'])
22
-		echo '
21
+	if (isBrowser('is_chrome') && !$context['user']['is_owner']) {
22
+			echo '
23 23
 	<script>
24 24
 		disableAutoComplete();
25 25
 	</script>';
26
+	}
26 27
 
27 28
 	// If an error occurred while trying to save previously, give the user a clue!
28 29
 	echo '
29 30
 					', template_error_message();
30 31
 
31 32
 	// If the profile was update successfully, let the user know this.
32
-	if (!empty($context['profile_updated']))
33
-		echo '
33
+	if (!empty($context['profile_updated'])) {
34
+			echo '
34 35
 					<div class="infobox">
35 36
 						', $context['profile_updated'], '
36 37
 					</div>';
37
-}
38
+	}
39
+	}
38 40
 
39 41
 /**
40 42
  * Template for any HTML needed below the profile (closing off divs/tables, etc.)
@@ -102,8 +104,7 @@  discard block
 block discarded – undo
102 104
 	if (empty($context['unread_alerts']))
103 105
 	{
104 106
 		template_alerts_all_read();
105
-	}
106
-	else
107
+	} else
107 108
 	{
108 109
 		foreach ($context['unread_alerts'] as $id_alert => $details)
109 110
 		{
@@ -164,10 +165,11 @@  discard block
 block discarded – undo
164 165
 			<div class="custom_fields_above_name">
165 166
 				<ul >';
166 167
 
167
-		foreach ($context['print_custom_fields']['above_member'] as $field)
168
-			if (!empty($field['output_html']))
168
+		foreach ($context['print_custom_fields']['above_member'] as $field) {
169
+					if (!empty($field['output_html']))
169 170
 				echo '
170 171
 					<li>', $field['output_html'], '</li>';
172
+		}
171 173
 
172 174
 		echo '
173 175
 				</ul>
@@ -188,10 +190,11 @@  discard block
 block discarded – undo
188 190
 			<div class="custom_fields_below_avatar">
189 191
 				<ul >';
190 192
 
191
-		foreach ($context['print_custom_fields']['below_avatar'] as $field)
192
-			if (!empty($field['output_html']))
193
+		foreach ($context['print_custom_fields']['below_avatar'] as $field) {
194
+					if (!empty($field['output_html']))
193 195
 				echo '
194 196
 					<li>', $field['output_html'], '</li>';
197
+		}
195 198
 
196 199
 		echo '
197 200
 				</ul>
@@ -202,22 +205,25 @@  discard block
 block discarded – undo
202 205
 		echo '
203 206
 			<ul class="clear">';
204 207
 	// Email is only visible if it's your profile or you have the moderate_forum permission
205
-	if ($context['member']['show_email'])
206
-		echo '
208
+	if ($context['member']['show_email']) {
209
+			echo '
207 210
 				<li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>';
211
+	}
208 212
 
209 213
 	// Don't show an icon if they haven't specified a website.
210
-	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website']))
211
-		echo '
214
+	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) {
215
+			echo '
212 216
 				<li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
217
+	}
213 218
 
214 219
 	// Are there any custom profile fields as icons?
215 220
 	if (!empty($context['print_custom_fields']['icons']))
216 221
 	{
217
-		foreach ($context['print_custom_fields']['icons'] as $field)
218
-			if (!empty($field['output_html']))
222
+		foreach ($context['print_custom_fields']['icons'] as $field) {
223
+					if (!empty($field['output_html']))
219 224
 				echo '
220 225
 					<li class="custom_field">', $field['output_html'], '</li>';
226
+		}
221 227
 	}
222 228
 
223 229
 	echo '
@@ -225,23 +231,26 @@  discard block
 block discarded – undo
225 231
 			<span id="userstatus">', $context['can_send_pm'] ? '<a href="' . $context['member']['online']['href'] . '" title="' . $context['member']['online']['text'] . '" rel="nofollow">' : '', $settings['use_image_buttons'] ? '<span class="' . ($context['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $context['member']['online']['text'] . '"></span>' : $context['member']['online']['label'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $context['member']['online']['label'] . '</span>' : '';
226 232
 
227 233
 	// Can they add this member as a buddy?
228
-	if (!empty($context['can_have_buddy']) && !$context['user']['is_owner'])
229
-		echo '
234
+	if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) {
235
+			echo '
230 236
 				<br><a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a>';
237
+	}
231 238
 
232 239
 	echo '
233 240
 			</span>';
234 241
 
235
-	if (!$context['user']['is_owner'] && $context['can_send_pm'])
236
-		echo '
242
+	if (!$context['user']['is_owner'] && $context['can_send_pm']) {
243
+			echo '
237 244
 			<a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>';
245
+	}
238 246
 
239 247
 	echo '
240 248
 			<a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>';
241 249
 
242
-	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled']))
243
-		echo '
250
+	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) {
251
+			echo '
244 252
 			<a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>';
253
+	}
245 254
 
246 255
 	echo '
247 256
 			<a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>';
@@ -253,10 +262,11 @@  discard block
 block discarded – undo
253 262
 			<div class="custom_fields_bottom">
254 263
 				<ul class="nolist">';
255 264
 
256
-		foreach ($context['print_custom_fields']['bottom_poster'] as $field)
257
-			if (!empty($field['output_html']))
265
+		foreach ($context['print_custom_fields']['bottom_poster'] as $field) {
266
+					if (!empty($field['output_html']))
258 267
 				echo '
259 268
 					<li>', $field['output_html'], '</li>';
269
+		}
260 270
 
261 271
 		echo '
262 272
 				</ul>
@@ -270,15 +280,17 @@  discard block
 block discarded – undo
270 280
 		<div id="detailedinfo">
271 281
 			<dl class="settings">';
272 282
 
273
-	if ($context['user']['is_owner'] || $context['user']['is_admin'])
274
-		echo '
283
+	if ($context['user']['is_owner'] || $context['user']['is_admin']) {
284
+			echo '
275 285
 				<dt>', $txt['username'], ': </dt>
276 286
 				<dd>', $context['member']['username'], '</dd>';
287
+	}
277 288
 
278
-	if (!isset($context['disabled_fields']['posts']))
279
-		echo '
289
+	if (!isset($context['disabled_fields']['posts'])) {
290
+			echo '
280 291
 				<dt>', $txt['profile_posts'], ': </dt>
281 292
 				<dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>';
293
+	}
282 294
 
283 295
 	if ($context['member']['show_email'])
284 296
 	{
@@ -287,15 +299,17 @@  discard block
 block discarded – undo
287 299
 				<dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>';
288 300
 	}
289 301
 
290
-	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title']))
291
-		echo '
302
+	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) {
303
+			echo '
292 304
 				<dt>', $txt['custom_title'], ': </dt>
293 305
 				<dd>', $context['member']['title'], '</dd>';
306
+	}
294 307
 
295
-	if (!empty($context['member']['blurb']))
296
-		echo '
308
+	if (!empty($context['member']['blurb'])) {
309
+			echo '
297 310
 				<dt>', $txt['personal_text'], ': </dt>
298 311
 				<dd>', $context['member']['blurb'], '</dd>';
312
+	}
299 313
 
300 314
 	echo '
301 315
 				<dt>', $txt['age'], ':</dt>
@@ -309,19 +323,21 @@  discard block
 block discarded – undo
309 323
 	{
310 324
 		$fields = array();
311 325
 
312
-		foreach ($context['print_custom_fields']['standard'] as $field)
313
-			if (!empty($field['output_html']))
326
+		foreach ($context['print_custom_fields']['standard'] as $field) {
327
+					if (!empty($field['output_html']))
314 328
 				$fields[] = $field;
329
+		}
315 330
 
316 331
 		if (count($fields) > 0)
317 332
 		{
318 333
 			echo '
319 334
 				<dl class="settings">';
320 335
 
321
-			foreach ($fields as $field)
322
-				echo '
336
+			foreach ($fields as $field) {
337
+							echo '
323 338
 					<dt>', $field['name'], ':</dt>
324 339
 					<dd>', $field['output_html'], '</dd>';
340
+			}
325 341
 
326 342
 			echo '
327 343
 				</dl>';
@@ -341,9 +357,10 @@  discard block
 block discarded – undo
341 357
 						<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>';
342 358
 
343 359
 		// Can we provide information on what this means?
344
-		if (!empty($context['warning_status']))
345
-			echo '
360
+		if (!empty($context['warning_status'])) {
361
+					echo '
346 362
 						<span class="smalltext">(', $context['warning_status'], ')</span>';
363
+		}
347 364
 
348 365
 		echo '
349 366
 					</dd>';
@@ -354,9 +371,10 @@  discard block
 block discarded – undo
354 371
 	{
355 372
 
356 373
 		// If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves.
357
-		if (!empty($context['activate_message']))
358
-			echo '
374
+		if (!empty($context['activate_message'])) {
375
+					echo '
359 376
 					<dt class="clear"><span class="alert">', $context['activate_message'], '</span>&nbsp;(<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>)</dt>';
377
+		}
360 378
 
361 379
 		// If the current member is banned, show a message and possibly a link to the ban.
362 380
 		if (!empty($context['member']['bans']))
@@ -366,9 +384,10 @@  discard block
 block discarded – undo
366 384
 					<dt class="clear" id="ban_info" style="display: none;">
367 385
 						<strong>', $txt['user_banned_by_following'], ':</strong>';
368 386
 
369
-			foreach ($context['member']['bans'] as $ban)
370
-				echo '
387
+			foreach ($context['member']['bans'] as $ban) {
388
+							echo '
371 389
 						<br><span class="smalltext">', $ban['explanation'], '</span>';
390
+			}
372 391
 
373 392
 			echo '
374 393
 					</dt>';
@@ -382,30 +401,34 @@  discard block
 block discarded – undo
382 401
 	// If the person looking is allowed, they can check the members IP address and hostname.
383 402
 	if ($context['can_see_ip'])
384 403
 	{
385
-		if (!empty($context['member']['ip']))
386
-		echo '
404
+		if (!empty($context['member']['ip'])) {
405
+				echo '
387 406
 					<dt>', $txt['ip'], ': </dt>
388 407
 					<dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>';
408
+		}
389 409
 
390
-		if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip']))
391
-			echo '
410
+		if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) {
411
+					echo '
392 412
 					<dt>', $txt['hostname'], ': </dt>
393 413
 					<dd>', $context['member']['hostname'], '</dd>';
414
+		}
394 415
 	}
395 416
 
396 417
 	echo '
397 418
 					<dt>', $txt['local_time'], ':</dt>
398 419
 					<dd>', $context['member']['local_time'], '</dd>';
399 420
 
400
-	if (!empty($modSettings['userLanguage']) && !empty($context['member']['language']))
401
-		echo '
421
+	if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) {
422
+			echo '
402 423
 					<dt>', $txt['language'], ':</dt>
403 424
 					<dd>', $context['member']['language'], '</dd>';
425
+	}
404 426
 
405
-	if ($context['member']['show_last_login'])
406
-		echo '
427
+	if ($context['member']['show_last_login']) {
428
+			echo '
407 429
 					<dt>', $txt['lastLoggedIn'], ': </dt>
408 430
 					<dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>';
431
+	}
409 432
 
410 433
 	echo '
411 434
 				</dl>';
@@ -417,10 +440,11 @@  discard block
 block discarded – undo
417 440
 				<div class="custom_fields_above_signature">
418 441
 					<ul class="nolist">';
419 442
 
420
-		foreach ($context['print_custom_fields']['above_signature'] as $field)
421
-			if (!empty($field['output_html']))
443
+		foreach ($context['print_custom_fields']['above_signature'] as $field) {
444
+					if (!empty($field['output_html']))
422 445
 				echo '
423 446
 						<li>', $field['output_html'], '</li>';
447
+		}
424 448
 
425 449
 		echo '
426 450
 					</ul>
@@ -428,12 +452,13 @@  discard block
 block discarded – undo
428 452
 	}
429 453
 
430 454
 	// Show the users signature.
431
-	if ($context['signature_enabled'] && !empty($context['member']['signature']))
432
-		echo '
455
+	if ($context['signature_enabled'] && !empty($context['member']['signature'])) {
456
+			echo '
433 457
 				<div class="signature">
434 458
 					<h5>', $txt['signature'], ':</h5>
435 459
 					', $context['member']['signature'], '
436 460
 				</div>';
461
+	}
437 462
 
438 463
 	// Are there any custom profile fields for below the signature?
439 464
 	if (!empty($context['print_custom_fields']['below_signature']))
@@ -442,10 +467,11 @@  discard block
 block discarded – undo
442 467
 				<div class="custom_fields_below_signature">
443 468
 					<ul class="nolist">';
444 469
 
445
-		foreach ($context['print_custom_fields']['below_signature'] as $field)
446
-			if (!empty($field['output_html']))
470
+		foreach ($context['print_custom_fields']['below_signature'] as $field) {
471
+					if (!empty($field['output_html']))
447 472
 				echo '
448 473
 						<li>', $field['output_html'], '</li>';
474
+		}
449 475
 
450 476
 		echo '
451 477
 					</ul>
@@ -490,62 +516,70 @@  discard block
 block discarded – undo
490 516
 				</div>
491 517
 				<div class="list_posts">';
492 518
 
493
-			if (!$post['approved'])
494
-				echo '
519
+			if (!$post['approved']) {
520
+							echo '
495 521
 					<div class="approve_post">
496 522
 						<em>', $txt['post_awaiting_approval'], '</em>
497 523
 					</div>';
524
+			}
498 525
 
499 526
 			echo '
500 527
 					', $post['body'], '
501 528
 				</div>';
502 529
 
503
-			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
504
-				echo '
530
+			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
531
+							echo '
505 532
 				<div class="floatright">
506 533
 					<ul class="quickbuttons">';
534
+			}
507 535
 
508 536
 			// If they *can* reply?
509
-			if ($post['can_reply'])
510
-				echo '
537
+			if ($post['can_reply']) {
538
+							echo '
511 539
 						<li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>';
540
+			}
512 541
 
513 542
 			// If they *can* quote?
514
-			if ($post['can_quote'])
515
-				echo '
543
+			if ($post['can_quote']) {
544
+							echo '
516 545
 						<li><a href="', $scripturl . '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>';
546
+			}
517 547
 
518 548
 			// How about... even... remove it entirely?!
519
-			if ($post['can_delete'])
520
-				echo '
549
+			if ($post['can_delete']) {
550
+							echo '
521 551
 						<li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
552
+			}
522 553
 
523
-			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
524
-				echo '
554
+			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
555
+							echo '
525 556
 					</ul>
526 557
 				</div>';
558
+			}
527 559
 
528 560
 			echo '
529 561
 			</div>';
530 562
 		}
563
+	} else {
564
+			template_show_list('attachments');
531 565
 	}
532
-	else
533
-		template_show_list('attachments');
534 566
 
535 567
 	// No posts? Just end with a informative message.
536
-	if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts'])))
537
-		echo '
568
+	if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) {
569
+			echo '
538 570
 			<div class="windowbg2">
539 571
 				', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), '
540 572
 			</div>';
573
+	}
541 574
 
542 575
 	// Show more page numbers.
543
-	if (!empty($context['page_index']))
544
-		echo '
576
+	if (!empty($context['page_index'])) {
577
+			echo '
545 578
 		<div class="pagesection">
546 579
 			<div class="pagelinks">', $context['page_index'], '</div>
547 580
 		</div>';
548
-}
581
+	}
582
+	}
549 583
 
550 584
 /**
551 585
  * Template for showing alerts within the alerts popup
@@ -555,11 +589,12 @@  discard block
 block discarded – undo
555 589
 	global $context, $txt, $scripturl;
556 590
 
557 591
 	// Do we have an update message?
558
-	if (!empty($context['update_message']))
559
-		echo '
592
+	if (!empty($context['update_message'])) {
593
+			echo '
560 594
 		<div class="infobox">
561 595
 			', $context['update_message'], '.
562 596
 		</div>';
597
+	}
563 598
 
564 599
 	echo '
565 600
 		<div class="cat_bar">
@@ -568,13 +603,12 @@  discard block
 block discarded – undo
568 603
 			</h3>
569 604
 		</div>';
570 605
 
571
-	if (empty($context['alerts']))
572
-		echo '
606
+	if (empty($context['alerts'])) {
607
+			echo '
573 608
 		<div class="information">
574 609
 			', $txt['alerts_none'], '
575 610
 		</div>';
576
-
577
-	else
611
+	} else
578 612
 	{
579 613
 		// Start the form.
580 614
 		echo '
@@ -636,12 +670,12 @@  discard block
 block discarded – undo
636 670
 		</div>' : '';
637 671
 
638 672
 	// No drafts? Just show an informative message.
639
-	if (empty($context['drafts']))
640
-		echo '
673
+	if (empty($context['drafts'])) {
674
+			echo '
641 675
 		<div class="windowbg2 centertext">
642 676
 			', $txt['draft_none'], '
643 677
 		</div>';
644
-	else
678
+	} else
645 679
 	{
646 680
 		// For every draft to be displayed, give it its own div, and show the important details of the draft.
647 681
 		foreach ($context['drafts'] as $draft)
@@ -652,11 +686,13 @@  discard block
 block discarded – undo
652 686
 					<div class="topic_details">
653 687
 						<h5><strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> &nbsp; &nbsp;';
654 688
 
655
-			if (!empty($draft['sticky']))
656
-				echo '<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>';
689
+			if (!empty($draft['sticky'])) {
690
+							echo '<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>';
691
+			}
657 692
 
658
-			if (!empty($draft['locked']))
659
-				echo '<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>';
693
+			if (!empty($draft['locked'])) {
694
+							echo '<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>';
695
+			}
660 696
 
661 697
 			echo '
662 698
 						</h5>
@@ -689,12 +725,13 @@  discard block
 block discarded – undo
689 725
 {
690 726
 	global $context, $scripturl, $txt;
691 727
 
692
-	if (!empty($context['saved_successful']))
693
-		echo '
728
+	if (!empty($context['saved_successful'])) {
729
+			echo '
694 730
 					<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
695
-	elseif (!empty($context['saved_failed']))
696
-		echo '
731
+	} elseif (!empty($context['saved_failed'])) {
732
+			echo '
697 733
 					<div class="errorbox">', $context['saved_failed'], '</div>';
734
+	}
698 735
 
699 736
 	echo '
700 737
 	<div id="edit_buddies">
@@ -708,24 +745,27 @@  discard block
 block discarded – undo
708 745
 				<th scope="col" class="quarter_table">', $txt['name'], '</th>
709 746
 				<th scope="col">', $txt['status'], '</th>';
710 747
 
711
-	if (allowedTo('moderate_forum'))
712
-		echo '
748
+	if (allowedTo('moderate_forum')) {
749
+			echo '
713 750
 				<th scope="col">', $txt['email'], '</th>';
751
+	}
714 752
 
715
-	if (!empty($context['custom_pf']))
716
-		foreach ($context['custom_pf'] as $column)
753
+	if (!empty($context['custom_pf'])) {
754
+			foreach ($context['custom_pf'] as $column)
717 755
 				echo '<th scope="col">', $column['label'], '</th>';
756
+	}
718 757
 
719 758
 	echo '
720 759
 				<th scope="col">', $txt['remove'], '</th>
721 760
 			</tr>';
722 761
 
723 762
 	// If they don't have any buddies don't list them!
724
-	if (empty($context['buddies']))
725
-		echo '
763
+	if (empty($context['buddies'])) {
764
+			echo '
726 765
 			<tr class="windowbg">
727 766
 				<td colspan="', allowedTo('moderate_forum') ? '10' : '9', '"><strong>', $txt['no_buddies'], '</strong></td>
728 767
 			</tr>';
768
+	}
729 769
 
730 770
 		// Now loop through each buddy showing info on each.
731 771
 	else
@@ -737,15 +777,17 @@  discard block
 block discarded – undo
737 777
 					<td>', $buddy['link'], '</td>
738 778
 					<td><a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a></td>';
739 779
 
740
-			if ($buddy['show_email'])
741
-				echo '
780
+			if ($buddy['show_email']) {
781
+							echo '
742 782
 					<td><a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a></td>';
783
+			}
743 784
 
744 785
 			// Show the custom profile fields for this user.
745
-			if (!empty($context['custom_pf']))
746
-				foreach ($context['custom_pf'] as $key => $column)
786
+			if (!empty($context['custom_pf'])) {
787
+							foreach ($context['custom_pf'] as $key => $column)
747 788
 					echo '
748 789
 						<td class="lefttext">', $buddy['options'][$key], '</td>';
790
+			}
749 791
 
750 792
 			echo '
751 793
 					<td><a href="', $scripturl, '?action=profile;area=lists;sa=buddies;u=', $context['id_member'], ';remove=', $buddy['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['buddy_remove'], '"></span></a></td>
@@ -775,9 +817,10 @@  discard block
 block discarded – undo
775 817
 			</dl>
776 818
 		</div>';
777 819
 
778
-	if (!empty($context['token_check']))
779
-		echo '
820
+	if (!empty($context['token_check'])) {
821
+			echo '
780 822
 			<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
823
+	}
781 824
 
782 825
 	echo '
783 826
 		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -803,12 +846,13 @@  discard block
 block discarded – undo
803 846
 {
804 847
 	global $context, $scripturl, $txt;
805 848
 
806
-	if (!empty($context['saved_successful']))
807
-		echo '
849
+	if (!empty($context['saved_successful'])) {
850
+			echo '
808 851
 					<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
809
-	elseif (!empty($context['saved_failed']))
810
-		echo '
852
+	} elseif (!empty($context['saved_failed'])) {
853
+			echo '
811 854
 					<div class="errorbox">', $context['saved_failed'], '</div>';
855
+	}
812 856
 
813 857
 	echo '
814 858
 	<div id="edit_buddies">
@@ -822,20 +866,22 @@  discard block
 block discarded – undo
822 866
 				<th scope="col" class="quarter_table">', $txt['name'], '</th>
823 867
 				<th scope="col">', $txt['status'], '</th>';
824 868
 
825
-	if (allowedTo('moderate_forum'))
826
-		echo '
869
+	if (allowedTo('moderate_forum')) {
870
+			echo '
827 871
 				<th scope="col">', $txt['email'], '</th>';
872
+	}
828 873
 
829 874
 	echo '
830 875
 				<th scope="col">', $txt['ignore_remove'], '</th>
831 876
 			</tr>';
832 877
 
833 878
 	// If they don't have anyone on their ignore list, don't list it!
834
-	if (empty($context['ignore_list']))
835
-		echo '
879
+	if (empty($context['ignore_list'])) {
880
+			echo '
836 881
 			<tr class="windowbg">
837 882
 				<td colspan="', allowedTo('moderate_forum') ? '4' : '3', '"><strong>', $txt['no_ignore'], '</strong></td>
838 883
 			</tr>';
884
+	}
839 885
 
840 886
 	// Now loop through each buddy showing info on each.
841 887
 	foreach ($context['ignore_list'] as $member)
@@ -845,9 +891,10 @@  discard block
 block discarded – undo
845 891
 				<td>', $member['link'], '</td>
846 892
 				<td><a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a></td>';
847 893
 
848
-		if ($member['show_email'])
849
-			echo '
894
+		if ($member['show_email']) {
895
+					echo '
850 896
 				<td><a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a></td>';
897
+		}
851 898
 		echo '
852 899
 				<td><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['ignore_remove'], '"></span></a></td>
853 900
 			</tr>';
@@ -874,9 +921,10 @@  discard block
 block discarded – undo
874 921
 			</dl>
875 922
 		</div>';
876 923
 
877
-	if (!empty($context['token_check']))
878
-		echo '
924
+	if (!empty($context['token_check'])) {
925
+			echo '
879 926
 		<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
927
+	}
880 928
 
881 929
 	echo '
882 930
 		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -921,9 +969,10 @@  discard block
 block discarded – undo
921 969
 					<a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>';
922 970
 
923 971
 	// Second address detected?
924
-	if (!empty($context['last_ip2']))
925
-		echo '
972
+	if (!empty($context['last_ip2'])) {
973
+			echo '
926 974
 					, <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>';
975
+	}
927 976
 
928 977
 	echo '
929 978
 				</dd>';
@@ -988,9 +1037,10 @@  discard block
 block discarded – undo
988 1037
 				<h3 class="catbg">', $txt['whois_title'], ' ', $context['ip'], '</h3>
989 1038
 			</div>
990 1039
 			<div class="windowbg2 noup">';
991
-			foreach ($context['whois_servers'] as $server)
992
-			echo '
1040
+			foreach ($context['whois_servers'] as $server) {
1041
+						echo '
993 1042
 				<a href="', $server['url'], '" target="_blank"', isset($context['auto_whois_server']) && $context['auto_whois_server']['name'] == $server['name'] ? ' style="font-weight: bold;"' : '', '>', $server['name'], '</a><br>';
1043
+			}
994 1044
 			echo '
995 1045
 			</div>
996 1046
 			<br>';
@@ -1001,10 +1051,10 @@  discard block
 block discarded – undo
1001 1051
 		<div class="cat_bar">
1002 1052
 			<h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3>
1003 1053
 		</div>';
1004
-	if (empty($context['ips']))
1005
-		echo '
1054
+	if (empty($context['ips'])) {
1055
+			echo '
1006 1056
 		<p class="windowbg2 description"><em>', $txt['no_members_from_ip'], '</em></p>';
1007
-	else
1057
+	} else
1008 1058
 	{
1009 1059
 		echo '
1010 1060
 		<table class="table_grid">
@@ -1017,12 +1067,13 @@  discard block
 block discarded – undo
1017 1067
 			<tbody>';
1018 1068
 
1019 1069
 		// Loop through each of the members and display them.
1020
-		foreach ($context['ips'] as $ip => $memberlist)
1021
-			echo '
1070
+		foreach ($context['ips'] as $ip => $memberlist) {
1071
+					echo '
1022 1072
 				<tr class="windowbg">
1023 1073
 					<td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td>
1024 1074
 					<td>', implode(', ', $memberlist), '</td>
1025 1075
 				</tr>';
1076
+		}
1026 1077
 
1027 1078
 		echo '
1028 1079
 			</tbody>
@@ -1068,8 +1119,7 @@  discard block
 block discarded – undo
1068 1119
 	{
1069 1120
 		echo '
1070 1121
 		<div class="information">', $txt['showPermissions_all'], '</div>';
1071
-	}
1072
-	else
1122
+	} else
1073 1123
 	{
1074 1124
 		echo '
1075 1125
 		<div class="information">',$txt['showPermissions_help'], '</div>
@@ -1083,9 +1133,10 @@  discard block
 block discarded – undo
1083 1133
 				</div>
1084 1134
 				<div class="windowbg smalltext">
1085 1135
 					', $txt['showPermissions_restricted_boards_desc'], ':<br>';
1086
-				foreach ($context['no_access_boards'] as $no_access_board)
1087
-					echo '
1136
+				foreach ($context['no_access_boards'] as $no_access_board) {
1137
+									echo '
1088 1138
 						<a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', ';
1139
+				}
1089 1140
 				echo '
1090 1141
 				</div>';
1091 1142
 		}
@@ -1117,12 +1168,13 @@  discard block
 block discarded – undo
1117 1168
 								</td>
1118 1169
 								<td class="smalltext">';
1119 1170
 
1120
-				if ($permission['is_denied'])
1121
-					echo '
1171
+				if ($permission['is_denied']) {
1172
+									echo '
1122 1173
 									<span class="alert">', $txt['showPermissions_denied'], ':&nbsp;', implode(', ', $permission['groups']['denied']), '</span>';
1123
-				else
1124
-					echo '
1174
+				} else {
1175
+									echo '
1125 1176
 									', $txt['showPermissions_given'], ':&nbsp;', implode(', ', $permission['groups']['allowed']);
1177
+				}
1126 1178
 
1127 1179
 					echo '
1128 1180
 								</td>
@@ -1132,10 +1184,10 @@  discard block
 block discarded – undo
1132 1184
 						</tbody>
1133 1185
 					</table>
1134 1186
 				</div><br>';
1135
-		}
1136
-		else
1137
-			echo '
1187
+		} else {
1188
+					echo '
1138 1189
 			<p class="windowbg2">', $txt['showPermissions_none_general'], '</p>';
1190
+		}
1139 1191
 
1140 1192
 		// Board permission section.
1141 1193
 		echo '
@@ -1145,14 +1197,16 @@  discard block
 block discarded – undo
1145 1197
 						<a id="board_permissions"></a>', $txt['showPermissions_select'], ':
1146 1198
 						<select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();">
1147 1199
 							<option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], '&nbsp;</option>';
1148
-				if (!empty($context['boards']))
1149
-					echo '
1200
+				if (!empty($context['boards'])) {
1201
+									echo '
1150 1202
 							<option value="" disabled>---------------------------</option>';
1203
+				}
1151 1204
 
1152 1205
 				// Fill the box with any local permission boards.
1153
-				foreach ($context['boards'] as $board)
1154
-					echo '
1206
+				foreach ($context['boards'] as $board) {
1207
+									echo '
1155 1208
 							<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>';
1209
+				}
1156 1210
 
1157 1211
 				echo '
1158 1212
 						</select>
@@ -1183,8 +1237,7 @@  discard block
 block discarded – undo
1183 1237
 				{
1184 1238
 					echo '
1185 1239
 							<span class="alert">', $txt['showPermissions_denied'], ':&nbsp;', implode(', ', $permission['groups']['denied']), '</span>';
1186
-				}
1187
-				else
1240
+				} else
1188 1241
 				{
1189 1242
 					echo '
1190 1243
 							', $txt['showPermissions_given'], ': &nbsp;', implode(', ', $permission['groups']['allowed']);
@@ -1196,10 +1249,10 @@  discard block
 block discarded – undo
1196 1249
 			echo '
1197 1250
 				</tbody>
1198 1251
 			</table>';
1199
-		}
1200
-		else
1201
-			echo '
1252
+		} else {
1253
+					echo '
1202 1254
 			<p class="windowbg2">', $txt['showPermissions_none_board'], '</p>';
1255
+		}
1203 1256
 	echo '
1204 1257
 			</div>
1205 1258
 		</div>';
@@ -1241,9 +1294,10 @@  discard block
 block discarded – undo
1241 1294
 			</div>';
1242 1295
 
1243 1296
 	// If they haven't post at all, don't draw the graph.
1244
-	if (empty($context['posts_by_time']))
1245
-		echo '
1297
+	if (empty($context['posts_by_time'])) {
1298
+			echo '
1246 1299
 			<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1300
+	}
1247 1301
 	// Otherwise do!
1248 1302
 	else
1249 1303
 	{
@@ -1282,11 +1336,10 @@  discard block
 block discarded – undo
1282 1336
 					</h3>
1283 1337
 				</div>';
1284 1338
 
1285
-	if (empty($context['popular_boards']))
1286
-		echo '
1339
+	if (empty($context['popular_boards'])) {
1340
+			echo '
1287 1341
 				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1288
-
1289
-	else
1342
+	} else
1290 1343
 	{
1291 1344
 		echo '
1292 1345
 				<dl class="stats">';
@@ -1317,10 +1370,10 @@  discard block
 block discarded – undo
1317 1370
 					</h3>
1318 1371
 				</div>';
1319 1372
 
1320
-	if (empty($context['board_activity']))
1321
-		echo '
1373
+	if (empty($context['board_activity'])) {
1374
+			echo '
1322 1375
 				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1323
-	else
1376
+	} else
1324 1377
 	{
1325 1378
 		echo '
1326 1379
 				<dl class="stats">';
@@ -1368,41 +1421,46 @@  discard block
 block discarded – undo
1368 1421
 				<h3 class="catbg profile_hd">';
1369 1422
 
1370 1423
 		// Don't say "Profile" if this isn't the profile...
1371
-		if (!empty($context['profile_header_text']))
1372
-			echo '
1424
+		if (!empty($context['profile_header_text'])) {
1425
+					echo '
1373 1426
 					', $context['profile_header_text'];
1374
-		else
1375
-			echo '
1427
+		} else {
1428
+					echo '
1376 1429
 					', $txt['profile'];
1430
+		}
1377 1431
 
1378 1432
 		echo '
1379 1433
 				</h3>
1380 1434
 			</div>';
1381 1435
 
1382 1436
 	// Have we some description?
1383
-	if ($context['page_desc'])
1384
-		echo '
1437
+	if ($context['page_desc']) {
1438
+			echo '
1385 1439
 			<p class="information">', $context['page_desc'], '</p>';
1440
+	}
1386 1441
 
1387 1442
 	echo '
1388 1443
 			<div class="roundframe">';
1389 1444
 
1390 1445
 	// Any bits at the start?
1391
-	if (!empty($context['profile_prehtml']))
1392
-		echo '
1446
+	if (!empty($context['profile_prehtml'])) {
1447
+			echo '
1393 1448
 				<div>', $context['profile_prehtml'], '</div>';
1449
+	}
1394 1450
 
1395
-	if (!empty($context['profile_fields']))
1396
-		echo '
1451
+	if (!empty($context['profile_fields'])) {
1452
+			echo '
1397 1453
 				<dl class="settings">';
1454
+	}
1398 1455
 
1399 1456
 	// Start the big old loop 'of love.
1400 1457
 	$lastItem = 'hr';
1401 1458
 	foreach ($context['profile_fields'] as $key => $field)
1402 1459
 	{
1403 1460
 		// We add a little hack to be sure we never get more than one hr in a row!
1404
-		if ($lastItem == 'hr' && $field['type'] == 'hr')
1405
-			continue;
1461
+		if ($lastItem == 'hr' && $field['type'] == 'hr') {
1462
+					continue;
1463
+		}
1406 1464
 
1407 1465
 		$lastItem = $field['type'];
1408 1466
 		if ($field['type'] == 'hr')
@@ -1411,48 +1469,50 @@  discard block
 block discarded – undo
1411 1469
 				</dl>
1412 1470
 				<hr>
1413 1471
 				<dl class="settings">';
1414
-		}
1415
-		elseif ($field['type'] == 'callback')
1472
+		} elseif ($field['type'] == 'callback')
1416 1473
 		{
1417 1474
 			if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func']))
1418 1475
 			{
1419 1476
 				$callback_func = 'template_profile_' . $field['callback_func'];
1420 1477
 				$callback_func();
1421 1478
 			}
1422
-		}
1423
-		else
1479
+		} else
1424 1480
 		{
1425 1481
 			echo '
1426 1482
 					<dt>
1427 1483
 						<strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>';
1428 1484
 
1429 1485
 			// Does it have any subtext to show?
1430
-			if (!empty($field['subtext']))
1431
-				echo '
1486
+			if (!empty($field['subtext'])) {
1487
+							echo '
1432 1488
 						<br>
1433 1489
 						<span class="smalltext">', $field['subtext'], '</span>';
1490
+			}
1434 1491
 
1435 1492
 			echo '
1436 1493
 					</dt>
1437 1494
 					<dd>';
1438 1495
 
1439 1496
 			// Want to put something infront of the box?
1440
-			if (!empty($field['preinput']))
1441
-				echo '
1497
+			if (!empty($field['preinput'])) {
1498
+							echo '
1442 1499
 						', $field['preinput'];
1500
+			}
1443 1501
 
1444 1502
 			// What type of data are we showing?
1445
-			if ($field['type'] == 'label')
1446
-				echo '
1503
+			if ($field['type'] == 'label') {
1504
+							echo '
1447 1505
 						', $field['value'];
1506
+			}
1448 1507
 
1449 1508
 			// Maybe it's a text box - very likely!
1450 1509
 			elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url')))
1451 1510
 			{
1452
-				if ($field['type'] == 'int' || $field['type'] == 'float')
1453
-					$type = 'number';
1454
-				else
1455
-					$type = $field['type'];
1511
+				if ($field['type'] == 'int' || $field['type'] == 'float') {
1512
+									$type = 'number';
1513
+				} else {
1514
+									$type = $field['type'];
1515
+				}
1456 1516
 				$step = $field['type'] == 'float' ? ' step="0.1"' : '';
1457 1517
 
1458 1518
 
@@ -1460,9 +1520,10 @@  discard block
 block discarded – undo
1460 1520
 						<input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' ', $step, '>';
1461 1521
 			}
1462 1522
 			// You "checking" me out? ;)
1463
-			elseif ($field['type'] == 'check')
1464
-				echo '
1523
+			elseif ($field['type'] == 'check') {
1524
+							echo '
1465 1525
 						<input type="hidden" name="', $key, '" value="0"><input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" ', $field['input_attr'], '>';
1526
+			}
1466 1527
 
1467 1528
 			// Always fun - select boxes!
1468 1529
 			elseif ($field['type'] == 'select')
@@ -1473,13 +1534,15 @@  discard block
 block discarded – undo
1473 1534
 				if (isset($field['options']))
1474 1535
 				{
1475 1536
 					// Is this some code to generate the options?
1476
-					if (!is_array($field['options']))
1477
-						$field['options'] = $field['options']();
1537
+					if (!is_array($field['options'])) {
1538
+											$field['options'] = $field['options']();
1539
+					}
1478 1540
 					// Assuming we now have some!
1479
-					if (is_array($field['options']))
1480
-						foreach ($field['options'] as $value => $name)
1541
+					if (is_array($field['options'])) {
1542
+											foreach ($field['options'] as $value => $name)
1481 1543
 							echo '
1482 1544
 								<option value="', $value, '"', $value == $field['value'] ? ' selected' : '', '>', $name, '</option>';
1545
+					}
1483 1546
 				}
1484 1547
 
1485 1548
 				echo '
@@ -1487,25 +1550,28 @@  discard block
 block discarded – undo
1487 1550
 			}
1488 1551
 
1489 1552
 			// Something to end with?
1490
-			if (!empty($field['postinput']))
1491
-				echo '
1553
+			if (!empty($field['postinput'])) {
1554
+							echo '
1492 1555
 							', $field['postinput'];
1556
+			}
1493 1557
 
1494 1558
 			echo '
1495 1559
 					</dd>';
1496 1560
 		}
1497 1561
 	}
1498 1562
 
1499
-	if (!empty($context['profile_fields']))
1500
-		echo '
1563
+	if (!empty($context['profile_fields'])) {
1564
+			echo '
1501 1565
 				</dl>';
1566
+	}
1502 1567
 
1503 1568
 	// Are there any custom profile fields - if so print them!
1504 1569
 	if (!empty($context['custom_fields']))
1505 1570
 	{
1506
-		if ($lastItem != 'hr')
1507
-			echo '
1571
+		if ($lastItem != 'hr') {
1572
+					echo '
1508 1573
 				<hr>';
1574
+		}
1509 1575
 
1510 1576
 		echo '
1511 1577
 				<dl class="settings">';
@@ -1528,13 +1594,14 @@  discard block
 block discarded – undo
1528 1594
 	}
1529 1595
 
1530 1596
 	// Any closing HTML?
1531
-	if (!empty($context['profile_posthtml']))
1532
-		echo '
1597
+	if (!empty($context['profile_posthtml'])) {
1598
+			echo '
1533 1599
 				<div>', $context['profile_posthtml'], '</div>';
1600
+	}
1534 1601
 
1535 1602
 	// Only show the password box if it's actually needed.
1536
-	if ($context['require_password'])
1537
-		echo '
1603
+	if ($context['require_password']) {
1604
+			echo '
1538 1605
 				<dl class="settings">
1539 1606
 					<dt>
1540 1607
 						<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br>
@@ -1544,18 +1611,21 @@  discard block
 block discarded – undo
1544 1611
 						<input type="password" name="oldpasswrd" id="oldpasswrd" size="20" style="margin-right: 4ex;">
1545 1612
 					</dd>
1546 1613
 				</dl>';
1614
+	}
1547 1615
 
1548 1616
 	// The button shouldn't say "Change profile" unless we're changing the profile...
1549
-	if (!empty($context['submit_button_text']))
1550
-		echo '
1617
+	if (!empty($context['submit_button_text'])) {
1618
+			echo '
1551 1619
 				<input type="submit" name="save" value="', $context['submit_button_text'], '" class="button">';
1552
-	else
1553
-		echo '
1620
+	} else {
1621
+			echo '
1554 1622
 				<input type="submit" name="save" value="', $txt['change_profile'], '" class="button">';
1623
+	}
1555 1624
 
1556
-	if (!empty($context['token_check']))
1557
-		echo '
1625
+	if (!empty($context['token_check'])) {
1626
+			echo '
1558 1627
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
1628
+	}
1559 1629
 
1560 1630
 	echo '
1561 1631
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -1565,10 +1635,11 @@  discard block
 block discarded – undo
1565 1635
 		</form>';
1566 1636
 
1567 1637
 	// Any final spellchecking stuff?
1568
-	if (!empty($context['show_spellchecking']))
1569
-		echo '
1638
+	if (!empty($context['show_spellchecking'])) {
1639
+			echo '
1570 1640
 		<form name="spell_form" id="spell_form" method="post" accept-charset="', $context['character_set'], '" target="spellWindow" action="', $scripturl, '?action=spellcheck"><input type="hidden" name="spellstring" value=""></form>';
1571
-}
1641
+	}
1642
+	}
1572 1643
 
1573 1644
 /**
1574 1645
  * Personal Message settings.
@@ -1605,10 +1676,11 @@  discard block
 block discarded – undo
1605 1676
 										<select name="pm_receive_from" id="pm_receive_from">
1606 1677
 												<option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>';
1607 1678
 
1608
-	if (!empty($modSettings['enable_buddylist']))
1609
-		echo '
1679
+	if (!empty($modSettings['enable_buddylist'])) {
1680
+			echo '
1610 1681
 												<option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option>
1611 1682
 												<option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>';
1683
+	}
1612 1684
 
1613 1685
 	echo '
1614 1686
 												<option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option>
@@ -1651,11 +1723,12 @@  discard block
 block discarded – undo
1651 1723
 		if (empty($setting) || !is_array($setting))
1652 1724
 		{
1653 1725
 			// Insert a separator (unless this is the first item in the list)
1654
-			if ($i !== $first_option_key)
1655
-				echo '
1726
+			if ($i !== $first_option_key) {
1727
+							echo '
1656 1728
 				</dl>
1657 1729
 				<hr>
1658 1730
 				<dl class="settings">';
1731
+			}
1659 1732
 
1660 1733
 			// Should we give a name to this section?
1661 1734
 			if (is_string($setting) && !empty($setting))
@@ -1663,48 +1736,52 @@  discard block
 block discarded – undo
1663 1736
 				$titled_section = true;
1664 1737
 				echo '
1665 1738
 					<dt><strong>' . $setting . '</strong></dt><dd></dd>';
1739
+			} else {
1740
+							$titled_section = false;
1666 1741
 			}
1667
-			else
1668
-				$titled_section = false;
1669 1742
 
1670 1743
 			continue;
1671 1744
 		}
1672 1745
 
1673 1746
 		// Is this disabled?
1674
-		if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled']))
1675
-			continue;
1676
-		elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage']))
1677
-			continue;
1678
-		elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored']))
1679
-			continue;
1680
-		elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist']))
1681
-			continue;
1682
-		elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg']))
1683
-			continue;
1684
-		elseif ($setting['id'] == 'topics_per_page' && !empty($modSettings['disableCustomPerPage']))
1685
-			continue;
1686
-		elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled']))))
1687
-			continue;
1688
-		elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled']))))
1689
-			continue;
1747
+		if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) {
1748
+					continue;
1749
+		} elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) {
1750
+					continue;
1751
+		} elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) {
1752
+					continue;
1753
+		} elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) {
1754
+					continue;
1755
+		} elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) {
1756
+					continue;
1757
+		} elseif ($setting['id'] == 'topics_per_page' && !empty($modSettings['disableCustomPerPage'])) {
1758
+					continue;
1759
+		} elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) {
1760
+					continue;
1761
+		} elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) {
1762
+					continue;
1763
+		}
1690 1764
 
1691
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
1692
-			$setting['type'] = 'checkbox';
1693
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
1694
-			$setting['type'] = 'number';
1695
-		elseif ($setting['type'] == 'string')
1696
-			$setting['type'] = 'text';
1765
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
1766
+					$setting['type'] = 'checkbox';
1767
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
1768
+					$setting['type'] = 'number';
1769
+		} elseif ($setting['type'] == 'string') {
1770
+					$setting['type'] = 'text';
1771
+		}
1697 1772
 
1698
-		if (isset($setting['options']))
1699
-			$setting['type'] = 'list';
1773
+		if (isset($setting['options'])) {
1774
+					$setting['type'] = 'list';
1775
+		}
1700 1776
 
1701 1777
 		echo '
1702 1778
 					<dt>
1703 1779
 						<label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>';
1704 1780
 
1705
-		if (isset($setting['description']))
1706
-			echo '
1781
+		if (isset($setting['description'])) {
1782
+					echo '
1707 1783
 						<br><span class="smalltext">', $setting['description'], '</span>';
1784
+		}
1708 1785
 		echo '
1709 1786
 					</dt>
1710 1787
 					<dd>';
@@ -1742,13 +1819,11 @@  discard block
 block discarded – undo
1742 1819
 
1743 1820
 				echo '
1744 1821
 						<input type="number"', $min . $max . $step;
1745
-			}
1746
-			else if (isset($setting['type']) && $setting['type'] == 'url')
1822
+			} else if (isset($setting['type']) && $setting['type'] == 'url')
1747 1823
 			{
1748 1824
 				echo'
1749 1825
 						<input type="url"';
1750
-			}
1751
-			else
1826
+			} else
1752 1827
 			{
1753 1828
 				echo '
1754 1829
 						<input type="text"';
@@ -1787,8 +1862,8 @@  discard block
 block discarded – undo
1787 1862
 				<dl class="settings">';
1788 1863
 
1789 1864
 	// Allow notification on announcements to be disabled?
1790
-	if (!empty($modSettings['allow_disableAnnounce']))
1791
-		echo '
1865
+	if (!empty($modSettings['allow_disableAnnounce'])) {
1866
+			echo '
1792 1867
 					<dt>
1793 1868
 						<label for="notify_announcements">', $txt['notify_important_email'], '</label>
1794 1869
 					</dt>
@@ -1796,9 +1871,10 @@  discard block
 block discarded – undo
1796 1871
 						<input type="hidden" name="notify_announcements" value="0">
1797 1872
 						<input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', '>
1798 1873
 					</dd>';
1874
+	}
1799 1875
 
1800
-	if (!empty($modSettings['enable_ajax_alerts']))
1801
-		echo '
1876
+	if (!empty($modSettings['enable_ajax_alerts'])) {
1877
+			echo '
1802 1878
 					<dt>
1803 1879
 						<label for="notify_send_body">', $txt['notify_alert_timeout'], '</label>
1804 1880
 					</dt>
@@ -1806,6 +1882,7 @@  discard block
 block discarded – undo
1806 1882
 						<input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '">
1807 1883
 					</dd>
1808 1884
 		';
1885
+	}
1809 1886
 
1810 1887
 	echo '
1811 1888
 				</dl>
@@ -1835,9 +1912,10 @@  discard block
 block discarded – undo
1835 1912
 					<td colspan="3">';
1836 1913
 				$label = $txt['alert_opt_' . $opts[1]];
1837 1914
 				$label_pos = isset($opts['label']) ? $opts['label'] : '';
1838
-				if ($label_pos == 'before')
1839
-					echo '
1915
+				if ($label_pos == 'before') {
1916
+									echo '
1840 1917
 					<label for="opt_', $opts[1], '">', $label, '</label>';
1918
+				}
1841 1919
 
1842 1920
 				$this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0;
1843 1921
 				switch ($opts[0])
@@ -1849,17 +1927,19 @@  discard block
 block discarded – undo
1849 1927
 					case 'select':
1850 1928
 						echo '
1851 1929
 						<select name="opt_', $opts[1], '" id="opt_', $opts[1], '">';
1852
-						foreach ($opts['opts'] as $k => $v)
1853
-							echo '
1930
+						foreach ($opts['opts'] as $k => $v) {
1931
+													echo '
1854 1932
 							<option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>';
1933
+						}
1855 1934
 						echo '
1856 1935
 						</select>';
1857 1936
 						break;
1858 1937
 				}
1859 1938
 
1860
-				if ($label_pos == 'after')
1861
-					echo '
1939
+				if ($label_pos == 'after') {
1940
+									echo '
1862 1941
 					<label for="opt_', $opts[1], '">', $label, '</label>';
1942
+				}
1863 1943
 
1864 1944
 				echo '
1865 1945
 					</td>
@@ -1973,11 +2053,12 @@  discard block
 block discarded – undo
1973 2053
 			<p class="information">', $txt['groupMembership_info'], '</p>';
1974 2054
 
1975 2055
 	// Do we have an update message?
1976
-	if (!empty($context['update_message']))
1977
-		echo '
2056
+	if (!empty($context['update_message'])) {
2057
+			echo '
1978 2058
 			<div class="infobox">
1979 2059
 				', $context['update_message'], '.
1980 2060
 			</div>';
2061
+	}
1981 2062
 
1982 2063
 	echo '
1983 2064
 		<div id="groups">';
@@ -1999,8 +2080,7 @@  discard block
 block discarded – undo
1999 2080
 					</div>
2000 2081
 				</div>
2001 2082
 			</div>';
2002
-	}
2003
-	else
2083
+	} else
2004 2084
 	{
2005 2085
 		echo '
2006 2086
 			<div class="title_bar">
@@ -2012,27 +2092,30 @@  discard block
 block discarded – undo
2012 2092
 			echo '
2013 2093
 					<div class="windowbg" id="primdiv_', $group['id'], '">';
2014 2094
 
2015
-				if ($context['can_edit_primary'])
2016
-					echo '
2095
+				if ($context['can_edit_primary']) {
2096
+									echo '
2017 2097
 						<input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '"', $group['is_primary'] ? ' checked' : '', ' onclick="highlightSelected(\'primdiv_' . $group['id'] . '\');"', $group['can_be_primary'] ? '' : ' disabled', '>';
2098
+				}
2018 2099
 
2019 2100
 				echo '
2020 2101
 						<label for="primary_', $group['id'], '"><strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '</label>';
2021 2102
 
2022 2103
 				// Can they leave their group?
2023
-				if ($group['can_leave'])
2024
-					echo '
2104
+				if ($group['can_leave']) {
2105
+									echo '
2025 2106
 						<a href="' . $scripturl . '?action=profile;save;u=' . $context['id_member'] . ';area=groupmembership;' . $context['session_var'] . '=' . $context['session_id'] . ';gid=' . $group['id'] . ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">' . $txt['leave_group'] . '</a>';
2107
+				}
2026 2108
 
2027 2109
 				echo '
2028 2110
 					</div>';
2029 2111
 		}
2030 2112
 
2031
-		if ($context['can_edit_primary'])
2032
-			echo '
2113
+		if ($context['can_edit_primary']) {
2114
+					echo '
2033 2115
 			<div class="padding righttext">
2034 2116
 				<input type="submit" value="', $txt['make_primary'], '" class="button">
2035 2117
 			</div>';
2118
+		}
2036 2119
 
2037 2120
 		// Any groups they can join?
2038 2121
 		if (!empty($context['groups']['available']))
@@ -2048,15 +2131,16 @@  discard block
 block discarded – undo
2048 2131
 					<div class="windowbg">
2049 2132
 						<strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '';
2050 2133
 
2051
-				if ($group['type'] == 3)
2052
-					echo '
2134
+				if ($group['type'] == 3) {
2135
+									echo '
2053 2136
 						<a href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '" class="button floatright">', $txt['join_group'], '</a>';
2054
-				elseif ($group['type'] == 2 && $group['pending'])
2055
-					echo '
2137
+				} elseif ($group['type'] == 2 && $group['pending']) {
2138
+									echo '
2056 2139
 						<span class="floatright">', $txt['approval_pending'], '</span>';
2057
-				elseif ($group['type'] == 2)
2058
-					echo '
2140
+				} elseif ($group['type'] == 2) {
2141
+									echo '
2059 2142
 						<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>';
2143
+				}
2060 2144
 
2061 2145
 				echo '
2062 2146
 					</div>';
@@ -2079,9 +2163,10 @@  discard block
 block discarded – undo
2079 2163
 
2080 2164
 			prevDiv.className = "windowbg";
2081 2165
 		}';
2082
-		if (isset($context['groups']['member'][$context['primary_group']]))
2083
-			echo '
2166
+		if (isset($context['groups']['member'][$context['primary_group']])) {
2167
+					echo '
2084 2168
 		highlightSelected("primdiv_' . $context['primary_group'] . '");';
2169
+		}
2085 2170
 		echo '
2086 2171
 	</script>';
2087 2172
 	}
@@ -2089,9 +2174,10 @@  discard block
 block discarded – undo
2089 2174
 	echo '
2090 2175
 		</div>';
2091 2176
 
2092
-	if (!empty($context['token_check']))
2093
-		echo '
2177
+	if (!empty($context['token_check'])) {
2178
+			echo '
2094 2179
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2180
+	}
2095 2181
 
2096 2182
 	echo '
2097 2183
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2138,14 +2224,15 @@  discard block
 block discarded – undo
2138 2224
 
2139 2225
 		foreach ($category['boards'] as $board)
2140 2226
 		{
2141
-			if ($i == $limit)
2142
-				echo '
2227
+			if ($i == $limit) {
2228
+							echo '
2143 2229
 						</ul>
2144 2230
 					</li>
2145 2231
 				</ul>
2146 2232
 				<ul class="ignoreboards floatright">
2147 2233
 					<li class="category">
2148 2234
 						<ul>';
2235
+			}
2149 2236
 
2150 2237
 			echo '
2151 2238
 							<li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
@@ -2191,10 +2278,11 @@  discard block
 block discarded – undo
2191 2278
 
2192 2279
 	// Work out the starting color.
2193 2280
 	$context['current_color'] = $context['colors'][0];
2194
-	foreach ($context['colors'] as $limit => $color)
2195
-		if ($context['member']['warning'] >= $limit)
2281
+	foreach ($context['colors'] as $limit => $color) {
2282
+			if ($context['member']['warning'] >= $limit)
2196 2283
 			$context['current_color'] = $color;
2197
-}
2284
+	}
2285
+	}
2198 2286
 
2199 2287
 // Show all warnings of a user?
2200 2288
 function template_viewWarning()
@@ -2233,14 +2321,15 @@  discard block
 block discarded – undo
2233 2321
 				</dd>';
2234 2322
 
2235 2323
 		// There's some impact of this?
2236
-		if (!empty($context['level_effects'][$context['current_level']]))
2237
-			echo '
2324
+		if (!empty($context['level_effects'][$context['current_level']])) {
2325
+					echo '
2238 2326
 				<dt>
2239 2327
 					<strong>', $txt['profile_viewwarning_impact'], ':</strong>
2240 2328
 				</dt>
2241 2329
 				<dd>
2242 2330
 					', $context['level_effects'][$context['current_level']], '
2243 2331
 				</dd>';
2332
+		}
2244 2333
 
2245 2334
 		echo '
2246 2335
 			</dl>
@@ -2278,10 +2367,11 @@  discard block
 block discarded – undo
2278 2367
 
2279 2368
 			// Otherwise see what we can do...';
2280 2369
 
2281
-	foreach ($context['notification_templates'] as $k => $type)
2282
-		echo '
2370
+	foreach ($context['notification_templates'] as $k => $type) {
2371
+			echo '
2283 2372
 			if (index == ', $k, ')
2284 2373
 				document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";';
2374
+	}
2285 2375
 
2286 2376
 	echo '
2287 2377
 		}
@@ -2291,10 +2381,11 @@  discard block
 block discarded – undo
2291 2381
 			// Also set the right effect.
2292 2382
 			effectText = "";';
2293 2383
 
2294
-	foreach ($context['level_effects'] as $limit => $text)
2295
-		echo '
2384
+	foreach ($context['level_effects'] as $limit => $text) {
2385
+			echo '
2296 2386
 			if (slideAmount >= ', $limit, ')
2297 2387
 				effectText = "', $text, '";';
2388
+	}
2298 2389
 
2299 2390
 	echo '
2300 2391
 			setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\');
@@ -2309,31 +2400,34 @@  discard block
 block discarded – undo
2309 2400
 			</h3>
2310 2401
 		</div>';
2311 2402
 
2312
-	if (!$context['user']['is_owner'])
2313
-		echo '
2403
+	if (!$context['user']['is_owner']) {
2404
+			echo '
2314 2405
 		<p class="information">', $txt['profile_warning_desc'], '</p>';
2406
+	}
2315 2407
 
2316 2408
 	echo '
2317 2409
 		<div class="windowbg">
2318 2410
 			<dl class="settings">';
2319 2411
 
2320
-	if (!$context['user']['is_owner'])
2321
-		echo '
2412
+	if (!$context['user']['is_owner']) {
2413
+			echo '
2322 2414
 				<dt>
2323 2415
 					<strong>', $txt['profile_warning_name'], ':</strong>
2324 2416
 				</dt>
2325 2417
 				<dd>
2326 2418
 					<strong>', $context['member']['name'], '</strong>
2327 2419
 				</dd>';
2420
+	}
2328 2421
 
2329 2422
 	echo '
2330 2423
 				<dt>
2331 2424
 					<strong>', $txt['profile_warning_level'], ':</strong>';
2332 2425
 
2333 2426
 	// Is there only so much they can apply?
2334
-	if ($context['warning_limit'])
2335
-		echo '
2427
+	if ($context['warning_limit']) {
2428
+			echo '
2336 2429
 					<br><span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>';
2430
+	}
2337 2431
 
2338 2432
 	echo '
2339 2433
 				</dt>
@@ -2386,9 +2480,10 @@  discard block
 block discarded – undo
2386 2480
 						<option value="-1">', $txt['profile_warning_notify_template'], '</option>
2387 2481
 						<option value="-1" disabled>------------------------------</option>';
2388 2482
 
2389
-		foreach ($context['notification_templates'] as $id_template => $template)
2390
-			echo '
2483
+		foreach ($context['notification_templates'] as $id_template => $template) {
2484
+					echo '
2391 2485
 						<option value="', $id_template, '">', $template['title'], '</option>';
2486
+		}
2392 2487
 
2393 2488
 		echo '
2394 2489
 					</select>
@@ -2400,9 +2495,10 @@  discard block
 block discarded – undo
2400 2495
 			</dl>
2401 2496
 			<div class="righttext">';
2402 2497
 
2403
-	if (!empty($context['token_check']))
2404
-		echo '
2498
+	if (!empty($context['token_check'])) {
2499
+			echo '
2405 2500
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2501
+	}
2406 2502
 
2407 2503
 	echo '
2408 2504
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2418,8 +2514,8 @@  discard block
 block discarded – undo
2418 2514
 	echo '
2419 2515
 	<script>';
2420 2516
 
2421
-	if (!$context['user']['is_owner'])
2422
-		echo '
2517
+	if (!$context['user']['is_owner']) {
2518
+			echo '
2423 2519
 		modifyWarnNotify();
2424 2520
 		$(document).ready(function() {
2425 2521
 			$("#preview_button").click(function() {
@@ -2458,6 +2554,7 @@  discard block
 block discarded – undo
2458 2554
 			});
2459 2555
 			return false;
2460 2556
 		}';
2557
+	}
2461 2558
 
2462 2559
 	echo '
2463 2560
 	</script>';
@@ -2480,16 +2577,18 @@  discard block
 block discarded – undo
2480 2577
 			</div>';
2481 2578
 
2482 2579
 	// If deleting another account give them a lovely info box.
2483
-	if (!$context['user']['is_owner'])
2484
-		echo '
2580
+	if (!$context['user']['is_owner']) {
2581
+			echo '
2485 2582
 			<p class="information">', $txt['deleteAccount_desc'], '</p>';
2583
+	}
2486 2584
 	echo '
2487 2585
 			<div class="windowbg2">';
2488 2586
 
2489 2587
 	// If they are deleting their account AND the admin needs to approve it - give them another piece of info ;)
2490
-	if ($context['needs_approval'])
2491
-		echo '
2588
+	if ($context['needs_approval']) {
2589
+			echo '
2492 2590
 				<div class="errorbox">', $txt['deleteAccount_approval'], '</div>';
2591
+	}
2493 2592
 
2494 2593
 	// If the user is deleting their own account warn them first - and require a password!
2495 2594
 	if ($context['user']['is_owner'])
@@ -2501,9 +2600,10 @@  discard block
 block discarded – undo
2501 2600
 					<input type="password" name="oldpasswrd" size="20">&nbsp;&nbsp;&nbsp;&nbsp;
2502 2601
 					<input type="submit" value="', $txt['yes'], '" class="button">';
2503 2602
 
2504
-		if (!empty($context['token_check']))
2505
-			echo '
2603
+		if (!empty($context['token_check'])) {
2604
+					echo '
2506 2605
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2606
+		}
2507 2607
 
2508 2608
 		echo '
2509 2609
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2529,9 +2629,10 @@  discard block
 block discarded – undo
2529 2629
 						<option value="topics">', $txt['deleteAccount_topics'], '</option>
2530 2630
 					</select>';
2531 2631
 
2532
-			if ($context['show_perma_delete'])
2533
-				echo '
2632
+			if ($context['show_perma_delete']) {
2633
+							echo '
2534 2634
 					<br><label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1">', $txt['deleteAccount_permanent'], ':</label>';
2635
+			}
2535 2636
 
2536 2637
 			echo '
2537 2638
 				</div>';
@@ -2544,9 +2645,10 @@  discard block
 block discarded – undo
2544 2645
 				<div>
2545 2646
 					<input type="submit" value="', $txt['delete'], '" class="button">';
2546 2647
 
2547
-		if (!empty($context['token_check']))
2548
-			echo '
2648
+		if (!empty($context['token_check'])) {
2649
+					echo '
2549 2650
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2651
+		}
2550 2652
 
2551 2653
 		echo '
2552 2654
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2572,8 +2674,8 @@  discard block
 block discarded – undo
2572 2674
 					<hr>';
2573 2675
 
2574 2676
 	// Only show the password box if it's actually needed.
2575
-	if ($context['require_password'])
2576
-		echo '
2677
+	if ($context['require_password']) {
2678
+			echo '
2577 2679
 					<dl class="settings">
2578 2680
 						<dt>
2579 2681
 							<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br>
@@ -2583,13 +2685,15 @@  discard block
 block discarded – undo
2583 2685
 							<input type="password" name="oldpasswrd" size="20" style="margin-right: 4ex;">
2584 2686
 						</dd>
2585 2687
 					</dl>';
2688
+	}
2586 2689
 
2587 2690
 	echo '
2588 2691
 					<div class="righttext">';
2589 2692
 
2590
-		if (!empty($context['token_check']))
2591
-			echo '
2693
+		if (!empty($context['token_check'])) {
2694
+					echo '
2592 2695
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2696
+		}
2593 2697
 
2594 2698
 	echo '
2595 2699
 						<input type="submit" value="', $txt['change_profile'], '" class="button">
@@ -2616,9 +2720,10 @@  discard block
 block discarded – undo
2616 2720
 			<ul id="list_errors">';
2617 2721
 
2618 2722
 		// Cycle through each error and display an error message.
2619
-		foreach ($context['post_errors'] as $error)
2620
-			echo '
2723
+		foreach ($context['post_errors'] as $error) {
2724
+					echo '
2621 2725
 				<li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>';
2726
+		}
2622 2727
 
2623 2728
 		echo '
2624 2729
 			</ul>';
@@ -2644,12 +2749,13 @@  discard block
 block discarded – undo
2644 2749
 								<select name="id_group" ', ($context['user']['is_owner'] && $context['member']['group_id'] == 1 ? 'onchange="if (this.value != 1 &amp;&amp; !confirm(\'' . $txt['deadmin_confirm'] . '\')) this.value = 1;"' : ''), '>';
2645 2750
 
2646 2751
 		// Fill the select box with all primary member groups that can be assigned to a member.
2647
-		foreach ($context['member_groups'] as $member_group)
2648
-			if (!empty($member_group['can_be_primary']))
2752
+		foreach ($context['member_groups'] as $member_group) {
2753
+					if (!empty($member_group['can_be_primary']))
2649 2754
 				echo '
2650 2755
 									<option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '>
2651 2756
 										', $member_group['name'], '
2652 2757
 									</option>';
2758
+		}
2653 2759
 		echo '
2654 2760
 								</select>
2655 2761
 							</dd>
@@ -2661,10 +2767,11 @@  discard block
 block discarded – undo
2661 2767
 									<input type="hidden" name="additional_groups[]" value="0">';
2662 2768
 
2663 2769
 		// For each membergroup show a checkbox so members can be assigned to more than one group.
2664
-		foreach ($context['member_groups'] as $member_group)
2665
-			if ($member_group['can_be_additional'])
2770
+		foreach ($context['member_groups'] as $member_group) {
2771
+					if ($member_group['can_be_additional'])
2666 2772
 				echo '
2667 2773
 									<label for="additional_groups-', $member_group['id'], '"><input type="checkbox" name="additional_groups[]" value="', $member_group['id'], '" id="additional_groups-', $member_group['id'], '"', $member_group['is_additional'] ? ' checked' : '', '> ', $member_group['name'], '</label><br>';
2774
+		}
2668 2775
 		echo '
2669 2776
 								</span>
2670 2777
 								<a href="javascript:void(0);" onclick="document.getElementById(\'additional_groupsList\').style.display = \'block\'; document.getElementById(\'additional_groupsLink\').style.display = \'none\'; return false;" id="additional_groupsLink" style="display: none;" class="toggle_down">', $txt['additional_membergroups_show'], '</a>
@@ -2724,9 +2831,10 @@  discard block
 block discarded – undo
2724 2831
 								<span class="smalltext">', $txt['sig_info'], '</span><br>
2725 2832
 								<br>';
2726 2833
 
2727
-	if ($context['show_spellchecking'])
2728
-		echo '
2834
+	if ($context['show_spellchecking']) {
2835
+			echo '
2729 2836
 								<input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button">';
2837
+	}
2730 2838
 
2731 2839
 		echo '
2732 2840
 							</dt>
@@ -2734,17 +2842,20 @@  discard block
 block discarded – undo
2734 2842
 								<textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50" style="min-width: 50%; max-width: 99%;">', $context['member']['signature'], '</textarea><br>';
2735 2843
 
2736 2844
 	// If there is a limit at all!
2737
-	if (!empty($context['signature_limits']['max_length']))
2738
-		echo '
2845
+	if (!empty($context['signature_limits']['max_length'])) {
2846
+			echo '
2739 2847
 								<span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>';
2848
+	}
2740 2849
 
2741
-	if (!empty($context['show_preview_button']))
2742
-		echo '
2850
+	if (!empty($context['show_preview_button'])) {
2851
+			echo '
2743 2852
 								<input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button">';
2853
+	}
2744 2854
 
2745
-	if ($context['signature_warning'])
2746
-		echo '
2855
+	if ($context['signature_warning']) {
2856
+			echo '
2747 2857
 								<span class="smalltext">', $context['signature_warning'], '</span>';
2858
+	}
2748 2859
 
2749 2860
 	// Some javascript used to count how many characters have been used so far in the signature.
2750 2861
 	echo '
@@ -2788,9 +2899,10 @@  discard block
 block discarded – undo
2788 2899
 									<div>
2789 2900
 										<select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">';
2790 2901
 		// This lists all the file categories.
2791
-		foreach ($context['avatars'] as $avatar)
2792
-			echo '
2902
+		foreach ($context['avatars'] as $avatar) {
2903
+					echo '
2793 2904
 											<option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>';
2905
+		}
2794 2906
 		echo '
2795 2907
 										</select>
2796 2908
 									</div>
@@ -2845,16 +2957,17 @@  discard block
 block discarded – undo
2845 2957
 								<div id="avatar_gravatar">
2846 2958
 									<img src="' . $context['member']['avatar']['href'] . '" alt="" />';
2847 2959
 
2848
-		if (empty($modSettings['gravatarAllowExtraEmail']))
2849
-			echo '
2960
+		if (empty($modSettings['gravatarAllowExtraEmail'])) {
2961
+					echo '
2850 2962
 									<div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>';
2851
-		else
2963
+		} else
2852 2964
 		{
2853 2965
 			// Depending on other stuff, the stored value here might have some odd things in it from other areas.
2854
-			if ($context['member']['avatar']['external'] == $context['member']['email'])
2855
-				$textbox_value = '';
2856
-			else
2857
-				$textbox_value = $context['member']['avatar']['external'];
2966
+			if ($context['member']['avatar']['external'] == $context['member']['email']) {
2967
+							$textbox_value = '';
2968
+			} else {
2969
+							$textbox_value = $context['member']['avatar']['external'];
2970
+			}
2858 2971
 
2859 2972
 			echo '
2860 2973
 									<div class="smalltext">', $txt['gravatar_alternateEmail'], '</div>
@@ -2926,8 +3039,9 @@  discard block
 block discarded – undo
2926 3039
 	$h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0;
2927 3040
 
2928 3041
 	$suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : '');
2929
-	if (empty($suffix))
2930
-		return;
3042
+	if (empty($suffix)) {
3043
+			return;
3044
+	}
2931 3045
 
2932 3046
 	echo '
2933 3047
 									<div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>';
@@ -2949,9 +3063,10 @@  discard block
 block discarded – undo
2949 3063
 							<dd>
2950 3064
 								<select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;" style="margin-bottom: 4px;">';
2951 3065
 	// Help the user by showing a list of common time formats.
2952
-	foreach ($context['easy_timeformats'] as $time_format)
2953
-		echo '
3066
+	foreach ($context['easy_timeformats'] as $time_format) {
3067
+			echo '
2954 3068
 									<option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>';
3069
+	}
2955 3070
 	echo '
2956 3071
 								</select><br>
2957 3072
 								<input type="text" name="time_format" id="time_format" value="', $context['member']['time_format'], '" size="30">
@@ -2987,9 +3102,10 @@  discard block
 block discarded – undo
2987 3102
 							</dt>
2988 3103
 							<dd>
2989 3104
 								<select name="smiley_set" id="smiley_set" onchange="document.getElementById(\'smileypr\').src = this.selectedIndex == 0 ? \'', $settings['images_url'], '/blank.png\' : \'', $modSettings['smileys_url'], '/\' + (this.selectedIndex != 1 ? this.options[this.selectedIndex].value : \'', !empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'], '\') + \'/smiley.gif\';">';
2990
-	foreach ($context['smiley_sets'] as $set)
2991
-		echo '
3105
+	foreach ($context['smiley_sets'] as $set) {
3106
+			echo '
2992 3107
 									<option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>';
3108
+	}
2993 3109
 	echo '
2994 3110
 								</select> <img id="smileypr" class="centericon" src="', $context['member']['smiley_set']['id'] != 'none' ? $modSettings['smileys_url'] . '/' . ($context['member']['smiley_set']['id'] != '' ? $context['member']['smiley_set']['id'] : (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'])) . '/smiley.gif' : $settings['images_url'] . '/blank.png', '" alt=":)"  style="padding-left: 20px;">
2995 3111
 							</dd>';
@@ -3040,10 +3156,11 @@  discard block
 block discarded – undo
3040 3156
 									</div>
3041 3157
 									<div class="clear"></div>';
3042 3158
 
3043
-	if (!empty($context['from_ajax']))
3044
-		echo '
3159
+	if (!empty($context['from_ajax'])) {
3160
+			echo '
3045 3161
 									<br>
3046 3162
 									<a href="javascript:self.close();"></a>';
3163
+	}
3047 3164
 
3048 3165
 	echo '
3049 3166
 								</div>
@@ -3082,15 +3199,16 @@  discard block
 block discarded – undo
3082 3199
 								<br><div class="smalltext">', $txt['tfa_profile_desc'], '</div>
3083 3200
 							</dt>
3084 3201
 							<dd>';
3085
-	if (!$context['tfa_enabled'] && $context['user']['is_owner'])
3086
-		echo '
3202
+	if (!$context['tfa_enabled'] && $context['user']['is_owner']) {
3203
+			echo '
3087 3204
 								<a href="', !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>';
3088
-	elseif (!$context['tfa_enabled'])
3089
-		echo '
3205
+	} elseif (!$context['tfa_enabled']) {
3206
+			echo '
3090 3207
 								', $txt['tfa_profile_disabled'];
3091
-	else
3092
-		echo '
3208
+	} else {
3209
+			echo '
3093 3210
 							', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable');
3211
+	}
3094 3212
 	echo '
3095 3213
 							</dd>';
3096 3214
 }
Please login to merge, or discard this patch.
Sources/ManageMail.php 1 patch
Braces   +26 added lines, -18 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 4
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * Main dispatcher. This function checks permissions and passes control through to the relevant section.
@@ -245,8 +246,9 @@  discard block
 block discarded – undo
245 246
 	while ($row = $smcFunc['db_fetch_assoc']($request))
246 247
 	{
247 248
 		// Private PM/email subjects and similar shouldn't be shown in the mailbox area.
248
-		if (!empty($row['private']))
249
-			$row['subject'] = $txt['personal_message'];
249
+		if (!empty($row['private'])) {
250
+					$row['subject'] = $txt['personal_message'];
251
+		}
250 252
 
251 253
 		$mails[] = $row;
252 254
 	}
@@ -300,8 +302,9 @@  discard block
 block discarded – undo
300 302
 		$element = substr($key, strrpos($key, '_') + 1);
301 303
 		$processedBirthdayEmails[$index][$element] = $value;
302 304
 	}
303
-	foreach ($processedBirthdayEmails as $index => $dummy)
304
-		$emails[$index] = $index;
305
+	foreach ($processedBirthdayEmails as $index => $dummy) {
306
+			$emails[$index] = $index;
307
+	}
305 308
 
306 309
 	$config_vars = array(
307 310
 			// Mail queue stuff, this rocks ;)
@@ -322,8 +325,9 @@  discard block
 block discarded – undo
322 325
 
323 326
 	call_integration_hook('integrate_modify_mail_settings', array(&$config_vars));
324 327
 
325
-	if ($return_config)
326
-		return $config_vars;
328
+	if ($return_config) {
329
+			return $config_vars;
330
+	}
327 331
 
328 332
 	// Saving?
329 333
 	if (isset($_GET['save']))
@@ -398,9 +402,9 @@  discard block
 block discarded – undo
398 402
 		);
399 403
 		list ($_GET['te']) = $smcFunc['db_fetch_row']($request);
400 404
 		$smcFunc['db_free_result']($request);
405
+	} else {
406
+			$_GET['te'] = (int) $_GET['te'];
401 407
 	}
402
-	else
403
-		$_GET['te'] = (int) $_GET['te'];
404 408
 
405 409
 	$_GET['sent'] = isset($_GET['sent']) ? (int) $_GET['sent'] : 0;
406 410
 
@@ -424,12 +428,14 @@  discard block
 block discarded – undo
424 428
 
425 429
 	// Try get more time...
426 430
 	@set_time_limit(600);
427
-	if (function_exists('apache_reset_timeout'))
428
-		@apache_reset_timeout();
431
+	if (function_exists('apache_reset_timeout')) {
432
+			@apache_reset_timeout();
433
+	}
429 434
 
430 435
 	// Have we already used our maximum time?
431
-	if ((time() - $time_start) < 5)
432
-		return;
436
+	if ((time() - $time_start) < 5) {
437
+			return;
438
+	}
433 439
 
434 440
 	$context['continue_get_data'] = '?action=admin;area=mailqueue;sa=clear;te=' . $_GET['te'] . ';sent=' . $_GET['sent'] . ';' . $context['session_var'] . '=' . $context['session_id'];
435 441
 	$context['page_title'] = $txt['not_done_title'];
@@ -459,8 +465,9 @@  discard block
 block discarded – undo
459 465
 {
460 466
 	global $txt;
461 467
 
462
-	if ($time_diff < 0)
463
-		$time_diff = 0;
468
+	if ($time_diff < 0) {
469
+			$time_diff = 0;
470
+	}
464 471
 
465 472
 	// Just do a bit of an if fest...
466 473
 	if ($time_diff > 86400)
@@ -481,8 +488,9 @@  discard block
 block discarded – undo
481 488
 		return sprintf($minutes == 1 ? $txt['mq_minute'] : $txt['mq_minutes'], $minutes);
482 489
 	}
483 490
 	// Otherwise must be second
484
-	else
485
-		return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff);
486
-}
491
+	else {
492
+			return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff);
493
+	}
494
+	}
487 495
 
488 496
 ?>
489 497
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/ManageAttachments.php 1 patch
Braces   +429 added lines, -325 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * The main 'Attachments and Avatars' management function.
@@ -63,10 +64,11 @@  discard block
 block discarded – undo
63 64
 	call_integration_hook('integrate_manage_attachments', array(&$subActions));
64 65
 
65 66
 	// Pick the correct sub-action.
66
-	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]))
67
-		$context['sub_action'] = $_REQUEST['sa'];
68
-	else
69
-		$context['sub_action'] = 'browse';
67
+	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
68
+			$context['sub_action'] = $_REQUEST['sa'];
69
+	} else {
70
+			$context['sub_action'] = 'browse';
71
+	}
70 72
 
71 73
 	// Default page title is good.
72 74
 	$context['page_title'] = $txt['attachments_avatars'];
@@ -94,20 +96,20 @@  discard block
 block discarded – undo
94 96
 	$context['attachmentUploadDir'] = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
95 97
 
96 98
 	// If not set, show a default path for the base directory
97
-	if (!isset($_GET['save']) && empty($modSettings['basedirectory_for_attachments']))
98
-		if (is_dir($modSettings['attachmentUploadDir'][1]))
99
+	if (!isset($_GET['save']) && empty($modSettings['basedirectory_for_attachments'])) {
100
+			if (is_dir($modSettings['attachmentUploadDir'][1]))
99 101
 			$modSettings['basedirectory_for_attachments'] = $modSettings['attachmentUploadDir'][1];
100
-
101
-	else
102
-		$modSettings['basedirectory_for_attachments'] = $context['attachmentUploadDir'];
102
+	} else {
103
+			$modSettings['basedirectory_for_attachments'] = $context['attachmentUploadDir'];
104
+	}
103 105
 
104 106
 	$context['valid_upload_dir'] = is_dir($context['attachmentUploadDir']) && is_writable($context['attachmentUploadDir']);
105 107
 
106
-	if (!empty($modSettings['automanage_attachments']))
107
-		$context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']);
108
-
109
-	else
110
-		$context['valid_basedirectory'] = true;
108
+	if (!empty($modSettings['automanage_attachments'])) {
109
+			$context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']);
110
+	} else {
111
+			$context['valid_basedirectory'] = true;
112
+	}
111 113
 
112 114
 	// A bit of razzle dazzle with the $txt strings. :)
113 115
 	$txt['attachment_path'] = $context['attachmentUploadDir'];
@@ -185,8 +187,9 @@  discard block
 block discarded – undo
185 187
 
186 188
 	call_integration_hook('integrate_modify_attachment_settings', array(&$config_vars));
187 189
 
188
-	if ($return_config)
189
-		return $config_vars;
190
+	if ($return_config) {
191
+			return $config_vars;
192
+	}
190 193
 
191 194
 	// These are very likely to come in handy! (i.e. without them we're doomed!)
192 195
 	require_once($sourcedir . '/ManagePermissions.php');
@@ -197,21 +200,24 @@  discard block
 block discarded – undo
197 200
 	{
198 201
 		checkSession();
199 202
 
200
-		if (isset($_POST['attachmentUploadDir']))
201
-			unset($_POST['attachmentUploadDir']);
203
+		if (isset($_POST['attachmentUploadDir'])) {
204
+					unset($_POST['attachmentUploadDir']);
205
+		}
202 206
 
203 207
 		if (!empty($_POST['use_subdirectories_for_attachments']))
204 208
 		{
205
-			if (isset($_POST['use_subdirectories_for_attachments']) && empty($_POST['basedirectory_for_attachments']))
206
-				$_POST['basedirectory_for_attachments'] = (!empty($modSettings['basedirectory_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir);
209
+			if (isset($_POST['use_subdirectories_for_attachments']) && empty($_POST['basedirectory_for_attachments'])) {
210
+							$_POST['basedirectory_for_attachments'] = (!empty($modSettings['basedirectory_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir);
211
+			}
207 212
 
208 213
 			if (!empty($_POST['use_subdirectories_for_attachments']) && !empty($modSettings['attachment_basedirectories']))
209 214
 			{
210
-				if (!is_array($modSettings['attachment_basedirectories']))
211
-					$modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true);
215
+				if (!is_array($modSettings['attachment_basedirectories'])) {
216
+									$modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true);
217
+				}
218
+			} else {
219
+							$modSettings['attachment_basedirectories'] = array();
212 220
 			}
213
-			else
214
-				$modSettings['attachment_basedirectories'] = array();
215 221
 
216 222
 			if (!empty($_POST['use_subdirectories_for_attachments']) && !empty($_POST['basedirectory_for_attachments']) && !in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']))
217 223
 			{
@@ -219,8 +225,9 @@  discard block
 block discarded – undo
219 225
 
220 226
 				if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachmentUploadDir']))
221 227
 				{
222
-					if (!automanage_attachments_create_directory($_POST['basedirectory_for_attachments']))
223
-						$_POST['basedirectory_for_attachments'] = $modSettings['basedirectory_for_attachments'];
228
+					if (!automanage_attachments_create_directory($_POST['basedirectory_for_attachments'])) {
229
+											$_POST['basedirectory_for_attachments'] = $modSettings['basedirectory_for_attachments'];
230
+					}
224 231
 				}
225 232
 
226 233
 				if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']))
@@ -336,8 +343,9 @@  discard block
 block discarded – undo
336 343
 
337 344
 	call_integration_hook('integrate_modify_avatar_settings', array(&$config_vars));
338 345
 
339
-	if ($return_config)
340
-		return $config_vars;
346
+	if ($return_config) {
347
+			return $config_vars;
348
+	}
341 349
 
342 350
 	// We need this file for the settings template.
343 351
 	require_once($sourcedir . '/ManageServer.php');
@@ -348,17 +356,21 @@  discard block
 block discarded – undo
348 356
 		checkSession();
349 357
 
350 358
 		// These settings cannot be left empty!
351
-		if (empty($_POST['custom_avatar_dir']))
352
-			$_POST['custom_avatar_dir'] = $boarddir . '/custom_avatar';
359
+		if (empty($_POST['custom_avatar_dir'])) {
360
+					$_POST['custom_avatar_dir'] = $boarddir . '/custom_avatar';
361
+		}
353 362
 
354
-		if (empty($_POST['custom_avatar_url']))
355
-			$_POST['custom_avatar_url'] = $boardurl . '/custom_avatar';
363
+		if (empty($_POST['custom_avatar_url'])) {
364
+					$_POST['custom_avatar_url'] = $boardurl . '/custom_avatar';
365
+		}
356 366
 
357
-		if (empty($_POST['avatar_directory']))
358
-			$_POST['avatar_directory'] = $boarddir . '/avatars';
367
+		if (empty($_POST['avatar_directory'])) {
368
+					$_POST['avatar_directory'] = $boarddir . '/avatars';
369
+		}
359 370
 
360
-		if (empty($_POST['avatar_url']))
361
-			$_POST['avatar_url'] = $boardurl . '/avatars';
371
+		if (empty($_POST['avatar_url'])) {
372
+					$_POST['avatar_url'] = $boardurl . '/avatars';
373
+		}
362 374
 
363 375
 		call_integration_hook('integrate_save_avatar_settings');
364 376
 
@@ -406,11 +418,13 @@  discard block
 block discarded – undo
406 418
 	$list_title = $txt['attachment_manager_browse_files'] . ': ';
407 419
 	foreach ($titles as $browse_type => $details)
408 420
 	{
409
-		if ($browse_type != 'attachments')
410
-			$list_title .= ' | ';
421
+		if ($browse_type != 'attachments') {
422
+					$list_title .= ' | ';
423
+		}
411 424
 
412
-		if ($context['browse_type'] == $browse_type)
413
-			$list_title .= '<img src="' . $settings['images_url'] . '/selected.png" alt="&gt;"> ';
425
+		if ($context['browse_type'] == $browse_type) {
426
+					$list_title .= '<img src="' . $settings['images_url'] . '/selected.png" alt="&gt;"> ';
427
+		}
414 428
 
415 429
 		$list_title .= '<a href="' . $scripturl . $details[0] . '">' . $details[1] . '</a>';
416 430
 	}
@@ -446,28 +460,33 @@  discard block
 block discarded – undo
446 460
 						$link = '<a href="';
447 461
 
448 462
 						// In case of a custom avatar URL attachments have a fixed directory.
449
-						if ($rowData['attachment_type'] == 1)
450
-							$link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']);
463
+						if ($rowData['attachment_type'] == 1) {
464
+													$link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']);
465
+						}
451 466
 
452 467
 						// By default avatars are downloaded almost as attachments.
453
-						elseif ($context['browse_type'] == 'avatars')
454
-							$link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']);
468
+						elseif ($context['browse_type'] == 'avatars') {
469
+													$link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']);
470
+						}
455 471
 
456 472
 						// Normal attachments are always linked to a topic ID.
457
-						else
458
-							$link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d', $scripturl, $rowData['id_topic'], $rowData['id_attach']);
473
+						else {
474
+													$link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d', $scripturl, $rowData['id_topic'], $rowData['id_attach']);
475
+						}
459 476
 
460 477
 						$link .= '"';
461 478
 
462 479
 						// Show a popup on click if it's a picture and we know its dimensions.
463
-						if (!empty($rowData['width']) && !empty($rowData['height']))
464
-							$link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : ' + \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20);
480
+						if (!empty($rowData['width']) && !empty($rowData['height'])) {
481
+													$link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : ' + \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20);
482
+						}
465 483
 
466 484
 						$link .= sprintf('>%1$s</a>', preg_replace('~&amp;#(\\\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\\\1;', $smcFunc['htmlspecialchars']($rowData['filename'])));
467 485
 
468 486
 						// Show the dimensions.
469
-						if (!empty($rowData['width']) && !empty($rowData['height']))
470
-							$link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']);
487
+						if (!empty($rowData['width']) && !empty($rowData['height'])) {
488
+													$link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']);
489
+						}
471 490
 
472 491
 						return $link;
473 492
 					},
@@ -500,12 +519,14 @@  discard block
 block discarded – undo
500 519
 					'function' => function($rowData) use ($scripturl, $smcFunc)
501 520
 					{
502 521
 						// In case of an attachment, return the poster of the attachment.
503
-						if (empty($rowData['id_member']))
504
-							return $smcFunc['htmlspecialchars']($rowData['poster_name']);
522
+						if (empty($rowData['id_member'])) {
523
+													return $smcFunc['htmlspecialchars']($rowData['poster_name']);
524
+						}
505 525
 
506 526
 						// Otherwise it must be an avatar, return the link to the owner of it.
507
-						else
508
-							return sprintf('<a href="%1$s?action=profile;u=%2$d">%3$s</a>', $scripturl, $rowData['id_member'], $rowData['poster_name']);
527
+						else {
528
+													return sprintf('<a href="%1$s?action=profile;u=%2$d">%3$s</a>', $scripturl, $rowData['id_member'], $rowData['poster_name']);
529
+						}
509 530
 					},
510 531
 				),
511 532
 				'sort' => array(
@@ -524,8 +545,9 @@  discard block
 block discarded – undo
524 545
 						$date = empty($rowData['poster_time']) ? $txt['never'] : timeformat($rowData['poster_time']);
525 546
 
526 547
 						// Add a link to the topic in case of an attachment.
527
-						if ($context['browse_type'] !== 'avatars')
528
-							$date .= sprintf('<br>%1$s <a href="%2$s?topic=%3$d.msg%4$d#msg%4$d">%5$s</a>', $txt['in'], $scripturl, $rowData['id_topic'], $rowData['id_msg'], $rowData['subject']);
548
+						if ($context['browse_type'] !== 'avatars') {
549
+													$date .= sprintf('<br>%1$s <a href="%2$s?topic=%3$d.msg%4$d#msg%4$d">%5$s</a>', $txt['in'], $scripturl, $rowData['id_topic'], $rowData['id_msg'], $rowData['subject']);
550
+						}
529 551
 
530 552
 						return $date;
531 553
 					},
@@ -610,8 +632,8 @@  discard block
 block discarded – undo
610 632
 	global $smcFunc, $txt;
611 633
 
612 634
 	// Choose a query depending on what we are viewing.
613
-	if ($browse_type === 'avatars')
614
-		$request = $smcFunc['db_query']('', '
635
+	if ($browse_type === 'avatars') {
636
+			$request = $smcFunc['db_query']('', '
615 637
 			SELECT
616 638
 				{string:blank_text} AS id_msg, COALESCE(mem.real_name, {string:not_applicable_text}) AS poster_name,
617 639
 				mem.last_login AS poster_time, 0 AS id_topic, a.id_member, a.id_attach, a.filename, a.file_hash, a.attachment_type,
@@ -630,8 +652,8 @@  discard block
 block discarded – undo
630 652
 				'per_page' => $items_per_page,
631 653
 			)
632 654
 		);
633
-	else
634
-		$request = $smcFunc['db_query']('', '
655
+	} else {
656
+			$request = $smcFunc['db_query']('', '
635 657
 			SELECT
636 658
 				m.id_msg, COALESCE(mem.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_topic, m.id_member,
637 659
 				a.id_attach, a.filename, a.file_hash, a.attachment_type, a.size, a.width, a.height, a.downloads, mf.subject, t.id_board
@@ -650,9 +672,11 @@  discard block
 block discarded – undo
650 672
 				'per_page' => $items_per_page,
651 673
 			)
652 674
 		);
675
+	}
653 676
 	$files = array();
654
-	while ($row = $smcFunc['db_fetch_assoc']($request))
655
-		$files[] = $row;
677
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
678
+			$files[] = $row;
679
+	}
656 680
 	$smcFunc['db_free_result']($request);
657 681
 
658 682
 	return $files;
@@ -670,8 +694,8 @@  discard block
 block discarded – undo
670 694
 	global $smcFunc;
671 695
 
672 696
 	// Depending on the type of file, different queries are used.
673
-	if ($browse_type === 'avatars')
674
-		$request = $smcFunc['db_query']('', '
697
+	if ($browse_type === 'avatars') {
698
+			$request = $smcFunc['db_query']('', '
675 699
 		SELECT COUNT(*)
676 700
 		FROM {db_prefix}attachments
677 701
 		WHERE id_member != {int:guest_id_member}',
@@ -679,8 +703,8 @@  discard block
 block discarded – undo
679 703
 			'guest_id_member' => 0,
680 704
 		)
681 705
 	);
682
-	else
683
-		$request = $smcFunc['db_query']('', '
706
+	} else {
707
+			$request = $smcFunc['db_query']('', '
684 708
 			SELECT COUNT(*) AS num_attach
685 709
 			FROM {db_prefix}attachments AS a
686 710
 				INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg)
@@ -693,6 +717,7 @@  discard block
 block discarded – undo
693 717
 				'guest_id_member' => 0,
694 718
 			)
695 719
 		);
720
+	}
696 721
 
697 722
 	list ($num_files) = $smcFunc['db_fetch_row']($request);
698 723
 	$smcFunc['db_free_result']($request);
@@ -775,12 +800,14 @@  discard block
 block discarded – undo
775 800
 	$current_dir_size /= 1024;
776 801
 
777 802
 	// If they specified a limit only....
778
-	if (!empty($modSettings['attachmentDirSizeLimit']))
779
-		$context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir_size, 0), 2);
803
+	if (!empty($modSettings['attachmentDirSizeLimit'])) {
804
+			$context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir_size, 0), 2);
805
+	}
780 806
 	$context['attachment_current_size'] = comma_format($current_dir_size, 2);
781 807
 
782
-	if (!empty($modSettings['attachmentDirFileLimit']))
783
-		$context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir_files, 0), 0);
808
+	if (!empty($modSettings['attachmentDirFileLimit'])) {
809
+			$context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir_files, 0), 0);
810
+	}
784 811
 	$context['attachment_current_files'] = comma_format($current_dir_files, 0);
785 812
 
786 813
 	$context['attach_multiple_dirs'] = count($attach_dirs) > 1 ? true : false;
@@ -817,8 +844,8 @@  discard block
 block discarded – undo
817 844
 		$messages = removeAttachments(array('attachment_type' => 0, 'poster_time' => (time() - 24 * 60 * 60 * $_POST['age'])), 'messages', true);
818 845
 
819 846
 		// Update the messages to reflect the change.
820
-		if (!empty($messages) && !empty($_POST['notice']))
821
-			$smcFunc['db_query']('', '
847
+		if (!empty($messages) && !empty($_POST['notice'])) {
848
+					$smcFunc['db_query']('', '
822 849
 				UPDATE {db_prefix}messages
823 850
 				SET body = CONCAT(body, {string:notice})
824 851
 				WHERE id_msg IN ({array_int:messages})',
@@ -827,8 +854,8 @@  discard block
 block discarded – undo
827 854
 					'notice' => '<br><br>' . $_POST['notice'],
828 855
 				)
829 856
 			);
830
-	}
831
-	else
857
+		}
858
+	} else
832 859
 	{
833 860
 		// Remove all the old avatars.
834 861
 		removeAttachments(array('not_id_member' => 0, 'last_login' => (time() - 24 * 60 * 60 * $_POST['age'])), 'members');
@@ -853,8 +880,8 @@  discard block
 block discarded – undo
853 880
 	$messages = removeAttachments(array('attachment_type' => 0, 'size' => 1024 * $_POST['size']), 'messages', true);
854 881
 
855 882
 	// And make a note on the post.
856
-	if (!empty($messages) && !empty($_POST['notice']))
857
-		$smcFunc['db_query']('', '
883
+	if (!empty($messages) && !empty($_POST['notice'])) {
884
+			$smcFunc['db_query']('', '
858 885
 			UPDATE {db_prefix}messages
859 886
 			SET body = CONCAT(body, {string:notice})
860 887
 			WHERE id_msg IN ({array_int:messages})',
@@ -863,6 +890,7 @@  discard block
 block discarded – undo
863 890
 				'notice' => '<br><br>' . $_POST['notice'],
864 891
 			)
865 892
 		);
893
+	}
866 894
 
867 895
 	redirectexit('action=admin;area=manageattachments;sa=maintenance');
868 896
 }
@@ -882,16 +910,17 @@  discard block
 block discarded – undo
882 910
 	{
883 911
 		$attachments = array();
884 912
 		// There must be a quicker way to pass this safety test??
885
-		foreach ($_POST['remove'] as $removeID => $dummy)
886
-			$attachments[] = (int) $removeID;
913
+		foreach ($_POST['remove'] as $removeID => $dummy) {
914
+					$attachments[] = (int) $removeID;
915
+		}
887 916
 
888 917
 		// If the attachments are from a 3rd party, let them remove it. Hooks should remove their ids from the array.
889 918
 		$filesRemoved = false;
890 919
 		call_integration_hook('integrate_attachment_remove', array(&$filesRemoved, $attachments));
891 920
 
892
-		if ($_REQUEST['type'] == 'avatars' && !empty($attachments))
893
-			removeAttachments(array('id_attach' => $attachments));
894
-		else if (!empty($attachments))
921
+		if ($_REQUEST['type'] == 'avatars' && !empty($attachments)) {
922
+					removeAttachments(array('id_attach' => $attachments));
923
+		} else if (!empty($attachments))
895 924
 		{
896 925
 			$messages = removeAttachments(array('id_attach' => $attachments), 'messages', true);
897 926
 
@@ -930,12 +959,13 @@  discard block
 block discarded – undo
930 959
 
931 960
 	$messages = removeAttachments(array('attachment_type' => 0), '', true);
932 961
 
933
-	if (!isset($_POST['notice']))
934
-		$_POST['notice'] = $txt['attachment_delete_admin'];
962
+	if (!isset($_POST['notice'])) {
963
+			$_POST['notice'] = $txt['attachment_delete_admin'];
964
+	}
935 965
 
936 966
 	// Add the notice on the end of the changed messages.
937
-	if (!empty($messages))
938
-		$smcFunc['db_query']('', '
967
+	if (!empty($messages)) {
968
+			$smcFunc['db_query']('', '
939 969
 			UPDATE {db_prefix}messages
940 970
 			SET body = CONCAT(body, {string:deleted_message})
941 971
 			WHERE id_msg IN ({array_int:messages})',
@@ -944,6 +974,7 @@  discard block
 block discarded – undo
944 974
 				'deleted_message' => '<br><br>' . $_POST['notice'],
945 975
 			)
946 976
 		);
977
+	}
947 978
 
948 979
 	redirectexit('action=admin;area=manageattachments;sa=maintenance');
949 980
 }
@@ -982,24 +1013,26 @@  discard block
 block discarded – undo
982 1013
 			$is_not = substr($real_type, 0, 4) == 'not_';
983 1014
 			$type = $is_not ? substr($real_type, 4) : $real_type;
984 1015
 
985
-			if (in_array($type, array('id_member', 'id_attach', 'id_msg')))
986
-				$new_condition[] = 'a.' . $type . ($is_not ? ' NOT' : '') . ' IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')';
987
-			elseif ($type == 'attachment_type')
988
-				$new_condition[] = 'a.attachment_type = {int:' . $real_type . '}';
989
-			elseif ($type == 'poster_time')
990
-				$new_condition[] = 'm.poster_time < {int:' . $real_type . '}';
991
-			elseif ($type == 'last_login')
992
-				$new_condition[] = 'mem.last_login < {int:' . $real_type . '}';
993
-			elseif ($type == 'size')
994
-				$new_condition[] = 'a.size > {int:' . $real_type . '}';
995
-			elseif ($type == 'id_topic')
996
-				$new_condition[] = 'm.id_topic IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')';
1016
+			if (in_array($type, array('id_member', 'id_attach', 'id_msg'))) {
1017
+							$new_condition[] = 'a.' . $type . ($is_not ? ' NOT' : '') . ' IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')';
1018
+			} elseif ($type == 'attachment_type') {
1019
+							$new_condition[] = 'a.attachment_type = {int:' . $real_type . '}';
1020
+			} elseif ($type == 'poster_time') {
1021
+							$new_condition[] = 'm.poster_time < {int:' . $real_type . '}';
1022
+			} elseif ($type == 'last_login') {
1023
+							$new_condition[] = 'mem.last_login < {int:' . $real_type . '}';
1024
+			} elseif ($type == 'size') {
1025
+							$new_condition[] = 'a.size > {int:' . $real_type . '}';
1026
+			} elseif ($type == 'id_topic') {
1027
+							$new_condition[] = 'm.id_topic IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')';
1028
+			}
997 1029
 
998 1030
 			// Add the parameter!
999 1031
 			$query_parameter[$real_type] = $restriction;
1000 1032
 
1001
-			if ($type == 'do_logging')
1002
-				$do_logging = $condition['id_attach'];
1033
+			if ($type == 'do_logging') {
1034
+							$do_logging = $condition['id_attach'];
1035
+			}
1003 1036
 		}
1004 1037
 		$condition = implode(' AND ', $new_condition);
1005 1038
 	}
@@ -1031,15 +1064,15 @@  discard block
 block discarded – undo
1031 1064
 			// wasn't it obvious? :P
1032 1065
 			// @todo look again at this.
1033 1066
 			@unlink($modSettings['custom_avatar_dir'] . '/' . $row['filename']);
1034
-		}
1035
-		else
1067
+		} else
1036 1068
 		{
1037 1069
 			$filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']);
1038 1070
 			@unlink($filename);
1039 1071
 
1040 1072
 			// If this was a thumb, the parent attachment should know about it.
1041
-			if (!empty($row['id_parent']))
1042
-				$parents[] = $row['id_parent'];
1073
+			if (!empty($row['id_parent'])) {
1074
+							$parents[] = $row['id_parent'];
1075
+			}
1043 1076
 
1044 1077
 			// If this attachments has a thumb, remove it as well.
1045 1078
 			if (!empty($row['id_thumb']) && $autoThumbRemoval)
@@ -1051,8 +1084,9 @@  discard block
 block discarded – undo
1051 1084
 		}
1052 1085
 
1053 1086
 		// Make a list.
1054
-		if ($return_affected_messages && empty($row['attachment_type']))
1055
-			$msgs[] = $row['id_msg'];
1087
+		if ($return_affected_messages && empty($row['attachment_type'])) {
1088
+					$msgs[] = $row['id_msg'];
1089
+		}
1056 1090
 
1057 1091
 		$attach[] = $row['id_attach'];
1058 1092
 	}
@@ -1060,8 +1094,8 @@  discard block
 block discarded – undo
1060 1094
 
1061 1095
 	// Removed attachments don't have to be updated anymore.
1062 1096
 	$parents = array_diff($parents, $attach);
1063
-	if (!empty($parents))
1064
-		$smcFunc['db_query']('', '
1097
+	if (!empty($parents)) {
1098
+			$smcFunc['db_query']('', '
1065 1099
 			UPDATE {db_prefix}attachments
1066 1100
 			SET id_thumb = {int:no_thumb}
1067 1101
 			WHERE id_attach IN ({array_int:parent_attachments})',
@@ -1070,6 +1104,7 @@  discard block
 block discarded – undo
1070 1104
 				'no_thumb' => 0,
1071 1105
 			)
1072 1106
 		);
1107
+	}
1073 1108
 
1074 1109
 	if (!empty($do_logging))
1075 1110
 	{
@@ -1086,31 +1121,34 @@  discard block
 block discarded – undo
1086 1121
 			)
1087 1122
 		);
1088 1123
 
1089
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1090
-			logAction(
1124
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1125
+					logAction(
1091 1126
 				'remove_attach',
1092 1127
 				array(
1093 1128
 					'message' => $row['id_msg'],
1094 1129
 					'filename' => preg_replace('~&amp;#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($row['filename'])),
1095 1130
 				)
1096 1131
 			);
1132
+		}
1097 1133
 		$smcFunc['db_free_result']($request);
1098 1134
 	}
1099 1135
 
1100
-	if (!empty($attach))
1101
-		$smcFunc['db_query']('', '
1136
+	if (!empty($attach)) {
1137
+			$smcFunc['db_query']('', '
1102 1138
 			DELETE FROM {db_prefix}attachments
1103 1139
 			WHERE id_attach IN ({array_int:attachment_list})',
1104 1140
 			array(
1105 1141
 				'attachment_list' => $attach,
1106 1142
 			)
1107 1143
 		);
1144
+	}
1108 1145
 
1109 1146
 	call_integration_hook('integrate_remove_attachments', array($attach));
1110 1147
 
1111
-	if ($return_affected_messages)
1112
-		return array_unique($msgs);
1113
-}
1148
+	if ($return_affected_messages) {
1149
+			return array_unique($msgs);
1150
+	}
1151
+	}
1114 1152
 
1115 1153
 /**
1116 1154
  * This function should find attachments in the database that no longer exist and clear them, and fix filesize issues.
@@ -1122,8 +1160,9 @@  discard block
 block discarded – undo
1122 1160
 	checkSession('get');
1123 1161
 
1124 1162
 	// If we choose cancel, redirect right back.
1125
-	if (isset($_POST['cancel']))
1126
-		redirectexit('action=admin;area=manageattachments;sa=maintenance');
1163
+	if (isset($_POST['cancel'])) {
1164
+			redirectexit('action=admin;area=manageattachments;sa=maintenance');
1165
+	}
1127 1166
 
1128 1167
 	// Try give us a while to sort this out...
1129 1168
 	@set_time_limit(600);
@@ -1140,13 +1179,15 @@  discard block
 block discarded – undo
1140 1179
 		if (isset($_GET['fixErrors']))
1141 1180
 		{
1142 1181
 			// Nothing?
1143
-			if (empty($_POST['to_fix']))
1144
-				redirectexit('action=admin;area=manageattachments;sa=maintenance');
1182
+			if (empty($_POST['to_fix'])) {
1183
+							redirectexit('action=admin;area=manageattachments;sa=maintenance');
1184
+			}
1145 1185
 
1146 1186
 			$_SESSION['attachments_to_fix'] = array();
1147 1187
 			// @todo No need to do this I think.
1148
-			foreach ($_POST['to_fix'] as $value)
1149
-				$_SESSION['attachments_to_fix'][] = $value;
1188
+			foreach ($_POST['to_fix'] as $value) {
1189
+							$_SESSION['attachments_to_fix'][] = $value;
1190
+			}
1150 1191
 		}
1151 1192
 	}
1152 1193
 
@@ -1213,13 +1254,14 @@  discard block
 block discarded – undo
1213 1254
 					}
1214 1255
 				}
1215 1256
 			}
1216
-			if ($smcFunc['db_num_rows']($result) != 0)
1217
-				$to_fix[] = 'missing_thumbnail_parent';
1257
+			if ($smcFunc['db_num_rows']($result) != 0) {
1258
+							$to_fix[] = 'missing_thumbnail_parent';
1259
+			}
1218 1260
 			$smcFunc['db_free_result']($result);
1219 1261
 
1220 1262
 			// Do we need to delete what we have?
1221
-			if ($fix_errors && !empty($to_remove) && in_array('missing_thumbnail_parent', $to_fix))
1222
-				$smcFunc['db_query']('', '
1263
+			if ($fix_errors && !empty($to_remove) && in_array('missing_thumbnail_parent', $to_fix)) {
1264
+							$smcFunc['db_query']('', '
1223 1265
 					DELETE FROM {db_prefix}attachments
1224 1266
 					WHERE id_attach IN ({array_int:to_remove})
1225 1267
 						AND attachment_type = {int:attachment_type}',
@@ -1228,6 +1270,7 @@  discard block
 block discarded – undo
1228 1270
 						'attachment_type' => 3,
1229 1271
 					)
1230 1272
 				);
1273
+			}
1231 1274
 
1232 1275
 			pauseAttachmentMaintenance($to_fix, $thumbnails);
1233 1276
 		}
@@ -1272,13 +1315,14 @@  discard block
 block discarded – undo
1272 1315
 				$to_update[] = $row['id_attach'];
1273 1316
 				$context['repair_errors']['parent_missing_thumbnail']++;
1274 1317
 			}
1275
-			if ($smcFunc['db_num_rows']($result) != 0)
1276
-				$to_fix[] = 'parent_missing_thumbnail';
1318
+			if ($smcFunc['db_num_rows']($result) != 0) {
1319
+							$to_fix[] = 'parent_missing_thumbnail';
1320
+			}
1277 1321
 			$smcFunc['db_free_result']($result);
1278 1322
 
1279 1323
 			// Do we need to delete what we have?
1280
-			if ($fix_errors && !empty($to_update) && in_array('parent_missing_thumbnail', $to_fix))
1281
-				$smcFunc['db_query']('', '
1324
+			if ($fix_errors && !empty($to_update) && in_array('parent_missing_thumbnail', $to_fix)) {
1325
+							$smcFunc['db_query']('', '
1282 1326
 					UPDATE {db_prefix}attachments
1283 1327
 					SET id_thumb = {int:no_thumb}
1284 1328
 					WHERE id_attach IN ({array_int:to_update})',
@@ -1287,6 +1331,7 @@  discard block
 block discarded – undo
1287 1331
 						'no_thumb' => 0,
1288 1332
 					)
1289 1333
 				);
1334
+			}
1290 1335
 
1291 1336
 			pauseAttachmentMaintenance($to_fix, $thumbnails);
1292 1337
 		}
@@ -1324,10 +1369,11 @@  discard block
 block discarded – undo
1324 1369
 			while ($row = $smcFunc['db_fetch_assoc']($result))
1325 1370
 			{
1326 1371
 				// Get the filename.
1327
-				if ($row['attachment_type'] == 1)
1328
-					$filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename'];
1329
-				else
1330
-					$filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']);
1372
+				if ($row['attachment_type'] == 1) {
1373
+									$filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename'];
1374
+				} else {
1375
+									$filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']);
1376
+				}
1331 1377
 
1332 1378
 				// File doesn't exist?
1333 1379
 				if (!file_exists($filename))
@@ -1339,15 +1385,16 @@  discard block
 block discarded – undo
1339 1385
 						$attachment_name = $row['id_attach'] . '_' . $row['file_hash'] . '.dat';
1340 1386
 
1341 1387
 						// Loop through the other folders.
1342
-						foreach ($modSettings['attachmentUploadDir'] as $id => $dir)
1343
-							if (file_exists($dir . '/' . $attachment_name))
1388
+						foreach ($modSettings['attachmentUploadDir'] as $id => $dir) {
1389
+													if (file_exists($dir . '/' . $attachment_name))
1344 1390
 							{
1345 1391
 								$context['repair_errors']['wrong_folder']++;
1392
+						}
1346 1393
 								$errors_found[] = 'wrong_folder';
1347 1394
 
1348 1395
 								// Are we going to fix this now?
1349
-								if ($fix_errors && in_array('wrong_folder', $to_fix))
1350
-									$smcFunc['db_query']('', '
1396
+								if ($fix_errors && in_array('wrong_folder', $to_fix)) {
1397
+																	$smcFunc['db_query']('', '
1351 1398
 										UPDATE {db_prefix}attachments
1352 1399
 										SET id_folder = {int:new_folder}
1353 1400
 										WHERE id_attach = {int:id_attach}',
@@ -1356,6 +1403,7 @@  discard block
 block discarded – undo
1356 1403
 											'id_attach' => $row['id_attach'],
1357 1404
 										)
1358 1405
 									);
1406
+								}
1359 1407
 
1360 1408
 								continue 2;
1361 1409
 							}
@@ -1364,8 +1412,7 @@  discard block
 block discarded – undo
1364 1412
 					$to_remove[] = $row['id_attach'];
1365 1413
 					$context['repair_errors']['file_missing_on_disk']++;
1366 1414
 					$errors_found[] = 'file_missing_on_disk';
1367
-				}
1368
-				elseif (filesize($filename) == 0)
1415
+				} elseif (filesize($filename) == 0)
1369 1416
 				{
1370 1417
 					$context['repair_errors']['file_size_of_zero']++;
1371 1418
 					$errors_found[] = 'file_size_of_zero';
@@ -1376,8 +1423,7 @@  discard block
 block discarded – undo
1376 1423
 						$to_remove[] = $row['id_attach'];
1377 1424
 						@unlink($filename);
1378 1425
 					}
1379
-				}
1380
-				elseif (filesize($filename) != $row['size'])
1426
+				} elseif (filesize($filename) != $row['size'])
1381 1427
 				{
1382 1428
 					$context['repair_errors']['file_wrong_size']++;
1383 1429
 					$errors_found[] = 'file_wrong_size';
@@ -1398,14 +1444,18 @@  discard block
 block discarded – undo
1398 1444
 				}
1399 1445
 			}
1400 1446
 
1401
-			if (in_array('file_missing_on_disk', $errors_found))
1402
-				$to_fix[] = 'file_missing_on_disk';
1403
-			if (in_array('file_size_of_zero', $errors_found))
1404
-				$to_fix[] = 'file_size_of_zero';
1405
-			if (in_array('file_wrong_size', $errors_found))
1406
-				$to_fix[] = 'file_wrong_size';
1407
-			if (in_array('wrong_folder', $errors_found))
1408
-				$to_fix[] = 'wrong_folder';
1447
+			if (in_array('file_missing_on_disk', $errors_found)) {
1448
+							$to_fix[] = 'file_missing_on_disk';
1449
+			}
1450
+			if (in_array('file_size_of_zero', $errors_found)) {
1451
+							$to_fix[] = 'file_size_of_zero';
1452
+			}
1453
+			if (in_array('file_wrong_size', $errors_found)) {
1454
+							$to_fix[] = 'file_wrong_size';
1455
+			}
1456
+			if (in_array('wrong_folder', $errors_found)) {
1457
+							$to_fix[] = 'wrong_folder';
1458
+			}
1409 1459
 			$smcFunc['db_free_result']($result);
1410 1460
 
1411 1461
 			// Do we need to delete what we have?
@@ -1475,20 +1525,22 @@  discard block
 block discarded – undo
1475 1525
 				// If we are repairing remove the file from disk now.
1476 1526
 				if ($fix_errors && in_array('avatar_no_member', $to_fix))
1477 1527
 				{
1478
-					if ($row['attachment_type'] == 1)
1479
-						$filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename'];
1480
-					else
1481
-						$filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']);
1528
+					if ($row['attachment_type'] == 1) {
1529
+											$filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename'];
1530
+					} else {
1531
+											$filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']);
1532
+					}
1482 1533
 					@unlink($filename);
1483 1534
 				}
1484 1535
 			}
1485
-			if ($smcFunc['db_num_rows']($result) != 0)
1486
-				$to_fix[] = 'avatar_no_member';
1536
+			if ($smcFunc['db_num_rows']($result) != 0) {
1537
+							$to_fix[] = 'avatar_no_member';
1538
+			}
1487 1539
 			$smcFunc['db_free_result']($result);
1488 1540
 
1489 1541
 			// Do we need to delete what we have?
1490
-			if ($fix_errors && !empty($to_remove) && in_array('avatar_no_member', $to_fix))
1491
-				$smcFunc['db_query']('', '
1542
+			if ($fix_errors && !empty($to_remove) && in_array('avatar_no_member', $to_fix)) {
1543
+							$smcFunc['db_query']('', '
1492 1544
 					DELETE FROM {db_prefix}attachments
1493 1545
 					WHERE id_attach IN ({array_int:to_remove})
1494 1546
 						AND id_member != {int:no_member}
@@ -1499,6 +1551,7 @@  discard block
 block discarded – undo
1499 1551
 						'no_msg' => 0,
1500 1552
 					)
1501 1553
 				);
1554
+			}
1502 1555
 
1503 1556
 			pauseAttachmentMaintenance($to_fix, $thumbnails);
1504 1557
 		}
@@ -1558,13 +1611,14 @@  discard block
 block discarded – undo
1558 1611
 					@unlink($filename);
1559 1612
 				}
1560 1613
 			}
1561
-			if ($smcFunc['db_num_rows']($result) != 0)
1562
-				$to_fix[] = 'attachment_no_msg';
1614
+			if ($smcFunc['db_num_rows']($result) != 0) {
1615
+							$to_fix[] = 'attachment_no_msg';
1616
+			}
1563 1617
 			$smcFunc['db_free_result']($result);
1564 1618
 
1565 1619
 			// Do we need to delete what we have?
1566
-			if ($fix_errors && !empty($to_remove) && in_array('attachment_no_msg', $to_fix))
1567
-				$smcFunc['db_query']('', '
1620
+			if ($fix_errors && !empty($to_remove) && in_array('attachment_no_msg', $to_fix)) {
1621
+							$smcFunc['db_query']('', '
1568 1622
 					DELETE FROM {db_prefix}attachments
1569 1623
 					WHERE id_attach IN ({array_int:to_remove})
1570 1624
 						AND id_member = {int:no_member}
@@ -1575,6 +1629,7 @@  discard block
 block discarded – undo
1575 1629
 						'attach_thumb' => array(0,3),
1576 1630
 					)
1577 1631
 				);
1632
+			}
1578 1633
 
1579 1634
 			pauseAttachmentMaintenance($to_fix, $thumbnails);
1580 1635
 		}
@@ -1598,8 +1653,9 @@  discard block
 block discarded – undo
1598 1653
 			{
1599 1654
 				while ($file = readdir($dir))
1600 1655
 				{
1601
-					if (in_array($file, array('.', '..', '.htaccess', 'index.php')))
1602
-						continue;
1656
+					if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) {
1657
+											continue;
1658
+					}
1603 1659
 
1604 1660
 					if ($files_checked <= $current_check)
1605 1661
 					{
@@ -1607,8 +1663,9 @@  discard block
 block discarded – undo
1607 1663
 						if (strpos($file, 'post_tmp_') !== false)
1608 1664
 						{
1609 1665
 							// Temp file is more than 5 hours old!
1610
-							if (filemtime($attach_dir . '/' . $file) < time() - 18000)
1611
-								@unlink($attach_dir . '/' . $file);
1666
+							if (filemtime($attach_dir . '/' . $file) < time() - 18000) {
1667
+															@unlink($attach_dir . '/' . $file);
1668
+							}
1612 1669
 						}
1613 1670
 						// That should be an attachment, let's check if we have it in the database
1614 1671
 						elseif (strpos($file, '_') !== false)
@@ -1630,8 +1687,7 @@  discard block
 block discarded – undo
1630 1687
 									if ($fix_errors && in_array('files_without_attachment', $to_fix))
1631 1688
 									{
1632 1689
 										@unlink($attach_dir . '/' . $file);
1633
-									}
1634
-									else
1690
+									} else
1635 1691
 									{
1636 1692
 										$context['repair_errors']['files_without_attachment']++;
1637 1693
 										$to_fix[] = 'files_without_attachment';
@@ -1639,14 +1695,12 @@  discard block
 block discarded – undo
1639 1695
 								}
1640 1696
 								$smcFunc['db_free_result']($request);
1641 1697
 							}
1642
-						}
1643
-						else
1698
+						} else
1644 1699
 						{
1645 1700
 							if ($fix_errors && in_array('files_without_attachment', $to_fix))
1646 1701
 							{
1647 1702
 								@unlink($attach_dir . '/' . $file);
1648
-							}
1649
-							else
1703
+							} else
1650 1704
 							{
1651 1705
 								$context['repair_errors']['files_without_attachment']++;
1652 1706
 								$to_fix[] = 'files_without_attachment';
@@ -1655,8 +1709,9 @@  discard block
 block discarded – undo
1655 1709
 					}
1656 1710
 					$current_check++;
1657 1711
 					$_GET['substep'] = $current_check;
1658
-					if ($current_check - $files_checked >= $max_checks)
1659
-						pauseAttachmentMaintenance($to_fix);
1712
+					if ($current_check - $files_checked >= $max_checks) {
1713
+											pauseAttachmentMaintenance($to_fix);
1714
+					}
1660 1715
 				}
1661 1716
 				closedir($dir);
1662 1717
 			}
@@ -1692,12 +1747,14 @@  discard block
 block discarded – undo
1692 1747
 
1693 1748
 	// Try get more time...
1694 1749
 	@set_time_limit(600);
1695
-	if (function_exists('apache_reset_timeout'))
1696
-		@apache_reset_timeout();
1750
+	if (function_exists('apache_reset_timeout')) {
1751
+			@apache_reset_timeout();
1752
+	}
1697 1753
 
1698 1754
 	// Have we already used our maximum time?
1699
-	if ((time() - $time_start) < 3 || $context['starting_substep'] == $_GET['substep'])
1700
-		return;
1755
+	if ((time() - $time_start) < 3 || $context['starting_substep'] == $_GET['substep']) {
1756
+			return;
1757
+	}
1701 1758
 
1702 1759
 	$context['continue_get_data'] = '?action=admin;area=manageattachments;sa=repair' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id'];
1703 1760
 	$context['page_title'] = $txt['not_done_title'];
@@ -1709,10 +1766,11 @@  discard block
 block discarded – undo
1709 1766
 	$context[$context['admin_menu_name']]['current_subsection'] = 'maintenance';
1710 1767
 
1711 1768
 	// Change these two if more steps are added!
1712
-	if (empty($max_substep))
1713
-		$context['continue_percent'] = round(($_GET['step'] * 100) / 25);
1714
-	else
1715
-		$context['continue_percent'] = round(($_GET['step'] * 100 + ($_GET['substep'] * 100) / $max_substep) / 25);
1769
+	if (empty($max_substep)) {
1770
+			$context['continue_percent'] = round(($_GET['step'] * 100) / 25);
1771
+	} else {
1772
+			$context['continue_percent'] = round(($_GET['step'] * 100 + ($_GET['substep'] * 100) / $max_substep) / 25);
1773
+	}
1716 1774
 
1717 1775
 	// Never more than 100%!
1718 1776
 	$context['continue_percent'] = min($context['continue_percent'], 100);
@@ -1754,15 +1812,17 @@  discard block
 block discarded – undo
1754 1812
 				'attachment_type' => 0,
1755 1813
 			)
1756 1814
 		);
1757
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1758
-			$attachments[] = $row['id_attach'];
1815
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1816
+					$attachments[] = $row['id_attach'];
1817
+		}
1759 1818
 		$smcFunc['db_free_result']($request);
1819
+	} elseif (!empty($_GET['aid'])) {
1820
+			$attachments[] = (int) $_GET['aid'];
1760 1821
 	}
1761
-	elseif (!empty($_GET['aid']))
1762
-		$attachments[] = (int) $_GET['aid'];
1763 1822
 
1764
-	if (empty($attachments))
1765
-		fatal_lang_error('no_access', false);
1823
+	if (empty($attachments)) {
1824
+			fatal_lang_error('no_access', false);
1825
+	}
1766 1826
 
1767 1827
 	// Now we have some ID's cleaned and ready to approve, but first - let's check we have permission!
1768 1828
 	$allowed_boards = boardsAllowedTo('approve_posts');
@@ -1795,17 +1855,18 @@  discard block
 block discarded – undo
1795 1855
 	}
1796 1856
 	$smcFunc['db_free_result']($request);
1797 1857
 
1798
-	if (empty($attachments))
1799
-		fatal_lang_error('no_access', false);
1858
+	if (empty($attachments)) {
1859
+			fatal_lang_error('no_access', false);
1860
+	}
1800 1861
 
1801 1862
 	// Finally, we are there. Follow through!
1802 1863
 	if ($is_approve)
1803 1864
 	{
1804 1865
 		// Checked and deemed worthy.
1805 1866
 		ApproveAttachments($attachments);
1867
+	} else {
1868
+			removeAttachments(array('id_attach' => $attachments, 'do_logging' => true));
1806 1869
 	}
1807
-	else
1808
-		removeAttachments(array('id_attach' => $attachments, 'do_logging' => true));
1809 1870
 
1810 1871
 	// Return to the topic....
1811 1872
 	redirectexit($redirect);
@@ -1821,8 +1882,9 @@  discard block
 block discarded – undo
1821 1882
 {
1822 1883
 	global $smcFunc;
1823 1884
 
1824
-	if (empty($attachments))
1825
-		return 0;
1885
+	if (empty($attachments)) {
1886
+			return 0;
1887
+	}
1826 1888
 
1827 1889
 	// For safety, check for thumbnails...
1828 1890
 	$request = $smcFunc['db_query']('', '
@@ -1841,15 +1903,17 @@  discard block
 block discarded – undo
1841 1903
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1842 1904
 	{
1843 1905
 		// Update the thumbnail too...
1844
-		if (!empty($row['id_thumb']))
1845
-			$attachments[] = $row['id_thumb'];
1906
+		if (!empty($row['id_thumb'])) {
1907
+					$attachments[] = $row['id_thumb'];
1908
+		}
1846 1909
 
1847 1910
 		$attachments[] = $row['id_attach'];
1848 1911
 	}
1849 1912
 	$smcFunc['db_free_result']($request);
1850 1913
 
1851
-	if (empty($attachments))
1852
-		return 0;
1914
+	if (empty($attachments)) {
1915
+			return 0;
1916
+	}
1853 1917
 
1854 1918
 	// Approving an attachment is not hard - it's easy.
1855 1919
 	$smcFunc['db_query']('', '
@@ -1875,14 +1939,15 @@  discard block
 block discarded – undo
1875 1939
 		)
1876 1940
 	);
1877 1941
 
1878
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1879
-		logAction(
1942
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1943
+			logAction(
1880 1944
 			'approve_attach',
1881 1945
 			array(
1882 1946
 				'message' => $row['id_msg'],
1883 1947
 				'filename' => preg_replace('~&amp;#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($row['filename'])),
1884 1948
 			)
1885 1949
 		);
1950
+	}
1886 1951
 	$smcFunc['db_free_result']($request);
1887 1952
 
1888 1953
 	// Remove from the approval queue.
@@ -1905,11 +1970,11 @@  discard block
 block discarded – undo
1905 1970
 	global $modSettings, $scripturl, $context, $txt, $sourcedir, $boarddir, $smcFunc, $settings;
1906 1971
 
1907 1972
 	// Since this needs to be done eventually.
1908
-	if (!isset($modSettings['attachment_basedirectories']))
1909
-		$modSettings['attachment_basedirectories'] = array();
1910
-
1911
-	elseif (!is_array($modSettings['attachment_basedirectories']))
1912
-		$modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true);
1973
+	if (!isset($modSettings['attachment_basedirectories'])) {
1974
+			$modSettings['attachment_basedirectories'] = array();
1975
+	} elseif (!is_array($modSettings['attachment_basedirectories'])) {
1976
+			$modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true);
1977
+	}
1913 1978
 
1914 1979
 	$errors = array();
1915 1980
 
@@ -1924,8 +1989,9 @@  discard block
 block discarded – undo
1924 1989
 		{
1925 1990
 			$error = '';
1926 1991
 			$id = (int) $id;
1927
-			if ($id < 1)
1928
-				continue;
1992
+			if ($id < 1) {
1993
+							continue;
1994
+			}
1929 1995
 
1930 1996
 			// Sorry, these dirs are NOT valid
1931 1997
 			$invalid_dirs = array($boarddir, $settings['default_theme_dir'], $sourcedir);
@@ -1944,8 +2010,7 @@  discard block
 block discarded – undo
1944 2010
 				{
1945 2011
 						$errors[] = $path . ': ' . $txt['attach_dir_duplicate_msg'];
1946 2012
 						continue;
1947
-				}
1948
-				elseif (empty($path))
2013
+				} elseif (empty($path))
1949 2014
 				{
1950 2015
 					// Ignore this and set $id to one less
1951 2016
 					continue;
@@ -1953,10 +2018,11 @@  discard block
 block discarded – undo
1953 2018
 
1954 2019
 				// OK, so let's try to create it then.
1955 2020
 				require_once($sourcedir . '/Subs-Attachments.php');
1956
-				if (automanage_attachments_create_directory($path))
1957
-					$_POST['current_dir'] = $modSettings['currentAttachmentUploadDir'];
1958
-				else
1959
-					$errors[] = $path . ': ' . $txt[$context['dir_creation_error']];
2021
+				if (automanage_attachments_create_directory($path)) {
2022
+									$_POST['current_dir'] = $modSettings['currentAttachmentUploadDir'];
2023
+				} else {
2024
+									$errors[] = $path . ': ' . $txt[$context['dir_creation_error']];
2025
+				}
1960 2026
 			}
1961 2027
 
1962 2028
 			// Changing a directory name?
@@ -1969,8 +2035,7 @@  discard block
 block discarded – undo
1969 2035
 						$errors[] = $path . ': ' . $txt['attach_dir_no_rename'];
1970 2036
 						$path = $modSettings['attachmentUploadDir'][$id];
1971 2037
 					}
1972
-				}
1973
-				else
2038
+				} else
1974 2039
 				{
1975 2040
 					$errors[] = $path . ': ' . $txt['attach_dir_exists_msg'];
1976 2041
 					$path = $modSettings['attachmentUploadDir'][$id];
@@ -1995,12 +2060,13 @@  discard block
 block discarded – undo
1995 2060
 				$path = $modSettings['attachmentUploadDir'][$id];
1996 2061
 
1997 2062
 				// It's not a good idea to delete the current directory.
1998
-				if ($id == (!empty($_POST['current_dir']) ? $_POST['current_dir'] : $modSettings['currentAttachmentUploadDir']))
1999
-					$errors[] = $path . ': ' . $txt['attach_dir_is_current'];
2063
+				if ($id == (!empty($_POST['current_dir']) ? $_POST['current_dir'] : $modSettings['currentAttachmentUploadDir'])) {
2064
+									$errors[] = $path . ': ' . $txt['attach_dir_is_current'];
2065
+				}
2000 2066
 				// Or the current base directory
2001
-				elseif (!empty($modSettings['basedirectory_for_attachments']) && $modSettings['basedirectory_for_attachments'] == $modSettings['attachmentUploadDir'][$id])
2002
-					$errors[] = $path . ': ' . $txt['attach_dir_is_current_bd'];
2003
-				else
2067
+				elseif (!empty($modSettings['basedirectory_for_attachments']) && $modSettings['basedirectory_for_attachments'] == $modSettings['attachmentUploadDir'][$id]) {
2068
+									$errors[] = $path . ': ' . $txt['attach_dir_is_current_bd'];
2069
+				} else
2004 2070
 				{
2005 2071
 					// Let's not try to delete a path with files in it.
2006 2072
 					$request = $smcFunc['db_query']('', '
@@ -2019,17 +2085,18 @@  discard block
 block discarded – undo
2019 2085
 					if (!empty($modSettings['attachment_basedirectories']))
2020 2086
 					{
2021 2087
 						// Count any sub-folders.
2022
-						foreach ($modSettings['attachmentUploadDir'] as $sub)
2023
-							if (strpos($sub, $path . DIRECTORY_SEPARATOR) !== false)
2088
+						foreach ($modSettings['attachmentUploadDir'] as $sub) {
2089
+													if (strpos($sub, $path . DIRECTORY_SEPARATOR) !== false)
2024 2090
 								$num_attach++;
2091
+						}
2025 2092
 					}
2026 2093
 
2027 2094
 					// It's safe to delete. So try to delete the folder also
2028 2095
 					if ($num_attach == 0)
2029 2096
 					{
2030
-						if (is_dir($path))
2031
-							$doit = true;
2032
-						elseif (is_dir($boarddir . DIRECTORY_SEPARATOR . $path))
2097
+						if (is_dir($path)) {
2098
+													$doit = true;
2099
+						} elseif (is_dir($boarddir . DIRECTORY_SEPARATOR . $path))
2033 2100
 						{
2034 2101
 							$doit = true;
2035 2102
 							$path = $boarddir . DIRECTORY_SEPARATOR . $path;
@@ -2039,8 +2106,9 @@  discard block
 block discarded – undo
2039 2106
 						{
2040 2107
 							unlink($path . '/.htaccess');
2041 2108
 							unlink($path . '/index.php');
2042
-							if (!@rmdir($path))
2043
-								$error = $path . ': ' . $txt['attach_dir_no_delete'];
2109
+							if (!@rmdir($path)) {
2110
+															$error = $path . ': ' . $txt['attach_dir_no_delete'];
2111
+							}
2044 2112
 						}
2045 2113
 
2046 2114
 						// Remove it from the base directory list.
@@ -2050,14 +2118,15 @@  discard block
 block discarded – undo
2050 2118
 							updateSettings(array('attachment_basedirectories' => $smcFunc['json_encode']($modSettings['attachment_basedirectories'])));
2051 2119
 							$modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true);
2052 2120
 						}
2121
+					} else {
2122
+											$error = $path . ': ' . $txt['attach_dir_no_remove'];
2053 2123
 					}
2054
-					else
2055
-						$error = $path . ': ' . $txt['attach_dir_no_remove'];
2056 2124
 
2057
-					if (empty($error))
2058
-						continue;
2059
-					else
2060
-						$errors[] = $error;
2125
+					if (empty($error)) {
2126
+											continue;
2127
+					} else {
2128
+											$errors[] = $error;
2129
+					}
2061 2130
 				}
2062 2131
 			}
2063 2132
 
@@ -2065,23 +2134,26 @@  discard block
 block discarded – undo
2065 2134
 		}
2066 2135
 
2067 2136
 		// We need to make sure the current directory is right.
2068
-		if (empty($_POST['current_dir']) && !empty($modSettings['currentAttachmentUploadDir']))
2069
-			$_POST['current_dir'] = $modSettings['currentAttachmentUploadDir'];
2137
+		if (empty($_POST['current_dir']) && !empty($modSettings['currentAttachmentUploadDir'])) {
2138
+					$_POST['current_dir'] = $modSettings['currentAttachmentUploadDir'];
2139
+		}
2070 2140
 
2071 2141
 		// Find the current directory if there's no value carried,
2072 2142
 		if (empty($_POST['current_dir']) || empty($new_dirs[$_POST['current_dir']]))
2073 2143
 		{
2074
-			if (array_key_exists($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir']))
2075
-				$_POST['current_dir'] = $modSettings['currentAttachmentUploadDir'];
2076
-			else
2077
-				$_POST['current_dir'] = max(array_keys($modSettings['attachmentUploadDir']));
2144
+			if (array_key_exists($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir'])) {
2145
+							$_POST['current_dir'] = $modSettings['currentAttachmentUploadDir'];
2146
+			} else {
2147
+							$_POST['current_dir'] = max(array_keys($modSettings['attachmentUploadDir']));
2148
+			}
2078 2149
 		}
2079 2150
 
2080 2151
 		// If the user wishes to go back, update the last_dir array
2081 2152
 		if ($_POST['current_dir'] != $modSettings['currentAttachmentUploadDir'] && !empty($modSettings['last_attachments_directory']) && (isset($modSettings['last_attachments_directory'][$_POST['current_dir']]) || isset($modSettings['last_attachments_directory'][0])))
2082 2153
 		{
2083
-			if (!is_array($modSettings['last_attachments_directory']))
2084
-				$modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true);
2154
+			if (!is_array($modSettings['last_attachments_directory'])) {
2155
+							$modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true);
2156
+			}
2085 2157
 			$num = substr(strrchr($modSettings['attachmentUploadDir'][$_POST['current_dir']], '_'), 1);
2086 2158
 
2087 2159
 			if (is_numeric($num))
@@ -2089,16 +2161,18 @@  discard block
 block discarded – undo
2089 2161
 				// Need to find the base folder.
2090 2162
 				$bid = -1;
2091 2163
 				$use_subdirectories_for_attachments = 0;
2092
-				if (!empty($modSettings['attachment_basedirectories']))
2093
-					foreach ($modSettings['attachment_basedirectories'] as $bid => $base)
2164
+				if (!empty($modSettings['attachment_basedirectories'])) {
2165
+									foreach ($modSettings['attachment_basedirectories'] as $bid => $base)
2094 2166
 						if (strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $base . DIRECTORY_SEPARATOR) !== false)
2095 2167
 						{
2096 2168
 							$use_subdirectories_for_attachments = 1;
2169
+				}
2097 2170
 							break;
2098 2171
 						}
2099 2172
 
2100
-				if ($use_subdirectories_for_attachments == 0 && strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $boarddir . DIRECTORY_SEPARATOR) !== false)
2101
-					$bid = 0;
2173
+				if ($use_subdirectories_for_attachments == 0 && strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $boarddir . DIRECTORY_SEPARATOR) !== false) {
2174
+									$bid = 0;
2175
+				}
2102 2176
 
2103 2177
 				$modSettings['last_attachments_directory'][$bid] = (int) $num;
2104 2178
 				$modSettings['basedirectory_for_attachments'] = !empty($modSettings['basedirectory_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : '';
@@ -2117,8 +2191,8 @@  discard block
 block discarded – undo
2117 2191
 			// We might need to reset the paths. This loop will just loop through once.
2118 2192
 			foreach ($new_dirs as $id => $dir)
2119 2193
 			{
2120
-				if ($id != 1)
2121
-					$smcFunc['db_query']('', '
2194
+				if ($id != 1) {
2195
+									$smcFunc['db_query']('', '
2122 2196
 						UPDATE {db_prefix}attachments
2123 2197
 						SET id_folder = {int:default_folder}
2124 2198
 						WHERE id_folder = {int:current_folder}',
@@ -2127,14 +2201,14 @@  discard block
 block discarded – undo
2127 2201
 							'current_folder' => $id,
2128 2202
 						)
2129 2203
 					);
2204
+				}
2130 2205
 
2131 2206
 				$update = array(
2132 2207
 					'currentAttachmentUploadDir' => 1,
2133 2208
 					'attachmentUploadDir' => $smcFunc['json_encode'](array(1 => $dir)),
2134 2209
 				);
2135 2210
 			}
2136
-		}
2137
-		else
2211
+		} else
2138 2212
 		{
2139 2213
 			// Save it to the database.
2140 2214
 			$update = array(
@@ -2143,11 +2217,13 @@  discard block
 block discarded – undo
2143 2217
 			);
2144 2218
 		}
2145 2219
 
2146
-		if (!empty($update))
2147
-			updateSettings($update);
2220
+		if (!empty($update)) {
2221
+					updateSettings($update);
2222
+		}
2148 2223
 
2149
-		if (!empty($errors))
2150
-			$_SESSION['errors']['dir'] = $errors;
2224
+		if (!empty($errors)) {
2225
+					$_SESSION['errors']['dir'] = $errors;
2226
+		}
2151 2227
 
2152 2228
 		redirectexit('action=admin;area=manageattachments;sa=attachpaths;' . $context['session_var'] . '=' . $context['session_id']);
2153 2229
 	}
@@ -2161,10 +2237,11 @@  discard block
 block discarded – undo
2161 2237
 		$_POST['current_base_dir'] = isset($_POST['current_base_dir']) ? (int) $_POST['current_base_dir'] : 1;
2162 2238
 		if (empty($_POST['new_base_dir']) && !empty($_POST['current_base_dir']))
2163 2239
 		{
2164
-			if ($modSettings['basedirectory_for_attachments'] != $modSettings['attachmentUploadDir'][$_POST['current_base_dir']])
2165
-				$update = (array(
2240
+			if ($modSettings['basedirectory_for_attachments'] != $modSettings['attachmentUploadDir'][$_POST['current_base_dir']]) {
2241
+							$update = (array(
2166 2242
 					'basedirectory_for_attachments' => $modSettings['attachmentUploadDir'][$_POST['current_base_dir']],
2167 2243
 				));
2244
+			}
2168 2245
 		}
2169 2246
 
2170 2247
 		if (isset($_POST['base_dir']))
@@ -2212,13 +2289,15 @@  discard block
 block discarded – undo
2212 2289
 
2213 2290
 			if (!in_array($_POST['new_base_dir'], $modSettings['attachmentUploadDir']))
2214 2291
 			{
2215
-				if (!automanage_attachments_create_directory($_POST['new_base_dir']))
2216
-					$errors[] = $_POST['new_base_dir'] . ': ' . $txt['attach_dir_base_no_create'];
2292
+				if (!automanage_attachments_create_directory($_POST['new_base_dir'])) {
2293
+									$errors[] = $_POST['new_base_dir'] . ': ' . $txt['attach_dir_base_no_create'];
2294
+				}
2217 2295
 			}
2218 2296
 
2219 2297
 			$modSettings['currentAttachmentUploadDir'] = array_search($_POST['new_base_dir'], $modSettings['attachmentUploadDir']);
2220
-			if (!in_array($_POST['new_base_dir'], $modSettings['attachment_basedirectories']))
2221
-				$modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $_POST['new_base_dir'];
2298
+			if (!in_array($_POST['new_base_dir'], $modSettings['attachment_basedirectories'])) {
2299
+							$modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $_POST['new_base_dir'];
2300
+			}
2222 2301
 			ksort($modSettings['attachment_basedirectories']);
2223 2302
 
2224 2303
 			$update = (array(
@@ -2228,11 +2307,13 @@  discard block
 block discarded – undo
2228 2307
 			));
2229 2308
 		}
2230 2309
 
2231
-		if (!empty($errors))
2232
-			$_SESSION['errors']['base'] = $errors;
2310
+		if (!empty($errors)) {
2311
+					$_SESSION['errors']['base'] = $errors;
2312
+		}
2233 2313
 
2234
-		if (!empty($update))
2235
-			updateSettings($update);
2314
+		if (!empty($update)) {
2315
+					updateSettings($update);
2316
+		}
2236 2317
 
2237 2318
 		redirectexit('action=admin;area=manageattachments;sa=attachpaths;' . $context['session_var'] . '=' . $context['session_id']);
2238 2319
 	}
@@ -2242,13 +2323,15 @@  discard block
 block discarded – undo
2242 2323
 		if (is_array($_SESSION['errors']))
2243 2324
 		{
2244 2325
 			$errors = array();
2245
-			if (!empty($_SESSION['errors']['dir']))
2246
-				foreach ($_SESSION['errors']['dir'] as $error)
2326
+			if (!empty($_SESSION['errors']['dir'])) {
2327
+							foreach ($_SESSION['errors']['dir'] as $error)
2247 2328
 					$errors['dir'][] = $smcFunc['htmlspecialchars']($error, ENT_QUOTES);
2329
+			}
2248 2330
 
2249
-			if (!empty($_SESSION['errors']['base']))
2250
-				foreach ($_SESSION['errors']['base'] as $error)
2331
+			if (!empty($_SESSION['errors']['base'])) {
2332
+							foreach ($_SESSION['errors']['base'] as $error)
2251 2333
 					$errors['base'][] = $smcFunc['htmlspecialchars']($error, ENT_QUOTES);
2334
+			}
2252 2335
 		}
2253 2336
 		unset($_SESSION['errors']);
2254 2337
 	}
@@ -2458,8 +2541,9 @@  discard block
 block discarded – undo
2458 2541
 	foreach ($modSettings['attachmentUploadDir'] as $id => $dir)
2459 2542
 	{
2460 2543
 		// If there aren't any attachments in this directory this won't exist.
2461
-		if (!isset($expected_files[$id]))
2462
-			$expected_files[$id] = 0;
2544
+		if (!isset($expected_files[$id])) {
2545
+					$expected_files[$id] = 0;
2546
+		}
2463 2547
 
2464 2548
 		// Check if the directory is doing okay.
2465 2549
 		list ($status, $error, $files) = attachDirStatus($dir, $expected_files[$id]);
@@ -2472,10 +2556,11 @@  discard block
 block discarded – undo
2472 2556
 			$is_base_dir = in_array($dir, $modSettings['attachment_basedirectories']);
2473 2557
 
2474 2558
 			// Count any sub-folders.
2475
-			foreach ($modSettings['attachmentUploadDir'] as $sid => $sub)
2476
-				if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false)
2559
+			foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) {
2560
+							if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false)
2477 2561
 				{
2478 2562
 					$expected_files[$id]++;
2563
+			}
2479 2564
 					$sub_dirs++;
2480 2565
 				}
2481 2566
 		}
@@ -2493,8 +2578,8 @@  discard block
 block discarded – undo
2493 2578
 	}
2494 2579
 
2495 2580
 	// Just stick a new directory on at the bottom.
2496
-	if (isset($_REQUEST['new_path']))
2497
-		$attachdirs[] = array(
2581
+	if (isset($_REQUEST['new_path'])) {
2582
+			$attachdirs[] = array(
2498 2583
 			'id' => max(array_merge(array_keys($expected_files), array_keys($modSettings['attachmentUploadDir']))) + 1,
2499 2584
 			'current' => false,
2500 2585
 			'path' => '',
@@ -2502,6 +2587,7 @@  discard block
 block discarded – undo
2502 2587
 			'num_files' => '',
2503 2588
 			'status' => '',
2504 2589
 		);
2590
+	}
2505 2591
 
2506 2592
 	return $attachdirs;
2507 2593
 }
@@ -2514,8 +2600,9 @@  discard block
 block discarded – undo
2514 2600
 {
2515 2601
 	global $modSettings, $txt;
2516 2602
 
2517
-	if (empty($modSettings['attachment_basedirectories']))
2518
-		return;
2603
+	if (empty($modSettings['attachment_basedirectories'])) {
2604
+			return;
2605
+	}
2519 2606
 
2520 2607
 	$basedirs = array();
2521 2608
 	// Get a list of the base directories.
@@ -2523,16 +2610,18 @@  discard block
 block discarded – undo
2523 2610
 	{
2524 2611
 		// Loop through the attach directory array to count any sub-directories
2525 2612
 		$expected_dirs = 0;
2526
-		foreach ($modSettings['attachmentUploadDir'] as $sid => $sub)
2527
-			if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false)
2613
+		foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) {
2614
+					if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false)
2528 2615
 				$expected_dirs++;
2616
+		}
2529 2617
 
2530
-		if (!is_dir($dir))
2531
-			$status = 'does_not_exist';
2532
-		elseif (!is_writeable($dir))
2533
-			$status = 'not_writable';
2534
-		else
2535
-			$status = 'ok';
2618
+		if (!is_dir($dir)) {
2619
+					$status = 'does_not_exist';
2620
+		} elseif (!is_writeable($dir)) {
2621
+					$status = 'not_writable';
2622
+		} else {
2623
+					$status = 'ok';
2624
+		}
2536 2625
 
2537 2626
 		$basedirs[] = array(
2538 2627
 			'id' => $id,
@@ -2543,14 +2632,15 @@  discard block
 block discarded – undo
2543 2632
 		);
2544 2633
 	}
2545 2634
 
2546
-	if (isset($_REQUEST['new_base_path']))
2547
-		$basedirs[] = array(
2635
+	if (isset($_REQUEST['new_base_path'])) {
2636
+			$basedirs[] = array(
2548 2637
 			'id' => '',
2549 2638
 			'current' => false,
2550 2639
 			'path' => '<input type="text" name="new_base_dir" value="" size="40">',
2551 2640
 			'num_dirs' => '',
2552 2641
 			'status' => '',
2553 2642
 		);
2643
+	}
2554 2644
 
2555 2645
 	return $basedirs;
2556 2646
 }
@@ -2566,10 +2656,11 @@  discard block
 block discarded – undo
2566 2656
  */
2567 2657
 function attachDirStatus($dir, $expected_files)
2568 2658
 {
2569
-	if (!is_dir($dir))
2570
-		return array('does_not_exist', true, '');
2571
-	elseif (!is_writable($dir))
2572
-		return array('not_writable', true, '');
2659
+	if (!is_dir($dir)) {
2660
+			return array('does_not_exist', true, '');
2661
+	} elseif (!is_writable($dir)) {
2662
+			return array('not_writable', true, '');
2663
+	}
2573 2664
 
2574 2665
 	// Everything is okay so far, start to scan through the directory.
2575 2666
 	$num_files = 0;
@@ -2577,22 +2668,26 @@  discard block
 block discarded – undo
2577 2668
 	while ($file = $dir_handle->read())
2578 2669
 	{
2579 2670
 		// Now do we have a real file here?
2580
-		if (in_array($file, array('.', '..', '.htaccess', 'index.php')))
2581
-			continue;
2671
+		if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) {
2672
+					continue;
2673
+		}
2582 2674
 
2583 2675
 		$num_files++;
2584 2676
 	}
2585 2677
 	$dir_handle->close();
2586 2678
 
2587
-	if ($num_files < $expected_files)
2588
-		return array('files_missing', true, $num_files);
2679
+	if ($num_files < $expected_files) {
2680
+			return array('files_missing', true, $num_files);
2681
+	}
2589 2682
 	// Empty?
2590
-	elseif ($expected_files == 0)
2591
-		return array('unused', false, $num_files);
2683
+	elseif ($expected_files == 0) {
2684
+			return array('unused', false, $num_files);
2685
+	}
2592 2686
 	// All good!
2593
-	else
2594
-		return array('ok', false, $num_files);
2595
-}
2687
+	else {
2688
+			return array('ok', false, $num_files);
2689
+	}
2690
+	}
2596 2691
 
2597 2692
 /**
2598 2693
  * Maintance function to move attachments from one directory to another
@@ -2604,10 +2699,11 @@  discard block
 block discarded – undo
2604 2699
 	checkSession();
2605 2700
 
2606 2701
 	$modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
2607
-	if (!empty($modSettings['attachment_basedirectories']))
2608
-		$modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true);
2609
-	else
2610
-		$modSettings['basedirectory_for_attachments'] = array();
2702
+	if (!empty($modSettings['attachment_basedirectories'])) {
2703
+			$modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true);
2704
+	} else {
2705
+			$modSettings['basedirectory_for_attachments'] = array();
2706
+	}
2611 2707
 
2612 2708
 	$_POST['from'] = (int) $_POST['from'];
2613 2709
 	$_POST['auto'] = !empty($_POST['auto']) ? (int) $_POST['auto'] : 0;
@@ -2621,11 +2717,13 @@  discard block
 block discarded – undo
2621 2717
 	$total_moved = 0;
2622 2718
 	$total_not_moved = 0;
2623 2719
 
2624
-	if (empty($_POST['from']) || (empty($_POST['auto']) && empty($_POST['to'])))
2625
-		$results[] = $txt['attachment_transfer_no_dir'];
2720
+	if (empty($_POST['from']) || (empty($_POST['auto']) && empty($_POST['to']))) {
2721
+			$results[] = $txt['attachment_transfer_no_dir'];
2722
+	}
2626 2723
 
2627
-	if ($_POST['from'] == $_POST['to'])
2628
-		$results[] = $txt['attachment_transfer_same_dir'];
2724
+	if ($_POST['from'] == $_POST['to']) {
2725
+			$results[] = $txt['attachment_transfer_same_dir'];
2726
+	}
2629 2727
 
2630 2728
 	if (empty($results))
2631 2729
 	{
@@ -2644,8 +2742,9 @@  discard block
 block discarded – undo
2644 2742
 		$smcFunc['db_free_result']($request);
2645 2743
 		$total_progress -= $start;
2646 2744
 
2647
-		if ($total_progress < 1)
2648
-			$results[] = $txt['attachment_transfer_no_find'];
2745
+		if ($total_progress < 1) {
2746
+					$results[] = $txt['attachment_transfer_no_find'];
2747
+		}
2649 2748
 	}
2650 2749
 
2651 2750
 	if (empty($results))
@@ -2661,9 +2760,9 @@  discard block
 block discarded – undo
2661 2760
 
2662 2761
 			automanage_attachments_check_directory();
2663 2762
 			$new_dir = $modSettings['currentAttachmentUploadDir'];
2763
+		} else {
2764
+					$new_dir = $_POST['to'];
2664 2765
 		}
2665
-		else
2666
-			$new_dir = $_POST['to'];
2667 2766
 
2668 2767
 		$modSettings['currentAttachmentUploadDir'] = $new_dir;
2669 2768
 
@@ -2671,8 +2770,9 @@  discard block
 block discarded – undo
2671 2770
 		while ($break == false)
2672 2771
 		{
2673 2772
 			@set_time_limit(300);
2674
-			if (function_exists('apache_reset_timeout'))
2675
-				@apache_reset_timeout();
2773
+			if (function_exists('apache_reset_timeout')) {
2774
+							@apache_reset_timeout();
2775
+			}
2676 2776
 
2677 2777
 			// If limits are set, get the file count and size for the destination folder
2678 2778
 			if ($dir_files <= 0 && (!empty($modSettings['attachmentDirSizeLimit']) || !empty($modSettings['attachmentDirFileLimit'])))
@@ -2708,13 +2808,15 @@  discard block
 block discarded – undo
2708 2808
 
2709 2809
 			if ($smcFunc['db_num_rows']($request) === 0)
2710 2810
 			{
2711
-				if (empty($current_progress))
2712
-					$results[] = $txt['attachment_transfer_no_find'];
2811
+				if (empty($current_progress)) {
2812
+									$results[] = $txt['attachment_transfer_no_find'];
2813
+				}
2713 2814
 				break;
2714 2815
 			}
2715 2816
 
2716
-			if ($smcFunc['db_num_rows']($request) < $limit)
2717
-				$break = true;
2817
+			if ($smcFunc['db_num_rows']($request) < $limit) {
2818
+							$break = true;
2819
+			}
2718 2820
 
2719 2821
 			// Move them
2720 2822
 			$moved = array();
@@ -2738,8 +2840,9 @@  discard block
 block discarded – undo
2738 2840
 							automanage_attachments_by_space();
2739 2841
 
2740 2842
 							$results[] = sprintf($txt['attachments_transferred'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]);
2741
-							if (!empty($total_not_moved))
2742
-								$results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved);
2843
+							if (!empty($total_not_moved)) {
2844
+															$results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved);
2845
+							}
2743 2846
 
2744 2847
 							$dir_files = 0;
2745 2848
 							$total_moved = 0;
@@ -2747,8 +2850,7 @@  discard block
 block discarded – undo
2747 2850
 
2748 2851
 							$break = false;
2749 2852
 							break;
2750
-						}
2751
-						else
2853
+						} else
2752 2854
 						{
2753 2855
 							// Hmm, not in auto. Time to bail out then...
2754 2856
 							$results[] = $txt['attachment_transfer_no_room'];
@@ -2763,9 +2865,9 @@  discard block
 block discarded – undo
2763 2865
 					$total_moved++;
2764 2866
 					$current_progress++;
2765 2867
 					$moved[] = $row['id_attach'];
2868
+				} else {
2869
+									$total_not_moved++;
2766 2870
 				}
2767
-				else
2768
-					$total_not_moved++;
2769 2871
 			}
2770 2872
 			$smcFunc['db_free_result']($request);
2771 2873
 
@@ -2803,13 +2905,15 @@  discard block
 block discarded – undo
2803 2905
 		}
2804 2906
 
2805 2907
 		$results[] = sprintf($txt['attachments_transferred'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]);
2806
-		if (!empty($total_not_moved))
2807
-			$results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved);
2908
+		if (!empty($total_not_moved)) {
2909
+					$results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved);
2910
+		}
2808 2911
 	}
2809 2912
 
2810 2913
 	$_SESSION['results'] = $results;
2811
-	if (file_exists($boarddir . '/progress.php'))
2812
-		unlink($boarddir . '/progress.php');
2914
+	if (file_exists($boarddir . '/progress.php')) {
2915
+			unlink($boarddir . '/progress.php');
2916
+	}
2813 2917
 
2814 2918
 	redirectexit('action=admin;area=manageattachments;sa=maintenance#transfer');
2815 2919
 }
Please login to merge, or discard this patch.
Sources/ManageMaintenance.php 1 patch
Braces   +266 added lines, -197 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Main dispatcher, the maintenance access point.
@@ -96,14 +97,16 @@  discard block
 block discarded – undo
96 97
 	call_integration_hook('integrate_manage_maintenance', array(&$subActions));
97 98
 
98 99
 	// Yep, sub-action time!
99
-	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]))
100
-		$subAction = $_REQUEST['sa'];
101
-	else
102
-		$subAction = 'routine';
100
+	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
101
+			$subAction = $_REQUEST['sa'];
102
+	} else {
103
+			$subAction = 'routine';
104
+	}
103 105
 
104 106
 	// Doing something special?
105
-	if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']]))
106
-		$activity = $_REQUEST['activity'];
107
+	if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']])) {
108
+			$activity = $_REQUEST['activity'];
109
+	}
107 110
 
108 111
 	// Set a few things.
109 112
 	$context['page_title'] = $txt['maintain_title'];
@@ -114,12 +117,14 @@  discard block
 block discarded – undo
114 117
 	call_helper($subActions[$subAction]['function']);
115 118
 
116 119
 	// Any special activity?
117
-	if (isset($activity))
118
-		call_helper($subActions[$subAction]['activities'][$activity]);
120
+	if (isset($activity)) {
121
+			call_helper($subActions[$subAction]['activities'][$activity]);
122
+	}
119 123
 
120 124
 	//converted to UTF-8? show a small maintenance info
121
-	if (isset($_GET['done']) && $_GET['done'] == 'convertutf8')
122
-		$context['maintenance_finished'] = $txt['utf8_title'];
125
+	if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') {
126
+			$context['maintenance_finished'] = $txt['utf8_title'];
127
+	}
123 128
 
124 129
 	// Create a maintenance token.  Kinda hard to do it any other way.
125 130
 	createToken('admin-maint');
@@ -141,19 +146,22 @@  discard block
 block discarded – undo
141 146
 		db_extend('packages');
142 147
 
143 148
 		$colData = $smcFunc['db_list_columns']('{db_prefix}messages', true);
144
-		foreach ($colData as $column)
145
-			if ($column['name'] == 'body')
149
+		foreach ($colData as $column) {
150
+					if ($column['name'] == 'body')
146 151
 				$body_type = $column['type'];
152
+		}
147 153
 
148 154
 		$context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text';
149 155
 		$context['convert_to_suggest'] = ($body_type != 'text' && !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] < 65536);
150 156
 	}
151 157
 
152
-	if (isset($_GET['done']) && $_GET['done'] == 'convertutf8')
153
-		$context['maintenance_finished'] = $txt['utf8_title'];
154
-	if (isset($_GET['done']) && $_GET['done'] == 'convertentities')
155
-		$context['maintenance_finished'] = $txt['entity_convert_title'];
156
-}
158
+	if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') {
159
+			$context['maintenance_finished'] = $txt['utf8_title'];
160
+	}
161
+	if (isset($_GET['done']) && $_GET['done'] == 'convertentities') {
162
+			$context['maintenance_finished'] = $txt['entity_convert_title'];
163
+	}
164
+	}
157 165
 
158 166
 /**
159 167
  * Supporting function for the routine maintenance area.
@@ -162,9 +170,10 @@  discard block
 block discarded – undo
162 170
 {
163 171
 	global $context, $txt;
164 172
 
165
-	if (isset($_GET['done']) && $_GET['done'] == 'recount')
166
-		$context['maintenance_finished'] = $txt['maintain_recount'];
167
-}
173
+	if (isset($_GET['done']) && $_GET['done'] == 'recount') {
174
+			$context['maintenance_finished'] = $txt['maintain_recount'];
175
+	}
176
+	}
168 177
 
169 178
 /**
170 179
  * Supporting function for the members maintenance area.
@@ -195,8 +204,9 @@  discard block
 block discarded – undo
195 204
 	}
196 205
 	$smcFunc['db_free_result']($result);
197 206
 
198
-	if (isset($_GET['done']) && $_GET['done'] == 'recountposts')
199
-		$context['maintenance_finished'] = $txt['maintain_recountposts'];
207
+	if (isset($_GET['done']) && $_GET['done'] == 'recountposts') {
208
+			$context['maintenance_finished'] = $txt['maintain_recountposts'];
209
+	}
200 210
 
201 211
 	loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest');
202 212
 }
@@ -222,11 +232,12 @@  discard block
 block discarded – undo
222 232
 	$context['categories'] = array();
223 233
 	while ($row = $smcFunc['db_fetch_assoc']($result))
224 234
 	{
225
-		if (!isset($context['categories'][$row['id_cat']]))
226
-			$context['categories'][$row['id_cat']] = array(
235
+		if (!isset($context['categories'][$row['id_cat']])) {
236
+					$context['categories'][$row['id_cat']] = array(
227 237
 				'name' => $row['cat_name'],
228 238
 				'boards' => array()
229 239
 			);
240
+		}
230 241
 
231 242
 		$context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
232 243
 			'id' => $row['id_board'],
@@ -239,11 +250,12 @@  discard block
 block discarded – undo
239 250
 	require_once($sourcedir . '/Subs-Boards.php');
240 251
 	sortCategories($context['categories']);
241 252
 
242
-	if (isset($_GET['done']) && $_GET['done'] == 'purgeold')
243
-		$context['maintenance_finished'] = $txt['maintain_old'];
244
-	elseif (isset($_GET['done']) && $_GET['done'] == 'massmove')
245
-		$context['maintenance_finished'] = $txt['move_topics_maintenance'];
246
-}
253
+	if (isset($_GET['done']) && $_GET['done'] == 'purgeold') {
254
+			$context['maintenance_finished'] = $txt['maintain_old'];
255
+	} elseif (isset($_GET['done']) && $_GET['done'] == 'massmove') {
256
+			$context['maintenance_finished'] = $txt['move_topics_maintenance'];
257
+	}
258
+	}
247 259
 
248 260
 /**
249 261
  * Find and fix all errors on the forum.
@@ -351,15 +363,17 @@  discard block
 block discarded – undo
351 363
 	// Show me your badge!
352 364
 	isAllowedTo('admin_forum');
353 365
 
354
-	if ($db_type != 'mysql')
355
-		return;
366
+	if ($db_type != 'mysql') {
367
+			return;
368
+	}
356 369
 
357 370
 	db_extend('packages');
358 371
 
359 372
 	$colData = $smcFunc['db_list_columns']('{db_prefix}messages', true);
360
-	foreach ($colData as $column)
361
-		if ($column['name'] == 'body')
373
+	foreach ($colData as $column) {
374
+			if ($column['name'] == 'body')
362 375
 			$body_type = $column['type'];
376
+	}
363 377
 
364 378
 	$context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text';
365 379
 
@@ -369,33 +383,36 @@  discard block
 block discarded – undo
369 383
 		validateToken('admin-maint');
370 384
 
371 385
 		// Make it longer so we can do their limit.
372
-		if ($body_type == 'text')
373
-			$smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext'));
386
+		if ($body_type == 'text') {
387
+					$smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext'));
388
+		}
374 389
 		// Shorten the column so we can have a bit (literally per record) less space occupied
375
-		else
376
-			$smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text'));
390
+		else {
391
+					$smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text'));
392
+		}
377 393
 
378 394
 		// 3rd party integrations may be interested in knowning about this.
379 395
 		call_integration_hook('integrate_convert_msgbody', array($body_type));
380 396
 
381 397
 		$colData = $smcFunc['db_list_columns']('{db_prefix}messages', true);
382
-		foreach ($colData as $column)
383
-			if ($column['name'] == 'body')
398
+		foreach ($colData as $column) {
399
+					if ($column['name'] == 'body')
384 400
 				$body_type = $column['type'];
401
+		}
385 402
 
386 403
 		$context['maintenance_finished'] = $txt[$context['convert_to'] . '_title'];
387 404
 		$context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text';
388 405
 		$context['convert_to_suggest'] = ($body_type != 'text' && !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] < 65536);
389 406
 
390 407
 		return;
391
-	}
392
-	elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont'])))
408
+	} elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont'])))
393 409
 	{
394 410
 		checkSession();
395
-		if (empty($_REQUEST['start']))
396
-			validateToken('admin-maint');
397
-		else
398
-			validateToken('admin-convertMsg');
411
+		if (empty($_REQUEST['start'])) {
412
+					validateToken('admin-maint');
413
+		} else {
414
+					validateToken('admin-convertMsg');
415
+		}
399 416
 
400 417
 		$context['page_title'] = $txt['not_done_title'];
401 418
 		$context['continue_post_data'] = '';
@@ -427,8 +444,9 @@  discard block
 block discarded – undo
427 444
 					'increment' => $increment - 1,
428 445
 				)
429 446
 			);
430
-			while ($row = $smcFunc['db_fetch_assoc']($request))
431
-				$id_msg_exceeding[] = $row['id_msg'];
447
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
448
+							$id_msg_exceeding[] = $row['id_msg'];
449
+			}
432 450
 			$smcFunc['db_free_result']($request);
433 451
 
434 452
 			$_REQUEST['start'] += $increment;
@@ -457,9 +475,9 @@  discard block
 block discarded – undo
457 475
 			{
458 476
 				$query_msg = array_slice($id_msg_exceeding, 0, 100);
459 477
 				$context['exceeding_messages_morethan'] = sprintf($txt['exceeding_messages_morethan'], count($id_msg_exceeding));
478
+			} else {
479
+							$query_msg = $id_msg_exceeding;
460 480
 			}
461
-			else
462
-				$query_msg = $id_msg_exceeding;
463 481
 
464 482
 			$context['exceeding_messages'] = array();
465 483
 			$request = $smcFunc['db_query']('', '
@@ -470,8 +488,9 @@  discard block
 block discarded – undo
470 488
 					'messages' => $query_msg,
471 489
 				)
472 490
 			);
473
-			while ($row = $smcFunc['db_fetch_assoc']($request))
474
-				$context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
491
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
492
+							$context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
493
+			}
475 494
 			$smcFunc['db_free_result']($request);
476 495
 		}
477 496
 	}
@@ -495,8 +514,9 @@  discard block
 block discarded – undo
495 514
 	isAllowedTo('admin_forum');
496 515
 
497 516
 	// Check to see if UTF-8 is currently the default character set.
498
-	if ($modSettings['global_character_set'] !== 'UTF-8' || !isset($db_character_set) || $db_character_set !== 'utf8')
499
-		fatal_lang_error('entity_convert_only_utf8');
517
+	if ($modSettings['global_character_set'] !== 'UTF-8' || !isset($db_character_set) || $db_character_set !== 'utf8') {
518
+			fatal_lang_error('entity_convert_only_utf8');
519
+	}
500 520
 
501 521
 	// Some starting values.
502 522
 	$context['table'] = empty($_REQUEST['table']) ? 0 : (int) $_REQUEST['table'];
@@ -558,8 +578,9 @@  discard block
 block discarded – undo
558 578
 		// Make sure we keep stuff unique!
559 579
 		$primary_keys = array();
560 580
 
561
-		if (function_exists('apache_reset_timeout'))
562
-			@apache_reset_timeout();
581
+		if (function_exists('apache_reset_timeout')) {
582
+					@apache_reset_timeout();
583
+		}
563 584
 
564 585
 		// Get a list of text columns.
565 586
 		$columns = array();
@@ -570,9 +591,10 @@  discard block
 block discarded – undo
570 591
 				'cur_table' => $cur_table,
571 592
 			)
572 593
 		);
573
-		while ($column_info = $smcFunc['db_fetch_assoc']($request))
574
-			if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false)
594
+		while ($column_info = $smcFunc['db_fetch_assoc']($request)) {
595
+					if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false)
575 596
 				$columns[] = strtolower($column_info['Field']);
597
+		}
576 598
 
577 599
 		// Get the column with the (first) primary key.
578 600
 		$request = $smcFunc['db_query']('', '
@@ -586,8 +608,9 @@  discard block
 block discarded – undo
586 608
 		{
587 609
 			if ($row['Key_name'] === 'PRIMARY')
588 610
 			{
589
-				if (empty($primary_key) || ($row['Seq_in_index'] == 1 && !in_array(strtolower($row['Column_name']), $columns)))
590
-					$primary_key = $row['Column_name'];
611
+				if (empty($primary_key) || ($row['Seq_in_index'] == 1 && !in_array(strtolower($row['Column_name']), $columns))) {
612
+									$primary_key = $row['Column_name'];
613
+				}
591 614
 
592 615
 				$primary_keys[] = $row['Column_name'];
593 616
 			}
@@ -596,8 +619,9 @@  discard block
 block discarded – undo
596 619
 
597 620
 		// No primary key, no glory.
598 621
 		// Same for columns. Just to be sure we've work to do!
599
-		if (empty($primary_key) || empty($columns))
600
-			continue;
622
+		if (empty($primary_key) || empty($columns)) {
623
+					continue;
624
+		}
601 625
 
602 626
 		// Get the maximum value for the primary key.
603 627
 		$request = $smcFunc['db_query']('', '
@@ -611,8 +635,9 @@  discard block
 block discarded – undo
611 635
 		list($max_value) = $smcFunc['db_fetch_row']($request);
612 636
 		$smcFunc['db_free_result']($request);
613 637
 
614
-		if (empty($max_value))
615
-			continue;
638
+		if (empty($max_value)) {
639
+					continue;
640
+		}
616 641
 
617 642
 		while ($context['start'] <= $max_value)
618 643
 		{
@@ -636,10 +661,11 @@  discard block
 block discarded – undo
636 661
 			{
637 662
 				$insertion_variables = array();
638 663
 				$changes = array();
639
-				foreach ($row as $column_name => $column_value)
640
-					if ($column_name !== $primary_key && strpos($column_value, '&#') !== false)
664
+				foreach ($row as $column_name => $column_value) {
665
+									if ($column_name !== $primary_key && strpos($column_value, '&#') !== false)
641 666
 					{
642 667
 						$changes[] = $column_name . ' = {string:changes_' . $column_name . '}';
668
+				}
643 669
 						$insertion_variables['changes_' . $column_name] = preg_replace_callback('~&#(\d{1,7}|x[0-9a-fA-F]{1,6});~', 'fixchar__callback', $column_value);
644 670
 					}
645 671
 
@@ -651,8 +677,8 @@  discard block
 block discarded – undo
651 677
 				}
652 678
 
653 679
 				// Update the row.
654
-				if (!empty($changes))
655
-					$smcFunc['db_query']('', '
680
+				if (!empty($changes)) {
681
+									$smcFunc['db_query']('', '
656 682
 						UPDATE {db_prefix}' . $cur_table . '
657 683
 						SET
658 684
 							' . implode(',
@@ -660,6 +686,7 @@  discard block
 block discarded – undo
660 686
 						WHERE ' . implode(' AND ', $where),
661 687
 						$insertion_variables
662 688
 					);
689
+				}
663 690
 			}
664 691
 			$smcFunc['db_free_result']($request);
665 692
 			$context['start'] += 500;
@@ -700,10 +727,11 @@  discard block
 block discarded – undo
700 727
 
701 728
 	checkSession('request');
702 729
 
703
-	if (!isset($_SESSION['optimized_tables']))
704
-		validateToken('admin-maint');
705
-	else
706
-		validateToken('admin-optimize', 'post', false);
730
+	if (!isset($_SESSION['optimized_tables'])) {
731
+			validateToken('admin-maint');
732
+	} else {
733
+			validateToken('admin-optimize', 'post', false);
734
+	}
707 735
 
708 736
 	ignore_user_abort(true);
709 737
 	db_extend();
@@ -719,13 +747,15 @@  discard block
 block discarded – undo
719 747
 	// Get a list of tables, as well as how many there are.
720 748
 	$temp_tables = $smcFunc['db_list_tables'](false, $real_prefix . '%');
721 749
 	$tables = array();
722
-	foreach ($temp_tables as $table)
723
-		$tables[] = array('table_name' => $table);
750
+	foreach ($temp_tables as $table) {
751
+			$tables[] = array('table_name' => $table);
752
+	}
724 753
 
725 754
 	// If there aren't any tables then I believe that would mean the world has exploded...
726 755
 	$context['num_tables'] = count($tables);
727
-	if ($context['num_tables'] == 0)
728
-		fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false);
756
+	if ($context['num_tables'] == 0) {
757
+			fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false);
758
+	}
729 759
 
730 760
 	$_REQUEST['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start'];
731 761
 
@@ -736,8 +766,9 @@  discard block
 block discarded – undo
736 766
 	$_SESSION['optimized_tables'] = !empty($_SESSION['optimized_tables']) ? $_SESSION['optimized_tables'] : array();
737 767
 	for ($key = $_REQUEST['start']; $context['num_tables'] - 1; $key++)
738 768
 	{
739
-		if (empty($tables[$key]))
740
-			break;
769
+		if (empty($tables[$key])) {
770
+					break;
771
+		}
741 772
 
742 773
 		// Continue?
743 774
 		if (microtime(true) - $time_start > 10)
@@ -751,8 +782,9 @@  discard block
 block discarded – undo
751 782
 			createToken('admin-optimize');
752 783
 			$context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-optimize_token_var'] . '" value="' . $context['admin-optimize_token'] . '">';
753 784
 
754
-			if (function_exists('apache_reset_timeout'))
755
-				apache_reset_timeout();
785
+			if (function_exists('apache_reset_timeout')) {
786
+							apache_reset_timeout();
787
+			}
756 788
 
757 789
 			return;
758 790
 		}
@@ -760,11 +792,12 @@  discard block
 block discarded – undo
760 792
 		// Optimize the table!  We use backticks here because it might be a custom table.
761 793
 		$data_freed = $smcFunc['db_optimize_table']($tables[$key]['table_name']);
762 794
 
763
-		if ($data_freed > 0)
764
-			$_SESSION['optimized_tables'][] = array(
795
+		if ($data_freed > 0) {
796
+					$_SESSION['optimized_tables'][] = array(
765 797
 				'name' => $tables[$key]['table_name'],
766 798
 				'data_freed' => $data_freed,
767 799
 			);
800
+		}
768 801
 	}
769 802
 
770 803
 	// Number of tables, etc...
@@ -799,10 +832,11 @@  discard block
 block discarded – undo
799 832
 	checkSession('request');
800 833
 
801 834
 	// validate the request or the loop
802
-	if (!isset($_REQUEST['step']))
803
-		validateToken('admin-maint');
804
-	else
805
-		validateToken('admin-boardrecount');
835
+	if (!isset($_REQUEST['step'])) {
836
+			validateToken('admin-maint');
837
+	} else {
838
+			validateToken('admin-boardrecount');
839
+	}
806 840
 
807 841
 	$context['page_title'] = $txt['not_done_title'];
808 842
 	$context['continue_post_data'] = '';
@@ -823,8 +857,9 @@  discard block
 block discarded – undo
823 857
 	$smcFunc['db_free_result']($request);
824 858
 
825 859
 	$increment = min(max(50, ceil($max_topics / 4)), 2000);
826
-	if (empty($_REQUEST['start']))
827
-		$_REQUEST['start'] = 0;
860
+	if (empty($_REQUEST['start'])) {
861
+			$_REQUEST['start'] = 0;
862
+	}
828 863
 
829 864
 	$total_steps = 8;
830 865
 
@@ -851,8 +886,8 @@  discard block
 block discarded – undo
851 886
 					'max_id' => $_REQUEST['start'] + $increment,
852 887
 				)
853 888
 			);
854
-			while ($row = $smcFunc['db_fetch_assoc']($request))
855
-				$smcFunc['db_query']('', '
889
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
890
+							$smcFunc['db_query']('', '
856 891
 					UPDATE {db_prefix}topics
857 892
 					SET num_replies = {int:num_replies}
858 893
 					WHERE id_topic = {int:id_topic}',
@@ -861,6 +896,7 @@  discard block
 block discarded – undo
861 896
 						'id_topic' => $row['id_topic'],
862 897
 					)
863 898
 				);
899
+			}
864 900
 			$smcFunc['db_free_result']($request);
865 901
 
866 902
 			// Recount unapproved messages
@@ -879,8 +915,8 @@  discard block
 block discarded – undo
879 915
 					'max_id' => $_REQUEST['start'] + $increment,
880 916
 				)
881 917
 			);
882
-			while ($row = $smcFunc['db_fetch_assoc']($request))
883
-				$smcFunc['db_query']('', '
918
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
919
+							$smcFunc['db_query']('', '
884 920
 					UPDATE {db_prefix}topics
885 921
 					SET unapproved_posts = {int:unapproved_posts}
886 922
 					WHERE id_topic = {int:id_topic}',
@@ -889,6 +925,7 @@  discard block
 block discarded – undo
889 925
 						'id_topic' => $row['id_topic'],
890 926
 					)
891 927
 				);
928
+			}
892 929
 			$smcFunc['db_free_result']($request);
893 930
 
894 931
 			$_REQUEST['start'] += $increment;
@@ -911,8 +948,8 @@  discard block
 block discarded – undo
911 948
 	// Update the post count of each board.
912 949
 	if ($_REQUEST['step'] <= 1)
913 950
 	{
914
-		if (empty($_REQUEST['start']))
915
-			$smcFunc['db_query']('', '
951
+		if (empty($_REQUEST['start'])) {
952
+					$smcFunc['db_query']('', '
916 953
 				UPDATE {db_prefix}boards
917 954
 				SET num_posts = {int:num_posts}
918 955
 				WHERE redirect = {string:redirect}',
@@ -921,6 +958,7 @@  discard block
 block discarded – undo
921 958
 					'redirect' => '',
922 959
 				)
923 960
 			);
961
+		}
924 962
 
925 963
 		while ($_REQUEST['start'] < $max_topics)
926 964
 		{
@@ -937,8 +975,8 @@  discard block
 block discarded – undo
937 975
 					'is_approved' => 1,
938 976
 				)
939 977
 			);
940
-			while ($row = $smcFunc['db_fetch_assoc']($request))
941
-				$smcFunc['db_query']('', '
978
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
979
+							$smcFunc['db_query']('', '
942 980
 					UPDATE {db_prefix}boards
943 981
 					SET num_posts = num_posts + {int:real_num_posts}
944 982
 					WHERE id_board = {int:id_board}',
@@ -947,6 +985,7 @@  discard block
 block discarded – undo
947 985
 						'real_num_posts' => $row['real_num_posts'],
948 986
 					)
949 987
 				);
988
+			}
950 989
 			$smcFunc['db_free_result']($request);
951 990
 
952 991
 			$_REQUEST['start'] += $increment;
@@ -969,14 +1008,15 @@  discard block
 block discarded – undo
969 1008
 	// Update the topic count of each board.
970 1009
 	if ($_REQUEST['step'] <= 2)
971 1010
 	{
972
-		if (empty($_REQUEST['start']))
973
-			$smcFunc['db_query']('', '
1011
+		if (empty($_REQUEST['start'])) {
1012
+					$smcFunc['db_query']('', '
974 1013
 				UPDATE {db_prefix}boards
975 1014
 				SET num_topics = {int:num_topics}',
976 1015
 				array(
977 1016
 					'num_topics' => 0,
978 1017
 				)
979 1018
 			);
1019
+		}
980 1020
 
981 1021
 		while ($_REQUEST['start'] < $max_topics)
982 1022
 		{
@@ -993,8 +1033,8 @@  discard block
 block discarded – undo
993 1033
 					'id_topic_max' => $_REQUEST['start'] + $increment,
994 1034
 				)
995 1035
 			);
996
-			while ($row = $smcFunc['db_fetch_assoc']($request))
997
-				$smcFunc['db_query']('', '
1036
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1037
+							$smcFunc['db_query']('', '
998 1038
 					UPDATE {db_prefix}boards
999 1039
 					SET num_topics = num_topics + {int:real_num_topics}
1000 1040
 					WHERE id_board = {int:id_board}',
@@ -1003,6 +1043,7 @@  discard block
 block discarded – undo
1003 1043
 						'real_num_topics' => $row['real_num_topics'],
1004 1044
 					)
1005 1045
 				);
1046
+			}
1006 1047
 			$smcFunc['db_free_result']($request);
1007 1048
 
1008 1049
 			$_REQUEST['start'] += $increment;
@@ -1025,14 +1066,15 @@  discard block
 block discarded – undo
1025 1066
 	// Update the unapproved post count of each board.
1026 1067
 	if ($_REQUEST['step'] <= 3)
1027 1068
 	{
1028
-		if (empty($_REQUEST['start']))
1029
-			$smcFunc['db_query']('', '
1069
+		if (empty($_REQUEST['start'])) {
1070
+					$smcFunc['db_query']('', '
1030 1071
 				UPDATE {db_prefix}boards
1031 1072
 				SET unapproved_posts = {int:unapproved_posts}',
1032 1073
 				array(
1033 1074
 					'unapproved_posts' => 0,
1034 1075
 				)
1035 1076
 			);
1077
+		}
1036 1078
 
1037 1079
 		while ($_REQUEST['start'] < $max_topics)
1038 1080
 		{
@@ -1049,8 +1091,8 @@  discard block
 block discarded – undo
1049 1091
 					'is_approved' => 0,
1050 1092
 				)
1051 1093
 			);
1052
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1053
-				$smcFunc['db_query']('', '
1094
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1095
+							$smcFunc['db_query']('', '
1054 1096
 					UPDATE {db_prefix}boards
1055 1097
 					SET unapproved_posts = unapproved_posts + {int:unapproved_posts}
1056 1098
 					WHERE id_board = {int:id_board}',
@@ -1059,6 +1101,7 @@  discard block
 block discarded – undo
1059 1101
 						'unapproved_posts' => $row['real_unapproved_posts'],
1060 1102
 					)
1061 1103
 				);
1104
+			}
1062 1105
 			$smcFunc['db_free_result']($request);
1063 1106
 
1064 1107
 			$_REQUEST['start'] += $increment;
@@ -1081,14 +1124,15 @@  discard block
 block discarded – undo
1081 1124
 	// Update the unapproved topic count of each board.
1082 1125
 	if ($_REQUEST['step'] <= 4)
1083 1126
 	{
1084
-		if (empty($_REQUEST['start']))
1085
-			$smcFunc['db_query']('', '
1127
+		if (empty($_REQUEST['start'])) {
1128
+					$smcFunc['db_query']('', '
1086 1129
 				UPDATE {db_prefix}boards
1087 1130
 				SET unapproved_topics = {int:unapproved_topics}',
1088 1131
 				array(
1089 1132
 					'unapproved_topics' => 0,
1090 1133
 				)
1091 1134
 			);
1135
+		}
1092 1136
 
1093 1137
 		while ($_REQUEST['start'] < $max_topics)
1094 1138
 		{
@@ -1105,8 +1149,8 @@  discard block
 block discarded – undo
1105 1149
 					'id_topic_max' => $_REQUEST['start'] + $increment,
1106 1150
 				)
1107 1151
 			);
1108
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1109
-				$smcFunc['db_query']('', '
1152
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1153
+							$smcFunc['db_query']('', '
1110 1154
 					UPDATE {db_prefix}boards
1111 1155
 					SET unapproved_topics = unapproved_topics + {int:real_unapproved_topics}
1112 1156
 					WHERE id_board = {int:id_board}',
@@ -1115,6 +1159,7 @@  discard block
 block discarded – undo
1115 1159
 						'real_unapproved_topics' => $row['real_unapproved_topics'],
1116 1160
 					)
1117 1161
 				);
1162
+			}
1118 1163
 			$smcFunc['db_free_result']($request);
1119 1164
 
1120 1165
 			$_REQUEST['start'] += $increment;
@@ -1148,8 +1193,9 @@  discard block
 block discarded – undo
1148 1193
 				'is_not_deleted' => 0,
1149 1194
 			)
1150 1195
 		);
1151
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1152
-			updateMemberData($row['id_member'], array('instant_messages' => $row['real_num']));
1196
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1197
+					updateMemberData($row['id_member'], array('instant_messages' => $row['real_num']));
1198
+		}
1153 1199
 		$smcFunc['db_free_result']($request);
1154 1200
 
1155 1201
 		$request = $smcFunc['db_query']('', '
@@ -1164,8 +1210,9 @@  discard block
 block discarded – undo
1164 1210
 				'is_not_read' => 0,
1165 1211
 			)
1166 1212
 		);
1167
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1168
-			updateMemberData($row['id_member'], array('unread_messages' => $row['real_num']));
1213
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1214
+					updateMemberData($row['id_member'], array('unread_messages' => $row['real_num']));
1215
+		}
1169 1216
 		$smcFunc['db_free_result']($request);
1170 1217
 
1171 1218
 		if (microtime(true) - $time_start > 3)
@@ -1197,12 +1244,13 @@  discard block
 block discarded – undo
1197 1244
 				)
1198 1245
 			);
1199 1246
 			$boards = array();
1200
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1201
-				$boards[$row['id_board']][] = $row['id_msg'];
1247
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1248
+							$boards[$row['id_board']][] = $row['id_msg'];
1249
+			}
1202 1250
 			$smcFunc['db_free_result']($request);
1203 1251
 
1204
-			foreach ($boards as $board_id => $messages)
1205
-				$smcFunc['db_query']('', '
1252
+			foreach ($boards as $board_id => $messages) {
1253
+							$smcFunc['db_query']('', '
1206 1254
 					UPDATE {db_prefix}messages
1207 1255
 					SET id_board = {int:id_board}
1208 1256
 					WHERE id_msg IN ({array_int:id_msg_array})',
@@ -1211,6 +1259,7 @@  discard block
 block discarded – undo
1211 1259
 						'id_board' => $board_id,
1212 1260
 					)
1213 1261
 				);
1262
+			}
1214 1263
 
1215 1264
 			$_REQUEST['start'] += $increment;
1216 1265
 
@@ -1240,8 +1289,9 @@  discard block
 block discarded – undo
1240 1289
 		)
1241 1290
 	);
1242 1291
 	$realBoardCounts = array();
1243
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1244
-		$realBoardCounts[$row['id_board']] = $row['local_last_msg'];
1292
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1293
+			$realBoardCounts[$row['id_board']] = $row['local_last_msg'];
1294
+	}
1245 1295
 	$smcFunc['db_free_result']($request);
1246 1296
 
1247 1297
 	$request = $smcFunc['db_query']('', '
@@ -1261,18 +1311,20 @@  discard block
 block discarded – undo
1261 1311
 	krsort($resort_me);
1262 1312
 
1263 1313
 	$lastModifiedMsg = array();
1264
-	foreach ($resort_me as $rows)
1265
-		foreach ($rows as $row)
1314
+	foreach ($resort_me as $rows) {
1315
+			foreach ($rows as $row)
1266 1316
 		{
1267 1317
 			// The latest message is the latest of the current board and its children.
1268 1318
 			if (isset($lastModifiedMsg[$row['id_board']]))
1269 1319
 				$curLastModifiedMsg = max($row['local_last_msg'], $lastModifiedMsg[$row['id_board']]);
1270
-			else
1271
-				$curLastModifiedMsg = $row['local_last_msg'];
1320
+	}
1321
+			else {
1322
+							$curLastModifiedMsg = $row['local_last_msg'];
1323
+			}
1272 1324
 
1273 1325
 			// If what is and what should be the latest message differ, an update is necessary.
1274
-			if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated'])
1275
-				$smcFunc['db_query']('', '
1326
+			if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) {
1327
+							$smcFunc['db_query']('', '
1276 1328
 					UPDATE {db_prefix}boards
1277 1329
 					SET id_last_msg = {int:id_last_msg}, id_msg_updated = {int:id_msg_updated}
1278 1330
 					WHERE id_board = {int:id_board}',
@@ -1282,12 +1334,14 @@  discard block
 block discarded – undo
1282 1334
 						'id_board' => $row['id_board'],
1283 1335
 					)
1284 1336
 				);
1337
+			}
1285 1338
 
1286 1339
 			// Parent boards inherit the latest modified message of their children.
1287
-			if (isset($lastModifiedMsg[$row['id_parent']]))
1288
-				$lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]);
1289
-			else
1290
-				$lastModifiedMsg[$row['id_parent']] = $row['local_last_msg'];
1340
+			if (isset($lastModifiedMsg[$row['id_parent']])) {
1341
+							$lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]);
1342
+			} else {
1343
+							$lastModifiedMsg[$row['id_parent']] = $row['local_last_msg'];
1344
+			}
1291 1345
 		}
1292 1346
 
1293 1347
 	// Update all the basic statistics.
@@ -1359,8 +1413,9 @@  discard block
 block discarded – undo
1359 1413
 	require_once($sourcedir . '/Subs-Auth.php');
1360 1414
 	$members = findMembers($_POST['to']);
1361 1415
 
1362
-	if (empty($members))
1363
-		fatal_lang_error('reattribute_cannot_find_member');
1416
+	if (empty($members)) {
1417
+			fatal_lang_error('reattribute_cannot_find_member');
1418
+	}
1364 1419
 
1365 1420
 	$memID = array_shift($members);
1366 1421
 	$memID = $memID['id'];
@@ -1390,8 +1445,9 @@  discard block
 block discarded – undo
1390 1445
 		validateToken('admin-maint');
1391 1446
 
1392 1447
 		$groups = array();
1393
-		foreach ($_POST['groups'] as $id => $dummy)
1394
-			$groups[] = (int) $id;
1448
+		foreach ($_POST['groups'] as $id => $dummy) {
1449
+					$groups[] = (int) $id;
1450
+		}
1395 1451
 		$time_limit = (time() - ($_POST['maxdays'] * 24 * 3600));
1396 1452
 		$where_vars = array(
1397 1453
 			'time_limit' => $time_limit,
@@ -1400,9 +1456,9 @@  discard block
 block discarded – undo
1400 1456
 		{
1401 1457
 			$where = 'mem.date_registered < {int:time_limit} AND mem.is_activated = {int:is_activated}';
1402 1458
 			$where_vars['is_activated'] = 0;
1459
+		} else {
1460
+					$where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})';
1403 1461
 		}
1404
-		else
1405
-			$where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})';
1406 1462
 
1407 1463
 		// Need to get *all* groups then work out which (if any) we avoid.
1408 1464
 		$request = $smcFunc['db_query']('', '
@@ -1421,8 +1477,7 @@  discard block
 block discarded – undo
1421 1477
 				{
1422 1478
 					$where .= ' AND mem.id_post_group != {int:id_post_group_' . $row['id_group'] . '}';
1423 1479
 					$where_vars['id_post_group_' . $row['id_group']] = $row['id_group'];
1424
-				}
1425
-				else
1480
+				} else
1426 1481
 				{
1427 1482
 					$where .= ' AND mem.id_group != {int:id_group_' . $row['id_group'] . '} AND FIND_IN_SET({int:id_group_' . $row['id_group'] . '}, mem.additional_groups) = 0';
1428 1483
 					$where_vars['id_group_' . $row['id_group']] = $row['id_group'];
@@ -1449,8 +1504,9 @@  discard block
 block discarded – undo
1449 1504
 		$members = array();
1450 1505
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1451 1506
 		{
1452
-			if (!$row['is_mod'] || !in_array(3, $groups))
1453
-				$members[] = $row['id_member'];
1507
+			if (!$row['is_mod'] || !in_array(3, $groups)) {
1508
+							$members[] = $row['id_member'];
1509
+			}
1454 1510
 		}
1455 1511
 		$smcFunc['db_free_result']($request);
1456 1512
 
@@ -1497,8 +1553,9 @@  discard block
 block discarded – undo
1497 1553
 		)
1498 1554
 	);
1499 1555
 
1500
-	while ($row = $smcFunc['db_fetch_row']($request))
1501
-		$drafts[] = (int) $row[0];
1556
+	while ($row = $smcFunc['db_fetch_row']($request)) {
1557
+			$drafts[] = (int) $row[0];
1558
+	}
1502 1559
 	$smcFunc['db_free_result']($request);
1503 1560
 
1504 1561
 	// If we have old drafts, remove them
@@ -1541,8 +1598,9 @@  discard block
 block discarded – undo
1541 1598
 	$sticky = isset($_POST['move_type_sticky']) || isset($_GET['sticky']);
1542 1599
 
1543 1600
 	// No boards then this is your stop.
1544
-	if (empty($id_board_from) || empty($id_board_to))
1545
-		return;
1601
+	if (empty($id_board_from) || empty($id_board_to)) {
1602
+			return;
1603
+	}
1546 1604
 
1547 1605
 	// The big WHERE clause
1548 1606
 	$conditions = 'WHERE t.id_board = {int:id_board_from}
@@ -1590,18 +1648,20 @@  discard block
 block discarded – undo
1590 1648
 		);
1591 1649
 		list ($total_topics) = $smcFunc['db_fetch_row']($request);
1592 1650
 		$smcFunc['db_free_result']($request);
1651
+	} else {
1652
+			$total_topics = (int) $_REQUEST['totaltopics'];
1593 1653
 	}
1594
-	else
1595
-		$total_topics = (int) $_REQUEST['totaltopics'];
1596 1654
 
1597 1655
 	// Seems like we need this here.
1598 1656
 	$context['continue_get_data'] = '?action=admin;area=maintain;sa=topics;activity=massmove;id_board_from=' . $id_board_from . ';id_board_to=' . $id_board_to . ';totaltopics=' . $total_topics . ';max_days=' . $max_days;
1599 1657
 
1600
-	if ($locked)
1601
-		$context['continue_get_data'] .= ';locked';
1658
+	if ($locked) {
1659
+			$context['continue_get_data'] .= ';locked';
1660
+	}
1602 1661
 
1603
-	if ($sticky)
1604
-		$context['continue_get_data'] .= ';sticky';
1662
+	if ($sticky) {
1663
+			$context['continue_get_data'] .= ';sticky';
1664
+	}
1605 1665
 
1606 1666
 	$context['continue_get_data'] .= ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id'];
1607 1667
 
@@ -1622,8 +1682,9 @@  discard block
 block discarded – undo
1622 1682
 
1623 1683
 			// Get the ids.
1624 1684
 			$topics = array();
1625
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1626
-				$topics[] = $row['id_topic'];
1685
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1686
+							$topics[] = $row['id_topic'];
1687
+			}
1627 1688
 
1628 1689
 			// Just return if we don't have any topics left to move.
1629 1690
 			if (empty($topics))
@@ -1714,9 +1775,9 @@  discard block
 block discarded – undo
1714 1775
 		// save it so we don't do this again for this task
1715 1776
 		list ($_SESSION['total_members']) = $smcFunc['db_fetch_row']($request);
1716 1777
 		$smcFunc['db_free_result']($request);
1778
+	} else {
1779
+			validateToken('admin-recountposts');
1717 1780
 	}
1718
-	else
1719
-		validateToken('admin-recountposts');
1720 1781
 
1721 1782
 	// Lets get a group of members and determine their post count (from the boards that have post count enabled of course).
1722 1783
 	$request = $smcFunc['db_query']('', '
@@ -1762,8 +1823,9 @@  discard block
 block discarded – undo
1762 1823
 		createToken('admin-recountposts');
1763 1824
 		$context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-recountposts_token_var'] . '" value="' . $context['admin-recountposts_token'] . '">';
1764 1825
 
1765
-		if (function_exists('apache_reset_timeout'))
1766
-			apache_reset_timeout();
1826
+		if (function_exists('apache_reset_timeout')) {
1827
+					apache_reset_timeout();
1828
+		}
1767 1829
 		return;
1768 1830
 	}
1769 1831
 
@@ -1849,10 +1911,9 @@  discard block
 block discarded – undo
1849 1911
 		checkSession('request');
1850 1912
 		validateToken('admin-hook', 'request');
1851 1913
 
1852
-		if ($_REQUEST['do'] == 'remove')
1853
-			remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function']));
1854
-
1855
-		else
1914
+		if ($_REQUEST['do'] == 'remove') {
1915
+					remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function']));
1916
+		} else
1856 1917
 		{
1857 1918
 			$function_remove = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '' : '!');
1858 1919
 			$function_add = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '!' : '');
@@ -1902,11 +1963,11 @@  discard block
 block discarded – undo
1902 1963
 						// Show a nice icon to indicate this is an instance.
1903 1964
 						$instance = (!empty($data['instance']) ? '<span class="generic_icons news" title="' . $txt['hooks_field_function_method'] . '"></span> ' : '');
1904 1965
 
1905
-						if (!empty($data['included_file']))
1906
-							return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file'];
1907
-
1908
-						else
1909
-							return $instance . $data['real_function'];
1966
+						if (!empty($data['included_file'])) {
1967
+													return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file'];
1968
+						} else {
1969
+													return $instance . $data['real_function'];
1970
+						}
1910 1971
 					},
1911 1972
 				),
1912 1973
 				'sort' =>  array(
@@ -1971,11 +2032,12 @@  discard block
 block discarded – undo
1971 2032
 		'data' => array(
1972 2033
 			'function' => function($data) use ($txt, $scripturl, $context)
1973 2034
 			{
1974
-				if (!$data['hook_exists'])
1975
-					return '
2035
+				if (!$data['hook_exists']) {
2036
+									return '
1976 2037
 					<a href="' . $scripturl . '?action=admin;area=maintain;sa=hooks;do=remove;hook=' . $data['hook_name'] . ';function=' . urlencode($data['function_name']) . $context['filter_url'] . ';' . $context['admin-hook_token_var'] . '=' . $context['admin-hook_token'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" data-confirm="' . $txt['quickmod_confirm'] . '" class="you_sure">
1977 2038
 						<span class="generic_icons delete" title="' . $txt['hooks_button_remove'] . '"></span>
1978 2039
 					</a>';
2040
+				}
1979 2041
 			},
1980 2042
 			'class' => 'centertext',
1981 2043
 		),
@@ -2010,10 +2072,11 @@  discard block
 block discarded – undo
2010 2072
 		{
2011 2073
 			if ($file != '.' && $file != '..')
2012 2074
 			{
2013
-				if (is_dir($dir_path . '/' . $file))
2014
-					$files = array_merge($files, get_files_recursive($dir_path . '/' . $file));
2015
-				else
2016
-					$files[] = array('dir' => $dir_path, 'name' => $file);
2075
+				if (is_dir($dir_path . '/' . $file)) {
2076
+									$files = array_merge($files, get_files_recursive($dir_path . '/' . $file));
2077
+				} else {
2078
+									$files[] = array('dir' => $dir_path, 'name' => $file);
2079
+				}
2017 2080
 			}
2018 2081
 		}
2019 2082
 	}
@@ -2062,16 +2125,16 @@  discard block
 block discarded – undo
2062 2125
 							// I need to know if there is at least one function called in this file.
2063 2126
 							$temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']);
2064 2127
 							unset($temp_hooks[$hook][$rawFunc]);
2065
-						}
2066
-						elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false)
2128
+						} elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false)
2067 2129
 						{
2068 2130
 							$hook_status[$hook][$hookParsedData['pureFunc']] = $hookParsedData;
2069 2131
 							$hook_status[$hook][$hookParsedData['pureFunc']]['exists'] = true;
2070 2132
 							$hook_status[$hook][$hookParsedData['pureFunc']]['in_file'] = (!empty($file['name']) ? $file['name'] : (!empty($hookParsedData['hookFile']) ? $hookParsedData['hookFile'] : ''));
2071 2133
 
2072 2134
 							// Does the hook has its own file?
2073
-							if (!empty($hookParsedData['hookFile']))
2074
-								$temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']);
2135
+							if (!empty($hookParsedData['hookFile'])) {
2136
+															$temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']);
2137
+							}
2075 2138
 
2076 2139
 							// I want to remember all the functions called within this file (to check later if they are enabled or disabled and decide if the integrare_*_include of that file can be disabled too)
2077 2140
 							$temp_data['function'][$file['name']][$hookParsedData['pureFunc']] = $hookParsedData['enabled'];
@@ -2098,15 +2161,17 @@  discard block
 block discarded – undo
2098 2161
 	$sort = array();
2099 2162
 	$hooks_filters = array();
2100 2163
 
2101
-	foreach ($hooks as $hook => $functions)
2102
-		$hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>';
2164
+	foreach ($hooks as $hook => $functions) {
2165
+			$hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>';
2166
+	}
2103 2167
 
2104
-	if (!empty($hooks_filters))
2105
-		$context['insert_after_template'] .= '
2168
+	if (!empty($hooks_filters)) {
2169
+			$context['insert_after_template'] .= '
2106 2170
 		<script>
2107 2171
 			var hook_name_header = document.getElementById(\'header_list_integration_hooks_hook_name\');
2108 2172
 			hook_name_header.innerHTML += ' . JavaScriptEscape('<select style="margin-left:15px;" onchange="window.location=(\'' . $scripturl . '?action=admin;area=maintain;sa=hooks\' + (this.value ? \';filter=\' + this.value : \'\'));"><option value="">' . $txt['hooks_reset_filter'] . '</option>' . implode('', $hooks_filters) . '</select>') . ';
2109 2173
 		</script>';
2174
+	}
2110 2175
 
2111 2176
 	$temp_data = array();
2112 2177
 	$id = 0;
@@ -2148,10 +2213,11 @@  discard block
 block discarded – undo
2148 2213
 
2149 2214
 	foreach ($temp_data as $data)
2150 2215
 	{
2151
-		if (++$counter < $start)
2152
-			continue;
2153
-		elseif ($counter == $start + $per_page)
2154
-			break;
2216
+		if (++$counter < $start) {
2217
+					continue;
2218
+		} elseif ($counter == $start + $per_page) {
2219
+					break;
2220
+		}
2155 2221
 
2156 2222
 		$hooks_data[] = $data;
2157 2223
 	}
@@ -2173,13 +2239,15 @@  discard block
 block discarded – undo
2173 2239
 	$hooks_count = 0;
2174 2240
 
2175 2241
 	$context['filter'] = false;
2176
-	if (isset($_GET['filter']))
2177
-		$context['filter'] = $_GET['filter'];
2242
+	if (isset($_GET['filter'])) {
2243
+			$context['filter'] = $_GET['filter'];
2244
+	}
2178 2245
 
2179 2246
 	foreach ($hooks as $hook => $functions)
2180 2247
 	{
2181
-		if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook))
2182
-			$hooks_count += count($functions);
2248
+		if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) {
2249
+					$hooks_count += count($functions);
2250
+		}
2183 2251
 	}
2184 2252
 
2185 2253
 	return $hooks_count;
@@ -2200,8 +2268,9 @@  discard block
 block discarded – undo
2200 2268
 		$integration_hooks = array();
2201 2269
 		foreach ($modSettings as $key => $value)
2202 2270
 		{
2203
-			if (!empty($value) && substr($key, 0, 10) === 'integrate_')
2204
-				$integration_hooks[$key] = explode(',', $value);
2271
+			if (!empty($value) && substr($key, 0, 10) === 'integrate_') {
2272
+							$integration_hooks[$key] = explode(',', $value);
2273
+			}
2205 2274
 		}
2206 2275
 	}
2207 2276
 
@@ -2232,8 +2301,9 @@  discard block
 block discarded – undo
2232 2301
 	);
2233 2302
 
2234 2303
 	// Meh...
2235
-	if (empty($rawData))
2236
-		return $hookData;
2304
+	if (empty($rawData)) {
2305
+			return $hookData;
2306
+	}
2237 2307
 
2238 2308
 	// For convenience purposes only!
2239 2309
 	$modFunc = $rawData;
@@ -2244,11 +2314,11 @@  discard block
 block discarded – undo
2244 2314
 		list ($hookData['hookFile'], $modFunc) = explode('|', $modFunc);
2245 2315
 
2246 2316
 		// Does the file exists? who knows!
2247
-		if (empty($settings['theme_dir']))
2248
-			$hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
2249
-
2250
-		else
2251
-			$hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
2317
+		if (empty($settings['theme_dir'])) {
2318
+					$hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
2319
+		} else {
2320
+					$hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
2321
+		}
2252 2322
 
2253 2323
 		$hookData['fileExists'] = file_exists($hookData['absPath']);
2254 2324
 		$hookData['hookFile'] = basename($hookData['hookFile']);
@@ -2273,11 +2343,10 @@  discard block
 block discarded – undo
2273 2343
 	{
2274 2344
 		list ($hookData['class'], $hookData['method']) = explode('::', $modFunc);
2275 2345
 		$hookData['pureFunc'] = $hookData['method'];
2346
+	} else {
2347
+			$hookData['pureFunc'] = $modFunc;
2276 2348
 	}
2277 2349
 
2278
-	else
2279
-		$hookData['pureFunc'] = $modFunc;
2280
-
2281 2350
 	return $hookData;
2282 2351
 }
2283 2352
 
Please login to merge, or discard this patch.
SSI.php 1 patch
Braces   +426 added lines, -304 removed lines patch added patch discarded remove patch
@@ -12,8 +12,9 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Don't do anything if SMF is already loaded.
15
-if (defined('SMF'))
15
+if (defined('SMF')) {
16 16
 	return true;
17
+}
17 18
 
18 19
 define('SMF', 'SSI');
19 20
 
@@ -28,16 +29,18 @@  discard block
 block discarded – undo
28 29
 $time_start = microtime(true);
29 30
 
30 31
 // Just being safe...
31
-foreach (array('db_character_set', 'cachedir') as $variable)
32
+foreach (array('db_character_set', 'cachedir') as $variable) {
32 33
 	if (isset($GLOBALS[$variable]))
33 34
 		unset($GLOBALS[$variable]);
35
+}
34 36
 
35 37
 // Get the forum's settings for database and file paths.
36 38
 require_once(dirname(__FILE__) . '/Settings.php');
37 39
 
38 40
 // Make absolutely sure the cache directory is defined.
39
-if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache'))
41
+if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) {
40 42
 	$cachedir = $boarddir . '/cache';
43
+}
41 44
 
42 45
 $ssi_error_reporting = error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL);
43 46
 /* Set this to one of three values depending on what you want to happen in the case of a fatal error.
@@ -48,12 +51,14 @@  discard block
 block discarded – undo
48 51
 $ssi_on_error_method = false;
49 52
 
50 53
 // Don't do john didley if the forum's been shut down completely.
51
-if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true))
54
+if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) {
52 55
 	die($mmessage);
56
+}
53 57
 
54 58
 // Fix for using the current directory as a path.
55
-if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.')
59
+if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') {
56 60
 	$sourcedir = dirname(__FILE__) . substr($sourcedir, 1);
61
+}
57 62
 
58 63
 // Load the important includes.
59 64
 require_once($sourcedir . '/QueryString.php');
@@ -78,34 +83,38 @@  discard block
 block discarded – undo
78 83
 cleanRequest();
79 84
 
80 85
 // Seed the random generator?
81
-if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69)
86
+if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) {
82 87
 	smf_seed_generator();
88
+}
83 89
 
84 90
 // Check on any hacking attempts.
85
-if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS']))
91
+if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) {
86 92
 	die('No direct access...');
87
-elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme)
93
+} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) {
88 94
 	die('No direct access...');
89
-elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme)
95
+} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) {
90 96
 	die('No direct access...');
91
-elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers)
97
+} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) {
92 98
 	die('No direct access...');
93
-if (isset($_REQUEST['context']))
99
+}
100
+if (isset($_REQUEST['context'])) {
94 101
 	die('No direct access...');
102
+}
95 103
 
96 104
 // Gzip output? (because it must be boolean and true, this can't be hacked.)
97
-if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>='))
105
+if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) {
98 106
 	ob_start('ob_gzhandler');
99
-else
107
+} else {
100 108
 	$modSettings['enableCompressedOutput'] = '0';
109
+}
101 110
 
102 111
 // Primarily, this is to fix the URLs...
103 112
 ob_start('ob_sessrewrite');
104 113
 
105 114
 // Start the session... known to scramble SSI includes in cases...
106
-if (!headers_sent())
115
+if (!headers_sent()) {
107 116
 	loadSession();
108
-else
117
+} else
109 118
 {
110 119
 	if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()]))
111 120
 	{
@@ -139,12 +148,14 @@  discard block
 block discarded – undo
139 148
 loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0);
140 149
 
141 150
 // @todo: probably not the best place, but somewhere it should be set...
142
-if (!headers_sent())
151
+if (!headers_sent()) {
143 152
 	header('Content-Type: text/html; charset=' . (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set']));
153
+}
144 154
 
145 155
 // Take care of any banning that needs to be done.
146
-if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true))
156
+if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) {
147 157
 	is_not_banned();
158
+}
148 159
 
149 160
 // Do we allow guests in here?
150 161
 if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php')
@@ -159,17 +170,19 @@  discard block
 block discarded – undo
159 170
 {
160 171
 	$context['template_layers'] = $ssi_layers;
161 172
 	template_header();
162
-}
163
-else
173
+} else {
164 174
 	setupThemeContext();
175
+}
165 176
 
166 177
 // Make sure they didn't muss around with the settings... but only if it's not cli.
167
-if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '')
178
+if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') {
168 179
 	trigger_error($txt['ssi_session_broken'], E_USER_NOTICE);
180
+}
169 181
 
170 182
 // Without visiting the forum this session variable might not be set on submit.
171
-if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote'))
183
+if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) {
172 184
 	$_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];
185
+}
173 186
 
174 187
 // Have the ability to easily add functions to SSI.
175 188
 call_integration_hook('integrate_SSI');
@@ -178,11 +191,13 @@  discard block
 block discarded – undo
178 191
 if (basename($_SERVER['PHP_SELF']) == 'SSI.php')
179 192
 {
180 193
 	// You shouldn't just access SSI.php directly by URL!!
181
-	if (!isset($_GET['ssi_function']))
182
-		die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\''));
194
+	if (!isset($_GET['ssi_function'])) {
195
+			die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\''));
196
+	}
183 197
 	// Call a function passed by GET.
184
-	if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest']))
185
-		call_user_func('ssi_' . $_GET['ssi_function']);
198
+	if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) {
199
+			call_user_func('ssi_' . $_GET['ssi_function']);
200
+	}
186 201
 	exit;
187 202
 }
188 203
 
@@ -199,9 +214,10 @@  discard block
 block discarded – undo
199 214
  */
200 215
 function ssi_shutdown()
201 216
 {
202
-	if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown')
203
-		template_footer();
204
-}
217
+	if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') {
218
+			template_footer();
219
+	}
220
+	}
205 221
 
206 222
 /**
207 223
  * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new.
@@ -214,15 +230,17 @@  discard block
 block discarded – undo
214 230
 
215 231
 	if ($output_method == 'echo')
216 232
 	{
217
-		if ($context['user']['is_guest'])
218
-			echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup');
219
-		else
220
-			echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : '';
233
+		if ($context['user']['is_guest']) {
234
+					echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup');
235
+		} else {
236
+					echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : '';
237
+		}
221 238
 	}
222 239
 	// Don't echo... then do what?!
223
-	else
224
-		return $context['user'];
225
-}
240
+	else {
241
+			return $context['user'];
242
+	}
243
+	}
226 244
 
227 245
 /**
228 246
  * Display a menu bar, like is displayed at the top of the forum.
@@ -233,12 +251,14 @@  discard block
 block discarded – undo
233 251
 {
234 252
 	global $context;
235 253
 
236
-	if ($output_method == 'echo')
237
-		template_menu();
254
+	if ($output_method == 'echo') {
255
+			template_menu();
256
+	}
238 257
 	// What else could this do?
239
-	else
240
-		return $context['menu_buttons'];
241
-}
258
+	else {
259
+			return $context['menu_buttons'];
260
+	}
261
+	}
242 262
 
243 263
 /**
244 264
  * Show a logout link.
@@ -250,20 +270,23 @@  discard block
 block discarded – undo
250 270
 {
251 271
 	global $context, $txt, $scripturl;
252 272
 
253
-	if ($redirect_to != '')
254
-		$_SESSION['logout_url'] = $redirect_to;
273
+	if ($redirect_to != '') {
274
+			$_SESSION['logout_url'] = $redirect_to;
275
+	}
255 276
 
256 277
 	// Guests can't log out.
257
-	if ($context['user']['is_guest'])
258
-		return false;
278
+	if ($context['user']['is_guest']) {
279
+			return false;
280
+	}
259 281
 
260 282
 	$link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>';
261 283
 
262
-	if ($output_method == 'echo')
263
-		echo $link;
264
-	else
265
-		return $link;
266
-}
284
+	if ($output_method == 'echo') {
285
+			echo $link;
286
+	} else {
287
+			return $link;
288
+	}
289
+	}
267 290
 
268 291
 /**
269 292
  * Recent post list:   [board] Subject by Poster    Date
@@ -279,17 +302,17 @@  discard block
 block discarded – undo
279 302
 	global $modSettings, $context;
280 303
 
281 304
 	// Excluding certain boards...
282
-	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
283
-		$exclude_boards = array($modSettings['recycle_board']);
284
-	else
285
-		$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
305
+	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) {
306
+			$exclude_boards = array($modSettings['recycle_board']);
307
+	} else {
308
+			$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
309
+	}
286 310
 
287 311
 	// What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter.
288 312
 	if (is_array($include_boards) || (int) $include_boards === $include_boards)
289 313
 	{
290 314
 		$include_boards = is_array($include_boards) ? $include_boards : array($include_boards);
291
-	}
292
-	elseif ($include_boards != null)
315
+	} elseif ($include_boards != null)
293 316
 	{
294 317
 		$include_boards = array();
295 318
 	}
@@ -326,8 +349,9 @@  discard block
 block discarded – undo
326 349
 {
327 350
 	global $modSettings;
328 351
 
329
-	if (empty($post_ids))
330
-		return;
352
+	if (empty($post_ids)) {
353
+			return;
354
+	}
331 355
 
332 356
 	// Allow the user to request more than one - why not?
333 357
 	$post_ids = is_array($post_ids) ? $post_ids : array($post_ids);
@@ -362,8 +386,9 @@  discard block
 block discarded – undo
362 386
 	global $scripturl, $txt, $user_info;
363 387
 	global $modSettings, $smcFunc, $context;
364 388
 
365
-	if (!empty($modSettings['enable_likes']))
366
-		$context['can_like'] = allowedTo('likes_like');
389
+	if (!empty($modSettings['enable_likes'])) {
390
+			$context['can_like'] = allowedTo('likes_like');
391
+	}
367 392
 
368 393
 	// Find all the posts. Newer ones will have higher IDs.
369 394
 	$request = $smcFunc['db_query']('substring', '
@@ -429,12 +454,13 @@  discard block
 block discarded – undo
429 454
 		);
430 455
 
431 456
 		// Get the likes for each message.
432
-		if (!empty($modSettings['enable_likes']))
433
-			$posts[$row['id_msg']]['likes'] = array(
457
+		if (!empty($modSettings['enable_likes'])) {
458
+					$posts[$row['id_msg']]['likes'] = array(
434 459
 				'count' => $row['likes'],
435 460
 				'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])),
436 461
 				'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']),
437 462
 			);
463
+		}
438 464
 	}
439 465
 	$smcFunc['db_free_result']($request);
440 466
 
@@ -442,13 +468,14 @@  discard block
 block discarded – undo
442 468
 	call_integration_hook('integrate_ssi_queryPosts', array(&$posts));
443 469
 
444 470
 	// Just return it.
445
-	if ($output_method != 'echo' || empty($posts))
446
-		return $posts;
471
+	if ($output_method != 'echo' || empty($posts)) {
472
+			return $posts;
473
+	}
447 474
 
448 475
 	echo '
449 476
 		<table style="border: none" class="ssi_table">';
450
-	foreach ($posts as $post)
451
-		echo '
477
+	foreach ($posts as $post) {
478
+			echo '
452 479
 			<tr>
453 480
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
454 481
 					[', $post['board']['link'], ']
@@ -462,6 +489,7 @@  discard block
 block discarded – undo
462 489
 					', $post['time'], '
463 490
 				</td>
464 491
 			</tr>';
492
+	}
465 493
 	echo '
466 494
 		</table>';
467 495
 }
@@ -479,25 +507,26 @@  discard block
 block discarded – undo
479 507
 	global $settings, $scripturl, $txt, $user_info;
480 508
 	global $modSettings, $smcFunc, $context;
481 509
 
482
-	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
483
-		$exclude_boards = array($modSettings['recycle_board']);
484
-	else
485
-		$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
510
+	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) {
511
+			$exclude_boards = array($modSettings['recycle_board']);
512
+	} else {
513
+			$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
514
+	}
486 515
 
487 516
 	// Only some boards?.
488 517
 	if (is_array($include_boards) || (int) $include_boards === $include_boards)
489 518
 	{
490 519
 		$include_boards = is_array($include_boards) ? $include_boards : array($include_boards);
491
-	}
492
-	elseif ($include_boards != null)
520
+	} elseif ($include_boards != null)
493 521
 	{
494 522
 		$output_method = $include_boards;
495 523
 		$include_boards = array();
496 524
 	}
497 525
 
498 526
 	$icon_sources = array();
499
-	foreach ($context['stable_icons'] as $icon)
500
-		$icon_sources[$icon] = 'images_url';
527
+	foreach ($context['stable_icons'] as $icon) {
528
+			$icon_sources[$icon] = 'images_url';
529
+	}
501 530
 
502 531
 	// Find all the posts in distinct topics.  Newer ones will have higher IDs.
503 532
 	$request = $smcFunc['db_query']('substring', '
@@ -522,13 +551,15 @@  discard block
 block discarded – undo
522 551
 		)
523 552
 	);
524 553
 	$topics = array();
525
-	while ($row = $smcFunc['db_fetch_assoc']($request))
526
-		$topics[$row['id_topic']] = $row;
554
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
555
+			$topics[$row['id_topic']] = $row;
556
+	}
527 557
 	$smcFunc['db_free_result']($request);
528 558
 
529 559
 	// Did we find anything? If not, bail.
530
-	if (empty($topics))
531
-		return array();
560
+	if (empty($topics)) {
561
+			return array();
562
+	}
532 563
 
533 564
 	$recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0;
534 565
 
@@ -556,19 +587,22 @@  discard block
 block discarded – undo
556 587
 	while ($row = $smcFunc['db_fetch_assoc']($request))
557 588
 	{
558 589
 		$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => '&#10;')));
559
-		if ($smcFunc['strlen']($row['body']) > 128)
560
-			$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
590
+		if ($smcFunc['strlen']($row['body']) > 128) {
591
+					$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
592
+		}
561 593
 
562 594
 		// Censor the subject.
563 595
 		censorText($row['subject']);
564 596
 		censorText($row['body']);
565 597
 
566 598
 		// Recycled icon
567
-		if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board'])
568
-			$row['icon'] = 'recycled';
599
+		if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) {
600
+					$row['icon'] = 'recycled';
601
+		}
569 602
 
570
-		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']]))
571
-			$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
603
+		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) {
604
+					$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
605
+		}
572 606
 
573 607
 		// Build the array.
574 608
 		$posts[] = array(
@@ -607,13 +641,14 @@  discard block
 block discarded – undo
607 641
 	call_integration_hook('integrate_ssi_recentTopics', array(&$posts));
608 642
 
609 643
 	// Just return it.
610
-	if ($output_method != 'echo' || empty($posts))
611
-		return $posts;
644
+	if ($output_method != 'echo' || empty($posts)) {
645
+			return $posts;
646
+	}
612 647
 
613 648
 	echo '
614 649
 		<table style="border: none" class="ssi_table">';
615
-	foreach ($posts as $post)
616
-		echo '
650
+	foreach ($posts as $post) {
651
+			echo '
617 652
 			<tr>
618 653
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
619 654
 					[', $post['board']['link'], ']
@@ -627,6 +662,7 @@  discard block
 block discarded – undo
627 662
 					', $post['time'], '
628 663
 				</td>
629 664
 			</tr>';
665
+	}
630 666
 	echo '
631 667
 		</table>';
632 668
 }
@@ -651,27 +687,30 @@  discard block
 block discarded – undo
651 687
 		)
652 688
 	);
653 689
 	$return = array();
654
-	while ($row = $smcFunc['db_fetch_assoc']($request))
655
-		$return[] = array(
690
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
691
+			$return[] = array(
656 692
 			'id' => $row['id_member'],
657 693
 			'name' => $row['real_name'],
658 694
 			'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
659 695
 			'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
660 696
 			'posts' => $row['posts']
661 697
 		);
698
+	}
662 699
 	$smcFunc['db_free_result']($request);
663 700
 
664 701
 	// If mods want to do somthing with this list of members, let them do that now.
665 702
 	call_integration_hook('integrate_ssi_topPoster', array(&$return));
666 703
 
667 704
 	// Just return all the top posters.
668
-	if ($output_method != 'echo')
669
-		return $return;
705
+	if ($output_method != 'echo') {
706
+			return $return;
707
+	}
670 708
 
671 709
 	// Make a quick array to list the links in.
672 710
 	$temp_array = array();
673
-	foreach ($return as $member)
674
-		$temp_array[] = $member['link'];
711
+	foreach ($return as $member) {
712
+			$temp_array[] = $member['link'];
713
+	}
675 714
 
676 715
 	echo implode(', ', $temp_array);
677 716
 }
@@ -703,8 +742,8 @@  discard block
 block discarded – undo
703 742
 		)
704 743
 	);
705 744
 	$boards = array();
706
-	while ($row = $smcFunc['db_fetch_assoc']($request))
707
-		$boards[] = array(
745
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
746
+			$boards[] = array(
708 747
 			'id' => $row['id_board'],
709 748
 			'num_posts' => $row['num_posts'],
710 749
 			'num_topics' => $row['num_topics'],
@@ -713,14 +752,16 @@  discard block
 block discarded – undo
713 752
 			'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
714 753
 			'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'
715 754
 		);
755
+	}
716 756
 	$smcFunc['db_free_result']($request);
717 757
 
718 758
 	// If mods want to do somthing with this list of boards, let them do that now.
719 759
 	call_integration_hook('integrate_ssi_topBoards', array(&$boards));
720 760
 
721 761
 	// If we shouldn't output or have nothing to output, just jump out.
722
-	if ($output_method != 'echo' || empty($boards))
723
-		return $boards;
762
+	if ($output_method != 'echo' || empty($boards)) {
763
+			return $boards;
764
+	}
724 765
 
725 766
 	echo '
726 767
 		<table class="ssi_table">
@@ -729,13 +770,14 @@  discard block
 block discarded – undo
729 770
 				<th style="text-align: left">', $txt['board_topics'], '</th>
730 771
 				<th style="text-align: left">', $txt['posts'], '</th>
731 772
 			</tr>';
732
-	foreach ($boards as $sBoard)
733
-		echo '
773
+	foreach ($boards as $sBoard) {
774
+			echo '
734 775
 			<tr>
735 776
 				<td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>' : '', '</td>
736 777
 				<td style="text-align: right">', comma_format($sBoard['num_topics']), '</td>
737 778
 				<td style="text-align: right">', comma_format($sBoard['num_posts']), '</td>
738 779
 			</tr>';
780
+	}
739 781
 	echo '
740 782
 		</table>';
741 783
 }
@@ -768,12 +810,13 @@  discard block
 block discarded – undo
768 810
 			)
769 811
 		);
770 812
 		$topic_ids = array();
771
-		while ($row = $smcFunc['db_fetch_assoc']($request))
772
-			$topic_ids[] = $row['id_topic'];
813
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
814
+					$topic_ids[] = $row['id_topic'];
815
+		}
773 816
 		$smcFunc['db_free_result']($request);
817
+	} else {
818
+			$topic_ids = array();
774 819
 	}
775
-	else
776
-		$topic_ids = array();
777 820
 
778 821
 	$request = $smcFunc['db_query']('', '
779 822
 		SELECT m.subject, m.id_topic, t.num_views, t.num_replies
@@ -812,8 +855,9 @@  discard block
 block discarded – undo
812 855
 	// If mods want to do somthing with this list of topics, let them do that now.
813 856
 	call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type));
814 857
 
815
-	if ($output_method != 'echo' || empty($topics))
816
-		return $topics;
858
+	if ($output_method != 'echo' || empty($topics)) {
859
+			return $topics;
860
+	}
817 861
 
818 862
 	echo '
819 863
 		<table class="ssi_table">
@@ -822,8 +866,8 @@  discard block
 block discarded – undo
822 866
 				<th style="text-align: left">', $txt['views'], '</th>
823 867
 				<th style="text-align: left">', $txt['replies'], '</th>
824 868
 			</tr>';
825
-	foreach ($topics as $sTopic)
826
-		echo '
869
+	foreach ($topics as $sTopic) {
870
+			echo '
827 871
 			<tr>
828 872
 				<td style="text-align: left">
829 873
 					', $sTopic['link'], '
@@ -831,6 +875,7 @@  discard block
 block discarded – undo
831 875
 				<td style="text-align: right">', comma_format($sTopic['num_views']), '</td>
832 876
 				<td style="text-align: right">', comma_format($sTopic['num_replies']), '</td>
833 877
 			</tr>';
878
+	}
834 879
 	echo '
835 880
 		</table>';
836 881
 }
@@ -866,12 +911,13 @@  discard block
 block discarded – undo
866 911
 {
867 912
 	global $txt, $context;
868 913
 
869
-	if ($output_method == 'echo')
870
-		echo '
914
+	if ($output_method == 'echo') {
915
+			echo '
871 916
 	', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>';
872
-	else
873
-		return $context['common_stats']['latest_member'];
874
-}
917
+	} else {
918
+			return $context['common_stats']['latest_member'];
919
+	}
920
+	}
875 921
 
876 922
 /**
877 923
  * Fetches a random member.
@@ -920,8 +966,9 @@  discard block
 block discarded – undo
920 966
 	}
921 967
 
922 968
 	// Just to be sure put the random generator back to something... random.
923
-	if ($random_type != '')
924
-		mt_srand(time());
969
+	if ($random_type != '') {
970
+			mt_srand(time());
971
+	}
925 972
 
926 973
 	return $result;
927 974
 }
@@ -934,8 +981,9 @@  discard block
 block discarded – undo
934 981
  */
935 982
 function ssi_fetchMember($member_ids = array(), $output_method = 'echo')
936 983
 {
937
-	if (empty($member_ids))
938
-		return;
984
+	if (empty($member_ids)) {
985
+			return;
986
+	}
939 987
 
940 988
 	// Can have more than one member if you really want...
941 989
 	$member_ids = is_array($member_ids) ? $member_ids : array($member_ids);
@@ -960,8 +1008,9 @@  discard block
 block discarded – undo
960 1008
  */
961 1009
 function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo')
962 1010
 {
963
-	if ($group_id === null)
964
-		return;
1011
+	if ($group_id === null) {
1012
+			return;
1013
+	}
965 1014
 
966 1015
 	$query_where = '
967 1016
 		id_group = {int:id_group}
@@ -988,8 +1037,9 @@  discard block
 block discarded – undo
988 1037
 {
989 1038
 	global $smcFunc, $memberContext;
990 1039
 
991
-	if ($query_where === null)
992
-		return;
1040
+	if ($query_where === null) {
1041
+			return;
1042
+	}
993 1043
 
994 1044
 	// Fetch the members in question.
995 1045
 	$request = $smcFunc['db_query']('', '
@@ -1002,12 +1052,14 @@  discard block
 block discarded – undo
1002 1052
 		))
1003 1053
 	);
1004 1054
 	$members = array();
1005
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1006
-		$members[] = $row['id_member'];
1055
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1056
+			$members[] = $row['id_member'];
1057
+	}
1007 1058
 	$smcFunc['db_free_result']($request);
1008 1059
 
1009
-	if (empty($members))
1010
-		return array();
1060
+	if (empty($members)) {
1061
+			return array();
1062
+	}
1011 1063
 
1012 1064
 	// If mods want to do somthing with this list of members, let them do that now.
1013 1065
 	call_integration_hook('integrate_ssi_queryMembers', array(&$members));
@@ -1016,23 +1068,25 @@  discard block
 block discarded – undo
1016 1068
 	loadMemberData($members);
1017 1069
 
1018 1070
 	// Draw the table!
1019
-	if ($output_method == 'echo')
1020
-		echo '
1071
+	if ($output_method == 'echo') {
1072
+			echo '
1021 1073
 		<table style="border: none" class="ssi_table">';
1074
+	}
1022 1075
 
1023 1076
 	$query_members = array();
1024 1077
 	foreach ($members as $member)
1025 1078
 	{
1026 1079
 		// Load their context data.
1027
-		if (!loadMemberContext($member))
1028
-			continue;
1080
+		if (!loadMemberContext($member)) {
1081
+					continue;
1082
+		}
1029 1083
 
1030 1084
 		// Store this member's information.
1031 1085
 		$query_members[$member] = $memberContext[$member];
1032 1086
 
1033 1087
 		// Only do something if we're echo'ing.
1034
-		if ($output_method == 'echo')
1035
-			echo '
1088
+		if ($output_method == 'echo') {
1089
+					echo '
1036 1090
 			<tr>
1037 1091
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
1038 1092
 					', $query_members[$member]['link'], '
@@ -1040,12 +1094,14 @@  discard block
 block discarded – undo
1040 1094
 					<br>', $query_members[$member]['avatar']['image'], '
1041 1095
 				</td>
1042 1096
 			</tr>';
1097
+		}
1043 1098
 	}
1044 1099
 
1045 1100
 	// End the table if appropriate.
1046
-	if ($output_method == 'echo')
1047
-		echo '
1101
+	if ($output_method == 'echo') {
1102
+			echo '
1048 1103
 		</table>';
1104
+	}
1049 1105
 
1050 1106
 	// Send back the data.
1051 1107
 	return $query_members;
@@ -1060,8 +1116,9 @@  discard block
 block discarded – undo
1060 1116
 {
1061 1117
 	global $txt, $scripturl, $modSettings, $smcFunc;
1062 1118
 
1063
-	if (!allowedTo('view_stats'))
1064
-		return;
1119
+	if (!allowedTo('view_stats')) {
1120
+			return;
1121
+	}
1065 1122
 
1066 1123
 	$totals = array(
1067 1124
 		'members' => $modSettings['totalMembers'],
@@ -1090,8 +1147,9 @@  discard block
 block discarded – undo
1090 1147
 	// If mods want to do somthing with the board stats, let them do that now.
1091 1148
 	call_integration_hook('integrate_ssi_boardStats', array(&$totals));
1092 1149
 
1093
-	if ($output_method != 'echo')
1094
-		return $totals;
1150
+	if ($output_method != 'echo') {
1151
+			return $totals;
1152
+	}
1095 1153
 
1096 1154
 	echo '
1097 1155
 		', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br>
@@ -1120,8 +1178,8 @@  discard block
 block discarded – undo
1120 1178
 	call_integration_hook('integrate_ssi_whosOnline', array(&$return));
1121 1179
 
1122 1180
 	// Add some redundancy for backwards compatibility reasons.
1123
-	if ($output_method != 'echo')
1124
-		return $return + array(
1181
+	if ($output_method != 'echo') {
1182
+			return $return + array(
1125 1183
 			'users' => $return['users_online'],
1126 1184
 			'guests' => $return['num_guests'],
1127 1185
 			'hidden' => $return['num_users_hidden'],
@@ -1129,29 +1187,35 @@  discard block
 block discarded – undo
1129 1187
 			'num_users' => $return['num_users_online'],
1130 1188
 			'total_users' => $return['num_users_online'] + $return['num_guests'],
1131 1189
 		);
1190
+	}
1132 1191
 
1133 1192
 	echo '
1134 1193
 		', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users'];
1135 1194
 
1136 1195
 	$bracketList = array();
1137
-	if (!empty($user_info['buddies']))
1138
-		$bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
1139
-	if (!empty($return['num_spiders']))
1140
-		$bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
1141
-	if (!empty($return['num_users_hidden']))
1142
-		$bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden'];
1196
+	if (!empty($user_info['buddies'])) {
1197
+			$bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
1198
+	}
1199
+	if (!empty($return['num_spiders'])) {
1200
+			$bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
1201
+	}
1202
+	if (!empty($return['num_users_hidden'])) {
1203
+			$bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden'];
1204
+	}
1143 1205
 
1144
-	if (!empty($bracketList))
1145
-		echo ' (' . implode(', ', $bracketList) . ')';
1206
+	if (!empty($bracketList)) {
1207
+			echo ' (' . implode(', ', $bracketList) . ')';
1208
+	}
1146 1209
 
1147 1210
 	echo '<br>
1148 1211
 			', implode(', ', $return['list_users_online']);
1149 1212
 
1150 1213
 	// Showing membergroups?
1151
-	if (!empty($settings['show_group_key']) && !empty($return['membergroups']))
1152
-		echo '<br>
1214
+	if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) {
1215
+			echo '<br>
1153 1216
 			[' . implode(']&nbsp;&nbsp;[', $return['membergroups']) . ']';
1154
-}
1217
+	}
1218
+	}
1155 1219
 
1156 1220
 /**
1157 1221
  * Just like whosOnline except it also logs the online presence.
@@ -1162,11 +1226,12 @@  discard block
 block discarded – undo
1162 1226
 {
1163 1227
 	writeLog();
1164 1228
 
1165
-	if ($output_method != 'echo')
1166
-		return ssi_whosOnline($output_method);
1167
-	else
1168
-		ssi_whosOnline($output_method);
1169
-}
1229
+	if ($output_method != 'echo') {
1230
+			return ssi_whosOnline($output_method);
1231
+	} else {
1232
+			ssi_whosOnline($output_method);
1233
+	}
1234
+	}
1170 1235
 
1171 1236
 // Shows a login box.
1172 1237
 /**
@@ -1179,11 +1244,13 @@  discard block
 block discarded – undo
1179 1244
 {
1180 1245
 	global $scripturl, $txt, $user_info, $context;
1181 1246
 
1182
-	if ($redirect_to != '')
1183
-		$_SESSION['login_url'] = $redirect_to;
1247
+	if ($redirect_to != '') {
1248
+			$_SESSION['login_url'] = $redirect_to;
1249
+	}
1184 1250
 
1185
-	if ($output_method != 'echo' || !$user_info['is_guest'])
1186
-		return $user_info['is_guest'];
1251
+	if ($output_method != 'echo' || !$user_info['is_guest']) {
1252
+			return $user_info['is_guest'];
1253
+	}
1187 1254
 
1188 1255
 	// Create a login token
1189 1256
 	createToken('login');
@@ -1235,8 +1302,9 @@  discard block
 block discarded – undo
1235 1302
 
1236 1303
 	$boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote'));
1237 1304
 
1238
-	if (empty($boardsAllowed))
1239
-		return array();
1305
+	if (empty($boardsAllowed)) {
1306
+			return array();
1307
+	}
1240 1308
 
1241 1309
 	$request = $smcFunc['db_query']('', '
1242 1310
 		SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time
@@ -1269,12 +1337,14 @@  discard block
 block discarded – undo
1269 1337
 	$smcFunc['db_free_result']($request);
1270 1338
 
1271 1339
 	// This user has voted on all the polls.
1272
-	if (empty($row) || !is_array($row))
1273
-		return array();
1340
+	if (empty($row) || !is_array($row)) {
1341
+			return array();
1342
+	}
1274 1343
 
1275 1344
 	// If this is a guest who's voted we'll through ourselves to show poll to show the results.
1276
-	if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote'])))))
1277
-		return ssi_showPoll($row['id_topic'], $output_method);
1345
+	if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) {
1346
+			return ssi_showPoll($row['id_topic'], $output_method);
1347
+	}
1278 1348
 
1279 1349
 	$request = $smcFunc['db_query']('', '
1280 1350
 		SELECT COUNT(DISTINCT id_member)
@@ -1338,8 +1408,9 @@  discard block
 block discarded – undo
1338 1408
 	// If mods want to do somthing with this list of polls, let them do that now.
1339 1409
 	call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead));
1340 1410
 
1341
-	if ($output_method != 'echo')
1342
-		return $return;
1411
+	if ($output_method != 'echo') {
1412
+			return $return;
1413
+	}
1343 1414
 
1344 1415
 	if ($allow_view_results)
1345 1416
 	{
@@ -1348,19 +1419,20 @@  discard block
 block discarded – undo
1348 1419
 			<strong>', $return['question'], '</strong><br>
1349 1420
 			', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : '';
1350 1421
 
1351
-		foreach ($return['options'] as $option)
1352
-			echo '
1422
+		foreach ($return['options'] as $option) {
1423
+					echo '
1353 1424
 			<label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>';
1425
+		}
1354 1426
 
1355 1427
 		echo '
1356 1428
 			<input type="submit" value="', $txt['poll_vote'], '" class="button">
1357 1429
 			<input type="hidden" name="poll" value="', $return['id'], '">
1358 1430
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1359 1431
 		</form>';
1432
+	} else {
1433
+			echo $txt['poll_cannot_see'];
1434
+	}
1360 1435
 	}
1361
-	else
1362
-		echo $txt['poll_cannot_see'];
1363
-}
1364 1436
 
1365 1437
 /**
1366 1438
  * Shows the poll from the specified topic
@@ -1374,13 +1446,15 @@  discard block
 block discarded – undo
1374 1446
 
1375 1447
 	$boardsAllowed = boardsAllowedTo('poll_view');
1376 1448
 
1377
-	if (empty($boardsAllowed))
1378
-		return array();
1449
+	if (empty($boardsAllowed)) {
1450
+			return array();
1451
+	}
1379 1452
 
1380
-	if ($topic === null && isset($_REQUEST['ssi_topic']))
1381
-		$topic = (int) $_REQUEST['ssi_topic'];
1382
-	else
1383
-		$topic = (int) $topic;
1453
+	if ($topic === null && isset($_REQUEST['ssi_topic'])) {
1454
+			$topic = (int) $_REQUEST['ssi_topic'];
1455
+	} else {
1456
+			$topic = (int) $topic;
1457
+	}
1384 1458
 
1385 1459
 	$request = $smcFunc['db_query']('', '
1386 1460
 		SELECT
@@ -1401,17 +1475,18 @@  discard block
 block discarded – undo
1401 1475
 	);
1402 1476
 
1403 1477
 	// Either this topic has no poll, or the user cannot view it.
1404
-	if ($smcFunc['db_num_rows']($request) == 0)
1405
-		return array();
1478
+	if ($smcFunc['db_num_rows']($request) == 0) {
1479
+			return array();
1480
+	}
1406 1481
 
1407 1482
 	$row = $smcFunc['db_fetch_assoc']($request);
1408 1483
 	$smcFunc['db_free_result']($request);
1409 1484
 
1410 1485
 	// Check if they can vote.
1411 1486
 	$already_voted = false;
1412
-	if (!empty($row['expire_time']) && $row['expire_time'] < time())
1413
-		$allow_vote = false;
1414
-	elseif ($user_info['is_guest'])
1487
+	if (!empty($row['expire_time']) && $row['expire_time'] < time()) {
1488
+			$allow_vote = false;
1489
+	} elseif ($user_info['is_guest'])
1415 1490
 	{
1416 1491
 		// There's a difference between "allowed to vote" and "already voted"...
1417 1492
 		$allow_vote = $row['guest_vote'];
@@ -1421,10 +1496,9 @@  discard block
 block discarded – undo
1421 1496
 		{
1422 1497
 			$already_voted = true;
1423 1498
 		}
1424
-	}
1425
-	elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board']))
1426
-		$allow_vote = false;
1427
-	else
1499
+	} elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) {
1500
+			$allow_vote = false;
1501
+	} else
1428 1502
 	{
1429 1503
 		$request = $smcFunc['db_query']('', '
1430 1504
 			SELECT id_member
@@ -1506,8 +1580,9 @@  discard block
 block discarded – undo
1506 1580
 	// If mods want to do somthing with this poll, let them do that now.
1507 1581
 	call_integration_hook('integrate_ssi_showPoll', array(&$return));
1508 1582
 
1509
-	if ($output_method != 'echo')
1510
-		return $return;
1583
+	if ($output_method != 'echo') {
1584
+			return $return;
1585
+	}
1511 1586
 
1512 1587
 	if ($return['allow_vote'])
1513 1588
 	{
@@ -1516,17 +1591,17 @@  discard block
 block discarded – undo
1516 1591
 				<strong>', $return['question'], '</strong><br>
1517 1592
 				', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : '';
1518 1593
 
1519
-		foreach ($return['options'] as $option)
1520
-			echo '
1594
+		foreach ($return['options'] as $option) {
1595
+					echo '
1521 1596
 				<label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>';
1597
+		}
1522 1598
 
1523 1599
 		echo '
1524 1600
 				<input type="submit" value="', $txt['poll_vote'], '" class="button">
1525 1601
 				<input type="hidden" name="poll" value="', $return['id'], '">
1526 1602
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1527 1603
 			</form>';
1528
-	}
1529
-	else
1604
+	} else
1530 1605
 	{
1531 1606
 		echo '
1532 1607
 			<div class="ssi_poll">
@@ -1606,27 +1681,32 @@  discard block
 block discarded – undo
1606 1681
 			'is_approved' => 1,
1607 1682
 		)
1608 1683
 	);
1609
-	if ($smcFunc['db_num_rows']($request) == 0)
1610
-		die;
1684
+	if ($smcFunc['db_num_rows']($request) == 0) {
1685
+			die;
1686
+	}
1611 1687
 	$row = $smcFunc['db_fetch_assoc']($request);
1612 1688
 	$smcFunc['db_free_result']($request);
1613 1689
 
1614
-	if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time']))
1615
-		redirectexit('topic=' . $row['id_topic'] . '.0');
1690
+	if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) {
1691
+			redirectexit('topic=' . $row['id_topic'] . '.0');
1692
+	}
1616 1693
 
1617 1694
 	// Too many options checked?
1618
-	if (count($_REQUEST['options']) > $row['max_votes'])
1619
-		redirectexit('topic=' . $row['id_topic'] . '.0');
1695
+	if (count($_REQUEST['options']) > $row['max_votes']) {
1696
+			redirectexit('topic=' . $row['id_topic'] . '.0');
1697
+	}
1620 1698
 
1621 1699
 	// It's a guest who has already voted?
1622 1700
 	if ($user_info['is_guest'])
1623 1701
 	{
1624 1702
 		// Guest voting disabled?
1625
-		if (!$row['guest_vote'])
1626
-			redirectexit('topic=' . $row['id_topic'] . '.0');
1703
+		if (!$row['guest_vote']) {
1704
+					redirectexit('topic=' . $row['id_topic'] . '.0');
1705
+		}
1627 1706
 		// Already voted?
1628
-		elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote'])))
1629
-			redirectexit('topic=' . $row['id_topic'] . '.0');
1707
+		elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) {
1708
+					redirectexit('topic=' . $row['id_topic'] . '.0');
1709
+		}
1630 1710
 	}
1631 1711
 
1632 1712
 	$sOptions = array();
@@ -1680,11 +1760,13 @@  discard block
 block discarded – undo
1680 1760
 {
1681 1761
 	global $scripturl, $txt, $context;
1682 1762
 
1683
-	if (!allowedTo('search_posts'))
1684
-		return;
1763
+	if (!allowedTo('search_posts')) {
1764
+			return;
1765
+	}
1685 1766
 
1686
-	if ($output_method != 'echo')
1687
-		return $scripturl . '?action=search';
1767
+	if ($output_method != 'echo') {
1768
+			return $scripturl . '?action=search';
1769
+	}
1688 1770
 
1689 1771
 	echo '
1690 1772
 		<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
@@ -1706,8 +1788,9 @@  discard block
 block discarded – undo
1706 1788
 	// If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in $context.
1707 1789
 	call_integration_hook('integrate_ssi_news');
1708 1790
 
1709
-	if ($output_method != 'echo')
1710
-		return $context['random_news_line'];
1791
+	if ($output_method != 'echo') {
1792
+			return $context['random_news_line'];
1793
+	}
1711 1794
 
1712 1795
 	echo $context['random_news_line'];
1713 1796
 }
@@ -1721,8 +1804,9 @@  discard block
 block discarded – undo
1721 1804
 {
1722 1805
 	global $scripturl, $modSettings, $user_info;
1723 1806
 
1724
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view'))
1725
-		return;
1807
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) {
1808
+			return;
1809
+	}
1726 1810
 
1727 1811
 	$eventOptions = array(
1728 1812
 		'include_birthdays' => true,
@@ -1733,13 +1817,15 @@  discard block
 block discarded – undo
1733 1817
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1734 1818
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1735 1819
 
1736
-	if ($output_method != 'echo')
1737
-		return $return['calendar_birthdays'];
1820
+	if ($output_method != 'echo') {
1821
+			return $return['calendar_birthdays'];
1822
+	}
1738 1823
 
1739
-	foreach ($return['calendar_birthdays'] as $member)
1740
-		echo '
1824
+	foreach ($return['calendar_birthdays'] as $member) {
1825
+			echo '
1741 1826
 			<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">' . $member['name'] . '</span>' . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? ', ' : '');
1742
-}
1827
+	}
1828
+	}
1743 1829
 
1744 1830
 /**
1745 1831
  * Shows today's holidays.
@@ -1750,8 +1836,9 @@  discard block
 block discarded – undo
1750 1836
 {
1751 1837
 	global $modSettings, $user_info;
1752 1838
 
1753
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1754
-		return;
1839
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1840
+			return;
1841
+	}
1755 1842
 
1756 1843
 	$eventOptions = array(
1757 1844
 		'include_holidays' => true,
@@ -1762,8 +1849,9 @@  discard block
 block discarded – undo
1762 1849
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1763 1850
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1764 1851
 
1765
-	if ($output_method != 'echo')
1766
-		return $return['calendar_holidays'];
1852
+	if ($output_method != 'echo') {
1853
+			return $return['calendar_holidays'];
1854
+	}
1767 1855
 
1768 1856
 	echo '
1769 1857
 		', implode(', ', $return['calendar_holidays']);
@@ -1777,8 +1865,9 @@  discard block
 block discarded – undo
1777 1865
 {
1778 1866
 	global $modSettings, $user_info;
1779 1867
 
1780
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1781
-		return;
1868
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1869
+			return;
1870
+	}
1782 1871
 
1783 1872
 	$eventOptions = array(
1784 1873
 		'include_events' => true,
@@ -1789,14 +1878,16 @@  discard block
 block discarded – undo
1789 1878
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1790 1879
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1791 1880
 
1792
-	if ($output_method != 'echo')
1793
-		return $return['calendar_events'];
1881
+	if ($output_method != 'echo') {
1882
+			return $return['calendar_events'];
1883
+	}
1794 1884
 
1795 1885
 	foreach ($return['calendar_events'] as $event)
1796 1886
 	{
1797
-		if ($event['can_edit'])
1798
-			echo '
1887
+		if ($event['can_edit']) {
1888
+					echo '
1799 1889
 	<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
1890
+		}
1800 1891
 		echo '
1801 1892
 	' . $event['link'] . (!$event['is_last'] ? ', ' : '');
1802 1893
 	}
@@ -1811,8 +1902,9 @@  discard block
 block discarded – undo
1811 1902
 {
1812 1903
 	global $modSettings, $txt, $scripturl, $user_info;
1813 1904
 
1814
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1815
-		return;
1905
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1906
+			return;
1907
+	}
1816 1908
 
1817 1909
 	$eventOptions = array(
1818 1910
 		'include_birthdays' => allowedTo('profile_view'),
@@ -1825,19 +1917,22 @@  discard block
 block discarded – undo
1825 1917
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1826 1918
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1827 1919
 
1828
-	if ($output_method != 'echo')
1829
-		return $return;
1920
+	if ($output_method != 'echo') {
1921
+			return $return;
1922
+	}
1830 1923
 
1831
-	if (!empty($return['calendar_holidays']))
1832
-		echo '
1924
+	if (!empty($return['calendar_holidays'])) {
1925
+			echo '
1833 1926
 			<span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>';
1927
+	}
1834 1928
 	if (!empty($return['calendar_birthdays']))
1835 1929
 	{
1836 1930
 		echo '
1837 1931
 			<span class="birthday">' . $txt['birthdays_upcoming'] . '</span> ';
1838
-		foreach ($return['calendar_birthdays'] as $member)
1839
-			echo '
1932
+		foreach ($return['calendar_birthdays'] as $member) {
1933
+					echo '
1840 1934
 			<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', !$member['is_last'] ? ', ' : '';
1935
+		}
1841 1936
 		echo '
1842 1937
 			<br>';
1843 1938
 	}
@@ -1847,9 +1942,10 @@  discard block
 block discarded – undo
1847 1942
 			<span class="event">' . $txt['events_upcoming'] . '</span> ';
1848 1943
 		foreach ($return['calendar_events'] as $event)
1849 1944
 		{
1850
-			if ($event['can_edit'])
1851
-				echo '
1945
+			if ($event['can_edit']) {
1946
+							echo '
1852 1947
 			<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
1948
+			}
1853 1949
 			echo '
1854 1950
 			' . $event['link'] . (!$event['is_last'] ? ', ' : '');
1855 1951
 		}
@@ -1873,25 +1969,29 @@  discard block
 block discarded – undo
1873 1969
 	loadLanguage('Stats');
1874 1970
 
1875 1971
 	// Must be integers....
1876
-	if ($limit === null)
1877
-		$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5;
1878
-	else
1879
-		$limit = (int) $limit;
1880
-
1881
-	if ($start === null)
1882
-		$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
1883
-	else
1884
-		$start = (int) $start;
1885
-
1886
-	if ($board !== null)
1887
-		$board = (int) $board;
1888
-	elseif (isset($_GET['board']))
1889
-		$board = (int) $_GET['board'];
1890
-
1891
-	if ($length === null)
1892
-		$length = isset($_GET['length']) ? (int) $_GET['length'] : 0;
1893
-	else
1894
-		$length = (int) $length;
1972
+	if ($limit === null) {
1973
+			$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5;
1974
+	} else {
1975
+			$limit = (int) $limit;
1976
+	}
1977
+
1978
+	if ($start === null) {
1979
+			$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
1980
+	} else {
1981
+			$start = (int) $start;
1982
+	}
1983
+
1984
+	if ($board !== null) {
1985
+			$board = (int) $board;
1986
+	} elseif (isset($_GET['board'])) {
1987
+			$board = (int) $_GET['board'];
1988
+	}
1989
+
1990
+	if ($length === null) {
1991
+			$length = isset($_GET['length']) ? (int) $_GET['length'] : 0;
1992
+	} else {
1993
+			$length = (int) $length;
1994
+	}
1895 1995
 
1896 1996
 	$limit = max(0, $limit);
1897 1997
 	$start = max(0, $start);
@@ -1909,17 +2009,19 @@  discard block
 block discarded – undo
1909 2009
 	);
1910 2010
 	if ($smcFunc['db_num_rows']($request) == 0)
1911 2011
 	{
1912
-		if ($output_method == 'echo')
1913
-			die($txt['ssi_no_guests']);
1914
-		else
1915
-			return array();
2012
+		if ($output_method == 'echo') {
2013
+					die($txt['ssi_no_guests']);
2014
+		} else {
2015
+					return array();
2016
+		}
1916 2017
 	}
1917 2018
 	list ($board) = $smcFunc['db_fetch_row']($request);
1918 2019
 	$smcFunc['db_free_result']($request);
1919 2020
 
1920 2021
 	$icon_sources = array();
1921
-	foreach ($context['stable_icons'] as $icon)
1922
-		$icon_sources[$icon] = 'images_url';
2022
+	foreach ($context['stable_icons'] as $icon) {
2023
+			$icon_sources[$icon] = 'images_url';
2024
+	}
1923 2025
 
1924 2026
 	if (!empty($modSettings['enable_likes']))
1925 2027
 	{
@@ -1942,12 +2044,14 @@  discard block
 block discarded – undo
1942 2044
 		)
1943 2045
 	);
1944 2046
 	$posts = array();
1945
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1946
-		$posts[] = $row['id_first_msg'];
2047
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2048
+			$posts[] = $row['id_first_msg'];
2049
+	}
1947 2050
 	$smcFunc['db_free_result']($request);
1948 2051
 
1949
-	if (empty($posts))
1950
-		return array();
2052
+	if (empty($posts)) {
2053
+			return array();
2054
+	}
1951 2055
 
1952 2056
 	// Find the posts.
1953 2057
 	$request = $smcFunc['db_query']('', '
@@ -1977,24 +2081,28 @@  discard block
 block discarded – undo
1977 2081
 			$last_space = strrpos($row['body'], ' ');
1978 2082
 			$last_open = strrpos($row['body'], '<');
1979 2083
 			$last_close = strrpos($row['body'], '>');
1980
-			if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6)
1981
-				$cutoff = $last_open;
1982
-			elseif (empty($last_close) || $last_close < $last_open)
1983
-				$cutoff = $last_space;
2084
+			if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) {
2085
+							$cutoff = $last_open;
2086
+			} elseif (empty($last_close) || $last_close < $last_open) {
2087
+							$cutoff = $last_space;
2088
+			}
1984 2089
 
1985
-			if ($cutoff !== false)
1986
-				$row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);
2090
+			if ($cutoff !== false) {
2091
+							$row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);
2092
+			}
1987 2093
 			$row['body'] .= '...';
1988 2094
 		}
1989 2095
 
1990 2096
 		$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
1991 2097
 
1992
-		if (!empty($recycle_board) && $row['id_board'] == $recycle_board)
1993
-			$row['icon'] = 'recycled';
2098
+		if (!empty($recycle_board) && $row['id_board'] == $recycle_board) {
2099
+					$row['icon'] = 'recycled';
2100
+		}
1994 2101
 
1995 2102
 		// Check that this message icon is there...
1996
-		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']]))
1997
-			$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
2103
+		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) {
2104
+					$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
2105
+		}
1998 2106
 
1999 2107
 		censorText($row['subject']);
2000 2108
 		censorText($row['body']);
@@ -2031,16 +2139,18 @@  discard block
 block discarded – undo
2031 2139
 	}
2032 2140
 	$smcFunc['db_free_result']($request);
2033 2141
 
2034
-	if (empty($return))
2035
-		return $return;
2142
+	if (empty($return)) {
2143
+			return $return;
2144
+	}
2036 2145
 
2037 2146
 	$return[count($return) - 1]['is_last'] = true;
2038 2147
 
2039 2148
 	// If mods want to do somthing with this list of posts, let them do that now.
2040 2149
 	call_integration_hook('integrate_ssi_boardNews', array(&$return));
2041 2150
 
2042
-	if ($output_method != 'echo')
2043
-		return $return;
2151
+	if ($output_method != 'echo') {
2152
+			return $return;
2153
+	}
2044 2154
 
2045 2155
 	foreach ($return as $news)
2046 2156
 	{
@@ -2092,9 +2202,10 @@  discard block
 block discarded – undo
2092 2202
 		echo '
2093 2203
 			</div>';
2094 2204
 
2095
-		if (!$news['is_last'])
2096
-			echo '
2205
+		if (!$news['is_last']) {
2206
+					echo '
2097 2207
 			<hr>';
2208
+		}
2098 2209
 	}
2099 2210
 }
2100 2211
 
@@ -2108,8 +2219,9 @@  discard block
 block discarded – undo
2108 2219
 {
2109 2220
 	global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc;
2110 2221
 
2111
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
2112
-		return;
2222
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
2223
+			return;
2224
+	}
2113 2225
 
2114 2226
 	// Find all events which are happening in the near future that the member can see.
2115 2227
 	$request = $smcFunc['db_query']('', '
@@ -2135,20 +2247,23 @@  discard block
 block discarded – undo
2135 2247
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2136 2248
 	{
2137 2249
 		// Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have.
2138
-		if (!empty($duplicates[$row['title'] . $row['id_topic']]))
2139
-			continue;
2250
+		if (!empty($duplicates[$row['title'] . $row['id_topic']])) {
2251
+					continue;
2252
+		}
2140 2253
 
2141 2254
 		// Censor the title.
2142 2255
 		censorText($row['title']);
2143 2256
 
2144
-		if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false)))
2145
-			$date = strftime('%Y-%m-%d', forum_time(false));
2146
-		else
2147
-			$date = $row['start_date'];
2257
+		if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) {
2258
+					$date = strftime('%Y-%m-%d', forum_time(false));
2259
+		} else {
2260
+					$date = $row['start_date'];
2261
+		}
2148 2262
 
2149 2263
 		// If the topic it is attached to is not approved then don't link it.
2150
-		if (!empty($row['id_first_msg']) && !$row['approved'])
2151
-			$row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0;
2264
+		if (!empty($row['id_first_msg']) && !$row['approved']) {
2265
+					$row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0;
2266
+		}
2152 2267
 
2153 2268
 		$allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false;
2154 2269
 
@@ -2174,24 +2289,27 @@  discard block
 block discarded – undo
2174 2289
 	}
2175 2290
 	$smcFunc['db_free_result']($request);
2176 2291
 
2177
-	foreach ($return as $mday => $array)
2178
-		$return[$mday][count($array) - 1]['is_last'] = true;
2292
+	foreach ($return as $mday => $array) {
2293
+			$return[$mday][count($array) - 1]['is_last'] = true;
2294
+	}
2179 2295
 
2180 2296
 	// If mods want to do somthing with this list of events, let them do that now.
2181 2297
 	call_integration_hook('integrate_ssi_recentEvents', array(&$return));
2182 2298
 
2183
-	if ($output_method != 'echo' || empty($return))
2184
-		return $return;
2299
+	if ($output_method != 'echo' || empty($return)) {
2300
+			return $return;
2301
+	}
2185 2302
 
2186 2303
 	// Well the output method is echo.
2187 2304
 	echo '
2188 2305
 			<span class="event">' . $txt['events'] . '</span> ';
2189
-	foreach ($return as $mday => $array)
2190
-		foreach ($array as $event)
2306
+	foreach ($return as $mday => $array) {
2307
+			foreach ($array as $event)
2191 2308
 		{
2192 2309
 			if ($event['can_edit'])
2193 2310
 				echo '
2194 2311
 				<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
2312
+	}
2195 2313
 
2196 2314
 			echo '
2197 2315
 				' . $event['link'] . (!$event['is_last'] ? ', ' : '');
@@ -2210,8 +2328,9 @@  discard block
 block discarded – undo
2210 2328
 	global $smcFunc;
2211 2329
 
2212 2330
 	// If $id is null, this was most likely called from a query string and should do nothing.
2213
-	if ($id === null)
2214
-		return;
2331
+	if ($id === null) {
2332
+			return;
2333
+	}
2215 2334
 
2216 2335
 	$request = $smcFunc['db_query']('', '
2217 2336
 		SELECT passwd, member_name, is_activated
@@ -2243,8 +2362,9 @@  discard block
 block discarded – undo
2243 2362
 	$attachments_boards = boardsAllowedTo('view_attachments');
2244 2363
 
2245 2364
 	// No boards?  Adios amigo.
2246
-	if (empty($attachments_boards))
2247
-		return array();
2365
+	if (empty($attachments_boards)) {
2366
+			return array();
2367
+	}
2248 2368
 
2249 2369
 	// Is it an array?
2250 2370
 	$attachment_ext = (array) $attachment_ext;
@@ -2328,8 +2448,9 @@  discard block
 block discarded – undo
2328 2448
 	call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments));
2329 2449
 
2330 2450
 	// So you just want an array?  Here you can have it.
2331
-	if ($output_method == 'array' || empty($attachments))
2332
-		return $attachments;
2451
+	if ($output_method == 'array' || empty($attachments)) {
2452
+			return $attachments;
2453
+	}
2333 2454
 
2334 2455
 	// Give them the default.
2335 2456
 	echo '
@@ -2340,14 +2461,15 @@  discard block
 block discarded – undo
2340 2461
 				<th style="text-align: left; padding: 2">', $txt['downloads'], '</th>
2341 2462
 				<th style="text-align: left; padding: 2">', $txt['filesize'], '</th>
2342 2463
 			</tr>';
2343
-	foreach ($attachments as $attach)
2344
-		echo '
2464
+	foreach ($attachments as $attach) {
2465
+			echo '
2345 2466
 			<tr>
2346 2467
 				<td>', $attach['file']['link'], '</td>
2347 2468
 				<td>', $attach['member']['link'], '</td>
2348 2469
 				<td style="text-align: center">', $attach['file']['downloads'], '</td>
2349 2470
 				<td>', $attach['file']['filesize'], '</td>
2350 2471
 			</tr>';
2472
+	}
2351 2473
 	echo '
2352 2474
 		</table>';
2353 2475
 }
Please login to merge, or discard this patch.