Completed
Pull Request — release-2.1 (#4892)
by Mathias
10:14
created
Sources/Profile-Actions.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1050,15 +1050,15 @@
 block discarded – undo
1050 1050
 }
1051 1051
 
1052 1052
 /**
1053
-  * Formats a line (passed as a fields  array) as CSV and returns the CSV as a string.
1054
-  * from https://stackoverflow.com/questions/3933668/convert-array-into-csv
1053
+ * Formats a line (passed as a fields  array) as CSV and returns the CSV as a string.
1054
+ * from https://stackoverflow.com/questions/3933668/convert-array-into-csv
1055 1055
  * 
1056 1056
  * @param array $fields a line of the array
1057 1057
  * @param string @delimiter the delimiter char
1058 1058
  * @param string @enclosure the enclosure char
1059 1059
  * @param boolean $encloseAll enclose all
1060 1060
  * @param boolean $nullToMysqlNull
1061
-  */
1061
+ */
1062 1062
 function arrayToCsv( array $fields, $delimiter = ';', $enclosure = '"', $encloseAll = false, $nullToMysqlNull = false ) {
1063 1063
 	$delimiter_esc = preg_quote($delimiter, '/');
1064 1064
 	$enclosure_esc = preg_quote($enclosure, '/');
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -992,12 +992,12 @@  discard block
 block discarded – undo
992 992
 	{
993 993
 		loadMemberData($memID, false, 'profile');
994 994
 		$profile = $user_profile[$memID];
995
-		$removeFields = array('secret_question','tfa_secret','password_salt');
995
+		$removeFields = array('secret_question', 'tfa_secret', 'password_salt');
996 996
 		foreach ($removeFields as $value)
997 997
 		{
998 998
 			unset($profile[$value]);
999 999
 		}
1000
-		foreach($profile as $key => &$value)
1000
+		foreach ($profile as $key => &$value)
1001 1001
 		{
1002 1002
 			if (is_array($value))
1003 1003
 				$value = $smcFunc['json_encode']($value);
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
 	elseif ($mode == 'messages') // messages
1010 1010
 	{
1011 1011
 		
1012
-		$request = $smcFunc['db_query']('','
1012
+		$request = $smcFunc['db_query']('', '
1013 1013
 			SELECT id_msg, id_topic, poster_time, subject, modified_time, modified_name, modified_reason, body, likes, poster_ip
1014 1014
 			FROM {db_prefix}messages 
1015 1015
 			WHERE id_member = {int:memID}',
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 	}
1028 1028
 	elseif ($mode == 'pmessages')
1029 1029
 	{
1030
-		$request = $smcFunc['db_query']('','
1030
+		$request = $smcFunc['db_query']('', '
1031 1031
 			SELECT pm.msgtime, pm.subject, pm.body
1032 1032
 			FROM {db_prefix}personal_messages pm
1033 1033
 			LEFT JOIN {db_prefix}pm_recipients pmr on (pm.id_pm = pmr.id_pm and pmr.id_member = {int:memID})
@@ -1045,14 +1045,14 @@  discard block
 block discarded – undo
1045 1045
 	}
1046 1046
 	$count = count($profileData);
1047 1047
 	$csv_data = '';
1048
-	for($i = 0; $i < $count; $i++)
1048
+	for ($i = 0; $i < $count; $i++)
1049 1049
 	{
1050 1050
 		$csv_data .= arrayToCsv($profileData[$i]) . "\r\n";
1051 1051
 	}
1052 1052
 
1053 1053
 
1054 1054
 	header("Pragma: no-cache");
1055
-	header('Content-Disposition: attachment; filename="privacySMF'.$mode.'.csv";');
1055
+	header('Content-Disposition: attachment; filename="privacySMF' . $mode . '.csv";');
1056 1056
 	header("Content-Length: " . strlen($csv_data));
1057 1057
 	header("Content-Transfer-Encoding: binary");
1058 1058
 	header("Content-Type: application/force-download");
@@ -1071,12 +1071,12 @@  discard block
 block discarded – undo
1071 1071
  * @param boolean $encloseAll enclose all
1072 1072
  * @param boolean $nullToMysqlNull
1073 1073
   */
1074
-function arrayToCsv( array $fields, $delimiter = ';', $enclosure = '"', $encloseAll = false, $nullToMysqlNull = false ) {
1074
+function arrayToCsv(array $fields, $delimiter = ';', $enclosure = '"', $encloseAll = false, $nullToMysqlNull = false) {
1075 1075
 	$delimiter_esc = preg_quote($delimiter, '/');
1076 1076
 	$enclosure_esc = preg_quote($enclosure, '/');
1077 1077
 
1078 1078
 	$output = array();
1079
-	foreach ( $fields as $field )
1079
+	foreach ($fields as $field)
1080 1080
 	{
1081 1081
 		if ($field === null && $nullToMysqlNull)
1082 1082
 		{
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
 		}
1086 1086
 
1087 1087
 		// Enclose fields containing $delimiter, $enclosure or whitespace
1088
-		if ( $encloseAll || preg_match( "/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field ) )
1088
+		if ($encloseAll || preg_match("/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field))
1089 1089
 		{
1090 1090
 			$output[] = $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field) . $enclosure;
1091 1091
 		}
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
 		}
1096 1096
 	}
1097 1097
 
1098
-	return implode( $delimiter, $output );
1098
+	return implode($delimiter, $output);
1099 1099
 }
1100 1100
 
1101 1101
 ?>
1102 1102
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +157 added lines, -114 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
  * Activate an account.
@@ -48,8 +49,9 @@  discard block
 block discarded – undo
48 49
 		logAction('approve_member', array('member' => $memID), 'admin');
49 50
 
50 51
 		// If we are doing approval, update the stats for the member just in case.
51
-		if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15)))
52
-			updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0)));
52
+		if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) {
53
+					updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0)));
54
+		}
53 55
 
54 56
 		// Make sure we update the stats too.
55 57
 		updateStats('member', false);
@@ -76,8 +78,9 @@  discard block
 block discarded – undo
76 78
 	$issueErrors = array();
77 79
 
78 80
 	// Doesn't hurt to be overly cautious.
79
-	if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning'))
80
-		fatal_lang_error('no_access', false);
81
+	if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) {
82
+			fatal_lang_error('no_access', false);
83
+	}
81 84
 
82 85
 	// Get the base (errors related) stuff done.
83 86
 	loadLanguage('Errors');
@@ -135,16 +138,18 @@  discard block
 block discarded – undo
135 138
 
136 139
 		// This cannot be empty!
137 140
 		$_POST['warn_reason'] = isset($_POST['warn_reason']) ? trim($_POST['warn_reason']) : '';
138
-		if ($_POST['warn_reason'] == '' && !$context['user']['is_owner'])
139
-			$issueErrors[] = 'warning_no_reason';
141
+		if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) {
142
+					$issueErrors[] = 'warning_no_reason';
143
+		}
140 144
 		$_POST['warn_reason'] = $smcFunc['htmlspecialchars']($_POST['warn_reason']);
141 145
 
142 146
 		$_POST['warning_level'] = (int) $_POST['warning_level'];
143 147
 		$_POST['warning_level'] = max(0, min(100, $_POST['warning_level']));
144
-		if ($_POST['warning_level'] < $context['min_allowed'])
145
-			$_POST['warning_level'] = $context['min_allowed'];
146
-		elseif ($_POST['warning_level'] > $context['max_allowed'])
147
-			$_POST['warning_level'] = $context['max_allowed'];
148
+		if ($_POST['warning_level'] < $context['min_allowed']) {
149
+					$_POST['warning_level'] = $context['min_allowed'];
150
+		} elseif ($_POST['warning_level'] > $context['max_allowed']) {
151
+					$_POST['warning_level'] = $context['max_allowed'];
152
+		}
148 153
 
149 154
 		// Do we actually have to issue them with a PM?
150 155
 		$id_notice = 0;
@@ -152,8 +157,9 @@  discard block
 block discarded – undo
152 157
 		{
153 158
 			$_POST['warn_sub'] = trim($_POST['warn_sub']);
154 159
 			$_POST['warn_body'] = trim($_POST['warn_body']);
155
-			if (empty($_POST['warn_sub']) || empty($_POST['warn_body']))
156
-				$issueErrors[] = 'warning_notify_blank';
160
+			if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) {
161
+							$issueErrors[] = 'warning_notify_blank';
162
+			}
157 163
 			// Send the PM?
158 164
 			else
159 165
 			{
@@ -190,8 +196,8 @@  discard block
 block discarded – undo
190 196
 		if (empty($issueErrors))
191 197
 		{
192 198
 			// Log what we've done!
193
-			if (!$context['user']['is_owner'])
194
-				$smcFunc['db_insert']('',
199
+			if (!$context['user']['is_owner']) {
200
+							$smcFunc['db_insert']('',
195 201
 					'{db_prefix}log_comments',
196 202
 					array(
197 203
 						'id_member' => 'int', 'member_name' => 'string', 'comment_type' => 'string', 'id_recipient' => 'int', 'recipient_name' => 'string-255',
@@ -203,14 +209,14 @@  discard block
 block discarded – undo
203 209
 					),
204 210
 					array('id_comment')
205 211
 				);
212
+			}
206 213
 
207 214
 			// Make the change.
208 215
 			updateMemberData($memID, array('warning' => $_POST['warning_level']));
209 216
 
210 217
 			// Leave a lovely message.
211 218
 			$context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : $txt['profile_warning_success'];
212
-		}
213
-		else
219
+		} else
214 220
 		{
215 221
 			// Try to remember some bits.
216 222
 			$context['warning_data'] = array(
@@ -229,8 +235,9 @@  discard block
 block discarded – undo
229 235
 	{
230 236
 		$warning_body = !empty($_POST['warn_body']) ? trim(censorText($_POST['warn_body'])) : '';
231 237
 		$context['preview_subject'] = !empty($_POST['warn_sub']) ? trim($smcFunc['htmlspecialchars']($_POST['warn_sub'])) : '';
232
-		if (empty($_POST['warn_sub']) || empty($_POST['warn_body']))
233
-			$issueErrors[] = 'warning_notify_blank';
238
+		if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) {
239
+					$issueErrors[] = 'warning_notify_blank';
240
+		}
234 241
 
235 242
 		if (!empty($_POST['warn_body']))
236 243
 		{
@@ -254,8 +261,9 @@  discard block
 block discarded – undo
254 261
 	{
255 262
 		// Fill in the suite of errors.
256 263
 		$context['post_errors'] = array();
257
-		foreach ($issueErrors as $error)
258
-			$context['post_errors'][] = $txt[$error];
264
+		foreach ($issueErrors as $error) {
265
+					$context['post_errors'][] = $txt[$error];
266
+		}
259 267
 	}
260 268
 
261 269
 
@@ -272,9 +280,10 @@  discard block
 block discarded – undo
272 280
 		$modSettings['warning_mute'] => $txt['profile_warning_effect_mute'],
273 281
 	);
274 282
 	$context['current_level'] = 0;
275
-	foreach ($context['level_effects'] as $limit => $dummy)
276
-		if ($context['member']['warning'] >= $limit)
283
+	foreach ($context['level_effects'] as $limit => $dummy) {
284
+			if ($context['member']['warning'] >= $limit)
277 285
 			$context['current_level'] = $limit;
286
+	}
278 287
 
279 288
 	$listOptions = array(
280 289
 		'id' => 'view_warnings',
@@ -337,11 +346,12 @@  discard block
 block discarded – undo
337 346
 							' . $warning['reason'] . '
338 347
 						</div>';
339 348
 
340
-						if (!empty($warning['id_notice']))
341
-							$ret .= '
349
+						if (!empty($warning['id_notice'])) {
350
+													$ret .= '
342 351
 						<div class="floatright">
343 352
 							<a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $warning['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" rel="noopener" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a>
344 353
 						</div>';
354
+						}
345 355
 
346 356
 						return $ret;
347 357
 					},
@@ -412,8 +422,9 @@  discard block
 block discarded – undo
412 422
 	while ($row = $smcFunc['db_fetch_assoc']($request))
413 423
 	{
414 424
 		// If we're not warning for a message skip any that are.
415
-		if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false)
416
-			continue;
425
+		if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) {
426
+					continue;
427
+		}
417 428
 
418 429
 		$context['notification_templates'][] = array(
419 430
 			'title' => $row['template_title'],
@@ -423,16 +434,18 @@  discard block
 block discarded – undo
423 434
 	$smcFunc['db_free_result']($request);
424 435
 
425 436
 	// Setup the "default" templates.
426
-	foreach (array('spamming', 'offence', 'insulting') as $type)
427
-		$context['notification_templates'][] = array(
437
+	foreach (array('spamming', 'offence', 'insulting') as $type) {
438
+			$context['notification_templates'][] = array(
428 439
 			'title' => $txt['profile_warning_notify_title_' . $type],
429 440
 			'body' => sprintf($txt['profile_warning_notify_template_outline' . (!empty($context['warning_for_message']) ? '_post' : '')], $txt['profile_warning_notify_for_' . $type]),
430 441
 		);
442
+	}
431 443
 
432 444
 	// Replace all the common variables in the templates.
433
-	foreach ($context['notification_templates'] as $k => $name)
434
-		$context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team']));
435
-}
445
+	foreach ($context['notification_templates'] as $k => $name) {
446
+			$context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team']));
447
+	}
448
+	}
436 449
 
437 450
 /**
438 451
  * Get the number of warnings a user has. Callback for $listOptions['get_count'] in issueWarning()
@@ -516,10 +529,11 @@  discard block
 block discarded – undo
516 529
 {
517 530
 	global $txt, $context, $modSettings, $cur_profile;
518 531
 
519
-	if (!$context['user']['is_owner'])
520
-		isAllowedTo('profile_remove_any');
521
-	elseif (!allowedTo('profile_remove_any'))
522
-		isAllowedTo('profile_remove_own');
532
+	if (!$context['user']['is_owner']) {
533
+			isAllowedTo('profile_remove_any');
534
+	} elseif (!allowedTo('profile_remove_any')) {
535
+			isAllowedTo('profile_remove_own');
536
+	}
523 537
 
524 538
 	// Permissions for removing stuff...
525 539
 	$context['can_delete_posts'] = !$context['user']['is_owner'] && allowedTo('moderate_forum');
@@ -546,10 +560,11 @@  discard block
 block discarded – undo
546 560
 
547 561
 	// @todo Add a way to delete pms as well?
548 562
 
549
-	if (!$context['user']['is_owner'])
550
-		isAllowedTo('profile_remove_any');
551
-	elseif (!allowedTo('profile_remove_any'))
552
-		isAllowedTo('profile_remove_own');
563
+	if (!$context['user']['is_owner']) {
564
+			isAllowedTo('profile_remove_any');
565
+	} elseif (!allowedTo('profile_remove_any')) {
566
+			isAllowedTo('profile_remove_own');
567
+	}
553 568
 
554 569
 	checkSession();
555 570
 
@@ -575,8 +590,9 @@  discard block
 block discarded – undo
575 590
 		list ($another) = $smcFunc['db_fetch_row']($request);
576 591
 		$smcFunc['db_free_result']($request);
577 592
 
578
-		if (empty($another))
579
-			fatal_lang_error('at_least_one_admin', 'critical');
593
+		if (empty($another)) {
594
+					fatal_lang_error('at_least_one_admin', 'critical');
595
+		}
580 596
 	}
581 597
 
582 598
 	// This file is needed for the deleteMembers function.
@@ -655,8 +671,9 @@  discard block
 block discarded – undo
655 671
 					)
656 672
 				);
657 673
 				$topicIDs = array();
658
-				while ($row = $smcFunc['db_fetch_assoc']($request))
659
-					$topicIDs[] = $row['id_topic'];
674
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
675
+									$topicIDs[] = $row['id_topic'];
676
+				}
660 677
 				$smcFunc['db_free_result']($request);
661 678
 
662 679
 				// Actually remove the topics. Ignore recycling if we want to perma-delete things...
@@ -679,8 +696,9 @@  discard block
 block discarded – undo
679 696
 			// This could take a while... but ya know it's gonna be worth it in the end.
680 697
 			while ($row = $smcFunc['db_fetch_assoc']($request))
681 698
 			{
682
-				if (function_exists('apache_reset_timeout'))
683
-					@apache_reset_timeout();
699
+				if (function_exists('apache_reset_timeout')) {
700
+									@apache_reset_timeout();
701
+				}
684 702
 
685 703
 				removeMessage($row['id_msg']);
686 704
 			}
@@ -688,8 +706,9 @@  discard block
 block discarded – undo
688 706
 		}
689 707
 
690 708
 		// Only delete this poor members account if they are actually being booted out of camp.
691
-		if (isset($_POST['deleteAccount']))
692
-			deleteMembers($memID);
709
+		if (isset($_POST['deleteAccount'])) {
710
+					deleteMembers($memID);
711
+		}
693 712
 	}
694 713
 	// Do they need approval to delete?
695 714
 	elseif (!empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum'))
@@ -740,18 +759,18 @@  discard block
 block discarded – undo
740 759
 		{
741 760
 			foreach ($costs as $duration => $cost)
742 761
 			{
743
-				if ($cost != 0)
744
-					$cost_array[$duration] = $cost;
762
+				if ($cost != 0) {
763
+									$cost_array[$duration] = $cost;
764
+				}
745 765
 			}
746
-		}
747
-		else
766
+		} else
748 767
 		{
749 768
 			$cost_array['fixed'] = $costs['fixed'];
750 769
 		}
751 770
 
752
-		if (empty($cost_array))
753
-			unset($context['subscriptions'][$id]);
754
-		else
771
+		if (empty($cost_array)) {
772
+					unset($context['subscriptions'][$id]);
773
+		} else
755 774
 		{
756 775
 			$context['subscriptions'][$id]['member'] = 0;
757 776
 			$context['subscriptions'][$id]['subscribed'] = false;
@@ -764,13 +783,15 @@  discard block
 block discarded – undo
764 783
 	foreach ($gateways as $id => $gateway)
765 784
 	{
766 785
 		$gateways[$id] = new $gateway['display_class']();
767
-		if (!$gateways[$id]->gatewayEnabled())
768
-			unset($gateways[$id]);
786
+		if (!$gateways[$id]->gatewayEnabled()) {
787
+					unset($gateways[$id]);
788
+		}
769 789
 	}
770 790
 
771 791
 	// No gateways yet?
772
-	if (empty($gateways))
773
-		fatal_error($txt['paid_admin_not_setup_gateway']);
792
+	if (empty($gateways)) {
793
+			fatal_error($txt['paid_admin_not_setup_gateway']);
794
+	}
774 795
 
775 796
 	// Get the current subscriptions.
776 797
 	$request = $smcFunc['db_query']('', '
@@ -785,8 +806,9 @@  discard block
 block discarded – undo
785 806
 	while ($row = $smcFunc['db_fetch_assoc']($request))
786 807
 	{
787 808
 		// The subscription must exist!
788
-		if (!isset($context['subscriptions'][$row['id_subscribe']]))
789
-			continue;
809
+		if (!isset($context['subscriptions'][$row['id_subscribe']])) {
810
+					continue;
811
+		}
790 812
 
791 813
 		$context['current'][$row['id_subscribe']] = array(
792 814
 			'id' => $row['id_sublog'],
@@ -800,8 +822,9 @@  discard block
 block discarded – undo
800 822
 			'status_text' => $row['status'] == 0 ? ($row['payments_pending'] ? $txt['paid_pending'] : $txt['paid_finished']) : $txt['paid_active'],
801 823
 		);
802 824
 
803
-		if ($row['status'] == 1)
804
-			$context['subscriptions'][$row['id_subscribe']]['subscribed'] = true;
825
+		if ($row['status'] == 1) {
826
+					$context['subscriptions'][$row['id_subscribe']]['subscribed'] = true;
827
+		}
805 828
 	}
806 829
 	$smcFunc['db_free_result']($request);
807 830
 
@@ -852,21 +875,25 @@  discard block
 block discarded – undo
852 875
 	if (isset($_GET['confirm']) && isset($_POST['sub_id']) && is_array($_POST['sub_id']))
853 876
 	{
854 877
 		// Hopefully just one.
855
-		foreach ($_POST['sub_id'] as $k => $v)
856
-			$ID_SUB = (int) $k;
878
+		foreach ($_POST['sub_id'] as $k => $v) {
879
+					$ID_SUB = (int) $k;
880
+		}
857 881
 
858
-		if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0)
859
-			fatal_lang_error('paid_sub_not_active');
882
+		if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) {
883
+					fatal_lang_error('paid_sub_not_active');
884
+		}
860 885
 
861 886
 		// Simplify...
862 887
 		$context['sub'] = $context['subscriptions'][$ID_SUB];
863 888
 		$period = 'xx';
864
-		if ($context['sub']['flexible'])
865
-			$period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx';
889
+		if ($context['sub']['flexible']) {
890
+					$period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx';
891
+		}
866 892
 
867 893
 		// Check we have a valid cost.
868
-		if ($context['sub']['flexible'] && $period == 'xx')
869
-			fatal_lang_error('paid_sub_not_active');
894
+		if ($context['sub']['flexible'] && $period == 'xx') {
895
+					fatal_lang_error('paid_sub_not_active');
896
+		}
870 897
 
871 898
 		// Sort out the cost/currency.
872 899
 		$context['currency'] = $modSettings['paid_currency_code'];
@@ -879,8 +906,7 @@  discard block
 block discarded – undo
879 906
 			$context['cost'] = sprintf($modSettings['paid_currency_symbol'], $context['value']) . '/' . $txt[$_POST['cur'][$ID_SUB]];
880 907
 			// The period value for paypal.
881 908
 			$context['paypal_period'] = strtoupper(substr($_POST['cur'][$ID_SUB], 0, 1));
882
-		}
883
-		else
909
+		} else
884 910
 		{
885 911
 			// Real cost...
886 912
 			$context['value'] = $context['sub']['costs']['fixed'];
@@ -897,13 +923,15 @@  discard block
 block discarded – undo
897 923
 		foreach ($gateways as $id => $gateway)
898 924
 		{
899 925
 			$fields = $gateways[$id]->fetchGatewayFields($context['sub']['id'] . '+' . $memID, $context['sub'], $context['value'], $period, $scripturl . '?action=profile;u=' . $memID . ';area=subscriptions;sub_id=' . $context['sub']['id'] . ';done');
900
-			if (!empty($fields['form']))
901
-				$context['gateways'][] = $fields;
926
+			if (!empty($fields['form'])) {
927
+							$context['gateways'][] = $fields;
928
+			}
902 929
 		}
903 930
 
904 931
 		// Bugger?!
905
-		if (empty($context['gateways']))
906
-			fatal_error($txt['paid_admin_not_setup_gateway']);
932
+		if (empty($context['gateways'])) {
933
+					fatal_error($txt['paid_admin_not_setup_gateway']);
934
+		}
907 935
 
908 936
 		// Now we are going to assume they want to take this out ;)
909 937
 		$new_data = array($context['sub']['id'], $context['value'], $period, 'prepay');
@@ -911,16 +939,19 @@  discard block
 block discarded – undo
911 939
 		{
912 940
 			// What are the details like?
913 941
 			$current_pending = array();
914
-			if ($context['current'][$context['sub']['id']]['pending_details'] != '')
915
-				$current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true);
942
+			if ($context['current'][$context['sub']['id']]['pending_details'] != '') {
943
+							$current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true);
944
+			}
916 945
 			// Don't get silly.
917
-			if (count($current_pending) > 9)
918
-				$current_pending = array();
946
+			if (count($current_pending) > 9) {
947
+							$current_pending = array();
948
+			}
919 949
 			$pending_count = 0;
920 950
 			// Only record real pending payments as will otherwise confuse the admin!
921
-			foreach ($current_pending as $pending)
922
-				if ($pending[3] == 'payback')
951
+			foreach ($current_pending as $pending) {
952
+							if ($pending[3] == 'payback')
923 953
 					$pending_count++;
954
+			}
924 955
 
925 956
 			if (!in_array($new_data, $current_pending))
926 957
 			{
@@ -964,10 +995,10 @@  discard block
 block discarded – undo
964 995
 
965 996
 		// Quit.
966 997
 		return;
998
+	} else {
999
+			$context['sub_template'] = 'user_subscription';
1000
+	}
967 1001
 	}
968
-	else
969
-		$context['sub_template'] = 'user_subscription';
970
-}
971 1002
 
972 1003
 /**
973 1004
  * Function to allow the user to todo Privacy stuff
@@ -978,23 +1009,28 @@  discard block
 block discarded – undo
978 1009
 {
979 1010
 	global $txt, $user_profile, $context, $smcFunc, $user_info;
980 1011
 
981
-	if ($memID == $user_info['id'])
982
-		$context['pdc']['own'] = true;
983
-	else
984
-		$context['pdc']['name'] = $context['member']['name'];
1012
+	if ($memID == $user_info['id']) {
1013
+			$context['pdc']['own'] = true;
1014
+	} else {
1015
+			$context['pdc']['name'] = $context['member']['name'];
1016
+	}
985 1017
 	
986
-	if (!empty($_REQUEST['nofound']))
987
-		$context['pdc']['nofound'] = true;
1018
+	if (!empty($_REQUEST['nofound'])) {
1019
+			$context['pdc']['nofound'] = true;
1020
+	}
988 1021
 	
989
-	if (empty($_REQUEST['activity']))
990
-		return;
1022
+	if (empty($_REQUEST['activity'])) {
1023
+			return;
1024
+	}
991 1025
 	
992 1026
 	$mode = $_REQUEST['activity'];
993 1027
 
994 1028
 	$profileData = array();
995
-	if ($mode == 'profile') // profile
1029
+	if ($mode == 'profile') {
1030
+		// profile
996 1031
 	{
997 1032
 		loadMemberData($memID, false, 'profile');
1033
+	}
998 1034
 		$profile = $user_profile[$memID];
999 1035
 		$removeFields = array('secret_question','tfa_secret','password_salt');
1000 1036
 		foreach ($removeFields as $value)
@@ -1003,14 +1039,15 @@  discard block
 block discarded – undo
1003 1039
 		}
1004 1040
 		foreach($profile as $key => &$value)
1005 1041
 		{
1006
-			if (is_array($value))
1007
-				$value = $smcFunc['json_encode']($value);
1042
+			if (is_array($value)) {
1043
+							$value = $smcFunc['json_encode']($value);
1044
+			}
1008 1045
 		}
1009 1046
 		$profileData[0] = array_keys($profile);
1010 1047
 		$profileData[1] = $profile;
1011 1048
 		call_integration_hook('integrate_getProfile_profile', array(&$profileData));
1012
-	}
1013
-	elseif ($mode == 'messages') // messages
1049
+	} elseif ($mode == 'messages') {
1050
+		// messages
1014 1051
 	{
1015 1052
 		
1016 1053
 		$request = $smcFunc['db_query']('','
@@ -1021,15 +1058,16 @@  discard block
 block discarded – undo
1021 1058
 				'memID' => $memID,
1022 1059
 			)
1023 1060
 		);
1061
+	}
1024 1062
 		$profileData = $smcFunc['db_fetch_all']($request);
1025
-		if (!is_array($profileData))
1026
-			redirectexit('action=profile;area=getprofiledata;u=' . $memID . ';nofound=1');
1063
+		if (!is_array($profileData)) {
1064
+					redirectexit('action=profile;area=getprofiledata;u=' . $memID . ';nofound=1');
1065
+		}
1027 1066
 		array_unshift($profileData, array_keys($profileData[0]));
1028 1067
 		$smcFunc['db_free_result']($request);
1029 1068
 
1030 1069
 		call_integration_hook('integrate_getProfile_messages', array(&$profileData));
1031
-	}
1032
-	elseif ($mode == 'pmessages')
1070
+	} elseif ($mode == 'pmessages')
1033 1071
 	{
1034 1072
 		$request = $smcFunc['db_query']('','
1035 1073
 			SELECT pm.msgtime, pm.subject, pm.body
@@ -1041,8 +1079,9 @@  discard block
 block discarded – undo
1041 1079
 			)
1042 1080
 		);
1043 1081
 		$profileData = $smcFunc['db_fetch_all']($request);
1044
-		if (!is_array($profileData))
1045
-			redirectexit('action=profile;area=getprofiledata;u=' . $memID . ';nofound=1');
1082
+		if (!is_array($profileData)) {
1083
+					redirectexit('action=profile;area=getprofiledata;u=' . $memID . ';nofound=1');
1084
+		}
1046 1085
 		array_unshift($profileData, array_keys($profileData[0]));
1047 1086
 		$smcFunc['db_free_result']($request);
1048 1087
 		call_integration_hook('integrate_getProfile_pmessages', array(&$profileData));
@@ -1076,8 +1115,9 @@  discard block
 block discarded – undo
1076 1115
 
1077 1116
 	$context['poc']['own'] = false;
1078 1117
 
1079
-	if ($memID == $user_info['id'])
1080
-		$context['poc']['own'] = true;
1118
+	if ($memID == $user_info['id']) {
1119
+			$context['poc']['own'] = true;
1120
+	}
1081 1121
 
1082 1122
 	if (!empty($user_profile[$memID]['options']['policy_approved']) &&
1083 1123
 			!empty($modSettings[$user_profile[$memID]['options']['policy_approved']]))
@@ -1095,19 +1135,23 @@  discard block
 block discarded – undo
1095 1135
 		$context['poc']['newVersionText'] = $modSettings[$modSettings['policy_version']];
1096 1136
 	}
1097 1137
 
1098
-	if (!empty($context['poc']['own']) && (!empty($context['poc']['newVersionText']) || empty($user_profile[$memID]['options']['policy_isvalid'])))
1099
-		$context['poc']['showAccept'] = true;
1138
+	if (!empty($context['poc']['own']) && (!empty($context['poc']['newVersionText']) || empty($user_profile[$memID]['options']['policy_isvalid']))) {
1139
+			$context['poc']['showAccept'] = true;
1140
+	}
1100 1141
 
1101
-	if (empty($_REQUEST['activity']))
1102
-		return;
1142
+	if (empty($_REQUEST['activity'])) {
1143
+			return;
1144
+	}
1103 1145
 
1104 1146
 	$mode = $_REQUEST['activity'];
1105 1147
 
1106 1148
 	$profileData = array();
1107
-	if ($mode == 'save') // profile
1149
+	if ($mode == 'save') {
1150
+		// profile
1108 1151
 	{
1109 1152
 		if (!$context['poc']['own']) //only for yourself
1110 1153
 			exit;
1154
+	}
1111 1155
 
1112 1156
 		$data = array(
1113 1157
 			array($memID, 1, 'policy_approved', $modSettings['policy_version']),
@@ -1151,8 +1195,7 @@  discard block
 block discarded – undo
1151 1195
 		if ( $encloseAll || preg_match( "/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field ) )
1152 1196
 		{
1153 1197
 			$output[] = $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field) . $enclosure;
1154
-		}
1155
-		else
1198
+		} else
1156 1199
 		{
1157 1200
 			$output[] = $field;
1158 1201
 		}
Please login to merge, or discard this patch.
Sources/Profile.php 1 patch
Braces   +164 added lines, -124 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
  * The main designating function for modifying profiles. Loads up info, determins what to do, etc.
@@ -29,18 +30,21 @@  discard block
 block discarded – undo
29 30
 	global $modSettings, $memberContext, $profile_vars, $post_errors, $smcFunc;
30 31
 
31 32
 	// Don't reload this as we may have processed error strings.
32
-	if (empty($post_errors))
33
-		loadLanguage('Profile+Drafts');
33
+	if (empty($post_errors)) {
34
+			loadLanguage('Profile+Drafts');
35
+	}
34 36
 	loadTemplate('Profile');
35 37
 
36 38
 	require_once($sourcedir . '/Subs-Menu.php');
37 39
 
38 40
 	// Did we get the user by name...
39
-	if (isset($_REQUEST['user']))
40
-		$memberResult = loadMemberData($_REQUEST['user'], true, 'profile');
41
+	if (isset($_REQUEST['user'])) {
42
+			$memberResult = loadMemberData($_REQUEST['user'], true, 'profile');
43
+	}
41 44
 	// ... or by id_member?
42
-	elseif (!empty($_REQUEST['u']))
43
-		$memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile');
45
+	elseif (!empty($_REQUEST['u'])) {
46
+			$memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile');
47
+	}
44 48
 	// If it was just ?action=profile, edit your own profile, but only if you're not a guest.
45 49
 	else
46 50
 	{
@@ -50,8 +54,9 @@  discard block
 block discarded – undo
50 54
 	}
51 55
 
52 56
 	// Check if loadMemberData() has returned a valid result.
53
-	if (!$memberResult)
54
-		fatal_lang_error('not_a_user', false, 404);
57
+	if (!$memberResult) {
58
+			fatal_lang_error('not_a_user', false, 404);
59
+	}
55 60
 
56 61
 	// If all went well, we have a valid member ID!
57 62
 	list ($memID) = $memberResult;
@@ -67,8 +72,9 @@  discard block
 block discarded – undo
67 72
 
68 73
 	// Group management isn't actually a permission. But we need it to be for this, so we need a phantom permission.
69 74
 	// And we care about what the current user can do, not what the user whose profile it is.
70
-	if ($user_info['mod_cache']['gq'] != '0=1')
71
-		$user_info['permissions'][] = 'approve_group_requests';
75
+	if ($user_info['mod_cache']['gq'] != '0=1') {
76
+			$user_info['permissions'][] = 'approve_group_requests';
77
+	}
72 78
 
73 79
 	// If paid subscriptions are enabled, make sure we actually have at least one subscription available...
74 80
 	$context['subs_available'] = false;
@@ -423,8 +429,8 @@  discard block
 block discarded – undo
423 429
 		),
424 430
 	);
425 431
 	
426
-	if (!empty($modSettings['enable_privacy_userexport']))
427
-		$profile_areas['profile_action']['areas']['getprofiledata'] = array(
432
+	if (!empty($modSettings['enable_privacy_userexport'])) {
433
+			$profile_areas['profile_action']['areas']['getprofiledata'] = array(
428 434
 					'label' => $txt['getProfileData'],
429 435
 					'file' => 'Profile-Actions.php',
430 436
 					'function' => 'getProfileData',
@@ -437,9 +443,10 @@  discard block
 block discarded – undo
437 443
 						'any' => array('privacy_userexport_others'),
438 444
 					),
439 445
 				);
446
+	}
440 447
 
441
-	if (!empty($modSettings['enable_policy_function']))
442
-		$profile_areas['profile_action']['areas']['getpolicydata'] = array(
448
+	if (!empty($modSettings['enable_policy_function'])) {
449
+			$profile_areas['profile_action']['areas']['getpolicydata'] = array(
443 450
 					'label' => $txt['getPolicyData'],
444 451
 					'file' => 'Profile-Actions.php',
445 452
 					'function' => 'getPolicyData',
@@ -452,6 +459,7 @@  discard block
 block discarded – undo
452 459
 						'any' => array('moderate_forum'),
453 460
 					),
454 461
 				);
462
+	}
455 463
 
456 464
 	// Let them modify profile areas easily.
457 465
 	call_integration_hook('integrate_pre_profile_areas', array(&$profile_areas));
@@ -466,21 +474,25 @@  discard block
 block discarded – undo
466 474
 		foreach ($section['areas'] as $area_id => $area)
467 475
 		{
468 476
 			// If it said no permissions that meant it wasn't valid!
469
-			if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any']))
470
-				$profile_areas[$section_id]['areas'][$area_id]['enabled'] = false;
477
+			if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) {
478
+							$profile_areas[$section_id]['areas'][$area_id]['enabled'] = false;
479
+			}
471 480
 			// Otherwise pick the right set.
472
-			else
473
-				$profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any'];
481
+			else {
482
+							$profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any'];
483
+			}
474 484
 
475 485
 			// Password required in most cases
476
-			if (!empty($area['password']))
477
-				$context['password_areas'][] = $area_id;
486
+			if (!empty($area['password'])) {
487
+							$context['password_areas'][] = $area_id;
488
+			}
478 489
 		}
479 490
 	}
480 491
 
481 492
 	// Is there an updated message to show?
482
-	if (isset($_GET['updated']))
483
-		$context['profile_updated'] = $txt['profile_updated_own'];
493
+	if (isset($_GET['updated'])) {
494
+			$context['profile_updated'] = $txt['profile_updated_own'];
495
+	}
484 496
 
485 497
 	// Set a few options for the menu.
486 498
 	$menuOptions = array(
@@ -495,8 +507,9 @@  discard block
 block discarded – undo
495 507
 	$profile_include_data = createMenu($profile_areas, $menuOptions);
496 508
 
497 509
 	// No menu means no access.
498
-	if (!$profile_include_data && (!$user_info['is_guest'] || validateSession()))
499
-		fatal_lang_error('no_access', false);
510
+	if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) {
511
+			fatal_lang_error('no_access', false);
512
+	}
500 513
 
501 514
 	// Make a note of the Unique ID for this menu.
502 515
 	$context['profile_menu_id'] = $context['max_menu_id'];
@@ -522,8 +535,9 @@  discard block
 block discarded – undo
522 535
 			if ($current_area == $area_id)
523 536
 			{
524 537
 				// This can't happen - but is a security check.
525
-				if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false))
526
-					fatal_lang_error('no_access', false);
538
+				if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) {
539
+									fatal_lang_error('no_access', false);
540
+				}
527 541
 
528 542
 				// Are we saving data in a valid area?
529 543
 				if (isset($area['sc']) && (isset($_REQUEST['save']) || $context['do_preview']))
@@ -542,12 +556,14 @@  discard block
 block discarded – undo
542 556
 				}
543 557
 
544 558
 				// Does this require session validating?
545
-				if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner']))
546
-					$security_checks['validate'] = true;
559
+				if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) {
560
+									$security_checks['validate'] = true;
561
+				}
547 562
 
548 563
 				// Permissions for good measure.
549
-				if (!empty($profile_include_data['permission']))
550
-					$security_checks['permission'] = $profile_include_data['permission'];
564
+				if (!empty($profile_include_data['permission'])) {
565
+									$security_checks['permission'] = $profile_include_data['permission'];
566
+				}
551 567
 
552 568
 				// Either way got something.
553 569
 				$found_area = true;
@@ -556,21 +572,26 @@  discard block
 block discarded – undo
556 572
 	}
557 573
 
558 574
 	// Oh dear, some serious security lapse is going on here... we'll put a stop to that!
559
-	if (!$found_area)
560
-		fatal_lang_error('no_access', false);
575
+	if (!$found_area) {
576
+			fatal_lang_error('no_access', false);
577
+	}
561 578
 
562 579
 	// Release this now.
563 580
 	unset($profile_areas);
564 581
 
565 582
 	// Now the context is setup have we got any security checks to carry out additional to that above?
566
-	if (isset($security_checks['session']))
567
-		checkSession($security_checks['session']);
568
-	if (isset($security_checks['validate']))
569
-		validateSession();
570
-	if (isset($security_checks['validateToken']))
571
-		validateToken($token_name, $token_type);
572
-	if (isset($security_checks['permission']))
573
-		isAllowedTo($security_checks['permission']);
583
+	if (isset($security_checks['session'])) {
584
+			checkSession($security_checks['session']);
585
+	}
586
+	if (isset($security_checks['validate'])) {
587
+			validateSession();
588
+	}
589
+	if (isset($security_checks['validateToken'])) {
590
+			validateToken($token_name, $token_type);
591
+	}
592
+	if (isset($security_checks['permission'])) {
593
+			isAllowedTo($security_checks['permission']);
594
+	}
574 595
 
575 596
 	// Create a token if needed.
576 597
 	if (isset($security_checks['needsToken']) || isset($security_checks['validateToken']))
@@ -580,8 +601,9 @@  discard block
 block discarded – undo
580 601
 	}
581 602
 
582 603
 	// File to include?
583
-	if (isset($profile_include_data['file']))
584
-		require_once($sourcedir . '/' . $profile_include_data['file']);
604
+	if (isset($profile_include_data['file'])) {
605
+			require_once($sourcedir . '/' . $profile_include_data['file']);
606
+	}
585 607
 
586 608
 	// Build the link tree.
587 609
 	$context['linktree'][] = array(
@@ -589,17 +611,19 @@  discard block
 block discarded – undo
589 611
 		'name' => sprintf($txt['profile_of_username'], $context['member']['name']),
590 612
 	);
591 613
 
592
-	if (!empty($profile_include_data['label']))
593
-		$context['linktree'][] = array(
614
+	if (!empty($profile_include_data['label'])) {
615
+			$context['linktree'][] = array(
594 616
 			'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'],
595 617
 			'name' => $profile_include_data['label'],
596 618
 		);
619
+	}
597 620
 
598
-	if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label'])
599
-		$context['linktree'][] = array(
621
+	if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) {
622
+			$context['linktree'][] = array(
600 623
 			'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'] . ';sa=' . $profile_include_data['current_subsection'],
601 624
 			'name' => $profile_include_data['subsections'][$profile_include_data['current_subsection']][0],
602 625
 		);
626
+	}
603 627
 
604 628
 	// Set the template for this area and add the profile layer.
605 629
 	$context['sub_template'] = $profile_include_data['function'];
@@ -625,12 +649,14 @@  discard block
 block discarded – undo
625 649
 		if ($check_password)
626 650
 		{
627 651
 			// Check to ensure we're forcing SSL for authentication
628
-			if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
629
-				fatal_lang_error('login_ssl_required');
652
+			if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
653
+							fatal_lang_error('login_ssl_required');
654
+			}
630 655
 
631 656
 			// You didn't even enter a password!
632
-			if (trim($_POST['oldpasswrd']) == '')
633
-				$post_errors[] = 'no_password';
657
+			if (trim($_POST['oldpasswrd']) == '') {
658
+							$post_errors[] = 'no_password';
659
+			}
634 660
 
635 661
 			// Since the password got modified due to all the $_POST cleaning, lets undo it so we can get the correct password
636 662
 			$_POST['oldpasswrd'] = un_htmlspecialchars($_POST['oldpasswrd']);
@@ -639,42 +665,43 @@  discard block
 block discarded – undo
639 665
 			$good_password = in_array(true, call_integration_hook('integrate_verify_password', array($cur_profile['member_name'], $_POST['oldpasswrd'], false)), true);
640 666
 
641 667
 			// Bad password!!!
642
-			if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd']))
643
-				$post_errors[] = 'bad_password';
668
+			if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) {
669
+							$post_errors[] = 'bad_password';
670
+			}
644 671
 
645 672
 			// Warn other elements not to jump the gun and do custom changes!
646
-			if (in_array('bad_password', $post_errors))
647
-				$context['password_auth_failed'] = true;
673
+			if (in_array('bad_password', $post_errors)) {
674
+							$context['password_auth_failed'] = true;
675
+			}
648 676
 		}
649 677
 
650 678
 		// Change the IP address in the database.
651
-		if ($context['user']['is_owner'])
652
-			$profile_vars['member_ip'] = $user_info['ip'];
679
+		if ($context['user']['is_owner']) {
680
+					$profile_vars['member_ip'] = $user_info['ip'];
681
+		}
653 682
 
654 683
 		// Now call the sub-action function...
655 684
 		if ($current_area == 'activateaccount')
656 685
 		{
657
-			if (empty($post_errors))
658
-				activateAccount($memID);
659
-		}
660
-		elseif ($current_area == 'deleteaccount')
686
+			if (empty($post_errors)) {
687
+							activateAccount($memID);
688
+			}
689
+		} elseif ($current_area == 'deleteaccount')
661 690
 		{
662 691
 			if (empty($post_errors))
663 692
 			{
664 693
 				deleteAccount2($memID);
665 694
 				redirectexit();
666 695
 			}
667
-		}
668
-		elseif ($current_area == 'groupmembership' && empty($post_errors))
696
+		} elseif ($current_area == 'groupmembership' && empty($post_errors))
669 697
 		{
670 698
 			$msg = groupMembership2($profile_vars, $post_errors, $memID);
671 699
 
672 700
 			// Whatever we've done, we have nothing else to do here...
673 701
 			redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=groupmembership' . (!empty($msg) ? ';msg=' . $msg : ''));
674
-		}
675
-		elseif (in_array($current_area, array('account', 'forumprofile', 'theme')))
676
-			saveProfileFields();
677
-		else
702
+		} elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) {
703
+					saveProfileFields();
704
+		} else
678 705
 		{
679 706
 			$force_redirect = true;
680 707
 			// Ensure we include this.
@@ -690,34 +717,36 @@  discard block
 block discarded – undo
690 717
 			// Load the language file so we can give a nice explanation of the errors.
691 718
 			loadLanguage('Errors');
692 719
 			$context['post_errors'] = $post_errors;
693
-		}
694
-		elseif (!empty($profile_vars))
720
+		} elseif (!empty($profile_vars))
695 721
 		{
696 722
 			// If we've changed the password, notify any integration that may be listening in.
697
-			if (isset($profile_vars['passwd']))
698
-				call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2']));
723
+			if (isset($profile_vars['passwd'])) {
724
+							call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2']));
725
+			}
699 726
 
700 727
 			updateMemberData($memID, $profile_vars);
701 728
 
702 729
 			// What if this is the newest member?
703
-			if ($modSettings['latestMember'] == $memID)
704
-				updateStats('member');
705
-			elseif (isset($profile_vars['real_name']))
706
-				updateSettings(array('memberlist_updated' => time()));
730
+			if ($modSettings['latestMember'] == $memID) {
731
+							updateStats('member');
732
+			} elseif (isset($profile_vars['real_name'])) {
733
+							updateSettings(array('memberlist_updated' => time()));
734
+			}
707 735
 
708 736
 			// If the member changed his/her birthdate, update calendar statistics.
709
-			if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name']))
710
-				updateSettings(array(
737
+			if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) {
738
+							updateSettings(array(
711 739
 					'calendar_updated' => time(),
712 740
 				));
741
+			}
713 742
 
714 743
 			// Anything worth logging?
715 744
 			if (!empty($context['log_changes']) && !empty($modSettings['modlog_enabled']))
716 745
 			{
717 746
 				$log_changes = array();
718 747
 				require_once($sourcedir . '/Logging.php');
719
-				foreach ($context['log_changes'] as $k => $v)
720
-					$log_changes[] = array(
748
+				foreach ($context['log_changes'] as $k => $v) {
749
+									$log_changes[] = array(
721 750
 						'action' => $k,
722 751
 						'log_type' => 'user',
723 752
 						'extra' => array_merge($v, array(
@@ -725,14 +754,16 @@  discard block
 block discarded – undo
725 754
 							'member_affected' => $memID,
726 755
 						)),
727 756
 					);
757
+				}
728 758
 
729 759
 				logActions($log_changes);
730 760
 			}
731 761
 
732 762
 			// Have we got any post save functions to execute?
733
-			if (!empty($context['profile_execute_on_save']))
734
-				foreach ($context['profile_execute_on_save'] as $saveFunc)
763
+			if (!empty($context['profile_execute_on_save'])) {
764
+							foreach ($context['profile_execute_on_save'] as $saveFunc)
735 765
 					$saveFunc();
766
+			}
736 767
 
737 768
 			// Let them know it worked!
738 769
 			$context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $cur_profile['member_name']);
@@ -746,27 +777,31 @@  discard block
 block discarded – undo
746 777
 	if (!empty($post_errors))
747 778
 	{
748 779
 		// Set all the errors so the template knows what went wrong.
749
-		foreach ($post_errors as $error_type)
750
-			$context['modify_error'][$error_type] = true;
780
+		foreach ($post_errors as $error_type) {
781
+					$context['modify_error'][$error_type] = true;
782
+		}
751 783
 	}
752 784
 	// If it's you then we should redirect upon save.
753
-	elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview'])
754
-		redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated');
755
-	elseif (!empty($force_redirect))
756
-		redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area);
785
+	elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) {
786
+			redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated');
787
+	} elseif (!empty($force_redirect)) {
788
+			redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area);
789
+	}
757 790
 
758 791
 
759 792
 	// Get the right callable.
760 793
 	$call = call_helper($profile_include_data['function'], true);
761 794
 
762 795
 	// Is it valid?
763
-	if (!empty($call))
764
-		call_user_func($call, $memID);
796
+	if (!empty($call)) {
797
+			call_user_func($call, $memID);
798
+	}
765 799
 
766 800
 	// Set the page title if it's not already set...
767
-	if (!isset($context['page_title']))
768
-		$context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : '');
769
-}
801
+	if (!isset($context['page_title'])) {
802
+			$context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : '');
803
+	}
804
+	}
770 805
 
771 806
 /**
772 807
  * Set up the requirements for the profile popup - the area that is shown as the popup menu for the current user.
@@ -889,16 +924,18 @@  discard block
 block discarded – undo
889 924
 	if (!allowedTo('admin_forum') && $area != 'register')
890 925
 	{
891 926
 		// If it's the owner they can see two types of private fields, regardless.
892
-		if ($memID == $user_info['id'])
893
-			$where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)';
894
-		else
895
-			$where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0';
927
+		if ($memID == $user_info['id']) {
928
+					$where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)';
929
+		} else {
930
+					$where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0';
931
+		}
896 932
 	}
897 933
 
898
-	if ($area == 'register')
899
-		$where .= ' AND show_reg != 0';
900
-	elseif ($area != 'summary')
901
-		$where .= ' AND show_profile = {string:area}';
934
+	if ($area == 'register') {
935
+			$where .= ' AND show_reg != 0';
936
+	} elseif ($area != 'summary') {
937
+			$where .= ' AND show_profile = {string:area}';
938
+	}
902 939
 
903 940
 	// Load all the relevant fields - and data.
904 941
 	$request = $smcFunc['db_query']('', '
@@ -926,8 +963,9 @@  discard block
 block discarded – undo
926 963
 			$fieldOptions = explode(',', $row['field_options']);
927 964
 			foreach ($fieldOptions as $k => $v)
928 965
 			{
929
-				if (empty($currentKey))
930
-					$currentKey = $v === $value ? $k : 0;
966
+				if (empty($currentKey)) {
967
+									$currentKey = $v === $value ? $k : 0;
968
+				}
931 969
 			}
932 970
 		}
933 971
 
@@ -935,13 +973,15 @@  discard block
 block discarded – undo
935 973
 		if (isset($_POST['customfield']) && isset($_POST['customfield'][$row['col_name']]))
936 974
 		{
937 975
 			$value = $smcFunc['htmlspecialchars']($_POST['customfield'][$row['col_name']]);
938
-			if (in_array($row['field_type'], array('select', 'radio')))
939
-					$value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : '';
976
+			if (in_array($row['field_type'], array('select', 'radio'))) {
977
+								$value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : '';
978
+			}
940 979
 		}
941 980
 
942 981
 		// Don't show the "disabled" option for the "gender" field if we are on the "summary" area.
943
-		if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'None')
944
-			continue;
982
+		if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'None') {
983
+					continue;
984
+		}
945 985
 
946 986
 		// HTML for the input form.
947 987
 		$output_html = $value;
@@ -950,8 +990,7 @@  discard block
 block discarded – undo
950 990
 			$true = (!$exists && $row['default_value']) || $value;
951 991
 			$input_html = '<input type="checkbox" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($true ? ' checked' : '') . '>';
952 992
 			$output_html = $true ? $txt['yes'] : $txt['no'];
953
-		}
954
-		elseif ($row['field_type'] == 'select')
993
+		} elseif ($row['field_type'] == 'select')
955 994
 		{
956 995
 			$input_html = '<select name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"><option value="-1"></option>';
957 996
 			$options = explode(',', $row['field_options']);
@@ -959,13 +998,13 @@  discard block
 block discarded – undo
959 998
 			{
960 999
 				$true = (!$exists && $row['default_value'] == $v) || $value == $v;
961 1000
 				$input_html .= '<option value="' . $k . '"' . ($true ? ' selected' : '') . '>' . $v . '</option>';
962
-				if ($true)
963
-					$output_html = $v;
1001
+				if ($true) {
1002
+									$output_html = $v;
1003
+				}
964 1004
 			}
965 1005
 
966 1006
 			$input_html .= '</select>';
967
-		}
968
-		elseif ($row['field_type'] == 'radio')
1007
+		} elseif ($row['field_type'] == 'radio')
969 1008
 		{
970 1009
 			$input_html = '<fieldset>';
971 1010
 			$options = explode(',', $row['field_options']);
@@ -973,37 +1012,38 @@  discard block
 block discarded – undo
973 1012
 			{
974 1013
 				$true = (!$exists && $row['default_value'] == $v) || $value == $v;
975 1014
 				$input_html .= '<label for="customfield_' . $row['col_name'] . '_' . $k . '"><input type="radio" name="customfield[' . $row['col_name'] . ']" id="customfield_' . $row['col_name'] . '_' . $k . '" value="' . $k . '"' . ($true ? ' checked' : '') . '>' . $v . '</label><br>';
976
-				if ($true)
977
-					$output_html = $v;
1015
+				if ($true) {
1016
+									$output_html = $v;
1017
+				}
978 1018
 			}
979 1019
 			$input_html .= '</fieldset>';
980
-		}
981
-		elseif ($row['field_type'] == 'text')
1020
+		} elseif ($row['field_type'] == 'text')
982 1021
 		{
983 1022
 			$input_html = '<input type="text" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($row['field_length'] != 0 ? ' maxlength="' . $row['field_length'] . '"' : '') . ' size="' . ($row['field_length'] == 0 || $row['field_length'] >= 50 ? 50 : ($row['field_length'] > 30 ? 30 : ($row['field_length'] > 10 ? 20 : 10))) . '" value="' . un_htmlspecialchars($value) . '"' . ($row['show_reg'] == 2 ? ' required' : '') . '>';
984
-		}
985
-		else
1023
+		} else
986 1024
 		{
987 1025
 			@list ($rows, $cols) = @explode(',', $row['default_value']);
988 1026
 			$input_html = '<textarea name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . (!empty($rows) ? ' rows="' . $rows . '"' : '') . (!empty($cols) ? ' cols="' . $cols . '"' : '') . ($row['show_reg'] == 2 ? ' required' : '') . '>' . un_htmlspecialchars($value) . '</textarea>';
989 1027
 		}
990 1028
 
991 1029
 		// Parse BBCode
992
-		if ($row['bbc'])
993
-			$output_html = parse_bbc($output_html);
994
-		elseif ($row['field_type'] == 'textarea')
995
-			// Allow for newlines at least
1030
+		if ($row['bbc']) {
1031
+					$output_html = parse_bbc($output_html);
1032
+		} elseif ($row['field_type'] == 'textarea') {
1033
+					// Allow for newlines at least
996 1034
 			$output_html = strtr($output_html, array("\n" => '<br>'));
1035
+		}
997 1036
 
998 1037
 		// Enclosing the user input within some other text?
999
-		if (!empty($row['enclose']) && !empty($output_html))
1000
-			$output_html = strtr($row['enclose'], array(
1038
+		if (!empty($row['enclose']) && !empty($output_html)) {
1039
+					$output_html = strtr($row['enclose'], array(
1001 1040
 				'{SCRIPTURL}' => $scripturl,
1002 1041
 				'{IMAGES_URL}' => $settings['images_url'],
1003 1042
 				'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
1004 1043
 				'{INPUT}' => un_htmlspecialchars($output_html),
1005 1044
 				'{KEY}' => $currentKey
1006 1045
 			));
1046
+		}
1007 1047
 
1008 1048
 		$context['custom_fields'][] = array(
1009 1049
 			'name' => $row['field_name'],
Please login to merge, or discard this patch.
Themes/default/Profile.template.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 		$fields = '';
460 460
 		foreach ($context['print_custom_fields']['below_signature'] as $field)
461 461
 			if (!empty($field['output_html']))
462
-				$fields .=  '
462
+				$fields .= '
463 463
 					<li>' . $field['output_html'] . '</li>';
464 464
 
465 465
 		if (!empty($fields))
@@ -3272,7 +3272,7 @@  discard block
 block discarded – undo
3272 3272
 				', $txt['profileDataCenter'], '
3273 3273
 			</h3>
3274 3274
 		</div>
3275
-		',( !empty($context['pdc']['nofound']) ? '<p class="information">' . $txt['profileDataNotFound'] . '</p>' : ''),'<div class="windowbg">
3275
+		',(!empty($context['pdc']['nofound']) ? '<p class="information">' . $txt['profileDataNotFound'] . '</p>' : ''), '<div class="windowbg">
3276 3276
 		<div>
3277 3277
 			<form action="', $scripturl, '?action=profile;area=getprofiledata;activity=profile" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
3278 3278
 				<p',  '', '>', (!empty($context['pdc']['own']) ? $txt['profileDownloadProfile_own'] : sprintf($txt['profileDownloadProfile_any'], $context['pdc']['name'])), ': </p>
@@ -3331,7 +3331,7 @@  discard block
 block discarded – undo
3331 3331
 				<div class="title_bar">
3332 3332
 					<h3 class="titlebg">', $txt['policy_approved'], '</h3>
3333 3333
 				</div>
3334
-				<p>' ,$context['poc']['approved_text'] , '</p>
3334
+				<p>' ,$context['poc']['approved_text'], '</p>
3335 3335
 			</div>';
3336 3336
 	if (!empty($context['poc']['newVersionText']))
3337 3337
 		echo '
@@ -3339,7 +3339,7 @@  discard block
 block discarded – undo
3339 3339
 				<div class="title_bar">
3340 3340
 					<h3 class="titlebg">', $txt['policy_new'], '</h3>
3341 3341
 				</div>
3342
-				<p>' ,$context['poc']['newVersionText'] , '</p>
3342
+				<p>' ,$context['poc']['newVersionText'], '</p>
3343 3343
 			</div>';
3344 3344
 	
3345 3345
 	if (!empty($context['poc']['showAccept']))
Please login to merge, or discard this patch.
Braces   +573 added lines, -437 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.)
@@ -99,19 +101,19 @@  discard block
 block discarded – undo
99 101
 		</div>
100 102
 		<div class="alerts_unread">';
101 103
 
102
-	if (empty($context['unread_alerts']))
103
-		template_alerts_all_read();
104
-
105
-	else
104
+	if (empty($context['unread_alerts'])) {
105
+			template_alerts_all_read();
106
+	} else
106 107
 	{
107
-		foreach ($context['unread_alerts'] as $id_alert => $details)
108
-			echo '
108
+		foreach ($context['unread_alerts'] as $id_alert => $details) {
109
+					echo '
109 110
 			<div class="unread">
110 111
 				', !empty($details['sender']) ? $details['sender']['avatar']['image'] : '', '
111 112
 				<div class="details">
112 113
 					', !empty($details['icon']) ? $details['icon'] : '', '<span>', $details['text'], '</span> - ', $details['time'], '
113 114
 				</div>
114 115
 			</div>';
116
+		}
115 117
 	}
116 118
 
117 119
 	echo '
@@ -158,37 +160,41 @@  discard block
 block discarded – undo
158 160
 	if (!empty($context['print_custom_fields']['above_member']))
159 161
 	{
160 162
 		$fields = '';
161
-		foreach ($context['print_custom_fields']['above_member'] as $field)
162
-			if (!empty($field['output_html']))
163
+		foreach ($context['print_custom_fields']['above_member'] as $field) {
164
+					if (!empty($field['output_html']))
163 165
 				$fields .= '
164 166
 					<li>' . $field['output_html'] . '</li>';
167
+		}
165 168
 
166
-		if (!empty($fields))
167
-			echo '
169
+		if (!empty($fields)) {
170
+					echo '
168 171
 			<div class="custom_fields_above_name">
169 172
 				<ul>', $fields, '
170 173
 				</ul>
171 174
 			</div>';
175
+		}
172 176
 	}
173 177
 
174 178
 	echo '
175 179
 			<div class="username clear">
176 180
 				<h4>';
177 181
 
178
-	if (!empty($context['print_custom_fields']['before_member']))
179
-		foreach ($context['print_custom_fields']['before_member'] as $field)
182
+	if (!empty($context['print_custom_fields']['before_member'])) {
183
+			foreach ($context['print_custom_fields']['before_member'] as $field)
180 184
 			if (!empty($field['output_html']))
181 185
 				echo '
182 186
 					<span>', $field['output_html'], '</span>';
187
+	}
183 188
 
184 189
 	echo '
185 190
 					', $context['member']['name'];
186 191
 
187
-	if (!empty($context['print_custom_fields']['after_member']))
188
-		foreach ($context['print_custom_fields']['after_member'] as $field)
192
+	if (!empty($context['print_custom_fields']['after_member'])) {
193
+			foreach ($context['print_custom_fields']['after_member'] as $field)
189 194
 			if (!empty($field['output_html']))
190 195
 				echo '
191 196
 					<span>', $field['output_html'], '</span>';
197
+	}
192 198
 
193 199
 
194 200
 	echo '
@@ -201,39 +207,44 @@  discard block
 block discarded – undo
201 207
 	if (!empty($context['print_custom_fields']['below_avatar']))
202 208
 	{
203 209
 		$fields = '';
204
-		foreach ($context['print_custom_fields']['below_avatar'] as $field)
205
-			if (!empty($field['output_html']))
210
+		foreach ($context['print_custom_fields']['below_avatar'] as $field) {
211
+					if (!empty($field['output_html']))
206 212
 				$fields .= '
207 213
 					<li>' . $field['output_html'] . '</li>';
214
+		}
208 215
 
209
-		if (!empty($fields))
210
-			echo '
216
+		if (!empty($fields)) {
217
+					echo '
211 218
 			<div class="custom_fields_below_avatar">
212 219
 				<ul>', $fields, '
213 220
 				</ul>
214 221
 			</div>';
222
+		}
215 223
 	}
216 224
 
217 225
 	echo '
218 226
 			<ul class="icon_fields clear">';
219 227
 
220 228
 	// Email is only visible if it's your profile or you have the moderate_forum permission
221
-	if ($context['member']['show_email'])
222
-		echo '
229
+	if ($context['member']['show_email']) {
230
+			echo '
223 231
 				<li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>';
232
+	}
224 233
 
225 234
 	// Don't show an icon if they haven't specified a website.
226
-	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website']))
227
-		echo '
235
+	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) {
236
+			echo '
228 237
 				<li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
238
+	}
229 239
 
230 240
 	// Are there any custom profile fields as icons?
231 241
 	if (!empty($context['print_custom_fields']['icons']))
232 242
 	{
233
-		foreach ($context['print_custom_fields']['icons'] as $field)
234
-			if (!empty($field['output_html']))
243
+		foreach ($context['print_custom_fields']['icons'] as $field) {
244
+					if (!empty($field['output_html']))
235 245
 				echo '
236 246
 				<li class="custom_field">', $field['output_html'], '</li>';
247
+		}
237 248
 	}
238 249
 
239 250
 	echo '
@@ -242,24 +253,27 @@  discard block
 block discarded – undo
242 253
 				', $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>' : '';
243 254
 
244 255
 	// Can they add this member as a buddy?
245
-	if (!empty($context['can_have_buddy']) && !$context['user']['is_owner'])
246
-		echo '
256
+	if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) {
257
+			echo '
247 258
 				<br>
248 259
 				<a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], '</a>';
260
+	}
249 261
 
250 262
 	echo '
251 263
 			</span>';
252 264
 
253
-	if (!$context['user']['is_owner'] && $context['can_send_pm'])
254
-		echo '
265
+	if (!$context['user']['is_owner'] && $context['can_send_pm']) {
266
+			echo '
255 267
 			<a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>';
268
+	}
256 269
 
257 270
 	echo '
258 271
 			<a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>';
259 272
 
260
-	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled']))
261
-		echo '
273
+	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) {
274
+			echo '
262 275
 			<a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>';
276
+	}
263 277
 
264 278
 	echo '
265 279
 			<a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>';
@@ -268,17 +282,19 @@  discard block
 block discarded – undo
268 282
 	if (!empty($context['print_custom_fields']['bottom_poster']))
269 283
 	{
270 284
 		$fields = '';
271
-		foreach ($context['print_custom_fields']['bottom_poster'] as $field)
272
-			if (!empty($field['output_html']))
285
+		foreach ($context['print_custom_fields']['bottom_poster'] as $field) {
286
+					if (!empty($field['output_html']))
273 287
 				$fields .= '
274 288
 					<li>' . $field['output_html'] . '</li>';
289
+		}
275 290
 
276
-		if (!empty($fields))
277
-			echo '
291
+		if (!empty($fields)) {
292
+					echo '
278 293
 			<div class="custom_fields_bottom">
279 294
 				<ul class="nolist">', $fields, '
280 295
 				</ul>
281 296
 			</div>';
297
+		}
282 298
 	}
283 299
 
284 300
 	echo '
@@ -287,30 +303,35 @@  discard block
 block discarded – undo
287 303
 		<div id="detailedinfo">
288 304
 			<dl class="settings">';
289 305
 
290
-	if ($context['user']['is_owner'] || $context['user']['is_admin'])
291
-		echo '
306
+	if ($context['user']['is_owner'] || $context['user']['is_admin']) {
307
+			echo '
292 308
 				<dt>', $txt['username'], ': </dt>
293 309
 				<dd>', $context['member']['username'], '</dd>';
310
+	}
294 311
 
295
-	if (!isset($context['disabled_fields']['posts']))
296
-		echo '
312
+	if (!isset($context['disabled_fields']['posts'])) {
313
+			echo '
297 314
 				<dt>', $txt['profile_posts'], ': </dt>
298 315
 				<dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>';
316
+	}
299 317
 
300
-	if ($context['member']['show_email'])
301
-		echo '
318
+	if ($context['member']['show_email']) {
319
+			echo '
302 320
 				<dt>', $txt['email'], ': </dt>
303 321
 				<dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>';
322
+	}
304 323
 
305
-	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title']))
306
-		echo '
324
+	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) {
325
+			echo '
307 326
 				<dt>', $txt['custom_title'], ': </dt>
308 327
 				<dd>', $context['member']['title'], '</dd>';
328
+	}
309 329
 
310
-	if (!empty($context['member']['blurb']))
311
-		echo '
330
+	if (!empty($context['member']['blurb'])) {
331
+			echo '
312 332
 				<dt>', $txt['personal_text'], ': </dt>
313 333
 				<dd>', $context['member']['blurb'], '</dd>';
334
+	}
314 335
 
315 336
 	echo '
316 337
 				<dt>', $txt['age'], ':</dt>
@@ -324,19 +345,21 @@  discard block
 block discarded – undo
324 345
 	{
325 346
 		$fields = array();
326 347
 
327
-		foreach ($context['print_custom_fields']['standard'] as $field)
328
-			if (!empty($field['output_html']))
348
+		foreach ($context['print_custom_fields']['standard'] as $field) {
349
+					if (!empty($field['output_html']))
329 350
 				$fields[] = $field;
351
+		}
330 352
 
331 353
 		if (count($fields) > 0)
332 354
 		{
333 355
 			echo '
334 356
 			<dl class="settings">';
335 357
 
336
-			foreach ($fields as $field)
337
-				echo '
358
+			foreach ($fields as $field) {
359
+							echo '
338 360
 				<dt>', $field['name'], ':</dt>
339 361
 				<dd>', $field['output_html'], '</dd>';
362
+			}
340 363
 
341 364
 			echo '
342 365
 			</dl>';
@@ -355,9 +378,10 @@  discard block
 block discarded – undo
355 378
 					<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>';
356 379
 
357 380
 		// Can we provide information on what this means?
358
-		if (!empty($context['warning_status']))
359
-			echo '
381
+		if (!empty($context['warning_status'])) {
382
+					echo '
360 383
 					<span class="smalltext">(', $context['warning_status'], ')</span>';
384
+		}
361 385
 
362 386
 		echo '
363 387
 				</dd>';
@@ -367,11 +391,12 @@  discard block
 block discarded – undo
367 391
 	if (!empty($context['activate_message']) || !empty($context['member']['bans']))
368 392
 	{
369 393
 		// If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves.
370
-		if (!empty($context['activate_message']))
371
-			echo '
394
+		if (!empty($context['activate_message'])) {
395
+					echo '
372 396
 				<dt class="clear">
373 397
 					<span class="alert">', $context['activate_message'], '</span> (<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>)
374 398
 				</dt>';
399
+		}
375 400
 
376 401
 		// If the current member is banned, show a message and possibly a link to the ban.
377 402
 		if (!empty($context['member']['bans']))
@@ -383,10 +408,11 @@  discard block
 block discarded – undo
383 408
 				<dt class="clear" id="ban_info" style="display: none;">
384 409
 					<strong>', $txt['user_banned_by_following'], ':</strong>';
385 410
 
386
-			foreach ($context['member']['bans'] as $ban)
387
-				echo '
411
+			foreach ($context['member']['bans'] as $ban) {
412
+							echo '
388 413
 					<br>
389 414
 					<span class="smalltext">', $ban['explanation'], '</span>';
415
+			}
390 416
 
391 417
 			echo '
392 418
 				</dt>';
@@ -400,30 +426,34 @@  discard block
 block discarded – undo
400 426
 	// If the person looking is allowed, they can check the members IP address and hostname.
401 427
 	if ($context['can_see_ip'])
402 428
 	{
403
-		if (!empty($context['member']['ip']))
404
-		echo '
429
+		if (!empty($context['member']['ip'])) {
430
+				echo '
405 431
 				<dt>', $txt['ip'], ': </dt>
406 432
 				<dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>';
433
+		}
407 434
 
408
-		if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip']))
409
-			echo '
435
+		if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) {
436
+					echo '
410 437
 				<dt>', $txt['hostname'], ': </dt>
411 438
 				<dd>', $context['member']['hostname'], '</dd>';
439
+		}
412 440
 	}
413 441
 
414 442
 	echo '
415 443
 				<dt>', $txt['local_time'], ':</dt>
416 444
 				<dd>', $context['member']['local_time'], '</dd>';
417 445
 
418
-	if (!empty($modSettings['userLanguage']) && !empty($context['member']['language']))
419
-		echo '
446
+	if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) {
447
+			echo '
420 448
 				<dt>', $txt['language'], ':</dt>
421 449
 				<dd>', $context['member']['language'], '</dd>';
450
+	}
422 451
 
423
-	if ($context['member']['show_last_login'])
424
-		echo '
452
+	if ($context['member']['show_last_login']) {
453
+			echo '
425 454
 				<dt>', $txt['lastLoggedIn'], ': </dt>
426 455
 				<dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>';
456
+	}
427 457
 
428 458
 	echo '
429 459
 			</dl>';
@@ -432,42 +462,47 @@  discard block
 block discarded – undo
432 462
 	if (!empty($context['print_custom_fields']['above_signature']))
433 463
 	{
434 464
 		$fields = '';
435
-		foreach ($context['print_custom_fields']['above_signature'] as $field)
436
-			if (!empty($field['output_html']))
465
+		foreach ($context['print_custom_fields']['above_signature'] as $field) {
466
+					if (!empty($field['output_html']))
437 467
 				$fields .= '
438 468
 					<li>' . $field['output_html'] . '</li>';
469
+		}
439 470
 
440
-		if (!empty($fields))
441
-			echo '
471
+		if (!empty($fields)) {
472
+					echo '
442 473
 			<div class="custom_fields_above_signature">
443 474
 				<ul class="nolist">', $fields, '
444 475
 				</ul>
445 476
 			</div>';
477
+		}
446 478
 	}
447 479
 
448 480
 	// Show the users signature.
449
-	if ($context['signature_enabled'] && !empty($context['member']['signature']))
450
-		echo '
481
+	if ($context['signature_enabled'] && !empty($context['member']['signature'])) {
482
+			echo '
451 483
 			<div class="signature">
452 484
 				<h5>', $txt['signature'], ':</h5>
453 485
 				', $context['member']['signature'], '
454 486
 			</div>';
487
+	}
455 488
 
456 489
 	// Are there any custom profile fields for below the signature?
457 490
 	if (!empty($context['print_custom_fields']['below_signature']))
458 491
 	{
459 492
 		$fields = '';
460
-		foreach ($context['print_custom_fields']['below_signature'] as $field)
461
-			if (!empty($field['output_html']))
493
+		foreach ($context['print_custom_fields']['below_signature'] as $field) {
494
+					if (!empty($field['output_html']))
462 495
 				$fields .=  '
463 496
 					<li>' . $field['output_html'] . '</li>';
497
+		}
464 498
 
465
-		if (!empty($fields))
466
-			echo '
499
+		if (!empty($fields)) {
500
+					echo '
467 501
 			<div class="custom_fields_below_signature">
468 502
 				<ul class="nolist">', $fields, '
469 503
 				</ul>
470 504
 			</div>';
505
+		}
471 506
 	}
472 507
 
473 508
 	echo '
@@ -509,62 +544,70 @@  discard block
 block discarded – undo
509 544
 			</div>
510 545
 			<div class="list_posts">';
511 546
 
512
-			if (!$post['approved'])
513
-				echo '
547
+			if (!$post['approved']) {
548
+							echo '
514 549
 				<div class="approve_post">
515 550
 					<em>', $txt['post_awaiting_approval'], '</em>
516 551
 				</div>';
552
+			}
517 553
 
518 554
 			echo '
519 555
 				', $post['body'], '
520 556
 			</div>';
521 557
 
522
-			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
523
-				echo '
558
+			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
559
+							echo '
524 560
 			<div class="floatright">
525 561
 				<ul class="quickbuttons">';
562
+			}
526 563
 
527 564
 			// If they *can* reply?
528
-			if ($post['can_reply'])
529
-				echo '
565
+			if ($post['can_reply']) {
566
+							echo '
530 567
 					<li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>';
568
+			}
531 569
 
532 570
 			// If they *can* quote?
533
-			if ($post['can_quote'])
534
-				echo '
571
+			if ($post['can_quote']) {
572
+							echo '
535 573
 					<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>';
574
+			}
536 575
 
537 576
 			// How about... even... remove it entirely?!
538
-			if ($post['can_delete'])
539
-				echo '
577
+			if ($post['can_delete']) {
578
+							echo '
540 579
 					<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>';
580
+			}
541 581
 
542
-			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
543
-				echo '
582
+			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
583
+							echo '
544 584
 				</ul>
545 585
 			</div><!-- .floatright -->';
586
+			}
546 587
 
547 588
 			echo '
548 589
 		</div><!-- $post[css_class] -->';
549 590
 		}
591
+	} else {
592
+			template_show_list('attachments');
550 593
 	}
551
-	else
552
-		template_show_list('attachments');
553 594
 
554 595
 	// No posts? Just end with a informative message.
555
-	if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts'])))
556
-		echo '
596
+	if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) {
597
+			echo '
557 598
 		<div class="windowbg">
558 599
 			', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), '
559 600
 		</div>';
601
+	}
560 602
 
561 603
 	// Show more page numbers.
562
-	if (!empty($context['page_index']))
563
-		echo '
604
+	if (!empty($context['page_index'])) {
605
+			echo '
564 606
 		<div class="pagesection">
565 607
 			<div class="pagelinks">', $context['page_index'], '</div>
566 608
 		</div>';
567
-}
609
+	}
610
+	}
568 611
 
569 612
 /**
570 613
  * Template for showing alerts within the alerts popup
@@ -574,11 +617,12 @@  discard block
 block discarded – undo
574 617
 	global $context, $txt, $scripturl;
575 618
 
576 619
 	// Do we have an update message?
577
-	if (!empty($context['update_message']))
578
-		echo '
620
+	if (!empty($context['update_message'])) {
621
+			echo '
579 622
 		<div class="infobox">
580 623
 			', $context['update_message'], '
581 624
 		</div>';
625
+	}
582 626
 
583 627
 	echo '
584 628
 		<div class="cat_bar">
@@ -587,18 +631,18 @@  discard block
 block discarded – undo
587 631
 			</h3>
588 632
 		</div>';
589 633
 
590
-	if (empty($context['alerts']))
591
-		echo '
634
+	if (empty($context['alerts'])) {
635
+			echo '
592 636
 		<div class="information">
593 637
 			', $txt['alerts_none'], '
594 638
 		</div>';
595
-
596
-	else
639
+	} else
597 640
 	{
598 641
 		// Start the form if checkboxes are in use
599
-		if ($context['showCheckboxes'])
600
-			echo '
642
+		if ($context['showCheckboxes']) {
643
+					echo '
601 644
 		<form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;save" method="post" accept-charset="', $context['character_set'], '" id="mark_all">';
645
+		}
602 646
 
603 647
 		echo '
604 648
 			<table id="alerts" class="table_grid">';
@@ -614,9 +658,10 @@  discard block
 block discarded – undo
614 658
 							<li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=remove;aid=', $id, ';', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'], '</a></li>
615 659
 							<li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=', ($alert['is_read'] != 0 ? 'unread' : 'read'), ';aid=', $id, ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons ', $alert['is_read'] != 0 ? 'unread_button' : 'read_button', '"></span>', ($alert['is_read'] != 0 ? $txt['mark_unread'] : $txt['mark_read_short']), '</a></li>';
616 660
 
617
-					if ($context['showCheckboxes'])
618
-						echo '
661
+					if ($context['showCheckboxes']) {
662
+											echo '
619 663
 							<li><input type="checkbox" name="mark[', $id, ']" value="', $id, '"></li>';
664
+					}
620 665
 
621 666
 			echo '
622 667
 						</ul>
@@ -631,8 +676,8 @@  discard block
 block discarded – undo
631 676
 					', $context['pagination'], '
632 677
 				</div>';
633 678
 
634
-		if ($context['showCheckboxes'])
635
-			echo '
679
+		if ($context['showCheckboxes']) {
680
+					echo '
636 681
 				<div class="floatright">
637 682
 					', $txt['check_all'], ': <input type="checkbox" name="select_all" id="select_all">
638 683
 					<select name="mark_as">
@@ -643,14 +688,16 @@  discard block
 block discarded – undo
643 688
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
644 689
 					<input type="submit" name="req" value="', $txt['quick_mod_go'], '" class="button you_sure">
645 690
 				</div>';
691
+		}
646 692
 
647 693
 	echo '
648 694
 			</div>';
649 695
 
650
-	if ($context['showCheckboxes'])
651
-		echo '
696
+	if ($context['showCheckboxes']) {
697
+			echo '
652 698
 		</form>';
653 699
 	}
700
+	}
654 701
 }
655 702
 
656 703
 /**
@@ -671,12 +718,12 @@  discard block
 block discarded – undo
671 718
 		</div>' : '';
672 719
 
673 720
 	// No drafts? Just show an informative message.
674
-	if (empty($context['drafts']))
675
-		echo '
721
+	if (empty($context['drafts'])) {
722
+			echo '
676 723
 		<div class="windowbg centertext">
677 724
 			', $txt['draft_none'], '
678 725
 		</div>';
679
-	else
726
+	} else
680 727
 	{
681 728
 		// For every draft to be displayed, give it its own div, and show the important details of the draft.
682 729
 		foreach ($context['drafts'] as $draft)
@@ -688,13 +735,15 @@  discard block
 block discarded – undo
688 735
 				<h5>
689 736
 					<strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> &nbsp; &nbsp;';
690 737
 
691
-			if (!empty($draft['sticky']))
692
-				echo '
738
+			if (!empty($draft['sticky'])) {
739
+							echo '
693 740
 					<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>';
741
+			}
694 742
 
695
-			if (!empty($draft['locked']))
696
-				echo '
743
+			if (!empty($draft['locked'])) {
744
+							echo '
697 745
 					<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>';
746
+			}
698 747
 
699 748
 			echo '
700 749
 				</h5>
@@ -727,13 +776,13 @@  discard block
 block discarded – undo
727 776
 {
728 777
 	global $context, $scripturl, $txt;
729 778
 
730
-	if (!empty($context['saved_successful']))
731
-		echo '
779
+	if (!empty($context['saved_successful'])) {
780
+			echo '
732 781
 	<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
733
-
734
-	elseif (!empty($context['saved_failed']))
735
-		echo '
782
+	} elseif (!empty($context['saved_failed'])) {
783
+			echo '
736 784
 	<div class="errorbox">', $context['saved_failed'], '</div>';
785
+	}
737 786
 
738 787
 	echo '
739 788
 	<div id="edit_buddies">
@@ -748,14 +797,16 @@  discard block
 block discarded – undo
748 797
 					<th scope="col" class="quarter_table">', $txt['name'], '</th>
749 798
 					<th scope="col">', $txt['status'], '</th>';
750 799
 
751
-	if (allowedTo('moderate_forum'))
752
-		echo '
800
+	if (allowedTo('moderate_forum')) {
801
+			echo '
753 802
 					<th scope="col">', $txt['email'], '</th>';
803
+	}
754 804
 
755
-	if (!empty($context['custom_pf']))
756
-		foreach ($context['custom_pf'] as $column)
805
+	if (!empty($context['custom_pf'])) {
806
+			foreach ($context['custom_pf'] as $column)
757 807
 				echo '
758 808
 					<th scope="col">', $column['label'], '</th>';
809
+	}
759 810
 
760 811
 	echo '
761 812
 					<th scope="col">', $txt['remove'], '</th>
@@ -764,13 +815,14 @@  discard block
 block discarded – undo
764 815
 			<tbody>';
765 816
 
766 817
 	// If they don't have any buddies don't list them!
767
-	if (empty($context['buddies']))
768
-		echo '
818
+	if (empty($context['buddies'])) {
819
+			echo '
769 820
 				<tr class="windowbg">
770 821
 					<td colspan="', allowedTo('moderate_forum') ? '10' : '9', '">
771 822
 						<strong>', $txt['no_buddies'], '</strong>
772 823
 					</td>
773 824
 				</tr>';
825
+	}
774 826
 
775 827
 		// Now loop through each buddy showing info on each.
776 828
 	else
@@ -784,17 +836,19 @@  discard block
 block discarded – undo
784 836
 						<a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a>
785 837
 					</td>';
786 838
 
787
-			if ($buddy['show_email'])
788
-				echo '
839
+			if ($buddy['show_email']) {
840
+							echo '
789 841
 					<td>
790 842
 						<a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a>
791 843
 					</td>';
844
+			}
792 845
 
793 846
 			// Show the custom profile fields for this user.
794
-			if (!empty($context['custom_pf']))
795
-				foreach ($context['custom_pf'] as $key => $column)
847
+			if (!empty($context['custom_pf'])) {
848
+							foreach ($context['custom_pf'] as $key => $column)
796 849
 					echo '
797 850
 					<td class="lefttext">', $buddy['options'][$key], '</td>';
851
+			}
798 852
 
799 853
 			echo '
800 854
 					<td>
@@ -827,9 +881,10 @@  discard block
 block discarded – undo
827 881
 			</dl>
828 882
 		</div>';
829 883
 
830
-	if (!empty($context['token_check']))
831
-		echo '
884
+	if (!empty($context['token_check'])) {
885
+			echo '
832 886
 		<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
887
+	}
833 888
 
834 889
 	echo '
835 890
 		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -855,13 +910,13 @@  discard block
 block discarded – undo
855 910
 {
856 911
 	global $context, $scripturl, $txt;
857 912
 
858
-	if (!empty($context['saved_successful']))
859
-		echo '
913
+	if (!empty($context['saved_successful'])) {
914
+			echo '
860 915
 	<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
861
-
862
-	elseif (!empty($context['saved_failed']))
863
-		echo '
916
+	} elseif (!empty($context['saved_failed'])) {
917
+			echo '
864 918
 	<div class="errorbox">', $context['saved_failed'], '</div>';
919
+	}
865 920
 
866 921
 	echo '
867 922
 	<div id="edit_buddies">
@@ -876,9 +931,10 @@  discard block
 block discarded – undo
876 931
 					<th scope="col" class="quarter_table">', $txt['name'], '</th>
877 932
 					<th scope="col">', $txt['status'], '</th>';
878 933
 
879
-	if (allowedTo('moderate_forum'))
880
-		echo '
934
+	if (allowedTo('moderate_forum')) {
935
+			echo '
881 936
 					<th scope="col">', $txt['email'], '</th>';
937
+	}
882 938
 
883 939
 	echo '
884 940
 					<th scope="col">', $txt['ignore_remove'], '</th>
@@ -887,13 +943,14 @@  discard block
 block discarded – undo
887 943
 			<tbody>';
888 944
 
889 945
 	// If they don't have anyone on their ignore list, don't list it!
890
-	if (empty($context['ignore_list']))
891
-		echo '
946
+	if (empty($context['ignore_list'])) {
947
+			echo '
892 948
 				<tr class="windowbg">
893 949
 					<td colspan="', allowedTo('moderate_forum') ? '4' : '3', '">
894 950
 						<strong>', $txt['no_ignore'], '</strong>
895 951
 					</td>
896 952
 				</tr>';
953
+	}
897 954
 
898 955
 	// Now loop through each buddy showing info on each.
899 956
 	foreach ($context['ignore_list'] as $member)
@@ -905,11 +962,12 @@  discard block
 block discarded – undo
905 962
 						<a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a>
906 963
 					</td>';
907 964
 
908
-		if ($member['show_email'])
909
-			echo '
965
+		if ($member['show_email']) {
966
+					echo '
910 967
 					<td>
911 968
 						<a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a>
912 969
 					</td>';
970
+		}
913 971
 		echo '
914 972
 					<td>
915 973
 						<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>
@@ -939,9 +997,10 @@  discard block
 block discarded – undo
939 997
 			</dl>
940 998
 		</div>';
941 999
 
942
-	if (!empty($context['token_check']))
943
-		echo '
1000
+	if (!empty($context['token_check'])) {
1001
+			echo '
944 1002
 		<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
1003
+	}
945 1004
 
946 1005
 	echo '
947 1006
 		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -987,9 +1046,10 @@  discard block
 block discarded – undo
987 1046
 					<a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>';
988 1047
 
989 1048
 	// Second address detected?
990
-	if (!empty($context['last_ip2']))
991
-		echo '
1049
+	if (!empty($context['last_ip2'])) {
1050
+			echo '
992 1051
 					, <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>';
1052
+	}
993 1053
 
994 1054
 	echo '
995 1055
 				</dd>';
@@ -1055,9 +1115,10 @@  discard block
 block discarded – undo
1055 1115
 		</div>
1056 1116
 		<div class="windowbg">';
1057 1117
 
1058
-		foreach ($context['whois_servers'] as $server)
1059
-			echo '
1118
+		foreach ($context['whois_servers'] as $server) {
1119
+					echo '
1060 1120
 			<a href="', $server['url'], '" target="_blank" rel="noopener"', '>', $server['name'], '</a><br>';
1121
+		}
1061 1122
 		echo '
1062 1123
 		</div>
1063 1124
 		<br>';
@@ -1069,13 +1130,12 @@  discard block
 block discarded – undo
1069 1130
 			<h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3>
1070 1131
 		</div>';
1071 1132
 
1072
-	if (empty($context['ips']))
1073
-		echo '
1133
+	if (empty($context['ips'])) {
1134
+			echo '
1074 1135
 		<p class="windowbg description">
1075 1136
 			<em>', $txt['no_members_from_ip'], '</em>
1076 1137
 		</p>';
1077
-
1078
-	else
1138
+	} else
1079 1139
 	{
1080 1140
 		echo '
1081 1141
 		<table class="table_grid">
@@ -1088,12 +1148,13 @@  discard block
 block discarded – undo
1088 1148
 			<tbody>';
1089 1149
 
1090 1150
 		// Loop through each of the members and display them.
1091
-		foreach ($context['ips'] as $ip => $memberlist)
1092
-			echo '
1151
+		foreach ($context['ips'] as $ip => $memberlist) {
1152
+					echo '
1093 1153
 				<tr class="windowbg">
1094 1154
 					<td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td>
1095 1155
 					<td>', implode(', ', $memberlist), '</td>
1096 1156
 				</tr>';
1157
+		}
1097 1158
 
1098 1159
 		echo '
1099 1160
 			</tbody>
@@ -1135,11 +1196,10 @@  discard block
 block discarded – undo
1135 1196
 			</h3>
1136 1197
 		</div>';
1137 1198
 
1138
-	if ($context['member']['has_all_permissions'])
1139
-		echo '
1199
+	if ($context['member']['has_all_permissions']) {
1200
+			echo '
1140 1201
 		<div class="information">', $txt['showPermissions_all'], '</div>';
1141
-
1142
-	else
1202
+	} else
1143 1203
 	{
1144 1204
 		echo '
1145 1205
 		<div class="information">',$txt['showPermissions_help'], '</div>
@@ -1154,9 +1214,10 @@  discard block
 block discarded – undo
1154 1214
 			<div class="windowbg smalltext">
1155 1215
 				', $txt['showPermissions_restricted_boards_desc'], ':<br>';
1156 1216
 
1157
-			foreach ($context['no_access_boards'] as $no_access_board)
1158
-				echo '
1217
+			foreach ($context['no_access_boards'] as $no_access_board) {
1218
+							echo '
1159 1219
 				<a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', ';
1220
+			}
1160 1221
 			echo '
1161 1222
 			</div>';
1162 1223
 		}
@@ -1188,12 +1249,13 @@  discard block
 block discarded – undo
1188 1249
 							</td>
1189 1250
 							<td class="smalltext">';
1190 1251
 
1191
-				if ($permission['is_denied'])
1192
-					echo '
1252
+				if ($permission['is_denied']) {
1253
+									echo '
1193 1254
 								<span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>';
1194
-				else
1195
-					echo '
1255
+				} else {
1256
+									echo '
1196 1257
 								', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']);
1258
+				}
1197 1259
 
1198 1260
 				echo '
1199 1261
 							</td>
@@ -1204,10 +1266,10 @@  discard block
 block discarded – undo
1204 1266
 				</table>
1205 1267
 			</div><!-- .tborder -->
1206 1268
 			<br>';
1207
-		}
1208
-		else
1209
-			echo '
1269
+		} else {
1270
+					echo '
1210 1271
 			<p class="windowbg">', $txt['showPermissions_none_general'], '</p>';
1272
+		}
1211 1273
 
1212 1274
 		// Board permission section.
1213 1275
 		echo '
@@ -1218,14 +1280,16 @@  discard block
 block discarded – undo
1218 1280
 						<select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();">
1219 1281
 							<option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], '</option>';
1220 1282
 
1221
-		if (!empty($context['boards']))
1222
-			echo '
1283
+		if (!empty($context['boards'])) {
1284
+					echo '
1223 1285
 							<option value="" disabled>---------------------------</option>';
1286
+		}
1224 1287
 
1225 1288
 		// Fill the box with any local permission boards.
1226
-		foreach ($context['boards'] as $board)
1227
-			echo '
1289
+		foreach ($context['boards'] as $board) {
1290
+					echo '
1228 1291
 							<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>';
1292
+		}
1229 1293
 
1230 1294
 		echo '
1231 1295
 						</select>
@@ -1254,13 +1318,13 @@  discard block
 block discarded – undo
1254 1318
 						</td>
1255 1319
 						<td class="smalltext">';
1256 1320
 
1257
-				if ($permission['is_denied'])
1258
-					echo '
1321
+				if ($permission['is_denied']) {
1322
+									echo '
1259 1323
 							<span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>';
1260
-
1261
-				else
1262
-					echo '
1324
+				} else {
1325
+									echo '
1263 1326
 							', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']);
1327
+				}
1264 1328
 
1265 1329
 				echo '
1266 1330
 						</td>
@@ -1269,10 +1333,10 @@  discard block
 block discarded – undo
1269 1333
 			echo '
1270 1334
 				</tbody>
1271 1335
 			</table>';
1272
-		}
1273
-		else
1274
-			echo '
1336
+		} else {
1337
+					echo '
1275 1338
 			<p class="windowbg">', $txt['showPermissions_none_board'], '</p>';
1339
+		}
1276 1340
 	echo '
1277 1341
 		</div><!-- #permissions -->';
1278 1342
 	}
@@ -1313,9 +1377,10 @@  discard block
 block discarded – undo
1313 1377
 			</div>';
1314 1378
 
1315 1379
 	// If they haven't post at all, don't draw the graph.
1316
-	if (empty($context['posts_by_time']))
1317
-		echo '
1380
+	if (empty($context['posts_by_time'])) {
1381
+			echo '
1318 1382
 			<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1383
+	}
1319 1384
 
1320 1385
 	// Otherwise do!
1321 1386
 	else
@@ -1324,8 +1389,8 @@  discard block
 block discarded – undo
1324 1389
 			<ul class="activity_stats flow_hidden">';
1325 1390
 
1326 1391
 		// The labels.
1327
-		foreach ($context['posts_by_time'] as $time_of_day)
1328
-			echo '
1392
+		foreach ($context['posts_by_time'] as $time_of_day) {
1393
+					echo '
1329 1394
 				<li>
1330 1395
 					<div class="generic_bar vertical">
1331 1396
 						<div class="bar" style="height: ', (int) $time_of_day['relative_percent'], '%;">
@@ -1334,6 +1399,7 @@  discard block
 block discarded – undo
1334 1399
 					</div>
1335 1400
 					<span class="stats_hour">', $time_of_day['hour_format'], '</span>
1336 1401
 				</li>';
1402
+		}
1337 1403
 
1338 1404
 		echo '
1339 1405
 			</ul>';
@@ -1352,11 +1418,10 @@  discard block
 block discarded – undo
1352 1418
 					</h3>
1353 1419
 				</div>';
1354 1420
 
1355
-	if (empty($context['popular_boards']))
1356
-		echo '
1421
+	if (empty($context['popular_boards'])) {
1422
+			echo '
1357 1423
 				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1358
-
1359
-	else
1424
+	} else
1360 1425
 	{
1361 1426
 		echo '
1362 1427
 				<dl class="stats">';
@@ -1386,10 +1451,10 @@  discard block
 block discarded – undo
1386 1451
 					</h3>
1387 1452
 				</div>';
1388 1453
 
1389
-	if (empty($context['board_activity']))
1390
-		echo '
1454
+	if (empty($context['board_activity'])) {
1455
+			echo '
1391 1456
 				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1392
-	else
1457
+	} else
1393 1458
 	{
1394 1459
 		echo '
1395 1460
 				<dl class="stats">';
@@ -1440,90 +1505,97 @@  discard block
 block discarded – undo
1440 1505
 				<h3 class="catbg profile_hd">';
1441 1506
 
1442 1507
 		// Don't say "Profile" if this isn't the profile...
1443
-		if (!empty($context['profile_header_text']))
1444
-			echo '
1508
+		if (!empty($context['profile_header_text'])) {
1509
+					echo '
1445 1510
 					', $context['profile_header_text'];
1446
-		else
1447
-			echo '
1511
+		} else {
1512
+					echo '
1448 1513
 					', $txt['profile'];
1514
+		}
1449 1515
 
1450 1516
 		echo '
1451 1517
 				</h3>
1452 1518
 			</div>';
1453 1519
 
1454 1520
 	// Have we some description?
1455
-	if ($context['page_desc'])
1456
-		echo '
1521
+	if ($context['page_desc']) {
1522
+			echo '
1457 1523
 			<p class="information">', $context['page_desc'], '</p>';
1524
+	}
1458 1525
 
1459 1526
 	echo '
1460 1527
 			<div class="roundframe">';
1461 1528
 
1462 1529
 	// Any bits at the start?
1463
-	if (!empty($context['profile_prehtml']))
1464
-		echo '
1530
+	if (!empty($context['profile_prehtml'])) {
1531
+			echo '
1465 1532
 				<div>', $context['profile_prehtml'], '</div>';
1533
+	}
1466 1534
 
1467
-	if (!empty($context['profile_fields']))
1468
-		echo '
1535
+	if (!empty($context['profile_fields'])) {
1536
+			echo '
1469 1537
 				<dl class="settings">';
1538
+	}
1470 1539
 
1471 1540
 	// Start the big old loop 'of love.
1472 1541
 	$lastItem = 'hr';
1473 1542
 	foreach ($context['profile_fields'] as $key => $field)
1474 1543
 	{
1475 1544
 		// We add a little hack to be sure we never get more than one hr in a row!
1476
-		if ($lastItem == 'hr' && $field['type'] == 'hr')
1477
-			continue;
1545
+		if ($lastItem == 'hr' && $field['type'] == 'hr') {
1546
+					continue;
1547
+		}
1478 1548
 
1479 1549
 		$lastItem = $field['type'];
1480
-		if ($field['type'] == 'hr')
1481
-			echo '
1550
+		if ($field['type'] == 'hr') {
1551
+					echo '
1482 1552
 				</dl>
1483 1553
 				<hr>
1484 1554
 				<dl class="settings">';
1485
-
1486
-		elseif ($field['type'] == 'callback')
1555
+		} elseif ($field['type'] == 'callback')
1487 1556
 		{
1488 1557
 			if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func']))
1489 1558
 			{
1490 1559
 				$callback_func = 'template_profile_' . $field['callback_func'];
1491 1560
 				$callback_func();
1492 1561
 			}
1493
-		}
1494
-		else
1562
+		} else
1495 1563
 		{
1496 1564
 			echo '
1497 1565
 					<dt>
1498 1566
 						<strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>';
1499 1567
 
1500 1568
 			// Does it have any subtext to show?
1501
-			if (!empty($field['subtext']))
1502
-				echo '
1569
+			if (!empty($field['subtext'])) {
1570
+							echo '
1503 1571
 						<br>
1504 1572
 						<span class="smalltext">', $field['subtext'], '</span>';
1573
+			}
1505 1574
 
1506 1575
 			echo '
1507 1576
 					</dt>
1508 1577
 					<dd>';
1509 1578
 
1510 1579
 			// Want to put something infront of the box?
1511
-			if (!empty($field['preinput']))
1512
-				echo '
1580
+			if (!empty($field['preinput'])) {
1581
+							echo '
1513 1582
 						', $field['preinput'];
1583
+			}
1514 1584
 
1515 1585
 			// What type of data are we showing?
1516
-			if ($field['type'] == 'label')
1517
-				echo '
1586
+			if ($field['type'] == 'label') {
1587
+							echo '
1518 1588
 						', $field['value'];
1589
+			}
1519 1590
 
1520 1591
 			// Maybe it's a text box - very likely!
1521 1592
 			elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url')))
1522 1593
 			{
1523
-				if ($field['type'] == 'int' || $field['type'] == 'float')
1524
-					$type = 'number';
1525
-				else
1526
-					$type = $field['type'];
1594
+				if ($field['type'] == 'int' || $field['type'] == 'float') {
1595
+									$type = 'number';
1596
+				} else {
1597
+									$type = $field['type'];
1598
+				}
1527 1599
 				$step = $field['type'] == 'float' ? ' step="0.1"' : '';
1528 1600
 
1529 1601
 
@@ -1531,10 +1603,11 @@  discard block
 block discarded – undo
1531 1603
 						<input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' ', $step, '>';
1532 1604
 			}
1533 1605
 			// You "checking" me out? ;)
1534
-			elseif ($field['type'] == 'check')
1535
-				echo '
1606
+			elseif ($field['type'] == 'check') {
1607
+							echo '
1536 1608
 						<input type="hidden" name="', $key, '" value="0">
1537 1609
 						<input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" ', $field['input_attr'], '>';
1610
+			}
1538 1611
 
1539 1612
 			// Always fun - select boxes!
1540 1613
 			elseif ($field['type'] == 'select')
@@ -1545,14 +1618,16 @@  discard block
 block discarded – undo
1545 1618
 				if (isset($field['options']))
1546 1619
 				{
1547 1620
 					// Is this some code to generate the options?
1548
-					if (!is_array($field['options']))
1549
-						$field['options'] = $field['options']();
1621
+					if (!is_array($field['options'])) {
1622
+											$field['options'] = $field['options']();
1623
+					}
1550 1624
 
1551 1625
 					// Assuming we now have some!
1552
-					if (is_array($field['options']))
1553
-						foreach ($field['options'] as $value => $name)
1626
+					if (is_array($field['options'])) {
1627
+											foreach ($field['options'] as $value => $name)
1554 1628
 							echo '
1555 1629
 							<option', is_numeric($value) ? ' value="" disabled' : ' value="' . $value . '"', $value === $field['value'] ? ' selected' : '', '>', $name, '</option>';
1630
+					}
1556 1631
 				}
1557 1632
 
1558 1633
 				echo '
@@ -1560,31 +1635,34 @@  discard block
 block discarded – undo
1560 1635
 			}
1561 1636
 
1562 1637
 			// Something to end with?
1563
-			if (!empty($field['postinput']))
1564
-				echo '
1638
+			if (!empty($field['postinput'])) {
1639
+							echo '
1565 1640
 						', $field['postinput'];
1641
+			}
1566 1642
 
1567 1643
 			echo '
1568 1644
 					</dd>';
1569 1645
 		}
1570 1646
 	}
1571 1647
 
1572
-	if (!empty($context['profile_fields']))
1573
-		echo '
1648
+	if (!empty($context['profile_fields'])) {
1649
+			echo '
1574 1650
 				</dl>';
1651
+	}
1575 1652
 
1576 1653
 	// Are there any custom profile fields - if so print them!
1577 1654
 	if (!empty($context['custom_fields']))
1578 1655
 	{
1579
-		if ($lastItem != 'hr')
1580
-			echo '
1656
+		if ($lastItem != 'hr') {
1657
+					echo '
1581 1658
 				<hr>';
1659
+		}
1582 1660
 
1583 1661
 		echo '
1584 1662
 				<dl class="settings">';
1585 1663
 
1586
-		foreach ($context['custom_fields'] as $field)
1587
-			echo '
1664
+		foreach ($context['custom_fields'] as $field) {
1665
+					echo '
1588 1666
 					<dt>
1589 1667
 						<strong>', $field['name'], ': </strong><br>
1590 1668
 						<span class="smalltext">', $field['desc'], '</span>
@@ -1592,19 +1670,21 @@  discard block
 block discarded – undo
1592 1670
 					<dd>
1593 1671
 						', $field['input_html'], '
1594 1672
 					</dd>';
1673
+		}
1595 1674
 
1596 1675
 		echo '
1597 1676
 				</dl>';
1598 1677
 	}
1599 1678
 
1600 1679
 	// Any closing HTML?
1601
-	if (!empty($context['profile_posthtml']))
1602
-		echo '
1680
+	if (!empty($context['profile_posthtml'])) {
1681
+			echo '
1603 1682
 				<div>', $context['profile_posthtml'], '</div>';
1683
+	}
1604 1684
 
1605 1685
 	// Only show the password box if it's actually needed.
1606
-	if ($context['require_password'])
1607
-		echo '
1686
+	if ($context['require_password']) {
1687
+			echo '
1608 1688
 				<dl class="settings">
1609 1689
 					<dt>
1610 1690
 						<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br>
@@ -1614,18 +1694,21 @@  discard block
 block discarded – undo
1614 1694
 						<input type="password" name="oldpasswrd" id="oldpasswrd" size="20">
1615 1695
 					</dd>
1616 1696
 				</dl>';
1697
+	}
1617 1698
 
1618 1699
 	// The button shouldn't say "Change profile" unless we're changing the profile...
1619
-	if (!empty($context['submit_button_text']))
1620
-		echo '
1700
+	if (!empty($context['submit_button_text'])) {
1701
+			echo '
1621 1702
 				<input type="submit" name="save" value="', $context['submit_button_text'], '" class="button floatright">';
1622
-	else
1623
-		echo '
1703
+	} else {
1704
+			echo '
1624 1705
 				<input type="submit" name="save" value="', $txt['change_profile'], '" class="button floatright">';
1706
+	}
1625 1707
 
1626
-	if (!empty($context['token_check']))
1627
-		echo '
1708
+	if (!empty($context['token_check'])) {
1709
+			echo '
1628 1710
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
1711
+	}
1629 1712
 
1630 1713
 	echo '
1631 1714
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -1635,10 +1718,11 @@  discard block
 block discarded – undo
1635 1718
 		</form>';
1636 1719
 
1637 1720
 	// Any final spellchecking stuff?
1638
-	if (!empty($context['show_spellchecking']))
1639
-		echo '
1721
+	if (!empty($context['show_spellchecking'])) {
1722
+			echo '
1640 1723
 		<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>';
1641
-}
1724
+	}
1725
+	}
1642 1726
 
1643 1727
 /**
1644 1728
  * Personal Message settings.
@@ -1675,10 +1759,11 @@  discard block
 block discarded – undo
1675 1759
 						<select name="pm_receive_from" id="pm_receive_from">
1676 1760
 							<option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>';
1677 1761
 
1678
-	if (!empty($modSettings['enable_buddylist']))
1679
-		echo '
1762
+	if (!empty($modSettings['enable_buddylist'])) {
1763
+			echo '
1680 1764
 							<option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option>
1681 1765
 							<option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>';
1766
+	}
1682 1767
 
1683 1768
 	echo '
1684 1769
 							<option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option>
@@ -1721,11 +1806,12 @@  discard block
 block discarded – undo
1721 1806
 		if (empty($setting) || !is_array($setting))
1722 1807
 		{
1723 1808
 			// Insert a separator (unless this is the first item in the list)
1724
-			if ($i !== $first_option_key)
1725
-				echo '
1809
+			if ($i !== $first_option_key) {
1810
+							echo '
1726 1811
 				</dl>
1727 1812
 				<hr>
1728 1813
 				<dl class="settings">';
1814
+			}
1729 1815
 
1730 1816
 			// Should we give a name to this section?
1731 1817
 			if (is_string($setting) && !empty($setting))
@@ -1734,69 +1820,67 @@  discard block
 block discarded – undo
1734 1820
 				echo '
1735 1821
 					<dt><strong>' . $setting . '</strong></dt>
1736 1822
 					<dd></dd>';
1823
+			} else {
1824
+							$titled_section = false;
1737 1825
 			}
1738
-			else
1739
-				$titled_section = false;
1740 1826
 
1741 1827
 			continue;
1742 1828
 		}
1743 1829
 
1744 1830
 		// Is this disabled?
1745
-		if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled']))
1746
-			continue;
1747
-
1748
-		elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage']))
1749
-			continue;
1750
-
1751
-		elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored']))
1752
-			continue;
1753
-
1754
-		elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist']))
1755
-			continue;
1756
-
1757
-		elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg']))
1758
-			continue;
1759
-
1760
-		elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled']))))
1761
-			continue;
1762
-
1763
-		elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled']))))
1764
-			continue;
1831
+		if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) {
1832
+					continue;
1833
+		} elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) {
1834
+					continue;
1835
+		} elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) {
1836
+					continue;
1837
+		} elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) {
1838
+					continue;
1839
+		} elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) {
1840
+					continue;
1841
+		} elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) {
1842
+					continue;
1843
+		} elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) {
1844
+					continue;
1845
+		}
1765 1846
 
1766 1847
 		// Some of these may not be set...  Set to defaults here
1767 1848
 		$opts = array('topics_per_page', 'messages_per_page', 'display_quick_mod');
1768
-		if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']]))
1769
-			$context['member']['options'][$setting['id']] = 0;
1770
-
1771
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
1772
-			$setting['type'] = 'checkbox';
1773
-
1774
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
1775
-			$setting['type'] = 'number';
1849
+		if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) {
1850
+					$context['member']['options'][$setting['id']] = 0;
1851
+		}
1776 1852
 
1777
-		elseif ($setting['type'] == 'string')
1778
-			$setting['type'] = 'text';
1853
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
1854
+					$setting['type'] = 'checkbox';
1855
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
1856
+					$setting['type'] = 'number';
1857
+		} elseif ($setting['type'] == 'string') {
1858
+					$setting['type'] = 'text';
1859
+		}
1779 1860
 
1780
-		if (isset($setting['options']))
1781
-			$setting['type'] = 'list';
1861
+		if (isset($setting['options'])) {
1862
+					$setting['type'] = 'list';
1863
+		}
1782 1864
 
1783 1865
 		echo '
1784 1866
 					<dt>
1785 1867
 						<label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>';
1786 1868
 
1787
-		if (isset($setting['description']))
1788
-			echo '
1869
+		if (isset($setting['description'])) {
1870
+					echo '
1789 1871
 						<br>
1790 1872
 						<span class="smalltext">', $setting['description'], '</span>';
1873
+		}
1791 1874
 		echo '
1792 1875
 					</dt>
1793 1876
 					<dd>';
1794 1877
 
1795 1878
 		// Display checkbox options
1796
-		if ($setting['type'] == 'checkbox')
1797
-			echo '
1879
+		if ($setting['type'] == 'checkbox') {
1880
+					echo '
1798 1881
 						<input type="hidden" name="default_options[' . $setting['id'] . ']" value="0">
1799 1882
 						<input type="checkbox" name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', !empty($context['member']['options'][$setting['id']]) ? ' checked' : '', ' value="1">';
1883
+		}
1800 1884
 
1801 1885
 		// How about selection lists, we all love them
1802 1886
 		elseif ($setting['type'] == 'list')
@@ -1804,9 +1888,10 @@  discard block
 block discarded – undo
1804 1888
 			echo '
1805 1889
 						<select name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', '>';
1806 1890
 
1807
-			foreach ($setting['options'] as $value => $label)
1808
-				echo '
1891
+			foreach ($setting['options'] as $value => $label) {
1892
+							echo '
1809 1893
 							<option value="', $value, '"', $value == $context['member']['options'][$setting['id']] ? ' selected' : '', '>', $label, '</option>';
1894
+			}
1810 1895
 
1811 1896
 			echo '
1812 1897
 						</select>';
@@ -1822,14 +1907,13 @@  discard block
 block discarded – undo
1822 1907
 
1823 1908
 				echo '
1824 1909
 						<input type="number"', $min . $max . $step;
1825
-			}
1826
-			elseif (isset($setting['type']) && $setting['type'] == 'url')
1827
-				echo'
1910
+			} elseif (isset($setting['type']) && $setting['type'] == 'url') {
1911
+							echo'
1828 1912
 						<input type="url"';
1829
-
1830
-			else
1831
-				echo '
1913
+			} else {
1914
+							echo '
1832 1915
 						<input type="text"';
1916
+			}
1833 1917
 
1834 1918
 			echo ' name="default_options[', $setting['id'], ']" id="', $setting['id'], '" value="', isset($context['member']['options'][$setting['id']]) ? $context['member']['options'][$setting['id']] : $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : '', '>';
1835 1919
 		}
@@ -1866,8 +1950,8 @@  discard block
 block discarded – undo
1866 1950
 				<dl class="settings">';
1867 1951
 
1868 1952
 	// Allow notification on announcements to be disabled?
1869
-	if (!empty($modSettings['allow_disableAnnounce']))
1870
-		echo '
1953
+	if (!empty($modSettings['allow_disableAnnounce'])) {
1954
+			echo '
1871 1955
 					<dt>
1872 1956
 						<label for="notify_announcements">', $txt['notify_important_email'], '</label>
1873 1957
 					</dt>
@@ -1875,15 +1959,17 @@  discard block
 block discarded – undo
1875 1959
 						<input type="hidden" name="notify_announcements" value="0">
1876 1960
 						<input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', '>
1877 1961
 					</dd>';
1962
+	}
1878 1963
 
1879
-	if (!empty($modSettings['enable_ajax_alerts']))
1880
-		echo '
1964
+	if (!empty($modSettings['enable_ajax_alerts'])) {
1965
+			echo '
1881 1966
 					<dt>
1882 1967
 						<label for="notify_send_body">', $txt['notify_alert_timeout'], '</label>
1883 1968
 					</dt>
1884 1969
 					<dd>
1885 1970
 						<input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '">
1886 1971
 					</dd>';
1972
+	}
1887 1973
 
1888 1974
 	echo '
1889 1975
 				</dl>
@@ -1915,9 +2001,10 @@  discard block
 block discarded – undo
1915 2001
 
1916 2002
 				$label = $txt['alert_opt_' . $opts[1]];
1917 2003
 				$label_pos = isset($opts['label']) ? $opts['label'] : '';
1918
-				if ($label_pos == 'before')
1919
-					echo '
2004
+				if ($label_pos == 'before') {
2005
+									echo '
1920 2006
 						<label for="opt_', $opts[1], '">', $label, '</label>';
2007
+				}
1921 2008
 
1922 2009
 				$this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0;
1923 2010
 				switch ($opts[0])
@@ -1931,17 +2018,19 @@  discard block
 block discarded – undo
1931 2018
 						echo '
1932 2019
 						<select name="opt_', $opts[1], '" id="opt_', $opts[1], '">';
1933 2020
 
1934
-						foreach ($opts['opts'] as $k => $v)
1935
-							echo '
2021
+						foreach ($opts['opts'] as $k => $v) {
2022
+													echo '
1936 2023
 							<option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>';
2024
+						}
1937 2025
 						echo '
1938 2026
 						</select>';
1939 2027
 						break;
1940 2028
 				}
1941 2029
 
1942
-				if ($label_pos == 'after')
1943
-					echo '
2030
+				if ($label_pos == 'after') {
2031
+									echo '
1944 2032
 						<label for="opt_', $opts[1], '">', $label, '</label>';
2033
+				}
1945 2034
 
1946 2035
 				echo '
1947 2036
 					</td>
@@ -2058,11 +2147,12 @@  discard block
 block discarded – undo
2058 2147
 			<p class="information">', $txt['groupMembership_info'], '</p>';
2059 2148
 
2060 2149
 	// Do we have an update message?
2061
-	if (!empty($context['update_message']))
2062
-		echo '
2150
+	if (!empty($context['update_message'])) {
2151
+			echo '
2063 2152
 			<div class="infobox">
2064 2153
 				', $context['update_message'], '.
2065 2154
 			</div>';
2155
+	}
2066 2156
 
2067 2157
 	echo '
2068 2158
 			<div id="groups">';
@@ -2084,8 +2174,7 @@  discard block
 block discarded – undo
2084 2174
 						</div>
2085 2175
 					</div>
2086 2176
 				</div><!-- .groupmembership -->';
2087
-	}
2088
-	else
2177
+	} else
2089 2178
 	{
2090 2179
 		echo '
2091 2180
 				<div class="title_bar">
@@ -2097,27 +2186,30 @@  discard block
 block discarded – undo
2097 2186
 			echo '
2098 2187
 				<div class="windowbg" id="primdiv_', $group['id'], '">';
2099 2188
 
2100
-				if ($context['can_edit_primary'])
2101
-					echo '
2189
+				if ($context['can_edit_primary']) {
2190
+									echo '
2102 2191
 					<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', '>';
2192
+				}
2103 2193
 
2104 2194
 				echo '
2105 2195
 					<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>';
2106 2196
 
2107 2197
 				// Can they leave their group?
2108
-				if ($group['can_leave'])
2109
-					echo '
2198
+				if ($group['can_leave']) {
2199
+									echo '
2110 2200
 					<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>';
2201
+				}
2111 2202
 
2112 2203
 				echo '
2113 2204
 				</div><!-- .windowbg -->';
2114 2205
 		}
2115 2206
 
2116
-		if ($context['can_edit_primary'])
2117
-			echo '
2207
+		if ($context['can_edit_primary']) {
2208
+					echo '
2118 2209
 				<div class="padding righttext">
2119 2210
 					<input type="submit" value="', $txt['make_primary'], '" class="button">
2120 2211
 				</div>';
2212
+		}
2121 2213
 
2122 2214
 		// Any groups they can join?
2123 2215
 		if (!empty($context['groups']['available']))
@@ -2133,17 +2225,16 @@  discard block
 block discarded – undo
2133 2225
 				<div class="windowbg">
2134 2226
 					<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>' : ''), '';
2135 2227
 
2136
-				if ($group['type'] == 3)
2137
-					echo '
2228
+				if ($group['type'] == 3) {
2229
+									echo '
2138 2230
 					<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>';
2139
-
2140
-				elseif ($group['type'] == 2 && $group['pending'])
2141
-					echo '
2231
+				} elseif ($group['type'] == 2 && $group['pending']) {
2232
+									echo '
2142 2233
 					<span class="floatright">', $txt['approval_pending'], '</span>';
2143
-
2144
-				elseif ($group['type'] == 2)
2145
-					echo '
2234
+				} elseif ($group['type'] == 2) {
2235
+									echo '
2146 2236
 					<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>';
2237
+				}
2147 2238
 
2148 2239
 				echo '
2149 2240
 				</div><!-- .windowbg -->';
@@ -2166,9 +2257,10 @@  discard block
 block discarded – undo
2166 2257
 
2167 2258
 						prevDiv.className = "windowbg";
2168 2259
 					}';
2169
-		if (isset($context['groups']['member'][$context['primary_group']]))
2170
-			echo '
2260
+		if (isset($context['groups']['member'][$context['primary_group']])) {
2261
+					echo '
2171 2262
 					highlightSelected("primdiv_' . $context['primary_group'] . '");';
2263
+		}
2172 2264
 
2173 2265
 		echo '
2174 2266
 				</script>';
@@ -2177,9 +2269,10 @@  discard block
 block discarded – undo
2177 2269
 	echo '
2178 2270
 			</div><!-- #groups -->';
2179 2271
 
2180
-	if (!empty($context['token_check']))
2181
-		echo '
2272
+	if (!empty($context['token_check'])) {
2273
+			echo '
2182 2274
 			<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2275
+	}
2183 2276
 
2184 2277
 	echo '
2185 2278
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2227,14 +2320,15 @@  discard block
 block discarded – undo
2227 2320
 
2228 2321
 		foreach ($category['boards'] as $board)
2229 2322
 		{
2230
-			if ($i == $limit)
2231
-				echo '
2323
+			if ($i == $limit) {
2324
+							echo '
2232 2325
 						</ul>
2233 2326
 					</li>
2234 2327
 				</ul>
2235 2328
 				<ul class="ignoreboards floatright">
2236 2329
 					<li class="category">
2237 2330
 						<ul>';
2331
+			}
2238 2332
 
2239 2333
 			echo '
2240 2334
 							<li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
@@ -2279,10 +2373,11 @@  discard block
 block discarded – undo
2279 2373
 
2280 2374
 	// Work out the starting warning.
2281 2375
 	$context['current_warning_mode'] = $context['warning_mode'][0];
2282
-	foreach ($context['warning_mode'] as $limit => $warning)
2283
-		if ($context['member']['warning'] >= $limit)
2376
+	foreach ($context['warning_mode'] as $limit => $warning) {
2377
+			if ($context['member']['warning'] >= $limit)
2284 2378
 			$context['current_warning_mode'] = $warning;
2285
-}
2379
+	}
2380
+	}
2286 2381
 
2287 2382
 // Show all warnings of a user?
2288 2383
 function template_viewWarning()
@@ -2317,14 +2412,15 @@  discard block
 block discarded – undo
2317 2412
 				</dd>';
2318 2413
 
2319 2414
 	// There's some impact of this?
2320
-	if (!empty($context['level_effects'][$context['current_level']]))
2321
-		echo '
2415
+	if (!empty($context['level_effects'][$context['current_level']])) {
2416
+			echo '
2322 2417
 				<dt>
2323 2418
 					<strong>', $txt['profile_viewwarning_impact'], ':</strong>
2324 2419
 				</dt>
2325 2420
 				<dd>
2326 2421
 					', $context['level_effects'][$context['current_level']], '
2327 2422
 				</dd>';
2423
+	}
2328 2424
 
2329 2425
 	echo '
2330 2426
 			</dl>
@@ -2362,10 +2458,11 @@  discard block
 block discarded – undo
2362 2458
 
2363 2459
 			// Otherwise see what we can do...';
2364 2460
 
2365
-	foreach ($context['notification_templates'] as $k => $type)
2366
-		echo '
2461
+	foreach ($context['notification_templates'] as $k => $type) {
2462
+			echo '
2367 2463
 			if (index == ', $k, ')
2368 2464
 				document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";';
2465
+	}
2369 2466
 
2370 2467
 	echo '
2371 2468
 		}
@@ -2375,10 +2472,11 @@  discard block
 block discarded – undo
2375 2472
 			// Also set the right effect.
2376 2473
 			effectText = "";';
2377 2474
 
2378
-	foreach ($context['level_effects'] as $limit => $text)
2379
-		echo '
2475
+	foreach ($context['level_effects'] as $limit => $text) {
2476
+			echo '
2380 2477
 			if (slideAmount >= ', $limit, ')
2381 2478
 				effectText = "', $text, '";';
2479
+	}
2382 2480
 
2383 2481
 	echo '
2384 2482
 			setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\');
@@ -2393,32 +2491,35 @@  discard block
 block discarded – undo
2393 2491
 			</h3>
2394 2492
 		</div>';
2395 2493
 
2396
-	if (!$context['user']['is_owner'])
2397
-		echo '
2494
+	if (!$context['user']['is_owner']) {
2495
+			echo '
2398 2496
 		<p class="information">', $txt['profile_warning_desc'], '</p>';
2497
+	}
2399 2498
 
2400 2499
 	echo '
2401 2500
 		<div class="windowbg">
2402 2501
 			<dl class="settings">';
2403 2502
 
2404
-	if (!$context['user']['is_owner'])
2405
-		echo '
2503
+	if (!$context['user']['is_owner']) {
2504
+			echo '
2406 2505
 				<dt>
2407 2506
 					<strong>', $txt['profile_warning_name'], ':</strong>
2408 2507
 				</dt>
2409 2508
 				<dd>
2410 2509
 					<strong>', $context['member']['name'], '</strong>
2411 2510
 				</dd>';
2511
+	}
2412 2512
 
2413 2513
 	echo '
2414 2514
 				<dt>
2415 2515
 					<strong>', $txt['profile_warning_level'], ':</strong>';
2416 2516
 
2417 2517
 	// Is there only so much they can apply?
2418
-	if ($context['warning_limit'])
2419
-		echo '
2518
+	if ($context['warning_limit']) {
2519
+			echo '
2420 2520
 					<br>
2421 2521
 					<span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>';
2522
+	}
2422 2523
 
2423 2524
 	echo '
2424 2525
 				</dt>
@@ -2473,9 +2574,10 @@  discard block
 block discarded – undo
2473 2574
 						<option value="-1">', $txt['profile_warning_notify_template'], '</option>
2474 2575
 						<option value="-1" disabled>------------------------------</option>';
2475 2576
 
2476
-		foreach ($context['notification_templates'] as $id_template => $template)
2477
-			echo '
2577
+		foreach ($context['notification_templates'] as $id_template => $template) {
2578
+					echo '
2478 2579
 						<option value="', $id_template, '">', $template['title'], '</option>';
2580
+		}
2479 2581
 
2480 2582
 		echo '
2481 2583
 					</select>
@@ -2488,9 +2590,10 @@  discard block
 block discarded – undo
2488 2590
 			</dl>
2489 2591
 			<div class="righttext">';
2490 2592
 
2491
-	if (!empty($context['token_check']))
2492
-		echo '
2593
+	if (!empty($context['token_check'])) {
2594
+			echo '
2493 2595
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2596
+	}
2494 2597
 
2495 2598
 	echo '
2496 2599
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2506,8 +2609,8 @@  discard block
 block discarded – undo
2506 2609
 	echo '
2507 2610
 	<script>';
2508 2611
 
2509
-	if (!$context['user']['is_owner'])
2510
-		echo '
2612
+	if (!$context['user']['is_owner']) {
2613
+			echo '
2511 2614
 		modifyWarnNotify();
2512 2615
 		$(document).ready(function() {
2513 2616
 			$("#preview_button").click(function() {
@@ -2546,6 +2649,7 @@  discard block
 block discarded – undo
2546 2649
 			});
2547 2650
 			return false;
2548 2651
 		}';
2652
+	}
2549 2653
 
2550 2654
 	echo '
2551 2655
 	</script>';
@@ -2568,17 +2672,19 @@  discard block
 block discarded – undo
2568 2672
 			</div>';
2569 2673
 
2570 2674
 	// If deleting another account give them a lovely info box.
2571
-	if (!$context['user']['is_owner'])
2572
-		echo '
2675
+	if (!$context['user']['is_owner']) {
2676
+			echo '
2573 2677
 			<p class="information">', $txt['deleteAccount_desc'], '</p>';
2678
+	}
2574 2679
 
2575 2680
 	echo '
2576 2681
 			<div class="windowbg">';
2577 2682
 
2578 2683
 	// If they are deleting their account AND the admin needs to approve it - give them another piece of info ;)
2579
-	if ($context['needs_approval'])
2580
-		echo '
2684
+	if ($context['needs_approval']) {
2685
+			echo '
2581 2686
 				<div class="errorbox">', $txt['deleteAccount_approval'], '</div>';
2687
+	}
2582 2688
 
2583 2689
 	// If the user is deleting their own account warn them first - and require a password!
2584 2690
 	if ($context['user']['is_owner'])
@@ -2590,9 +2696,10 @@  discard block
 block discarded – undo
2590 2696
 					<input type="password" name="oldpasswrd" size="20">
2591 2697
 					<input type="submit" value="', $txt['yes'], '" class="button">';
2592 2698
 
2593
-		if (!empty($context['token_check']))
2594
-			echo '
2699
+		if (!empty($context['token_check'])) {
2700
+					echo '
2595 2701
 					<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2702
+		}
2596 2703
 
2597 2704
 		echo '
2598 2705
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2622,10 +2729,11 @@  discard block
 block discarded – undo
2622 2729
 						<option value="topics">', $txt['deleteAccount_topics'], '</option>
2623 2730
 					</select>';
2624 2731
 
2625
-			if ($context['show_perma_delete'])
2626
-				echo '
2732
+			if ($context['show_perma_delete']) {
2733
+							echo '
2627 2734
 					<br>
2628 2735
 					<label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1">', $txt['deleteAccount_permanent'], ':</label>';
2736
+			}
2629 2737
 
2630 2738
 			echo '
2631 2739
 				</div>';
@@ -2638,9 +2746,10 @@  discard block
 block discarded – undo
2638 2746
 				<div>
2639 2747
 					<input type="submit" value="', $txt['delete'], '" class="button">';
2640 2748
 
2641
-		if (!empty($context['token_check']))
2642
-			echo '
2749
+		if (!empty($context['token_check'])) {
2750
+					echo '
2643 2751
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2752
+		}
2644 2753
 
2645 2754
 		echo '
2646 2755
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2666,8 +2775,8 @@  discard block
 block discarded – undo
2666 2775
 					<hr>';
2667 2776
 
2668 2777
 	// Only show the password box if it's actually needed.
2669
-	if ($context['require_password'])
2670
-		echo '
2778
+	if ($context['require_password']) {
2779
+			echo '
2671 2780
 					<dl class="settings">
2672 2781
 						<dt>
2673 2782
 							<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br>
@@ -2677,13 +2786,15 @@  discard block
 block discarded – undo
2677 2786
 							<input type="password" name="oldpasswrd" size="20">
2678 2787
 						</dd>
2679 2788
 					</dl>';
2789
+	}
2680 2790
 
2681 2791
 	echo '
2682 2792
 					<div class="righttext">';
2683 2793
 
2684
-	if (!empty($context['token_check']))
2685
-		echo '
2794
+	if (!empty($context['token_check'])) {
2795
+			echo '
2686 2796
 						<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2797
+	}
2687 2798
 
2688 2799
 	echo '
2689 2800
 						<input type="submit" value="', $txt['change_profile'], '" class="button">
@@ -2710,9 +2821,10 @@  discard block
 block discarded – undo
2710 2821
 			<ul id="list_errors">';
2711 2822
 
2712 2823
 		// Cycle through each error and display an error message.
2713
-		foreach ($context['post_errors'] as $error)
2714
-			echo '
2824
+		foreach ($context['post_errors'] as $error) {
2825
+					echo '
2715 2826
 				<li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>';
2827
+		}
2716 2828
 
2717 2829
 		echo '
2718 2830
 			</ul>';
@@ -2738,12 +2850,13 @@  discard block
 block discarded – undo
2738 2850
 								<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;"' : ''), '>';
2739 2851
 
2740 2852
 	// Fill the select box with all primary member groups that can be assigned to a member.
2741
-	foreach ($context['member_groups'] as $member_group)
2742
-		if (!empty($member_group['can_be_primary']))
2853
+	foreach ($context['member_groups'] as $member_group) {
2854
+			if (!empty($member_group['can_be_primary']))
2743 2855
 			echo '
2744 2856
 									<option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '>
2745 2857
 										', $member_group['name'], '
2746 2858
 									</option>';
2859
+	}
2747 2860
 
2748 2861
 	echo '
2749 2862
 								</select>
@@ -2756,10 +2869,11 @@  discard block
 block discarded – undo
2756 2869
 									<input type="hidden" name="additional_groups[]" value="0">';
2757 2870
 
2758 2871
 	// For each membergroup show a checkbox so members can be assigned to more than one group.
2759
-	foreach ($context['member_groups'] as $member_group)
2760
-		if ($member_group['can_be_additional'])
2872
+	foreach ($context['member_groups'] as $member_group) {
2873
+			if ($member_group['can_be_additional'])
2761 2874
 			echo '
2762 2875
 									<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>';
2876
+	}
2763 2877
 
2764 2878
 	echo '
2765 2879
 								</span>
@@ -2819,9 +2933,10 @@  discard block
 block discarded – undo
2819 2933
 								<span class="smalltext">', $txt['sig_info'], '</span><br>
2820 2934
 								<br>';
2821 2935
 
2822
-	if ($context['show_spellchecking'])
2823
-		echo '
2936
+	if ($context['show_spellchecking']) {
2937
+			echo '
2824 2938
 								<input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button">';
2939
+	}
2825 2940
 
2826 2941
 	echo '
2827 2942
 							</dt>
@@ -2829,17 +2944,20 @@  discard block
 block discarded – undo
2829 2944
 								<textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50">', $context['member']['signature'], '</textarea><br>';
2830 2945
 
2831 2946
 	// If there is a limit at all!
2832
-	if (!empty($context['signature_limits']['max_length']))
2833
-		echo '
2947
+	if (!empty($context['signature_limits']['max_length'])) {
2948
+			echo '
2834 2949
 								<span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>';
2950
+	}
2835 2951
 
2836
-	if (!empty($context['show_preview_button']))
2837
-		echo '
2952
+	if (!empty($context['show_preview_button'])) {
2953
+			echo '
2838 2954
 								<input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button floatright">';
2955
+	}
2839 2956
 
2840
-	if ($context['signature_warning'])
2841
-		echo '
2957
+	if ($context['signature_warning']) {
2958
+			echo '
2842 2959
 								<span class="smalltext">', $context['signature_warning'], '</span>';
2960
+	}
2843 2961
 
2844 2962
 	// Some javascript used to count how many characters have been used so far in the signature.
2845 2963
 	echo '
@@ -2870,38 +2988,43 @@  discard block
 block discarded – undo
2870 2988
 									<label for="avatar_upload_box">', $txt['personal_picture'], '</label>
2871 2989
 								</strong>';
2872 2990
 
2873
-	if (empty($modSettings['gravatarOverride']))
2874
-		echo '
2991
+	if (empty($modSettings['gravatarOverride'])) {
2992
+			echo '
2875 2993
 								<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_none" value="none"' . ($context['member']['avatar']['choice'] == 'none' ? ' checked="checked"' : '') . '>
2876 2994
 								<label for="avatar_choice_none"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
2877 2995
 									' . $txt['no_avatar'] . '
2878 2996
 								</label><br>';
2997
+	}
2879 2998
 
2880
-	if (!empty($context['member']['avatar']['allow_server_stored']))
2881
-		echo '
2999
+	if (!empty($context['member']['avatar']['allow_server_stored'])) {
3000
+			echo '
2882 3001
 								<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_server_stored" value="server_stored"' . ($context['member']['avatar']['choice'] == 'server_stored' ? ' checked="checked"' : '') . '>
2883 3002
 								<label for="avatar_choice_server_stored"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
2884 3003
 									', $txt['choose_avatar_gallery'], '
2885 3004
 								</label><br>';
3005
+	}
2886 3006
 
2887
-	if (!empty($context['member']['avatar']['allow_external']))
2888
-		echo '
3007
+	if (!empty($context['member']['avatar']['allow_external'])) {
3008
+			echo '
2889 3009
 								<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_external" value="external"' . ($context['member']['avatar']['choice'] == 'external' ? ' checked="checked"' : '') . '>
2890 3010
 								<label for="avatar_choice_external"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
2891 3011
 									', $txt['my_own_pic'], '
2892 3012
 								</label><br>';
3013
+	}
2893 3014
 
2894
-	if (!empty($context['member']['avatar']['allow_upload']))
2895
-		echo '
3015
+	if (!empty($context['member']['avatar']['allow_upload'])) {
3016
+			echo '
2896 3017
 								<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_upload" value="upload"' . ($context['member']['avatar']['choice'] == 'upload' ? ' checked="checked"' : '') . '>
2897 3018
 								<label for="avatar_choice_upload"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
2898 3019
 									', $txt['avatar_will_upload'], '
2899 3020
 								</label><br>';
3021
+	}
2900 3022
 
2901
-	if (!empty($context['member']['avatar']['allow_gravatar']))
2902
-		echo '
3023
+	if (!empty($context['member']['avatar']['allow_gravatar'])) {
3024
+			echo '
2903 3025
 								<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_gravatar" value="gravatar"' . ($context['member']['avatar']['choice'] == 'gravatar' ? ' checked="checked"' : '') . '>
2904 3026
 								<label for="avatar_choice_gravatar"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['use_gravatar'] . '</label>';
3027
+	}
2905 3028
 
2906 3029
 	echo '
2907 3030
 							</dt>
@@ -2916,9 +3039,10 @@  discard block
 block discarded – undo
2916 3039
 										<select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">';
2917 3040
 
2918 3041
 		// This lists all the file categories.
2919
-		foreach ($context['avatars'] as $avatar)
2920
-			echo '
3042
+		foreach ($context['avatars'] as $avatar) {
3043
+					echo '
2921 3044
 											<option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>';
3045
+		}
2922 3046
 
2923 3047
 		echo '
2924 3048
 										</select>
@@ -2950,20 +3074,22 @@  discard block
 block discarded – undo
2950 3074
 	}
2951 3075
 
2952 3076
 	// If the user can link to an off server avatar, show them a box to input the address.
2953
-	if (!empty($context['member']['avatar']['allow_external']))
2954
-		echo '
3077
+	if (!empty($context['member']['avatar']['allow_external'])) {
3078
+			echo '
2955 3079
 								<div id="avatar_external">
2956 3080
 									<div class="smalltext">', $txt['avatar_by_url'], '</div>', !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_download_and_resize' ? template_max_size('external') : '', '
2957 3081
 									<input type="text" name="userpicpersonal" size="45" value="', ((stristr($context['member']['avatar']['external'], 'http://') || stristr($context['member']['avatar']['external'], 'https://')) ? $context['member']['avatar']['external'] : 'http://'), '" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'external\');" onchange="if (typeof(previewExternalAvatar) != \'undefined\') previewExternalAvatar(this.value);">
2958 3082
 								</div>';
3083
+	}
2959 3084
 
2960 3085
 	// If the user is able to upload avatars to the server show them an upload box.
2961
-	if (!empty($context['member']['avatar']['allow_upload']))
2962
-		echo '
3086
+	if (!empty($context['member']['avatar']['allow_upload'])) {
3087
+			echo '
2963 3088
 								<div id="avatar_upload">
2964 3089
 									<input type="file" size="44" name="attachment" id="avatar_upload_box" value="" onchange="readfromUpload(this)"  onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'upload\');" accept="image/gif, image/jpeg, image/jpg, image/png">', template_max_size('upload'), '
2965 3090
 									', (!empty($context['member']['avatar']['id_attach']) ? '<br><img src="' . $context['member']['avatar']['href'] . (strpos($context['member']['avatar']['href'], '?') === false ? '?' : '&amp;') . 'time=' . time() . '" alt="" id="attached_image"><input type="hidden" name="id_attach" value="' . $context['member']['avatar']['id_attach'] . '">' : ''), '
2966 3091
 								</div>';
3092
+	}
2967 3093
 
2968 3094
 	// if the user is able to use Gravatar avatars show then the image preview
2969 3095
 	if (!empty($context['member']['avatar']['allow_gravatar']))
@@ -2972,16 +3098,17 @@  discard block
 block discarded – undo
2972 3098
 								<div id="avatar_gravatar">
2973 3099
 									<img src="' . $context['member']['avatar']['href'] . '" alt="">';
2974 3100
 
2975
-		if (empty($modSettings['gravatarAllowExtraEmail']))
2976
-			echo '
3101
+		if (empty($modSettings['gravatarAllowExtraEmail'])) {
3102
+					echo '
2977 3103
 									<div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>';
2978
-		else
3104
+		} else
2979 3105
 		{
2980 3106
 			// Depending on other stuff, the stored value here might have some odd things in it from other areas.
2981
-			if ($context['member']['avatar']['external'] == $context['member']['email'])
2982
-				$textbox_value = '';
2983
-			else
2984
-				$textbox_value = $context['member']['avatar']['external'];
3107
+			if ($context['member']['avatar']['external'] == $context['member']['email']) {
3108
+							$textbox_value = '';
3109
+			} else {
3110
+							$textbox_value = $context['member']['avatar']['external'];
3111
+			}
2985 3112
 
2986 3113
 			echo '
2987 3114
 									<div class="smalltext">', $txt['gravatar_alternateEmail'], '</div>
@@ -3053,8 +3180,9 @@  discard block
 block discarded – undo
3053 3180
 	$h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0;
3054 3181
 
3055 3182
 	$suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : '');
3056
-	if (empty($suffix))
3057
-		return;
3183
+	if (empty($suffix)) {
3184
+			return;
3185
+	}
3058 3186
 
3059 3187
 	echo '
3060 3188
 								<div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>';
@@ -3079,9 +3207,10 @@  discard block
 block discarded – undo
3079 3207
 								<select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;">';
3080 3208
 
3081 3209
 	// Help the user by showing a list of common time formats.
3082
-	foreach ($context['easy_timeformats'] as $time_format)
3083
-		echo '
3210
+	foreach ($context['easy_timeformats'] as $time_format) {
3211
+			echo '
3084 3212
 									<option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>';
3213
+	}
3085 3214
 
3086 3215
 	echo '
3087 3216
 								</select>
@@ -3119,9 +3248,10 @@  discard block
 block discarded – undo
3119 3248
 							<dd>
3120 3249
 								<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.png\';">';
3121 3250
 
3122
-	foreach ($context['smiley_sets'] as $set)
3123
-		echo '
3251
+	foreach ($context['smiley_sets'] as $set) {
3252
+			echo '
3124 3253
 									<option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>';
3254
+	}
3125 3255
 
3126 3256
 	echo '
3127 3257
 								</select>
@@ -3143,17 +3273,17 @@  discard block
 block discarded – undo
3143 3273
 			<div class="roundframe">
3144 3274
 				<div>';
3145 3275
 
3146
-	if (!empty($context['tfa_backup']))
3147
-		echo '
3276
+	if (!empty($context['tfa_backup'])) {
3277
+			echo '
3148 3278
 					<div class="smalltext error">
3149 3279
 						', $txt['tfa_backup_used_desc'], '
3150 3280
 					</div>';
3151
-
3152
-	elseif ($modSettings['tfa_mode'] == 2)
3153
-		echo '
3281
+	} elseif ($modSettings['tfa_mode'] == 2) {
3282
+			echo '
3154 3283
 					<div class="smalltext">
3155 3284
 						<strong>', $txt['tfa_forced_desc'], '</strong>
3156 3285
 					</div>';
3286
+	}
3157 3287
 
3158 3288
 	echo '
3159 3289
 					<div class="smalltext">
@@ -3164,11 +3294,12 @@  discard block
 block discarded – undo
3164 3294
 							<div class="block">
3165 3295
 								<strong>', $txt['tfa_step1'], '</strong><br>';
3166 3296
 
3167
-	if (!empty($context['tfa_pass_error']))
3168
-		echo '
3297
+	if (!empty($context['tfa_pass_error'])) {
3298
+			echo '
3169 3299
 								<div class="error smalltext">
3170 3300
 									', $txt['tfa_pass_invalid'], '
3171 3301
 								</div>';
3302
+	}
3172 3303
 
3173 3304
 	echo '
3174 3305
 								<input type="password" name="passwd" size="25"', !empty($context['tfa_pass_error']) ? ' class="error"' : '', !empty($context['tfa_pass_value']) ? ' value="' . $context['tfa_pass_value'] . '"' : '', '>
@@ -3181,11 +3312,12 @@  discard block
 block discarded – undo
3181 3312
 							<div class="block">
3182 3313
 								<strong>', $txt['tfa_step3'], '</strong><br>';
3183 3314
 
3184
-	if (!empty($context['tfa_error']))
3185
-		echo '
3315
+	if (!empty($context['tfa_error'])) {
3316
+			echo '
3186 3317
 								<div class="error smalltext">
3187 3318
 									', $txt['tfa_code_invalid'], '
3188 3319
 								</div>';
3320
+	}
3189 3321
 
3190 3322
 	echo '
3191 3323
 								<input type="text" name="tfa_code" size="25"', !empty($context['tfa_error']) ? ' class="error"' : '', !empty($context['tfa_value']) ? ' value="' . $context['tfa_value'] . '"' : '', '>
@@ -3199,10 +3331,11 @@  discard block
 block discarded – undo
3199 3331
 						<img src="', $context['tfa_qr_url'], '" alt="">
3200 3332
 					</div>';
3201 3333
 
3202
-	if (!empty($context['from_ajax']))
3203
-		echo '
3334
+	if (!empty($context['from_ajax'])) {
3335
+			echo '
3204 3336
 					<br>
3205 3337
 					<a href="javascript:self.close();"></a>';
3338
+	}
3206 3339
 
3207 3340
 	echo '
3208 3341
 				</div>
@@ -3242,17 +3375,16 @@  discard block
 block discarded – undo
3242 3375
 							</dt>
3243 3376
 							<dd>';
3244 3377
 
3245
-	if (!$context['tfa_enabled'] && $context['user']['is_owner'])
3246
-		echo '
3378
+	if (!$context['tfa_enabled'] && $context['user']['is_owner']) {
3379
+			echo '
3247 3380
 								<a href="', !empty($modSettings['force_ssl']) ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>';
3248
-
3249
-	elseif (!$context['tfa_enabled'])
3250
-		echo '
3381
+	} elseif (!$context['tfa_enabled']) {
3382
+			echo '
3251 3383
 								', $txt['tfa_profile_disabled'];
3252
-
3253
-	else
3254
-		echo '
3384
+	} else {
3385
+			echo '
3255 3386
 								', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable');
3387
+	}
3256 3388
 
3257 3389
 	echo '
3258 3390
 							</dd>';
@@ -3319,31 +3451,34 @@  discard block
 block discarded – undo
3319 3451
 			</h3>
3320 3452
 		</div>
3321 3453
 		<div class="windowbg">';
3322
-	if (empty($context['poc']['approved_text']) && empty($context['poc']['newVersionText']))
3323
-		echo '
3454
+	if (empty($context['poc']['approved_text']) && empty($context['poc']['newVersionText'])) {
3455
+			echo '
3324 3456
 			</div>
3325 3457
 				<p class="information">', $txt['policyNoApprved'], '</p><div class="windowbg">
3326 3458
 			<div>';
3459
+	}
3327 3460
 	
3328
-	if (!empty($context['poc']['approved_text']))
3329
-		echo '
3461
+	if (!empty($context['poc']['approved_text'])) {
3462
+			echo '
3330 3463
 			<div>
3331 3464
 				<div class="title_bar">
3332 3465
 					<h3 class="titlebg">', $txt['policy_approved'], '</h3>
3333 3466
 				</div>
3334 3467
 				<p>' ,$context['poc']['approved_text'] , '</p>
3335 3468
 			</div>';
3336
-	if (!empty($context['poc']['newVersionText']))
3337
-		echo '
3469
+	}
3470
+	if (!empty($context['poc']['newVersionText'])) {
3471
+			echo '
3338 3472
 			<div>
3339 3473
 				<div class="title_bar">
3340 3474
 					<h3 class="titlebg">', $txt['policy_new'], '</h3>
3341 3475
 				</div>
3342 3476
 				<p>' ,$context['poc']['newVersionText'] , '</p>
3343 3477
 			</div>';
3478
+	}
3344 3479
 	
3345
-	if (!empty($context['poc']['showAccept']))
3346
-		echo '
3480
+	if (!empty($context['poc']['showAccept'])) {
3481
+			echo '
3347 3482
 			<div>
3348 3483
 				<form action="', $scripturl, '?action=profile;area=getpolicydata;activity=save" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
3349 3484
 					<input type="submit" value="', $txt['policyAccept'], '" class="button">
@@ -3352,6 +3487,7 @@  discard block
 block discarded – undo
3352 3487
 					<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
3353 3488
 				</form>
3354 3489
 			</div>';
3490
+	}
3355 3491
 
3356 3492
 	echo '
3357 3493
 		</div><!-- .windowbg -->
Please login to merge, or discard this patch.
Themes/default/Admin.template.php 2 patches
Braces   +185 added lines, -132 removed lines patch added patch discarded remove patch
@@ -65,9 +65,10 @@  discard block
 block discarded – undo
65 65
 										', implode(', ', $context['administrators']);
66 66
 
67 67
 	// If we have lots of admins... don't show them all.
68
-	if (!empty($context['more_admins_link']))
69
-		echo '
68
+	if (!empty($context['more_admins_link'])) {
69
+			echo '
70 70
 										(', $context['more_admins_link'], ')';
71
+	}
71 72
 
72 73
 	echo '
73 74
 									</div><!-- #version_details -->
@@ -84,17 +85,19 @@  discard block
 block discarded – undo
84 85
 		foreach ($area['areas'] as $item_id => $item)
85 86
 		{
86 87
 			// No point showing the 'home' page here, we're already on it!
87
-			if ($area_id == 'forum' && $item_id == 'index')
88
-				continue;
88
+			if ($area_id == 'forum' && $item_id == 'index') {
89
+							continue;
90
+			}
89 91
 
90 92
 			$url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : '');
91 93
 
92
-			if (!empty($item['icon_file']))
93
-				echo '
94
+			if (!empty($item['icon_file'])) {
95
+							echo '
94 96
 							<a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>';
95
-			else
96
-				echo '
97
+			} else {
98
+							echo '
97 99
 							<a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>';
100
+			}
98 101
 		}
99 102
 
100 103
 		echo '
@@ -105,10 +108,11 @@  discard block
 block discarded – undo
105 108
 					</div><!-- #admincenter -->';
106 109
 
107 110
 	// The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization.
108
-	if (empty($modSettings['disable_smf_js']))
109
-		echo '
111
+	if (empty($modSettings['disable_smf_js'])) {
112
+			echo '
110 113
 					<script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script>
111 114
 					<script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>';
115
+	}
112 116
 
113 117
 	// This sets the announcements and current versions themselves ;).
114 118
 	echo '
@@ -186,9 +190,10 @@  discard block
 block discarded – undo
186 190
 								<em>', $version['version'], '</em>';
187 191
 
188 192
 		// more details for this item, show them a link
189
-		if ($context['can_admin'] && isset($version['more']))
190
-			echo
193
+		if ($context['can_admin'] && isset($version['more'])) {
194
+					echo
191 195
 								' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>';
196
+		}
192 197
 		echo '
193 198
 								<br>';
194 199
 	}
@@ -219,21 +224,23 @@  discard block
 block discarded – undo
219 224
 
220 225
 	foreach ($context['credits'] as $section)
221 226
 	{
222
-		if (isset($section['pretext']))
223
-			echo '
227
+		if (isset($section['pretext'])) {
228
+					echo '
224 229
 								<p>', $section['pretext'], '</p>
225 230
 								<hr>';
231
+		}
226 232
 
227 233
 		echo '
228 234
 								<dl>';
229 235
 
230 236
 		foreach ($section['groups'] as $group)
231 237
 		{
232
-			if (isset($group['title']))
233
-				echo '
238
+			if (isset($group['title'])) {
239
+							echo '
234 240
 									<dt>
235 241
 										<strong>', $group['title'], ':</strong>
236 242
 									</dt>';
243
+			}
237 244
 
238 245
 			echo '
239 246
 									<dd>', implode(', ', $group['members']), '</dd>';
@@ -242,10 +249,11 @@  discard block
 block discarded – undo
242 249
 		echo '
243 250
 								</dl>';
244 251
 
245
-		if (isset($section['posttext']))
246
-			echo '
252
+		if (isset($section['posttext'])) {
253
+					echo '
247 254
 								<hr>
248 255
 								<p>', $section['posttext'], '</p>';
256
+		}
249 257
 	}
250 258
 
251 259
 	echo '
@@ -261,9 +269,10 @@  discard block
 block discarded – undo
261 269
 						smfSupportVersions.forum = "', $context['forum_version'], '";';
262 270
 
263 271
 	// Don't worry, none of this is logged, it's just used to give information that might be of use.
264
-	foreach ($context['current_versions'] as $variable => $version)
265
-		echo '
272
+	foreach ($context['current_versions'] as $variable => $version) {
273
+			echo '
266 274
 						smfSupportVersions.', $variable, ' = "', $version['version'], '";';
275
+	}
267 276
 
268 277
 	// Now we just have to include the script and wait ;).
269 278
 	echo '
@@ -360,8 +369,8 @@  discard block
 block discarded – undo
360 369
 								<tbody>';
361 370
 
362 371
 	// Loop through every source file displaying its version - using javascript.
363
-	foreach ($context['file_versions'] as $filename => $version)
364
-		echo '
372
+	foreach ($context['file_versions'] as $filename => $version) {
373
+			echo '
365 374
 									<tr class="windowbg">
366 375
 										<td class="half_table">
367 376
 											', $filename, '
@@ -373,6 +382,7 @@  discard block
 block discarded – undo
373 382
 											<em id="currentSources', $filename, '">??</em>
374 383
 										</td>
375 384
 									</tr>';
385
+	}
376 386
 
377 387
 	// Default template files.
378 388
 	echo '
@@ -398,8 +408,8 @@  discard block
 block discarded – undo
398 408
 							<table id="Default" class="table_grid">
399 409
 								<tbody>';
400 410
 
401
-	foreach ($context['default_template_versions'] as $filename => $version)
402
-		echo '
411
+	foreach ($context['default_template_versions'] as $filename => $version) {
412
+			echo '
403 413
 									<tr class="windowbg">
404 414
 										<td class="half_table">
405 415
 											', $filename, '
@@ -411,6 +421,7 @@  discard block
 block discarded – undo
411 421
 											<em id="currentDefault', $filename, '">??</em>
412 422
 										</td>
413 423
 									</tr>';
424
+	}
414 425
 
415 426
 	// Now the language files...
416 427
 	echo '
@@ -438,8 +449,8 @@  discard block
 block discarded – undo
438 449
 
439 450
 	foreach ($context['default_language_versions'] as $language => $files)
440 451
 	{
441
-		foreach ($files as $filename => $version)
442
-			echo '
452
+		foreach ($files as $filename => $version) {
453
+					echo '
443 454
 									<tr class="windowbg">
444 455
 										<td class="half_table">
445 456
 											', $filename, '.<em>', $language, '</em>.php
@@ -451,6 +462,7 @@  discard block
 block discarded – undo
451 462
 											<em id="current', $filename, '.', $language, '">??</em>
452 463
 										</td>
453 464
 									</tr>';
465
+		}
454 466
 	}
455 467
 
456 468
 	echo '
@@ -480,8 +492,8 @@  discard block
 block discarded – undo
480 492
 							<table id="Templates" class="table_grid">
481 493
 								<tbody>';
482 494
 
483
-		foreach ($context['template_versions'] as $filename => $version)
484
-			echo '
495
+		foreach ($context['template_versions'] as $filename => $version) {
496
+					echo '
485 497
 									<tr class="windowbg">
486 498
 										<td class="half_table">
487 499
 											', $filename, '
@@ -493,6 +505,7 @@  discard block
 block discarded – undo
493 505
 											<em id="currentTemplates', $filename, '">??</em>
494 506
 										</td>
495 507
 									</tr>';
508
+		}
496 509
 
497 510
 		echo '
498 511
 								</tbody>
@@ -522,8 +535,8 @@  discard block
 block discarded – undo
522 535
 							<table id="Tasks" class="table_grid">
523 536
 								<tbody>';
524 537
 
525
-		foreach ($context['tasks_versions'] as $filename => $version)
526
-			echo '
538
+		foreach ($context['tasks_versions'] as $filename => $version) {
539
+					echo '
527 540
 									<tr class="windowbg">
528 541
 										<td class="half_table">
529 542
 											', $filename, '
@@ -535,6 +548,7 @@  discard block
 block discarded – undo
535 548
 											<em id="currentTasks', $filename, '">??</em>
536 549
 										</td>
537 550
 									</tr>';
551
+		}
538 552
 
539 553
 		echo '
540 554
 								</tbody>
@@ -576,9 +590,10 @@  discard block
 block discarded – undo
576 590
 {
577 591
 	global $context, $scripturl, $txt, $modSettings;
578 592
 
579
-	if (!empty($context['saved_successful']))
580
-		echo '
593
+	if (!empty($context['saved_successful'])) {
594
+			echo '
581 595
 					<div class="infobox">', $txt['settings_saved'], '</div>';
596
+	}
582 597
 
583 598
 	// First section is for adding/removing words from the censored list.
584 599
 	echo '
@@ -593,11 +608,12 @@  discard block
 block discarded – undo
593 608
 								<p>', $txt['admin_censored_where'], '</p>';
594 609
 
595 610
 	// Show text boxes for censoring [bad   ] => [good  ].
596
-	foreach ($context['censored_words'] as $vulgar => $proper)
597
-		echo '
611
+	foreach ($context['censored_words'] as $vulgar => $proper) {
612
+			echo '
598 613
 								<div class="block">
599 614
 									<input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> =&gt; <input type="text" name="censor_proper[]" value="', $proper, '" size="30">
600 615
 								</div>';
616
+	}
601 617
 
602 618
 	// Now provide a way to censor more words.
603 619
 	echo '
@@ -672,27 +688,30 @@  discard block
 block discarded – undo
672 688
 						<div class="windowbg">
673 689
 							', $txt['not_done_reason'];
674 690
 
675
-	if (!empty($context['continue_percent']))
676
-		echo '
691
+	if (!empty($context['continue_percent'])) {
692
+			echo '
677 693
 							<div class="progress_bar">
678 694
 								<span>', $context['continue_percent'], '%</span>
679 695
 								<div class="bar" style="width: ', $context['continue_percent'], '%;"></div>
680 696
 							</div>';
697
+	}
681 698
 
682
-	if (!empty($context['substep_enabled']))
683
-		echo '
699
+	if (!empty($context['substep_enabled'])) {
700
+			echo '
684 701
 							<div class="progress_bar progress_blue">
685 702
 								<span>', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</span>
686 703
 								<div class="bar" style="width: ', $context['substep_continue_percent'], '%;"></div>
687 704
 							</div>';
705
+	}
688 706
 
689 707
 	echo '
690 708
 							<form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit">';
691 709
 
692 710
 	// Do we have a token?
693
-	if (isset($context['not_done_token']) && isset($context[$context['not_done_token'] . '_token'], $context[$context['not_done_token'] . '_token_var']))
694
-		echo '
711
+	if (isset($context['not_done_token']) && isset($context[$context['not_done_token'] . '_token'], $context[$context['not_done_token'] . '_token_var'])) {
712
+			echo '
695 713
 							<input type="hidden" name="', $context[$context['not_done_token'] . '_token_var'], '" value="', $context[$context['not_done_token'] . '_token'], '">';
714
+	}
696 715
 
697 716
 	echo '
698 717
 								<input type="submit" name="cont" value="', $txt['not_done_continue'], '" class="button">
@@ -726,35 +745,40 @@  discard block
 block discarded – undo
726 745
 {
727 746
 	global $context, $txt, $scripturl;
728 747
 
729
-	if (!empty($context['saved_successful']))
730
-		echo '
748
+	if (!empty($context['saved_successful'])) {
749
+			echo '
731 750
 					<div class="infobox">', $txt['settings_saved'], '</div>';
732
-	elseif (!empty($context['saved_failed']))
733
-		echo '
751
+	} elseif (!empty($context['saved_failed'])) {
752
+			echo '
734 753
 					<div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>';
754
+	}
735 755
 
736
-	if (!empty($context['settings_pre_javascript']))
737
-		echo '
756
+	if (!empty($context['settings_pre_javascript'])) {
757
+			echo '
738 758
 					<script>', $context['settings_pre_javascript'], '</script>';
759
+	}
739 760
 
740
-	if (!empty($context['settings_insert_above']))
741
-		echo $context['settings_insert_above'];
761
+	if (!empty($context['settings_insert_above'])) {
762
+			echo $context['settings_insert_above'];
763
+	}
742 764
 
743 765
 	echo '
744 766
 					<div id="admincenter">
745 767
 						<form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>';
746 768
 
747 769
 	// Is there a custom title?
748
-	if (isset($context['settings_title']))
749
-		echo '
770
+	if (isset($context['settings_title'])) {
771
+			echo '
750 772
 							<div class="cat_bar">
751 773
 								<h3 class="catbg">', $context['settings_title'], '</h3>
752 774
 							</div>';
775
+	}
753 776
 
754 777
 	// Have we got a message to display?
755
-	if (!empty($context['settings_message']))
756
-		echo '
778
+	if (!empty($context['settings_message'])) {
779
+			echo '
757 780
 							<div class="information">', $context['settings_message'], '</div>';
781
+	}
758 782
 
759 783
 	// Now actually loop through all the variables.
760 784
 	$is_open = false;
@@ -807,8 +831,9 @@  discard block
 block discarded – undo
807 831
 		// Hang about? Are you pulling my leg - a callback?!
808 832
 		if (is_array($config_var) && $config_var['type'] == 'callback')
809 833
 		{
810
-			if (function_exists('template_callback_' . $config_var['name']))
811
-				call_user_func('template_callback_' . $config_var['name']);
834
+			if (function_exists('template_callback_' . $config_var['name'])) {
835
+							call_user_func('template_callback_' . $config_var['name']);
836
+			}
812 837
 
813 838
 			continue;
814 839
 		}
@@ -838,9 +863,10 @@  discard block
 block discarded – undo
838 863
 				$text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time');
839 864
 
840 865
 				// Show the [?] button.
841
-				if ($config_var['help'])
842
-					echo '
866
+				if ($config_var['help']) {
867
+									echo '
843 868
 										<a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> ';
869
+				}
844 870
 
845 871
 				echo '
846 872
 										<a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span>
@@ -849,23 +875,26 @@  discard block
 block discarded – undo
849 875
 										$config_var['preinput'];
850 876
 
851 877
 				// Show a check box.
852
-				if ($config_var['type'] == 'check')
853
-					echo '
878
+				if ($config_var['type'] == 'check') {
879
+									echo '
854 880
 										<input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1">';
881
+				}
855 882
 				// Escape (via htmlspecialchars.) the text box.
856
-				elseif ($config_var['type'] == 'password')
857
-					echo '
883
+				elseif ($config_var['type'] == 'password') {
884
+									echo '
858 885
 										<input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;"><br>
859 886
 										<input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), '>';
887
+				}
860 888
 				// Show a selection box.
861 889
 				elseif ($config_var['type'] == 'select')
862 890
 				{
863 891
 					echo '
864 892
 										<select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>';
865 893
 
866
-					foreach ($config_var['data'] as $option)
867
-						echo '
894
+					foreach ($config_var['data'] as $option) {
895
+											echo '
868 896
 											<option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>';
897
+					}
869 898
 					echo '
870 899
 										</select>';
871 900
 				}
@@ -882,16 +911,18 @@  discard block
 block discarded – undo
882 911
 
883 912
 					foreach ($context['board_list'] as $id_cat => $cat)
884 913
 					{
885
-						if (!$first)
886
-							echo '
914
+						if (!$first) {
915
+													echo '
887 916
 											<hr>';
917
+						}
888 918
 						echo '
889 919
 											<strong>', $cat['name'], '</strong>
890 920
 											<ul>';
891 921
 
892
-						foreach ($cat['boards'] as $id_board => $brd)
893
-							echo '
922
+						foreach ($cat['boards'] as $id_board => $brd) {
923
+													echo '
894 924
 												<li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat('&nbsp; &nbsp;', $brd['child_level']) : '', $brd['name'], '</label></li>';
925
+						}
895 926
 
896 927
 						echo '
897 928
 											</ul>';
@@ -901,12 +932,14 @@  discard block
 block discarded – undo
901 932
 										</fieldset>';
902 933
 				}
903 934
 				// Text area?
904
-				elseif ($config_var['type'] == 'large_text')
905
-					echo '
935
+				elseif ($config_var['type'] == 'large_text') {
936
+									echo '
906 937
 										<textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>';
938
+				}
907 939
 				// Permission group?
908
-				elseif ($config_var['type'] == 'permissions')
909
-					theme_inline_permissions($config_var['name']);
940
+				elseif ($config_var['type'] == 'permissions') {
941
+									theme_inline_permissions($config_var['name']);
942
+				}
910 943
 
911 944
 				// BBC selection?
912 945
 				elseif ($config_var['type'] == 'bbc')
@@ -918,22 +951,24 @@  discard block
 block discarded – undo
918 951
 
919 952
 					foreach ($context['bbc_columns'] as $bbcColumn)
920 953
 					{
921
-						foreach ($bbcColumn as $bbcTag)
922
-							echo '
954
+						foreach ($bbcColumn as $bbcTag) {
955
+													echo '
923 956
 												<li class="list_bbc floatleft">
924 957
 													<input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', '> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', '
925 958
 												</li>';
959
+						}
926 960
 					}
927 961
 					echo '					</ul>
928 962
 											<input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', '> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label>
929 963
 										</fieldset>';
930 964
 				}
931 965
 				// A simple message?
932
-				elseif ($config_var['type'] == 'var_message')
933
-					echo '
966
+				elseif ($config_var['type'] == 'var_message') {
967
+									echo '
934 968
 										<div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '>
935 969
 											', $config_var['var_message'], '
936 970
 										</div>';
971
+				}
937 972
 				// Assume it must be a text box
938 973
 				else
939 974
 				{
@@ -958,62 +993,70 @@  discard block
 block discarded – undo
958 993
 											' . $config_var['postinput'] : '','
959 994
 									</dd>';
960 995
 			}
961
-		}
962
-		else
996
+		} else
963 997
 		{
964 998
 			// Just show a separator.
965
-			if ($config_var == '')
966
-				echo '
999
+			if ($config_var == '') {
1000
+							echo '
967 1001
 								</dl>
968 1002
 								<hr>
969 1003
 								<dl class="settings">';
970
-			else
971
-				echo '
1004
+			} else {
1005
+							echo '
972 1006
 									<dd>
973 1007
 										<strong>' . $config_var . '</strong>
974 1008
 									</dd>';
1009
+			}
975 1010
 		}
976 1011
 	}
977 1012
 
978
-	if ($is_open)
979
-		echo '
1013
+	if ($is_open) {
1014
+			echo '
980 1015
 								</dl>';
1016
+	}
981 1017
 
982
-	if (empty($context['settings_save_dont_show']))
983
-		echo '
1018
+	if (empty($context['settings_save_dont_show'])) {
1019
+			echo '
984 1020
 								<input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button">';
1021
+	}
985 1022
 
986
-	if ($is_open)
987
-		echo '
1023
+	if ($is_open) {
1024
+			echo '
988 1025
 							</div><!-- .windowbg -->';
1026
+	}
989 1027
 
990 1028
 
991 1029
 	// At least one token has to be used!
992
-	if (isset($context['admin-ssc_token']))
993
-		echo '
1030
+	if (isset($context['admin-ssc_token'])) {
1031
+			echo '
994 1032
 							<input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">';
1033
+	}
995 1034
 
996
-	if (isset($context['admin-dbsc_token']))
997
-		echo '
1035
+	if (isset($context['admin-dbsc_token'])) {
1036
+			echo '
998 1037
 							<input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">';
1038
+	}
999 1039
 
1000
-	if (isset($context['admin-mp_token']))
1001
-		echo '
1040
+	if (isset($context['admin-mp_token'])) {
1041
+			echo '
1002 1042
 							<input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">';
1043
+	}
1003 1044
 
1004 1045
 	echo '
1005 1046
 							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1006 1047
 						</form>
1007 1048
 					</div><!-- #admincenter -->';
1008 1049
 
1009
-	if (!empty($context['settings_post_javascript']))
1010
-		echo '
1050
+	if (!empty($context['settings_post_javascript'])) {
1051
+			echo '
1011 1052
 					<script>
1012 1053
 						', $context['settings_post_javascript'], '
1013 1054
 					</script>';
1055
+	}
1014 1056
 
1015
-	if (!empty($context['settings_insert_below']))
1016
-		echo $context['settings_insert_below'];
1057
+	if (!empty($context['settings_insert_below'])) {
1058
+			echo $context['settings_insert_below'];
1059
+	}
1017 1060
 
1018 1061
 	// We may have added a board listing. If we did, we need to make it work.
1019 1062
 	addInlineJavascript('
@@ -1036,9 +1079,10 @@  discard block
 block discarded – undo
1036 1079
 {
1037 1080
 	global $context, $txt;
1038 1081
 
1039
-	if (!empty($context['saved_successful']))
1040
-		echo '
1082
+	if (!empty($context['saved_successful'])) {
1083
+			echo '
1041 1084
 					<div class="infobox">', $txt['settings_saved'], '</div>';
1085
+	}
1042 1086
 
1043 1087
 	// Standard fields.
1044 1088
 	template_show_list('standard_profile_fields');
@@ -1072,11 +1116,12 @@  discard block
 block discarded – undo
1072 1116
 	{
1073 1117
 		loadLanguage('Errors');
1074 1118
 
1075
-		if (isset($txt['custom_option_' . $_GET['msg']]))
1076
-			echo '
1119
+		if (isset($txt['custom_option_' . $_GET['msg']])) {
1120
+					echo '
1077 1121
 					<div class="errorbox">',
1078 1122
 						$txt['custom_option_' . $_GET['msg']], '
1079 1123
 					</div>';
1124
+		}
1080 1125
 	}
1081 1126
 
1082 1127
 	echo '
@@ -1143,9 +1188,10 @@  discard block
 block discarded – undo
1143 1188
 										<dd>
1144 1189
 											<select name="placement" id="placement">';
1145 1190
 
1146
-	foreach ($context['cust_profile_fields_placement'] as $order => $name)
1147
-		echo '
1191
+	foreach ($context['cust_profile_fields_placement'] as $order => $name) {
1192
+			echo '
1148 1193
 												<option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>';
1194
+	}
1149 1195
 
1150 1196
 	echo '
1151 1197
 											</select>
@@ -1169,9 +1215,10 @@  discard block
 block discarded – undo
1169 1215
 										<dd>
1170 1216
 											<select name="field_type" id="field_type" onchange="updateInputBoxes();">';
1171 1217
 
1172
-	foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type)
1173
-		echo '
1218
+	foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) {
1219
+			echo '
1174 1220
 												<option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>';
1221
+	}
1175 1222
 
1176 1223
 	echo '
1177 1224
 											</select>
@@ -1203,9 +1250,10 @@  discard block
 block discarded – undo
1203 1250
 										</dt>
1204 1251
 										<dd id="options_dd">';
1205 1252
 
1206
-	foreach ($context['field']['options'] as $k => $option)
1207
-		echo '
1253
+	foreach ($context['field']['options'] as $k => $option) {
1254
+			echo '
1208 1255
 											', $k == 0 ? '' : '<br>', '<input type="radio" name="default_select" value="', $k, '"', $context['field']['default_select'] == $option ? ' checked' : '', '><input type="text" name="select_option[', $k, ']" value="', $option, '">';
1256
+	}
1209 1257
 
1210 1258
 	echo '
1211 1259
 											<span id="addopt"></span>
@@ -1269,9 +1317,10 @@  discard block
 block discarded – undo
1269 1317
 								</fieldset>
1270 1318
 								<input type="submit" name="save" value="', $txt['save'], '" class="button">';
1271 1319
 
1272
-	if ($context['fid'])
1273
-		echo '
1320
+	if ($context['fid']) {
1321
+			echo '
1274 1322
 								<input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button you_sure">';
1323
+	}
1275 1324
 
1276 1325
 	echo '
1277 1326
 							</div><!-- .windowbg -->
@@ -1318,8 +1367,7 @@  discard block
 block discarded – undo
1318 1367
 							<p class="centertext">
1319 1368
 								<strong>', $txt['admin_search_results_none'], '</strong>
1320 1369
 							</p>';
1321
-	}
1322
-	else
1370
+	} else
1323 1371
 	{
1324 1372
 		echo '
1325 1373
 							<ol class="search_results">';
@@ -1346,9 +1394,10 @@  discard block
 block discarded – undo
1346 1394
 								<li>
1347 1395
 									<a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']';
1348 1396
 
1349
-				if ($result['help'])
1350
-					echo '
1397
+				if ($result['help']) {
1398
+									echo '
1351 1399
 									<p class="double_height">', $result['help'], '</p>';
1400
+				}
1352 1401
 
1353 1402
 				echo '
1354 1403
 								</li>';
@@ -1388,10 +1437,11 @@  discard block
 block discarded – undo
1388 1437
 									<strong>', $txt['setup_verification_answer'], '</strong>
1389 1438
 								</dd>';
1390 1439
 
1391
-		if (!empty($context['qa_by_lang'][$lang_id]))
1392
-			foreach ($context['qa_by_lang'][$lang_id] as $q_id)
1440
+		if (!empty($context['qa_by_lang'][$lang_id])) {
1441
+					foreach ($context['qa_by_lang'][$lang_id] as $q_id)
1393 1442
 			{
1394 1443
 				$question = $context['question_answers'][$q_id];
1444
+		}
1395 1445
 
1396 1446
 				echo '
1397 1447
 								<dt>
@@ -1399,9 +1449,10 @@  discard block
 block discarded – undo
1399 1449
 								</dt>
1400 1450
 								<dd>';
1401 1451
 
1402
-				foreach ($question['answers'] as $answer)
1403
-					echo '
1452
+				foreach ($question['answers'] as $answer) {
1453
+									echo '
1404 1454
 									<input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="verification_answer">';
1455
+				}
1405 1456
 
1406 1457
 				echo '
1407 1458
 									<div class="qa_add_answer"><a href="javascript:void(0);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div>
@@ -1440,11 +1491,12 @@  discard block
 block discarded – undo
1440 1491
 							', $txt['errors_found'], ':
1441 1492
 							<ul>';
1442 1493
 
1443
-			foreach ($context['repair_errors'] as $error)
1444
-				echo '
1494
+			foreach ($context['repair_errors'] as $error) {
1495
+							echo '
1445 1496
 								<li>
1446 1497
 									', $error, '
1447 1498
 								</li>';
1499
+			}
1448 1500
 
1449 1501
 			echo '
1450 1502
 							</ul>
@@ -1454,15 +1506,14 @@  discard block
 block discarded – undo
1454 1506
 							<p class="padding">
1455 1507
 								<strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong>
1456 1508
 							</p>';
1457
-		}
1458
-		else
1459
-			echo '
1509
+		} else {
1510
+					echo '
1460 1511
 							<p>', $txt['maintain_no_errors'], '</p>
1461 1512
 							<p class="padding">
1462 1513
 								<a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a>
1463 1514
 							</p>';
1464
-	}
1465
-	else
1515
+		}
1516
+	} else
1466 1517
 	{
1467 1518
 		if (!empty($context['redirect_to_recount']))
1468 1519
 		{
@@ -1474,8 +1525,7 @@  discard block
 block discarded – undo
1474 1525
 								<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1475 1526
 								<input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '">
1476 1527
 							</form>';
1477
-		}
1478
-		else
1528
+		} else
1479 1529
 		{
1480 1530
 			echo '
1481 1531
 							<p>', $txt['errors_fixed'], '</p>
@@ -1566,9 +1616,10 @@  discard block
 block discarded – undo
1566 1616
 								<tr class="windowbg">
1567 1617
 									<td class="equal_table">', $key, '</td>';
1568 1618
 
1569
-				foreach ($setting as $key_lm => $value)
1570
-					echo '
1619
+				foreach ($setting as $key_lm => $value) {
1620
+									echo '
1571 1621
 									<td class="equal_table">', $value, '</td>';
1622
+				}
1572 1623
 
1573 1624
 				echo '
1574 1625
 								</tr>';
@@ -1628,8 +1679,8 @@  discard block
 block discarded – undo
1628 1679
 {
1629 1680
 	global $context, $txt;
1630 1681
 
1631
-	if ($context['user']['is_admin'])
1632
-		echo '
1682
+	if ($context['user']['is_admin']) {
1683
+			echo '
1633 1684
 								<span class="floatright admin_search">
1634 1685
 									<span class="generic_icons filter centericon"></span>
1635 1686
 									<input type="search" name="search_term" placeholder="', $txt['admin_search'], '">
@@ -1640,7 +1691,8 @@  discard block
 block discarded – undo
1640 1691
 									</select>
1641 1692
 									<input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button">
1642 1693
 								</span>';
1643
-}
1694
+	}
1695
+	}
1644 1696
 
1645 1697
 /**
1646 1698
  * This shows the policy settings
@@ -1649,9 +1701,10 @@  discard block
 block discarded – undo
1649 1701
 {
1650 1702
 	global $context, $scripturl, $txt, $modSettings;
1651 1703
 
1652
-	if (!empty($context['saved_successful']))
1653
-		echo '
1704
+	if (!empty($context['saved_successful'])) {
1705
+			echo '
1654 1706
 					<div class="infobox">', $txt['settings_saved'], '</div>';
1707
+	}
1655 1708
 
1656 1709
 	echo '
1657 1710
 					<div id="admincenter">
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
 				}
956 956
 
957 957
 				echo isset($config_var['postinput']) ? '
958
-											' . $config_var['postinput'] : '','
958
+											' . $config_var['postinput'] : '', '
959 959
 									</dd>';
960 960
 			}
961 961
 		}
@@ -1672,7 +1672,7 @@  discard block
 block discarded – undo
1672 1672
 								</dl>
1673 1673
 								<input type="submit" name="save_setting" value="', $txt['save'], '" class="button">
1674 1674
 								<div class="block">
1675
-									',template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message') ,'
1675
+									',template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), '
1676 1676
 								</div>
1677 1677
 								<input type="submit" name="save_new_policy" value="', $txt['policy_save'], '" class="button">
1678 1678
 								<input type="submit" name="update_policy" value="', $txt['policy_update'], '" class="button">								
@@ -1717,11 +1717,11 @@  discard block
 block discarded – undo
1717 1717
 							</div>
1718 1718
 							<div class="windowbg">
1719 1719
 								<dl class="settings">';
1720
-	$count = ( is_array($context['poc']['policy_management']) ? count($context['poc']['policy_management']) : 0);
1720
+	$count = (is_array($context['poc']['policy_management']) ? count($context['poc']['policy_management']) : 0);
1721 1721
 	foreach ($context['poc']['policy_management'] as $row)
1722 1722
 	{
1723 1723
 		echo '
1724
-									<dt>', ($row['new'] ? 'current' : '<input type="submit" name="delete_policy" value="' . $row['name'] . '" class="button">') , '</dt><dd>', $row['amount'], '</dd>';
1724
+									<dt>', ($row['new'] ? 'current' : '<input type="submit" name="delete_policy" value="' . $row['name'] . '" class="button">'), '</dt><dd>', $row['amount'], '</dd>';
1725 1725
 	}
1726 1726
 	echo '
1727 1727
 								</dl>
Please login to merge, or discard this patch.
Sources/ManageSettings.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1342,7 +1342,7 @@  discard block
 block discarded – undo
1342 1342
 					'class' => 'centercol',
1343 1343
 				),
1344 1344
 				'data' => array(
1345
-					'function' => function ($rowData)
1345
+					'function' => function($rowData)
1346 1346
 					{
1347 1347
 						$isChecked = $rowData['disabled'] ? '' : ' checked';
1348 1348
 						$onClickHandler = $rowData['can_show_register'] ? sprintf(' onclick="document.getElementById(\'reg_%1$s\').disabled = !this.checked;"', $rowData['id']) : '';
@@ -1358,7 +1358,7 @@  discard block
 block discarded – undo
1358 1358
 					'class' => 'centercol',
1359 1359
 				),
1360 1360
 				'data' => array(
1361
-					'function' => function ($rowData)
1361
+					'function' => function($rowData)
1362 1362
 					{
1363 1363
 						$isChecked = $rowData['on_register'] && !$rowData['disabled'] ? ' checked' : '';
1364 1364
 						$isDisabled = $rowData['can_show_register'] ? '' : ' disabled';
@@ -1405,15 +1405,15 @@  discard block
 block discarded – undo
1405 1405
 					'value' => $txt['custom_profile_fieldorder'],
1406 1406
 				),
1407 1407
 				'data' => array(
1408
-					'function' => function ($rowData) use ($context, $txt, $scripturl)
1408
+					'function' => function($rowData) use ($context, $txt, $scripturl)
1409 1409
 					{
1410
-						$return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>';
1410
+						$return = '<p class="centertext bold_text">' . $rowData['field_order'] . '<br>';
1411 1411
 
1412 1412
 						if ($rowData['field_order'] > 1)
1413
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>';
1413
+							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_up'] . '"></span></a>';
1414 1414
 
1415 1415
 						if ($rowData['field_order'] < $context['custFieldsMaxOrder'])
1416
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>';
1416
+							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_down'] . '"></span></a>';
1417 1417
 
1418 1418
 						$return .= '</p>';
1419 1419
 
@@ -1431,7 +1431,7 @@  discard block
 block discarded – undo
1431 1431
 					'value' => $txt['custom_profile_fieldname'],
1432 1432
 				),
1433 1433
 				'data' => array(
1434
-					'function' => function ($rowData) use ($scripturl)
1434
+					'function' => function($rowData) use ($scripturl)
1435 1435
 					{
1436 1436
 						return sprintf('<a href="%1$s?action=admin;area=featuresettings;sa=profileedit;fid=%2$d">%3$s</a><div class="smalltext">%4$s</div>', $scripturl, $rowData['id_field'], $rowData['field_name'], $rowData['field_desc']);
1437 1437
 					},
@@ -1447,7 +1447,7 @@  discard block
 block discarded – undo
1447 1447
 					'value' => $txt['custom_profile_fieldtype'],
1448 1448
 				),
1449 1449
 				'data' => array(
1450
-					'function' => function ($rowData) use ($txt)
1450
+					'function' => function($rowData) use ($txt)
1451 1451
 					{
1452 1452
 						$textKey = sprintf('custom_profile_type_%1$s', $rowData['field_type']);
1453 1453
 						return isset($txt[$textKey]) ? $txt[$textKey] : $textKey;
@@ -1465,7 +1465,7 @@  discard block
 block discarded – undo
1465 1465
 					'value' => $txt['custom_profile_active'],
1466 1466
 				),
1467 1467
 				'data' => array(
1468
-					'function' => function ($rowData) use ($txt)
1468
+					'function' => function($rowData) use ($txt)
1469 1469
 					{
1470 1470
 						return $rowData['active'] ? $txt['yes'] : $txt['no'];
1471 1471
 					},
@@ -1482,7 +1482,7 @@  discard block
 block discarded – undo
1482 1482
 					'value' => $txt['custom_profile_placement'],
1483 1483
 				),
1484 1484
 				'data' => array(
1485
-					'function' => function ($rowData)
1485
+					'function' => function($rowData)
1486 1486
 					{
1487 1487
 						global $txt, $context;
1488 1488
 
@@ -1717,7 +1717,7 @@  discard block
 block discarded – undo
1717 1717
 			redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler
1718 1718
 
1719 1719
 		// All good, proceed.
1720
-		$smcFunc['db_query']('','
1720
+		$smcFunc['db_query']('', '
1721 1721
 			UPDATE {db_prefix}custom_fields
1722 1722
 			SET field_order = {int:old_order}
1723 1723
 			WHERE field_order = {int:new_order}',
@@ -1726,7 +1726,7 @@  discard block
 block discarded – undo
1726 1726
 				'old_order' => $context['field']['order'],
1727 1727
 			)
1728 1728
 		);
1729
-		$smcFunc['db_query']('','
1729
+		$smcFunc['db_query']('', '
1730 1730
 			UPDATE {db_prefix}custom_fields
1731 1731
 			SET field_order = {int:new_order}
1732 1732
 			WHERE id_field = {int:id_field}',
@@ -1828,7 +1828,7 @@  discard block
 block discarded – undo
1828 1828
 			$smcFunc['db_free_result']($request);
1829 1829
 
1830 1830
 			$unique = false;
1831
-			for ($i = 0; !$unique && $i < 9; $i ++)
1831
+			for ($i = 0; !$unique && $i < 9; $i++)
1832 1832
 			{
1833 1833
 				if (!in_array($col_name, $current_fields))
1834 1834
 					$unique = true;
@@ -2001,7 +2001,7 @@  discard block
 block discarded – undo
2001 2001
 		);
2002 2002
 
2003 2003
 		// Re-arrange the order.
2004
-		$smcFunc['db_query']('','
2004
+		$smcFunc['db_query']('', '
2005 2005
 			UPDATE {db_prefix}custom_fields
2006 2006
 			SET field_order = field_order - 1
2007 2007
 			WHERE field_order > {int:current_order}',
@@ -2266,7 +2266,7 @@  discard block
 block discarded – undo
2266 2266
 	$context['token_check'] = 'noti-admin';
2267 2267
 
2268 2268
 	// Specify our action since we'll want to post back here instead of the profile
2269
-	$context['action'] = 'action=admin;area=featuresettings;sa=alerts;'. $context['session_var'] .'='. $context['session_id'];
2269
+	$context['action'] = 'action=admin;area=featuresettings;sa=alerts;' . $context['session_var'] . '=' . $context['session_id'];
2270 2270
 
2271 2271
 	loadTemplate('Profile');
2272 2272
 	loadLanguage('Profile');
@@ -2438,10 +2438,10 @@  discard block
 block discarded – undo
2438 2438
 			if (!empty($_REQUEST['save_new_policy']))
2439 2439
 				$currentVersion++;
2440 2440
 			
2441
-			$config_vars[] = array('text', 'policy_text'.$currentVersion);
2442
-			$_POST['policy_text'.$currentVersion] = $_REQUEST['policy_text'];
2441
+			$config_vars[] = array('text', 'policy_text' . $currentVersion);
2442
+			$_POST['policy_text' . $currentVersion] = $_REQUEST['policy_text'];
2443 2443
 			$config_vars[] = array('text', 'policy_version');
2444
-			$_POST['policy_version'] = 'policy_text'.$currentVersion;
2444
+			$_POST['policy_version'] = 'policy_text' . $currentVersion;
2445 2445
 			unset($config_vars[1]);
2446 2446
 			saveDBSettings($config_vars);
2447 2447
 		}
@@ -2499,7 +2499,7 @@  discard block
 block discarded – undo
2499 2499
 			)
2500 2500
 		);
2501 2501
 		
2502
-		$smcFunc['db_query']('','
2502
+		$smcFunc['db_query']('', '
2503 2503
 			DELETE FROM {db_prefix}settings
2504 2504
 			WHERE variable = {string:policy_text}',
2505 2505
 			array(
Please login to merge, or discard this patch.
Braces   +287 added lines, -211 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
  * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or.
@@ -212,16 +213,18 @@  discard block
 block discarded – undo
212 213
 	{
213 214
 		$all_zones = timezone_identifiers_list();
214 215
 		// Make sure we set the value to the same as the printed value.
215
-		foreach ($all_zones as $zone)
216
-			$config_vars['default_timezone'][2][$zone] = $zone;
216
+		foreach ($all_zones as $zone) {
217
+					$config_vars['default_timezone'][2][$zone] = $zone;
218
+		}
219
+	} else {
220
+			unset($config_vars['default_timezone']);
217 221
 	}
218
-	else
219
-		unset($config_vars['default_timezone']);
220 222
 
221 223
 	call_integration_hook('integrate_modify_basic_settings', array(&$config_vars));
222 224
 
223
-	if ($return_config)
224
-		return $config_vars;
225
+	if ($return_config) {
226
+			return $config_vars;
227
+	}
225 228
 
226 229
 	// Saving?
227 230
 	if (isset($_GET['save']))
@@ -229,8 +232,9 @@  discard block
 block discarded – undo
229 232
 		checkSession();
230 233
 
231 234
 		// Prevent absurd boundaries here - make it a day tops.
232
-		if (isset($_POST['lastActive']))
233
-			$_POST['lastActive'] = min((int) $_POST['lastActive'], 1440);
235
+		if (isset($_POST['lastActive'])) {
236
+					$_POST['lastActive'] = min((int) $_POST['lastActive'], 1440);
237
+		}
234 238
 
235 239
 		call_integration_hook('integrate_save_basic_settings');
236 240
 
@@ -238,8 +242,9 @@  discard block
 block discarded – undo
238 242
 		$_SESSION['adm-save'] = true;
239 243
 
240 244
 		// Do a bit of housekeeping
241
-		if (empty($_POST['minimize_files']))
242
-			deleteAllMinified();
245
+		if (empty($_POST['minimize_files'])) {
246
+					deleteAllMinified();
247
+		}
243 248
 
244 249
 		writeLog();
245 250
 		redirectexit('action=admin;area=featuresettings;sa=basic');
@@ -279,8 +284,9 @@  discard block
 block discarded – undo
279 284
 
280 285
 	call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars));
281 286
 
282
-	if ($return_config)
283
-		return $config_vars;
287
+	if ($return_config) {
288
+			return $config_vars;
289
+	}
284 290
 
285 291
 	// Setup the template.
286 292
 	require_once($sourcedir . '/ManageServer.php');
@@ -297,13 +303,15 @@  discard block
 block discarded – undo
297 303
 
298 304
 		// Clean up the tags.
299 305
 		$bbcTags = array();
300
-		foreach (parse_bbc(false) as $tag)
301
-			$bbcTags[] = $tag['tag'];
306
+		foreach (parse_bbc(false) as $tag) {
307
+					$bbcTags[] = $tag['tag'];
308
+		}
302 309
 
303
-		if (!isset($_POST['disabledBBC_enabledTags']))
304
-			$_POST['disabledBBC_enabledTags'] = array();
305
-		elseif (!is_array($_POST['disabledBBC_enabledTags']))
306
-			$_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']);
310
+		if (!isset($_POST['disabledBBC_enabledTags'])) {
311
+					$_POST['disabledBBC_enabledTags'] = array();
312
+		} elseif (!is_array($_POST['disabledBBC_enabledTags'])) {
313
+					$_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']);
314
+		}
307 315
 		// Work out what is actually disabled!
308 316
 		$_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags']));
309 317
 
@@ -347,8 +355,9 @@  discard block
 block discarded – undo
347 355
 
348 356
 	call_integration_hook('integrate_layout_settings', array(&$config_vars));
349 357
 
350
-	if ($return_config)
351
-		return $config_vars;
358
+	if ($return_config) {
359
+			return $config_vars;
360
+	}
352 361
 
353 362
 	// Saving?
354 363
 	if (isset($_GET['save']))
@@ -388,8 +397,9 @@  discard block
 block discarded – undo
388 397
 
389 398
 	call_integration_hook('integrate_likes_settings', array(&$config_vars));
390 399
 
391
-	if ($return_config)
392
-		return $config_vars;
400
+	if ($return_config) {
401
+			return $config_vars;
402
+	}
393 403
 
394 404
 	// Saving?
395 405
 	if (isset($_GET['save']))
@@ -427,8 +437,9 @@  discard block
 block discarded – undo
427 437
 
428 438
 	call_integration_hook('integrate_mentions_settings', array(&$config_vars));
429 439
 
430
-	if ($return_config)
431
-		return $config_vars;
440
+	if ($return_config) {
441
+			return $config_vars;
442
+	}
432 443
 
433 444
 	// Saving?
434 445
 	if (isset($_GET['save']))
@@ -472,8 +483,8 @@  discard block
 block discarded – undo
472 483
 			'enable' => array('check', 'warning_enable'),
473 484
 	);
474 485
 
475
-	if (!empty($modSettings['warning_settings']) && $currently_enabled)
476
-		$config_vars += array(
486
+	if (!empty($modSettings['warning_settings']) && $currently_enabled) {
487
+			$config_vars += array(
477 488
 			'',
478 489
 				array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']),
479 490
 				'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']),
@@ -482,15 +493,18 @@  discard block
 block discarded – undo
482 493
 				'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']),
483 494
 				array('permissions', 'view_warning'),
484 495
 		);
496
+	}
485 497
 
486 498
 	call_integration_hook('integrate_warning_settings', array(&$config_vars));
487 499
 
488
-	if ($return_config)
489
-		return $config_vars;
500
+	if ($return_config) {
501
+			return $config_vars;
502
+	}
490 503
 
491 504
 	// Cannot use moderation if post moderation is not enabled.
492
-	if (!$modSettings['postmod_active'])
493
-		unset($config_vars['moderate']);
505
+	if (!$modSettings['postmod_active']) {
506
+			unset($config_vars['moderate']);
507
+	}
494 508
 
495 509
 	// Will need the utility functions from here.
496 510
 	require_once($sourcedir . '/ManageServer.php');
@@ -515,16 +529,16 @@  discard block
 block discarded – undo
515 529
 				'warning_watch' => 10,
516 530
 				'warning_mute' => 60,
517 531
 			);
518
-			if ($modSettings['postmod_active'])
519
-				$vars['warning_moderate'] = 35;
532
+			if ($modSettings['postmod_active']) {
533
+							$vars['warning_moderate'] = 35;
534
+			}
520 535
 
521 536
 			foreach ($vars as $var => $value)
522 537
 			{
523 538
 				$config_vars[] = array('int', $var);
524 539
 				$_POST[$var] = $value;
525 540
 			}
526
-		}
527
-		else
541
+		} else
528 542
 		{
529 543
 			$_POST['warning_watch'] = min($_POST['warning_watch'], 100);
530 544
 			$_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0;
@@ -612,8 +626,9 @@  discard block
 block discarded – undo
612 626
 
613 627
 	call_integration_hook('integrate_spam_settings', array(&$config_vars));
614 628
 
615
-	if ($return_config)
616
-		return $config_vars;
629
+	if ($return_config) {
630
+			return $config_vars;
631
+	}
617 632
 
618 633
 	// You need to be an admin to edit settings!
619 634
 	isAllowedTo('admin_forum');
@@ -647,8 +662,9 @@  discard block
 block discarded – undo
647 662
 
648 663
 	if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers']))
649 664
 	{
650
-		if (empty($context['settings_insert_above']))
651
-			$context['settings_insert_above'] = '';
665
+		if (empty($context['settings_insert_above'])) {
666
+					$context['settings_insert_above'] = '';
667
+		}
652 668
 
653 669
 		$context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>';
654 670
 	}
@@ -690,8 +706,9 @@  discard block
 block discarded – undo
690 706
 		$_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour'];
691 707
 
692 708
 		// Hack in guest requiring verification!
693
-		if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha']))
694
-			$_POST['posts_require_captcha'] = -1;
709
+		if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) {
710
+					$_POST['posts_require_captcha'] = -1;
711
+		}
695 712
 
696 713
 		$save_vars = $config_vars;
697 714
 		unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']);
@@ -708,14 +725,16 @@  discard block
 block discarded – undo
708 725
 		foreach ($context['qa_languages'] as $lang_id => $dummy)
709 726
 		{
710 727
 			// If we had some questions for this language before, but don't now, delete everything from that language.
711
-			if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id]))
712
-				$changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]);
728
+			if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) {
729
+							$changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]);
730
+			}
713 731
 
714 732
 			// Now step through and see if any existing questions no longer exist.
715
-			if (!empty($context['qa_by_lang'][$lang_id]))
716
-				foreach ($context['qa_by_lang'][$lang_id] as $q_id)
733
+			if (!empty($context['qa_by_lang'][$lang_id])) {
734
+							foreach ($context['qa_by_lang'][$lang_id] as $q_id)
717 735
 					if (empty($_POST['question'][$lang_id][$q_id]))
718 736
 						$changes['delete'][] = $q_id;
737
+			}
719 738
 
720 739
 			// Now let's see if there are new questions or ones that need updating.
721 740
 			if (isset($_POST['question'][$lang_id]))
@@ -724,14 +743,16 @@  discard block
 block discarded – undo
724 743
 				{
725 744
 					// Ignore junky ids.
726 745
 					$q_id = (int) $q_id;
727
-					if ($q_id <= 0)
728
-						continue;
746
+					if ($q_id <= 0) {
747
+											continue;
748
+					}
729 749
 
730 750
 					// Check the question isn't empty (because they want to delete it?)
731 751
 					if (empty($question) || trim($question) == '')
732 752
 					{
733
-						if (isset($context['question_answers'][$q_id]))
734
-							$changes['delete'][] = $q_id;
753
+						if (isset($context['question_answers'][$q_id])) {
754
+													$changes['delete'][] = $q_id;
755
+						}
735 756
 						continue;
736 757
 					}
737 758
 					$question = $smcFunc['htmlspecialchars'](trim($question));
@@ -739,19 +760,22 @@  discard block
 block discarded – undo
739 760
 					// Get the answers. Firstly check there actually might be some.
740 761
 					if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id]))
741 762
 					{
742
-						if (isset($context['question_answers'][$q_id]))
743
-							$changes['delete'][] = $q_id;
763
+						if (isset($context['question_answers'][$q_id])) {
764
+													$changes['delete'][] = $q_id;
765
+						}
744 766
 						continue;
745 767
 					}
746 768
 					// Now get them and check that they might be viable.
747 769
 					$answers = array();
748
-					foreach ($_POST['answer'][$lang_id][$q_id] as $answer)
749
-						if (!empty($answer) && trim($answer) !== '')
770
+					foreach ($_POST['answer'][$lang_id][$q_id] as $answer) {
771
+											if (!empty($answer) && trim($answer) !== '')
750 772
 							$answers[] = $smcFunc['htmlspecialchars'](trim($answer));
773
+					}
751 774
 					if (empty($answers))
752 775
 					{
753
-						if (isset($context['question_answers'][$q_id]))
754
-							$changes['delete'][] = $q_id;
776
+						if (isset($context['question_answers'][$q_id])) {
777
+													$changes['delete'][] = $q_id;
778
+						}
755 779
 						continue;
756 780
 					}
757 781
 					$answers = $smcFunc['json_encode']($answers);
@@ -761,16 +785,17 @@  discard block
 block discarded – undo
761 785
 					{
762 786
 						// New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids.
763 787
 						$changes['insert'][] = array($lang_id, $question, $answers);
764
-					}
765
-					else
788
+					} else
766 789
 					{
767 790
 						// It's an existing question. Let's see what's changed, if anything.
768
-						if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers'])
769
-							$changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers);
791
+						if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) {
792
+													$changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers);
793
+						}
770 794
 					}
771 795
 
772
-					if (!isset($qs_per_lang[$lang_id]))
773
-						$qs_per_lang[$lang_id] = 0;
796
+					if (!isset($qs_per_lang[$lang_id])) {
797
+											$qs_per_lang[$lang_id] = 0;
798
+					}
774 799
 					$qs_per_lang[$lang_id]++;
775 800
 				}
776 801
 			}
@@ -820,8 +845,9 @@  discard block
 block discarded – undo
820 845
 
821 846
 		// Lastly, the count of messages needs to be no more than the lowest number of questions for any one language.
822 847
 		$count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang);
823
-		if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions)
824
-			$_POST['qa_verification_number'] = $count_questions;
848
+		if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) {
849
+					$_POST['qa_verification_number'] = $count_questions;
850
+		}
825 851
 
826 852
 		call_integration_hook('integrate_save_spam_settings', array(&$save_vars));
827 853
 
@@ -836,24 +862,27 @@  discard block
 block discarded – undo
836 862
 
837 863
 	$character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y'));
838 864
 	$_SESSION['visual_verification_code'] = '';
839
-	for ($i = 0; $i < 6; $i++)
840
-		$_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)];
865
+	for ($i = 0; $i < 6; $i++) {
866
+			$_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)];
867
+	}
841 868
 
842 869
 	// Some javascript for CAPTCHA.
843 870
 	$context['settings_post_javascript'] = '';
844
-	if ($context['use_graphic_library'])
845
-		$context['settings_post_javascript'] .= '
871
+	if ($context['use_graphic_library']) {
872
+			$context['settings_post_javascript'] .= '
846 873
 		function refreshImages()
847 874
 		{
848 875
 			var imageType = document.getElementById(\'visual_verification_type\').value;
849 876
 			document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType;
850 877
 		}';
878
+	}
851 879
 
852 880
 	// Show the image itself, or text saying we can't.
853
-	if ($context['use_graphic_library'])
854
-		$config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>';
855
-	else
856
-		$config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>';
881
+	if ($context['use_graphic_library']) {
882
+			$config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>';
883
+	} else {
884
+			$config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>';
885
+	}
857 886
 
858 887
 	// Hack for PM spam settings.
859 888
 	list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']);
@@ -863,9 +892,10 @@  discard block
 block discarded – undo
863 892
 	$modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha'];
864 893
 
865 894
 	// Some minor javascript for the guest post setting.
866
-	if ($modSettings['posts_require_captcha'])
867
-		$context['settings_post_javascript'] .= '
895
+	if ($modSettings['posts_require_captcha']) {
896
+			$context['settings_post_javascript'] .= '
868 897
 		document.getElementById(\'guests_require_captcha\').disabled = true;';
898
+	}
869 899
 
870 900
 	// And everything else.
871 901
 	$context['post_url'] = $scripturl . '?action=admin;area=antispam;save';
@@ -912,8 +942,9 @@  discard block
 block discarded – undo
912 942
 
913 943
 	call_integration_hook('integrate_signature_settings', array(&$config_vars));
914 944
 
915
-	if ($return_config)
916
-		return $config_vars;
945
+	if ($return_config) {
946
+			return $config_vars;
947
+	}
917 948
 
918 949
 	// Setup the template.
919 950
 	$context['page_title'] = $txt['signature_settings'];
@@ -968,8 +999,9 @@  discard block
 block discarded – undo
968 999
 				$sig = strtr($row['signature'], array('<br>' => "\n"));
969 1000
 
970 1001
 				// Max characters...
971
-				if (!empty($sig_limits[1]))
972
-					$sig = $smcFunc['substr']($sig, 0, $sig_limits[1]);
1002
+				if (!empty($sig_limits[1])) {
1003
+									$sig = $smcFunc['substr']($sig, 0, $sig_limits[1]);
1004
+				}
973 1005
 				// Max lines...
974 1006
 				if (!empty($sig_limits[2]))
975 1007
 				{
@@ -979,8 +1011,9 @@  discard block
 block discarded – undo
979 1011
 						if ($sig[$i] == "\n")
980 1012
 						{
981 1013
 							$count++;
982
-							if ($count >= $sig_limits[2])
983
-								$sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' '));
1014
+							if ($count >= $sig_limits[2]) {
1015
+															$sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' '));
1016
+							}
984 1017
 						}
985 1018
 					}
986 1019
 				}
@@ -991,17 +1024,19 @@  discard block
 block discarded – undo
991 1024
 					{
992 1025
 						$limit_broke = 0;
993 1026
 						// Attempt to allow all sizes of abuse, so to speak.
994
-						if ($matches[2][$ind] == 'px' && $size > $sig_limits[7])
995
-							$limit_broke = $sig_limits[7] . 'px';
996
-						elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75))
997
-							$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
998
-						elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16))
999
-							$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
1000
-						elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18)
1001
-							$limit_broke = 'large';
1002
-
1003
-						if ($limit_broke)
1004
-							$sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig);
1027
+						if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) {
1028
+													$limit_broke = $sig_limits[7] . 'px';
1029
+						} elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) {
1030
+													$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
1031
+						} elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) {
1032
+													$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
1033
+						} elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) {
1034
+													$limit_broke = 'large';
1035
+						}
1036
+
1037
+						if ($limit_broke) {
1038
+													$sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig);
1039
+						}
1005 1040
 					}
1006 1041
 				}
1007 1042
 
@@ -1057,32 +1092,34 @@  discard block
 block discarded – undo
1057 1092
 											$img_offset = false;
1058 1093
 										}
1059 1094
 									}
1095
+								} else {
1096
+																	$replaces[$image] = '';
1060 1097
 								}
1061
-								else
1062
-									$replaces[$image] = '';
1063 1098
 
1064 1099
 								continue;
1065 1100
 							}
1066 1101
 
1067 1102
 							// Does it have predefined restraints? Width first.
1068
-							if ($matches[6][$key])
1069
-								$matches[2][$key] = $matches[6][$key];
1103
+							if ($matches[6][$key]) {
1104
+															$matches[2][$key] = $matches[6][$key];
1105
+							}
1070 1106
 							if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5])
1071 1107
 							{
1072 1108
 								$width = $sig_limits[5];
1073 1109
 								$matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]);
1110
+							} elseif ($matches[2][$key]) {
1111
+															$width = $matches[2][$key];
1074 1112
 							}
1075
-							elseif ($matches[2][$key])
1076
-								$width = $matches[2][$key];
1077 1113
 							// ... and height.
1078 1114
 							if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6])
1079 1115
 							{
1080 1116
 								$height = $sig_limits[6];
1081
-								if ($width != -1)
1082
-									$width = $width * ($height / $matches[4][$key]);
1117
+								if ($width != -1) {
1118
+																	$width = $width * ($height / $matches[4][$key]);
1119
+								}
1120
+							} elseif ($matches[4][$key]) {
1121
+															$height = $matches[4][$key];
1083 1122
 							}
1084
-							elseif ($matches[4][$key])
1085
-								$height = $matches[4][$key];
1086 1123
 
1087 1124
 							// If the dimensions are still not fixed - we need to check the actual image.
1088 1125
 							if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6]))
@@ -1100,12 +1137,13 @@  discard block
 block discarded – undo
1100 1137
 									if ($sizes[1] > $sig_limits[6] && $sig_limits[6])
1101 1138
 									{
1102 1139
 										$height = $sig_limits[6];
1103
-										if ($width == -1)
1104
-											$width = $sizes[0];
1140
+										if ($width == -1) {
1141
+																					$width = $sizes[0];
1142
+										}
1105 1143
 										$width = $width * ($height / $sizes[1]);
1144
+									} elseif ($width != -1) {
1145
+																			$height = $sizes[1];
1106 1146
 									}
1107
-									elseif ($width != -1)
1108
-										$height = $sizes[1];
1109 1147
 								}
1110 1148
 							}
1111 1149
 
@@ -1118,8 +1156,9 @@  discard block
 block discarded – undo
1118 1156
 							// Record that we got one.
1119 1157
 							$image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1;
1120 1158
 						}
1121
-						if (!empty($replaces))
1122
-							$sig = str_replace(array_keys($replaces), array_values($replaces), $sig);
1159
+						if (!empty($replaces)) {
1160
+													$sig = str_replace(array_keys($replaces), array_values($replaces), $sig);
1161
+						}
1123 1162
 					}
1124 1163
 				}
1125 1164
 				// Try to fix disabled tags.
@@ -1131,18 +1170,20 @@  discard block
 block discarded – undo
1131 1170
 
1132 1171
 				$sig = strtr($sig, array("\n" => '<br>'));
1133 1172
 				call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags));
1134
-				if ($sig != $row['signature'])
1135
-					$changes[$row['id_member']] = $sig;
1173
+				if ($sig != $row['signature']) {
1174
+									$changes[$row['id_member']] = $sig;
1175
+				}
1176
+			}
1177
+			if ($smcFunc['db_num_rows']($request) == 0) {
1178
+							$done = true;
1136 1179
 			}
1137
-			if ($smcFunc['db_num_rows']($request) == 0)
1138
-				$done = true;
1139 1180
 			$smcFunc['db_free_result']($request);
1140 1181
 
1141 1182
 			// Do we need to delete what we have?
1142 1183
 			if (!empty($changes))
1143 1184
 			{
1144
-				foreach ($changes as $id => $sig)
1145
-					$smcFunc['db_query']('', '
1185
+				foreach ($changes as $id => $sig) {
1186
+									$smcFunc['db_query']('', '
1146 1187
 						UPDATE {db_prefix}members
1147 1188
 						SET signature = {string:signature}
1148 1189
 						WHERE id_member = {int:id_member}',
@@ -1151,11 +1192,13 @@  discard block
 block discarded – undo
1151 1192
 							'signature' => $sig,
1152 1193
 						)
1153 1194
 					);
1195
+				}
1154 1196
 			}
1155 1197
 
1156 1198
 			$_GET['step'] += 50;
1157
-			if (!$done)
1158
-				pauseSignatureApplySettings();
1199
+			if (!$done) {
1200
+							pauseSignatureApplySettings();
1201
+			}
1159 1202
 		}
1160 1203
 		$settings_applied = true;
1161 1204
 	}
@@ -1173,8 +1216,9 @@  discard block
 block discarded – undo
1173 1216
 	);
1174 1217
 
1175 1218
 	// Temporarily make each setting a modSetting!
1176
-	foreach ($context['signature_settings'] as $key => $value)
1177
-		$modSettings['signature_' . $key] = $value;
1219
+	foreach ($context['signature_settings'] as $key => $value) {
1220
+			$modSettings['signature_' . $key] = $value;
1221
+	}
1178 1222
 
1179 1223
 	// Make sure we check the right tags!
1180 1224
 	$modSettings['bbc_disabled_signature_bbc'] = $disabledTags;
@@ -1186,23 +1230,26 @@  discard block
 block discarded – undo
1186 1230
 
1187 1231
 		// Clean up the tag stuff!
1188 1232
 		$bbcTags = array();
1189
-		foreach (parse_bbc(false) as $tag)
1190
-			$bbcTags[] = $tag['tag'];
1233
+		foreach (parse_bbc(false) as $tag) {
1234
+					$bbcTags[] = $tag['tag'];
1235
+		}
1191 1236
 
1192
-		if (!isset($_POST['signature_bbc_enabledTags']))
1193
-			$_POST['signature_bbc_enabledTags'] = array();
1194
-		elseif (!is_array($_POST['signature_bbc_enabledTags']))
1195
-			$_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']);
1237
+		if (!isset($_POST['signature_bbc_enabledTags'])) {
1238
+					$_POST['signature_bbc_enabledTags'] = array();
1239
+		} elseif (!is_array($_POST['signature_bbc_enabledTags'])) {
1240
+					$_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']);
1241
+		}
1196 1242
 
1197 1243
 		$sig_limits = array();
1198 1244
 		foreach ($context['signature_settings'] as $key => $value)
1199 1245
 		{
1200
-			if ($key == 'allow_smileys')
1201
-				continue;
1202
-			elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys']))
1203
-				$sig_limits[] = -1;
1204
-			else
1205
-				$sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0;
1246
+			if ($key == 'allow_smileys') {
1247
+							continue;
1248
+			} elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) {
1249
+							$sig_limits[] = -1;
1250
+			} else {
1251
+							$sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0;
1252
+			}
1206 1253
 		}
1207 1254
 
1208 1255
 		call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags));
@@ -1235,12 +1282,14 @@  discard block
 block discarded – undo
1235 1282
 
1236 1283
 	// Try get more time...
1237 1284
 	@set_time_limit(600);
1238
-	if (function_exists('apache_reset_timeout'))
1239
-		@apache_reset_timeout();
1285
+	if (function_exists('apache_reset_timeout')) {
1286
+			@apache_reset_timeout();
1287
+	}
1240 1288
 
1241 1289
 	// Have we exhausted all the time we allowed?
1242
-	if (time() - array_sum(explode(' ', $sig_start)) < 3)
1243
-		return;
1290
+	if (time() - array_sum(explode(' ', $sig_start)) < 3) {
1291
+			return;
1292
+	}
1244 1293
 
1245 1294
 	$context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id'];
1246 1295
 	$context['page_title'] = $txt['not_done_title'];
@@ -1286,9 +1335,10 @@  discard block
 block discarded – undo
1286 1335
 		$disable_fields = array_flip($standard_fields);
1287 1336
 		if (!empty($_POST['active']))
1288 1337
 		{
1289
-			foreach ($_POST['active'] as $value)
1290
-				if (isset($disable_fields[$value]))
1338
+			foreach ($_POST['active'] as $value) {
1339
+							if (isset($disable_fields[$value]))
1291 1340
 					unset($disable_fields[$value]);
1341
+			}
1292 1342
 		}
1293 1343
 		// What we have left!
1294 1344
 		$changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields));
@@ -1297,16 +1347,18 @@  discard block
 block discarded – undo
1297 1347
 		$reg_fields = array();
1298 1348
 		if (!empty($_POST['reg']))
1299 1349
 		{
1300
-			foreach ($_POST['reg'] as $value)
1301
-				if (in_array($value, $standard_fields) && !isset($disable_fields[$value]))
1350
+			foreach ($_POST['reg'] as $value) {
1351
+							if (in_array($value, $standard_fields) && !isset($disable_fields[$value]))
1302 1352
 					$reg_fields[] = $value;
1353
+			}
1303 1354
 		}
1304 1355
 		// What we have left!
1305 1356
 		$changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields);
1306 1357
 
1307 1358
 		$_SESSION['adm-save'] = true;
1308
-		if (!empty($changes))
1309
-			updateSettings($changes);
1359
+		if (!empty($changes)) {
1360
+					updateSettings($changes);
1361
+		}
1310 1362
 	}
1311 1363
 
1312 1364
 	createToken('admin-scp');
@@ -1409,11 +1461,13 @@  discard block
 block discarded – undo
1409 1461
 					{
1410 1462
 						$return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>';
1411 1463
 
1412
-						if ($rowData['field_order'] > 1)
1413
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>';
1464
+						if ($rowData['field_order'] > 1) {
1465
+													$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>';
1466
+						}
1414 1467
 
1415
-						if ($rowData['field_order'] < $context['custFieldsMaxOrder'])
1416
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>';
1468
+						if ($rowData['field_order'] < $context['custFieldsMaxOrder']) {
1469
+													$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>';
1470
+						}
1417 1471
 
1418 1472
 						$return .= '</p>';
1419 1473
 
@@ -1551,16 +1605,16 @@  discard block
 block discarded – undo
1551 1605
 		$disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array();
1552 1606
 		$registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array();
1553 1607
 
1554
-		foreach ($standard_fields as $field)
1555
-			$list[] = array(
1608
+		foreach ($standard_fields as $field) {
1609
+					$list[] = array(
1556 1610
 				'id' => $field,
1557 1611
 				'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field),
1558 1612
 				'disabled' => in_array($field, $disabled_fields),
1559 1613
 				'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration),
1560 1614
 				'can_show_register' => !in_array($field, $fields_no_registration),
1561 1615
 			);
1562
-	}
1563
-	else
1616
+		}
1617
+	} else
1564 1618
 	{
1565 1619
 		// Load all the fields.
1566 1620
 		$request = $smcFunc['db_query']('', '
@@ -1574,8 +1628,9 @@  discard block
 block discarded – undo
1574 1628
 				'items_per_page' => $items_per_page,
1575 1629
 			)
1576 1630
 		);
1577
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1578
-			$list[] = $row;
1631
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1632
+					$list[] = $row;
1633
+		}
1579 1634
 		$smcFunc['db_free_result']($request);
1580 1635
 	}
1581 1636
 
@@ -1641,9 +1696,9 @@  discard block
 block discarded – undo
1641 1696
 		$context['field'] = array();
1642 1697
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1643 1698
 		{
1644
-			if ($row['field_type'] == 'textarea')
1645
-				@list ($rows, $cols) = @explode(',', $row['default_value']);
1646
-			else
1699
+			if ($row['field_type'] == 'textarea') {
1700
+							@list ($rows, $cols) = @explode(',', $row['default_value']);
1701
+			} else
1647 1702
 			{
1648 1703
 				$rows = 3;
1649 1704
 				$cols = 30;
@@ -1679,8 +1734,8 @@  discard block
 block discarded – undo
1679 1734
 	}
1680 1735
 
1681 1736
 	// Setup the default values as needed.
1682
-	if (empty($context['field']))
1683
-		$context['field'] = array(
1737
+	if (empty($context['field'])) {
1738
+			$context['field'] = array(
1684 1739
 			'name' => '',
1685 1740
 			'col_name' => '???',
1686 1741
 			'desc' => '',
@@ -1705,6 +1760,7 @@  discard block
 block discarded – undo
1705 1760
 			'enclose' => '',
1706 1761
 			'placement' => 0,
1707 1762
 		);
1763
+	}
1708 1764
 
1709 1765
 	// Are we moving it?
1710 1766
 	if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to))
@@ -1713,8 +1769,10 @@  discard block
 block discarded – undo
1713 1769
 		$new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1));
1714 1770
 
1715 1771
 		// Is this a valid position?
1716
-		if ($new_order <= 0 || $new_order > $order_count)
1717
-			redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler
1772
+		if ($new_order <= 0 || $new_order > $order_count) {
1773
+					redirectexit('action=admin;area=featuresettings;sa=profile');
1774
+		}
1775
+		// @todo implement an error handler
1718 1776
 
1719 1777
 		// All good, proceed.
1720 1778
 		$smcFunc['db_query']('','
@@ -1745,12 +1803,14 @@  discard block
 block discarded – undo
1745 1803
 		validateToken('admin-ecp');
1746 1804
 
1747 1805
 		// Everyone needs a name - even the (bracket) unknown...
1748
-		if (trim($_POST['field_name']) == '')
1749
-			redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name');
1806
+		if (trim($_POST['field_name']) == '') {
1807
+					redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name');
1808
+		}
1750 1809
 
1751 1810
 		// Regex you say?  Do a very basic test to see if the pattern is valid
1752
-		if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false)
1753
-			redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error');
1811
+		if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) {
1812
+					redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error');
1813
+		}
1754 1814
 
1755 1815
 		$_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']);
1756 1816
 		$_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']);
@@ -1767,8 +1827,9 @@  discard block
 block discarded – undo
1767 1827
 
1768 1828
 		// Some masking stuff...
1769 1829
 		$mask = isset($_POST['mask']) ? $_POST['mask'] : '';
1770
-		if ($mask == 'regex' && isset($_POST['regex']))
1771
-			$mask .= $_POST['regex'];
1830
+		if ($mask == 'regex' && isset($_POST['regex'])) {
1831
+					$mask .= $_POST['regex'];
1832
+		}
1772 1833
 
1773 1834
 		$field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255;
1774 1835
 		$enclose = isset($_POST['enclose']) ? $_POST['enclose'] : '';
@@ -1787,8 +1848,9 @@  discard block
 block discarded – undo
1787 1848
 				$v = strtr($v, array(',' => ''));
1788 1849
 
1789 1850
 				// Nada, zip, etc...
1790
-				if (trim($v) == '')
1791
-					continue;
1851
+				if (trim($v) == '') {
1852
+									continue;
1853
+				}
1792 1854
 
1793 1855
 				// Otherwise, save it boy.
1794 1856
 				$field_options .= $v . ',';
@@ -1796,15 +1858,17 @@  discard block
 block discarded – undo
1796 1858
 				$newOptions[$k] = $v;
1797 1859
 
1798 1860
 				// Is it default?
1799
-				if (isset($_POST['default_select']) && $_POST['default_select'] == $k)
1800
-					$default = $v;
1861
+				if (isset($_POST['default_select']) && $_POST['default_select'] == $k) {
1862
+									$default = $v;
1863
+				}
1801 1864
 			}
1802 1865
 			$field_options = substr($field_options, 0, -1);
1803 1866
 		}
1804 1867
 
1805 1868
 		// Text area has default has dimensions
1806
-		if ($_POST['field_type'] == 'textarea')
1807
-			$default = (int) $_POST['rows'] . ',' . (int) $_POST['cols'];
1869
+		if ($_POST['field_type'] == 'textarea') {
1870
+					$default = (int) $_POST['rows'] . ',' . (int) $_POST['cols'];
1871
+		}
1808 1872
 
1809 1873
 		// Come up with the unique name?
1810 1874
 		if (empty($context['fid']))
@@ -1813,32 +1877,36 @@  discard block
 block discarded – undo
1813 1877
 			preg_match('~([\w\d_-]+)~', $col_name, $matches);
1814 1878
 
1815 1879
 			// If there is nothing to the name, then let's start out own - for foreign languages etc.
1816
-			if (isset($matches[1]))
1817
-				$col_name = $initial_col_name = 'cust_' . strtolower($matches[1]);
1818
-			else
1819
-				$col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999);
1880
+			if (isset($matches[1])) {
1881
+							$col_name = $initial_col_name = 'cust_' . strtolower($matches[1]);
1882
+			} else {
1883
+							$col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999);
1884
+			}
1820 1885
 
1821 1886
 			// Make sure this is unique.
1822 1887
 			$current_fields = array();
1823 1888
 			$request = $smcFunc['db_query']('', '
1824 1889
 				SELECT id_field, col_name
1825 1890
 				FROM {db_prefix}custom_fields');
1826
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1827
-				$current_fields[$row['id_field']] = $row['col_name'];
1891
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1892
+							$current_fields[$row['id_field']] = $row['col_name'];
1893
+			}
1828 1894
 			$smcFunc['db_free_result']($request);
1829 1895
 
1830 1896
 			$unique = false;
1831 1897
 			for ($i = 0; !$unique && $i < 9; $i ++)
1832 1898
 			{
1833
-				if (!in_array($col_name, $current_fields))
1834
-					$unique = true;
1835
-				else
1836
-					$col_name = $initial_col_name . $i;
1899
+				if (!in_array($col_name, $current_fields)) {
1900
+									$unique = true;
1901
+				} else {
1902
+									$col_name = $initial_col_name . $i;
1903
+				}
1837 1904
 			}
1838 1905
 
1839 1906
 			// Still not a unique column name? Leave it up to the user, then.
1840
-			if (!$unique)
1841
-				fatal_lang_error('custom_option_not_unique');
1907
+			if (!$unique) {
1908
+							fatal_lang_error('custom_option_not_unique');
1909
+			}
1842 1910
 		}
1843 1911
 		// Work out what to do with the user data otherwise...
1844 1912
 		else
@@ -1866,8 +1934,9 @@  discard block
 block discarded – undo
1866 1934
 				// Work out what's changed!
1867 1935
 				foreach ($context['field']['options'] as $k => $option)
1868 1936
 				{
1869
-					if (trim($option) == '')
1870
-						continue;
1937
+					if (trim($option) == '') {
1938
+											continue;
1939
+					}
1871 1940
 
1872 1941
 					// Still exists?
1873 1942
 					if (in_array($option, $newOptions))
@@ -1881,8 +1950,8 @@  discard block
 block discarded – undo
1881 1950
 				foreach ($optionChanges as $k => $option)
1882 1951
 				{
1883 1952
 					// Just been renamed?
1884
-					if (!in_array($k, $takenKeys) && !empty($newOptions[$k]))
1885
-						$smcFunc['db_query']('', '
1953
+					if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) {
1954
+											$smcFunc['db_query']('', '
1886 1955
 							UPDATE {db_prefix}themes
1887 1956
 							SET value = {string:new_value}
1888 1957
 							WHERE variable = {string:current_column}
@@ -1895,6 +1964,7 @@  discard block
 block discarded – undo
1895 1964
 								'old_value' => $option,
1896 1965
 							)
1897 1966
 						);
1967
+					}
1898 1968
 				}
1899 1969
 			}
1900 1970
 			// @todo Maybe we should adjust based on new text length limits?
@@ -1937,8 +2007,8 @@  discard block
 block discarded – undo
1937 2007
 			);
1938 2008
 
1939 2009
 			// Just clean up any old selects - these are a pain!
1940
-			if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions))
1941
-				$smcFunc['db_query']('', '
2010
+			if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) {
2011
+							$smcFunc['db_query']('', '
1942 2012
 					DELETE FROM {db_prefix}themes
1943 2013
 					WHERE variable = {string:current_column}
1944 2014
 						AND value NOT IN ({array_string:new_option_values})
@@ -1949,8 +2019,8 @@  discard block
 block discarded – undo
1949 2019
 						'current_column' => $context['field']['col_name'],
1950 2020
 					)
1951 2021
 				);
1952
-		}
1953
-		else
2022
+			}
2023
+		} else
1954 2024
 		{
1955 2025
 			// Gotta figure it out the order.
1956 2026
 			$new_order = $order_count > 1 ? ($order_count + 1) : 1;
@@ -2125,11 +2195,13 @@  discard block
 block discarded – undo
2125 2195
 	call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false));
2126 2196
 
2127 2197
 	$prune_toggle_dt = array();
2128
-	foreach ($prune_toggle as $item)
2129
-		$prune_toggle_dt[] = 'setting_' . $item;
2198
+	foreach ($prune_toggle as $item) {
2199
+			$prune_toggle_dt[] = 'setting_' . $item;
2200
+	}
2130 2201
 
2131
-	if ($return_config)
2132
-		return $config_vars;
2202
+	if ($return_config) {
2203
+			return $config_vars;
2204
+	}
2133 2205
 
2134 2206
 	addInlineJavaScript('
2135 2207
 	function togglePruned()
@@ -2167,15 +2239,16 @@  discard block
 block discarded – undo
2167 2239
 			$vals = array();
2168 2240
 			foreach ($config_vars as $index => $dummy)
2169 2241
 			{
2170
-				if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle))
2171
-					continue;
2242
+				if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) {
2243
+									continue;
2244
+				}
2172 2245
 
2173 2246
 				$vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]];
2174 2247
 			}
2175 2248
 			$_POST['pruningOptions'] = implode(',', $vals);
2249
+		} else {
2250
+					$_POST['pruningOptions'] = '';
2176 2251
 		}
2177
-		else
2178
-			$_POST['pruningOptions'] = '';
2179 2252
 
2180 2253
 		saveDBSettings($savevar);
2181 2254
 		$_SESSION['adm-save'] = true;
@@ -2187,10 +2260,11 @@  discard block
 block discarded – undo
2187 2260
 	$context['sub_template'] = 'show_settings';
2188 2261
 
2189 2262
 	// Get the actual values
2190
-	if (!empty($modSettings['pruningOptions']))
2191
-		@list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
2192
-	else
2193
-		$modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0;
2263
+	if (!empty($modSettings['pruningOptions'])) {
2264
+			@list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
2265
+	} else {
2266
+			$modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0;
2267
+	}
2194 2268
 
2195 2269
 	prepareDBSettingContext($config_vars);
2196 2270
 }
@@ -2212,8 +2286,9 @@  discard block
 block discarded – undo
2212 2286
 	// Make it even easier to add new settings.
2213 2287
 	call_integration_hook('integrate_general_mod_settings', array(&$config_vars));
2214 2288
 
2215
-	if ($return_config)
2216
-		return $config_vars;
2289
+	if ($return_config) {
2290
+			return $config_vars;
2291
+	}
2217 2292
 
2218 2293
 	$context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general';
2219 2294
 	$context['settings_title'] = $txt['mods_cat_modifications_misc'];
@@ -2300,8 +2375,9 @@  discard block
 block discarded – undo
2300 2375
 
2301 2376
 	call_integration_hook('integrate_privacy_settings', array(&$config_vars));
2302 2377
 
2303
-	if ($return_config)
2304
-		return $config_vars;
2378
+	if ($return_config) {
2379
+			return $config_vars;
2380
+	}
2305 2381
 
2306 2382
 	// Saving?
2307 2383
 	if (isset($_GET['save']))
@@ -2400,8 +2476,9 @@  discard block
 block discarded – undo
2400 2476
 		);
2401 2477
 	}
2402 2478
 	$smcFunc['db_free_result']($request);
2403
-	if ($return_config)
2404
-		return $config_vars;
2479
+	if ($return_config) {
2480
+			return $config_vars;
2481
+	}
2405 2482
 
2406 2483
 	// Saving?
2407 2484
 	if (isset($_GET['save']))
@@ -2432,11 +2509,11 @@  discard block
 block discarded – undo
2432 2509
 					'bval' => 'policy_text' . $currentVersion,
2433 2510
 				)
2434 2511
 			);
2435
-		}
2436
-		elseif (!empty($_REQUEST['save_new_policy']) || !empty($_REQUEST['update_policy']))
2512
+		} elseif (!empty($_REQUEST['save_new_policy']) || !empty($_REQUEST['update_policy']))
2437 2513
 		{
2438
-			if (!empty($_REQUEST['save_new_policy']))
2439
-				$currentVersion++;
2514
+			if (!empty($_REQUEST['save_new_policy'])) {
2515
+							$currentVersion++;
2516
+			}
2440 2517
 			
2441 2518
 			$config_vars[] = array('text', 'policy_text'.$currentVersion);
2442 2519
 			$_POST['policy_text'.$currentVersion] = $_REQUEST['policy_text'];
@@ -2448,8 +2525,7 @@  discard block
 block discarded – undo
2448 2525
 
2449 2526
 		$_SESSION['adm-save'] = true;
2450 2527
 		redirectexit('action=admin;area=featuresettings;sa=policy');
2451
-	}
2452
-	elseif (isset($_GET['manage']))
2528
+	} elseif (isset($_GET['manage']))
2453 2529
 	{
2454 2530
 		checkSession();
2455 2531
 		
Please login to merge, or discard this patch.
Sources/Register.php 1 patch
Braces   +195 added lines, -144 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 4
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * Begin the registration process.
@@ -29,19 +30,23 @@  discard block
 block discarded – undo
29 30
 	global $language, $scripturl, $smcFunc, $sourcedir, $cur_profile;
30 31
 
31 32
 	// Is this an incoming AJAX check?
32
-	if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck')
33
-		return RegisterCheckUsername();
33
+	if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') {
34
+			return RegisterCheckUsername();
35
+	}
34 36
 
35 37
 	// Check if the administrator has it disabled.
36
-	if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3')
37
-		fatal_lang_error('registration_disabled', false);
38
+	if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') {
39
+			fatal_lang_error('registration_disabled', false);
40
+	}
38 41
 
39 42
 	// If this user is an admin - redirect them to the admin registration page.
40
-	if (allowedTo('moderate_forum') && !$user_info['is_guest'])
41
-		redirectexit('action=admin;area=regcenter;sa=register');
43
+	if (allowedTo('moderate_forum') && !$user_info['is_guest']) {
44
+			redirectexit('action=admin;area=regcenter;sa=register');
45
+	}
42 46
 	// You are not a guest, so you are a member - and members don't get to register twice!
43
-	elseif (empty($user_info['is_guest']))
44
-		redirectexit();
47
+	elseif (empty($user_info['is_guest'])) {
48
+			redirectexit();
49
+	}
45 50
 
46 51
 	loadLanguage('Login');
47 52
 	loadTemplate('Register');
@@ -94,32 +99,33 @@  discard block
 block discarded – undo
94 99
 	}
95 100
 
96 101
 	// Make sure they don't squeeze through without agreeing.
97
-	elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement'])
98
-		$current_step = 1;
102
+	elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) {
103
+			$current_step = 1;
104
+	}
99 105
 	// Make sure they don't squeeze through without agreeing.
100
-	elseif ($current_step > 2 && $context['require_policy'] && !$context['registration_passed_policy'])
101
-		$current_step = 2;
106
+	elseif ($current_step > 2 && $context['require_policy'] && !$context['registration_passed_policy']) {
107
+			$current_step = 2;
108
+	}
102 109
 
103 110
 	// Show the user the right form.
104 111
 	if ($current_step == 1)
105 112
 	{
106 113
 		$context['sub_template'] = 'registration_agreement';
107 114
 		$context['page_title'] = $txt['registration_agreement'];
108
-	}
109
-	elseif ($current_step == 2)
115
+	} elseif ($current_step == 2)
110 116
 	{
111 117
 		$context['sub_template'] = 'registration_policy';
112 118
 		$context['page_title'] = $txt['registration_policy'];
113
-	}
114
-	else
119
+	} else
115 120
 	{
116 121
 		$context['sub_template'] = 'registration_form';
117 122
 		$context['page_title'] = $txt['registration_form'];
118 123
 	}
119 124
 
120 125
 	// Kinda need this.
121
-	if ($context['sub_template'] == 'registration_form')
122
-		loadJavaScriptFile('register.js', array('defer' => false, 'minimize' => true), 'smf_register');
126
+	if ($context['sub_template'] == 'registration_form') {
127
+			loadJavaScriptFile('register.js', array('defer' => false, 'minimize' => true), 'smf_register');
128
+	}
123 129
 
124 130
 	// Add the register chain to the link tree.
125 131
 	$context['linktree'][] = array(
@@ -128,24 +134,26 @@  discard block
 block discarded – undo
128 134
 	);
129 135
 
130 136
 	// Prepare the time gate! Do it like so, in case later steps want to reset the limit for any reason, but make sure the time is the current one.
131
-	if (!isset($_SESSION['register']))
132
-		$_SESSION['register'] = array(
137
+	if (!isset($_SESSION['register'])) {
138
+			$_SESSION['register'] = array(
133 139
 			'timenow' => time(),
134 140
 			'limit' => 10, // minimum number of seconds required on this page for registration
135 141
 		);
136
-	else
137
-		$_SESSION['register']['timenow'] = time();
142
+	} else {
143
+			$_SESSION['register']['timenow'] = time();
144
+	}
138 145
 
139 146
 	// If you have to agree to the agreement, it needs to be fetched from the file.
140 147
 	if ($context['require_agreement'])
141 148
 	{
142 149
 		// Have we got a localized one?
143
-		if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt'))
144
-			$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']);
145
-		elseif (file_exists($boarddir . '/agreement.txt'))
146
-			$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement');
147
-		else
148
-			$context['agreement'] = '';
150
+		if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) {
151
+					$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']);
152
+		} elseif (file_exists($boarddir . '/agreement.txt')) {
153
+					$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement');
154
+		} else {
155
+					$context['agreement'] = '';
156
+		}
149 157
 
150 158
 		// Nothing to show, lets disable registration and inform the admin of this error
151 159
 		if (empty($context['agreement']))
@@ -160,10 +168,11 @@  discard block
 block discarded – undo
160 168
 	if ($context['require_policy'])
161 169
 	{
162 170
 		// Have we got a localized one?
163
-		if (!empty($modSettings[$modSettings['policy_version']]))
164
-			$context['policy'] = $modSettings[$modSettings['policy_version']];
165
-		else
166
-			$context['policy'] = '';
171
+		if (!empty($modSettings[$modSettings['policy_version']])) {
172
+					$context['policy'] = $modSettings[$modSettings['policy_version']];
173
+		} else {
174
+					$context['policy'] = '';
175
+		}
167 176
 
168 177
 		// Nothing to show, lets disable registration and inform the admin of this error
169 178
 		if (empty($context['policy']))
@@ -179,8 +188,9 @@  discard block
 block discarded – undo
179 188
 		$selectedLanguage = empty($_SESSION['language']) ? $language : $_SESSION['language'];
180 189
 
181 190
 		// Do we have any languages?
182
-		if (empty($context['languages']))
183
-			getLanguages();
191
+		if (empty($context['languages'])) {
192
+					getLanguages();
193
+		}
184 194
 
185 195
 		// Try to find our selected language.
186 196
 		foreach ($context['languages'] as $key => $lang)
@@ -188,8 +198,9 @@  discard block
 block discarded – undo
188 198
 			$context['languages'][$key]['name'] = strtr($lang['name'], array('-utf8' => ''));
189 199
 
190 200
 			// Found it!
191
-			if ($selectedLanguage == $lang['filename'])
192
-				$context['languages'][$key]['selected'] = true;
201
+			if ($selectedLanguage == $lang['filename']) {
202
+							$context['languages'][$key]['selected'] = true;
203
+			}
193 204
 		}
194 205
 	}
195 206
 
@@ -216,16 +227,19 @@  discard block
 block discarded – undo
216 227
 		if (in_array('website', $reg_fields))
217 228
 		{
218 229
 			unset($reg_fields['website']);
219
-			if (isset($_POST['website_title']))
220
-				$cur_profile['website_title'] = $smcFunc['htmlspecialchars']($_POST['website_title']);
221
-			if (isset($_POST['website_url']))
222
-				$cur_profile['website_url'] = $smcFunc['htmlspecialchars']($_POST['website_url']);
230
+			if (isset($_POST['website_title'])) {
231
+							$cur_profile['website_title'] = $smcFunc['htmlspecialchars']($_POST['website_title']);
232
+			}
233
+			if (isset($_POST['website_url'])) {
234
+							$cur_profile['website_url'] = $smcFunc['htmlspecialchars']($_POST['website_url']);
235
+			}
223 236
 		}
224 237
 
225 238
 		// We might have had some submissions on this front - go check.
226
-		foreach ($reg_fields as $field)
227
-			if (isset($_POST[$field]))
239
+		foreach ($reg_fields as $field) {
240
+					if (isset($_POST[$field]))
228 241
 				$cur_profile[$field] = $smcFunc['htmlspecialchars']($_POST[$field]);
242
+		}
229 243
 
230 244
 		// Load all the fields in question.
231 245
 		setupProfileContext($reg_fields);
@@ -242,8 +256,9 @@  discard block
 block discarded – undo
242 256
 		$context['visual_verification_id'] = $verificationOptions['id'];
243 257
 	}
244 258
 	// Otherwise we have nothing to show.
245
-	else
246
-		$context['visual_verification'] = false;
259
+	else {
260
+			$context['visual_verification'] = false;
261
+	}
247 262
 
248 263
 
249 264
 	$context += array(
@@ -254,8 +269,9 @@  discard block
 block discarded – undo
254 269
 
255 270
 	// Were there any errors?
256 271
 	$context['registration_errors'] = array();
257
-	if (!empty($reg_errors))
258
-		$context['registration_errors'] = $reg_errors;
272
+	if (!empty($reg_errors)) {
273
+			$context['registration_errors'] = $reg_errors;
274
+	}
259 275
 
260 276
 	createToken('register');
261 277
 }
@@ -272,31 +288,37 @@  discard block
 block discarded – undo
272 288
 	validateToken('register');
273 289
 
274 290
 	// Check to ensure we're forcing SSL for authentication
275
-	if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
276
-		fatal_lang_error('register_ssl_required');
291
+	if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
292
+			fatal_lang_error('register_ssl_required');
293
+	}
277 294
 
278 295
 	// Start collecting together any errors.
279 296
 	$reg_errors = array();
280 297
 
281 298
 	// You can't register if it's disabled.
282
-	if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3)
283
-		fatal_lang_error('registration_disabled', false);
299
+	if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) {
300
+			fatal_lang_error('registration_disabled', false);
301
+	}
284 302
 
285 303
 	// Well, if you don't agree, you can't register.
286
-	if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed']))
287
-		redirectexit();
304
+	if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) {
305
+			redirectexit();
306
+	}
288 307
 	
289 308
 	// Well, if you don't agree to policy, you can't register.
290
-	if (!empty($modSettings['enable_policy_function']) && empty($_SESSION['policy_agreed']))
291
-		redirectexit();
309
+	if (!empty($modSettings['enable_policy_function']) && empty($_SESSION['policy_agreed'])) {
310
+			redirectexit();
311
+	}
292 312
 
293 313
 	// Make sure they came from *somewhere*, have a session.
294
-	if (!isset($_SESSION['old_url']))
295
-		redirectexit('action=signup');
314
+	if (!isset($_SESSION['old_url'])) {
315
+			redirectexit('action=signup');
316
+	}
296 317
 
297 318
 	// If we don't require an agreement, we need a extra check for coppa.
298
-	if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge']))
299
-		$_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']);
319
+	if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) {
320
+			$_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']);
321
+	}
300 322
 	// Are they under age, and under age users are banned?
301 323
 	if (!empty($modSettings['coppaAge']) && empty($modSettings['coppaType']) && empty($_SESSION['skip_coppa']))
302 324
 	{
@@ -305,8 +327,9 @@  discard block
 block discarded – undo
305 327
 	}
306 328
 
307 329
 	// Check the time gate for miscreants. First make sure they came from somewhere that actually set it up.
308
-	if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit']))
309
-		redirectexit('action=signup');
330
+	if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) {
331
+			redirectexit('action=signup');
332
+	}
310 333
 	// Failing that, check the time on it.
311 334
 	if (time() - $_SESSION['register']['timenow'] < $_SESSION['register']['limit'])
312 335
 	{
@@ -326,8 +349,9 @@  discard block
 block discarded – undo
326 349
 		if (is_array($context['visual_verification']))
327 350
 		{
328 351
 			loadLanguage('Errors');
329
-			foreach ($context['visual_verification'] as $error)
330
-				$reg_errors[] = $txt['error_' . $error];
352
+			foreach ($context['visual_verification'] as $error) {
353
+							$reg_errors[] = $txt['error_' . $error];
354
+			}
331 355
 		}
332 356
 	}
333 357
 
@@ -336,14 +360,16 @@  discard block
 block discarded – undo
336 360
 		if (!is_array($_POST[$key]))
337 361
 		{
338 362
 			// For UTF-8, replace any kind of space with a normal space, and remove any kind of control character (incl. "\n" and "\r"), then trim.
339
-			if ($context['utf8'])
340
-				$_POST[$key] = $smcFunc['htmltrim'](preg_replace(array('~\p{Z}+~u', '~\p{C}+~u'), array(' ', ''), $_POST[$key]));
363
+			if ($context['utf8']) {
364
+							$_POST[$key] = $smcFunc['htmltrim'](preg_replace(array('~\p{Z}+~u', '~\p{C}+~u'), array(' ', ''), $_POST[$key]));
365
+			}
341 366
 			// Otherwise, just remove "\n" and "\r", then trim.
342
-			else
343
-				$_POST[$key] = $smcFunc['htmltrim'](str_replace(array("\n", "\r"), '', $_POST[$key]));
367
+			else {
368
+							$_POST[$key] = $smcFunc['htmltrim'](str_replace(array("\n", "\r"), '', $_POST[$key]));
369
+			}
370
+		} else {
371
+					$_POST[$key] = htmltrim__recursive($_POST[$key]);
344 372
 		}
345
-		else
346
-			$_POST[$key] = htmltrim__recursive($_POST[$key]);
347 373
 	}
348 374
 
349 375
 	// Collect all extra registration fields someone might have filled in.
@@ -378,13 +404,15 @@  discard block
 block discarded – undo
378 404
 			$possible_strings = array_merge(array('website_url', 'website_title'), $possible_strings);
379 405
 
380 406
 			// Make sure their website URL is squeaky clean
381
-			if (isset($_POST['website_url']))
382
-				$_POST['website_url'] = (string) validate_iri(sanitize_iri($_POST['website_url']));
407
+			if (isset($_POST['website_url'])) {
408
+							$_POST['website_url'] = (string) validate_iri(sanitize_iri($_POST['website_url']));
409
+			}
383 410
 		}
384 411
 	}
385 412
 
386
-	if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '')
387
-		$_POST['secret_answer'] = md5($_POST['secret_answer']);
413
+	if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') {
414
+			$_POST['secret_answer'] = md5($_POST['secret_answer']);
415
+	}
388 416
 
389 417
 	// Needed for isReservedName() and registerMember().
390 418
 	require_once($sourcedir . '/Subs-Members.php');
@@ -393,8 +421,9 @@  discard block
 block discarded – undo
393 421
 	if (isset($_POST['real_name']))
394 422
 	{
395 423
 		// Are you already allowed to edit the displayed name?
396
-		if (allowedTo('profile_displayed_name') || allowedTo('moderate_forum'))
397
-			$canEditDisplayName = true;
424
+		if (allowedTo('profile_displayed_name') || allowedTo('moderate_forum')) {
425
+					$canEditDisplayName = true;
426
+		}
398 427
 
399 428
 		// If you are a guest, will you be allowed to once you register?
400 429
 		else
@@ -413,32 +442,37 @@  discard block
 block discarded – undo
413 442
 		}
414 443
 
415 444
 		// Only set it if you can and if we are sure it is good
416
-		if ($canEditDisplayName && $smcFunc['htmltrim']($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60)
417
-				$possible_strings[] = 'real_name';
445
+		if ($canEditDisplayName && $smcFunc['htmltrim']($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60) {
446
+						$possible_strings[] = 'real_name';
447
+		}
418 448
 	}
419 449
 
420 450
 	// Handle a string as a birthdate...
421
-	if (isset($_POST['birthdate']) && $_POST['birthdate'] != '')
422
-		$_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate']));
451
+	if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') {
452
+			$_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate']));
453
+	}
423 454
 	// Or birthdate parts...
424
-	elseif (!empty($_POST['bday1']) && !empty($_POST['bday2']))
425
-		$_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']);
455
+	elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) {
456
+			$_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']);
457
+	}
426 458
 
427 459
 	// Validate the passed language file.
428 460
 	if (isset($_POST['lngfile']) && !empty($modSettings['userLanguage']))
429 461
 	{
430 462
 		// Do we have any languages?
431
-		if (empty($context['languages']))
432
-			getLanguages();
463
+		if (empty($context['languages'])) {
464
+					getLanguages();
465
+		}
433 466
 
434 467
 		// Did we find it?
435
-		if (isset($context['languages'][$_POST['lngfile']]))
436
-			$_SESSION['language'] = $_POST['lngfile'];
437
-		else
468
+		if (isset($context['languages'][$_POST['lngfile']])) {
469
+					$_SESSION['language'] = $_POST['lngfile'];
470
+		} else {
471
+					unset($_POST['lngfile']);
472
+		}
473
+	} else {
438 474
 			unset($_POST['lngfile']);
439 475
 	}
440
-	else
441
-		unset($_POST['lngfile']);
442 476
 
443 477
 	// Set the options needed for registration.
444 478
 	$regOptions = array(
@@ -458,22 +492,27 @@  discard block
 block discarded – undo
458 492
 	);
459 493
 
460 494
 	// Include the additional options that might have been filled in.
461
-	foreach ($possible_strings as $var)
462
-		if (isset($_POST[$var]))
495
+	foreach ($possible_strings as $var) {
496
+			if (isset($_POST[$var]))
463 497
 			$regOptions['extra_register_vars'][$var] = $smcFunc['htmlspecialchars']($_POST[$var], ENT_QUOTES);
464
-	foreach ($possible_ints as $var)
465
-		if (isset($_POST[$var]))
498
+	}
499
+	foreach ($possible_ints as $var) {
500
+			if (isset($_POST[$var]))
466 501
 			$regOptions['extra_register_vars'][$var] = (int) $_POST[$var];
467
-	foreach ($possible_floats as $var)
468
-		if (isset($_POST[$var]))
502
+	}
503
+	foreach ($possible_floats as $var) {
504
+			if (isset($_POST[$var]))
469 505
 			$regOptions['extra_register_vars'][$var] = (float) $_POST[$var];
470
-	foreach ($possible_bools as $var)
471
-		if (isset($_POST[$var]))
506
+	}
507
+	foreach ($possible_bools as $var) {
508
+			if (isset($_POST[$var]))
472 509
 			$regOptions['extra_register_vars'][$var] = empty($_POST[$var]) ? 0 : 1;
510
+	}
473 511
 
474 512
 	// Registration options are always default options...
475
-	if (isset($_POST['default_options']))
476
-		$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
513
+	if (isset($_POST['default_options'])) {
514
+			$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
515
+	}
477 516
 	$regOptions['theme_vars'] = isset($_POST['options']) && is_array($_POST['options']) ? $_POST['options'] : array();
478 517
 
479 518
 	// Make sure they are clean, dammit!
@@ -493,12 +532,14 @@  discard block
 block discarded – undo
493 532
 	while ($row = $smcFunc['db_fetch_assoc']($request))
494 533
 	{
495 534
 		// Don't allow overriding of the theme variables.
496
-		if (isset($regOptions['theme_vars'][$row['col_name']]))
497
-			unset($regOptions['theme_vars'][$row['col_name']]);
535
+		if (isset($regOptions['theme_vars'][$row['col_name']])) {
536
+					unset($regOptions['theme_vars'][$row['col_name']]);
537
+		}
498 538
 
499 539
 		// Not actually showing it then?
500
-		if (!$row['show_reg'])
501
-			continue;
540
+		if (!$row['show_reg']) {
541
+					continue;
542
+		}
502 543
 
503 544
 		// Prepare the value!
504 545
 		$value = isset($_POST['customfield'][$row['col_name']]) ? trim($_POST['customfield'][$row['col_name']]) : '';
@@ -507,24 +548,27 @@  discard block
 block discarded – undo
507 548
 		if (!in_array($row['field_type'], array('check', 'select', 'radio')))
508 549
 		{
509 550
 			// Is it too long?
510
-			if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value))
511
-				$custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length']));
551
+			if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value)) {
552
+							$custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length']));
553
+			}
512 554
 
513 555
 			// Any masks to apply?
514 556
 			if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none')
515 557
 			{
516
-				if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255))
517
-					$custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name']));
518
-				elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value))
519
-					$custom_field_errors[] = array('custom_field_not_number', array($row['field_name']));
520
-				elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0)
521
-					$custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name']));
558
+				if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) {
559
+									$custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name']));
560
+				} elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value)) {
561
+									$custom_field_errors[] = array('custom_field_not_number', array($row['field_name']));
562
+				} elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) {
563
+									$custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name']));
564
+				}
522 565
 			}
523 566
 		}
524 567
 
525 568
 		// Is this required but not there?
526
-		if (trim($value) == '' && $row['show_reg'] > 1)
527
-			$custom_field_errors[] = array('custom_field_empty', array($row['field_name']));
569
+		if (trim($value) == '' && $row['show_reg'] > 1) {
570
+					$custom_field_errors[] = array('custom_field_empty', array($row['field_name']));
571
+		}
528 572
 	}
529 573
 	$smcFunc['db_free_result']($request);
530 574
 
@@ -532,8 +576,9 @@  discard block
 block discarded – undo
532 576
 	if (!empty($custom_field_errors))
533 577
 	{
534 578
 		loadLanguage('Errors');
535
-		foreach ($custom_field_errors as $error)
536
-			$reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]);
579
+		foreach ($custom_field_errors as $error) {
580
+					$reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]);
581
+		}
537 582
 	}
538 583
 
539 584
 	// Lets check for other errors before trying to register the member.
@@ -578,8 +623,9 @@  discard block
 block discarded – undo
578 623
 	}
579 624
 
580 625
 	// If COPPA has been selected then things get complicated, setup the template.
581
-	if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa']))
582
-		redirectexit('action=coppa;member=' . $memberID);
626
+	if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) {
627
+			redirectexit('action=coppa;member=' . $memberID);
628
+	}
583 629
 	// Basic template variable setup.
584 630
 	elseif (!empty($modSettings['registration_method']))
585 631
 	{
@@ -591,8 +637,7 @@  discard block
 block discarded – undo
591 637
 			'sub_template' => 'after',
592 638
 			'description' => $modSettings['registration_method'] == 2 ? $txt['approval_after_registration'] : $txt['activate_after_registration']
593 639
 		);
594
-	}
595
-	else
640
+	} else
596 641
 	{
597 642
 		call_integration_hook('integrate_activate', array($regOptions['username']));
598 643
 
@@ -612,16 +657,18 @@  discard block
 block discarded – undo
612 657
 	global $context, $txt, $modSettings, $scripturl, $sourcedir, $smcFunc, $language, $user_info;
613 658
 
614 659
 	// Logged in users should not bother to activate their accounts
615
-	if (!empty($user_info['id']))
616
-		redirectexit();
660
+	if (!empty($user_info['id'])) {
661
+			redirectexit();
662
+	}
617 663
 
618 664
 	loadLanguage('Login');
619 665
 	loadTemplate('Login');
620 666
 
621 667
 	if (empty($_REQUEST['u']) && empty($_POST['user']))
622 668
 	{
623
-		if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3')
624
-			fatal_lang_error('no_access', false);
669
+		if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3') {
670
+					fatal_lang_error('no_access', false);
671
+		}
625 672
 
626 673
 		$context['member_id'] = 0;
627 674
 		$context['sub_template'] = 'resend';
@@ -661,11 +708,13 @@  discard block
 block discarded – undo
661 708
 	// Change their email address? (they probably tried a fake one first :P.)
662 709
 	if (isset($_POST['new_email'], $_REQUEST['passwd']) && hash_password($row['member_name'], $_REQUEST['passwd']) == $row['passwd'] && ($row['is_activated'] == 0 || $row['is_activated'] == 2))
663 710
 	{
664
-		if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3)
665
-			fatal_lang_error('no_access', false);
711
+		if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3) {
712
+					fatal_lang_error('no_access', false);
713
+		}
666 714
 
667
-		if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL))
668
-			fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false);
715
+		if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) {
716
+					fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false);
717
+		}
669 718
 
670 719
 		// Make sure their email isn't banned.
671 720
 		isBannedEmail($_POST['new_email'], 'cannot_register', $txt['ban_register_prohibited']);
@@ -681,8 +730,9 @@  discard block
 block discarded – undo
681 730
 			)
682 731
 		);
683 732
 
684
-		if ($smcFunc['db_num_rows']($request) != 0)
685
-			fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email'])));
733
+		if ($smcFunc['db_num_rows']($request) != 0) {
734
+					fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email'])));
735
+		}
686 736
 		$smcFunc['db_free_result']($request);
687 737
 
688 738
 		updateMemberData($row['id_member'], array('email_address' => $_POST['new_email']));
@@ -720,9 +770,9 @@  discard block
 block discarded – undo
720 770
 	// Quit if this code is not right.
721 771
 	if (empty($_REQUEST['code']) || $row['validation_code'] != $_REQUEST['code'])
722 772
 	{
723
-		if (!empty($row['is_activated']))
724
-			fatal_lang_error('already_activated', false);
725
-		elseif ($row['validation_code'] == '')
773
+		if (!empty($row['is_activated'])) {
774
+					fatal_lang_error('already_activated', false);
775
+		} elseif ($row['validation_code'] == '')
726 776
 		{
727 777
 			loadLanguage('Profile');
728 778
 			fatal_error(sprintf($txt['registration_not_approved'], $scripturl . '?action=activate;user=' . $row['member_name']), false);
@@ -772,8 +822,9 @@  discard block
 block discarded – undo
772 822
 	loadTemplate('Register');
773 823
 
774 824
 	// No User ID??
775
-	if (!isset($_GET['member']))
776
-		fatal_lang_error('no_access', false);
825
+	if (!isset($_GET['member'])) {
826
+			fatal_lang_error('no_access', false);
827
+	}
777 828
 
778 829
 	// Get the user details...
779 830
 	$request = $smcFunc['db_query']('', '
@@ -786,8 +837,9 @@  discard block
 block discarded – undo
786 837
 			'is_coppa' => 5,
787 838
 		)
788 839
 	);
789
-	if ($smcFunc['db_num_rows']($request) == 0)
790
-		fatal_lang_error('no_access', false);
840
+	if ($smcFunc['db_num_rows']($request) == 0) {
841
+			fatal_lang_error('no_access', false);
842
+	}
791 843
 	list ($username) = $smcFunc['db_fetch_row']($request);
792 844
 	$smcFunc['db_free_result']($request);
793 845
 
@@ -825,8 +877,7 @@  discard block
 block discarded – undo
825 877
 			echo $data;
826 878
 			obExit(false);
827 879
 		}
828
-	}
829
-	else
880
+	} else
830 881
 	{
831 882
 		$context += array(
832 883
 			'page_title' => $txt['coppa_title'],
@@ -879,8 +930,9 @@  discard block
 block discarded – undo
879 930
 	{
880 931
 		require_once($sourcedir . '/Subs-Graphics.php');
881 932
 
882
-		if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code))
883
-			header('HTTP/1.1 400 Bad Request');
933
+		if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) {
934
+					header('HTTP/1.1 400 Bad Request');
935
+		}
884 936
 
885 937
 		// Otherwise just show a pre-defined letter.
886 938
 		elseif (isset($_REQUEST['letter']))
@@ -898,14 +950,13 @@  discard block
 block discarded – undo
898 950
 			header('content-type: image/gif');
899 951
 			die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B");
900 952
 		}
901
-	}
902
-
903
-	elseif ($_REQUEST['format'] === '.wav')
953
+	} elseif ($_REQUEST['format'] === '.wav')
904 954
 	{
905 955
 		require_once($sourcedir . '/Subs-Sound.php');
906 956
 
907
-		if (!createWaveFile($code))
908
-			header('HTTP/1.1 400 Bad Request');
957
+		if (!createWaveFile($code)) {
958
+					header('HTTP/1.1 400 Bad Request');
959
+		}
909 960
 	}
910 961
 
911 962
 	// We all die one day...
Please login to merge, or discard this patch.
Sources/Load.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1743,7 +1743,7 @@  discard block
 block discarded – undo
1743 1743
 	}
1744 1744
 		
1745 1745
 	// We already load the basic stuff?
1746
-	if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme )
1746
+	if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme)
1747 1747
 	{
1748 1748
 		$member = empty($user_info['id']) ? -1 : $user_info['id'];
1749 1749
 
@@ -1768,7 +1768,7 @@  discard block
 block discarded – undo
1768 1768
 				SELECT variable, value, id_member, id_theme
1769 1769
 				FROM {db_prefix}themes
1770 1770
 				WHERE id_member' . (empty($themeData[0]) ? ' IN (-1, 0, {int:id_member})' : ' = {int:id_member}') . '
1771
-					AND id_theme' . ($id_theme == 1 ? ' = {int:id_theme}' : ' IN ({int:id_theme}, 1)') .'
1771
+					AND id_theme' . ($id_theme == 1 ? ' = {int:id_theme}' : ' IN ({int:id_theme}, 1)') . '
1772 1772
 				ORDER BY id_theme asc',
1773 1773
 				array(
1774 1774
 					'id_theme' => $id_theme,
@@ -1998,7 +1998,7 @@  discard block
 block discarded – undo
1998 1998
 	if (!isset($context['javascript_vars']))
1999 1999
 		$context['javascript_vars'] = array();
2000 2000
 
2001
-	$context['login_url'] =  $scripturl . '?action=login2';
2001
+	$context['login_url'] = $scripturl . '?action=login2';
2002 2002
 	$context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | ';
2003 2003
 	$context['session_var'] = $_SESSION['session_var'];
2004 2004
 	$context['session_id'] = $_SESSION['session_value'];
@@ -2302,7 +2302,7 @@  discard block
 block discarded – undo
2302 2302
 
2303 2303
 	// Privacy logic only when enabled, got no valid version, try not to call the policy data
2304 2304
 	if (!empty($modSettings['enable_policy_function']) && empty($options['policy_isvalid']) &&
2305
-			( empty($_REQUEST['area']) || (!empty($_REQUEST['area']) && $_REQUEST['area'] != 'getpolicydata')) &&
2305
+			(empty($_REQUEST['area']) || (!empty($_REQUEST['area']) && $_REQUEST['area'] != 'getpolicydata')) &&
2306 2306
 			!$user_info['is_guest'])
2307 2307
 		redirectexit('action=profile;area=getpolicydata;u=1');
2308 2308
 	// We are ready to go.
Please login to merge, or discard this patch.
Braces   +795 added lines, -599 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
  * Load the $modSettings array.
@@ -25,13 +26,14 @@  discard block
 block discarded – undo
25 26
 	global $cache_enable, $sourcedir, $context;
26 27
 
27 28
 	// Most database systems have not set UTF-8 as their default input charset.
28
-	if (!empty($db_character_set))
29
-		$smcFunc['db_query']('', '
29
+	if (!empty($db_character_set)) {
30
+			$smcFunc['db_query']('', '
30 31
 			SET NAMES {string:db_character_set}',
31 32
 			array(
32 33
 				'db_character_set' => $db_character_set,
33 34
 			)
34 35
 		);
36
+	}
35 37
 
36 38
 	// We need some caching support, maybe.
37 39
 	loadCacheAccelerator();
@@ -46,28 +48,36 @@  discard block
 block discarded – undo
46 48
 			)
47 49
 		);
48 50
 		$modSettings = array();
49
-		if (!$request)
50
-			display_db_error();
51
-		while ($row = $smcFunc['db_fetch_row']($request))
52
-			$modSettings[$row[0]] = $row[1];
51
+		if (!$request) {
52
+					display_db_error();
53
+		}
54
+		while ($row = $smcFunc['db_fetch_row']($request)) {
55
+					$modSettings[$row[0]] = $row[1];
56
+		}
53 57
 		$smcFunc['db_free_result']($request);
54 58
 
55 59
 		// Do a few things to protect against missing settings or settings with invalid values...
56
-		if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999)
57
-			$modSettings['defaultMaxTopics'] = 20;
58
-		if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999)
59
-			$modSettings['defaultMaxMessages'] = 15;
60
-		if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999)
61
-			$modSettings['defaultMaxMembers'] = 30;
62
-		if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999)
63
-			$modSettings['defaultMaxListItems'] = 15;
60
+		if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) {
61
+					$modSettings['defaultMaxTopics'] = 20;
62
+		}
63
+		if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) {
64
+					$modSettings['defaultMaxMessages'] = 15;
65
+		}
66
+		if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) {
67
+					$modSettings['defaultMaxMembers'] = 30;
68
+		}
69
+		if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) {
70
+					$modSettings['defaultMaxListItems'] = 15;
71
+		}
64 72
 
65 73
 		// We excpiclity do not use $smcFunc['json_decode'] here yet, as $smcFunc is not fully loaded.
66
-		if (!is_array($modSettings['attachmentUploadDir']))
67
-			$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
74
+		if (!is_array($modSettings['attachmentUploadDir'])) {
75
+					$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
76
+		}
68 77
 
69
-		if (!empty($cache_enable))
70
-			cache_put_data('modSettings', $modSettings, 90);
78
+		if (!empty($cache_enable)) {
79
+					cache_put_data('modSettings', $modSettings, 90);
80
+		}
71 81
 	}
72 82
 
73 83
 	$modSettings['cache_enable'] = $cache_enable;
@@ -87,8 +97,9 @@  discard block
 block discarded – undo
87 97
 		};
88 98
 	$fix_utf8mb4 = function($string) use ($utf8, $smcFunc)
89 99
 	{
90
-		if (!$utf8 || $smcFunc['db_mb4'])
91
-			return $string;
100
+		if (!$utf8 || $smcFunc['db_mb4']) {
101
+					return $string;
102
+		}
92 103
 
93 104
 		$i = 0;
94 105
 		$len = strlen($string);
@@ -100,18 +111,15 @@  discard block
 block discarded – undo
100 111
 			{
101 112
 				$new_string .= $string[$i];
102 113
 				$i++;
103
-			}
104
-			elseif ($ord < 224)
114
+			} elseif ($ord < 224)
105 115
 			{
106 116
 				$new_string .= $string[$i] . $string[$i + 1];
107 117
 				$i += 2;
108
-			}
109
-			elseif ($ord < 240)
118
+			} elseif ($ord < 240)
110 119
 			{
111 120
 				$new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2];
112 121
 				$i += 3;
113
-			}
114
-			elseif ($ord < 248)
122
+			} elseif ($ord < 248)
115 123
 			{
116 124
 				// Magic happens.
117 125
 				$val = (ord($string[$i]) & 0x07) << 18;
@@ -155,8 +163,7 @@  discard block
 block discarded – undo
155 163
 			{
156 164
 				$result = array_search($needle, array_slice($haystack_arr, $offset));
157 165
 				return is_int($result) ? $result + $offset : false;
158
-			}
159
-			else
166
+			} else
160 167
 			{
161 168
 				$needle_arr = preg_split('~(' . $ent_list . '|.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
162 169
 				$needle_size = count($needle_arr);
@@ -165,8 +172,9 @@  discard block
 block discarded – undo
165 172
 				while ((int) $result === $result)
166 173
 				{
167 174
 					$offset += $result;
168
-					if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr)
169
-						return $offset;
175
+					if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) {
176
+											return $offset;
177
+					}
170 178
 					$result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset));
171 179
 				}
172 180
 				return false;
@@ -204,8 +212,9 @@  discard block
 block discarded – undo
204 212
 			$string = $ent_check($string);
205 213
 			preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches);
206 214
 			$string = $matches[0];
207
-			while (strlen($string) > $length)
208
-				$string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string);
215
+			while (strlen($string) > $length) {
216
+							$string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string);
217
+			}
209 218
 			return $string;
210 219
 		},
211 220
 		'ucfirst' => $utf8 ? function($string) use (&$smcFunc)
@@ -215,8 +224,9 @@  discard block
 block discarded – undo
215 224
 		'ucwords' => $utf8 ? function($string) use (&$smcFunc)
216 225
 		{
217 226
 			$words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
218
-			for ($i = 0, $n = count($words); $i < $n; $i += 2)
219
-				$words[$i] = $smcFunc['ucfirst']($words[$i]);
227
+			for ($i = 0, $n = count($words); $i < $n; $i += 2) {
228
+							$words[$i] = $smcFunc['ucfirst']($words[$i]);
229
+			}
220 230
 			return implode('', $words);
221 231
 		} : 'ucwords',
222 232
 		'json_decode' => 'smf_json_decode',
@@ -224,16 +234,17 @@  discard block
 block discarded – undo
224 234
 	);
225 235
 
226 236
 	// Setting the timezone is a requirement for some functions.
227
-	if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list()))
228
-		date_default_timezone_set($modSettings['default_timezone']);
229
-	else
237
+	if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) {
238
+			date_default_timezone_set($modSettings['default_timezone']);
239
+	} else
230 240
 	{
231 241
 		// Get PHP's default timezone, if set
232 242
 		$ini_tz = ini_get('date.timezone');
233
-		if (!empty($ini_tz))
234
-			$modSettings['default_timezone'] = $ini_tz;
235
-		else
236
-			$modSettings['default_timezone'] = '';
243
+		if (!empty($ini_tz)) {
244
+					$modSettings['default_timezone'] = $ini_tz;
245
+		} else {
246
+					$modSettings['default_timezone'] = '';
247
+		}
237 248
 
238 249
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
239 250
 		if (!in_array($modSettings['default_timezone'], timezone_identifiers_list()))
@@ -251,22 +262,26 @@  discard block
 block discarded – undo
251 262
 		if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null)
252 263
 		{
253 264
 			$modSettings['load_average'] = @file_get_contents('/proc/loadavg');
254
-			if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0)
255
-				$modSettings['load_average'] = (float) $matches[1];
256
-			elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0)
257
-				$modSettings['load_average'] = (float) $matches[1];
258
-			else
259
-				unset($modSettings['load_average']);
265
+			if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) {
266
+							$modSettings['load_average'] = (float) $matches[1];
267
+			} elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) {
268
+							$modSettings['load_average'] = (float) $matches[1];
269
+			} else {
270
+							unset($modSettings['load_average']);
271
+			}
260 272
 
261
-			if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0)
262
-				cache_put_data('loadavg', $modSettings['load_average'], 90);
273
+			if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) {
274
+							cache_put_data('loadavg', $modSettings['load_average'], 90);
275
+			}
263 276
 		}
264 277
 
265
-		if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0)
266
-			call_integration_hook('integrate_load_average', array($modSettings['load_average']));
278
+		if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) {
279
+					call_integration_hook('integrate_load_average', array($modSettings['load_average']));
280
+		}
267 281
 
268
-		if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum'])
269
-			display_loadavg_error();
282
+		if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) {
283
+					display_loadavg_error();
284
+		}
270 285
 	}
271 286
 
272 287
 	// Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is.
@@ -287,8 +302,9 @@  discard block
 block discarded – undo
287 302
 	if (defined('SMF_INTEGRATION_SETTINGS'))
288 303
 	{
289 304
 		$integration_settings = $smcFunc['json_decode'](SMF_INTEGRATION_SETTINGS, true);
290
-		foreach ($integration_settings as $hook => $function)
291
-			add_integration_function($hook, $function, '', false);
305
+		foreach ($integration_settings as $hook => $function) {
306
+					add_integration_function($hook, $function, '', false);
307
+		}
292 308
 	}
293 309
 
294 310
 	// Any files to pre include?
@@ -298,8 +314,9 @@  discard block
 block discarded – undo
298 314
 		foreach ($pre_includes as $include)
299 315
 		{
300 316
 			$include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
301
-			if (file_exists($include))
302
-				require_once($include);
317
+			if (file_exists($include)) {
318
+							require_once($include);
319
+			}
303 320
 		}
304 321
 	}
305 322
 
@@ -392,9 +409,9 @@  discard block
 block discarded – undo
392 409
 				break;
393 410
 			}
394 411
 		}
412
+	} else {
413
+			$id_member = 0;
395 414
 	}
396
-	else
397
-		$id_member = 0;
398 415
 
399 416
 	if (empty($id_member) && isset($_COOKIE[$cookiename]))
400 417
 	{
@@ -402,8 +419,9 @@  discard block
 block discarded – undo
402 419
 		$cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false);
403 420
 
404 421
 		// Legacy format (for recent 2.0 --> 2.1 upgrades)
405
-		if (empty($cookie_data))
406
-			$cookie_data = safe_unserialize($_COOKIE[$cookiename]);
422
+		if (empty($cookie_data)) {
423
+					$cookie_data = safe_unserialize($_COOKIE[$cookiename]);
424
+		}
407 425
 
408 426
 		list($id_member, $password, $login_span, $cookie_domain, $cookie_path) = array_pad((array) $cookie_data, 5, '');
409 427
 
@@ -411,16 +429,17 @@  discard block
 block discarded – undo
411 429
 
412 430
 		// Make sure the cookie is set to the correct domain and path
413 431
 		require_once($sourcedir . '/Subs-Auth.php');
414
-		if (array($cookie_domain, $cookie_path) !== url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies'])))
415
-			setLoginCookie((int) $login_span - time(), $id_member);
416
-	}
417
-	elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA'])))
432
+		if (array($cookie_domain, $cookie_path) !== url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']))) {
433
+					setLoginCookie((int) $login_span - time(), $id_member);
434
+		}
435
+	} elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA'])))
418 436
 	{
419 437
 		// @todo Perhaps we can do some more checking on this, such as on the first octet of the IP?
420 438
 		$cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename], true);
421 439
 
422
-		if (empty($cookie_data))
423
-			$cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]);
440
+		if (empty($cookie_data)) {
441
+					$cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]);
442
+		}
424 443
 
425 444
 		list($id_member, $password, $login_span) = array_pad((array) $cookie_data, 3, '');
426 445
 		$id_member = !empty($id_member) && strlen($password) == 128 && (int) $login_span > time() ? (int) $id_member : 0;
@@ -445,30 +464,34 @@  discard block
 block discarded – undo
445 464
 			$user_settings = $smcFunc['db_fetch_assoc']($request);
446 465
 			$smcFunc['db_free_result']($request);
447 466
 
448
-			if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot']))
449
-				$user_settings['avatar'] = get_proxied_url($user_settings['avatar']);
467
+			if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) {
468
+							$user_settings['avatar'] = get_proxied_url($user_settings['avatar']);
469
+			}
450 470
 
451
-			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
452
-				cache_put_data('user_settings-' . $id_member, $user_settings, 60);
471
+			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
472
+							cache_put_data('user_settings-' . $id_member, $user_settings, 60);
473
+			}
453 474
 		}
454 475
 
455 476
 		// Did we find 'im?  If not, junk it.
456 477
 		if (!empty($user_settings))
457 478
 		{
458 479
 			// As much as the password should be right, we can assume the integration set things up.
459
-			if (!empty($already_verified) && $already_verified === true)
460
-				$check = true;
480
+			if (!empty($already_verified) && $already_verified === true) {
481
+							$check = true;
482
+			}
461 483
 			// SHA-512 hash should be 128 characters long.
462
-			elseif (strlen($password) == 128)
463
-				$check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password;
464
-			else
465
-				$check = false;
484
+			elseif (strlen($password) == 128) {
485
+							$check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password;
486
+			} else {
487
+							$check = false;
488
+			}
466 489
 
467 490
 			// Wrong password or not activated - either way, you're going nowhere.
468 491
 			$id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0;
492
+		} else {
493
+					$id_member = 0;
469 494
 		}
470
-		else
471
-			$id_member = 0;
472 495
 
473 496
 		// If we no longer have the member maybe they're being all hackey, stop brute force!
474 497
 		if (!$id_member)
@@ -497,8 +520,9 @@  discard block
 block discarded – undo
497 520
 
498 521
 					list ($tfamember, $tfasecret) = array_pad((array) $tfa_data, 2, '');
499 522
 
500
-					if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member)
501
-						$tfasecret = null;
523
+					if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) {
524
+											$tfasecret = null;
525
+					}
502 526
 				}
503 527
 
504 528
 				// They didn't finish logging in before coming here? Then they're no one to us.
@@ -520,10 +544,12 @@  discard block
 block discarded – undo
520 544
 		// Are we forcing 2FA? Need to check if the user groups actually require 2FA
521 545
 		elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret']))
522 546
 		{
523
-			if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups
547
+			if ($modSettings['tfa_mode'] == 2) {
548
+				//only do this if we are just forcing SOME membergroups
524 549
 			{
525 550
 				//Build an array of ALL user membergroups.
526 551
 				$full_groups = array($user_settings['id_group']);
552
+			}
527 553
 				if (!empty($user_settings['additional_groups']))
528 554
 				{
529 555
 					$full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups']));
@@ -543,15 +569,17 @@  discard block
 block discarded – undo
543 569
 				);
544 570
 				$row = $smcFunc['db_fetch_assoc']($request);
545 571
 				$smcFunc['db_free_result']($request);
572
+			} else {
573
+							$row['total'] = 1;
546 574
 			}
547
-			else
548
-				$row['total'] = 1; //simplifies logics in the next "if"
575
+			//simplifies logics in the next "if"
549 576
 
550 577
 			$area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : '';
551 578
 			$action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';
552 579
 
553
-			if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup'))
554
-				redirectexit('action=profile;area=tfasetup;forced');
580
+			if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) {
581
+							redirectexit('action=profile;area=tfasetup;forced');
582
+			}
555 583
 		}
556 584
 	}
557 585
 
@@ -588,29 +616,32 @@  discard block
 block discarded – undo
588 616
 				updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']));
589 617
 				$user_settings['last_login'] = time();
590 618
 
591
-				if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
592
-					cache_put_data('user_settings-' . $id_member, $user_settings, 60);
619
+				if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
620
+									cache_put_data('user_settings-' . $id_member, $user_settings, 60);
621
+				}
593 622
 
594
-				if (!empty($modSettings['cache_enable']))
595
-					cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600);
623
+				if (!empty($modSettings['cache_enable'])) {
624
+									cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600);
625
+				}
596 626
 			}
627
+		} elseif (empty($_SESSION['id_msg_last_visit'])) {
628
+					$_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit'];
597 629
 		}
598
-		elseif (empty($_SESSION['id_msg_last_visit']))
599
-			$_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit'];
600 630
 
601 631
 		$username = $user_settings['member_name'];
602 632
 
603
-		if (empty($user_settings['additional_groups']))
604
-			$user_info = array(
633
+		if (empty($user_settings['additional_groups'])) {
634
+					$user_info = array(
605 635
 				'groups' => array($user_settings['id_group'], $user_settings['id_post_group'])
606 636
 			);
607
-		else
608
-			$user_info = array(
637
+		} else {
638
+					$user_info = array(
609 639
 				'groups' => array_merge(
610 640
 					array($user_settings['id_group'], $user_settings['id_post_group']),
611 641
 					explode(',', $user_settings['additional_groups'])
612 642
 				)
613 643
 			);
644
+		}
614 645
 
615 646
 		// Because history has proven that it is possible for groups to go bad - clean up in case.
616 647
 		$user_info['groups'] = array_map('intval', $user_info['groups']);
@@ -627,8 +658,7 @@  discard block
 block discarded – undo
627 658
 			$time_system = new DateTime('now', $tz_system);
628 659
 			$time_user = new DateTime('now', $tz_user);
629 660
 			$user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600;
630
-		}
631
-		else
661
+		} else
632 662
 		{
633 663
 			// !!! Compatibility.
634 664
 			$user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset'];
@@ -642,8 +672,9 @@  discard block
 block discarded – undo
642 672
 		$user_info = array('groups' => array(-1));
643 673
 		$user_settings = array();
644 674
 
645
-		if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member']))
646
-			$_COOKIE[$cookiename] = '';
675
+		if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) {
676
+					$_COOKIE[$cookiename] = '';
677
+		}
647 678
 
648 679
 		// Expire the 2FA cookie
649 680
 		if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member']))
@@ -660,19 +691,20 @@  discard block
 block discarded – undo
660 691
 		}
661 692
 
662 693
 		// Create a login token if it doesn't exist yet.
663
-		if (!isset($_SESSION['token']['post-login']))
664
-			createToken('login');
665
-		else
666
-			list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login'];
694
+		if (!isset($_SESSION['token']['post-login'])) {
695
+					createToken('login');
696
+		} else {
697
+					list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login'];
698
+		}
667 699
 
668 700
 		// Do we perhaps think this is a search robot? Check every five minutes just in case...
669 701
 		if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300))
670 702
 		{
671 703
 			require_once($sourcedir . '/ManageSearchEngines.php');
672 704
 			$user_info['possibly_robot'] = SpiderCheck();
705
+		} elseif (!empty($modSettings['spider_mode'])) {
706
+					$user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0;
673 707
 		}
674
-		elseif (!empty($modSettings['spider_mode']))
675
-			$user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0;
676 708
 		// If we haven't turned on proper spider hunts then have a guess!
677 709
 		else
678 710
 		{
@@ -720,8 +752,9 @@  discard block
 block discarded – undo
720 752
 	$user_info['groups'] = array_unique($user_info['groups']);
721 753
 
722 754
 	// Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems.
723
-	if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1]))
724
-		unset($user_info['ignoreboards'][$tmp]);
755
+	if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) {
756
+			unset($user_info['ignoreboards'][$tmp]);
757
+	}
725 758
 
726 759
 	// Allow the user to change their language.
727 760
 	if (!empty($modSettings['userLanguage']))
@@ -734,13 +767,14 @@  discard block
 block discarded – undo
734 767
 			$user_info['language'] = strtr($_GET['language'], './\\:', '____');
735 768
 
736 769
 			// Make it permanent for members.
737
-			if (!empty($user_info['id']))
738
-				updateMemberData($user_info['id'], array('lngfile' => $user_info['language']));
739
-			else
740
-				$_SESSION['language'] = $user_info['language'];
770
+			if (!empty($user_info['id'])) {
771
+							updateMemberData($user_info['id'], array('lngfile' => $user_info['language']));
772
+			} else {
773
+							$_SESSION['language'] = $user_info['language'];
774
+			}
775
+		} elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) {
776
+					$user_info['language'] = strtr($_SESSION['language'], './\\:', '____');
741 777
 		}
742
-		elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')]))
743
-			$user_info['language'] = strtr($_SESSION['language'], './\\:', '____');
744 778
 	}
745 779
 
746 780
 	$temp = build_query_board($user_info['id']);
@@ -803,9 +837,9 @@  discard block
 block discarded – undo
803 837
 		}
804 838
 
805 839
 		// Remember redirection is the key to avoiding fallout from your bosses.
806
-		if (!empty($topic))
807
-			redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']);
808
-		else
840
+		if (!empty($topic)) {
841
+					redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']);
842
+		} else
809 843
 		{
810 844
 			loadPermissions();
811 845
 			loadTheme();
@@ -823,10 +857,11 @@  discard block
 block discarded – undo
823 857
 	if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3))
824 858
 	{
825 859
 		// @todo SLOW?
826
-		if (!empty($topic))
827
-			$temp = cache_get_data('topic_board-' . $topic, 120);
828
-		else
829
-			$temp = cache_get_data('board-' . $board, 120);
860
+		if (!empty($topic)) {
861
+					$temp = cache_get_data('topic_board-' . $topic, 120);
862
+		} else {
863
+					$temp = cache_get_data('board-' . $board, 120);
864
+		}
830 865
 
831 866
 		if (!empty($temp))
832 867
 		{
@@ -864,8 +899,9 @@  discard block
 block discarded – undo
864 899
 			$row = $smcFunc['db_fetch_assoc']($request);
865 900
 
866 901
 			// Set the current board.
867
-			if (!empty($row['id_board']))
868
-				$board = $row['id_board'];
902
+			if (!empty($row['id_board'])) {
903
+							$board = $row['id_board'];
904
+			}
869 905
 
870 906
 			// Basic operating information. (globals... :/)
871 907
 			$board_info = array(
@@ -901,21 +937,23 @@  discard block
 block discarded – undo
901 937
 
902 938
 			do
903 939
 			{
904
-				if (!empty($row['id_moderator']))
905
-					$board_info['moderators'][$row['id_moderator']] = array(
940
+				if (!empty($row['id_moderator'])) {
941
+									$board_info['moderators'][$row['id_moderator']] = array(
906 942
 						'id' => $row['id_moderator'],
907 943
 						'name' => $row['real_name'],
908 944
 						'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'],
909 945
 						'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>'
910 946
 					);
947
+				}
911 948
 
912
-				if (!empty($row['id_moderator_group']))
913
-					$board_info['moderator_groups'][$row['id_moderator_group']] = array(
949
+				if (!empty($row['id_moderator_group'])) {
950
+									$board_info['moderator_groups'][$row['id_moderator_group']] = array(
914 951
 						'id' => $row['id_moderator_group'],
915 952
 						'name' => $row['group_name'],
916 953
 						'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'],
917 954
 						'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>'
918 955
 					);
956
+				}
919 957
 			}
920 958
 			while ($row = $smcFunc['db_fetch_assoc']($request));
921 959
 
@@ -947,12 +985,12 @@  discard block
 block discarded – undo
947 985
 			if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3))
948 986
 			{
949 987
 				// @todo SLOW?
950
-				if (!empty($topic))
951
-					cache_put_data('topic_board-' . $topic, $board_info, 120);
988
+				if (!empty($topic)) {
989
+									cache_put_data('topic_board-' . $topic, $board_info, 120);
990
+				}
952 991
 				cache_put_data('board-' . $board, $board_info, 120);
953 992
 			}
954
-		}
955
-		else
993
+		} else
956 994
 		{
957 995
 			// Otherwise the topic is invalid, there are no moderators, etc.
958 996
 			$board_info = array(
@@ -966,8 +1004,9 @@  discard block
 block discarded – undo
966 1004
 		$smcFunc['db_free_result']($request);
967 1005
 	}
968 1006
 
969
-	if (!empty($topic))
970
-		$_GET['board'] = (int) $board;
1007
+	if (!empty($topic)) {
1008
+			$_GET['board'] = (int) $board;
1009
+	}
971 1010
 
972 1011
 	if (!empty($board))
973 1012
 	{
@@ -977,10 +1016,12 @@  discard block
 block discarded – undo
977 1016
 		// Now check if the user is a moderator.
978 1017
 		$user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0;
979 1018
 
980
-		if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin'])
981
-			$board_info['error'] = 'access';
982
-		if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin'])
983
-			$board_info['error'] = 'access';
1019
+		if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) {
1020
+					$board_info['error'] = 'access';
1021
+		}
1022
+		if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) {
1023
+					$board_info['error'] = 'access';
1024
+		}
984 1025
 
985 1026
 		// Build up the linktree.
986 1027
 		$context['linktree'] = array_merge(
@@ -1003,8 +1044,9 @@  discard block
 block discarded – undo
1003 1044
 	$context['current_board'] = $board;
1004 1045
 
1005 1046
 	// No posting in redirection boards!
1006
-	if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect']))
1007
-		$board_info['error'] == 'post_in_redirect';
1047
+	if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) {
1048
+			$board_info['error'] == 'post_in_redirect';
1049
+	}
1008 1050
 
1009 1051
 	// Hacker... you can't see this topic, I'll tell you that. (but moderators can!)
1010 1052
 	if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod']))
@@ -1030,24 +1072,23 @@  discard block
 block discarded – undo
1030 1072
 			ob_end_clean();
1031 1073
 			header('HTTP/1.1 403 Forbidden');
1032 1074
 			die;
1033
-		}
1034
-		elseif ($board_info['error'] == 'post_in_redirect')
1075
+		} elseif ($board_info['error'] == 'post_in_redirect')
1035 1076
 		{
1036 1077
 			// Slightly different error message here...
1037 1078
 			fatal_lang_error('cannot_post_redirect', false);
1038
-		}
1039
-		elseif ($user_info['is_guest'])
1079
+		} elseif ($user_info['is_guest'])
1040 1080
 		{
1041 1081
 			loadLanguage('Errors');
1042 1082
 			is_not_guest($txt['topic_gone']);
1083
+		} else {
1084
+					fatal_lang_error('topic_gone', false);
1043 1085
 		}
1044
-		else
1045
-			fatal_lang_error('topic_gone', false);
1046 1086
 	}
1047 1087
 
1048
-	if ($user_info['is_mod'])
1049
-		$user_info['groups'][] = 3;
1050
-}
1088
+	if ($user_info['is_mod']) {
1089
+			$user_info['groups'][] = 3;
1090
+	}
1091
+	}
1051 1092
 
1052 1093
 /**
1053 1094
  * Load this user's permissions.
@@ -1068,8 +1109,9 @@  discard block
 block discarded – undo
1068 1109
 		asort($cache_groups);
1069 1110
 		$cache_groups = implode(',', $cache_groups);
1070 1111
 		// If it's a spider then cache it different.
1071
-		if ($user_info['possibly_robot'])
1072
-			$cache_groups .= '-spider';
1112
+		if ($user_info['possibly_robot']) {
1113
+					$cache_groups .= '-spider';
1114
+		}
1073 1115
 
1074 1116
 		if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated'])
1075 1117
 		{
@@ -1077,9 +1119,9 @@  discard block
 block discarded – undo
1077 1119
 			banPermissions();
1078 1120
 
1079 1121
 			return;
1122
+		} elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) {
1123
+					list ($user_info['permissions'], $removals) = $temp;
1080 1124
 		}
1081
-		elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated'])
1082
-			list ($user_info['permissions'], $removals) = $temp;
1083 1125
 	}
1084 1126
 
1085 1127
 	// If it is detected as a robot, and we are restricting permissions as a special group - then implement this.
@@ -1101,23 +1143,26 @@  discard block
 block discarded – undo
1101 1143
 		$removals = array();
1102 1144
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1103 1145
 		{
1104
-			if (empty($row['add_deny']))
1105
-				$removals[] = $row['permission'];
1106
-			else
1107
-				$user_info['permissions'][] = $row['permission'];
1146
+			if (empty($row['add_deny'])) {
1147
+							$removals[] = $row['permission'];
1148
+			} else {
1149
+							$user_info['permissions'][] = $row['permission'];
1150
+			}
1108 1151
 		}
1109 1152
 		$smcFunc['db_free_result']($request);
1110 1153
 
1111
-		if (isset($cache_groups))
1112
-			cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240);
1154
+		if (isset($cache_groups)) {
1155
+					cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240);
1156
+		}
1113 1157
 	}
1114 1158
 
1115 1159
 	// Get the board permissions.
1116 1160
 	if (!empty($board))
1117 1161
 	{
1118 1162
 		// Make sure the board (if any) has been loaded by loadBoard().
1119
-		if (!isset($board_info['profile']))
1120
-			fatal_lang_error('no_board');
1163
+		if (!isset($board_info['profile'])) {
1164
+					fatal_lang_error('no_board');
1165
+		}
1121 1166
 
1122 1167
 		$request = $smcFunc['db_query']('', '
1123 1168
 			SELECT permission, add_deny
@@ -1133,20 +1178,23 @@  discard block
 block discarded – undo
1133 1178
 		);
1134 1179
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1135 1180
 		{
1136
-			if (empty($row['add_deny']))
1137
-				$removals[] = $row['permission'];
1138
-			else
1139
-				$user_info['permissions'][] = $row['permission'];
1181
+			if (empty($row['add_deny'])) {
1182
+							$removals[] = $row['permission'];
1183
+			} else {
1184
+							$user_info['permissions'][] = $row['permission'];
1185
+			}
1140 1186
 		}
1141 1187
 		$smcFunc['db_free_result']($request);
1142 1188
 	}
1143 1189
 
1144 1190
 	// Remove all the permissions they shouldn't have ;).
1145
-	if (!empty($modSettings['permission_enable_deny']))
1146
-		$user_info['permissions'] = array_diff($user_info['permissions'], $removals);
1191
+	if (!empty($modSettings['permission_enable_deny'])) {
1192
+			$user_info['permissions'] = array_diff($user_info['permissions'], $removals);
1193
+	}
1147 1194
 
1148
-	if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2)
1149
-		cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240);
1195
+	if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) {
1196
+			cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240);
1197
+	}
1150 1198
 
1151 1199
 	// Banned?  Watch, don't touch..
1152 1200
 	banPermissions();
@@ -1158,17 +1206,18 @@  discard block
 block discarded – undo
1158 1206
 		{
1159 1207
 			require_once($sourcedir . '/Subs-Auth.php');
1160 1208
 			rebuildModCache();
1209
+		} else {
1210
+					$user_info['mod_cache'] = $_SESSION['mc'];
1161 1211
 		}
1162
-		else
1163
-			$user_info['mod_cache'] = $_SESSION['mc'];
1164 1212
 
1165 1213
 		// This is a useful phantom permission added to the current user, and only the current user while they are logged in.
1166 1214
 		// For example this drastically simplifies certain changes to the profile area.
1167 1215
 		$user_info['permissions'][] = 'is_not_guest';
1168 1216
 		// And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions.
1169 1217
 		$user_info['permissions'][] = 'profile_view_own';
1170
-		if (in_array('profile_view', $user_info['permissions']))
1171
-			$user_info['permissions'][] = 'profile_view_any';
1218
+		if (in_array('profile_view', $user_info['permissions'])) {
1219
+					$user_info['permissions'][] = 'profile_view_any';
1220
+		}
1172 1221
 	}
1173 1222
 }
1174 1223
 
@@ -1186,8 +1235,9 @@  discard block
 block discarded – undo
1186 1235
 	global $image_proxy_enabled, $user_info;
1187 1236
 
1188 1237
 	// Can't just look for no users :P.
1189
-	if (empty($users))
1190
-		return array();
1238
+	if (empty($users)) {
1239
+			return array();
1240
+	}
1191 1241
 
1192 1242
 	// Pass the set value
1193 1243
 	$context['loadMemberContext_set'] = $set;
@@ -1202,8 +1252,9 @@  discard block
 block discarded – undo
1202 1252
 		for ($i = 0, $n = count($users); $i < $n; $i++)
1203 1253
 		{
1204 1254
 			$data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240);
1205
-			if ($data == null)
1206
-				continue;
1255
+			if ($data == null) {
1256
+							continue;
1257
+			}
1207 1258
 
1208 1259
 			$loaded_ids[] = $data['id_member'];
1209 1260
 			$user_profile[$data['id_member']] = $data;
@@ -1270,16 +1321,19 @@  discard block
 block discarded – undo
1270 1321
 			$row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : '';
1271 1322
 
1272 1323
 			// Take care of proxying avatar if required, do this here for maximum reach
1273
-			if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot']))
1274
-				$row['avatar'] = get_proxied_url($row['avatar']);
1324
+			if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) {
1325
+							$row['avatar'] = get_proxied_url($row['avatar']);
1326
+			}
1275 1327
 
1276 1328
 			// Keep track of the member's normal member group
1277 1329
 			$row['primary_group'] = !empty($row['member_group']) ? $row['member_group'] : '';
1278 1330
 
1279
-			if (isset($row['member_ip']))
1280
-				$row['member_ip'] = inet_dtop($row['member_ip']);
1281
-			if (isset($row['member_ip2']))
1282
-				$row['member_ip2'] = inet_dtop($row['member_ip2']);
1331
+			if (isset($row['member_ip'])) {
1332
+							$row['member_ip'] = inet_dtop($row['member_ip']);
1333
+			}
1334
+			if (isset($row['member_ip2'])) {
1335
+							$row['member_ip2'] = inet_dtop($row['member_ip2']);
1336
+			}
1283 1337
 			$new_loaded_ids[] = $row['id_member'];
1284 1338
 			$loaded_ids[] = $row['id_member'];
1285 1339
 			$row['options'] = array();
@@ -1298,8 +1352,9 @@  discard block
 block discarded – undo
1298 1352
 				'loaded_ids' => $new_loaded_ids,
1299 1353
 			)
1300 1354
 		);
1301
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1302
-			$user_profile[$row['id_member']]['options'][$row['variable']] = $row['value'];
1355
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1356
+					$user_profile[$row['id_member']]['options'][$row['variable']] = $row['value'];
1357
+		}
1303 1358
 		$smcFunc['db_free_result']($request);
1304 1359
 	}
1305 1360
 
@@ -1310,10 +1365,11 @@  discard block
 block discarded – undo
1310 1365
 	{
1311 1366
 		foreach ($loaded_ids as $a_member)
1312 1367
 		{
1313
-			if (!empty($user_profile[$a_member]['additional_groups']))
1314
-				$groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups']));
1315
-			else
1316
-				$groups = array($user_profile[$a_member]['id_group']);
1368
+			if (!empty($user_profile[$a_member]['additional_groups'])) {
1369
+							$groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups']));
1370
+			} else {
1371
+							$groups = array($user_profile[$a_member]['id_group']);
1372
+			}
1317 1373
 
1318 1374
 			$temp = array_intersect($groups, array_keys($board_info['moderator_groups']));
1319 1375
 
@@ -1326,8 +1382,9 @@  discard block
 block discarded – undo
1326 1382
 
1327 1383
 	if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3)
1328 1384
 	{
1329
-		for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++)
1330
-			cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240);
1385
+		for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) {
1386
+					cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240);
1387
+		}
1331 1388
 	}
1332 1389
 
1333 1390
 	// Are we loading any moderators?  If so, fix their group data...
@@ -1353,14 +1410,17 @@  discard block
 block discarded – undo
1353 1410
 		foreach ($temp_mods as $id)
1354 1411
 		{
1355 1412
 			// By popular demand, don't show admins or global moderators as moderators.
1356
-			if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2)
1357
-				$user_profile[$id]['member_group'] = $row['member_group'];
1413
+			if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) {
1414
+							$user_profile[$id]['member_group'] = $row['member_group'];
1415
+			}
1358 1416
 
1359 1417
 			// If the Moderator group has no color or icons, but their group does... don't overwrite.
1360
-			if (!empty($row['icons']))
1361
-				$user_profile[$id]['icons'] = $row['icons'];
1362
-			if (!empty($row['member_group_color']))
1363
-				$user_profile[$id]['member_group_color'] = $row['member_group_color'];
1418
+			if (!empty($row['icons'])) {
1419
+							$user_profile[$id]['icons'] = $row['icons'];
1420
+			}
1421
+			if (!empty($row['member_group_color'])) {
1422
+							$user_profile[$id]['member_group_color'] = $row['member_group_color'];
1423
+			}
1364 1424
 		}
1365 1425
 	}
1366 1426
 
@@ -1382,12 +1442,14 @@  discard block
 block discarded – undo
1382 1442
 	static $loadedLanguages = array();
1383 1443
 
1384 1444
 	// If this person's data is already loaded, skip it.
1385
-	if (isset($dataLoaded[$user]))
1386
-		return true;
1445
+	if (isset($dataLoaded[$user])) {
1446
+			return true;
1447
+	}
1387 1448
 
1388 1449
 	// We can't load guests or members not loaded by loadMemberData()!
1389
-	if ($user == 0)
1390
-		return false;
1450
+	if ($user == 0) {
1451
+			return false;
1452
+	}
1391 1453
 	if (!isset($user_profile[$user]))
1392 1454
 	{
1393 1455
 		trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING);
@@ -1413,12 +1475,16 @@  discard block
 block discarded – undo
1413 1475
 	$buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array();
1414 1476
 
1415 1477
 	//We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme
1416
-	if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists
1478
+	if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) {
1479
+		//icon is set and exists
1417 1480
 		$group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1];
1418
-	elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default
1481
+	} elseif (isset($profile['icons'][1])) {
1482
+		//icon is set and doesn't exist, fallback to default
1419 1483
 		$group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1];
1420
-	else //not set, bye bye
1484
+	} else {
1485
+		//not set, bye bye
1421 1486
 		$group_icon_url = '';
1487
+	}
1422 1488
 
1423 1489
 	// These minimal values are always loaded
1424 1490
 	$memberContext[$user] = array(
@@ -1437,8 +1503,9 @@  discard block
 block discarded – undo
1437 1503
 	if ($context['loadMemberContext_set'] != 'minimal')
1438 1504
 	{
1439 1505
 		// Go the extra mile and load the user's native language name.
1440
-		if (empty($loadedLanguages))
1441
-			$loadedLanguages = getLanguages();
1506
+		if (empty($loadedLanguages)) {
1507
+					$loadedLanguages = getLanguages();
1508
+		}
1442 1509
 
1443 1510
 		$memberContext[$user] += array(
1444 1511
 			'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>',
@@ -1493,31 +1560,33 @@  discard block
 block discarded – undo
1493 1560
 	{
1494 1561
 		if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://')))
1495 1562
 		{
1496
-			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11)
1497
-				$image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11));
1498
-			else
1499
-				$image = get_gravatar_url($profile['email_address']);
1500
-		}
1501
-		else
1563
+			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) {
1564
+							$image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11));
1565
+			} else {
1566
+							$image = get_gravatar_url($profile['email_address']);
1567
+			}
1568
+		} else
1502 1569
 		{
1503 1570
 			// So it's stored in the member table?
1504 1571
 			if (!empty($profile['avatar']))
1505 1572
 			{
1506 1573
 				$image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar'];
1574
+			} elseif (!empty($profile['filename'])) {
1575
+							$image = $modSettings['custom_avatar_url'] . '/' . $profile['filename'];
1507 1576
 			}
1508
-			elseif (!empty($profile['filename']))
1509
-				$image = $modSettings['custom_avatar_url'] . '/' . $profile['filename'];
1510 1577
 			// Right... no avatar...use the default one
1511
-			else
1512
-				$image = $modSettings['avatar_url'] . '/default.png';
1578
+			else {
1579
+							$image = $modSettings['avatar_url'] . '/default.png';
1580
+			}
1513 1581
 		}
1514
-		if (!empty($image))
1515
-			$memberContext[$user]['avatar'] = array(
1582
+		if (!empty($image)) {
1583
+					$memberContext[$user]['avatar'] = array(
1516 1584
 				'name' => $profile['avatar'],
1517 1585
 				'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">',
1518 1586
 				'href' => $image,
1519 1587
 				'url' => $image,
1520 1588
 			);
1589
+		}
1521 1590
 	}
1522 1591
 
1523 1592
 	// Are we also loading the members custom fields into context?
@@ -1525,13 +1594,15 @@  discard block
 block discarded – undo
1525 1594
 	{
1526 1595
 		$memberContext[$user]['custom_fields'] = array();
1527 1596
 
1528
-		if (!isset($context['display_fields']))
1529
-			$context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true);
1597
+		if (!isset($context['display_fields'])) {
1598
+					$context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true);
1599
+		}
1530 1600
 
1531 1601
 		foreach ($context['display_fields'] as $custom)
1532 1602
 		{
1533
-			if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']]))
1534
-				continue;
1603
+			if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) {
1604
+							continue;
1605
+			}
1535 1606
 
1536 1607
 			$value = $profile['options'][$custom['col_name']];
1537 1608
 
@@ -1539,31 +1610,36 @@  discard block
 block discarded – undo
1539 1610
 			$currentKey = 0;
1540 1611
 
1541 1612
 			// Create a key => value array for multiple options fields
1542
-			if (!empty($custom['options']))
1543
-				foreach ($custom['options'] as $k => $v)
1613
+			if (!empty($custom['options'])) {
1614
+							foreach ($custom['options'] as $k => $v)
1544 1615
 				{
1545 1616
 					$fieldOptions[] = $v;
1546
-					if (empty($currentKey))
1547
-						$currentKey = $v == $value ? $k : 0;
1617
+			}
1618
+					if (empty($currentKey)) {
1619
+											$currentKey = $v == $value ? $k : 0;
1620
+					}
1548 1621
 				}
1549 1622
 
1550 1623
 			// BBC?
1551
-			if ($custom['bbc'])
1552
-				$value = parse_bbc($value);
1624
+			if ($custom['bbc']) {
1625
+							$value = parse_bbc($value);
1626
+			}
1553 1627
 
1554 1628
 			// ... or checkbox?
1555
-			elseif (isset($custom['type']) && $custom['type'] == 'check')
1556
-				$value = $value ? $txt['yes'] : $txt['no'];
1629
+			elseif (isset($custom['type']) && $custom['type'] == 'check') {
1630
+							$value = $value ? $txt['yes'] : $txt['no'];
1631
+			}
1557 1632
 
1558 1633
 			// Enclosing the user input within some other text?
1559
-			if (!empty($custom['enclose']))
1560
-				$value = strtr($custom['enclose'], array(
1634
+			if (!empty($custom['enclose'])) {
1635
+							$value = strtr($custom['enclose'], array(
1561 1636
 					'{SCRIPTURL}' => $scripturl,
1562 1637
 					'{IMAGES_URL}' => $settings['images_url'],
1563 1638
 					'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
1564 1639
 					'{INPUT}' => $value,
1565 1640
 					'{KEY}' => $currentKey,
1566 1641
 				));
1642
+			}
1567 1643
 
1568 1644
 			$memberContext[$user]['custom_fields'][] = array(
1569 1645
 				'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'],
@@ -1590,8 +1666,9 @@  discard block
 block discarded – undo
1590 1666
 	global $smcFunc, $txt, $scripturl, $settings;
1591 1667
 
1592 1668
 	// Do not waste my time...
1593
-	if (empty($users) || empty($params))
1594
-		return false;
1669
+	if (empty($users) || empty($params)) {
1670
+			return false;
1671
+	}
1595 1672
 
1596 1673
 	// Make sure it's an array.
1597 1674
 	$users = !is_array($users) ? array($users) : array_unique($users);
@@ -1618,41 +1695,48 @@  discard block
 block discarded – undo
1618 1695
 		$currentKey = 0;
1619 1696
 
1620 1697
 		// Create a key => value array for multiple options fields
1621
-		if (!empty($row['field_options']))
1622
-			foreach (explode(',', $row['field_options']) as $k => $v)
1698
+		if (!empty($row['field_options'])) {
1699
+					foreach (explode(',', $row['field_options']) as $k => $v)
1623 1700
 			{
1624 1701
 				$fieldOptions[] = $v;
1625
-				if (empty($currentKey))
1626
-					$currentKey = $v == $row['value'] ? $k : 0;
1702
+		}
1703
+				if (empty($currentKey)) {
1704
+									$currentKey = $v == $row['value'] ? $k : 0;
1705
+				}
1627 1706
 			}
1628 1707
 
1629 1708
 		// BBC?
1630
-		if (!empty($row['bbc']))
1631
-			$row['value'] = parse_bbc($row['value']);
1709
+		if (!empty($row['bbc'])) {
1710
+					$row['value'] = parse_bbc($row['value']);
1711
+		}
1632 1712
 
1633 1713
 		// ... or checkbox?
1634
-		elseif (isset($row['type']) && $row['type'] == 'check')
1635
-			$row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no'];
1714
+		elseif (isset($row['type']) && $row['type'] == 'check') {
1715
+					$row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no'];
1716
+		}
1636 1717
 
1637 1718
 		// Enclosing the user input within some other text?
1638
-		if (!empty($row['enclose']))
1639
-			$row['value'] = strtr($row['enclose'], array(
1719
+		if (!empty($row['enclose'])) {
1720
+					$row['value'] = strtr($row['enclose'], array(
1640 1721
 				'{SCRIPTURL}' => $scripturl,
1641 1722
 				'{IMAGES_URL}' => $settings['images_url'],
1642 1723
 				'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
1643 1724
 				'{INPUT}' => un_htmlspecialchars($row['value']),
1644 1725
 				'{KEY}' => $currentKey,
1645 1726
 			));
1727
+		}
1646 1728
 
1647 1729
 		// Send a simple array if there is just 1 param
1648
-		if (count($params) == 1)
1649
-			$return[$row['id_member']] = $row;
1730
+		if (count($params) == 1) {
1731
+					$return[$row['id_member']] = $row;
1732
+		}
1650 1733
 
1651 1734
 		// More than 1? knock yourself out...
1652 1735
 		else
1653 1736
 		{
1654
-			if (!isset($return[$row['id_member']]))
1655
-				$return[$row['id_member']] = array();
1737
+			if (!isset($return[$row['id_member']])) {
1738
+							$return[$row['id_member']] = array();
1739
+			}
1656 1740
 
1657 1741
 			$return[$row['id_member']][$row['variable']] = $row;
1658 1742
 		}
@@ -1686,8 +1770,9 @@  discard block
 block discarded – undo
1686 1770
 	global $context;
1687 1771
 
1688 1772
 	// Don't know any browser!
1689
-	if (empty($context['browser']))
1690
-		detectBrowser();
1773
+	if (empty($context['browser'])) {
1774
+			detectBrowser();
1775
+	}
1691 1776
 
1692 1777
 	return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false;
1693 1778
 }
@@ -1705,8 +1790,9 @@  discard block
 block discarded – undo
1705 1790
 	global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled;
1706 1791
 
1707 1792
 	// The theme was specified by parameter.
1708
-	if (!empty($id_theme))
1709
-		$id_theme = (int) $id_theme;
1793
+	if (!empty($id_theme)) {
1794
+			$id_theme = (int) $id_theme;
1795
+	}
1710 1796
 	// The theme was specified by REQUEST.
1711 1797
 	elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum')))
1712 1798
 	{
@@ -1714,32 +1800,38 @@  discard block
 block discarded – undo
1714 1800
 		$_SESSION['id_theme'] = $id_theme;
1715 1801
 	}
1716 1802
 	// The theme was specified by REQUEST... previously.
1717
-	elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum')))
1718
-		$id_theme = (int) $_SESSION['id_theme'];
1803
+	elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) {
1804
+			$id_theme = (int) $_SESSION['id_theme'];
1805
+	}
1719 1806
 	// The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.)
1720
-	elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme']))
1721
-		$id_theme = $user_info['theme'];
1807
+	elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) {
1808
+			$id_theme = $user_info['theme'];
1809
+	}
1722 1810
 	// The theme was specified by the board.
1723
-	elseif (!empty($board_info['theme']))
1724
-		$id_theme = $board_info['theme'];
1811
+	elseif (!empty($board_info['theme'])) {
1812
+			$id_theme = $board_info['theme'];
1813
+	}
1725 1814
 	// The theme is the forum's default.
1726
-	else
1727
-		$id_theme = $modSettings['theme_guests'];
1815
+	else {
1816
+			$id_theme = $modSettings['theme_guests'];
1817
+	}
1728 1818
 
1729 1819
 	// Verify the id_theme... no foul play.
1730 1820
 	// Always allow the board specific theme, if they are overriding.
1731
-	if (!empty($board_info['theme']) && $board_info['override_theme'])
1732
-		$id_theme = $board_info['theme'];
1821
+	if (!empty($board_info['theme']) && $board_info['override_theme']) {
1822
+			$id_theme = $board_info['theme'];
1823
+	}
1733 1824
 	// If they have specified a particular theme to use with SSI allow it to be used.
1734
-	elseif (!empty($ssi_theme) && $id_theme == $ssi_theme)
1735
-		$id_theme = (int) $id_theme;
1736
-	elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum'))
1825
+	elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) {
1826
+			$id_theme = (int) $id_theme;
1827
+	} elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum'))
1737 1828
 	{
1738 1829
 		$themes = explode(',', $modSettings['enableThemes']);
1739
-		if (!in_array($id_theme, $themes))
1740
-			$id_theme = $modSettings['theme_guests'];
1741
-		else
1742
-			$id_theme = (int) $id_theme;
1830
+		if (!in_array($id_theme, $themes)) {
1831
+					$id_theme = $modSettings['theme_guests'];
1832
+		} else {
1833
+					$id_theme = (int) $id_theme;
1834
+		}
1743 1835
 	}
1744 1836
 		
1745 1837
 	// We already load the basic stuff?
@@ -1748,18 +1840,19 @@  discard block
 block discarded – undo
1748 1840
 		$member = empty($user_info['id']) ? -1 : $user_info['id'];
1749 1841
 
1750 1842
 		// Disable image proxy if we don't have SSL enabled
1751
-		if (empty($modSettings['force_ssl']))
1752
-			$image_proxy_enabled = false;
1843
+		if (empty($modSettings['force_ssl'])) {
1844
+					$image_proxy_enabled = false;
1845
+		}
1753 1846
 
1754 1847
 		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated'])
1755 1848
 		{
1756 1849
 			$themeData = $temp;
1757 1850
 			$flag = true;
1851
+		} elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) {
1852
+					$themeData = $temp + array($member => array());
1853
+		} else {
1854
+					$themeData = array(-1 => array(), 0 => array(), $member => array());
1758 1855
 		}
1759
-		elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated'])
1760
-			$themeData = $temp + array($member => array());
1761
-		else
1762
-			$themeData = array(-1 => array(), 0 => array(), $member => array());
1763 1856
 
1764 1857
 		if (empty($flag))
1765 1858
 		{
@@ -1779,31 +1872,37 @@  discard block
 block discarded – undo
1779 1872
 			while ($row = $smcFunc['db_fetch_assoc']($result))
1780 1873
 			{
1781 1874
 				// There are just things we shouldn't be able to change as members.
1782
-				if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url')))
1783
-					continue;
1875
+				if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) {
1876
+									continue;
1877
+				}
1784 1878
 
1785 1879
 				// If this is the theme_dir of the default theme, store it.
1786
-				if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member']))
1787
-					$themeData[0]['default_' . $row['variable']] = $row['value'];
1880
+				if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) {
1881
+									$themeData[0]['default_' . $row['variable']] = $row['value'];
1882
+				}
1788 1883
 
1789 1884
 				// If this isn't set yet, is a theme option, or is not the default theme..
1790
-				if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1')
1791
-					$themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value'];
1885
+				if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') {
1886
+									$themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value'];
1887
+				}
1792 1888
 			}
1793 1889
 			$smcFunc['db_free_result']($result);
1794 1890
 
1795
-			if (!empty($themeData[-1]))
1796
-				foreach ($themeData[-1] as $k => $v)
1891
+			if (!empty($themeData[-1])) {
1892
+							foreach ($themeData[-1] as $k => $v)
1797 1893
 				{
1798 1894
 					if (!isset($themeData[$member][$k]))
1799 1895
 						$themeData[$member][$k] = $v;
1896
+			}
1800 1897
 				}
1801 1898
 
1802
-			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
1803
-				cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60);
1899
+			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
1900
+							cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60);
1901
+			}
1804 1902
 			// Only if we didn't already load that part of the cache...
1805
-			elseif (!isset($temp))
1806
-				cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90);
1903
+			elseif (!isset($temp)) {
1904
+							cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90);
1905
+			}
1807 1906
 		}
1808 1907
 
1809 1908
 		$settings = $themeData[0];
@@ -1820,17 +1919,20 @@  discard block
 block discarded – undo
1820 1919
 		$settings['template_dirs'][] = $settings['theme_dir'];
1821 1920
 
1822 1921
 		// Based on theme (if there is one).
1823
-		if (!empty($settings['base_theme_dir']))
1824
-			$settings['template_dirs'][] = $settings['base_theme_dir'];
1922
+		if (!empty($settings['base_theme_dir'])) {
1923
+					$settings['template_dirs'][] = $settings['base_theme_dir'];
1924
+		}
1825 1925
 
1826 1926
 		// Lastly the default theme.
1827
-		if ($settings['theme_dir'] != $settings['default_theme_dir'])
1828
-			$settings['template_dirs'][] = $settings['default_theme_dir'];
1927
+		if ($settings['theme_dir'] != $settings['default_theme_dir']) {
1928
+					$settings['template_dirs'][] = $settings['default_theme_dir'];
1929
+		}
1829 1930
 	}
1830 1931
 
1831 1932
 
1832
-	if (!$initialize)
1833
-		return;
1933
+	if (!$initialize) {
1934
+			return;
1935
+	}
1834 1936
 
1835 1937
 	// Check to see if we're forcing SSL
1836 1938
 	if (!empty($modSettings['force_ssl']) && empty($maintenance) &&
@@ -1851,8 +1953,9 @@  discard block
 block discarded – undo
1851 1953
 		$detected_url = httpsOn() ? 'https://' : 'http://';
1852 1954
 		$detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST'];
1853 1955
 		$temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/'));
1854
-		if ($temp != '/')
1855
-			$detected_url .= $temp;
1956
+		if ($temp != '/') {
1957
+					$detected_url .= $temp;
1958
+		}
1856 1959
 	}
1857 1960
 	if (isset($detected_url) && $detected_url != $boardurl)
1858 1961
 	{
@@ -1864,8 +1967,9 @@  discard block
 block discarded – undo
1864 1967
 			foreach ($aliases as $alias)
1865 1968
 			{
1866 1969
 				// Rip off all the boring parts, spaces, etc.
1867
-				if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias))
1868
-					$do_fix = true;
1970
+				if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) {
1971
+									$do_fix = true;
1972
+				}
1869 1973
 			}
1870 1974
 		}
1871 1975
 
@@ -1873,21 +1977,23 @@  discard block
 block discarded – undo
1873 1977
 		if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI')
1874 1978
 		{
1875 1979
 			// Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;).
1876
-			if (empty($_GET))
1877
-				redirectexit('wwwRedirect');
1878
-			else
1980
+			if (empty($_GET)) {
1981
+							redirectexit('wwwRedirect');
1982
+			} else
1879 1983
 			{
1880 1984
 				$k = key($_GET);
1881 1985
 				$v = current($_GET);
1882 1986
 
1883
-				if ($k != 'wwwRedirect')
1884
-					redirectexit('wwwRedirect;' . $k . '=' . $v);
1987
+				if ($k != 'wwwRedirect') {
1988
+									redirectexit('wwwRedirect;' . $k . '=' . $v);
1989
+				}
1885 1990
 			}
1886 1991
 		}
1887 1992
 
1888 1993
 		// #3 is just a check for SSL...
1889
-		if (strtr($detected_url, array('https://' => 'http://')) == $boardurl)
1890
-			$do_fix = true;
1994
+		if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) {
1995
+					$do_fix = true;
1996
+		}
1891 1997
 
1892 1998
 		// Okay, #4 - perhaps it's an IP address?  We're gonna want to use that one, then. (assuming it's the IP or something...)
1893 1999
 		if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1)
@@ -1922,8 +2028,9 @@  discard block
 block discarded – undo
1922 2028
 					$board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl));
1923 2029
 				}
1924 2030
 			}
1925
-			foreach ($context['linktree'] as $k => $dummy)
1926
-				$context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl));
2031
+			foreach ($context['linktree'] as $k => $dummy) {
2032
+							$context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl));
2033
+			}
1927 2034
 		}
1928 2035
 	}
1929 2036
 	// Set up the contextual user array.
@@ -1942,16 +2049,16 @@  discard block
 block discarded – undo
1942 2049
 			'email' => $user_info['email'],
1943 2050
 			'ignoreusers' => $user_info['ignoreusers'],
1944 2051
 		);
1945
-		if (!$context['user']['is_guest'])
1946
-			$context['user']['name'] = $user_info['name'];
1947
-		elseif ($context['user']['is_guest'] && !empty($txt['guest_title']))
1948
-			$context['user']['name'] = $txt['guest_title'];
2052
+		if (!$context['user']['is_guest']) {
2053
+					$context['user']['name'] = $user_info['name'];
2054
+		} elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) {
2055
+					$context['user']['name'] = $txt['guest_title'];
2056
+		}
1949 2057
 
1950 2058
 		// Determine the current smiley set.
1951 2059
 		$user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set'];
1952 2060
 		$context['user']['smiley_set'] = $user_info['smiley_set'];
1953
-	}
1954
-	else
2061
+	} else
1955 2062
 	{
1956 2063
 		// What to do when there is no $user_info (e.g., an error very early in the login process)
1957 2064
 		$context['user'] = array(
@@ -1985,18 +2092,24 @@  discard block
 block discarded – undo
1985 2092
 	}
1986 2093
 
1987 2094
 	// Some basic information...
1988
-	if (!isset($context['html_headers']))
1989
-		$context['html_headers'] = '';
1990
-	if (!isset($context['javascript_files']))
1991
-		$context['javascript_files'] = array();
1992
-	if (!isset($context['css_files']))
1993
-		$context['css_files'] = array();
1994
-	if (!isset($context['css_header']))
1995
-		$context['css_header'] = array();
1996
-	if (!isset($context['javascript_inline']))
1997
-		$context['javascript_inline'] = array('standard' => array(), 'defer' => array());
1998
-	if (!isset($context['javascript_vars']))
1999
-		$context['javascript_vars'] = array();
2095
+	if (!isset($context['html_headers'])) {
2096
+			$context['html_headers'] = '';
2097
+	}
2098
+	if (!isset($context['javascript_files'])) {
2099
+			$context['javascript_files'] = array();
2100
+	}
2101
+	if (!isset($context['css_files'])) {
2102
+			$context['css_files'] = array();
2103
+	}
2104
+	if (!isset($context['css_header'])) {
2105
+			$context['css_header'] = array();
2106
+	}
2107
+	if (!isset($context['javascript_inline'])) {
2108
+			$context['javascript_inline'] = array('standard' => array(), 'defer' => array());
2109
+	}
2110
+	if (!isset($context['javascript_vars'])) {
2111
+			$context['javascript_vars'] = array();
2112
+	}
2000 2113
 
2001 2114
 	$context['login_url'] =  $scripturl . '?action=login2';
2002 2115
 	$context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | ';
@@ -2008,16 +2121,18 @@  discard block
 block discarded – undo
2008 2121
 	$context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null;
2009 2122
 	$context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null;
2010 2123
 	$context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3;
2011
-	if (isset($modSettings['load_average']))
2012
-		$context['load_average'] = $modSettings['load_average'];
2124
+	if (isset($modSettings['load_average'])) {
2125
+			$context['load_average'] = $modSettings['load_average'];
2126
+	}
2013 2127
 
2014 2128
 	// Detect the browser. This is separated out because it's also used in attachment downloads
2015 2129
 	detectBrowser();
2016 2130
 
2017 2131
 	// Set the top level linktree up.
2018 2132
 	// Note that if we're dealing with certain very early errors (e.g., login) the linktree might not be set yet...
2019
-	if (empty($context['linktree']))
2020
-		$context['linktree'] = array();
2133
+	if (empty($context['linktree'])) {
2134
+			$context['linktree'] = array();
2135
+	}
2021 2136
 	array_unshift($context['linktree'], array(
2022 2137
 		'url' => $scripturl,
2023 2138
 		'name' => $context['forum_name_html_safe']
@@ -2026,8 +2141,9 @@  discard block
 block discarded – undo
2026 2141
 	// This allows sticking some HTML on the page output - useful for controls.
2027 2142
 	$context['insert_after_template'] = '';
2028 2143
 
2029
-	if (!isset($txt))
2030
-		$txt = array();
2144
+	if (!isset($txt)) {
2145
+			$txt = array();
2146
+	}
2031 2147
 
2032 2148
 	$simpleActions = array(
2033 2149
 		'findmember',
@@ -2073,9 +2189,10 @@  discard block
 block discarded – undo
2073 2189
 
2074 2190
 	// See if theres any extra param to check.
2075 2191
 	$requiresXML = false;
2076
-	foreach ($extraParams as $key => $extra)
2077
-		if (isset($_REQUEST[$extra]))
2192
+	foreach ($extraParams as $key => $extra) {
2193
+			if (isset($_REQUEST[$extra]))
2078 2194
 			$requiresXML = true;
2195
+	}
2079 2196
 
2080 2197
 	// Output is fully XML, so no need for the index template.
2081 2198
 	if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML))
@@ -2090,37 +2207,39 @@  discard block
 block discarded – undo
2090 2207
 	{
2091 2208
 		loadLanguage('index+Modifications');
2092 2209
 		$context['template_layers'] = array();
2093
-	}
2094
-
2095
-	else
2210
+	} else
2096 2211
 	{
2097 2212
 		// Custom templates to load, or just default?
2098
-		if (isset($settings['theme_templates']))
2099
-			$templates = explode(',', $settings['theme_templates']);
2100
-		else
2101
-			$templates = array('index');
2213
+		if (isset($settings['theme_templates'])) {
2214
+					$templates = explode(',', $settings['theme_templates']);
2215
+		} else {
2216
+					$templates = array('index');
2217
+		}
2102 2218
 
2103 2219
 		// Load each template...
2104
-		foreach ($templates as $template)
2105
-			loadTemplate($template);
2220
+		foreach ($templates as $template) {
2221
+					loadTemplate($template);
2222
+		}
2106 2223
 
2107 2224
 		// ...and attempt to load their associated language files.
2108 2225
 		$required_files = implode('+', array_merge($templates, array('Modifications')));
2109 2226
 		loadLanguage($required_files, '', false);
2110 2227
 
2111 2228
 		// Custom template layers?
2112
-		if (isset($settings['theme_layers']))
2113
-			$context['template_layers'] = explode(',', $settings['theme_layers']);
2114
-		else
2115
-			$context['template_layers'] = array('html', 'body');
2229
+		if (isset($settings['theme_layers'])) {
2230
+					$context['template_layers'] = explode(',', $settings['theme_layers']);
2231
+		} else {
2232
+					$context['template_layers'] = array('html', 'body');
2233
+		}
2116 2234
 	}
2117 2235
 
2118 2236
 	// Initialize the theme.
2119 2237
 	loadSubTemplate('init', 'ignore');
2120 2238
 
2121 2239
 	// Allow overriding the board wide time/number formats.
2122
-	if (empty($user_settings['time_format']) && !empty($txt['time_format']))
2123
-		$user_info['time_format'] = $txt['time_format'];
2240
+	if (empty($user_settings['time_format']) && !empty($txt['time_format'])) {
2241
+			$user_info['time_format'] = $txt['time_format'];
2242
+	}
2124 2243
 
2125 2244
 	// Set the character set from the template.
2126 2245
 	$context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set'];
@@ -2128,12 +2247,14 @@  discard block
 block discarded – undo
2128 2247
 	$context['right_to_left'] = !empty($txt['lang_rtl']);
2129 2248
 
2130 2249
 	// Guests may still need a name.
2131
-	if ($context['user']['is_guest'] && empty($context['user']['name']))
2132
-		$context['user']['name'] = $txt['guest_title'];
2250
+	if ($context['user']['is_guest'] && empty($context['user']['name'])) {
2251
+			$context['user']['name'] = $txt['guest_title'];
2252
+	}
2133 2253
 
2134 2254
 	// Any theme-related strings that need to be loaded?
2135
-	if (!empty($settings['require_theme_strings']))
2136
-		loadLanguage('ThemeStrings', '', false);
2255
+	if (!empty($settings['require_theme_strings'])) {
2256
+			loadLanguage('ThemeStrings', '', false);
2257
+	}
2137 2258
 
2138 2259
 	// Make a special URL for the language.
2139 2260
 	$settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']);
@@ -2144,8 +2265,9 @@  discard block
 block discarded – undo
2144 2265
 	// Here is my luvly Responsive CSS
2145 2266
 	loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true, 'order_pos' => 9000), 'smf_responsive');
2146 2267
 
2147
-	if ($context['right_to_left'])
2148
-		loadCSSFile('rtl.css', array('order_pos' => 200), 'smf_rtl');
2268
+	if ($context['right_to_left']) {
2269
+			loadCSSFile('rtl.css', array('order_pos' => 200), 'smf_rtl');
2270
+	}
2149 2271
 
2150 2272
 	// We allow theme variants, because we're cool.
2151 2273
 	$context['theme_variant'] = '';
@@ -2153,14 +2275,17 @@  discard block
 block discarded – undo
2153 2275
 	if (!empty($settings['theme_variants']))
2154 2276
 	{
2155 2277
 		// Overriding - for previews and that ilk.
2156
-		if (!empty($_REQUEST['variant']))
2157
-			$_SESSION['id_variant'] = $_REQUEST['variant'];
2278
+		if (!empty($_REQUEST['variant'])) {
2279
+					$_SESSION['id_variant'] = $_REQUEST['variant'];
2280
+		}
2158 2281
 		// User selection?
2159
-		if (empty($settings['disable_user_variant']) || allowedTo('admin_forum'))
2160
-			$context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : '');
2282
+		if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) {
2283
+					$context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : '');
2284
+		}
2161 2285
 		// If not a user variant, select the default.
2162
-		if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants']))
2163
-			$context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0];
2286
+		if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) {
2287
+					$context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0];
2288
+		}
2164 2289
 
2165 2290
 		// Do this to keep things easier in the templates.
2166 2291
 		$context['theme_variant'] = '_' . $context['theme_variant'];
@@ -2169,20 +2294,23 @@  discard block
 block discarded – undo
2169 2294
 		if (!empty($context['theme_variant']))
2170 2295
 		{
2171 2296
 			loadCSSFile('index' . $context['theme_variant'] . '.css', array('order_pos' => 300), 'smf_index' . $context['theme_variant']);
2172
-			if ($context['right_to_left'])
2173
-				loadCSSFile('rtl' . $context['theme_variant'] . '.css', array('order_pos' => 400), 'smf_rtl' . $context['theme_variant']);
2297
+			if ($context['right_to_left']) {
2298
+							loadCSSFile('rtl' . $context['theme_variant'] . '.css', array('order_pos' => 400), 'smf_rtl' . $context['theme_variant']);
2299
+			}
2174 2300
 		}
2175 2301
 	}
2176 2302
 
2177 2303
 	// Let's be compatible with old themes!
2178
-	if (!function_exists('template_html_above') && in_array('html', $context['template_layers']))
2179
-		$context['template_layers'] = array('main');
2304
+	if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) {
2305
+			$context['template_layers'] = array('main');
2306
+	}
2180 2307
 
2181 2308
 	$context['tabindex'] = 1;
2182 2309
 
2183 2310
 	// Compatibility.
2184
-	if (!isset($settings['theme_version']))
2185
-		$modSettings['memberCount'] = $modSettings['totalMembers'];
2311
+	if (!isset($settings['theme_version'])) {
2312
+			$modSettings['memberCount'] = $modSettings['totalMembers'];
2313
+	}
2186 2314
 
2187 2315
 	// Default JS variables for use in every theme
2188 2316
 	$context['javascript_vars'] = array(
@@ -2202,18 +2330,18 @@  discard block
 block discarded – undo
2202 2330
 	);
2203 2331
 
2204 2332
 	// Add the JQuery library to the list of files to load.
2205
-	if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn')
2206
-		loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery');
2207
-
2208
-	elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local')
2209
-		loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery');
2210
-
2211
-	elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom')
2212
-		loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery');
2333
+	if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') {
2334
+			loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery');
2335
+	} elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') {
2336
+			loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery');
2337
+	} elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') {
2338
+			loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery');
2339
+	}
2213 2340
 
2214 2341
 	// Auto loading? template_javascript() will take care of the local half of this.
2215
-	else
2216
-		loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery');
2342
+	else {
2343
+			loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery');
2344
+	}
2217 2345
 
2218 2346
 	// Queue our JQuery plugins!
2219 2347
 	loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins');
@@ -2236,12 +2364,12 @@  discard block
 block discarded – undo
2236 2364
 			require_once($sourcedir . '/ScheduledTasks.php');
2237 2365
 
2238 2366
 			// What to do, what to do?!
2239
-			if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time())
2240
-				AutoTask();
2241
-			else
2242
-				ReduceMailQueue();
2243
-		}
2244
-		else
2367
+			if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) {
2368
+							AutoTask();
2369
+			} else {
2370
+							ReduceMailQueue();
2371
+			}
2372
+		} else
2245 2373
 		{
2246 2374
 			$type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq';
2247 2375
 			$ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time'];
@@ -2292,8 +2420,9 @@  discard block
 block discarded – undo
2292 2420
 		foreach ($theme_includes as $include)
2293 2421
 		{
2294 2422
 			$include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
2295
-			if (file_exists($include))
2296
-				require_once($include);
2423
+			if (file_exists($include)) {
2424
+							require_once($include);
2425
+			}
2297 2426
 		}
2298 2427
 	}
2299 2428
 
@@ -2303,8 +2432,9 @@  discard block
 block discarded – undo
2303 2432
 	// Privacy logic only when enabled, got no valid version, try not to call the policy data
2304 2433
 	if (!empty($modSettings['enable_policy_function']) && empty($options['policy_isvalid']) &&
2305 2434
 			( empty($_REQUEST['area']) || (!empty($_REQUEST['area']) && $_REQUEST['area'] != 'getpolicydata')) &&
2306
-			!$user_info['is_guest'])
2307
-		redirectexit('action=profile;area=getpolicydata;u=1');
2435
+			!$user_info['is_guest']) {
2436
+			redirectexit('action=profile;area=getpolicydata;u=1');
2437
+	}
2308 2438
 	// We are ready to go.
2309 2439
 	$context['theme_loaded'] = true;
2310 2440
 }
@@ -2328,16 +2458,19 @@  discard block
 block discarded – undo
2328 2458
 	// Do any style sheets first, cause we're easy with those.
2329 2459
 	if (!empty($style_sheets))
2330 2460
 	{
2331
-		if (!is_array($style_sheets))
2332
-			$style_sheets = array($style_sheets);
2461
+		if (!is_array($style_sheets)) {
2462
+					$style_sheets = array($style_sheets);
2463
+		}
2333 2464
 
2334
-		foreach ($style_sheets as $sheet)
2335
-			loadCSSFile($sheet . '.css', array(), $sheet);
2465
+		foreach ($style_sheets as $sheet) {
2466
+					loadCSSFile($sheet . '.css', array(), $sheet);
2467
+		}
2336 2468
 	}
2337 2469
 
2338 2470
 	// No template to load?
2339
-	if ($template_name === false)
2340
-		return true;
2471
+	if ($template_name === false) {
2472
+			return true;
2473
+	}
2341 2474
 
2342 2475
 	$loaded = false;
2343 2476
 	foreach ($settings['template_dirs'] as $template_dir)
@@ -2352,12 +2485,14 @@  discard block
 block discarded – undo
2352 2485
 
2353 2486
 	if ($loaded)
2354 2487
 	{
2355
-		if ($db_show_debug === true)
2356
-			$context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')';
2488
+		if ($db_show_debug === true) {
2489
+					$context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')';
2490
+		}
2357 2491
 
2358 2492
 		// If they have specified an initialization function for this template, go ahead and call it now.
2359
-		if (function_exists('template_' . $template_name . '_init'))
2360
-			call_user_func('template_' . $template_name . '_init');
2493
+		if (function_exists('template_' . $template_name . '_init')) {
2494
+					call_user_func('template_' . $template_name . '_init');
2495
+		}
2361 2496
 	}
2362 2497
 	// Hmmm... doesn't exist?!  I don't suppose the directory is wrong, is it?
2363 2498
 	elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default'))
@@ -2377,13 +2512,14 @@  discard block
 block discarded – undo
2377 2512
 		loadTemplate($template_name);
2378 2513
 	}
2379 2514
 	// Cause an error otherwise.
2380
-	elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal)
2381
-		fatal_lang_error('theme_template_error', 'template', array((string) $template_name));
2382
-	elseif ($fatal)
2383
-		die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template'));
2384
-	else
2385
-		return false;
2386
-}
2515
+	elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) {
2516
+			fatal_lang_error('theme_template_error', 'template', array((string) $template_name));
2517
+	} elseif ($fatal) {
2518
+			die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template'));
2519
+	} else {
2520
+			return false;
2521
+	}
2522
+	}
2387 2523
 
2388 2524
 /**
2389 2525
  * Load a sub-template.
@@ -2401,17 +2537,19 @@  discard block
 block discarded – undo
2401 2537
 {
2402 2538
 	global $context, $txt, $db_show_debug;
2403 2539
 
2404
-	if ($db_show_debug === true)
2405
-		$context['debug']['sub_templates'][] = $sub_template_name;
2540
+	if ($db_show_debug === true) {
2541
+			$context['debug']['sub_templates'][] = $sub_template_name;
2542
+	}
2406 2543
 
2407 2544
 	// Figure out what the template function is named.
2408 2545
 	$theme_function = 'template_' . $sub_template_name;
2409
-	if (function_exists($theme_function))
2410
-		$theme_function();
2411
-	elseif ($fatal === false)
2412
-		fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name));
2413
-	elseif ($fatal !== 'ignore')
2414
-		die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template'));
2546
+	if (function_exists($theme_function)) {
2547
+			$theme_function();
2548
+	} elseif ($fatal === false) {
2549
+			fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name));
2550
+	} elseif ($fatal !== 'ignore') {
2551
+			die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template'));
2552
+	}
2415 2553
 
2416 2554
 	// Are we showing debugging for templates?  Just make sure not to do it before the doctype...
2417 2555
 	if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml']))
@@ -2441,8 +2579,9 @@  discard block
 block discarded – undo
2441 2579
 {
2442 2580
 	global $settings, $context, $modSettings;
2443 2581
 
2444
-	if (empty($context['css_files_order']))
2445
-		$context['css_files_order'] = array();
2582
+	if (empty($context['css_files_order'])) {
2583
+			$context['css_files_order'] = array();
2584
+	}
2446 2585
 
2447 2586
 	$params['seed'] = (!array_key_exists('seed', $params) || (array_key_exists('seed', $params) && $params['seed'] === true)) ? (array_key_exists('browser_cache', $modSettings) ? $modSettings['browser_cache'] : '') : (is_string($params['seed']) ? ($params['seed'] = $params['seed'][0] === '?' ? $params['seed'] : '?' . $params['seed']) : '');
2448 2587
 	$params['force_current'] = isset($params['force_current']) ? $params['force_current'] : false;
@@ -2453,8 +2592,9 @@  discard block
 block discarded – undo
2453 2592
 	$params['order_pos'] = isset($params['order_pos']) ? (int) $params['order_pos'] : 3000;
2454 2593
 
2455 2594
 	// If this is an external file, automatically set this to false.
2456
-	if (!empty($params['external']))
2457
-		$params['minimize'] = false;
2595
+	if (!empty($params['external'])) {
2596
+			$params['minimize'] = false;
2597
+	}
2458 2598
 
2459 2599
 	// Account for shorthand like admin.css?alp21 filenames
2460 2600
 	$has_seed = strpos($fileName, '.css?');
@@ -2471,16 +2611,12 @@  discard block
 block discarded – undo
2471 2611
 			{
2472 2612
 				$fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
2473 2613
 				$filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
2474
-			}
2475
-
2476
-			else
2614
+			} else
2477 2615
 			{
2478 2616
 				$fileUrl = false;
2479 2617
 				$filePath = false;
2480 2618
 			}
2481
-		}
2482
-
2483
-		else
2619
+		} else
2484 2620
 		{
2485 2621
 			$fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
2486 2622
 			$filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
@@ -2498,16 +2634,18 @@  discard block
 block discarded – undo
2498 2634
 	if (!empty($fileName))
2499 2635
 	{
2500 2636
 		// find a free number/position
2501
-		while (isset($context['css_files_order'][$params['order_pos']]))
2502
-			$params['order_pos']++;
2637
+		while (isset($context['css_files_order'][$params['order_pos']])) {
2638
+					$params['order_pos']++;
2639
+		}
2503 2640
 		$context['css_files_order'][$params['order_pos']] = $id;
2504 2641
 
2505 2642
 		$context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params);
2506 2643
 	}
2507 2644
 
2508
-	if (!empty($context['right_to_left']) && !empty($params['rtl']))
2509
-		loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0)));
2510
-}
2645
+	if (!empty($context['right_to_left']) && !empty($params['rtl'])) {
2646
+			loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0)));
2647
+	}
2648
+	}
2511 2649
 
2512 2650
 /**
2513 2651
  * Add a block of inline css code to be executed later
@@ -2524,8 +2662,9 @@  discard block
 block discarded – undo
2524 2662
 	global $context;
2525 2663
 
2526 2664
 	// Gotta add something...
2527
-	if (empty($css))
2528
-		return false;
2665
+	if (empty($css)) {
2666
+			return false;
2667
+	}
2529 2668
 
2530 2669
 	$context['css_header'][] = $css;
2531 2670
 }
@@ -2561,8 +2700,9 @@  discard block
 block discarded – undo
2561 2700
 	$params['validate'] = isset($params['validate']) ? $params['validate'] : true;
2562 2701
 
2563 2702
 	// If this is an external file, automatically set this to false.
2564
-	if (!empty($params['external']))
2565
-		$params['minimize'] = false;
2703
+	if (!empty($params['external'])) {
2704
+			$params['minimize'] = false;
2705
+	}
2566 2706
 
2567 2707
 	// Account for shorthand like admin.js?alp21 filenames
2568 2708
 	$has_seed = strpos($fileName, '.js?');
@@ -2579,16 +2719,12 @@  discard block
 block discarded – undo
2579 2719
 			{
2580 2720
 				$fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
2581 2721
 				$filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
2582
-			}
2583
-
2584
-			else
2722
+			} else
2585 2723
 			{
2586 2724
 				$fileUrl = false;
2587 2725
 				$filePath = false;
2588 2726
 			}
2589
-		}
2590
-
2591
-		else
2727
+		} else
2592 2728
 		{
2593 2729
 			$fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
2594 2730
 			$filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
@@ -2603,9 +2739,10 @@  discard block
 block discarded – undo
2603 2739
 	}
2604 2740
 
2605 2741
 	// Add it to the array for use in the template
2606
-	if (!empty($fileName))
2607
-		$context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params);
2608
-}
2742
+	if (!empty($fileName)) {
2743
+			$context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params);
2744
+	}
2745
+	}
2609 2746
 
2610 2747
 /**
2611 2748
  * Add a Javascript variable for output later (for feeding text strings and similar to JS)
@@ -2619,9 +2756,10 @@  discard block
 block discarded – undo
2619 2756
 {
2620 2757
 	global $context;
2621 2758
 
2622
-	if (!empty($key) && (!empty($value) || $value === '0'))
2623
-		$context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value;
2624
-}
2759
+	if (!empty($key) && (!empty($value) || $value === '0')) {
2760
+			$context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value;
2761
+	}
2762
+	}
2625 2763
 
2626 2764
 /**
2627 2765
  * Add a block of inline Javascript code to be executed later
@@ -2638,8 +2776,9 @@  discard block
 block discarded – undo
2638 2776
 {
2639 2777
 	global $context;
2640 2778
 
2641
-	if (empty($javascript))
2642
-		return false;
2779
+	if (empty($javascript)) {
2780
+			return false;
2781
+	}
2643 2782
 
2644 2783
 	$context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript;
2645 2784
 }
@@ -2660,15 +2799,18 @@  discard block
 block discarded – undo
2660 2799
 	static $already_loaded = array();
2661 2800
 
2662 2801
 	// Default to the user's language.
2663
-	if ($lang == '')
2664
-		$lang = isset($user_info['language']) ? $user_info['language'] : $language;
2802
+	if ($lang == '') {
2803
+			$lang = isset($user_info['language']) ? $user_info['language'] : $language;
2804
+	}
2665 2805
 
2666 2806
 	// Do we want the English version of language file as fallback?
2667
-	if (empty($modSettings['disable_language_fallback']) && $lang != 'english')
2668
-		loadLanguage($template_name, 'english', false);
2807
+	if (empty($modSettings['disable_language_fallback']) && $lang != 'english') {
2808
+			loadLanguage($template_name, 'english', false);
2809
+	}
2669 2810
 
2670
-	if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang)
2671
-		return $lang;
2811
+	if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) {
2812
+			return $lang;
2813
+	}
2672 2814
 
2673 2815
 	// Make sure we have $settings - if not we're in trouble and need to find it!
2674 2816
 	if (empty($settings['default_theme_dir']))
@@ -2679,8 +2821,9 @@  discard block
 block discarded – undo
2679 2821
 
2680 2822
 	// What theme are we in?
2681 2823
 	$theme_name = basename($settings['theme_url']);
2682
-	if (empty($theme_name))
2683
-		$theme_name = 'unknown';
2824
+	if (empty($theme_name)) {
2825
+			$theme_name = 'unknown';
2826
+	}
2684 2827
 
2685 2828
 	// For each file open it up and write it out!
2686 2829
 	foreach (explode('+', $template_name) as $template)
@@ -2722,8 +2865,9 @@  discard block
 block discarded – undo
2722 2865
 				$found = true;
2723 2866
 
2724 2867
 				// setlocale is required for basename() & pathinfo() to work properly on the selected language
2725
-				if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set']))
2726
-					setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']);
2868
+				if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) {
2869
+									setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']);
2870
+				}
2727 2871
 
2728 2872
 				break;
2729 2873
 			}
@@ -2763,8 +2907,9 @@  discard block
 block discarded – undo
2763 2907
 	}
2764 2908
 
2765 2909
 	// Keep track of what we're up to soldier.
2766
-	if ($db_show_debug === true)
2767
-		$context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')';
2910
+	if ($db_show_debug === true) {
2911
+			$context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')';
2912
+	}
2768 2913
 
2769 2914
 	// Remember what we have loaded, and in which language.
2770 2915
 	$already_loaded[$template_name] = $lang;
@@ -2810,8 +2955,9 @@  discard block
 block discarded – undo
2810 2955
 				)
2811 2956
 			);
2812 2957
 			// In the EXTREMELY unlikely event this happens, give an error message.
2813
-			if ($smcFunc['db_num_rows']($result) == 0)
2814
-				fatal_lang_error('parent_not_found', 'critical');
2958
+			if ($smcFunc['db_num_rows']($result) == 0) {
2959
+							fatal_lang_error('parent_not_found', 'critical');
2960
+			}
2815 2961
 			while ($row = $smcFunc['db_fetch_assoc']($result))
2816 2962
 			{
2817 2963
 				if (!isset($boards[$row['id_board']]))
@@ -2828,8 +2974,8 @@  discard block
 block discarded – undo
2828 2974
 					);
2829 2975
 				}
2830 2976
 				// If a moderator exists for this board, add that moderator for all children too.
2831
-				if (!empty($row['id_moderator']))
2832
-					foreach ($boards as $id => $dummy)
2977
+				if (!empty($row['id_moderator'])) {
2978
+									foreach ($boards as $id => $dummy)
2833 2979
 					{
2834 2980
 						$boards[$id]['moderators'][$row['id_moderator']] = array(
2835 2981
 							'id' => $row['id_moderator'],
@@ -2837,11 +2983,12 @@  discard block
 block discarded – undo
2837 2983
 							'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'],
2838 2984
 							'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>'
2839 2985
 						);
2986
+				}
2840 2987
 					}
2841 2988
 
2842 2989
 				// If a moderator group exists for this board, add that moderator group for all children too
2843
-				if (!empty($row['id_moderator_group']))
2844
-					foreach ($boards as $id => $dummy)
2990
+				if (!empty($row['id_moderator_group'])) {
2991
+									foreach ($boards as $id => $dummy)
2845 2992
 					{
2846 2993
 						$boards[$id]['moderator_groups'][$row['id_moderator_group']] = array(
2847 2994
 							'id' => $row['id_moderator_group'],
@@ -2849,6 +2996,7 @@  discard block
 block discarded – undo
2849 2996
 							'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'],
2850 2997
 							'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>'
2851 2998
 						);
2999
+				}
2852 3000
 					}
2853 3001
 			}
2854 3002
 			$smcFunc['db_free_result']($result);
@@ -2875,23 +3023,27 @@  discard block
 block discarded – undo
2875 3023
 	if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null)
2876 3024
 	{
2877 3025
 		// If we don't have our ucwords function defined yet, let's load the settings data.
2878
-		if (empty($smcFunc['ucwords']))
2879
-			reloadSettings();
3026
+		if (empty($smcFunc['ucwords'])) {
3027
+					reloadSettings();
3028
+		}
2880 3029
 
2881 3030
 		// If we don't have our theme information yet, let's get it.
2882
-		if (empty($settings['default_theme_dir']))
2883
-			loadTheme(0, false);
3031
+		if (empty($settings['default_theme_dir'])) {
3032
+					loadTheme(0, false);
3033
+		}
2884 3034
 
2885 3035
 		// Default language directories to try.
2886 3036
 		$language_directories = array(
2887 3037
 			$settings['default_theme_dir'] . '/languages',
2888 3038
 		);
2889
-		if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir'])
2890
-			$language_directories[] = $settings['actual_theme_dir'] . '/languages';
3039
+		if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) {
3040
+					$language_directories[] = $settings['actual_theme_dir'] . '/languages';
3041
+		}
2891 3042
 
2892 3043
 		// We possibly have a base theme directory.
2893
-		if (!empty($settings['base_theme_dir']))
2894
-			$language_directories[] = $settings['base_theme_dir'] . '/languages';
3044
+		if (!empty($settings['base_theme_dir'])) {
3045
+					$language_directories[] = $settings['base_theme_dir'] . '/languages';
3046
+		}
2895 3047
 
2896 3048
 		// Remove any duplicates.
2897 3049
 		$language_directories = array_unique($language_directories);
@@ -2905,20 +3057,21 @@  discard block
 block discarded – undo
2905 3057
 		foreach ($language_directories as $language_dir)
2906 3058
 		{
2907 3059
 			// Can't look in here... doesn't exist!
2908
-			if (!file_exists($language_dir))
2909
-				continue;
3060
+			if (!file_exists($language_dir)) {
3061
+							continue;
3062
+			}
2910 3063
 
2911 3064
 			$dir = dir($language_dir);
2912 3065
 			while ($entry = $dir->read())
2913 3066
 			{
2914 3067
 				// Look for the index language file... For good measure skip any "index.language-utf8.php" files
2915
-				if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches))
2916
-					continue;
2917
-
2918
-				if (!empty($langList) && !empty($langList[$matches[1]]))
2919
-					$langName = $langList[$matches[1]];
3068
+				if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) {
3069
+									continue;
3070
+				}
2920 3071
 
2921
-				else
3072
+				if (!empty($langList) && !empty($langList[$matches[1]])) {
3073
+									$langName = $langList[$matches[1]];
3074
+				} else
2922 3075
 				{
2923 3076
 					$langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' ')));
2924 3077
 
@@ -2959,12 +3112,14 @@  discard block
 block discarded – undo
2959 3112
 		}
2960 3113
 
2961 3114
 		// Do we need to store the lang list?
2962
-		if (empty($langList))
2963
-			updateSettings(array('langList' => $smcFunc['json_encode']($catchLang)));
3115
+		if (empty($langList)) {
3116
+					updateSettings(array('langList' => $smcFunc['json_encode']($catchLang)));
3117
+		}
2964 3118
 
2965 3119
 		// Let's cash in on this deal.
2966
-		if (!empty($modSettings['cache_enable']))
2967
-			cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600);
3120
+		if (!empty($modSettings['cache_enable'])) {
3121
+					cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600);
3122
+		}
2968 3123
 	}
2969 3124
 
2970 3125
 	return $context['languages'];
@@ -2987,8 +3142,9 @@  discard block
 block discarded – undo
2987 3142
 	global $modSettings, $options, $txt;
2988 3143
 	static $censor_vulgar = null, $censor_proper;
2989 3144
 
2990
-	if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '')
2991
-		return $text;
3145
+	if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') {
3146
+			return $text;
3147
+	}
2992 3148
 
2993 3149
 	// If they haven't yet been loaded, load them.
2994 3150
 	if ($censor_vulgar == null)
@@ -3019,9 +3175,9 @@  discard block
 block discarded – undo
3019 3175
 	{
3020 3176
 		$func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace';
3021 3177
 		$text = $func($censor_vulgar, $censor_proper, $text);
3178
+	} else {
3179
+			$text = preg_replace($censor_vulgar, $censor_proper, $text);
3022 3180
 	}
3023
-	else
3024
-		$text = preg_replace($censor_vulgar, $censor_proper, $text);
3025 3181
 
3026 3182
 	return $text;
3027 3183
 }
@@ -3047,30 +3203,35 @@  discard block
 block discarded – undo
3047 3203
 	@ini_set('track_errors', '1');
3048 3204
 
3049 3205
 	// Don't include the file more than once, if $once is true.
3050
-	if ($once && in_array($filename, $templates))
3051
-		return;
3206
+	if ($once && in_array($filename, $templates)) {
3207
+			return;
3208
+	}
3052 3209
 	// Add this file to the include list, whether $once is true or not.
3053
-	else
3054
-		$templates[] = $filename;
3210
+	else {
3211
+			$templates[] = $filename;
3212
+	}
3055 3213
 
3056 3214
 
3057 3215
 	$file_found = file_exists($filename);
3058 3216
 
3059
-	if ($once && $file_found)
3060
-		require_once($filename);
3061
-	elseif ($file_found)
3062
-		require($filename);
3217
+	if ($once && $file_found) {
3218
+			require_once($filename);
3219
+	} elseif ($file_found) {
3220
+			require($filename);
3221
+	}
3063 3222
 
3064 3223
 	if ($file_found !== true)
3065 3224
 	{
3066 3225
 		ob_end_clean();
3067
-		if (!empty($modSettings['enableCompressedOutput']))
3068
-			@ob_start('ob_gzhandler');
3069
-		else
3070
-			ob_start();
3226
+		if (!empty($modSettings['enableCompressedOutput'])) {
3227
+					@ob_start('ob_gzhandler');
3228
+		} else {
3229
+					ob_start();
3230
+		}
3071 3231
 
3072
-		if (isset($_GET['debug']))
3073
-			header('content-type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3232
+		if (isset($_GET['debug'])) {
3233
+					header('content-type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3234
+		}
3074 3235
 
3075 3236
 		// Don't cache error pages!!
3076 3237
 		header('expires: Mon, 26 Jul 1997 05:00:00 GMT');
@@ -3089,12 +3250,13 @@  discard block
 block discarded – undo
3089 3250
 		echo '<!DOCTYPE html>
3090 3251
 <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '>
3091 3252
 	<head>';
3092
-		if (isset($context['character_set']))
3093
-			echo '
3253
+		if (isset($context['character_set'])) {
3254
+					echo '
3094 3255
 		<meta charset="', $context['character_set'], '">';
3256
+		}
3095 3257
 
3096
-		if (!empty($maintenance) && !allowedTo('admin_forum'))
3097
-			echo '
3258
+		if (!empty($maintenance) && !allowedTo('admin_forum')) {
3259
+					echo '
3098 3260
 		<title>', $mtitle, '</title>
3099 3261
 	</head>
3100 3262
 	<body>
@@ -3102,8 +3264,8 @@  discard block
 block discarded – undo
3102 3264
 		', $mmessage, '
3103 3265
 	</body>
3104 3266
 </html>';
3105
-		elseif (!allowedTo('admin_forum'))
3106
-			echo '
3267
+		} elseif (!allowedTo('admin_forum')) {
3268
+					echo '
3107 3269
 		<title>', $txt['template_parse_error'], '</title>
3108 3270
 	</head>
3109 3271
 	<body>
@@ -3111,14 +3273,16 @@  discard block
 block discarded – undo
3111 3273
 		', $txt['template_parse_error_message'], '
3112 3274
 	</body>
3113 3275
 </html>';
3114
-		else
3276
+		} else
3115 3277
 		{
3116 3278
 			$error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => '')));
3117 3279
 			$error_array = error_get_last();
3118
-			if (empty($error) && ini_get('track_errors') && !empty($error_array))
3119
-				$error = $error_array['message'];
3120
-			if (empty($error))
3121
-				$error = $txt['template_parse_errmsg'];
3280
+			if (empty($error) && ini_get('track_errors') && !empty($error_array)) {
3281
+							$error = $error_array['message'];
3282
+			}
3283
+			if (empty($error)) {
3284
+							$error = $txt['template_parse_errmsg'];
3285
+			}
3122 3286
 
3123 3287
 			$error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>'));
3124 3288
 
@@ -3129,11 +3293,12 @@  discard block
 block discarded – undo
3129 3293
 		<h3>', $txt['template_parse_error'], '</h3>
3130 3294
 		', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => '')));
3131 3295
 
3132
-			if (!empty($error))
3133
-				echo '
3296
+			if (!empty($error)) {
3297
+							echo '
3134 3298
 		<hr>
3135 3299
 
3136 3300
 		<div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>';
3301
+			}
3137 3302
 
3138 3303
 			// I know, I know... this is VERY COMPLICATED.  Still, it's good.
3139 3304
 			if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0)
@@ -3143,10 +3308,11 @@  discard block
 block discarded – undo
3143 3308
 				$data2 = preg_split('~\<br( /)?\>~', $data2);
3144 3309
 
3145 3310
 				// Fix the PHP code stuff...
3146
-				if (!isBrowser('gecko'))
3147
-					$data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2);
3148
-				else
3149
-					$data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2);
3311
+				if (!isBrowser('gecko')) {
3312
+									$data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2);
3313
+				} else {
3314
+									$data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2);
3315
+				}
3150 3316
 
3151 3317
 				// Now we get to work around a bug in PHP where it doesn't escape <br>s!
3152 3318
 				$j = -1;
@@ -3154,8 +3320,9 @@  discard block
 block discarded – undo
3154 3320
 				{
3155 3321
 					$j++;
3156 3322
 
3157
-					if (substr_count($line, '<br>') == 0)
3158
-						continue;
3323
+					if (substr_count($line, '<br>') == 0) {
3324
+											continue;
3325
+					}
3159 3326
 
3160 3327
 					$n = substr_count($line, '<br>');
3161 3328
 					for ($i = 0; $i < $n; $i++)
@@ -3174,38 +3341,42 @@  discard block
 block discarded – undo
3174 3341
 				// Figure out what the color coding was before...
3175 3342
 				$line = max($match[1] - 9, 1);
3176 3343
 				$last_line = '';
3177
-				for ($line2 = $line - 1; $line2 > 1; $line2--)
3178
-					if (strpos($data2[$line2], '<') !== false)
3344
+				for ($line2 = $line - 1; $line2 > 1; $line2--) {
3345
+									if (strpos($data2[$line2], '<') !== false)
3179 3346
 					{
3180 3347
 						if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0)
3181 3348
 							$last_line = $color_match[1];
3349
+				}
3182 3350
 						break;
3183 3351
 					}
3184 3352
 
3185 3353
 				// Show the relevant lines...
3186 3354
 				for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++)
3187 3355
 				{
3188
-					if ($line == $match[1])
3189
-						echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">';
3356
+					if ($line == $match[1]) {
3357
+											echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">';
3358
+					}
3190 3359
 
3191 3360
 					echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> ';
3192
-					if (isset($data2[$line]) && $data2[$line] != '')
3193
-						echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line];
3361
+					if (isset($data2[$line]) && $data2[$line] != '') {
3362
+											echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line];
3363
+					}
3194 3364
 
3195 3365
 					if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0)
3196 3366
 					{
3197 3367
 						$last_line = $color_match[1];
3198 3368
 						echo '</', substr($last_line, 1, 4), '>';
3369
+					} elseif ($last_line != '' && strpos($data2[$line], '<') !== false) {
3370
+											$last_line = '';
3371
+					} elseif ($last_line != '' && $data2[$line] != '') {
3372
+											echo '</', substr($last_line, 1, 4), '>';
3199 3373
 					}
3200
-					elseif ($last_line != '' && strpos($data2[$line], '<') !== false)
3201
-						$last_line = '';
3202
-					elseif ($last_line != '' && $data2[$line] != '')
3203
-						echo '</', substr($last_line, 1, 4), '>';
3204 3374
 
3205
-					if ($line == $match[1])
3206
-						echo '</pre></div><pre style="margin: 0;">';
3207
-					else
3208
-						echo "\n";
3375
+					if ($line == $match[1]) {
3376
+											echo '</pre></div><pre style="margin: 0;">';
3377
+					} else {
3378
+											echo "\n";
3379
+					}
3209 3380
 				}
3210 3381
 
3211 3382
 				echo '</pre></div>';
@@ -3229,8 +3400,9 @@  discard block
 block discarded – undo
3229 3400
 	global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port, $db_mb4;
3230 3401
 
3231 3402
 	// Figure out what type of database we are using.
3232
-	if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
3233
-		$db_type = 'mysql';
3403
+	if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) {
3404
+			$db_type = 'mysql';
3405
+	}
3234 3406
 
3235 3407
 	// Load the file for the database.
3236 3408
 	require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
@@ -3238,11 +3410,13 @@  discard block
 block discarded – undo
3238 3410
 	$db_options = array();
3239 3411
 
3240 3412
 	// Add in the port if needed
3241
-	if (!empty($db_port))
3242
-		$db_options['port'] = $db_port;
3413
+	if (!empty($db_port)) {
3414
+			$db_options['port'] = $db_port;
3415
+	}
3243 3416
 
3244
-	if (!empty($db_mb4))
3245
-		$db_options['db_mb4'] = $db_mb4;
3417
+	if (!empty($db_mb4)) {
3418
+			$db_options['db_mb4'] = $db_mb4;
3419
+	}
3246 3420
 
3247 3421
 	// If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use.
3248 3422
 	if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
@@ -3261,13 +3435,15 @@  discard block
 block discarded – undo
3261 3435
 	}
3262 3436
 
3263 3437
 	// Safe guard here, if there isn't a valid connection lets put a stop to it.
3264
-	if (!$db_connection)
3265
-		display_db_error();
3438
+	if (!$db_connection) {
3439
+			display_db_error();
3440
+	}
3266 3441
 
3267 3442
 	// If in SSI mode fix up the prefix.
3268
-	if (SMF == 'SSI')
3269
-		db_fix_prefix($db_prefix, $db_name);
3270
-}
3443
+	if (SMF == 'SSI') {
3444
+			db_fix_prefix($db_prefix, $db_name);
3445
+	}
3446
+	}
3271 3447
 
3272 3448
 /**
3273 3449
  * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it.
@@ -3281,10 +3457,11 @@  discard block
 block discarded – undo
3281 3457
 	global $sourcedir, $cacheAPI, $cache_accelerator;
3282 3458
 
3283 3459
 	// Not overriding this and we have a cacheAPI, send it back.
3284
-	if (empty($overrideCache) && is_object($cacheAPI))
3285
-		return $cacheAPI;
3286
-	elseif (is_null($cacheAPI))
3287
-		$cacheAPI = false;
3460
+	if (empty($overrideCache) && is_object($cacheAPI)) {
3461
+			return $cacheAPI;
3462
+	} elseif (is_null($cacheAPI)) {
3463
+			$cacheAPI = false;
3464
+	}
3288 3465
 
3289 3466
 	// Make sure our class is in session.
3290 3467
 	require_once($sourcedir . '/Class-CacheAPI.php');
@@ -3305,8 +3482,9 @@  discard block
 block discarded – undo
3305 3482
 		if (!$testAPI->isSupported())
3306 3483
 		{
3307 3484
 			// Can we save ourselves?
3308
-			if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf')
3309
-				return loadCacheAccelerator(null, false);
3485
+			if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') {
3486
+							return loadCacheAccelerator(null, false);
3487
+			}
3310 3488
 			return false;
3311 3489
 		}
3312 3490
 
@@ -3318,9 +3496,9 @@  discard block
 block discarded – undo
3318 3496
 		{
3319 3497
 			$cacheAPI = $testAPI;
3320 3498
 			return $cacheAPI;
3499
+		} else {
3500
+					return $testAPI;
3321 3501
 		}
3322
-		else
3323
-			return $testAPI;
3324 3502
 	}
3325 3503
 }
3326 3504
 
@@ -3340,8 +3518,9 @@  discard block
 block discarded – undo
3340 3518
 
3341 3519
 	// @todo Why are we doing this if caching is disabled?
3342 3520
 
3343
-	if (function_exists('call_integration_hook'))
3344
-		call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level));
3521
+	if (function_exists('call_integration_hook')) {
3522
+			call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level));
3523
+	}
3345 3524
 
3346 3525
 	/* Refresh the cache if either:
3347 3526
 		1. Caching is disabled.
@@ -3355,16 +3534,19 @@  discard block
 block discarded – undo
3355 3534
 		require_once($sourcedir . '/' . $file);
3356 3535
 		$cache_block = call_user_func_array($function, $params);
3357 3536
 
3358
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level)
3359
-			cache_put_data($key, $cache_block, $cache_block['expires'] - time());
3537
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) {
3538
+					cache_put_data($key, $cache_block, $cache_block['expires'] - time());
3539
+		}
3360 3540
 	}
3361 3541
 
3362 3542
 	// Some cached data may need a freshening up after retrieval.
3363
-	if (!empty($cache_block['post_retri_eval']))
3364
-		eval($cache_block['post_retri_eval']);
3543
+	if (!empty($cache_block['post_retri_eval'])) {
3544
+			eval($cache_block['post_retri_eval']);
3545
+	}
3365 3546
 
3366
-	if (function_exists('call_integration_hook'))
3367
-		call_integration_hook('post_cache_quick_get', array(&$cache_block));
3547
+	if (function_exists('call_integration_hook')) {
3548
+			call_integration_hook('post_cache_quick_get', array(&$cache_block));
3549
+	}
3368 3550
 
3369 3551
 	return $cache_block['data'];
3370 3552
 }
@@ -3391,8 +3573,9 @@  discard block
 block discarded – undo
3391 3573
 	global $smcFunc, $cache_enable, $cacheAPI;
3392 3574
 	global $cache_hits, $cache_count, $db_show_debug;
3393 3575
 
3394
-	if (empty($cache_enable) || empty($cacheAPI))
3395
-		return;
3576
+	if (empty($cache_enable) || empty($cacheAPI)) {
3577
+			return;
3578
+	}
3396 3579
 
3397 3580
 	$cache_count = isset($cache_count) ? $cache_count + 1 : 1;
3398 3581
 	if (isset($db_show_debug) && $db_show_debug === true)
@@ -3405,12 +3588,14 @@  discard block
 block discarded – undo
3405 3588
 	$value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value));
3406 3589
 	$cacheAPI->putData($key, $value, $ttl);
3407 3590
 
3408
-	if (function_exists('call_integration_hook'))
3409
-		call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl));
3591
+	if (function_exists('call_integration_hook')) {
3592
+			call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl));
3593
+	}
3410 3594
 
3411
-	if (isset($db_show_debug) && $db_show_debug === true)
3412
-		$cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
3413
-}
3595
+	if (isset($db_show_debug) && $db_show_debug === true) {
3596
+			$cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
3597
+	}
3598
+	}
3414 3599
 
3415 3600
 /**
3416 3601
  * Gets the value from the cache specified by key, so long as it is not older than ttl seconds.
@@ -3426,8 +3611,9 @@  discard block
 block discarded – undo
3426 3611
 	global $smcFunc, $cache_enable, $cacheAPI;
3427 3612
 	global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug;
3428 3613
 
3429
-	if (empty($cache_enable) || empty($cacheAPI))
3430
-		return;
3614
+	if (empty($cache_enable) || empty($cacheAPI)) {
3615
+			return;
3616
+	}
3431 3617
 
3432 3618
 	$cache_count = isset($cache_count) ? $cache_count + 1 : 1;
3433 3619
 	if (isset($db_show_debug) && $db_show_debug === true)
@@ -3447,16 +3633,18 @@  discard block
 block discarded – undo
3447 3633
 
3448 3634
 		if (empty($value))
3449 3635
 		{
3450
-			if (!is_array($cache_misses))
3451
-				$cache_misses = array();
3636
+			if (!is_array($cache_misses)) {
3637
+							$cache_misses = array();
3638
+			}
3452 3639
 
3453 3640
 			$cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1;
3454 3641
 			$cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get');
3455 3642
 		}
3456 3643
 	}
3457 3644
 
3458
-	if (function_exists('call_integration_hook') && isset($value))
3459
-		call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value));
3645
+	if (function_exists('call_integration_hook') && isset($value)) {
3646
+			call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value));
3647
+	}
3460 3648
 
3461 3649
 	return empty($value) ? null : (isset($smcFunc['json_decode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true));
3462 3650
 }
@@ -3478,8 +3666,9 @@  discard block
 block discarded – undo
3478 3666
 	global $cacheAPI;
3479 3667
 
3480 3668
 	// If we can't get to the API, can't do this.
3481
-	if (empty($cacheAPI))
3482
-		return;
3669
+	if (empty($cacheAPI)) {
3670
+			return;
3671
+	}
3483 3672
 
3484 3673
 	// Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure.
3485 3674
 	$cacheAPI->cleanCache($type);
@@ -3504,8 +3693,9 @@  discard block
 block discarded – undo
3504 3693
 	global $modSettings, $smcFunc, $image_proxy_enabled, $user_info;
3505 3694
 
3506 3695
 	// Come on!
3507
-	if (empty($data))
3508
-		return array();
3696
+	if (empty($data)) {
3697
+			return array();
3698
+	}
3509 3699
 
3510 3700
 	// Set a nice default var.
3511 3701
 	$image = '';
@@ -3513,11 +3703,11 @@  discard block
 block discarded – undo
3513 3703
 	// Gravatar has been set as mandatory!
3514 3704
 	if (!empty($modSettings['gravatarOverride']))
3515 3705
 	{
3516
-		if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://'))
3517
-			$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3518
-
3519
-		else if (!empty($data['email']))
3520
-			$image = get_gravatar_url($data['email']);
3706
+		if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) {
3707
+					$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3708
+		} else if (!empty($data['email'])) {
3709
+					$image = get_gravatar_url($data['email']);
3710
+		}
3521 3711
 	}
3522 3712
 
3523 3713
 	// Look if the user has a gravatar field or has set an external url as avatar.
@@ -3529,54 +3719,60 @@  discard block
 block discarded – undo
3529 3719
 			// Gravatar.
3530 3720
 			if (stristr($data['avatar'], 'gravatar://'))
3531 3721
 			{
3532
-				if ($data['avatar'] == 'gravatar://')
3533
-					$image = get_gravatar_url($data['email']);
3534
-
3535
-				elseif (!empty($modSettings['gravatarAllowExtraEmail']))
3536
-					$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3722
+				if ($data['avatar'] == 'gravatar://') {
3723
+									$image = get_gravatar_url($data['email']);
3724
+				} elseif (!empty($modSettings['gravatarAllowExtraEmail'])) {
3725
+									$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3726
+				}
3537 3727
 			}
3538 3728
 
3539 3729
 			// External url.
3540 3730
 			else
3541 3731
 			{
3542 3732
 				// Using ssl?
3543
-				if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot']))
3544
-					$image = get_proxied_url($data['avatar']);
3733
+				if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) {
3734
+									$image = get_proxied_url($data['avatar']);
3735
+				}
3545 3736
 
3546 3737
 				// Just a plain external url.
3547
-				else
3548
-					$image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar'];
3738
+				else {
3739
+									$image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar'];
3740
+				}
3549 3741
 			}
3550 3742
 		}
3551 3743
 
3552 3744
 		// Perhaps this user has an attachment as avatar...
3553
-		else if (!empty($data['filename']))
3554
-			$image = $modSettings['custom_avatar_url'] . '/' . $data['filename'];
3745
+		else if (!empty($data['filename'])) {
3746
+					$image = $modSettings['custom_avatar_url'] . '/' . $data['filename'];
3747
+		}
3555 3748
 
3556 3749
 		// Right... no avatar... use our default image.
3557
-		else
3558
-			$image = $modSettings['avatar_url'] . '/default.png';
3750
+		else {
3751
+					$image = $modSettings['avatar_url'] . '/default.png';
3752
+		}
3559 3753
 	}
3560 3754
 
3561 3755
 	call_integration_hook('integrate_set_avatar_data', array(&$image, &$data));
3562 3756
 
3563 3757
 	// At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed.
3564
-	if (!empty($image))
3565
-		return array(
3758
+	if (!empty($image)) {
3759
+			return array(
3566 3760
 			'name' => !empty($data['avatar']) ? $data['avatar'] : '',
3567 3761
 			'image' => '<img class="avatar" src="' . $image . '" />',
3568 3762
 			'href' => $image,
3569 3763
 			'url' => $image,
3570 3764
 		);
3765
+	}
3571 3766
 
3572 3767
 	// Fallback to make life easier for everyone...
3573
-	else
3574
-		return array(
3768
+	else {
3769
+			return array(
3575 3770
 			'name' => '',
3576 3771
 			'image' => '',
3577 3772
 			'href' => '',
3578 3773
 			'url' => '',
3579 3774
 		);
3580
-}
3775
+	}
3776
+	}
3581 3777
 
3582 3778
 ?>
3583 3779
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Subs-Members.php 1 patch
Braces   +208 added lines, -151 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
  * Delete one or more members.
@@ -43,30 +44,32 @@  discard block
 block discarded – undo
43 44
 	setMemoryLimit('128M');
44 45
 
45 46
 	// If it's not an array, make it so!
46
-	if (!is_array($users))
47
-		$users = array($users);
48
-	else
49
-		$users = array_unique($users);
47
+	if (!is_array($users)) {
48
+			$users = array($users);
49
+	} else {
50
+			$users = array_unique($users);
51
+	}
50 52
 
51 53
 	// Make sure there's no void user in here.
52 54
 	$users = array_diff($users, array(0));
53 55
 
54 56
 	// How many are they deleting?
55
-	if (empty($users))
56
-		return;
57
-	elseif (count($users) == 1)
57
+	if (empty($users)) {
58
+			return;
59
+	} elseif (count($users) == 1)
58 60
 	{
59 61
 		list ($user) = $users;
60 62
 
61
-		if ($user == $user_info['id'])
62
-			isAllowedTo('profile_remove_own');
63
-		else
64
-			isAllowedTo('profile_remove_any');
65
-	}
66
-	else
63
+		if ($user == $user_info['id']) {
64
+					isAllowedTo('profile_remove_own');
65
+		} else {
66
+					isAllowedTo('profile_remove_any');
67
+		}
68
+	} else
67 69
 	{
68
-		foreach ($users as $k => $v)
69
-			$users[$k] = (int) $v;
70
+		foreach ($users as $k => $v) {
71
+					$users[$k] = (int) $v;
72
+		}
70 73
 
71 74
 		// Deleting more than one?  You can't have more than one account...
72 75
 		isAllowedTo('profile_remove_any');
@@ -88,26 +91,30 @@  discard block
 block discarded – undo
88 91
 	$user_log_details = array();
89 92
 	while ($row = $smcFunc['db_fetch_assoc']($request))
90 93
 	{
91
-		if ($row['is_admin'])
92
-			$admins[] = $row['id_member'];
94
+		if ($row['is_admin']) {
95
+					$admins[] = $row['id_member'];
96
+		}
93 97
 		$user_log_details[$row['id_member']] = array($row['id_member'], $row['member_name']);
94 98
 	}
95 99
 	$smcFunc['db_free_result']($request);
96 100
 
97
-	if (empty($user_log_details))
98
-		return;
101
+	if (empty($user_log_details)) {
102
+			return;
103
+	}
99 104
 
100 105
 	// Make sure they aren't trying to delete administrators if they aren't one.  But don't bother checking if it's just themself.
101 106
 	if (!empty($admins) && ($check_not_admin || (!allowedTo('admin_forum') && (count($users) != 1 || $users[0] != $user_info['id']))))
102 107
 	{
103 108
 		$users = array_diff($users, $admins);
104
-		foreach ($admins as $id)
105
-			unset($user_log_details[$id]);
109
+		foreach ($admins as $id) {
110
+					unset($user_log_details[$id]);
111
+		}
106 112
 	}
107 113
 
108 114
 	// No one left?
109
-	if (empty($users))
110
-		return;
115
+	if (empty($users)) {
116
+			return;
117
+	}
111 118
 
112 119
 	// Log the action - regardless of who is deleting it.
113 120
 	$log_changes = array();
@@ -124,8 +131,9 @@  discard block
 block discarded – undo
124 131
 		);
125 132
 
126 133
 		// Remove any cached data if enabled.
127
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
128
-			cache_put_data('user_settings-' . $user[0], null, 60);
134
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
135
+					cache_put_data('user_settings-' . $user[0], null, 60);
136
+		}
129 137
 	}
130 138
 
131 139
 	// Make these peoples' posts guest posts.
@@ -388,8 +396,8 @@  discard block
 block discarded – undo
388 396
 			'buddy_list' => implode(', buddy_list) != 0 OR FIND_IN_SET(', $users),
389 397
 		)
390 398
 	);
391
-	while ($row = $smcFunc['db_fetch_assoc']($request))
392
-		$smcFunc['db_query']('', '
399
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
400
+			$smcFunc['db_query']('', '
393 401
 			UPDATE {db_prefix}members
394 402
 			SET
395 403
 				pm_ignore_list = {string:pm_ignore_list},
@@ -401,6 +409,7 @@  discard block
 block discarded – undo
401 409
 				'buddy_list' => implode(',', array_diff(explode(',', $row['buddy_list']), $users)),
402 410
 			)
403 411
 		);
412
+	}
404 413
 	$smcFunc['db_free_result']($request);
405 414
 
406 415
 	// Make sure no member's birthday is still sticking in the calendar...
@@ -455,29 +464,34 @@  discard block
 block discarded – undo
455 464
 	elseif ($regOptions['interface'] == 'guest')
456 465
 	{
457 466
 		// You cannot register twice...
458
-		if (empty($user_info['is_guest']))
459
-			redirectexit();
467
+		if (empty($user_info['is_guest'])) {
468
+					redirectexit();
469
+		}
460 470
 
461 471
 		// Make sure they didn't just register with this session.
462
-		if (!empty($_SESSION['just_registered']) && empty($modSettings['disableRegisterCheck']))
463
-			fatal_lang_error('register_only_once', false);
472
+		if (!empty($_SESSION['just_registered']) && empty($modSettings['disableRegisterCheck'])) {
473
+					fatal_lang_error('register_only_once', false);
474
+		}
464 475
 	}
465 476
 
466 477
 	// Spaces and other odd characters are evil...
467 478
 	$regOptions['username'] = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $regOptions['username']));
468 479
 
469 480
 	// @todo Separate the sprintf?
470
-	if (empty($regOptions['email']) || !filter_var($regOptions['email'], FILTER_VALIDATE_EMAIL) || strlen($regOptions['email']) > 255)
471
-		$reg_errors[] = array('lang', 'profile_error_bad_email');
481
+	if (empty($regOptions['email']) || !filter_var($regOptions['email'], FILTER_VALIDATE_EMAIL) || strlen($regOptions['email']) > 255) {
482
+			$reg_errors[] = array('lang', 'profile_error_bad_email');
483
+	}
472 484
 
473 485
 	$username_validation_errors = validateUsername(0, $regOptions['username'], true, !empty($regOptions['check_reserved_name']));
474
-	if (!empty($username_validation_errors))
475
-		$reg_errors = array_merge($reg_errors, $username_validation_errors);
486
+	if (!empty($username_validation_errors)) {
487
+			$reg_errors = array_merge($reg_errors, $username_validation_errors);
488
+	}
476 489
 
477 490
 	// Generate a validation code if it's supposed to be emailed.
478 491
 	$validation_code = '';
479
-	if ($regOptions['require'] == 'activation')
480
-		$validation_code = generateValidationCode();
492
+	if ($regOptions['require'] == 'activation') {
493
+			$validation_code = generateValidationCode();
494
+	}
481 495
 
482 496
 	// If you haven't put in a password generate one.
483 497
 	if ($regOptions['interface'] == 'admin' && $regOptions['password'] == '')
@@ -487,8 +501,9 @@  discard block
 block discarded – undo
487 501
 		$regOptions['password_check'] = $regOptions['password'];
488 502
 	}
489 503
 	// Does the first password match the second?
490
-	elseif ($regOptions['password'] != $regOptions['password_check'])
491
-		$reg_errors[] = array('lang', 'passwords_dont_match');
504
+	elseif ($regOptions['password'] != $regOptions['password_check']) {
505
+			$reg_errors[] = array('lang', 'passwords_dont_match');
506
+	}
492 507
 
493 508
 	// That's kind of easy to guess...
494 509
 	if ($regOptions['password'] == '')
@@ -502,13 +517,15 @@  discard block
 block discarded – undo
502 517
 		$passwordError = validatePassword($regOptions['password'], $regOptions['username'], array($regOptions['email']));
503 518
 
504 519
 		// Password isn't legal?
505
-		if ($passwordError != null)
506
-			$reg_errors[] = array('lang', 'profile_error_password_' . $passwordError);
520
+		if ($passwordError != null) {
521
+					$reg_errors[] = array('lang', 'profile_error_password_' . $passwordError);
522
+		}
507 523
 	}
508 524
 
509 525
 	// You may not be allowed to register this email.
510
-	if (!empty($regOptions['check_email_ban']))
511
-		isBannedEmail($regOptions['email'], 'cannot_register', $txt['ban_register_prohibited']);
526
+	if (!empty($regOptions['check_email_ban'])) {
527
+			isBannedEmail($regOptions['email'], 'cannot_register', $txt['ban_register_prohibited']);
528
+	}
512 529
 
513 530
 	// Check if the email address is in use.
514 531
 	$request = $smcFunc['db_query']('', '
@@ -523,8 +540,9 @@  discard block
 block discarded – undo
523 540
 		)
524 541
 	);
525 542
 	// @todo Separate the sprintf?
526
-	if ($smcFunc['db_num_rows']($request) != 0)
527
-		$reg_errors[] = array('lang', 'email_in_use', false, array($smcFunc['htmlspecialchars']($regOptions['email'])));
543
+	if ($smcFunc['db_num_rows']($request) != 0) {
544
+			$reg_errors[] = array('lang', 'email_in_use', false, array($smcFunc['htmlspecialchars']($regOptions['email'])));
545
+	}
528 546
 
529 547
 	$smcFunc['db_free_result']($request);
530 548
 
@@ -539,24 +557,27 @@  discard block
 block discarded – undo
539 557
 			1 = The text/index.
540 558
 			2 = Whether to log.
541 559
 			3 = sprintf data if necessary. */
542
-		if ($error[0] == 'lang')
543
-			loadLanguage('Errors');
560
+		if ($error[0] == 'lang') {
561
+					loadLanguage('Errors');
562
+		}
544 563
 		$message = $error[0] == 'lang' ? (empty($error[3]) ? $txt[$error[1]] : vsprintf($txt[$error[1]], $error[3])) : $error[1];
545 564
 
546 565
 		// What to do, what to do, what to do.
547 566
 		if ($return_errors)
548 567
 		{
549
-			if (!empty($error[2]))
550
-				log_error($message, $error[2]);
568
+			if (!empty($error[2])) {
569
+							log_error($message, $error[2]);
570
+			}
551 571
 			$reg_errors[$key] = $message;
572
+		} else {
573
+					fatal_error($message, empty($error[2]) ? false : $error[2]);
552 574
 		}
553
-		else
554
-			fatal_error($message, empty($error[2]) ? false : $error[2]);
555 575
 	}
556 576
 
557 577
 	// If there's any errors left return them at once!
558
-	if (!empty($reg_errors))
559
-		return $reg_errors;
578
+	if (!empty($reg_errors)) {
579
+			return $reg_errors;
580
+	}
560 581
 
561 582
 	$reservedVars = array(
562 583
 		'actual_theme_url',
@@ -578,8 +599,9 @@  discard block
 block discarded – undo
578 599
 	);
579 600
 
580 601
 	// Can't change reserved vars.
581
-	if (isset($regOptions['theme_vars']) && count(array_intersect(array_keys($regOptions['theme_vars']), $reservedVars)) != 0)
582
-		fatal_lang_error('no_theme');
602
+	if (isset($regOptions['theme_vars']) && count(array_intersect(array_keys($regOptions['theme_vars']), $reservedVars)) != 0) {
603
+			fatal_lang_error('no_theme');
604
+	}
583 605
 
584 606
 	// Some of these might be overwritten. (the lower ones that are in the arrays below.)
585 607
 	$regOptions['register_vars'] = array(
@@ -621,14 +643,17 @@  discard block
 block discarded – undo
621 643
 		$regOptions['register_vars']['validation_code'] = '';
622 644
 	}
623 645
 	// Maybe it can be activated right away?
624
-	elseif ($regOptions['require'] == 'nothing')
625
-		$regOptions['register_vars']['is_activated'] = 1;
646
+	elseif ($regOptions['require'] == 'nothing') {
647
+			$regOptions['register_vars']['is_activated'] = 1;
648
+	}
626 649
 	// Maybe it must be activated by email?
627
-	elseif ($regOptions['require'] == 'activation')
628
-		$regOptions['register_vars']['is_activated'] = 0;
650
+	elseif ($regOptions['require'] == 'activation') {
651
+			$regOptions['register_vars']['is_activated'] = 0;
652
+	}
629 653
 	// Otherwise it must be awaiting approval!
630
-	else
631
-		$regOptions['register_vars']['is_activated'] = 3;
654
+	else {
655
+			$regOptions['register_vars']['is_activated'] = 3;
656
+	}
632 657
 
633 658
 	if (isset($regOptions['memberGroup']))
634 659
 	{
@@ -647,24 +672,28 @@  discard block
 block discarded – undo
647 672
 				'is_protected' => 1,
648 673
 			)
649 674
 		);
650
-		while ($row = $smcFunc['db_fetch_assoc']($request))
651
-			$unassignableGroups[] = $row['id_group'];
675
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
676
+					$unassignableGroups[] = $row['id_group'];
677
+		}
652 678
 		$smcFunc['db_free_result']($request);
653 679
 
654
-		if (in_array($regOptions['register_vars']['id_group'], $unassignableGroups))
655
-			$regOptions['register_vars']['id_group'] = 0;
680
+		if (in_array($regOptions['register_vars']['id_group'], $unassignableGroups)) {
681
+					$regOptions['register_vars']['id_group'] = 0;
682
+		}
656 683
 	}
657 684
 
658 685
 	// Integrate optional member settings to be set.
659
-	if (!empty($regOptions['extra_register_vars']))
660
-		foreach ($regOptions['extra_register_vars'] as $var => $value)
686
+	if (!empty($regOptions['extra_register_vars'])) {
687
+			foreach ($regOptions['extra_register_vars'] as $var => $value)
661 688
 			$regOptions['register_vars'][$var] = $value;
689
+	}
662 690
 
663 691
 	// Integrate optional user theme options to be set.
664 692
 	$theme_vars = array();
665
-	if (!empty($regOptions['theme_vars']))
666
-		foreach ($regOptions['theme_vars'] as $var => $value)
693
+	if (!empty($regOptions['theme_vars'])) {
694
+			foreach ($regOptions['theme_vars'] as $var => $value)
667 695
 			$theme_vars[$var] = $value;
696
+	}
668 697
 
669 698
 	// Right, now let's prepare for insertion.
670 699
 	$knownInts = array(
@@ -687,14 +716,15 @@  discard block
 block discarded – undo
687 716
 	foreach ($regOptions['register_vars'] as $var => $val)
688 717
 	{
689 718
 		$type = 'string';
690
-		if (in_array($var, $knownInts))
691
-			$type = 'int';
692
-		elseif (in_array($var, $knownFloats))
693
-			$type = 'float';
694
-		elseif (in_array($var, $knownInets))
695
-			$type = 'inet';
696
-		elseif ($var == 'birthdate')
697
-			$type = 'date';
719
+		if (in_array($var, $knownInts)) {
720
+					$type = 'int';
721
+		} elseif (in_array($var, $knownFloats)) {
722
+					$type = 'float';
723
+		} elseif (in_array($var, $knownInets)) {
724
+					$type = 'inet';
725
+		} elseif ($var == 'birthdate') {
726
+					$type = 'date';
727
+		}
698 728
 
699 729
 		$column_names[$var] = $type;
700 730
 		$values[$var] = $val;
@@ -713,10 +743,11 @@  discard block
 block discarded – undo
713 743
 	call_integration_hook('integrate_post_register', array(&$regOptions, &$theme_vars, &$memberID));
714 744
 
715 745
 	// Update the number of members and latest member's info - and pass the name, but remove the 's.
716
-	if ($regOptions['register_vars']['is_activated'] == 1)
717
-		updateStats('member', $memberID, $regOptions['register_vars']['real_name']);
718
-	else
719
-		updateStats('member');
746
+	if ($regOptions['register_vars']['is_activated'] == 1) {
747
+			updateStats('member', $memberID, $regOptions['register_vars']['real_name']);
748
+	} else {
749
+			updateStats('member');
750
+	}
720 751
 
721 752
 	// If policy require and the user came so far he agreed to this
722 753
 	if (!empty($modSettings['enable_policy_function']))
@@ -729,8 +760,9 @@  discard block
 block discarded – undo
729 760
 	if (!empty($theme_vars))
730 761
 	{
731 762
 		$inserts = array();
732
-		foreach ($theme_vars as $var => $val)
733
-			$inserts[] = array($memberID, $var, $val);
763
+		foreach ($theme_vars as $var => $val) {
764
+					$inserts[] = array($memberID, $var, $val);
765
+		}
734 766
 		$smcFunc['db_insert']('insert',
735 767
 			'{db_prefix}themes',
736 768
 			array('id_member' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'),
@@ -745,10 +777,11 @@  discard block
 block discarded – undo
745 777
 	// Administrative registrations are a bit different...
746 778
 	if ($regOptions['interface'] == 'admin')
747 779
 	{
748
-		if ($regOptions['require'] == 'activation')
749
-			$email_message = 'admin_register_activate';
750
-		elseif (!empty($regOptions['send_welcome_email']))
751
-			$email_message = 'admin_register_immediate';
780
+		if ($regOptions['require'] == 'activation') {
781
+					$email_message = 'admin_register_activate';
782
+		} elseif (!empty($regOptions['send_welcome_email'])) {
783
+					$email_message = 'admin_register_immediate';
784
+		}
752 785
 
753 786
 		if (isset($email_message))
754 787
 		{
@@ -799,16 +832,17 @@  discard block
 block discarded – undo
799 832
 			'FORGOTPASSWORDLINK' => $scripturl . '?action=reminder',
800 833
 		);
801 834
 
802
-		if ($regOptions['require'] == 'activation')
803
-			$replacements += array(
835
+		if ($regOptions['require'] == 'activation') {
836
+					$replacements += array(
804 837
 				'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $memberID . ';code=' . $validation_code,
805 838
 				'ACTIVATIONLINKWITHOUTCODE' => $scripturl . '?action=activate;u=' . $memberID,
806 839
 				'ACTIVATIONCODE' => $validation_code,
807 840
 			);
808
-		else
809
-			$replacements += array(
841
+		} else {
842
+					$replacements += array(
810 843
 				'COPPALINK' => $scripturl . '?action=coppa;u=' . $memberID,
811 844
 			);
845
+		}
812 846
 
813 847
 		$emaildata = loadEmailTemplate('register_' . ($regOptions['require'] == 'activation' ? 'activate' : 'coppa'), $replacements);
814 848
 
@@ -873,39 +907,45 @@  discard block
 block discarded – undo
873 907
 		// Check each name in the list...
874 908
 		foreach ($reservedNames as $reserved)
875 909
 		{
876
-			if ($reserved == '')
877
-				continue;
910
+			if ($reserved == '') {
911
+							continue;
912
+			}
878 913
 
879 914
 			// The admin might've used entities too, level the playing field.
880 915
 			$reservedCheck = preg_replace('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'replaceEntities__callback', $reserved);
881 916
 
882 917
 			// Case sensitive name?
883
-			if (empty($modSettings['reserveCase']))
884
-				$reservedCheck = $smcFunc['strtolower']($reservedCheck);
918
+			if (empty($modSettings['reserveCase'])) {
919
+							$reservedCheck = $smcFunc['strtolower']($reservedCheck);
920
+			}
885 921
 
886 922
 			// If it's not just entire word, check for it in there somewhere...
887
-			if ($checkMe == $reservedCheck || ($smcFunc['strpos']($checkMe, $reservedCheck) !== false && empty($modSettings['reserveWord'])))
888
-				if ($fatal)
923
+			if ($checkMe == $reservedCheck || ($smcFunc['strpos']($checkMe, $reservedCheck) !== false && empty($modSettings['reserveWord']))) {
924
+							if ($fatal)
889 925
 					fatal_lang_error('username_reserved', 'password', array($reserved));
890
-				else
891
-					return true;
926
+			} else {
927
+									return true;
928
+				}
892 929
 		}
893 930
 
894 931
 		$censor_name = $name;
895
-		if (censorText($censor_name) != $name)
896
-			if ($fatal)
932
+		if (censorText($censor_name) != $name) {
933
+					if ($fatal)
897 934
 				fatal_lang_error('name_censored', 'password', array($name));
898
-			else
899
-				return true;
935
+		} else {
936
+							return true;
937
+			}
900 938
 	}
901 939
 
902 940
 	// Characters we just shouldn't allow, regardless.
903
-	foreach (array('*') as $char)
904
-		if (strpos($checkName, $char) !== false)
941
+	foreach (array('*') as $char) {
942
+			if (strpos($checkName, $char) !== false)
905 943
 			if ($fatal)
906 944
 				fatal_lang_error('username_reserved', 'password', array($char));
907
-			else
908
-				return true;
945
+	}
946
+			else {
947
+							return true;
948
+			}
909 949
 
910 950
 	// Get rid of any SQL parts of the reserved name...
911 951
 	$checkName = strtr($name, array('_' => '\\_', '%' => '\\%'));
@@ -987,8 +1027,9 @@  discard block
 block discarded – undo
987 1027
 				'permission' => $permission,
988 1028
 			)
989 1029
 		);
990
-		while ($row = $smcFunc['db_fetch_assoc']($request))
991
-			$member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group'];
1030
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1031
+					$member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group'];
1032
+		}
992 1033
 		$smcFunc['db_free_result']($request);
993 1034
 	}
994 1035
 
@@ -996,9 +1037,9 @@  discard block
 block discarded – undo
996 1037
 	else
997 1038
 	{
998 1039
 		// First get the profile of the given board.
999
-		if (isset($board_info['id']) && $board_info['id'] == $board_id)
1000
-			$profile_id = $board_info['profile'];
1001
-		elseif ($board_id !== 0)
1040
+		if (isset($board_info['id']) && $board_info['id'] == $board_id) {
1041
+					$profile_id = $board_info['profile'];
1042
+		} elseif ($board_id !== 0)
1002 1043
 		{
1003 1044
 			$request = $smcFunc['db_query']('', '
1004 1045
 				SELECT id_profile
@@ -1009,13 +1050,14 @@  discard block
 block discarded – undo
1009 1050
 					'id_board' => $board_id,
1010 1051
 				)
1011 1052
 			);
1012
-			if ($smcFunc['db_num_rows']($request) == 0)
1013
-				fatal_lang_error('no_board');
1053
+			if ($smcFunc['db_num_rows']($request) == 0) {
1054
+							fatal_lang_error('no_board');
1055
+			}
1014 1056
 			list ($profile_id) = $smcFunc['db_fetch_row']($request);
1015 1057
 			$smcFunc['db_free_result']($request);
1058
+		} else {
1059
+					$profile_id = 1;
1016 1060
 		}
1017
-		else
1018
-			$profile_id = 1;
1019 1061
 
1020 1062
 		$request = $smcFunc['db_query']('', '
1021 1063
 			SELECT bp.id_group, bp.add_deny
@@ -1027,8 +1069,9 @@  discard block
 block discarded – undo
1027 1069
 				'permission' => $permission,
1028 1070
 			)
1029 1071
 		);
1030
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1031
-			$member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group'];
1072
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1073
+					$member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group'];
1074
+		}
1032 1075
 		$smcFunc['db_free_result']($request);
1033 1076
 
1034 1077
 		$moderator_groups = array();
@@ -1037,8 +1080,7 @@  discard block
 block discarded – undo
1037 1080
 		if (isset($board_info['moderator_groups']))
1038 1081
 		{
1039 1082
 			$moderator_groups = array_keys($board_info['moderator_groups']);
1040
-		}
1041
-		elseif ($board_id !== 0)
1083
+		} elseif ($board_id !== 0)
1042 1084
 		{
1043 1085
 			// Get the groups that can moderate this board
1044 1086
 			$request = $smcFunc['db_query']('', '
@@ -1123,8 +1165,9 @@  discard block
 block discarded – undo
1123 1165
 		)
1124 1166
 	);
1125 1167
 	$members = array();
1126
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1127
-		$members[] = $row['id_member'];
1168
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1169
+			$members[] = $row['id_member'];
1170
+	}
1128 1171
 	$smcFunc['db_free_result']($request);
1129 1172
 
1130 1173
 	return $members;
@@ -1197,10 +1240,12 @@  discard block
 block discarded – undo
1197 1240
 	}
1198 1241
 
1199 1242
 	$query_parts = array();
1200
-	if (!empty($email))
1201
-		$query_parts[] = 'poster_email = {string:email_address}';
1202
-	if (!empty($membername))
1203
-		$query_parts[] = 'poster_name = {string:member_name}';
1243
+	if (!empty($email)) {
1244
+			$query_parts[] = 'poster_email = {string:email_address}';
1245
+	}
1246
+	if (!empty($membername)) {
1247
+			$query_parts[] = 'poster_name = {string:member_name}';
1248
+	}
1204 1249
 	$query = implode(' AND ', $query_parts);
1205 1250
 
1206 1251
 	// Finally, update the posts themselves!
@@ -1267,12 +1312,14 @@  discard block
 block discarded – undo
1267 1312
 
1268 1313
 	$userReceiver = (int) !empty($_REQUEST['u']) ? $_REQUEST['u'] : 0;
1269 1314
 
1270
-	if (empty($userReceiver))
1271
-		fatal_lang_error('no_access', false);
1315
+	if (empty($userReceiver)) {
1316
+			fatal_lang_error('no_access', false);
1317
+	}
1272 1318
 
1273 1319
 	// Remove if it's already there...
1274
-	if (in_array($userReceiver, $user_info['buddies']))
1275
-		$user_info['buddies'] = array_diff($user_info['buddies'], array($userReceiver));
1320
+	if (in_array($userReceiver, $user_info['buddies'])) {
1321
+			$user_info['buddies'] = array_diff($user_info['buddies'], array($userReceiver));
1322
+	}
1276 1323
 
1277 1324
 	// ...or add if it's not and if it's not you.
1278 1325
 	elseif ($user_info['id'] != $userReceiver)
@@ -1347,8 +1394,9 @@  discard block
 block discarded – undo
1347 1394
 	$smcFunc['db_free_result']($request);
1348 1395
 
1349 1396
 	// If we want duplicates pass the members array off.
1350
-	if ($get_duplicates)
1351
-		populateDuplicateMembers($members);
1397
+	if ($get_duplicates) {
1398
+			populateDuplicateMembers($members);
1399
+	}
1352 1400
 
1353 1401
 	return $members;
1354 1402
 }
@@ -1365,8 +1413,9 @@  discard block
 block discarded – undo
1365 1413
 	global $smcFunc, $modSettings;
1366 1414
 
1367 1415
 	// We know how many members there are in total.
1368
-	if (empty($where) || $where == '1=1')
1369
-		$num_members = $modSettings['totalMembers'];
1416
+	if (empty($where) || $where == '1=1') {
1417
+			$num_members = $modSettings['totalMembers'];
1418
+	}
1370 1419
 
1371 1420
 	// The database knows the amount when there are extra conditions.
1372 1421
 	else
@@ -1402,16 +1451,19 @@  discard block
 block discarded – undo
1402 1451
 		$members[$key]['duplicate_members'] = array();
1403 1452
 
1404 1453
 		// Store the IPs.
1405
-		if (!empty($member['member_ip']))
1406
-			$ips[] = $member['member_ip'];
1407
-		if (!empty($member['member_ip2']))
1408
-			$ips[] = $member['member_ip2'];
1454
+		if (!empty($member['member_ip'])) {
1455
+					$ips[] = $member['member_ip'];
1456
+		}
1457
+		if (!empty($member['member_ip2'])) {
1458
+					$ips[] = $member['member_ip2'];
1459
+		}
1409 1460
 	}
1410 1461
 
1411 1462
 	$ips = array_unique($ips);
1412 1463
 
1413
-	if (empty($ips))
1414
-		return false;
1464
+	if (empty($ips)) {
1465
+			return false;
1466
+	}
1415 1467
 
1416 1468
 	// Fetch all members with this IP address, we'll filter out the current ones in a sec.
1417 1469
 	$request = $smcFunc['db_query']('', '
@@ -1441,10 +1493,12 @@  discard block
 block discarded – undo
1441 1493
 			'ip2' => $row['member_ip2'],
1442 1494
 		);
1443 1495
 
1444
-		if (in_array($row['member_ip'], $ips))
1445
-			$duplicate_members[$row['member_ip']][] = $member_context;
1446
-		if ($row['member_ip'] != $row['member_ip2'] && in_array($row['member_ip2'], $ips))
1447
-			$duplicate_members[$row['member_ip2']][] = $member_context;
1496
+		if (in_array($row['member_ip'], $ips)) {
1497
+					$duplicate_members[$row['member_ip']][] = $member_context;
1498
+		}
1499
+		if ($row['member_ip'] != $row['member_ip2'] && in_array($row['member_ip2'], $ips)) {
1500
+					$duplicate_members[$row['member_ip2']][] = $member_context;
1501
+		}
1448 1502
 	}
1449 1503
 	$smcFunc['db_free_result']($request);
1450 1504
 
@@ -1469,8 +1523,9 @@  discard block
 block discarded – undo
1469 1523
 		$row['poster_ip'] = inet_dtop($row['poster_ip']);
1470 1524
 
1471 1525
 		// Don't collect lots of the same.
1472
-		if (isset($had_ips[$row['poster_ip']]) && in_array($row['id_member'], $had_ips[$row['poster_ip']]))
1473
-			continue;
1526
+		if (isset($had_ips[$row['poster_ip']]) && in_array($row['id_member'], $had_ips[$row['poster_ip']])) {
1527
+					continue;
1528
+		}
1474 1529
 		$had_ips[$row['poster_ip']][] = $row['id_member'];
1475 1530
 
1476 1531
 		$duplicate_members[$row['poster_ip']][] = array(
@@ -1485,13 +1540,15 @@  discard block
 block discarded – undo
1485 1540
 	$smcFunc['db_free_result']($request);
1486 1541
 
1487 1542
 	// Now we have all the duplicate members, stick them with their respective member in the list.
1488
-	if (!empty($duplicate_members))
1489
-		foreach ($members as $key => $member)
1543
+	if (!empty($duplicate_members)) {
1544
+			foreach ($members as $key => $member)
1490 1545
 		{
1491 1546
 			if (isset($duplicate_members[$member['member_ip']]))
1492 1547
 				$members[$key]['duplicate_members'] = $duplicate_members[$member['member_ip']];
1493
-			if ($member['member_ip'] != $member['member_ip2'] && isset($duplicate_members[$member['member_ip2']]))
1494
-				$members[$key]['duplicate_members'] = array_merge($member['duplicate_members'], $duplicate_members[$member['member_ip2']]);
1548
+	}
1549
+			if ($member['member_ip'] != $member['member_ip2'] && isset($duplicate_members[$member['member_ip2']])) {
1550
+							$members[$key]['duplicate_members'] = array_merge($member['duplicate_members'], $duplicate_members[$member['member_ip2']]);
1551
+			}
1495 1552
 
1496 1553
 			// Check we don't have lots of the same member.
1497 1554
 			$member_track = array($member['id_member']);
Please login to merge, or discard this patch.
Themes/default/Register.template.php 1 patch
Braces   +90 added lines, -65 removed lines patch added patch discarded remove patch
@@ -28,14 +28,15 @@  discard block
 block discarded – undo
28 28
 			<div id="confirm_buttons">';
29 29
 
30 30
 	// Age restriction in effect?
31
-	if ($context['show_coppa'])
32
-		echo '
31
+	if ($context['show_coppa']) {
32
+			echo '
33 33
 				<input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br>
34 34
 				<br>
35 35
 				<input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">';
36
-	else
37
-		echo '
36
+	} else {
37
+			echo '
38 38
 				<input type="submit" name="accept_agreement" value="', $txt['policy_agree'], '" class="button">';
39
+	}
39 40
 
40 41
 	echo '
41 42
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -108,9 +109,10 @@  discard block
 block discarded – undo
108 109
 			<ul>';
109 110
 
110 111
 		// Cycle through each error and display an error message.
111
-		foreach ($context['registration_errors'] as $error)
112
-			echo '
112
+		foreach ($context['registration_errors'] as $error) {
113
+					echo '
113 114
 				<li>', $error, '</li>';
115
+		}
114 116
 
115 117
 		echo '
116 118
 			</ul>
@@ -179,14 +181,15 @@  discard block
 block discarded – undo
179 181
 		echo '
180 182
 					<dl class="register_form">';
181 183
 
182
-		foreach ($context['custom_fields'] as $field)
183
-			if ($field['show_reg'] > 1)
184
+		foreach ($context['custom_fields'] as $field) {
185
+					if ($field['show_reg'] > 1)
184 186
 				echo '
185 187
 						<dt>
186 188
 							<strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong>
187 189
 							<span class="smalltext">', $field['desc'], '</span>
188 190
 						</dt>
189 191
 						<dd>', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), '</dd>';
192
+		}
190 193
 
191 194
 		echo '
192 195
 					</dl>';
@@ -197,14 +200,15 @@  discard block
 block discarded – undo
197 200
 			</div><!-- .roundframe -->';
198 201
 
199 202
 	// If we have either of these, show the extra group.
200
-	if (!empty($context['profile_fields']) || !empty($context['custom_fields']))
201
-		echo '
203
+	if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) {
204
+			echo '
202 205
 			<div class="title_bar">
203 206
 				<h3 class="titlebg">', $txt['additional_information'], '</h3>
204 207
 			</div>
205 208
 			<div class="roundframe noup">
206 209
 				<fieldset>
207 210
 					<dl class="register_form" id="custom_group">';
211
+	}
208 212
 
209 213
 	if (!empty($context['profile_fields']))
210 214
 	{
@@ -218,41 +222,45 @@  discard block
 block discarded – undo
218 222
 					$callback_func = 'template_profile_' . $field['callback_func'];
219 223
 					$callback_func();
220 224
 				}
221
-			}
222
-			else
225
+			} else
223 226
 			{
224 227
 				echo '
225 228
 						<dt>
226 229
 							<strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['label'], ':</strong>';
227 230
 
228 231
 				// Does it have any subtext to show?
229
-				if (!empty($field['subtext']))
230
-					echo '
232
+				if (!empty($field['subtext'])) {
233
+									echo '
231 234
 							<span class="smalltext">', $field['subtext'], '</span>';
235
+				}
232 236
 
233 237
 				echo '
234 238
 						</dt>
235 239
 						<dd>';
236 240
 
237 241
 				// Want to put something infront of the box?
238
-				if (!empty($field['preinput']))
239
-					echo '
242
+				if (!empty($field['preinput'])) {
243
+									echo '
240 244
 							', $field['preinput'];
245
+				}
241 246
 
242 247
 				// What type of data are we showing?
243
-				if ($field['type'] == 'label')
244
-					echo '
248
+				if ($field['type'] == 'label') {
249
+									echo '
245 250
 							', $field['value'];
251
+				}
246 252
 
247 253
 				// Maybe it's a text box - very likely!
248
-				elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'url')))
249
-					echo '
254
+				elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'url'))) {
255
+									echo '
250 256
 							<input type="', $field['type'] == 'password' ? 'password' : 'text', '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>';
257
+				}
251 258
 
252 259
 				// You "checking" me out? ;)
253
-				elseif ($field['type'] == 'check')
254
-					echo '
260
+				elseif ($field['type'] == 'check') {
261
+									echo '
255 262
 							<input type="hidden" name="', $key, '" value="0"><input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>';
263
+				}
256 264
 
257 265
 				// Always fun - select boxes!
258 266
 				elseif ($field['type'] == 'select')
@@ -263,14 +271,16 @@  discard block
 block discarded – undo
263 271
 					if (isset($field['options']))
264 272
 					{
265 273
 						// Is this some code to generate the options?
266
-						if (!is_array($field['options']))
267
-							$field['options'] = eval($field['options']);
274
+						if (!is_array($field['options'])) {
275
+													$field['options'] = eval($field['options']);
276
+						}
268 277
 
269 278
 						// Assuming we now have some!
270
-						if (is_array($field['options']))
271
-							foreach ($field['options'] as $value => $name)
279
+						if (is_array($field['options'])) {
280
+													foreach ($field['options'] as $value => $name)
272 281
 								echo '
273 282
 								<option', is_numeric($value) ? ' value="" disabled' : ' value="' . $value . '"', $value === $field['value'] ? ' selected' : '', '>', $name, '</option>';
283
+						}
274 284
 					}
275 285
 
276 286
 					echo '
@@ -278,9 +288,10 @@  discard block
 block discarded – undo
278 288
 				}
279 289
 
280 290
 				// Something to end with?
281
-				if (!empty($field['postinput']))
282
-					echo '
291
+				if (!empty($field['postinput'])) {
292
+									echo '
283 293
 							', $field['postinput'];
294
+				}
284 295
 
285 296
 				echo '
286 297
 						</dd>';
@@ -291,25 +302,27 @@  discard block
 block discarded – undo
291 302
 	// Are there any custom fields?
292 303
 	if (!empty($context['custom_fields']))
293 304
 	{
294
-		foreach ($context['custom_fields'] as $field)
295
-			if ($field['show_reg'] < 2)
305
+		foreach ($context['custom_fields'] as $field) {
306
+					if ($field['show_reg'] < 2)
296 307
 				echo '
297 308
 						<dt>
298 309
 							<strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong>
299 310
 							<span class="smalltext">', $field['desc'], '</span>
300 311
 						</dt>
301 312
 						<dd>', $field['input_html'], '</dd>';
313
+		}
302 314
 	}
303 315
 
304 316
 	// If we have either of these, close the list like a proper gent.
305
-	if (!empty($context['profile_fields']) || !empty($context['custom_fields']))
306
-		echo '
317
+	if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) {
318
+			echo '
307 319
 					</dl>
308 320
 				</fieldset>
309 321
 			</div><!-- .roundframe -->';
322
+	}
310 323
 
311
-	if ($context['visual_verification'])
312
-		echo '
324
+	if ($context['visual_verification']) {
325
+			echo '
313 326
 			<div class="title_bar">
314 327
 				<h3 class="titlebg">', $txt['verification'], '</h3>
315 328
 			</div>
@@ -318,19 +331,21 @@  discard block
 block discarded – undo
318 331
 					', template_control_verification($context['visual_verification_id'], 'all'), '
319 332
 				</fieldset>
320 333
 			</div>';
334
+	}
321 335
 
322 336
 	echo '
323 337
 			<div id="confirm_buttons" class="flow_auto">';
324 338
 
325 339
 	// Age restriction in effect?
326
-	if (!$context['require_agreement'] && $context['show_coppa'])
327
-		echo '
340
+	if (!$context['require_agreement'] && $context['show_coppa']) {
341
+			echo '
328 342
 				<input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br>
329 343
 				<br>
330 344
 				<input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">';
331
-	else
332
-		echo '
345
+	} else {
346
+			echo '
333 347
 				<input type="submit" name="regSubmit" value="', $txt['register'], '" tabindex="', $context['tabindex']++, '" class="button">';
348
+	}
334 349
 
335 350
 	echo '
336 351
 			</div>
@@ -392,25 +407,28 @@  discard block
 block discarded – undo
392 407
 				<p>', $context['coppa']['many_options'] ? $txt['coppa_send_to_two_options'] : $txt['coppa_send_to_one_option'], '</p>';
393 408
 
394 409
 	// Can they send by post?
395
-	if (!empty($context['coppa']['post']))
396
-		echo '
410
+	if (!empty($context['coppa']['post'])) {
411
+			echo '
397 412
 				<h4>1) ', $txt['coppa_send_by_post'], '</h4>
398 413
 				<div class="coppa_contact">
399 414
 					', $context['coppa']['post'], '
400 415
 				</div>';
416
+	}
401 417
 
402 418
 	// Can they send by fax??
403
-	if (!empty($context['coppa']['fax']))
404
-		echo '
419
+	if (!empty($context['coppa']['fax'])) {
420
+			echo '
405 421
 				<h4>', !empty($context['coppa']['post']) ? '2' : '1', ') ', $txt['coppa_send_by_fax'], '</h4>
406 422
 				<div class="coppa_contact">
407 423
 					', $context['coppa']['fax'], '
408 424
 				</div>';
425
+	}
409 426
 
410 427
 	// Offer an alternative Phone Number?
411
-	if ($context['coppa']['phone'])
412
-		echo '
428
+	if ($context['coppa']['phone']) {
429
+			echo '
413 430
 				<p>', $context['coppa']['phone'], '</p>';
431
+	}
414 432
 
415 433
 	echo '
416 434
 			</div><!-- #coppa -->';
@@ -475,19 +493,20 @@  discard block
 block discarded – undo
475 493
 	<body style="margin: 1ex;">
476 494
 		<div class="windowbg description" style="text-align: center;">';
477 495
 
478
-	if (isBrowser('is_ie') || isBrowser('is_ie11'))
479
-		echo '
496
+	if (isBrowser('is_ie') || isBrowser('is_ie11')) {
497
+			echo '
480 498
 			<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" type="audio/x-wav">
481 499
 				<param name="AutoStart" value="1">
482 500
 				<param name="FileName" value="', $context['verification_sound_href'], '">
483 501
 			</object>';
484
-	else
485
-		echo '
502
+	} else {
503
+			echo '
486 504
 			<audio src="', $context['verification_sound_href'], '" controls>
487 505
 				<object type="audio/x-wav" data="', $context['verification_sound_href'], '">
488 506
 					<a href="', $context['verification_sound_href'], '" rel="nofollow">', $context['verification_sound_href'], '</a>
489 507
 				</object>
490 508
 			</audio>';
509
+	}
491 510
 
492 511
 	echo '
493 512
 			<br>
@@ -515,11 +534,12 @@  discard block
 block discarded – undo
515 534
 				</div>
516 535
 				<div id="register_screen" class="windowbg">';
517 536
 
518
-	if (!empty($context['registration_done']))
519
-		echo '
537
+	if (!empty($context['registration_done'])) {
538
+			echo '
520 539
 					<div class="infobox">
521 540
 						', $context['registration_done'], '
522 541
 					</div>';
542
+	}
523 543
 
524 544
 	echo '
525 545
 					<dl class="register_form" id="admin_register_form">
@@ -555,9 +575,10 @@  discard block
 block discarded – undo
555 575
 						<dd>
556 576
 							<select name="group" id="group_select" tabindex="', $context['tabindex']++, '">';
557 577
 
558
-		foreach ($context['member_groups'] as $id => $name)
559
-			echo '
578
+		foreach ($context['member_groups'] as $id => $name) {
579
+					echo '
560 580
 								<option value="', $id, '">', $name, '</option>';
581
+		}
561 582
 
562 583
 		echo '
563 584
 							</select>
@@ -565,8 +586,8 @@  discard block
 block discarded – undo
565 586
 	}
566 587
 
567 588
 	// If there is any field marked as required, show it here!
568
-	if (!empty($context['custom_fields_required']) && !empty($context['custom_fields']))
569
-		foreach ($context['custom_fields'] as $field)
589
+	if (!empty($context['custom_fields_required']) && !empty($context['custom_fields'])) {
590
+			foreach ($context['custom_fields'] as $field)
570 591
 			if ($field['show_reg'] > 1)
571 592
 				echo '
572 593
 						<dt>
@@ -576,6 +597,7 @@  discard block
 block discarded – undo
576 597
 						<dd>
577 598
 							', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), '
578 599
 						</dd>';
600
+	}
579 601
 
580 602
 	echo '
581 603
 						<dt>
@@ -612,18 +634,19 @@  discard block
 block discarded – undo
612 634
 {
613 635
 	global $context, $scripturl, $txt;
614 636
 
615
-	if (!empty($context['saved_successful']))
616
-		echo '
637
+	if (!empty($context['saved_successful'])) {
638
+			echo '
617 639
 		<div class="infobox">', $txt['settings_saved'], '</div>';
618
-
619
-	elseif (!empty($context['could_not_save']))
620
-		echo '
640
+	} elseif (!empty($context['could_not_save'])) {
641
+			echo '
621 642
 		<div class="errorbox">', $txt['admin_agreement_not_saved'], '</div>';
643
+	}
622 644
 
623 645
 	// Warning for if the file isn't writable.
624
-	if (!empty($context['warning']))
625
-		echo '
646
+	if (!empty($context['warning'])) {
647
+			echo '
626 648
 		<div class="errorbox">', $context['warning'], '</div>';
649
+	}
627 650
 
628 651
 	// Just a big box to edit the text file ;)
629 652
 	echo '
@@ -645,9 +668,10 @@  discard block
 block discarded – undo
645 668
 						<strong>', $txt['admin_agreement_select_language'], ':</strong>
646 669
 						<select name="agree_lang" onchange="document.getElementById(\'change_reg\').submit();" tabindex="', $context['tabindex']++, '">';
647 670
 
648
-		foreach ($context['editable_agreements'] as $file => $name)
649
-			echo '
671
+		foreach ($context['editable_agreements'] as $file => $name) {
672
+					echo '
650 673
 							<option value="', $file, '"', $context['current_agreement'] == $file ? ' selected' : '', '>', $name, '</option>';
674
+		}
651 675
 
652 676
 		echo '
653 677
 						</select>
@@ -687,9 +711,10 @@  discard block
 block discarded – undo
687 711
 {
688 712
 	global $context, $scripturl, $txt;
689 713
 
690
-	if (!empty($context['saved_successful']))
691
-		echo '
714
+	if (!empty($context['saved_successful'])) {
715
+			echo '
692 716
 	<div class="infobox">', $txt['settings_saved'], '</div>';
717
+	}
693 718
 
694 719
 	echo '
695 720
 	<form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=regcenter" method="post" accept-charset="', $context['character_set'], '">
Please login to merge, or discard this patch.