Completed
Push — release-2.1 ( 95a5a1...719065 )
by Jeremy
18s
created
Sources/Profile-Modify.php 1 patch
Braces   +710 added lines, -533 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
  * This defines every profile field known to man.
@@ -29,8 +30,9 @@  discard block
 block discarded – undo
29 30
 	global $sourcedir, $profile_vars;
30 31
 
31 32
 	// Don't load this twice!
32
-	if (!empty($profile_fields) && !$force_reload)
33
-		return;
33
+	if (!empty($profile_fields) && !$force_reload) {
34
+			return;
35
+	}
34 36
 
35 37
 	/* This horrific array defines all the profile fields in the whole world!
36 38
 		In general each "field" has one array - the key of which is the database column name associated with said field. Each item
@@ -103,13 +105,14 @@  discard block
 block discarded – undo
103 105
 				if (isset($_POST['bday2'], $_POST['bday3']) && $value > 0 && $_POST['bday2'] > 0)
104 106
 				{
105 107
 					// Set to blank?
106
-					if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1)
107
-						$value = '1004-01-01';
108
-					else
109
-						$value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01';
108
+					if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) {
109
+											$value = '1004-01-01';
110
+					} else {
111
+											$value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01';
112
+					}
113
+				} else {
114
+									$value = '1004-01-01';
110 115
 				}
111
-				else
112
-					$value = '1004-01-01';
113 116
 
114 117
 				$profile_vars['birthdate'] = $value;
115 118
 				$cur_profile['birthdate'] = $value;
@@ -127,8 +130,7 @@  discard block
 block discarded – undo
127 130
 				{
128 131
 					$value = checkdate($dates[2], $dates[3], $dates[1] < 4 ? 4 : $dates[1]) ? sprintf('%04d-%02d-%02d', $dates[1] < 4 ? 4 : $dates[1], $dates[2], $dates[3]) : '1004-01-01';
129 132
 					return true;
130
-				}
131
-				else
133
+				} else
132 134
 				{
133 135
 					$value = empty($cur_profile['birthdate']) ? '1004-01-01' : $cur_profile['birthdate'];
134 136
 					return false;
@@ -150,10 +152,11 @@  discard block
 block discarded – undo
150 152
 					return $txt['invalid_registration'] . ' ' . strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%H:%M:%S'), forum_time(false));
151 153
 				}
152 154
 				// As long as it doesn't equal "N/A"...
153
-				elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600)))
154
-					$value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
155
-				else
156
-					$value = $cur_profile['date_registered'];
155
+				elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) {
156
+									$value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
157
+				} else {
158
+									$value = $cur_profile['date_registered'];
159
+				}
157 160
 
158 161
 				return true;
159 162
 			},
@@ -177,8 +180,9 @@  discard block
 block discarded – undo
177 180
 			{
178 181
 				global $context, $old_profile, $profile_vars, $sourcedir, $modSettings;
179 182
 
180
-				if (strtolower($value) == strtolower($old_profile['email_address']))
181
-					return false;
183
+				if (strtolower($value) == strtolower($old_profile['email_address'])) {
184
+									return false;
185
+				}
182 186
 
183 187
 				$isValid = profileValidateEmail($value, $context['id_member']);
184 188
 
@@ -254,11 +258,11 @@  discard block
 block discarded – undo
254 258
 
255 259
 				if (isset($context['profile_languages'][$value]))
256 260
 				{
257
-					if ($context['user']['is_owner'] && empty($context['password_auth_failed']))
258
-						$_SESSION['language'] = $value;
261
+					if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) {
262
+											$_SESSION['language'] = $value;
263
+					}
259 264
 					return true;
260
-				}
261
-				else
265
+				} else
262 266
 				{
263 267
 					$value = $cur_profile['lngfile'];
264 268
 					return false;
@@ -282,13 +286,14 @@  discard block
 block discarded – undo
282 286
 
283 287
 					// Maybe they are trying to change their password as well?
284 288
 					$resetPassword = true;
285
-					if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null)
286
-						$resetPassword = false;
289
+					if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) {
290
+											$resetPassword = false;
291
+					}
287 292
 
288 293
 					// Do the reset... this will send them an email too.
289
-					if ($resetPassword)
290
-						resetPassword($context['id_member'], $value);
291
-					elseif ($value !== null)
294
+					if ($resetPassword) {
295
+											resetPassword($context['id_member'], $value);
296
+					} elseif ($value !== null)
292 297
 					{
293 298
 						validateUsername($context['id_member'], 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' : ''), ' ', $value)));
294 299
 						updateMemberData($context['id_member'], array('member_name' => $value));
@@ -312,20 +317,23 @@  discard block
 block discarded – undo
312 317
 			'input_validate' => function(&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile)
313 318
 			{
314 319
 				// If we didn't try it then ignore it!
315
-				if ($value == '')
316
-					return false;
320
+				if ($value == '') {
321
+									return false;
322
+				}
317 323
 
318 324
 				// Do the two entries for the password even match?
319
-				if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2'])
320
-					return 'bad_new_password';
325
+				if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) {
326
+									return 'bad_new_password';
327
+				}
321 328
 
322 329
 				// Let's get the validation function into play...
323 330
 				require_once($sourcedir . '/Subs-Auth.php');
324 331
 				$passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email']));
325 332
 
326 333
 				// Were there errors?
327
-				if ($passwordErrors != null)
328
-					return 'password_' . $passwordErrors;
334
+				if ($passwordErrors != null) {
335
+									return 'password_' . $passwordErrors;
336
+				}
329 337
 
330 338
 				// Set up the new password variable... ready for storage.
331 339
 				$value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value));
@@ -350,8 +358,9 @@  discard block
 block discarded – undo
350 358
 			'permission' => 'profile_blurb',
351 359
 			'input_validate' => function(&$value) use ($smcFunc)
352 360
 			{
353
-				if ($smcFunc['strlen']($value) > 50)
354
-					return 'personal_text_too_long';
361
+				if ($smcFunc['strlen']($value) > 50) {
362
+									return 'personal_text_too_long';
363
+				}
355 364
 
356 365
 				return true;
357 366
 			},
@@ -386,10 +395,11 @@  discard block
 block discarded – undo
386 395
 			'permission' => 'moderate_forum',
387 396
 			'input_validate' => function(&$value)
388 397
 			{
389
-				if (!is_numeric($value))
390
-					return 'digits_only';
391
-				else
392
-					$value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0;
398
+				if (!is_numeric($value)) {
399
+									return 'digits_only';
400
+				} else {
401
+									$value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0;
402
+				}
393 403
 				return true;
394 404
 			},
395 405
 		),
@@ -405,15 +415,16 @@  discard block
 block discarded – undo
405 415
 			{
406 416
 				$value = 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' : ''), ' ', $value));
407 417
 
408
-				if (trim($value) == '')
409
-					return 'no_name';
410
-				elseif ($smcFunc['strlen']($value) > 60)
411
-					return 'name_too_long';
412
-				elseif ($cur_profile['real_name'] != $value)
418
+				if (trim($value) == '') {
419
+									return 'no_name';
420
+				} elseif ($smcFunc['strlen']($value) > 60) {
421
+									return 'name_too_long';
422
+				} elseif ($cur_profile['real_name'] != $value)
413 423
 				{
414 424
 					require_once($sourcedir . '/Subs-Members.php');
415
-					if (isReservedName($value, $context['id_member']))
416
-						return 'name_taken';
425
+					if (isReservedName($value, $context['id_member'])) {
426
+											return 'name_taken';
427
+					}
417 428
 				}
418 429
 				return true;
419 430
 			},
@@ -471,8 +482,9 @@  discard block
 block discarded – undo
471 482
 						'selected' => $set == $context['member']['smiley_set']['id']
472 483
 					);
473 484
 
474
-					if ($context['smiley_sets'][$i]['selected'])
475
-						$context['member']['smiley_set']['name'] = $set_names[$i];
485
+					if ($context['smiley_sets'][$i]['selected']) {
486
+											$context['member']['smiley_set']['name'] = $set_names[$i];
487
+					}
476 488
 				}
477 489
 				return true;
478 490
 			},
@@ -481,8 +493,9 @@  discard block
 block discarded – undo
481 493
 				global $modSettings;
482 494
 
483 495
 				$smiley_sets = explode(',', $modSettings['smiley_sets_known']);
484
-				if (!in_array($value, $smiley_sets) && $value != 'none')
485
-					$value = '';
496
+				if (!in_array($value, $smiley_sets) && $value != 'none') {
497
+									$value = '';
498
+				}
486 499
 				return true;
487 500
 			},
488 501
 		),
@@ -497,8 +510,9 @@  discard block
 block discarded – undo
497 510
 				loadLanguage('Settings');
498 511
 
499 512
 				$context['allow_no_censored'] = false;
500
-				if ($user_info['is_admin'] || $context['user']['is_owner'])
501
-					$context['allow_no_censored'] = !empty($modSettings['allow_no_censored']);
513
+				if ($user_info['is_admin'] || $context['user']['is_owner']) {
514
+									$context['allow_no_censored'] = !empty($modSettings['allow_no_censored']);
515
+				}
502 516
 
503 517
 				return true;
504 518
 			},
@@ -545,8 +559,9 @@  discard block
 block discarded – undo
545 559
 			'input_validate' => function($value)
546 560
 			{
547 561
 				$tz = smf_list_timezones();
548
-				if (!isset($tz[$value]))
549
-					return 'bad_timezone';
562
+				if (!isset($tz[$value])) {
563
+									return 'bad_timezone';
564
+				}
550 565
 
551 566
 				return true;
552 567
 			},
@@ -561,8 +576,9 @@  discard block
 block discarded – undo
561 576
 			'enabled' => !empty($modSettings['titlesEnable']),
562 577
 			'input_validate' => function(&$value) use ($smcFunc)
563 578
 			{
564
-				if ($smcFunc['strlen']($value) > 50)
565
-					return 'user_title_too_long';
579
+				if ($smcFunc['strlen']($value) > 50) {
580
+									return 'user_title_too_long';
581
+				}
566 582
 
567 583
 				return true;
568 584
 			},
@@ -584,10 +600,12 @@  discard block
 block discarded – undo
584 600
 			// Fix the URL...
585 601
 			'input_validate' => function(&$value)
586 602
 			{
587
-				if (strlen(trim($value)) > 0 && strpos($value, '://') === false)
588
-					$value = 'http://' . $value;
589
-				if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://'))
590
-					$value = '';
603
+				if (strlen(trim($value)) > 0 && strpos($value, '://') === false) {
604
+									$value = 'http://' . $value;
605
+				}
606
+				if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) {
607
+									$value = '';
608
+				}
591 609
 				$value = (string) validate_iri(sanitize_iri($value));
592 610
 				return true;
593 611
 			},
@@ -602,16 +620,19 @@  discard block
 block discarded – undo
602 620
 	foreach ($profile_fields as $key => $field)
603 621
 	{
604 622
 		// Do we have permission to do this?
605
-		if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission']))
606
-			unset($profile_fields[$key]);
623
+		if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) {
624
+					unset($profile_fields[$key]);
625
+		}
607 626
 
608 627
 		// Is it enabled?
609
-		if (isset($field['enabled']) && !$field['enabled'])
610
-			unset($profile_fields[$key]);
628
+		if (isset($field['enabled']) && !$field['enabled']) {
629
+					unset($profile_fields[$key]);
630
+		}
611 631
 
612 632
 		// Is it specifically disabled?
613
-		if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields)))
614
-			unset($profile_fields[$key]);
633
+		if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) {
634
+					unset($profile_fields[$key]);
635
+		}
615 636
 	}
616 637
 }
617 638
 
@@ -636,9 +657,10 @@  discard block
 block discarded – undo
636 657
 	loadProfileFields(true);
637 658
 
638 659
 	// First check for any linked sets.
639
-	foreach ($profile_fields as $key => $field)
640
-		if (isset($field['link_with']) && in_array($field['link_with'], $fields))
660
+	foreach ($profile_fields as $key => $field) {
661
+			if (isset($field['link_with']) && in_array($field['link_with'], $fields))
641 662
 			$fields[] = $key;
663
+	}
642 664
 
643 665
 	$i = 0;
644 666
 	$last_type = '';
@@ -650,38 +672,46 @@  discard block
 block discarded – undo
650 672
 			$cur_field = &$profile_fields[$field];
651 673
 
652 674
 			// Does it have a preload and does that preload succeed?
653
-			if (isset($cur_field['preload']) && !$cur_field['preload']())
654
-				continue;
675
+			if (isset($cur_field['preload']) && !$cur_field['preload']()) {
676
+							continue;
677
+			}
655 678
 
656 679
 			// If this is anything but complex we need to do more cleaning!
657 680
 			if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden')
658 681
 			{
659
-				if (!isset($cur_field['label']))
660
-					$cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field;
682
+				if (!isset($cur_field['label'])) {
683
+									$cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field;
684
+				}
661 685
 
662 686
 				// Everything has a value!
663
-				if (!isset($cur_field['value']))
664
-					$cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : '';
687
+				if (!isset($cur_field['value'])) {
688
+									$cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : '';
689
+				}
665 690
 
666 691
 				// Any input attributes?
667 692
 				$cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : '';
668 693
 			}
669 694
 
670 695
 			// Was there an error with this field on posting?
671
-			if (isset($context['profile_errors'][$field]))
672
-				$cur_field['is_error'] = true;
696
+			if (isset($context['profile_errors'][$field])) {
697
+							$cur_field['is_error'] = true;
698
+			}
673 699
 
674 700
 			// Any javascript stuff?
675
-			if (!empty($cur_field['js_submit']))
676
-				$context['profile_onsubmit_javascript'] .= $cur_field['js_submit'];
677
-			if (!empty($cur_field['js']))
678
-				$context['profile_javascript'] .= $cur_field['js'];
701
+			if (!empty($cur_field['js_submit'])) {
702
+							$context['profile_onsubmit_javascript'] .= $cur_field['js_submit'];
703
+			}
704
+			if (!empty($cur_field['js'])) {
705
+							$context['profile_javascript'] .= $cur_field['js'];
706
+			}
679 707
 
680 708
 			// Any template stuff?
681
-			if (!empty($cur_field['prehtml']))
682
-				$context['profile_prehtml'] .= $cur_field['prehtml'];
683
-			if (!empty($cur_field['posthtml']))
684
-				$context['profile_posthtml'] .= $cur_field['posthtml'];
709
+			if (!empty($cur_field['prehtml'])) {
710
+							$context['profile_prehtml'] .= $cur_field['prehtml'];
711
+			}
712
+			if (!empty($cur_field['posthtml'])) {
713
+							$context['profile_posthtml'] .= $cur_field['posthtml'];
714
+			}
685 715
 
686 716
 			// Finally put it into context?
687 717
 			if ($cur_field['type'] != 'hidden')
@@ -714,12 +744,14 @@  discard block
 block discarded – undo
714 744
 	}, false);' : ''), true);
715 745
 
716 746
 	// Any onsubmit javascript?
717
-	if (!empty($context['profile_onsubmit_javascript']))
718
-		addInlineJavaScript($context['profile_onsubmit_javascript'], true);
747
+	if (!empty($context['profile_onsubmit_javascript'])) {
748
+			addInlineJavaScript($context['profile_onsubmit_javascript'], true);
749
+	}
719 750
 
720 751
 	// Any totally custom stuff?
721
-	if (!empty($context['profile_javascript']))
722
-		addInlineJavaScript($context['profile_javascript'], true);
752
+	if (!empty($context['profile_javascript'])) {
753
+			addInlineJavaScript($context['profile_javascript'], true);
754
+	}
723 755
 
724 756
 	// Free up some memory.
725 757
 	unset($profile_fields);
@@ -740,8 +772,9 @@  discard block
 block discarded – undo
740 772
 
741 773
 	// This allows variables to call activities when they save - by default just to reload their settings
742 774
 	$context['profile_execute_on_save'] = array();
743
-	if ($context['user']['is_owner'])
744
-		$context['profile_execute_on_save']['reload_user'] = 'profileReloadUser';
775
+	if ($context['user']['is_owner']) {
776
+			$context['profile_execute_on_save']['reload_user'] = 'profileReloadUser';
777
+	}
745 778
 
746 779
 	// Assume we log nothing.
747 780
 	$context['log_changes'] = array();
@@ -749,8 +782,9 @@  discard block
 block discarded – undo
749 782
 	// Cycle through the profile fields working out what to do!
750 783
 	foreach ($profile_fields as $key => $field)
751 784
 	{
752
-		if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature'))
753
-			continue;
785
+		if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) {
786
+					continue;
787
+		}
754 788
 
755 789
 		// What gets updated?
756 790
 		$db_key = isset($field['save_key']) ? $field['save_key'] : $key;
@@ -778,12 +812,13 @@  discard block
 block discarded – undo
778 812
 		$field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type'];
779 813
 
780 814
 		// Finally, clean up certain types.
781
-		if ($field['cast_type'] == 'int')
782
-			$_POST[$key] = (int) $_POST[$key];
783
-		elseif ($field['cast_type'] == 'float')
784
-			$_POST[$key] = (float) $_POST[$key];
785
-		elseif ($field['cast_type'] == 'check')
786
-			$_POST[$key] = !empty($_POST[$key]) ? 1 : 0;
815
+		if ($field['cast_type'] == 'int') {
816
+					$_POST[$key] = (int) $_POST[$key];
817
+		} elseif ($field['cast_type'] == 'float') {
818
+					$_POST[$key] = (float) $_POST[$key];
819
+		} elseif ($field['cast_type'] == 'check') {
820
+					$_POST[$key] = !empty($_POST[$key]) ? 1 : 0;
821
+		}
787 822
 
788 823
 		// If we got here we're doing OK.
789 824
 		if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key]))
@@ -794,11 +829,12 @@  discard block
 block discarded – undo
794 829
 			$cur_profile[$key] = $_POST[$key];
795 830
 
796 831
 			// Are we logging it?
797
-			if (!empty($field['log_change']) && isset($old_profile[$key]))
798
-				$context['log_changes'][$key] = array(
832
+			if (!empty($field['log_change']) && isset($old_profile[$key])) {
833
+							$context['log_changes'][$key] = array(
799 834
 					'previous' => $old_profile[$key],
800 835
 					'new' => $_POST[$key],
801 836
 				);
837
+			}
802 838
 		}
803 839
 
804 840
 		// Logging group changes are a bit different...
@@ -831,10 +867,11 @@  discard block
 block discarded – undo
831 867
 				{
832 868
 					foreach ($groups as $id => $group)
833 869
 					{
834
-						if (isset($context['member_groups'][$group]))
835
-							$additional_groups[$type][$id] = $context['member_groups'][$group]['name'];
836
-						else
837
-							unset($additional_groups[$type][$id]);
870
+						if (isset($context['member_groups'][$group])) {
871
+													$additional_groups[$type][$id] = $context['member_groups'][$group]['name'];
872
+						} else {
873
+													unset($additional_groups[$type][$id]);
874
+						}
838 875
 					}
839 876
 					$additional_groups[$type] = implode(', ', $additional_groups[$type]);
840 877
 				}
@@ -845,10 +882,11 @@  discard block
 block discarded – undo
845 882
 	}
846 883
 
847 884
 	// @todo Temporary
848
-	if ($context['user']['is_owner'])
849
-		$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own'));
850
-	else
851
-		$changeOther = allowedTo('profile_extra_any');
885
+	if ($context['user']['is_owner']) {
886
+			$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own'));
887
+	} else {
888
+			$changeOther = allowedTo('profile_extra_any');
889
+	}
852 890
 	if ($changeOther && empty($post_errors))
853 891
 	{
854 892
 		makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']);
@@ -856,8 +894,9 @@  discard block
 block discarded – undo
856 894
 		{
857 895
 			$custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true);
858 896
 
859
-			if (!empty($custom_fields_errors))
860
-				$post_errors = array_merge($post_errors, $custom_fields_errors);
897
+			if (!empty($custom_fields_errors)) {
898
+							$post_errors = array_merge($post_errors, $custom_fields_errors);
899
+			}
861 900
 		}
862 901
 	}
863 902
 
@@ -883,9 +922,9 @@  discard block
 block discarded – undo
883 922
 	if ($context['user']['is_owner'])
884 923
 	{
885 924
 		$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own'));
925
+	} else {
926
+			$changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any'));
886 927
 	}
887
-	else
888
-		$changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any'));
889 928
 
890 929
 	// Arrays of all the changes - makes things easier.
891 930
 	$profile_bools = array();
@@ -896,22 +935,25 @@  discard block
 block discarded – undo
896 935
 		'ignore_boards',
897 936
 	);
898 937
 
899
-	if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd']))
900
-		$_POST['ignore_brd'] = array();
938
+	if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) {
939
+			$_POST['ignore_brd'] = array();
940
+	}
901 941
 
902 942
 	unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing.  Kinda like our minds.
903 943
 	if (isset($_POST['ignore_brd']))
904 944
 	{
905
-		if (!is_array($_POST['ignore_brd']))
906
-			$_POST['ignore_brd'] = array($_POST['ignore_brd']);
945
+		if (!is_array($_POST['ignore_brd'])) {
946
+					$_POST['ignore_brd'] = array($_POST['ignore_brd']);
947
+		}
907 948
 
908 949
 		foreach ($_POST['ignore_brd'] as $k => $d)
909 950
 		{
910 951
 			$d = (int) $d;
911
-			if ($d != 0)
912
-				$_POST['ignore_brd'][$k] = $d;
913
-			else
914
-				unset($_POST['ignore_brd'][$k]);
952
+			if ($d != 0) {
953
+							$_POST['ignore_brd'][$k] = $d;
954
+			} else {
955
+							unset($_POST['ignore_brd'][$k]);
956
+			}
915 957
 		}
916 958
 		$_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']);
917 959
 		unset($_POST['ignore_brd']);
@@ -923,21 +965,26 @@  discard block
 block discarded – undo
923 965
 		makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']);
924 966
 		//makeAvatarChanges($memID, $post_errors);
925 967
 
926
-		if (!empty($_REQUEST['sa']))
927
-			makeCustomFieldChanges($memID, $_REQUEST['sa'], false);
968
+		if (!empty($_REQUEST['sa'])) {
969
+					makeCustomFieldChanges($memID, $_REQUEST['sa'], false);
970
+		}
928 971
 
929
-		foreach ($profile_bools as $var)
930
-			if (isset($_POST[$var]))
972
+		foreach ($profile_bools as $var) {
973
+					if (isset($_POST[$var]))
931 974
 				$profile_vars[$var] = empty($_POST[$var]) ? '0' : '1';
932
-		foreach ($profile_ints as $var)
933
-			if (isset($_POST[$var]))
975
+		}
976
+		foreach ($profile_ints as $var) {
977
+					if (isset($_POST[$var]))
934 978
 				$profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : '';
935
-		foreach ($profile_floats as $var)
936
-			if (isset($_POST[$var]))
979
+		}
980
+		foreach ($profile_floats as $var) {
981
+					if (isset($_POST[$var]))
937 982
 				$profile_vars[$var] = (float) $_POST[$var];
938
-		foreach ($profile_strings as $var)
939
-			if (isset($_POST[$var]))
983
+		}
984
+		foreach ($profile_strings as $var) {
985
+					if (isset($_POST[$var]))
940 986
 				$profile_vars[$var] = $_POST[$var];
987
+		}
941 988
 	}
942 989
 }
943 990
 
@@ -971,8 +1018,9 @@  discard block
 block discarded – undo
971 1018
 	);
972 1019
 
973 1020
 	// Can't change reserved vars.
974
-	if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0))
975
-		fatal_lang_error('no_access', false);
1021
+	if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) {
1022
+			fatal_lang_error('no_access', false);
1023
+	}
976 1024
 
977 1025
 	// Don't allow any overriding of custom fields with default or non-default options.
978 1026
 	$request = $smcFunc['db_query']('', '
@@ -984,8 +1032,9 @@  discard block
 block discarded – undo
984 1032
 		)
985 1033
 	);
986 1034
 	$custom_fields = array();
987
-	while ($row = $smcFunc['db_fetch_assoc']($request))
988
-		$custom_fields[] = $row['col_name'];
1035
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1036
+			$custom_fields[] = $row['col_name'];
1037
+	}
989 1038
 	$smcFunc['db_free_result']($request);
990 1039
 
991 1040
 	// These are the theme changes...
@@ -994,33 +1043,39 @@  discard block
 block discarded – undo
994 1043
 	{
995 1044
 		foreach ($_POST['options'] as $opt => $val)
996 1045
 		{
997
-			if (in_array($opt, $custom_fields))
998
-				continue;
1046
+			if (in_array($opt, $custom_fields)) {
1047
+							continue;
1048
+			}
999 1049
 
1000 1050
 			// These need to be controlled.
1001
-			if ($opt == 'topics_per_page' || $opt == 'messages_per_page')
1002
-				$val = max(0, min($val, 50));
1051
+			if ($opt == 'topics_per_page' || $opt == 'messages_per_page') {
1052
+							$val = max(0, min($val, 50));
1053
+			}
1003 1054
 			// We don't set this per theme anymore.
1004
-			elseif ($opt == 'allow_no_censored')
1005
-				continue;
1055
+			elseif ($opt == 'allow_no_censored') {
1056
+							continue;
1057
+			}
1006 1058
 
1007 1059
 			$themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val);
1008 1060
 		}
1009 1061
 	}
1010 1062
 
1011 1063
 	$erase_options = array();
1012
-	if (isset($_POST['default_options']) && is_array($_POST['default_options']))
1013
-		foreach ($_POST['default_options'] as $opt => $val)
1064
+	if (isset($_POST['default_options']) && is_array($_POST['default_options'])) {
1065
+			foreach ($_POST['default_options'] as $opt => $val)
1014 1066
 		{
1015 1067
 			if (in_array($opt, $custom_fields))
1016 1068
 				continue;
1069
+	}
1017 1070
 
1018 1071
 			// These need to be controlled.
1019
-			if ($opt == 'topics_per_page' || $opt == 'messages_per_page')
1020
-				$val = max(0, min($val, 50));
1072
+			if ($opt == 'topics_per_page' || $opt == 'messages_per_page') {
1073
+							$val = max(0, min($val, 50));
1074
+			}
1021 1075
 			// Only let admins and owners change the censor.
1022
-			elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner'])
1023
-					continue;
1076
+			elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) {
1077
+								continue;
1078
+			}
1024 1079
 
1025 1080
 			$themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val);
1026 1081
 			$erase_options[] = $opt;
@@ -1056,8 +1111,9 @@  discard block
 block discarded – undo
1056 1111
 
1057 1112
 		// Admins can choose any theme, even if it's not enabled...
1058 1113
 		$themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']);
1059
-		foreach ($themes as $t)
1060
-			cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60);
1114
+		foreach ($themes as $t) {
1115
+					cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60);
1116
+		}
1061 1117
 	}
1062 1118
 }
1063 1119
 
@@ -1076,8 +1132,9 @@  discard block
 block discarded – undo
1076 1132
 	if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards']))
1077 1133
 	{
1078 1134
 		// Make sure only integers are deleted.
1079
-		foreach ($_POST['notify_boards'] as $index => $id)
1080
-			$_POST['notify_boards'][$index] = (int) $id;
1135
+		foreach ($_POST['notify_boards'] as $index => $id) {
1136
+					$_POST['notify_boards'][$index] = (int) $id;
1137
+		}
1081 1138
 
1082 1139
 		// id_board = 0 is reserved for topic notifications.
1083 1140
 		$_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0));
@@ -1096,8 +1153,9 @@  discard block
 block discarded – undo
1096 1153
 	// We are editing topic notifications......
1097 1154
 	elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics']))
1098 1155
 	{
1099
-		foreach ($_POST['notify_topics'] as $index => $id)
1100
-			$_POST['notify_topics'][$index] = (int) $id;
1156
+		foreach ($_POST['notify_topics'] as $index => $id) {
1157
+					$_POST['notify_topics'][$index] = (int) $id;
1158
+		}
1101 1159
 
1102 1160
 		// Make sure there are no zeros left.
1103 1161
 		$_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0));
@@ -1111,16 +1169,18 @@  discard block
 block discarded – undo
1111 1169
 				'selected_member' => $memID,
1112 1170
 			)
1113 1171
 		);
1114
-		foreach ($_POST['notify_topics'] as $topic)
1115
-			setNotifyPrefs($memID, array('topic_notify_' . $topic => 0));
1172
+		foreach ($_POST['notify_topics'] as $topic) {
1173
+					setNotifyPrefs($memID, array('topic_notify_' . $topic => 0));
1174
+		}
1116 1175
 	}
1117 1176
 
1118 1177
 	// We are removing topic preferences
1119 1178
 	elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics']))
1120 1179
 	{
1121 1180
 		$prefs = array();
1122
-		foreach ($_POST['notify_topics'] as $topic)
1123
-			$prefs[] = 'topic_notify_' . $topic;
1181
+		foreach ($_POST['notify_topics'] as $topic) {
1182
+					$prefs[] = 'topic_notify_' . $topic;
1183
+		}
1124 1184
 		deleteNotifyPrefs($memID, $prefs);
1125 1185
 	}
1126 1186
 
@@ -1128,8 +1188,9 @@  discard block
 block discarded – undo
1128 1188
 	elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards']))
1129 1189
 	{
1130 1190
 		$prefs = array();
1131
-		foreach ($_POST['notify_boards'] as $board)
1132
-			$prefs[] = 'board_notify_' . $board;
1191
+		foreach ($_POST['notify_boards'] as $board) {
1192
+					$prefs[] = 'board_notify_' . $board;
1193
+		}
1133 1194
 		deleteNotifyPrefs($memID, $prefs);
1134 1195
 	}
1135 1196
 }
@@ -1150,8 +1211,9 @@  discard block
 block discarded – undo
1150 1211
 
1151 1212
 	$errors = array();
1152 1213
 
1153
-	if ($sanitize && isset($_POST['customfield']))
1154
-		$_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']);
1214
+	if ($sanitize && isset($_POST['customfield'])) {
1215
+			$_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']);
1216
+	}
1155 1217
 
1156 1218
 	$where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}';
1157 1219
 
@@ -1177,26 +1239,29 @@  discard block
 block discarded – undo
1177 1239
 			- The data is not invisible to users but editable by the owner (or if it is the user is not the owner)
1178 1240
 			- The area isn't registration, and if it is that the field is not supposed to be shown there.
1179 1241
 		*/
1180
-		if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0))
1181
-			continue;
1242
+		if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) {
1243
+					continue;
1244
+		}
1182 1245
 
1183 1246
 		// Validate the user data.
1184
-		if ($row['field_type'] == 'check')
1185
-			$value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0;
1186
-		elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio')
1247
+		if ($row['field_type'] == 'check') {
1248
+					$value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0;
1249
+		} elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio')
1187 1250
 		{
1188 1251
 			$value = $row['default_value'];
1189
-			foreach (explode(',', $row['field_options']) as $k => $v)
1190
-				if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k)
1252
+			foreach (explode(',', $row['field_options']) as $k => $v) {
1253
+							if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k)
1191 1254
 					$value = $v;
1255
+			}
1192 1256
 		}
1193 1257
 		// Otherwise some form of text!
1194 1258
 		else
1195 1259
 		{
1196 1260
 			$value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : '';
1197 1261
 
1198
-			if ($row['field_length'])
1199
-				$value = $smcFunc['substr']($value, 0, $row['field_length']);
1262
+			if ($row['field_length']) {
1263
+							$value = $smcFunc['substr']($value, 0, $row['field_length']);
1264
+			}
1200 1265
 
1201 1266
 			// Any masks?
1202 1267
 			if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none')
@@ -1205,36 +1270,34 @@  discard block
 block discarded – undo
1205 1270
 				$valueReference = un_htmlspecialchars($value);
1206 1271
 
1207 1272
 				// Try and avoid some checks. '0' could be a valid non-empty value.
1208
-				if (empty($value) && !is_numeric($value))
1209
-					$value = '';
1273
+				if (empty($value) && !is_numeric($value)) {
1274
+									$value = '';
1275
+				}
1210 1276
 
1211 1277
 				if ($row['mask'] == 'nohtml' && ($valueReference != strip_tags($valueReference) || $value != filter_var($value, FILTER_SANITIZE_STRING) || preg_match('/<(.+?)[\s]*\/?[\s]*>/si', $valueReference)))
1212 1278
 				{
1213
-					if ($returnErrors)
1214
-						$errors[] = 'custom_field_nohtml_fail';
1215
-
1216
-					else
1217
-						$value = '';
1218
-				}
1219
-				elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255))
1279
+					if ($returnErrors) {
1280
+											$errors[] = 'custom_field_nohtml_fail';
1281
+					} else {
1282
+											$value = '';
1283
+					}
1284
+				} elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255))
1220 1285
 				{
1221
-					if ($returnErrors)
1222
-						$errors[] = 'custom_field_mail_fail';
1223
-
1224
-					else
1225
-						$value = '';
1226
-				}
1227
-				elseif ($row['mask'] == 'number')
1286
+					if ($returnErrors) {
1287
+											$errors[] = 'custom_field_mail_fail';
1288
+					} else {
1289
+											$value = '';
1290
+					}
1291
+				} elseif ($row['mask'] == 'number')
1228 1292
 				{
1229 1293
 					$value = (int) $value;
1230
-				}
1231
-				elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0)
1294
+				} elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0)
1232 1295
 				{
1233
-					if ($returnErrors)
1234
-						$errors[] = 'custom_field_regex_fail';
1235
-
1236
-					else
1237
-						$value = '';
1296
+					if ($returnErrors) {
1297
+											$errors[] = 'custom_field_regex_fail';
1298
+					} else {
1299
+											$value = '';
1300
+					}
1238 1301
 				}
1239 1302
 
1240 1303
 				unset($valueReference);
@@ -1258,8 +1321,7 @@  discard block
 block discarded – undo
1258 1321
 			{
1259 1322
 				$deletes = array('id_theme' => 1 , 'variable' => $row['col_name'], 'id_member' => $memID);
1260 1323
 				unset($user_profile[$memID]['options'][$row['col_name']]);
1261
-			}
1262
-			else
1324
+			} else
1263 1325
 			{
1264 1326
 				$changes[] = array(1, $row['col_name'], $value, $memID);
1265 1327
 				$user_profile[$memID]['options'][$row['col_name']] = $value;
@@ -1270,27 +1332,30 @@  discard block
 block discarded – undo
1270 1332
 
1271 1333
 	$hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize, &$deletes));
1272 1334
 
1273
-	if (!empty($hook_errors) && is_array($hook_errors))
1274
-		$errors = array_merge($errors, $hook_errors);
1335
+	if (!empty($hook_errors) && is_array($hook_errors)) {
1336
+			$errors = array_merge($errors, $hook_errors);
1337
+	}
1275 1338
 
1276 1339
 	// Make those changes!
1277 1340
 	if ((!empty($changes) || !empty($deletes)) && empty($context['password_auth_failed']) && empty($errors))
1278 1341
 	{
1279
-		if (!empty($changes))
1280
-			$smcFunc['db_insert']('replace',
1342
+		if (!empty($changes)) {
1343
+					$smcFunc['db_insert']('replace',
1281 1344
 				'{db_prefix}themes',
1282 1345
 				array('id_theme' => 'int', 'variable' => 'string-255', 'value' => 'string-65534', 'id_member' => 'int'),
1283 1346
 				$changes,
1284 1347
 				array('id_theme', 'variable', 'id_member')
1285 1348
 			);
1286
-		if (!empty($deletes))
1287
-			$smcFunc['db_query']('','
1349
+		}
1350
+		if (!empty($deletes)) {
1351
+					$smcFunc['db_query']('','
1288 1352
 				DELETE FROM {db_prefix}themes
1289 1353
 				WHERE id_theme = {int:id_theme} AND
1290 1354
 						variable = {string:variable} AND
1291 1355
 						id_member = {int:id_member}',
1292 1356
 				$deletes
1293 1357
 				);
1358
+		}
1294 1359
 		if (!empty($log_changes) && !empty($modSettings['modlog_enabled']))
1295 1360
 		{
1296 1361
 			require_once($sourcedir . '/Logging.php');
@@ -1298,9 +1363,10 @@  discard block
 block discarded – undo
1298 1363
 		}
1299 1364
 	}
1300 1365
 
1301
-	if ($returnErrors)
1302
-		return $errors;
1303
-}
1366
+	if ($returnErrors) {
1367
+			return $errors;
1368
+	}
1369
+	}
1304 1370
 
1305 1371
 /**
1306 1372
  * Show all the users buddies, as well as a add/delete interface.
@@ -1312,8 +1378,9 @@  discard block
 block discarded – undo
1312 1378
 	global $context, $txt, $modSettings;
1313 1379
 
1314 1380
 	// Do a quick check to ensure people aren't getting here illegally!
1315
-	if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist']))
1316
-		fatal_lang_error('no_access', false);
1381
+	if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) {
1382
+			fatal_lang_error('no_access', false);
1383
+	}
1317 1384
 
1318 1385
 	// Can we email the user direct?
1319 1386
 	$context['can_moderate_forum'] = allowedTo('moderate_forum');
@@ -1343,9 +1410,10 @@  discard block
 block discarded – undo
1343 1410
 	$context['sub_template'] = $subActions[$context['list_area']][0];
1344 1411
 	$call = call_helper($subActions[$context['list_area']][0], true);
1345 1412
 
1346
-	if (!empty($call))
1347
-		call_user_func($call, $memID);
1348
-}
1413
+	if (!empty($call)) {
1414
+			call_user_func($call, $memID);
1415
+	}
1416
+	}
1349 1417
 
1350 1418
 /**
1351 1419
  * Show all the users buddies, as well as a add/delete interface.
@@ -1359,9 +1427,10 @@  discard block
 block discarded – undo
1359 1427
 
1360 1428
 	// For making changes!
1361 1429
 	$buddiesArray = explode(',', $user_profile[$memID]['buddy_list']);
1362
-	foreach ($buddiesArray as $k => $dummy)
1363
-		if ($dummy == '')
1430
+	foreach ($buddiesArray as $k => $dummy) {
1431
+			if ($dummy == '')
1364 1432
 			unset($buddiesArray[$k]);
1433
+	}
1365 1434
 
1366 1435
 	// Removing a buddy?
1367 1436
 	if (isset($_GET['remove']))
@@ -1373,10 +1442,11 @@  discard block
 block discarded – undo
1373 1442
 		$_SESSION['prf-save'] = $txt['could_not_remove_person'];
1374 1443
 
1375 1444
 		// Heh, I'm lazy, do it the easy way...
1376
-		foreach ($buddiesArray as $key => $buddy)
1377
-			if ($buddy == (int) $_GET['remove'])
1445
+		foreach ($buddiesArray as $key => $buddy) {
1446
+					if ($buddy == (int) $_GET['remove'])
1378 1447
 			{
1379 1448
 				unset($buddiesArray[$key]);
1449
+		}
1380 1450
 				$_SESSION['prf-save'] = true;
1381 1451
 			}
1382 1452
 
@@ -1386,8 +1456,7 @@  discard block
 block discarded – undo
1386 1456
 
1387 1457
 		// Redirect off the page because we don't like all this ugly query stuff to stick in the history.
1388 1458
 		redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID);
1389
-	}
1390
-	elseif (isset($_POST['new_buddy']))
1459
+	} elseif (isset($_POST['new_buddy']))
1391 1460
 	{
1392 1461
 		checkSession();
1393 1462
 
@@ -1400,8 +1469,9 @@  discard block
 block discarded – undo
1400 1469
 		{
1401 1470
 			$new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => '&#039;'));
1402 1471
 
1403
-			if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name'])))
1404
-				unset($new_buddies[$k]);
1472
+			if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) {
1473
+							unset($new_buddies[$k]);
1474
+			}
1405 1475
 		}
1406 1476
 
1407 1477
 		call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies));
@@ -1421,16 +1491,18 @@  discard block
 block discarded – undo
1421 1491
 				)
1422 1492
 			);
1423 1493
 
1424
-			if ($smcFunc['db_num_rows']($request) != 0)
1425
-				$_SESSION['prf-save'] = true;
1494
+			if ($smcFunc['db_num_rows']($request) != 0) {
1495
+							$_SESSION['prf-save'] = true;
1496
+			}
1426 1497
 
1427 1498
 			// Add the new member to the buddies array.
1428 1499
 			while ($row = $smcFunc['db_fetch_assoc']($request))
1429 1500
 			{
1430
-				if (in_array($row['id_member'], $buddiesArray))
1431
-					continue;
1432
-				else
1433
-					$buddiesArray[] = (int) $row['id_member'];
1501
+				if (in_array($row['id_member'], $buddiesArray)) {
1502
+									continue;
1503
+				} else {
1504
+									$buddiesArray[] = (int) $row['id_member'];
1505
+				}
1434 1506
 			}
1435 1507
 			$smcFunc['db_free_result']($request);
1436 1508
 
@@ -1460,18 +1532,20 @@  discard block
 block discarded – undo
1460 1532
 
1461 1533
 	$context['custom_pf'] = array();
1462 1534
 	$disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array();
1463
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1464
-		if (!isset($disabled_fields[$row['col_name']]))
1535
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1536
+			if (!isset($disabled_fields[$row['col_name']]))
1465 1537
 			$context['custom_pf'][$row['col_name']] = array(
1466 1538
 				'label' => $row['field_name'],
1467 1539
 				'type' => $row['field_type'],
1468 1540
 				'bbc' => !empty($row['bbc']),
1469 1541
 				'enclose' => $row['enclose'],
1470 1542
 			);
1543
+	}
1471 1544
 
1472 1545
 	// Gotta disable the gender option.
1473
-	if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'None')
1474
-		unset($context['custom_pf']['cust_gender']);
1546
+	if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'None') {
1547
+			unset($context['custom_pf']['cust_gender']);
1548
+	}
1475 1549
 
1476 1550
 	$smcFunc['db_free_result']($request);
1477 1551
 
@@ -1488,8 +1562,9 @@  discard block
 block discarded – undo
1488 1562
 				'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1,
1489 1563
 			)
1490 1564
 		);
1491
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1492
-			$buddies[] = $row['id_member'];
1565
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1566
+					$buddies[] = $row['id_member'];
1567
+		}
1493 1568
 		$smcFunc['db_free_result']($result);
1494 1569
 	}
1495 1570
 
@@ -1517,30 +1592,32 @@  discard block
 block discarded – undo
1517 1592
 					continue;
1518 1593
 				}
1519 1594
 
1520
-				if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key]))
1521
-					$context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key]));
1522
-
1523
-				elseif ($column['type'] == 'check')
1524
-					$context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes'];
1595
+				if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) {
1596
+									$context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key]));
1597
+				} elseif ($column['type'] == 'check') {
1598
+									$context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes'];
1599
+				}
1525 1600
 
1526 1601
 				// Enclosing the user input within some other text?
1527
-				if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key]))
1528
-					$context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array(
1602
+				if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) {
1603
+									$context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array(
1529 1604
 						'{SCRIPTURL}' => $scripturl,
1530 1605
 						'{IMAGES_URL}' => $settings['images_url'],
1531 1606
 						'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
1532 1607
 						'{INPUT}' => $context['buddies'][$buddy]['options'][$key],
1533 1608
 					));
1609
+				}
1534 1610
 			}
1535 1611
 		}
1536 1612
 	}
1537 1613
 
1538 1614
 	if (isset($_SESSION['prf-save']))
1539 1615
 	{
1540
-		if ($_SESSION['prf-save'] === true)
1541
-			$context['saved_successful'] = true;
1542
-		else
1543
-			$context['saved_failed'] = $_SESSION['prf-save'];
1616
+		if ($_SESSION['prf-save'] === true) {
1617
+					$context['saved_successful'] = true;
1618
+		} else {
1619
+					$context['saved_failed'] = $_SESSION['prf-save'];
1620
+		}
1544 1621
 
1545 1622
 		unset($_SESSION['prf-save']);
1546 1623
 	}
@@ -1560,9 +1637,10 @@  discard block
 block discarded – undo
1560 1637
 
1561 1638
 	// For making changes!
1562 1639
 	$ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']);
1563
-	foreach ($ignoreArray as $k => $dummy)
1564
-		if ($dummy == '')
1640
+	foreach ($ignoreArray as $k => $dummy) {
1641
+			if ($dummy == '')
1565 1642
 			unset($ignoreArray[$k]);
1643
+	}
1566 1644
 
1567 1645
 	// Removing a member from the ignore list?
1568 1646
 	if (isset($_GET['remove']))
@@ -1572,10 +1650,11 @@  discard block
 block discarded – undo
1572 1650
 		$_SESSION['prf-save'] = $txt['could_not_remove_person'];
1573 1651
 
1574 1652
 		// Heh, I'm lazy, do it the easy way...
1575
-		foreach ($ignoreArray as $key => $id_remove)
1576
-			if ($id_remove == (int) $_GET['remove'])
1653
+		foreach ($ignoreArray as $key => $id_remove) {
1654
+					if ($id_remove == (int) $_GET['remove'])
1577 1655
 			{
1578 1656
 				unset($ignoreArray[$key]);
1657
+		}
1579 1658
 				$_SESSION['prf-save'] = true;
1580 1659
 			}
1581 1660
 
@@ -1585,8 +1664,7 @@  discard block
 block discarded – undo
1585 1664
 
1586 1665
 		// Redirect off the page because we don't like all this ugly query stuff to stick in the history.
1587 1666
 		redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID);
1588
-	}
1589
-	elseif (isset($_POST['new_ignore']))
1667
+	} elseif (isset($_POST['new_ignore']))
1590 1668
 	{
1591 1669
 		checkSession();
1592 1670
 		// Prepare the string for extraction...
@@ -1598,8 +1676,9 @@  discard block
 block discarded – undo
1598 1676
 		{
1599 1677
 			$new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => '&#039;'));
1600 1678
 
1601
-			if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name'])))
1602
-				unset($new_entries[$k]);
1679
+			if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) {
1680
+							unset($new_entries[$k]);
1681
+			}
1603 1682
 		}
1604 1683
 
1605 1684
 		$_SESSION['prf-save'] = $txt['could_not_add_person'];
@@ -1617,16 +1696,18 @@  discard block
 block discarded – undo
1617 1696
 				)
1618 1697
 			);
1619 1698
 
1620
-			if ($smcFunc['db_num_rows']($request) != 0)
1621
-				$_SESSION['prf-save'] = true;
1699
+			if ($smcFunc['db_num_rows']($request) != 0) {
1700
+							$_SESSION['prf-save'] = true;
1701
+			}
1622 1702
 
1623 1703
 			// Add the new member to the buddies array.
1624 1704
 			while ($row = $smcFunc['db_fetch_assoc']($request))
1625 1705
 			{
1626
-				if (in_array($row['id_member'], $ignoreArray))
1627
-					continue;
1628
-				else
1629
-					$ignoreArray[] = (int) $row['id_member'];
1706
+				if (in_array($row['id_member'], $ignoreArray)) {
1707
+									continue;
1708
+				} else {
1709
+									$ignoreArray[] = (int) $row['id_member'];
1710
+				}
1630 1711
 			}
1631 1712
 			$smcFunc['db_free_result']($request);
1632 1713
 
@@ -1655,8 +1736,9 @@  discard block
 block discarded – undo
1655 1736
 				'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1,
1656 1737
 			)
1657 1738
 		);
1658
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1659
-			$ignored[] = $row['id_member'];
1739
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1740
+					$ignored[] = $row['id_member'];
1741
+		}
1660 1742
 		$smcFunc['db_free_result']($result);
1661 1743
 	}
1662 1744
 
@@ -1675,10 +1757,11 @@  discard block
 block discarded – undo
1675 1757
 
1676 1758
 	if (isset($_SESSION['prf-save']))
1677 1759
 	{
1678
-		if ($_SESSION['prf-save'] === true)
1679
-			$context['saved_successful'] = true;
1680
-		else
1681
-			$context['saved_failed'] = $_SESSION['prf-save'];
1760
+		if ($_SESSION['prf-save'] === true) {
1761
+					$context['saved_successful'] = true;
1762
+		} else {
1763
+					$context['saved_failed'] = $_SESSION['prf-save'];
1764
+		}
1682 1765
 
1683 1766
 		unset($_SESSION['prf-save']);
1684 1767
 	}
@@ -1694,8 +1777,9 @@  discard block
 block discarded – undo
1694 1777
 	global $context, $txt;
1695 1778
 
1696 1779
 	loadThemeOptions($memID);
1697
-	if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any')))
1698
-		loadCustomFields($memID, 'account');
1780
+	if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) {
1781
+			loadCustomFields($memID, 'account');
1782
+	}
1699 1783
 
1700 1784
 	$context['sub_template'] = 'edit_options';
1701 1785
 	$context['page_desc'] = $txt['account_info'];
@@ -1722,8 +1806,9 @@  discard block
 block discarded – undo
1722 1806
 	global $context, $txt;
1723 1807
 
1724 1808
 	loadThemeOptions($memID);
1725
-	if (allowedTo(array('profile_forum_own', 'profile_forum_any')))
1726
-		loadCustomFields($memID, 'forumprofile');
1809
+	if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) {
1810
+			loadCustomFields($memID, 'forumprofile');
1811
+	}
1727 1812
 
1728 1813
 	$context['sub_template'] = 'edit_options';
1729 1814
 	$context['page_desc'] = $txt['forumProfile_info'];
@@ -1756,18 +1841,21 @@  discard block
 block discarded – undo
1756 1841
 	$dirs = array();
1757 1842
 	$files = array();
1758 1843
 
1759
-	if (!$dir)
1760
-		return array();
1844
+	if (!$dir) {
1845
+			return array();
1846
+	}
1761 1847
 
1762 1848
 	while ($line = $dir->read())
1763 1849
 	{
1764
-		if (in_array($line, array('.', '..', 'blank.png', 'index.php')))
1765
-			continue;
1850
+		if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) {
1851
+					continue;
1852
+		}
1766 1853
 
1767
-		if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line))
1768
-			$dirs[] = $line;
1769
-		else
1770
-			$files[] = $line;
1854
+		if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) {
1855
+					$dirs[] = $line;
1856
+		} else {
1857
+					$files[] = $line;
1858
+		}
1771 1859
 	}
1772 1860
 	$dir->close();
1773 1861
 
@@ -1788,14 +1876,15 @@  discard block
 block discarded – undo
1788 1876
 	foreach ($dirs as $line)
1789 1877
 	{
1790 1878
 		$tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1);
1791
-		if (!empty($tmp))
1792
-			$result[] = array(
1879
+		if (!empty($tmp)) {
1880
+					$result[] = array(
1793 1881
 				'filename' => $smcFunc['htmlspecialchars']($line),
1794 1882
 				'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false,
1795 1883
 				'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']',
1796 1884
 				'is_dir' => true,
1797 1885
 				'files' => $tmp
1798 1886
 		);
1887
+		}
1799 1888
 		unset($tmp);
1800 1889
 	}
1801 1890
 
@@ -1805,8 +1894,9 @@  discard block
 block discarded – undo
1805 1894
 		$extension = substr(strrchr($line, '.'), 1);
1806 1895
 
1807 1896
 		// Make sure it is an image.
1808
-		if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0)
1809
-			continue;
1897
+		if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) {
1898
+					continue;
1899
+		}
1810 1900
 
1811 1901
 		$result[] = array(
1812 1902
 			'filename' => $smcFunc['htmlspecialchars']($line),
@@ -1814,8 +1904,9 @@  discard block
 block discarded – undo
1814 1904
 			'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)),
1815 1905
 			'is_dir' => false
1816 1906
 		);
1817
-		if ($level == 1)
1818
-			$context['avatar_list'][] = $directory . '/' . $line;
1907
+		if ($level == 1) {
1908
+					$context['avatar_list'][] = $directory . '/' . $line;
1909
+		}
1819 1910
 	}
1820 1911
 
1821 1912
 	return $result;
@@ -1837,8 +1928,9 @@  discard block
 block discarded – undo
1837 1928
 	call_integration_hook('integrate_theme_options');
1838 1929
 
1839 1930
 	loadThemeOptions($memID);
1840
-	if (allowedTo(array('profile_extra_own', 'profile_extra_any')))
1841
-		loadCustomFields($memID, 'theme');
1931
+	if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) {
1932
+			loadCustomFields($memID, 'theme');
1933
+	}
1842 1934
 
1843 1935
 	$context['sub_template'] = 'edit_options';
1844 1936
 	$context['page_desc'] = $txt['theme_info'];
@@ -1892,16 +1984,19 @@  discard block
 block discarded – undo
1892 1984
 {
1893 1985
 	global $txt, $context, $modSettings, $smcFunc, $sourcedir;
1894 1986
 
1895
-	if (!isset($context['token_check']))
1896
-		$context['token_check'] = 'profile-nt' . $memID;
1987
+	if (!isset($context['token_check'])) {
1988
+			$context['token_check'] = 'profile-nt' . $memID;
1989
+	}
1897 1990
 
1898 1991
 	is_not_guest();
1899
-	if (!$context['user']['is_owner'])
1900
-		isAllowedTo('profile_extra_any');
1992
+	if (!$context['user']['is_owner']) {
1993
+			isAllowedTo('profile_extra_any');
1994
+	}
1901 1995
 
1902 1996
 	// Set the post action if we're coming from the profile...
1903
-	if (!isset($context['action']))
1904
-		$context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID;
1997
+	if (!isset($context['action'])) {
1998
+			$context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID;
1999
+	}
1905 2000
 
1906 2001
 	// What options are set
1907 2002
 	loadThemeOptions($memID);
@@ -1988,28 +2083,34 @@  discard block
 block discarded – undo
1988 2083
 	);
1989 2084
 
1990 2085
 	// There are certain things that are disabled at the group level.
1991
-	if (empty($modSettings['cal_enabled']))
1992
-		unset($alert_types['calendar']);
2086
+	if (empty($modSettings['cal_enabled'])) {
2087
+			unset($alert_types['calendar']);
2088
+	}
1993 2089
 
1994 2090
 	// Disable paid subscriptions at group level if they're disabled
1995
-	if (empty($modSettings['paid_enabled']))
1996
-		unset($alert_types['paidsubs']);
2091
+	if (empty($modSettings['paid_enabled'])) {
2092
+			unset($alert_types['paidsubs']);
2093
+	}
1997 2094
 
1998 2095
 	// Disable membergroup requests at group level if they're disabled
1999
-	if (empty($modSettings['show_group_membership']))
2000
-		unset($alert_types['groupr'], $alert_types['members']['request_group']);
2096
+	if (empty($modSettings['show_group_membership'])) {
2097
+			unset($alert_types['groupr'], $alert_types['members']['request_group']);
2098
+	}
2001 2099
 
2002 2100
 	// Disable mentions if they're disabled
2003
-	if (empty($modSettings['enable_mentions']))
2004
-		unset($alert_types['msg']['msg_mention']);
2101
+	if (empty($modSettings['enable_mentions'])) {
2102
+			unset($alert_types['msg']['msg_mention']);
2103
+	}
2005 2104
 
2006 2105
 	// Disable likes if they're disabled
2007
-	if (empty($modSettings['enable_likes']))
2008
-		unset($alert_types['msg']['msg_like']);
2106
+	if (empty($modSettings['enable_likes'])) {
2107
+			unset($alert_types['msg']['msg_like']);
2108
+	}
2009 2109
 
2010 2110
 	// Disable buddy requests if they're disabled
2011
-	if (empty($modSettings['enable_buddylist']))
2012
-		unset($alert_types['members']['buddy_request']);
2111
+	if (empty($modSettings['enable_buddylist'])) {
2112
+			unset($alert_types['members']['buddy_request']);
2113
+	}
2013 2114
 
2014 2115
 	// Now, now, we could pass this through global but we should really get into the habit of
2015 2116
 	// passing content to hooks, not expecting hooks to splatter everything everywhere.
@@ -2037,15 +2138,17 @@  discard block
 block discarded – undo
2037 2138
 			$perms_cache['manage_membergroups'] = in_array($memID, $members);
2038 2139
 		}
2039 2140
 
2040
-		if (!($perms_cache['manage_membergroups'] || $can_mod != 0))
2041
-			unset($alert_types['members']['request_group']);
2141
+		if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) {
2142
+					unset($alert_types['members']['request_group']);
2143
+		}
2042 2144
 
2043 2145
 		foreach ($alert_types as $group => $items)
2044 2146
 		{
2045 2147
 			foreach ($items as $alert_key => $alert_value)
2046 2148
 			{
2047
-				if (!isset($alert_value['permission']))
2048
-					continue;
2149
+				if (!isset($alert_value['permission'])) {
2150
+									continue;
2151
+				}
2049 2152
 				if (!isset($perms_cache[$alert_value['permission']['name']]))
2050 2153
 				{
2051 2154
 					$in_board = !empty($alert_value['permission']['is_board']) ? 0 : null;
@@ -2053,12 +2156,14 @@  discard block
 block discarded – undo
2053 2156
 					$perms_cache[$alert_value['permission']['name']] = in_array($memID, $members);
2054 2157
 				}
2055 2158
 
2056
-				if (!$perms_cache[$alert_value['permission']['name']])
2057
-					unset ($alert_types[$group][$alert_key]);
2159
+				if (!$perms_cache[$alert_value['permission']['name']]) {
2160
+									unset ($alert_types[$group][$alert_key]);
2161
+				}
2058 2162
 			}
2059 2163
 
2060
-			if (empty($alert_types[$group]))
2061
-				unset ($alert_types[$group]);
2164
+			if (empty($alert_types[$group])) {
2165
+							unset ($alert_types[$group]);
2166
+			}
2062 2167
 		}
2063 2168
 	}
2064 2169
 
@@ -2090,9 +2195,9 @@  discard block
 block discarded – undo
2090 2195
 						$update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0;
2091 2196
 						break;
2092 2197
 					case 'select':
2093
-						if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]]))
2094
-							$update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]];
2095
-						else
2198
+						if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) {
2199
+													$update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]];
2200
+						} else
2096 2201
 						{
2097 2202
 							// We didn't have a sane value. Let's grab the first item from the possibles.
2098 2203
 							$keys = array_keys($this_option['opts']);
@@ -2112,23 +2217,28 @@  discard block
 block discarded – undo
2112 2217
 				$this_value = 0;
2113 2218
 				foreach ($context['alert_bits'] as $type => $bitvalue)
2114 2219
 				{
2115
-					if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always')
2116
-						$this_value |= $bitvalue;
2220
+					if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') {
2221
+											$this_value |= $bitvalue;
2222
+					}
2223
+				}
2224
+				if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) {
2225
+									$update_prefs[$item_key] = $this_value;
2117 2226
 				}
2118
-				if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value)
2119
-					$update_prefs[$item_key] = $this_value;
2120 2227
 			}
2121 2228
 		}
2122 2229
 
2123
-		if (!empty($_POST['opt_alert_timeout']))
2124
-			$update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout'];
2230
+		if (!empty($_POST['opt_alert_timeout'])) {
2231
+					$update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout'];
2232
+		}
2125 2233
 
2126
-		if (!empty($_POST['notify_announcements']))
2127
-			$update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements'];
2234
+		if (!empty($_POST['notify_announcements'])) {
2235
+					$update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements'];
2236
+		}
2128 2237
 
2129 2238
 		setNotifyPrefs((int) $memID, $update_prefs);
2130
-		foreach ($update_prefs as $pref => $value)
2131
-			$context['alert_prefs'][$pref] = $value;
2239
+		foreach ($update_prefs as $pref => $value) {
2240
+					$context['alert_prefs'][$pref] = $value;
2241
+		}
2132 2242
 
2133 2243
 		makeNotificationChanges($memID);
2134 2244
 
@@ -2158,8 +2268,9 @@  discard block
 block discarded – undo
2158 2268
 
2159 2269
 	// Now we're all set up.
2160 2270
 	is_not_guest();
2161
-	if (!$context['user']['is_owner'])
2162
-		fatal_error('no_access');
2271
+	if (!$context['user']['is_owner']) {
2272
+			fatal_error('no_access');
2273
+	}
2163 2274
 
2164 2275
 	checkSession('get');
2165 2276
 
@@ -2191,8 +2302,9 @@  discard block
 block discarded – undo
2191 2302
 {
2192 2303
 	global $smcFunc;
2193 2304
 
2194
-	if (empty($toMark) || empty($memID))
2195
-		return false;
2305
+	if (empty($toMark) || empty($memID)) {
2306
+			return false;
2307
+	}
2196 2308
 
2197 2309
 	$toMark = (array) $toMark;
2198 2310
 
@@ -2226,8 +2338,9 @@  discard block
 block discarded – undo
2226 2338
 {
2227 2339
 	global $smcFunc;
2228 2340
 
2229
-	if (empty($toDelete))
2230
-		return false;
2341
+	if (empty($toDelete)) {
2342
+			return false;
2343
+	}
2231 2344
 
2232 2345
 	$toDelete = (array) $toDelete;
2233 2346
 
@@ -2262,8 +2375,9 @@  discard block
 block discarded – undo
2262 2375
 {
2263 2376
 	global $smcFunc;
2264 2377
 
2265
-	if (empty($memID))
2266
-		return false;
2378
+	if (empty($memID)) {
2379
+			return false;
2380
+	}
2267 2381
 
2268 2382
 	$request = $smcFunc['db_query']('', '
2269 2383
 		SELECT id_alert
@@ -2340,8 +2454,9 @@  discard block
 block discarded – undo
2340 2454
 					{
2341 2455
 						$link = $topic['link'];
2342 2456
 
2343
-						if ($topic['new'])
2344
-							$link .= ' <a href="' . $topic['new_href'] . '" class="new_posts">' . $txt['new'] . '</a>';
2457
+						if ($topic['new']) {
2458
+													$link .= ' <a href="' . $topic['new_href'] . '" class="new_posts">' . $txt['new'] . '</a>';
2459
+						}
2345 2460
 
2346 2461
 						$link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>';
2347 2462
 
@@ -2492,8 +2607,9 @@  discard block
 block discarded – undo
2492 2607
 					{
2493 2608
 						$link = $board['link'];
2494 2609
 
2495
-						if ($board['new'])
2496
-							$link .= ' <a href="' . $board['href'] . '" class="new_posts">' . $txt['new'] . '</a>';
2610
+						if ($board['new']) {
2611
+													$link .= ' <a href="' . $board['href'] . '" class="new_posts">' . $txt['new'] . '</a>';
2612
+						}
2497 2613
 
2498 2614
 						return $link;
2499 2615
 					},
@@ -2693,8 +2809,8 @@  discard block
 block discarded – undo
2693 2809
 		)
2694 2810
 	);
2695 2811
 	$notification_boards = array();
2696
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2697
-		$notification_boards[] = array(
2812
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2813
+			$notification_boards[] = array(
2698 2814
 			'id' => $row['id_board'],
2699 2815
 			'name' => $row['name'],
2700 2816
 			'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
@@ -2702,6 +2818,7 @@  discard block
 block discarded – undo
2702 2818
 			'new' => $row['board_read'] < $row['id_msg_updated'],
2703 2819
 			'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0),
2704 2820
 		);
2821
+	}
2705 2822
 	$smcFunc['db_free_result']($request);
2706 2823
 
2707 2824
 	return $notification_boards;
@@ -2716,17 +2833,18 @@  discard block
 block discarded – undo
2716 2833
 {
2717 2834
 	global $context, $options, $cur_profile, $smcFunc;
2718 2835
 
2719
-	if (isset($_POST['default_options']))
2720
-		$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
2836
+	if (isset($_POST['default_options'])) {
2837
+			$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
2838
+	}
2721 2839
 
2722 2840
 	if ($context['user']['is_owner'])
2723 2841
 	{
2724 2842
 		$context['member']['options'] = $options;
2725
-		if (isset($_POST['options']) && is_array($_POST['options']))
2726
-			foreach ($_POST['options'] as $k => $v)
2843
+		if (isset($_POST['options']) && is_array($_POST['options'])) {
2844
+					foreach ($_POST['options'] as $k => $v)
2727 2845
 				$context['member']['options'][$k] = $v;
2728
-	}
2729
-	else
2846
+		}
2847
+	} else
2730 2848
 	{
2731 2849
 		$request = $smcFunc['db_query']('', '
2732 2850
 			SELECT id_member, variable, value
@@ -2747,8 +2865,9 @@  discard block
 block discarded – undo
2747 2865
 				continue;
2748 2866
 			}
2749 2867
 
2750
-			if (isset($_POST['options'][$row['variable']]))
2751
-				$row['value'] = $_POST['options'][$row['variable']];
2868
+			if (isset($_POST['options'][$row['variable']])) {
2869
+							$row['value'] = $_POST['options'][$row['variable']];
2870
+			}
2752 2871
 			$context['member']['options'][$row['variable']] = $row['value'];
2753 2872
 		}
2754 2873
 		$smcFunc['db_free_result']($request);
@@ -2756,8 +2875,9 @@  discard block
 block discarded – undo
2756 2875
 		// Load up the default theme options for any missing.
2757 2876
 		foreach ($temp as $k => $v)
2758 2877
 		{
2759
-			if (!isset($context['member']['options'][$k]))
2760
-				$context['member']['options'][$k] = $v;
2878
+			if (!isset($context['member']['options'][$k])) {
2879
+							$context['member']['options'][$k] = $v;
2880
+			}
2761 2881
 		}
2762 2882
 	}
2763 2883
 }
@@ -2772,8 +2892,9 @@  discard block
 block discarded – undo
2772 2892
 	global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir;
2773 2893
 
2774 2894
 	// Have the admins enabled this option?
2775
-	if (empty($modSettings['allow_ignore_boards']))
2776
-		fatal_lang_error('ignoreboards_disallowed', 'user');
2895
+	if (empty($modSettings['allow_ignore_boards'])) {
2896
+			fatal_lang_error('ignoreboards_disallowed', 'user');
2897
+	}
2777 2898
 
2778 2899
 	// Find all the boards this user is allowed to see.
2779 2900
 	$request = $smcFunc['db_query']('order_by_board_order', '
@@ -2793,12 +2914,13 @@  discard block
 block discarded – undo
2793 2914
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2794 2915
 	{
2795 2916
 		// This category hasn't been set up yet..
2796
-		if (!isset($context['categories'][$row['id_cat']]))
2797
-			$context['categories'][$row['id_cat']] = array(
2917
+		if (!isset($context['categories'][$row['id_cat']])) {
2918
+					$context['categories'][$row['id_cat']] = array(
2798 2919
 				'id' => $row['id_cat'],
2799 2920
 				'name' => $row['cat_name'],
2800 2921
 				'boards' => array()
2801 2922
 			);
2923
+		}
2802 2924
 
2803 2925
 		// Set this board up, and let the template know when it's a child.  (indent them..)
2804 2926
 		$context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
@@ -2828,18 +2950,20 @@  discard block
 block discarded – undo
2828 2950
 	}
2829 2951
 
2830 2952
 	$max_boards = ceil(count($temp_boards) / 2);
2831
-	if ($max_boards == 1)
2832
-		$max_boards = 2;
2953
+	if ($max_boards == 1) {
2954
+			$max_boards = 2;
2955
+	}
2833 2956
 
2834 2957
 	// Now, alternate them so they can be shown left and right ;).
2835 2958
 	$context['board_columns'] = array();
2836 2959
 	for ($i = 0; $i < $max_boards; $i++)
2837 2960
 	{
2838 2961
 		$context['board_columns'][] = $temp_boards[$i];
2839
-		if (isset($temp_boards[$i + $max_boards]))
2840
-			$context['board_columns'][] = $temp_boards[$i + $max_boards];
2841
-		else
2842
-			$context['board_columns'][] = array();
2962
+		if (isset($temp_boards[$i + $max_boards])) {
2963
+					$context['board_columns'][] = $temp_boards[$i + $max_boards];
2964
+		} else {
2965
+					$context['board_columns'][] = array();
2966
+		}
2843 2967
 	}
2844 2968
 
2845 2969
 	loadThemeOptions($memID);
@@ -2908,8 +3032,9 @@  discard block
 block discarded – undo
2908 3032
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2909 3033
 	{
2910 3034
 		// We should skip the administrator group if they don't have the admin_forum permission!
2911
-		if ($row['id_group'] == 1 && !allowedTo('admin_forum'))
2912
-			continue;
3035
+		if ($row['id_group'] == 1 && !allowedTo('admin_forum')) {
3036
+					continue;
3037
+		}
2913 3038
 
2914 3039
 		$context['member_groups'][$row['id_group']] = array(
2915 3040
 			'id' => $row['id_group'],
@@ -2955,16 +3080,17 @@  discard block
 block discarded – undo
2955 3080
 	$context['max_signature_length'] = $context['signature_limits']['max_length'];
2956 3081
 	// Warning message for signature image limits?
2957 3082
 	$context['signature_warning'] = '';
2958
-	if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height'])
2959
-		$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']);
2960
-	elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height'])
2961
-		$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']);
3083
+	if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) {
3084
+			$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']);
3085
+	} elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) {
3086
+			$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']);
3087
+	}
2962 3088
 
2963 3089
 	$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_character_set'] == 'UTF-8' || function_exists('iconv'))));
2964 3090
 
2965
-	if (empty($context['do_preview']))
2966
-		$context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '&lt;', '&gt;', '&quot;', '&#039;'), $cur_profile['signature']);
2967
-	else
3091
+	if (empty($context['do_preview'])) {
3092
+			$context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '&lt;', '&gt;', '&quot;', '&#039;'), $cur_profile['signature']);
3093
+	} else
2968 3094
 	{
2969 3095
 		$signature = !empty($_POST['signature']) ? $_POST['signature'] : '';
2970 3096
 		$validation = profileValidateSignature($signature);
@@ -2974,8 +3100,9 @@  discard block
 block discarded – undo
2974 3100
 			$context['post_errors'] = array();
2975 3101
 		}
2976 3102
 		$context['post_errors'][] = 'signature_not_yet_saved';
2977
-		if ($validation !== true && $validation !== false)
2978
-			$context['post_errors'][] = $validation;
3103
+		if ($validation !== true && $validation !== false) {
3104
+					$context['post_errors'][] = $validation;
3105
+		}
2979 3106
 
2980 3107
 		censorText($context['member']['signature']);
2981 3108
 		$context['member']['current_signature'] = $context['member']['signature'];
@@ -2985,8 +3112,9 @@  discard block
 block discarded – undo
2985 3112
 	}
2986 3113
 
2987 3114
 	// Load the spell checker?
2988
-	if ($context['show_spellchecking'])
2989
-		loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck');
3115
+	if ($context['show_spellchecking']) {
3116
+			loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck');
3117
+	}
2990 3118
 
2991 3119
 	return true;
2992 3120
 }
@@ -3020,8 +3148,7 @@  discard block
 block discarded – undo
3020 3148
 			'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11)
3021 3149
 		);
3022 3150
 		$context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']);
3023
-	}
3024
-	elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload'])
3151
+	} elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload'])
3025 3152
 	{
3026 3153
 		$context['member']['avatar'] += array(
3027 3154
 			'choice' => 'upload',
@@ -3031,33 +3158,34 @@  discard block
 block discarded – undo
3031 3158
 		$context['member']['avatar']['href'] = empty($cur_profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $cur_profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $cur_profile['filename'];
3032 3159
 	}
3033 3160
 	// Use "avatar_original" here so we show what the user entered even if the image proxy is enabled
3034
-	elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external'])
3035
-		$context['member']['avatar'] += array(
3161
+	elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) {
3162
+			$context['member']['avatar'] += array(
3036 3163
 			'choice' => 'external',
3037 3164
 			'server_pic' => 'blank.png',
3038 3165
 			'external' => $cur_profile['avatar_original']
3039 3166
 		);
3040
-	elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored'])
3041
-		$context['member']['avatar'] += array(
3167
+	} elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) {
3168
+			$context['member']['avatar'] += array(
3042 3169
 			'choice' => 'server_stored',
3043 3170
 			'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'],
3044 3171
 			'external' => 'http://'
3045 3172
 		);
3046
-	else
3047
-		$context['member']['avatar'] += array(
3173
+	} else {
3174
+			$context['member']['avatar'] += array(
3048 3175
 			'choice' => 'none',
3049 3176
 			'server_pic' => 'blank.png',
3050 3177
 			'external' => 'http://'
3051 3178
 		);
3179
+	}
3052 3180
 
3053 3181
 	// Get a list of all the avatars.
3054 3182
 	if ($context['member']['avatar']['allow_server_stored'])
3055 3183
 	{
3056 3184
 		$context['avatar_list'] = array();
3057 3185
 		$context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array();
3186
+	} else {
3187
+			$context['avatars'] = array();
3058 3188
 	}
3059
-	else
3060
-		$context['avatars'] = array();
3061 3189
 
3062 3190
 	// Second level selected avatar...
3063 3191
 	$context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1);
@@ -3086,19 +3214,22 @@  discard block
 block discarded – undo
3086 3214
 			)
3087 3215
 		);
3088 3216
 		$protected_groups = array(1);
3089
-		while ($row = $smcFunc['db_fetch_assoc']($request))
3090
-			$protected_groups[] = $row['id_group'];
3217
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
3218
+					$protected_groups[] = $row['id_group'];
3219
+		}
3091 3220
 		$smcFunc['db_free_result']($request);
3092 3221
 
3093 3222
 		$protected_groups = array_unique($protected_groups);
3094 3223
 	}
3095 3224
 
3096 3225
 	// The account page allows the change of your id_group - but not to a protected group!
3097
-	if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0)
3098
-		$value = (int) $value;
3226
+	if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) {
3227
+			$value = (int) $value;
3228
+	}
3099 3229
 	// ... otherwise it's the old group sir.
3100
-	else
3101
-		$value = $old_profile['id_group'];
3230
+	else {
3231
+			$value = $old_profile['id_group'];
3232
+	}
3102 3233
 
3103 3234
 	// Find the additional membergroups (if any)
3104 3235
 	if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups']))
@@ -3107,16 +3238,18 @@  discard block
 block discarded – undo
3107 3238
 		foreach ($_POST['additional_groups'] as $group_id)
3108 3239
 		{
3109 3240
 			$group_id = (int) $group_id;
3110
-			if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups)))
3111
-				$additional_groups[] = $group_id;
3241
+			if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) {
3242
+							$additional_groups[] = $group_id;
3243
+			}
3112 3244
 		}
3113 3245
 
3114 3246
 		// Put the protected groups back in there if you don't have permission to take them away.
3115 3247
 		$old_additional_groups = explode(',', $old_profile['additional_groups']);
3116 3248
 		foreach ($old_additional_groups as $group_id)
3117 3249
 		{
3118
-			if (!empty($protected_groups) && in_array($group_id, $protected_groups))
3119
-				$additional_groups[] = $group_id;
3250
+			if (!empty($protected_groups) && in_array($group_id, $protected_groups)) {
3251
+							$additional_groups[] = $group_id;
3252
+			}
3120 3253
 		}
3121 3254
 
3122 3255
 		if (implode(',', $additional_groups) !== $old_profile['additional_groups'])
@@ -3148,18 +3281,20 @@  discard block
 block discarded – undo
3148 3281
 			list ($another) = $smcFunc['db_fetch_row']($request);
3149 3282
 			$smcFunc['db_free_result']($request);
3150 3283
 
3151
-			if (empty($another))
3152
-				fatal_lang_error('at_least_one_admin', 'critical');
3284
+			if (empty($another)) {
3285
+							fatal_lang_error('at_least_one_admin', 'critical');
3286
+			}
3153 3287
 		}
3154 3288
 	}
3155 3289
 
3156 3290
 	// If we are changing group status, update permission cache as necessary.
3157 3291
 	if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups']))
3158 3292
 	{
3159
-		if ($context['user']['is_owner'])
3160
-			$_SESSION['mc']['time'] = 0;
3161
-		else
3162
-			updateSettings(array('settings_updated' => time()));
3293
+		if ($context['user']['is_owner']) {
3294
+					$_SESSION['mc']['time'] = 0;
3295
+		} else {
3296
+					updateSettings(array('settings_updated' => time()));
3297
+		}
3163 3298
 	}
3164 3299
 
3165 3300
 	// Announce to any hooks that we have changed groups, but don't allow them to change it.
@@ -3180,8 +3315,9 @@  discard block
 block discarded – undo
3180 3315
 	global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context;
3181 3316
 
3182 3317
 	$memID = $context['id_member'];
3183
-	if (empty($memID) && !empty($context['password_auth_failed']))
3184
-		return false;
3318
+	if (empty($memID) && !empty($context['password_auth_failed'])) {
3319
+			return false;
3320
+	}
3185 3321
 
3186 3322
 	require_once($sourcedir . '/ManageAttachments.php');
3187 3323
 
@@ -3192,8 +3328,9 @@  discard block
 block discarded – undo
3192 3328
 	$downloadedExternalAvatar = false;
3193 3329
 	if ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external']))
3194 3330
 	{
3195
-		if (!is_writable($uploadDir))
3196
-			fatal_lang_error('attachments_no_write', 'critical');
3331
+		if (!is_writable($uploadDir)) {
3332
+					fatal_lang_error('attachments_no_write', 'critical');
3333
+		}
3197 3334
 
3198 3335
 		$url = parse_url($_POST['userpicpersonal']);
3199 3336
 		$contents = fetch_web_data($url['scheme'] . '://' . $url['host'] . (empty($url['port']) ? '' : ':' . $url['port']) . str_replace(' ', '%20', trim($url['path'])));
@@ -3235,19 +3372,18 @@  discard block
 block discarded – undo
3235 3372
 
3236 3373
 		// Get rid of their old avatar. (if uploaded.)
3237 3374
 		removeAttachments(array('id_member' => $memID));
3238
-	}
3239
-	elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled']))
3375
+	} elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled']))
3240 3376
 	{
3241 3377
 		// One wasn't specified, or it's not allowed to use extra email addresses, or it's not a valid one, reset to default Gravatar.
3242
-		if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL))
3243
-			$profile_vars['avatar'] = 'gravatar://';
3244
-		else
3245
-			$profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : '');
3378
+		if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) {
3379
+					$profile_vars['avatar'] = 'gravatar://';
3380
+		} else {
3381
+					$profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : '');
3382
+		}
3246 3383
 
3247 3384
 		// Get rid of their old avatar. (if uploaded.)
3248 3385
 		removeAttachments(array('id_member' => $memID));
3249
-	}
3250
-	elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external']))
3386
+	} elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external']))
3251 3387
 	{
3252 3388
 		// We need these clean...
3253 3389
 		$cur_profile['id_attach'] = 0;
@@ -3259,11 +3395,13 @@  discard block
 block discarded – undo
3259 3395
 
3260 3396
 		$profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal']));
3261 3397
 
3262
-		if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///')
3263
-			$profile_vars['avatar'] = '';
3398
+		if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') {
3399
+					$profile_vars['avatar'] = '';
3400
+		}
3264 3401
 		// Trying to make us do something we'll regret?
3265
-		elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://')
3266
-			return 'bad_avatar_invalid_url';
3402
+		elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') {
3403
+					return 'bad_avatar_invalid_url';
3404
+		}
3267 3405
 		// Should we check dimensions?
3268 3406
 		elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external']))
3269 3407
 		{
@@ -3273,9 +3411,9 @@  discard block
 block discarded – undo
3273 3411
 			if (is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external']))))
3274 3412
 			{
3275 3413
 				// Houston, we have a problem. The avatar is too large!!
3276
-				if ($modSettings['avatar_action_too_large'] == 'option_refuse')
3277
-					return 'bad_avatar_too_large';
3278
-				elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize')
3414
+				if ($modSettings['avatar_action_too_large'] == 'option_refuse') {
3415
+									return 'bad_avatar_too_large';
3416
+				} elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize')
3279 3417
 				{
3280 3418
 					// @todo remove this if appropriate
3281 3419
 					require_once($sourcedir . '/Subs-Graphics.php');
@@ -3285,26 +3423,27 @@  discard block
 block discarded – undo
3285 3423
 						$cur_profile['id_attach'] = $modSettings['new_avatar_data']['id'];
3286 3424
 						$cur_profile['filename'] = $modSettings['new_avatar_data']['filename'];
3287 3425
 						$cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type'];
3426
+					} else {
3427
+											return 'bad_avatar';
3288 3428
 					}
3289
-					else
3290
-						return 'bad_avatar';
3291 3429
 				}
3292 3430
 			}
3293 3431
 		}
3294
-	}
3295
-	elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar)
3432
+	} elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar)
3296 3433
 	{
3297 3434
 		if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar)
3298 3435
 		{
3299 3436
 			// Get the dimensions of the image.
3300 3437
 			if (!$downloadedExternalAvatar)
3301 3438
 			{
3302
-				if (!is_writable($uploadDir))
3303
-					fatal_lang_error('attachments_no_write', 'critical');
3439
+				if (!is_writable($uploadDir)) {
3440
+									fatal_lang_error('attachments_no_write', 'critical');
3441
+				}
3304 3442
 
3305 3443
 				$new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true);
3306
-				if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename))
3307
-					fatal_lang_error('attach_timeout', 'critical');
3444
+				if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) {
3445
+									fatal_lang_error('attach_timeout', 'critical');
3446
+				}
3308 3447
 
3309 3448
 				$_FILES['attachment']['tmp_name'] = $new_filename;
3310 3449
 			}
@@ -3417,17 +3556,19 @@  discard block
 block discarded – undo
3417 3556
 			$profile_vars['avatar'] = '';
3418 3557
 
3419 3558
 			// Delete any temporary file.
3420
-			if (file_exists($_FILES['attachment']['tmp_name']))
3421
-				@unlink($_FILES['attachment']['tmp_name']);
3559
+			if (file_exists($_FILES['attachment']['tmp_name'])) {
3560
+							@unlink($_FILES['attachment']['tmp_name']);
3561
+			}
3422 3562
 		}
3423 3563
 		// Selected the upload avatar option and had one already uploaded before or didn't upload one.
3424
-		else
3564
+		else {
3565
+					$profile_vars['avatar'] = '';
3566
+		}
3567
+	} elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) {
3568
+			$profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address'])));
3569
+	} else {
3425 3570
 			$profile_vars['avatar'] = '';
3426 3571
 	}
3427
-	elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar'))
3428
-		$profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address'])));
3429
-	else
3430
-		$profile_vars['avatar'] = '';
3431 3572
 
3432 3573
 	// Setup the profile variables so it shows things right on display!
3433 3574
 	$cur_profile['avatar'] = $profile_vars['avatar'];
@@ -3475,9 +3616,9 @@  discard block
 block discarded – undo
3475 3616
 		$smiley_parsed = $unparsed_signature;
3476 3617
 		parsesmileys($smiley_parsed);
3477 3618
 		$smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img');
3478
-		if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0)
3479
-			return 'signature_allow_smileys';
3480
-		elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4])
3619
+		if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) {
3620
+					return 'signature_allow_smileys';
3621
+		} elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4])
3481 3622
 		{
3482 3623
 			$txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]);
3483 3624
 			return 'signature_max_smileys';
@@ -3490,14 +3631,15 @@  discard block
 block discarded – undo
3490 3631
 			{
3491 3632
 				$limit_broke = 0;
3492 3633
 				// Attempt to allow all sizes of abuse, so to speak.
3493
-				if ($matches[2][$ind] == 'px' && $size > $sig_limits[7])
3494
-					$limit_broke = $sig_limits[7] . 'px';
3495
-				elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75))
3496
-					$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
3497
-				elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16))
3498
-					$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
3499
-				elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18)
3500
-					$limit_broke = 'large';
3634
+				if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) {
3635
+									$limit_broke = $sig_limits[7] . 'px';
3636
+				} elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) {
3637
+									$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
3638
+				} elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) {
3639
+									$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
3640
+				} elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) {
3641
+									$limit_broke = 'large';
3642
+				}
3501 3643
 
3502 3644
 				if ($limit_broke)
3503 3645
 				{
@@ -3539,24 +3681,26 @@  discard block
 block discarded – undo
3539 3681
 					$width = -1; $height = -1;
3540 3682
 
3541 3683
 					// Does it have predefined restraints? Width first.
3542
-					if ($matches[6][$key])
3543
-						$matches[2][$key] = $matches[6][$key];
3684
+					if ($matches[6][$key]) {
3685
+											$matches[2][$key] = $matches[6][$key];
3686
+					}
3544 3687
 					if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5])
3545 3688
 					{
3546 3689
 						$width = $sig_limits[5];
3547 3690
 						$matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]);
3691
+					} elseif ($matches[2][$key]) {
3692
+											$width = $matches[2][$key];
3548 3693
 					}
3549
-					elseif ($matches[2][$key])
3550
-						$width = $matches[2][$key];
3551 3694
 					// ... and height.
3552 3695
 					if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6])
3553 3696
 					{
3554 3697
 						$height = $sig_limits[6];
3555
-						if ($width != -1)
3556
-							$width = $width * ($height / $matches[4][$key]);
3698
+						if ($width != -1) {
3699
+													$width = $width * ($height / $matches[4][$key]);
3700
+						}
3701
+					} elseif ($matches[4][$key]) {
3702
+											$height = $matches[4][$key];
3557 3703
 					}
3558
-					elseif ($matches[4][$key])
3559
-						$height = $matches[4][$key];
3560 3704
 
3561 3705
 					// If the dimensions are still not fixed - we need to check the actual image.
3562 3706
 					if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6]))
@@ -3574,21 +3718,24 @@  discard block
 block discarded – undo
3574 3718
 							if ($sizes[1] > $sig_limits[6] && $sig_limits[6])
3575 3719
 							{
3576 3720
 								$height = $sig_limits[6];
3577
-								if ($width == -1)
3578
-									$width = $sizes[0];
3721
+								if ($width == -1) {
3722
+																	$width = $sizes[0];
3723
+								}
3579 3724
 								$width = $width * ($height / $sizes[1]);
3725
+							} elseif ($width != -1) {
3726
+															$height = $sizes[1];
3580 3727
 							}
3581
-							elseif ($width != -1)
3582
-								$height = $sizes[1];
3583 3728
 						}
3584 3729
 					}
3585 3730
 
3586 3731
 					// Did we come up with some changes? If so remake the string.
3587
-					if ($width != -1 || $height != -1)
3588
-						$replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]';
3732
+					if ($width != -1 || $height != -1) {
3733
+											$replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]';
3734
+					}
3735
+				}
3736
+				if (!empty($replaces)) {
3737
+									$value = str_replace(array_keys($replaces), array_values($replaces), $value);
3589 3738
 				}
3590
-				if (!empty($replaces))
3591
-					$value = str_replace(array_keys($replaces), array_values($replaces), $value);
3592 3739
 			}
3593 3740
 		}
3594 3741
 
@@ -3632,10 +3779,12 @@  discard block
 block discarded – undo
3632 3779
 	$email = strtr($email, array('&#039;' => '\''));
3633 3780
 
3634 3781
 	// Check the name and email for validity.
3635
-	if (trim($email) == '')
3636
-		return 'no_email';
3637
-	if (!filter_var($email, FILTER_VALIDATE_EMAIL))
3638
-		return 'bad_email';
3782
+	if (trim($email) == '') {
3783
+			return 'no_email';
3784
+	}
3785
+	if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
3786
+			return 'bad_email';
3787
+	}
3639 3788
 
3640 3789
 	// Email addresses should be and stay unique.
3641 3790
 	$request = $smcFunc['db_query']('', '
@@ -3650,8 +3799,9 @@  discard block
 block discarded – undo
3650 3799
 		)
3651 3800
 	);
3652 3801
 
3653
-	if ($smcFunc['db_num_rows']($request) > 0)
3654
-		return 'email_taken';
3802
+	if ($smcFunc['db_num_rows']($request) > 0) {
3803
+			return 'email_taken';
3804
+	}
3655 3805
 	$smcFunc['db_free_result']($request);
3656 3806
 
3657 3807
 	return true;
@@ -3664,8 +3814,9 @@  discard block
 block discarded – undo
3664 3814
 {
3665 3815
 	global $modSettings, $context, $cur_profile;
3666 3816
 
3667
-	if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '')
3668
-		setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt']));
3817
+	if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') {
3818
+			setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt']));
3819
+	}
3669 3820
 
3670 3821
 	loadUserSettings();
3671 3822
 	writeLog();
@@ -3681,8 +3832,9 @@  discard block
 block discarded – undo
3681 3832
 	require_once($sourcedir . '/Subs-Post.php');
3682 3833
 
3683 3834
 	// Shouldn't happen but just in case.
3684
-	if (empty($profile_vars['email_address']))
3685
-		return;
3835
+	if (empty($profile_vars['email_address'])) {
3836
+			return;
3837
+	}
3686 3838
 
3687 3839
 	$replacements = array(
3688 3840
 		'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'],
@@ -3705,8 +3857,9 @@  discard block
 block discarded – undo
3705 3857
 	$_SESSION['log_time'] = 0;
3706 3858
 	$_SESSION['login_' . $cookiename] = $smcFunc['json_encode'](array(0, '', 0));
3707 3859
 
3708
-	if (isset($_COOKIE[$cookiename]))
3709
-		$_COOKIE[$cookiename] = '';
3860
+	if (isset($_COOKIE[$cookiename])) {
3861
+			$_COOKIE[$cookiename] = '';
3862
+	}
3710 3863
 
3711 3864
 	loadUserSettings();
3712 3865
 
@@ -3739,11 +3892,13 @@  discard block
 block discarded – undo
3739 3892
 	$groups[] = $curMember['id_group'];
3740 3893
 
3741 3894
 	// Ensure the query doesn't croak!
3742
-	if (empty($groups))
3743
-		$groups = array(0);
3895
+	if (empty($groups)) {
3896
+			$groups = array(0);
3897
+	}
3744 3898
 	// Just to be sure...
3745
-	foreach ($groups as $k => $v)
3746
-		$groups[$k] = (int) $v;
3899
+	foreach ($groups as $k => $v) {
3900
+			$groups[$k] = (int) $v;
3901
+	}
3747 3902
 
3748 3903
 	// Get all the membergroups they can join.
3749 3904
 	$request = $smcFunc['db_query']('', '
@@ -3773,12 +3928,14 @@  discard block
 block discarded – undo
3773 3928
 	while ($row = $smcFunc['db_fetch_assoc']($request))
3774 3929
 	{
3775 3930
 		// Can they edit their primary group?
3776
-		if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups)))
3777
-			$context['can_edit_primary'] = true;
3931
+		if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) {
3932
+					$context['can_edit_primary'] = true;
3933
+		}
3778 3934
 
3779 3935
 		// If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it.
3780
-		if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group'])
3781
-			continue;
3936
+		if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) {
3937
+					continue;
3938
+		}
3782 3939
 
3783 3940
 		$context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array(
3784 3941
 			'id' => $row['id_group'],
@@ -3807,13 +3964,15 @@  discard block
 block discarded – undo
3807 3964
 	);
3808 3965
 
3809 3966
 	// No changing primary one unless you have enough groups!
3810
-	if (count($context['groups']['member']) < 2)
3811
-		$context['can_edit_primary'] = false;
3967
+	if (count($context['groups']['member']) < 2) {
3968
+			$context['can_edit_primary'] = false;
3969
+	}
3812 3970
 
3813 3971
 	// In the special case that someone is requesting membership of a group, setup some special context vars.
3814
-	if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2)
3815
-		$context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']];
3816
-}
3972
+	if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) {
3973
+			$context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']];
3974
+	}
3975
+	}
3817 3976
 
3818 3977
 /**
3819 3978
  * This function actually makes all the group changes
@@ -3828,10 +3987,12 @@  discard block
 block discarded – undo
3828 3987
 	global $user_info, $context, $user_profile, $modSettings, $smcFunc;
3829 3988
 
3830 3989
 	// Let's be extra cautious...
3831
-	if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership']))
3832
-		isAllowedTo('manage_membergroups');
3833
-	if (!isset($_REQUEST['gid']) && !isset($_POST['primary']))
3834
-		fatal_lang_error('no_access', false);
3990
+	if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) {
3991
+			isAllowedTo('manage_membergroups');
3992
+	}
3993
+	if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) {
3994
+			fatal_lang_error('no_access', false);
3995
+	}
3835 3996
 
3836 3997
 	checkSession(isset($_GET['gid']) ? 'get' : 'post');
3837 3998
 
@@ -3850,8 +4011,9 @@  discard block
 block discarded – undo
3850 4011
 	$foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false;
3851 4012
 
3852 4013
 	// Sanity check!!
3853
-	if ($group_id == 1)
3854
-		isAllowedTo('admin_forum');
4014
+	if ($group_id == 1) {
4015
+			isAllowedTo('admin_forum');
4016
+	}
3855 4017
 	// Protected groups too!
3856 4018
 	else
3857 4019
 	{
@@ -3868,8 +4030,9 @@  discard block
 block discarded – undo
3868 4030
 		list ($is_protected) = $smcFunc['db_fetch_row']($request);
3869 4031
 		$smcFunc['db_free_result']($request);
3870 4032
 
3871
-		if ($is_protected == 1)
3872
-			isAllowedTo('admin_forum');
4033
+		if ($is_protected == 1) {
4034
+					isAllowedTo('admin_forum');
4035
+		}
3873 4036
 	}
3874 4037
 
3875 4038
 	// What ever we are doing, we need to determine if changing primary is possible!
@@ -3891,36 +4054,43 @@  discard block
 block discarded – undo
3891 4054
 			$group_name = $row['group_name'];
3892 4055
 
3893 4056
 			// Does the group type match what we're doing - are we trying to request a non-requestable group?
3894
-			if ($changeType == 'request' && $row['group_type'] != 2)
3895
-				fatal_lang_error('no_access', false);
4057
+			if ($changeType == 'request' && $row['group_type'] != 2) {
4058
+							fatal_lang_error('no_access', false);
4059
+			}
3896 4060
 			// What about leaving a requestable group we are not a member of?
3897
-			elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']]))
3898
-				fatal_lang_error('no_access', false);
3899
-			elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2)
3900
-				fatal_lang_error('no_access', false);
4061
+			elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) {
4062
+							fatal_lang_error('no_access', false);
4063
+			} elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) {
4064
+							fatal_lang_error('no_access', false);
4065
+			}
3901 4066
 
3902 4067
 			// We can't change the primary group if this is hidden!
3903
-			if ($row['hidden'] == 2)
3904
-				$canChangePrimary = false;
4068
+			if ($row['hidden'] == 2) {
4069
+							$canChangePrimary = false;
4070
+			}
3905 4071
 		}
3906 4072
 
3907 4073
 		// If this is their old primary, can we change it?
3908
-		if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false)
3909
-			$canChangePrimary = 1;
4074
+		if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) {
4075
+					$canChangePrimary = 1;
4076
+		}
3910 4077
 
3911 4078
 		// If we are not doing a force primary move, don't do it automatically if current primary is not 0.
3912
-		if ($changeType != 'primary' && $old_profile['id_group'] != 0)
3913
-			$canChangePrimary = false;
4079
+		if ($changeType != 'primary' && $old_profile['id_group'] != 0) {
4080
+					$canChangePrimary = false;
4081
+		}
3914 4082
 
3915 4083
 		// If this is the one we are acting on, can we even act?
3916
-		if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0))
3917
-			$canChangePrimary = false;
4084
+		if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) {
4085
+					$canChangePrimary = false;
4086
+		}
3918 4087
 	}
3919 4088
 	$smcFunc['db_free_result']($request);
3920 4089
 
3921 4090
 	// Didn't find the target?
3922
-	if (!$foundTarget)
3923
-		fatal_lang_error('no_access', false);
4091
+	if (!$foundTarget) {
4092
+			fatal_lang_error('no_access', false);
4093
+	}
3924 4094
 
3925 4095
 	// Final security check, don't allow users to promote themselves to admin.
3926 4096
 	if ($context['can_manage_membergroups'] && !allowedTo('admin_forum'))
@@ -3940,8 +4110,9 @@  discard block
 block discarded – undo
3940 4110
 		list ($disallow) = $smcFunc['db_fetch_row']($request);
3941 4111
 		$smcFunc['db_free_result']($request);
3942 4112
 
3943
-		if ($disallow)
3944
-			isAllowedTo('admin_forum');
4113
+		if ($disallow) {
4114
+					isAllowedTo('admin_forum');
4115
+		}
3945 4116
 	}
3946 4117
 
3947 4118
 	// If we're requesting, add the note then return.
@@ -3959,8 +4130,9 @@  discard block
 block discarded – undo
3959 4130
 				'status_open' => 0,
3960 4131
 			)
3961 4132
 		);
3962
-		if ($smcFunc['db_num_rows']($request) != 0)
3963
-			fatal_lang_error('profile_error_already_requested_group');
4133
+		if ($smcFunc['db_num_rows']($request) != 0) {
4134
+					fatal_lang_error('profile_error_already_requested_group');
4135
+		}
3964 4136
 		$smcFunc['db_free_result']($request);
3965 4137
 
3966 4138
 		// Log the request.
@@ -3994,10 +4166,11 @@  discard block
 block discarded – undo
3994 4166
 		// Are we leaving?
3995 4167
 		if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id]))
3996 4168
 		{
3997
-			if ($old_profile['id_group'] == $group_id)
3998
-				$newPrimary = 0;
3999
-			else
4000
-				unset($addGroups[$group_id]);
4169
+			if ($old_profile['id_group'] == $group_id) {
4170
+							$newPrimary = 0;
4171
+			} else {
4172
+							unset($addGroups[$group_id]);
4173
+			}
4001 4174
 		}
4002 4175
 		// ... if not, must be joining.
4003 4176
 		else
@@ -4005,36 +4178,42 @@  discard block
 block discarded – undo
4005 4178
 			// Can we change the primary, and do we want to?
4006 4179
 			if ($canChangePrimary)
4007 4180
 			{
4008
-				if ($old_profile['id_group'] != 0)
4009
-					$addGroups[$old_profile['id_group']] = -1;
4181
+				if ($old_profile['id_group'] != 0) {
4182
+									$addGroups[$old_profile['id_group']] = -1;
4183
+				}
4010 4184
 				$newPrimary = $group_id;
4011 4185
 			}
4012 4186
 			// Otherwise it's an additional group...
4013
-			else
4014
-				$addGroups[$group_id] = -1;
4187
+			else {
4188
+							$addGroups[$group_id] = -1;
4189
+			}
4015 4190
 		}
4016 4191
 	}
4017 4192
 	// Finally, we must be setting the primary.
4018 4193
 	elseif ($canChangePrimary)
4019 4194
 	{
4020
-		if ($old_profile['id_group'] != 0)
4021
-			$addGroups[$old_profile['id_group']] = -1;
4022
-		if (isset($addGroups[$group_id]))
4023
-			unset($addGroups[$group_id]);
4195
+		if ($old_profile['id_group'] != 0) {
4196
+					$addGroups[$old_profile['id_group']] = -1;
4197
+		}
4198
+		if (isset($addGroups[$group_id])) {
4199
+					unset($addGroups[$group_id]);
4200
+		}
4024 4201
 		$newPrimary = $group_id;
4025 4202
 	}
4026 4203
 
4027 4204
 	// Finally, we can make the changes!
4028
-	foreach ($addGroups as $id => $dummy)
4029
-		if (empty($id))
4205
+	foreach ($addGroups as $id => $dummy) {
4206
+			if (empty($id))
4030 4207
 			unset($addGroups[$id]);
4208
+	}
4031 4209
 	$addGroups = implode(',', array_flip($addGroups));
4032 4210
 
4033 4211
 	// Ensure that we don't cache permissions if the group is changing.
4034
-	if ($context['user']['is_owner'])
4035
-		$_SESSION['mc']['time'] = 0;
4036
-	else
4037
-		updateSettings(array('settings_updated' => time()));
4212
+	if ($context['user']['is_owner']) {
4213
+			$_SESSION['mc']['time'] = 0;
4214
+	} else {
4215
+			updateSettings(array('settings_updated' => time()));
4216
+	}
4038 4217
 
4039 4218
 	updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups));
4040 4219
 
@@ -4057,8 +4236,9 @@  discard block
 block discarded – undo
4057 4236
 	if (empty($user_settings['tfa_secret']) && $context['user']['is_owner'])
4058 4237
 	{
4059 4238
 		// Check to ensure we're forcing SSL for authentication
4060
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
4061
-			fatal_lang_error('login_ssl_required');
4239
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
4240
+					fatal_lang_error('login_ssl_required');
4241
+		}
4062 4242
 
4063 4243
 		// In some cases (forced 2FA or backup code) they would be forced to be redirected here,
4064 4244
 		// we do not want too much AJAX to confuse them.
@@ -4095,8 +4275,7 @@  discard block
 block discarded – undo
4095 4275
 				$context['sub_template'] = 'tfasetup_backup';
4096 4276
 
4097 4277
 				return;
4098
-			}
4099
-			else
4278
+			} else
4100 4279
 			{
4101 4280
 				$context['tfa_secret'] = $_SESSION['tfa_secret'];
4102 4281
 				$context['tfa_error'] = !$valid_code;
@@ -4104,8 +4283,7 @@  discard block
 block discarded – undo
4104 4283
 				$context['tfa_pass_value'] = $_POST['passwd'];
4105 4284
 				$context['tfa_value'] = $_POST['tfa_code'];
4106 4285
 			}
4107
-		}
4108
-		else
4286
+		} else
4109 4287
 		{
4110 4288
 			$totp = new \TOTP\Auth();
4111 4289
 			$secret = $totp->generateCode();
@@ -4115,17 +4293,16 @@  discard block
 block discarded – undo
4115 4293
 		}
4116 4294
 
4117 4295
 		$context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']);
4118
-	}
4119
-	elseif (isset($_REQUEST['disable']))
4296
+	} elseif (isset($_REQUEST['disable']))
4120 4297
 	{
4121 4298
 		updateMemberData($memID, array(
4122 4299
 			'tfa_secret' => '',
4123 4300
 			'tfa_backup' => '',
4124 4301
 		));
4125 4302
 		redirectexit('action=profile;area=account;u=' . $memID);
4303
+	} else {
4304
+			redirectexit('action=profile;area=account;u=' . $memID);
4305
+	}
4126 4306
 	}
4127
-	else
4128
-		redirectexit('action=profile;area=account;u=' . $memID);
4129
-}
4130 4307
 
4131 4308
 ?>
4132 4309
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Subs-Editor.php 1 patch
Braces   +409 added lines, -307 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
  * !!!Compatibility!!!
@@ -31,8 +32,9 @@  discard block
 block discarded – undo
31 32
 {
32 33
 	global $modSettings;
33 34
 
34
-	if (!$compat_mode)
35
-		return $text;
35
+	if (!$compat_mode) {
36
+			return $text;
37
+	}
36 38
 
37 39
 	// Turn line breaks back into br's.
38 40
 	$text = strtr($text, array("\r" => '', "\n" => '<br>'));
@@ -49,8 +51,9 @@  discard block
 block discarded – undo
49 51
 			for ($i = 0, $n = count($parts); $i < $n; $i++)
50 52
 			{
51 53
 				// Value of 2 means we're inside the tag.
52
-				if ($i % 4 == 2)
53
-					$parts[$i] = strtr($parts[$i], array('[' => '&#91;', ']' => '&#93;', "'" => "'"));
54
+				if ($i % 4 == 2) {
55
+									$parts[$i] = strtr($parts[$i], array('[' => '&#91;', ']' => '&#93;', "'" => "'"));
56
+				}
54 57
 			}
55 58
 			// Put our humpty dumpty message back together again.
56 59
 			$text = implode('', $parts);
@@ -109,8 +112,9 @@  discard block
 block discarded – undo
109 112
 	$text = preg_replace('~</p>\s*(?!<)~i', '</p><br>', $text);
110 113
 
111 114
 	// Safari/webkit wraps lines in Wysiwyg in <div>'s.
112
-	if (isBrowser('webkit'))
113
-		$text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text);
115
+	if (isBrowser('webkit')) {
116
+			$text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text);
117
+	}
114 118
 
115 119
 	// If there's a trailing break get rid of it - Firefox tends to add one.
116 120
 	$text = preg_replace('~<br\s?/?' . '>$~i', '', $text);
@@ -125,8 +129,9 @@  discard block
 block discarded – undo
125 129
 		for ($i = 0, $n = count($parts); $i < $n; $i++)
126 130
 		{
127 131
 			// Value of 2 means we're inside the tag.
128
-			if ($i % 4 == 2)
129
-				$parts[$i] = strip_tags($parts[$i]);
132
+			if ($i % 4 == 2) {
133
+							$parts[$i] = strip_tags($parts[$i]);
134
+			}
130 135
 		}
131 136
 
132 137
 		$text = strtr(implode('', $parts), array('#smf_br_spec_grudge_cool!#' => '<br>'));
@@ -152,18 +157,19 @@  discard block
 block discarded – undo
152 157
 			{
153 158
 				$found = array_search($file, $smileysto);
154 159
 				// Note the weirdness here is to stop double spaces between smileys.
155
-				if ($found)
156
-					$matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#';
157
-				else
158
-					$matches[1][$k] = '';
160
+				if ($found) {
161
+									$matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#';
162
+				} else {
163
+									$matches[1][$k] = '';
164
+				}
159 165
 			}
160
-		}
161
-		else
166
+		} else
162 167
 		{
163 168
 			// Load all the smileys.
164 169
 			$names = array();
165
-			foreach ($matches[1] as $file)
166
-				$names[] = $file;
170
+			foreach ($matches[1] as $file) {
171
+							$names[] = $file;
172
+			}
167 173
 			$names = array_unique($names);
168 174
 
169 175
 			if (!empty($names))
@@ -177,13 +183,15 @@  discard block
 block discarded – undo
177 183
 					)
178 184
 				);
179 185
 				$mappings = array();
180
-				while ($row = $smcFunc['db_fetch_assoc']($request))
181
-					$mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']);
186
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
187
+									$mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']);
188
+				}
182 189
 				$smcFunc['db_free_result']($request);
183 190
 
184
-				foreach ($matches[1] as $k => $file)
185
-					if (isset($mappings[$file]))
191
+				foreach ($matches[1] as $k => $file) {
192
+									if (isset($mappings[$file]))
186 193
 						$matches[1][$k] = '-[]-smf_smily_start#|#' . $mappings[$file] . '-[]-smf_smily_end#|#';
194
+				}
187 195
 			}
188 196
 		}
189 197
 
@@ -195,8 +203,9 @@  discard block
 block discarded – undo
195 203
 	}
196 204
 
197 205
 	// Only try to buy more time if the client didn't quit.
198
-	if (connection_aborted() && $context['server']['is_apache'])
199
-		@apache_reset_timeout();
206
+	if (connection_aborted() && $context['server']['is_apache']) {
207
+			@apache_reset_timeout();
208
+	}
200 209
 
201 210
 	$parts = preg_split('~(<[A-Za-z]+\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
202 211
 	$replacement = '';
@@ -207,9 +216,9 @@  discard block
 block discarded – undo
207 216
 		if (preg_match('~(<([A-Za-z]+)\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1)
208 217
 		{
209 218
 			// If it's being closed instantly, we can't deal with it...yet.
210
-			if ($matches[5] === '/')
211
-				continue;
212
-			else
219
+			if ($matches[5] === '/') {
220
+							continue;
221
+			} else
213 222
 			{
214 223
 				// Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.)
215 224
 				$styles = explode(';', strtr($matches[3], array('&quot;' => '')));
@@ -225,8 +234,9 @@  discard block
 block discarded – undo
225 234
 					$clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':'));
226 235
 
227 236
 					// Something like 'font-weight: bold' is expected here.
228
-					if (strpos($clean_type_value_pair, ':') === false)
229
-						continue;
237
+					if (strpos($clean_type_value_pair, ':') === false) {
238
+											continue;
239
+					}
230 240
 
231 241
 					// Capture the elements of a single style item (e.g. 'font-weight' and 'bold').
232 242
 					list ($style_type, $style_value) = explode(':', $type_value_pair);
@@ -248,8 +258,7 @@  discard block
 block discarded – undo
248 258
 							{
249 259
 								$curCloseTags .= '[/u]';
250 260
 								$replacement .= '[u]';
251
-							}
252
-							elseif ($style_value == 'line-through')
261
+							} elseif ($style_value == 'line-through')
253 262
 							{
254 263
 								$curCloseTags .= '[/s]';
255 264
 								$replacement .= '[s]';
@@ -261,13 +270,11 @@  discard block
 block discarded – undo
261 270
 							{
262 271
 								$curCloseTags .= '[/left]';
263 272
 								$replacement .= '[left]';
264
-							}
265
-							elseif ($style_value == 'center')
273
+							} elseif ($style_value == 'center')
266 274
 							{
267 275
 								$curCloseTags .= '[/center]';
268 276
 								$replacement .= '[center]';
269
-							}
270
-							elseif ($style_value == 'right')
277
+							} elseif ($style_value == 'right')
271 278
 							{
272 279
 								$curCloseTags .= '[/right]';
273 280
 								$replacement .= '[right]';
@@ -289,8 +296,9 @@  discard block
 block discarded – undo
289 296
 
290 297
 						case 'font-size':
291 298
 							// Sometimes people put decimals where decimals should not be.
292
-							if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1)
293
-								$style_value = $dec_matches[1] . $dec_matches[2];
299
+							if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) {
300
+															$style_value = $dec_matches[1] . $dec_matches[2];
301
+							}
294 302
 
295 303
 							$curCloseTags .= '[/size]';
296 304
 							$replacement .= '[size=' . $style_value . ']';
@@ -298,8 +306,9 @@  discard block
 block discarded – undo
298 306
 
299 307
 						case 'font-family':
300 308
 							// Only get the first freaking font if there's a list!
301
-							if (strpos($style_value, ',') !== false)
302
-								$style_value = substr($style_value, 0, strpos($style_value, ','));
309
+							if (strpos($style_value, ',') !== false) {
310
+															$style_value = substr($style_value, 0, strpos($style_value, ','));
311
+							}
303 312
 
304 313
 							$curCloseTags .= '[/font]';
305 314
 							$replacement .= '[font=' . strtr($style_value, array("'" => '')) . ']';
@@ -308,13 +317,15 @@  discard block
 block discarded – undo
308 317
 						// This is a hack for images with dimensions embedded.
309 318
 						case 'width':
310 319
 						case 'height':
311
-							if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1)
312
-								$extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"';
320
+							if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) {
321
+															$extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"';
322
+							}
313 323
 						break;
314 324
 
315 325
 						case 'list-style-type':
316
-							if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1)
317
-								$extra_attr .= ' listtype="' . $listType[0] . '"';
326
+							if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) {
327
+															$extra_attr .= ' listtype="' . $listType[0] . '"';
328
+							}
318 329
 						break;
319 330
 					}
320 331
 				}
@@ -327,18 +338,17 @@  discard block
 block discarded – undo
327 338
 				}
328 339
 
329 340
 				// If there's something that still needs closing, push it to the stack.
330
-				if (!empty($curCloseTags))
331
-					array_push($stack, array(
341
+				if (!empty($curCloseTags)) {
342
+									array_push($stack, array(
332 343
 							'element' => strtolower($curElement),
333 344
 							'closeTags' => $curCloseTags
334 345
 						)
335 346
 					);
336
-				elseif (!empty($extra_attr))
337
-					$replacement .= $precedingStyle . $extra_attr . $afterStyle;
347
+				} elseif (!empty($extra_attr)) {
348
+									$replacement .= $precedingStyle . $extra_attr . $afterStyle;
349
+				}
338 350
 			}
339
-		}
340
-
341
-		elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1)
351
+		} elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1)
342 352
 		{
343 353
 			// Is this the element that we've been waiting for to be closed?
344 354
 			if (!empty($stack) && strtolower($matches[1]) === $stack[count($stack) - 1]['element'])
@@ -348,28 +358,32 @@  discard block
 block discarded – undo
348 358
 			}
349 359
 
350 360
 			// Must've been something else.
351
-			else
352
-				$replacement .= $part;
361
+			else {
362
+							$replacement .= $part;
363
+			}
353 364
 		}
354 365
 		// In all other cases, just add the part to the replacement.
355
-		else
356
-			$replacement .= $part;
366
+		else {
367
+					$replacement .= $part;
368
+		}
357 369
 	}
358 370
 
359 371
 	// Now put back the replacement in the text.
360 372
 	$text = $replacement;
361 373
 
362 374
 	// We are not finished yet, request more time.
363
-	if (connection_aborted() && $context['server']['is_apache'])
364
-		@apache_reset_timeout();
375
+	if (connection_aborted() && $context['server']['is_apache']) {
376
+			@apache_reset_timeout();
377
+	}
365 378
 
366 379
 	// Let's pull out any legacy alignments.
367 380
 	while (preg_match('~<([A-Za-z]+)\s+[^<>]*?(align="*(left|center|right)"*)[^<>]*?(/?)>~i', $text, $matches) === 1)
368 381
 	{
369 382
 		// Find the position in the text of this tag over again.
370 383
 		$start_pos = strpos($text, $matches[0]);
371
-		if ($start_pos === false)
372
-			break;
384
+		if ($start_pos === false) {
385
+					break;
386
+		}
373 387
 
374 388
 		// End tag?
375 389
 		if ($matches[4] != '/' && strpos($text, '</' . $matches[1] . '>', $start_pos) !== false)
@@ -383,8 +397,7 @@  discard block
 block discarded – undo
383 397
 
384 398
 			// Put the tags back into the body.
385 399
 			$text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos);
386
-		}
387
-		else
400
+		} else
388 401
 		{
389 402
 			// Just get rid of this evil tag.
390 403
 			$text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0]));
@@ -397,8 +410,9 @@  discard block
 block discarded – undo
397 410
 		// Find the position of this again.
398 411
 		$start_pos = strpos($text, $matches[0]);
399 412
 		$end_pos = false;
400
-		if ($start_pos === false)
401
-			break;
413
+		if ($start_pos === false) {
414
+					break;
415
+		}
402 416
 
403 417
 		// This must have an end tag - and we must find the right one.
404 418
 		$lower_text = strtolower($text);
@@ -431,8 +445,9 @@  discard block
 block discarded – undo
431 445
 				break;
432 446
 			}
433 447
 		}
434
-		if ($end_pos === false)
435
-			break;
448
+		if ($end_pos === false) {
449
+					break;
450
+		}
436 451
 
437 452
 		// Now work out what the attributes are.
438 453
 		$attribs = fetchTagAttributes($matches[1]);
@@ -446,11 +461,11 @@  discard block
 block discarded – undo
446 461
 				$v = (int) trim($v);
447 462
 				$v = empty($v) ? 1 : $v;
448 463
 				$tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]');
464
+			} elseif ($s == 'face') {
465
+							$tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]');
466
+			} elseif ($s == 'color') {
467
+							$tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]');
449 468
 			}
450
-			elseif ($s == 'face')
451
-				$tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]');
452
-			elseif ($s == 'color')
453
-				$tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]');
454 469
 		}
455 470
 
456 471
 		// As before add in our tags.
@@ -458,8 +473,9 @@  discard block
 block discarded – undo
458 473
 		foreach ($tags as $tag)
459 474
 		{
460 475
 			$before .= $tag[0];
461
-			if (isset($tag[1]))
462
-				$after = $tag[1] . $after;
476
+			if (isset($tag[1])) {
477
+							$after = $tag[1] . $after;
478
+			}
463 479
 		}
464 480
 
465 481
 		// Remove the tag so it's never checked again.
@@ -470,8 +486,9 @@  discard block
 block discarded – undo
470 486
 	}
471 487
 
472 488
 	// Almost there, just a little more time.
473
-	if (connection_aborted() && $context['server']['is_apache'])
474
-		@apache_reset_timeout();
489
+	if (connection_aborted() && $context['server']['is_apache']) {
490
+			@apache_reset_timeout();
491
+	}
475 492
 
476 493
 	if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1)
477 494
 	{
@@ -527,12 +544,13 @@  discard block
 block discarded – undo
527 544
 						{
528 545
 							$inList = true;
529 546
 
530
-							if ($tag === 'ol')
531
-								$listType = 'decimal';
532
-							elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1)
533
-								$listType = $listTypeMapping[$match[1]];
534
-							else
535
-								$listType = null;
547
+							if ($tag === 'ol') {
548
+															$listType = 'decimal';
549
+							} elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) {
550
+															$listType = $listTypeMapping[$match[1]];
551
+							} else {
552
+															$listType = null;
553
+							}
536 554
 
537 555
 							$listDepth++;
538 556
 
@@ -596,9 +614,7 @@  discard block
 block discarded – undo
596 614
 							$parts[$i + 1] = '';
597 615
 							$parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]';
598 616
 							$parts[$i + 3] = '';
599
-						}
600
-
601
-						else
617
+						} else
602 618
 						{
603 619
 							// We're in a list item.
604 620
 							if ($listDepth > 0)
@@ -635,9 +651,7 @@  discard block
 block discarded – undo
635 651
 							$parts[$i + 1] = '';
636 652
 							$parts[$i + 2] = '';
637 653
 							$parts[$i + 3] = '';
638
-						}
639
-
640
-						else
654
+						} else
641 655
 						{
642 656
 							// Remove the trailing breaks from the list item.
643 657
 							$parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]);
@@ -675,8 +689,9 @@  discard block
 block discarded – undo
675 689
 			$text .= str_repeat("\t", $listDepth) . '[/list]';
676 690
 		}
677 691
 
678
-		for ($i = $listDepth; $i > 0; $i--)
679
-			$text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]';
692
+		for ($i = $listDepth; $i > 0; $i--) {
693
+					$text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]';
694
+		}
680 695
 	}
681 696
 
682 697
 	// I love my own image...
@@ -684,8 +699,9 @@  discard block
 block discarded – undo
684 699
 	{
685 700
 		// Find the position of the image.
686 701
 		$start_pos = strpos($text, $matches[0]);
687
-		if ($start_pos === false)
688
-			break;
702
+		if ($start_pos === false) {
703
+					break;
704
+		}
689 705
 		$end_pos = $start_pos + strlen($matches[0]);
690 706
 
691 707
 		$params = '';
@@ -694,12 +710,13 @@  discard block
 block discarded – undo
694 710
 		$attrs = fetchTagAttributes($matches[1]);
695 711
 		foreach ($attrs as $attrib => $value)
696 712
 		{
697
-			if (in_array($attrib, array('width', 'height')))
698
-				$params .= ' ' . $attrib . '=' . (int) $value;
699
-			elseif ($attrib == 'alt' && trim($value) != '')
700
-				$params .= ' alt=' . trim($value);
701
-			elseif ($attrib == 'src')
702
-				$src = trim($value);
713
+			if (in_array($attrib, array('width', 'height'))) {
714
+							$params .= ' ' . $attrib . '=' . (int) $value;
715
+			} elseif ($attrib == 'alt' && trim($value) != '') {
716
+							$params .= ' alt=' . trim($value);
717
+			} elseif ($attrib == 'src') {
718
+							$src = trim($value);
719
+			}
703 720
 		}
704 721
 
705 722
 		$tag = '';
@@ -710,10 +727,11 @@  discard block
 block discarded – undo
710 727
 			{
711 728
 				$baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']);
712 729
 
713
-				if (substr($src, 0, 1) === '/')
714
-					$src = $baseURL . $src;
715
-				else
716
-					$src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src;
730
+				if (substr($src, 0, 1) === '/') {
731
+									$src = $baseURL . $src;
732
+				} else {
733
+									$src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src;
734
+				}
717 735
 			}
718 736
 
719 737
 			$tag = '[img' . $params . ']' . $src . '[/img]';
@@ -891,20 +909,23 @@  discard block
 block discarded – undo
891 909
 		},
892 910
 	);
893 911
 
894
-	foreach ($tags as $tag => $replace)
895
-		$text = preg_replace_callback($tag, $replace, $text);
912
+	foreach ($tags as $tag => $replace) {
913
+			$text = preg_replace_callback($tag, $replace, $text);
914
+	}
896 915
 
897 916
 	// Please give us just a little more time.
898
-	if (connection_aborted() && $context['server']['is_apache'])
899
-		@apache_reset_timeout();
917
+	if (connection_aborted() && $context['server']['is_apache']) {
918
+			@apache_reset_timeout();
919
+	}
900 920
 
901 921
 	// What about URL's - the pain in the ass of the tag world.
902 922
 	while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1)
903 923
 	{
904 924
 		// Find the position of the URL.
905 925
 		$start_pos = strpos($text, $matches[0]);
906
-		if ($start_pos === false)
907
-			break;
926
+		if ($start_pos === false) {
927
+					break;
928
+		}
908 929
 		$end_pos = $start_pos + strlen($matches[0]);
909 930
 
910 931
 		$tag_type = 'url';
@@ -918,8 +939,9 @@  discard block
 block discarded – undo
918 939
 				$href = trim($value);
919 940
 
920 941
 				// Are we dealing with an FTP link?
921
-				if (preg_match('~^ftps?://~', $href) === 1)
922
-					$tag_type = 'ftp';
942
+				if (preg_match('~^ftps?://~', $href) === 1) {
943
+									$tag_type = 'ftp';
944
+				}
923 945
 
924 946
 				// Or is this a link to an email address?
925 947
 				elseif (substr($href, 0, 7) == 'mailto:')
@@ -933,28 +955,31 @@  discard block
 block discarded – undo
933 955
 				{
934 956
 					$baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']);
935 957
 
936
-					if (substr($href, 0, 1) === '/')
937
-						$href = $baseURL . $href;
938
-					else
939
-						$href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href;
958
+					if (substr($href, 0, 1) === '/') {
959
+											$href = $baseURL . $href;
960
+					} else {
961
+											$href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href;
962
+					}
940 963
 				}
941 964
 			}
942 965
 
943 966
 			// External URL?
944 967
 			if ($attrib == 'target' && $tag_type == 'url')
945 968
 			{
946
-				if (trim($value) == '_blank')
947
-					$tag_type == 'iurl';
969
+				if (trim($value) == '_blank') {
970
+									$tag_type == 'iurl';
971
+				}
948 972
 			}
949 973
 		}
950 974
 
951 975
 		$tag = '';
952 976
 		if ($href != '')
953 977
 		{
954
-			if ($matches[2] == $href)
955
-				$tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']';
956
-			else
957
-				$tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']';
978
+			if ($matches[2] == $href) {
979
+							$tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']';
980
+			} else {
981
+							$tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']';
982
+			}
958 983
 		}
959 984
 
960 985
 		// Replace the tag
@@ -994,17 +1019,18 @@  discard block
 block discarded – undo
994 1019
 		// We're either moving from the key to the attribute or we're in a string and this is fine.
995 1020
 		if ($text[$i] == '=')
996 1021
 		{
997
-			if ($tag_state == 0)
998
-				$tag_state = 1;
999
-			elseif ($tag_state == 2)
1000
-				$value .= '=';
1022
+			if ($tag_state == 0) {
1023
+							$tag_state = 1;
1024
+			} elseif ($tag_state == 2) {
1025
+							$value .= '=';
1026
+			}
1001 1027
 		}
1002 1028
 		// A space is either moving from an attribute back to a potential key or in a string is fine.
1003 1029
 		elseif ($text[$i] == ' ')
1004 1030
 		{
1005
-			if ($tag_state == 2)
1006
-				$value .= ' ';
1007
-			elseif ($tag_state == 1)
1031
+			if ($tag_state == 2) {
1032
+							$value .= ' ';
1033
+			} elseif ($tag_state == 1)
1008 1034
 			{
1009 1035
 				$attribs[$key] = $value;
1010 1036
 				$key = $value = '';
@@ -1015,24 +1041,27 @@  discard block
 block discarded – undo
1015 1041
 		elseif ($text[$i] == '"')
1016 1042
 		{
1017 1043
 			// Must be either going into or out of a string.
1018
-			if ($tag_state == 1)
1019
-				$tag_state = 2;
1020
-			else
1021
-				$tag_state = 1;
1044
+			if ($tag_state == 1) {
1045
+							$tag_state = 2;
1046
+			} else {
1047
+							$tag_state = 1;
1048
+			}
1022 1049
 		}
1023 1050
 		// Otherwise it's fine.
1024 1051
 		else
1025 1052
 		{
1026
-			if ($tag_state == 0)
1027
-				$key .= $text[$i];
1028
-			else
1029
-				$value .= $text[$i];
1053
+			if ($tag_state == 0) {
1054
+							$key .= $text[$i];
1055
+			} else {
1056
+							$value .= $text[$i];
1057
+			}
1030 1058
 		}
1031 1059
 	}
1032 1060
 
1033 1061
 	// Anything left?
1034
-	if ($key != '' && $value != '')
1035
-		$attribs[$key] = $value;
1062
+	if ($key != '' && $value != '') {
1063
+			$attribs[$key] = $value;
1064
+	}
1036 1065
 
1037 1066
 	return $attribs;
1038 1067
 }
@@ -1050,15 +1079,17 @@  discard block
 block discarded – undo
1050 1079
 	global $modSettings;
1051 1080
 
1052 1081
 	// Don't care about the texts that are too short.
1053
-	if (strlen($text) < 3)
1054
-		return $text;
1082
+	if (strlen($text) < 3) {
1083
+			return $text;
1084
+	}
1055 1085
 
1056 1086
 	// A list of tags that's disabled by the admin.
1057 1087
 	$disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC'])));
1058 1088
 
1059 1089
 	// Add flash if it's disabled as embedded tag.
1060
-	if (empty($modSettings['enableEmbeddedFlash']))
1061
-		$disabled['flash'] = true;
1090
+	if (empty($modSettings['enableEmbeddedFlash'])) {
1091
+			$disabled['flash'] = true;
1092
+	}
1062 1093
 
1063 1094
 	// Get a list of all the tags that are not disabled.
1064 1095
 	$all_tags = parse_bbc(false);
@@ -1066,10 +1097,12 @@  discard block
 block discarded – undo
1066 1097
 	$self_closing_tags = array();
1067 1098
 	foreach ($all_tags as $tag)
1068 1099
 	{
1069
-		if (!isset($disabled[$tag['tag']]))
1070
-			$valid_tags[$tag['tag']] = !empty($tag['block_level']);
1071
-		if (isset($tag['type']) && $tag['type'] == 'closed')
1072
-			$self_closing_tags[] = $tag['tag'];
1100
+		if (!isset($disabled[$tag['tag']])) {
1101
+					$valid_tags[$tag['tag']] = !empty($tag['block_level']);
1102
+		}
1103
+		if (isset($tag['type']) && $tag['type'] == 'closed') {
1104
+					$self_closing_tags[] = $tag['tag'];
1105
+		}
1073 1106
 	}
1074 1107
 
1075 1108
 	// Right - we're going to start by going through the whole lot to make sure we don't have align stuff crossed as this happens load and is stupid!
@@ -1096,16 +1129,19 @@  discard block
 block discarded – undo
1096 1129
 				$tagName = substr($match, $isClosingTag ? 2 : 1, -1);
1097 1130
 
1098 1131
 				// We're closing the exact same tag that we opened.
1099
-				if ($isClosingTag && $insideTag === $tagName)
1100
-					$insideTag = null;
1132
+				if ($isClosingTag && $insideTag === $tagName) {
1133
+									$insideTag = null;
1134
+				}
1101 1135
 
1102 1136
 				// We're opening a tag and we're not yet inside one either
1103
-				elseif (!$isClosingTag && $insideTag === null)
1104
-					$insideTag = $tagName;
1137
+				elseif (!$isClosingTag && $insideTag === null) {
1138
+									$insideTag = $tagName;
1139
+				}
1105 1140
 
1106 1141
 				// In all other cases, this tag must be invalid
1107
-				else
1108
-					unset($matches[$i]);
1142
+				else {
1143
+									unset($matches[$i]);
1144
+				}
1109 1145
 			}
1110 1146
 
1111 1147
 			// The next one is gonna be the other one.
@@ -1113,8 +1149,9 @@  discard block
 block discarded – undo
1113 1149
 		}
1114 1150
 
1115 1151
 		// We're still inside a tag and had no chance for closure?
1116
-		if ($insideTag !== null)
1117
-			$matches[] = '[/' . $insideTag . ']';
1152
+		if ($insideTag !== null) {
1153
+					$matches[] = '[/' . $insideTag . ']';
1154
+		}
1118 1155
 
1119 1156
 		// And a complete text string again.
1120 1157
 		$text = implode('', $matches);
@@ -1123,8 +1160,9 @@  discard block
 block discarded – undo
1123 1160
 	// Quickly remove any tags which are back to back.
1124 1161
 	$backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~';
1125 1162
 	$lastlen = 0;
1126
-	while (strlen($text) !== $lastlen)
1127
-		$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1163
+	while (strlen($text) !== $lastlen) {
1164
+			$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1165
+	}
1128 1166
 
1129 1167
 	// Need to sort the tags my name length.
1130 1168
 	uksort($valid_tags, 'sort_array_length');
@@ -1161,8 +1199,9 @@  discard block
 block discarded – undo
1161 1199
 			$isCompetingTag = in_array($tag, $competing_tags);
1162 1200
 
1163 1201
 			// Check if this might be one of those cleaned out tags.
1164
-			if ($tag === '')
1165
-				continue;
1202
+			if ($tag === '') {
1203
+							continue;
1204
+			}
1166 1205
 
1167 1206
 			// Special case: inside [code] blocks any code is left untouched.
1168 1207
 			elseif ($tag === 'code')
@@ -1173,8 +1212,9 @@  discard block
 block discarded – undo
1173 1212
 					$inCode = false;
1174 1213
 
1175 1214
 					// Reopen tags that were closed before the code block.
1176
-					if (!empty($inlineElements))
1177
-						$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1215
+					if (!empty($inlineElements)) {
1216
+											$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1217
+					}
1178 1218
 				}
1179 1219
 
1180 1220
 				// We're outside a coding and nobbc block and opening it.
@@ -1203,8 +1243,9 @@  discard block
 block discarded – undo
1203 1243
 					$inNoBbc = false;
1204 1244
 
1205 1245
 					// Some inline elements might've been closed that need reopening.
1206
-					if (!empty($inlineElements))
1207
-						$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1246
+					if (!empty($inlineElements)) {
1247
+											$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1248
+					}
1208 1249
 				}
1209 1250
 
1210 1251
 				// We're outside a nobbc and coding block and opening it.
@@ -1224,8 +1265,9 @@  discard block
 block discarded – undo
1224 1265
 			}
1225 1266
 
1226 1267
 			// So, we're inside one of the special blocks: ignore any tag.
1227
-			elseif ($inCode || $inNoBbc)
1228
-				continue;
1268
+			elseif ($inCode || $inNoBbc) {
1269
+							continue;
1270
+			}
1229 1271
 
1230 1272
 			// We're dealing with an opening tag.
1231 1273
 			if ($isOpeningTag)
@@ -1266,8 +1308,9 @@  discard block
 block discarded – undo
1266 1308
 							if ($parts[$j + 3] === $tag)
1267 1309
 							{
1268 1310
 								// If it's an opening tag, increase the level.
1269
-								if ($parts[$j + 2] === '')
1270
-									$curLevel++;
1311
+								if ($parts[$j + 2] === '') {
1312
+																	$curLevel++;
1313
+								}
1271 1314
 
1272 1315
 								// A closing tag, decrease the level.
1273 1316
 								else
@@ -1290,13 +1333,15 @@  discard block
 block discarded – undo
1290 1333
 					{
1291 1334
 						if ($isCompetingTag)
1292 1335
 						{
1293
-							if (!isset($competingElements[$tag]))
1294
-								$competingElements[$tag] = array();
1336
+							if (!isset($competingElements[$tag])) {
1337
+															$competingElements[$tag] = array();
1338
+							}
1295 1339
 
1296 1340
 							$competingElements[$tag][] = $parts[$i + 4];
1297 1341
 
1298
-							if (count($competingElements[$tag]) > 1)
1299
-								$parts[$i] .= '[/' . $tag . ']';
1342
+							if (count($competingElements[$tag]) > 1) {
1343
+															$parts[$i] .= '[/' . $tag . ']';
1344
+							}
1300 1345
 						}
1301 1346
 
1302 1347
 						$inlineElements[$elementContent] = $tag;
@@ -1316,15 +1361,17 @@  discard block
 block discarded – undo
1316 1361
 						$addClosingTags = array();
1317 1362
 						while ($element = array_pop($blockElements))
1318 1363
 						{
1319
-							if ($element === $tag)
1320
-								break;
1364
+							if ($element === $tag) {
1365
+															break;
1366
+							}
1321 1367
 
1322 1368
 							// Still a block tag was open not equal to this tag.
1323 1369
 							$addClosingTags[] = $element['type'];
1324 1370
 						}
1325 1371
 
1326
-						if (!empty($addClosingTags))
1327
-							$parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1];
1372
+						if (!empty($addClosingTags)) {
1373
+													$parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1];
1374
+						}
1328 1375
 
1329 1376
 						// Apparently the closing tag was not found on the stack.
1330 1377
 						if (!is_string($element) || $element !== $tag)
@@ -1334,8 +1381,7 @@  discard block
 block discarded – undo
1334 1381
 							$parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1335 1382
 							continue;
1336 1383
 						}
1337
-					}
1338
-					else
1384
+					} else
1339 1385
 					{
1340 1386
 						// Get rid of this closing tag!
1341 1387
 						$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
@@ -1364,53 +1410,62 @@  discard block
 block discarded – undo
1364 1410
 							unset($inlineElements[$tagContentToBeClosed]);
1365 1411
 
1366 1412
 							// Was this the tag we were looking for?
1367
-							if ($tagToBeClosed === $tag)
1368
-								break;
1413
+							if ($tagToBeClosed === $tag) {
1414
+															break;
1415
+							}
1369 1416
 
1370 1417
 							// Nope, close it and look further!
1371
-							else
1372
-								$parts[$i] .= '[/' . $tagToBeClosed . ']';
1418
+							else {
1419
+															$parts[$i] .= '[/' . $tagToBeClosed . ']';
1420
+							}
1373 1421
 						}
1374 1422
 
1375 1423
 						if ($isCompetingTag && !empty($competingElements[$tag]))
1376 1424
 						{
1377 1425
 							array_pop($competingElements[$tag]);
1378 1426
 
1379
-							if (count($competingElements[$tag]) > 0)
1380
-								$parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5];
1427
+							if (count($competingElements[$tag]) > 0) {
1428
+															$parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5];
1429
+							}
1381 1430
 						}
1382 1431
 					}
1383 1432
 
1384 1433
 					// Unexpected closing tag, ex-ter-mi-nate.
1385
-					else
1386
-						$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1434
+					else {
1435
+											$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1436
+					}
1387 1437
 				}
1388 1438
 			}
1389 1439
 		}
1390 1440
 
1391 1441
 		// Close the code tags.
1392
-		if ($inCode)
1393
-			$parts[$i] .= '[/code]';
1442
+		if ($inCode) {
1443
+					$parts[$i] .= '[/code]';
1444
+		}
1394 1445
 
1395 1446
 		// The same for nobbc tags.
1396
-		elseif ($inNoBbc)
1397
-			$parts[$i] .= '[/nobbc]';
1447
+		elseif ($inNoBbc) {
1448
+					$parts[$i] .= '[/nobbc]';
1449
+		}
1398 1450
 
1399 1451
 		// Still inline tags left unclosed? Close them now, better late than never.
1400
-		elseif (!empty($inlineElements))
1401
-			$parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']';
1452
+		elseif (!empty($inlineElements)) {
1453
+					$parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']';
1454
+		}
1402 1455
 
1403 1456
 		// Now close the block elements.
1404
-		if (!empty($blockElements))
1405
-			$parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']';
1457
+		if (!empty($blockElements)) {
1458
+					$parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']';
1459
+		}
1406 1460
 
1407 1461
 		$text = implode('', $parts);
1408 1462
 	}
1409 1463
 
1410 1464
 	// Final clean up of back to back tags.
1411 1465
 	$lastlen = 0;
1412
-	while (strlen($text) !== $lastlen)
1413
-		$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1466
+	while (strlen($text) !== $lastlen) {
1467
+			$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1468
+	}
1414 1469
 
1415 1470
 	return $text;
1416 1471
 }
@@ -1441,22 +1496,25 @@  discard block
 block discarded – undo
1441 1496
 	$context['template_layers'] = array();
1442 1497
 	// Lets make sure we aren't going to output anything nasty.
1443 1498
 	@ob_end_clean();
1444
-	if (!empty($modSettings['enableCompressedOutput']))
1445
-		@ob_start('ob_gzhandler');
1446
-	else
1447
-		@ob_start();
1499
+	if (!empty($modSettings['enableCompressedOutput'])) {
1500
+			@ob_start('ob_gzhandler');
1501
+	} else {
1502
+			@ob_start();
1503
+	}
1448 1504
 
1449 1505
 	// If we don't have any locale better avoid broken js
1450
-	if (empty($txt['lang_locale']))
1451
-		die();
1506
+	if (empty($txt['lang_locale'])) {
1507
+			die();
1508
+	}
1452 1509
 
1453 1510
 	$file_data = '(function ($) {
1454 1511
 	\'use strict\';
1455 1512
 
1456 1513
 	$.sceditor.locale[' . JavaScriptEscape($txt['lang_locale']) . '] = {';
1457
-	foreach ($editortxt as $key => $val)
1458
-		$file_data .= '
1514
+	foreach ($editortxt as $key => $val) {
1515
+			$file_data .= '
1459 1516
 		' . JavaScriptEscape($key) . ': ' . JavaScriptEscape($val) . ',';
1517
+	}
1460 1518
 
1461 1519
 	$file_data .= '
1462 1520
 		dateFormat: "day.month.year"
@@ -1524,8 +1582,9 @@  discard block
 block discarded – undo
1524 1582
 				)
1525 1583
 			);
1526 1584
 			$icon_data = array();
1527
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1528
-				$icon_data[] = $row;
1585
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1586
+							$icon_data[] = $row;
1587
+			}
1529 1588
 			$smcFunc['db_free_result']($request);
1530 1589
 
1531 1590
 			$icons = array();
@@ -1540,9 +1599,9 @@  discard block
 block discarded – undo
1540 1599
 			}
1541 1600
 
1542 1601
 			cache_put_data('posting_icons-' . $board_id, $icons, 480);
1602
+		} else {
1603
+					$icons = $temp;
1543 1604
 		}
1544
-		else
1545
-			$icons = $temp;
1546 1605
 	}
1547 1606
 	call_integration_hook('integrate_load_message_icons', array(&$icons));
1548 1607
 
@@ -1585,8 +1644,9 @@  discard block
 block discarded – undo
1585 1644
 	{
1586 1645
 		// Some general stuff.
1587 1646
 		$settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set'];
1588
-		if (!empty($context['drafts_autosave']))
1589
-			$context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000;
1647
+		if (!empty($context['drafts_autosave'])) {
1648
+					$context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000;
1649
+		}
1590 1650
 
1591 1651
 		// This really has some WYSIWYG stuff.
1592 1652
 		loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor');
@@ -1603,8 +1663,9 @@  discard block
 block discarded – undo
1603 1663
 		var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\';
1604 1664
 		var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';');
1605 1665
 		// editor language file
1606
-		if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US')
1607
-			loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language');
1666
+		if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') {
1667
+					loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language');
1668
+		}
1608 1669
 
1609 1670
 		$context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (stripos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== false ? '_mac' : (isBrowser('is_firefox') ? '_firefox' : ''))];
1610 1671
 		$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_character_set'] == 'UTF-8' || function_exists('iconv'))));
@@ -1613,11 +1674,12 @@  discard block
 block discarded – undo
1613 1674
 			loadJavaScriptFile('spellcheck.js', array('minimize' => true), 'smf_spellcheck');
1614 1675
 
1615 1676
 			// Some hidden information is needed in order to make the spell checking work.
1616
-			if (!isset($_REQUEST['xml']))
1617
-				$context['insert_after_template'] .= '
1677
+			if (!isset($_REQUEST['xml'])) {
1678
+							$context['insert_after_template'] .= '
1618 1679
 		<form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck">
1619 1680
 			<input type="hidden" name="spellstring" value="">
1620 1681
 		</form>';
1682
+			}
1621 1683
 		}
1622 1684
 	}
1623 1685
 
@@ -1809,10 +1871,12 @@  discard block
 block discarded – undo
1809 1871
 
1810 1872
 		// Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this.
1811 1873
 		$disabled_tags = array();
1812
-		if (!empty($modSettings['disabledBBC']))
1813
-			$disabled_tags = explode(',', $modSettings['disabledBBC']);
1814
-		if (empty($modSettings['enableEmbeddedFlash']))
1815
-			$disabled_tags[] = 'flash';
1874
+		if (!empty($modSettings['disabledBBC'])) {
1875
+					$disabled_tags = explode(',', $modSettings['disabledBBC']);
1876
+		}
1877
+		if (empty($modSettings['enableEmbeddedFlash'])) {
1878
+					$disabled_tags[] = 'flash';
1879
+		}
1816 1880
 
1817 1881
 		foreach ($disabled_tags as $tag)
1818 1882
 		{
@@ -1824,9 +1888,10 @@  discard block
 block discarded – undo
1824 1888
 				$context['disabled_tags']['orderedlist'] = true;
1825 1889
 			}
1826 1890
 
1827
-			foreach ($editor_tag_map as $thisTag => $tagNameBBC)
1828
-				if ($tag === $thisTag)
1891
+			foreach ($editor_tag_map as $thisTag => $tagNameBBC) {
1892
+							if ($tag === $thisTag)
1829 1893
 					$context['disabled_tags'][$tagNameBBC] = true;
1894
+			}
1830 1895
 
1831 1896
 			$context['disabled_tags'][$tag] = true;
1832 1897
 		}
@@ -1837,8 +1902,9 @@  discard block
 block discarded – undo
1837 1902
 
1838 1903
 		foreach ($context['bbc_tags'] as $row => $tagRow)
1839 1904
 		{
1840
-			if (!isset($context['bbc_toolbar'][$row]))
1841
-				$context['bbc_toolbar'][$row] = array();
1905
+			if (!isset($context['bbc_toolbar'][$row])) {
1906
+							$context['bbc_toolbar'][$row] = array();
1907
+			}
1842 1908
 
1843 1909
 			$tagsRow = array();
1844 1910
 
@@ -1874,20 +1940,21 @@  discard block
 block discarded – undo
1874 1940
 
1875 1941
 					$context['bbcodes_handlers'] .= '
1876 1942
 						});';
1877
-				}
1878
-				else
1943
+				} else
1879 1944
 				{
1880 1945
 					$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1881 1946
 					$tagsRow = array();
1882 1947
 				}
1883 1948
 			}
1884 1949
 
1885
-			if (!empty($tagsRow))
1886
-				$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1950
+			if (!empty($tagsRow)) {
1951
+							$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1952
+			}
1887 1953
 		}
1888 1954
 
1889
-		if (!empty($bbcodes_styles))
1890
-			addInlineCss($bbcodes_styles);
1955
+		if (!empty($bbcodes_styles)) {
1956
+					addInlineCss($bbcodes_styles);
1957
+		}
1891 1958
 	}
1892 1959
 
1893 1960
 	// Initialize smiley array... if not loaded before.
@@ -1899,8 +1966,8 @@  discard block
 block discarded – undo
1899 1966
 		);
1900 1967
 
1901 1968
 		// Load smileys - don't bother to run a query if we're not using the database's ones anyhow.
1902
-		if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none')
1903
-			$context['smileys']['postform'][] = array(
1969
+		if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') {
1970
+					$context['smileys']['postform'][] = array(
1904 1971
 				'smileys' => array(
1905 1972
 					array(
1906 1973
 						'code' => ':)',
@@ -1986,7 +2053,7 @@  discard block
 block discarded – undo
1986 2053
 				),
1987 2054
 				'isLast' => true,
1988 2055
 			);
1989
-		elseif ($user_info['smiley_set'] != 'none')
2056
+		} elseif ($user_info['smiley_set'] != 'none')
1990 2057
 		{
1991 2058
 			if (($temp = cache_get_data('posting_smileys', 480)) == null)
1992 2059
 			{
@@ -2009,17 +2076,19 @@  discard block
 block discarded – undo
2009 2076
 
2010 2077
 				foreach ($context['smileys'] as $section => $smileyRows)
2011 2078
 				{
2012
-					foreach ($smileyRows as $rowIndex => $smileys)
2013
-						$context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
2079
+					foreach ($smileyRows as $rowIndex => $smileys) {
2080
+											$context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
2081
+					}
2014 2082
 
2015
-					if (!empty($smileyRows))
2016
-						$context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
2083
+					if (!empty($smileyRows)) {
2084
+											$context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
2085
+					}
2017 2086
 				}
2018 2087
 
2019 2088
 				cache_put_data('posting_smileys', $context['smileys'], 480);
2089
+			} else {
2090
+							$context['smileys'] = $temp;
2020 2091
 			}
2021
-			else
2022
-				$context['smileys'] = $temp;
2023 2092
 		}
2024 2093
 	}
2025 2094
 
@@ -2035,12 +2104,15 @@  discard block
 block discarded – undo
2035 2104
 		'plugins' => 'undo',
2036 2105
 		'bbcodeTrim' => true,
2037 2106
 	);
2038
-	if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale']))
2039
-		$sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale'];
2040
-	if (!empty($context['right_to_left']))
2041
-		$sce_options['rtl'] = true;
2042
-	if ($editorOptions['id'] != 'quickReply')
2043
-		$sce_options['autofocus'] = true;
2107
+	if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale'])) {
2108
+			$sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale'];
2109
+	}
2110
+	if (!empty($context['right_to_left'])) {
2111
+			$sce_options['rtl'] = true;
2112
+	}
2113
+	if ($editorOptions['id'] != 'quickReply') {
2114
+			$sce_options['autofocus'] = true;
2115
+	}
2044 2116
 
2045 2117
 	$sce_options['emoticons'] = array();
2046 2118
 	$sce_options['emoticonsDescriptions'] = array();
@@ -2057,10 +2129,11 @@  discard block
 block discarded – undo
2057 2129
 			$countLocations--;
2058 2130
 
2059 2131
 			unset($smiley_location);
2060
-			if ($location == 'postform')
2061
-				$smiley_location = &$sce_options['emoticons']['dropdown'];
2062
-			elseif ($location == 'popup')
2063
-				$smiley_location = &$sce_options['emoticons']['popup'];
2132
+			if ($location == 'postform') {
2133
+							$smiley_location = &$sce_options['emoticons']['dropdown'];
2134
+			} elseif ($location == 'popup') {
2135
+							$smiley_location = &$sce_options['emoticons']['popup'];
2136
+			}
2064 2137
 
2065 2138
 			$numRows = count($smileyRows);
2066 2139
 
@@ -2074,8 +2147,9 @@  discard block
 block discarded – undo
2074 2147
 					$sce_options['emoticonsDescriptions'][$smiley['code']] = $smiley['description'];
2075 2148
 				}
2076 2149
 
2077
-				if (empty($smileyRow['isLast']) && $numRows != 1)
2078
-					$smiley_location['-' . $emptyPlaceholder++] = '';
2150
+				if (empty($smileyRow['isLast']) && $numRows != 1) {
2151
+									$smiley_location['-' . $emptyPlaceholder++] = '';
2152
+				}
2079 2153
 			}
2080 2154
 		}
2081 2155
 	}
@@ -2090,8 +2164,9 @@  discard block
 block discarded – undo
2090 2164
 
2091 2165
 			$count_tags--;
2092 2166
 
2093
-			if (!empty($count_tags))
2094
-				$sce_options['toolbar'] .= '||';
2167
+			if (!empty($count_tags)) {
2168
+							$sce_options['toolbar'] .= '||';
2169
+			}
2095 2170
 		}
2096 2171
 	}
2097 2172
 
@@ -2119,8 +2194,9 @@  discard block
 block discarded – undo
2119 2194
 		loadTemplate('GenericControls');
2120 2195
 
2121 2196
 		// Some javascript ma'am?
2122
-		if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])))
2123
-			loadJavaScriptFile('captcha.js', array('minimize' => true), 'smf_captcha');
2197
+		if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) {
2198
+					loadJavaScriptFile('captcha.js', array('minimize' => true), 'smf_captcha');
2199
+		}
2124 2200
 
2125 2201
 		$context['use_graphic_library'] = in_array('gd', get_loaded_extensions());
2126 2202
 
@@ -2133,8 +2209,8 @@  discard block
 block discarded – undo
2133 2209
 	$isNew = !isset($context['controls']['verification'][$verificationOptions['id']]);
2134 2210
 
2135 2211
 	// Log this into our collection.
2136
-	if ($isNew)
2137
-		$context['controls']['verification'][$verificationOptions['id']] = array(
2212
+	if ($isNew) {
2213
+			$context['controls']['verification'][$verificationOptions['id']] = array(
2138 2214
 			'id' => $verificationOptions['id'],
2139 2215
 			'empty_field' => empty($verificationOptions['no_empty_field']),
2140 2216
 			'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])),
@@ -2145,13 +2221,15 @@  discard block
 block discarded – undo
2145 2221
 			'questions' => array(),
2146 2222
 			'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']),
2147 2223
 		);
2224
+	}
2148 2225
 	$thisVerification = &$context['controls']['verification'][$verificationOptions['id']];
2149 2226
 
2150 2227
 	// Is there actually going to be anything?
2151
-	if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha']))
2152
-		return false;
2153
-	elseif (!$isNew && !$do_test)
2154
-		return true;
2228
+	if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) {
2229
+			return false;
2230
+	} elseif (!$isNew && !$do_test) {
2231
+			return true;
2232
+	}
2155 2233
 
2156 2234
 	// Sanitize reCAPTCHA fields?
2157 2235
 	if ($thisVerification['can_recaptcha'])
@@ -2164,11 +2242,12 @@  discard block
 block discarded – undo
2164 2242
 	}
2165 2243
 
2166 2244
 	// Add javascript for the object.
2167
-	if ($context['controls']['verification'][$verificationOptions['id']]['show_visual'])
2168
-		$context['insert_after_template'] .= '
2245
+	if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) {
2246
+			$context['insert_after_template'] .= '
2169 2247
 			<script>
2170 2248
 				var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . ');
2171 2249
 			</script>';
2250
+	}
2172 2251
 
2173 2252
 	// If we want questions do we have a cache of all the IDs?
2174 2253
 	if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache']))
@@ -2191,8 +2270,9 @@  discard block
 block discarded – undo
2191 2270
 				unset ($row['id_question']);
2192 2271
 				// Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh?
2193 2272
 				$row['answers'] = $smcFunc['json_decode']($row['answers'], true);
2194
-				foreach ($row['answers'] as $k => $v)
2195
-					$row['answers'][$k] = $smcFunc['strtolower']($v);
2273
+				foreach ($row['answers'] as $k => $v) {
2274
+									$row['answers'][$k] = $smcFunc['strtolower']($v);
2275
+				}
2196 2276
 
2197 2277
 				$modSettings['question_id_cache']['questions'][$id_question] = $row;
2198 2278
 				$modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question;
@@ -2203,35 +2283,42 @@  discard block
 block discarded – undo
2203 2283
 		}
2204 2284
 	}
2205 2285
 
2206
-	if (!isset($_SESSION[$verificationOptions['id'] . '_vv']))
2207
-		$_SESSION[$verificationOptions['id'] . '_vv'] = array();
2286
+	if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) {
2287
+			$_SESSION[$verificationOptions['id'] . '_vv'] = array();
2288
+	}
2208 2289
 
2209 2290
 	// Do we need to refresh the verification?
2210
-	if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh']))
2211
-		$force_refresh = true;
2212
-	else
2213
-		$force_refresh = false;
2291
+	if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) {
2292
+			$force_refresh = true;
2293
+	} else {
2294
+			$force_refresh = false;
2295
+	}
2214 2296
 
2215 2297
 	// This can also force a fresh, although unlikely.
2216
-	if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q'])))
2217
-		$force_refresh = true;
2298
+	if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) {
2299
+			$force_refresh = true;
2300
+	}
2218 2301
 
2219 2302
 	$verification_errors = array();
2220 2303
 	// Start with any testing.
2221 2304
 	if ($do_test)
2222 2305
 	{
2223 2306
 		// This cannot happen!
2224
-		if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count']))
2225
-			fatal_lang_error('no_access', false);
2307
+		if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) {
2308
+					fatal_lang_error('no_access', false);
2309
+		}
2226 2310
 		// ... nor this!
2227
-		if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'])))
2228
-			fatal_lang_error('no_access', false);
2311
+		if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) {
2312
+					fatal_lang_error('no_access', false);
2313
+		}
2229 2314
 		// Hmm, it's requested but not actually declared. This shouldn't happen.
2230
-		if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']))
2231
-			fatal_lang_error('no_access', false);
2315
+		if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) {
2316
+					fatal_lang_error('no_access', false);
2317
+		}
2232 2318
 		// While we're here, did the user do something bad?
2233
-		if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']]))
2234
-			$verification_errors[] = 'wrong_verification_answer';
2319
+		if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) {
2320
+					$verification_errors[] = 'wrong_verification_answer';
2321
+		}
2235 2322
 
2236 2323
 		if ($thisVerification['can_recaptcha'])
2237 2324
 		{
@@ -2242,22 +2329,25 @@  discard block
 block discarded – undo
2242 2329
 			{
2243 2330
 				$resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']);
2244 2331
 
2245
-				if (!$resp->isSuccess())
2246
-					$verification_errors[] = 'wrong_verification_code';
2332
+				if (!$resp->isSuccess()) {
2333
+									$verification_errors[] = 'wrong_verification_code';
2334
+				}
2335
+			} else {
2336
+							$verification_errors[] = 'wrong_verification_code';
2247 2337
 			}
2248
-			else
2249
-				$verification_errors[] = 'wrong_verification_code';
2250 2338
 		}
2251
-		if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code']))
2252
-			$verification_errors[] = 'wrong_verification_code';
2339
+		if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) {
2340
+					$verification_errors[] = 'wrong_verification_code';
2341
+		}
2253 2342
 		if ($thisVerification['number_questions'])
2254 2343
 		{
2255 2344
 			$incorrectQuestions = array();
2256 2345
 			foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q)
2257 2346
 			{
2258 2347
 				// We don't have this question any more, thus no answers.
2259
-				if (!isset($modSettings['question_id_cache']['questions'][$q]))
2260
-					continue;
2348
+				if (!isset($modSettings['question_id_cache']['questions'][$q])) {
2349
+									continue;
2350
+				}
2261 2351
 				// This is quite complex. We have our question but it might have multiple answers.
2262 2352
 				// First, did they actually answer this question?
2263 2353
 				if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '')
@@ -2269,24 +2359,28 @@  discard block
 block discarded – undo
2269 2359
 				else
2270 2360
 				{
2271 2361
 					$given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q])));
2272
-					if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers']))
2273
-						$incorrectQuestions[] = $q;
2362
+					if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) {
2363
+											$incorrectQuestions[] = $q;
2364
+					}
2274 2365
 				}
2275 2366
 			}
2276 2367
 
2277
-			if (!empty($incorrectQuestions))
2278
-				$verification_errors[] = 'wrong_verification_answer';
2368
+			if (!empty($incorrectQuestions)) {
2369
+							$verification_errors[] = 'wrong_verification_answer';
2370
+			}
2279 2371
 		}
2280 2372
 	}
2281 2373
 
2282 2374
 	// Any errors means we refresh potentially.
2283 2375
 	if (!empty($verification_errors))
2284 2376
 	{
2285
-		if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors']))
2286
-			$_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0;
2377
+		if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) {
2378
+					$_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0;
2379
+		}
2287 2380
 		// Too many errors?
2288
-		elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors'])
2289
-			$force_refresh = true;
2381
+		elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) {
2382
+					$force_refresh = true;
2383
+		}
2290 2384
 
2291 2385
 		// Keep a track of these.
2292 2386
 		$_SESSION[$verificationOptions['id'] . '_vv']['errors']++;
@@ -2319,8 +2413,9 @@  discard block
 block discarded – undo
2319 2413
 			// Are we overriding the range?
2320 2414
 			$character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range'];
2321 2415
 
2322
-			for ($i = 0; $i < 6; $i++)
2323
-				$_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)];
2416
+			for ($i = 0; $i < 6; $i++) {
2417
+							$_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)];
2418
+			}
2324 2419
 		}
2325 2420
 
2326 2421
 		// Getting some new questions?
@@ -2328,8 +2423,9 @@  discard block
 block discarded – undo
2328 2423
 		{
2329 2424
 			// Attempt to try the current page's language, followed by the user's preference, followed by the site default.
2330 2425
 			$possible_langs = array();
2331
-			if (isset($_SESSION['language']))
2332
-				$possible_langs[] = strtr($_SESSION['language'], array('-utf8' => ''));
2426
+			if (isset($_SESSION['language'])) {
2427
+							$possible_langs[] = strtr($_SESSION['language'], array('-utf8' => ''));
2428
+			}
2333 2429
 			if (!empty($user_info['language']));
2334 2430
 			$possible_langs[] = $user_info['language'];
2335 2431
 			$possible_langs[] = $language;
@@ -2348,8 +2444,7 @@  discard block
 block discarded – undo
2348 2444
 				}
2349 2445
 			}
2350 2446
 		}
2351
-	}
2352
-	else
2447
+	} else
2353 2448
 	{
2354 2449
 		// Same questions as before.
2355 2450
 		$questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array();
@@ -2359,8 +2454,9 @@  discard block
 block discarded – undo
2359 2454
 	// If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway.
2360 2455
 	if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']))
2361 2456
 	{
2362
-		if (!isset($context['html_headers']))
2363
-			$context['html_headers'] = '';
2457
+		if (!isset($context['html_headers'])) {
2458
+					$context['html_headers'] = '';
2459
+		}
2364 2460
 		$context['html_headers'] .= '<style>.vv_special { display:none; }</style>';
2365 2461
 	}
2366 2462
 
@@ -2386,11 +2482,13 @@  discard block
 block discarded – undo
2386 2482
 	$_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1;
2387 2483
 
2388 2484
 	// Return errors if we have them.
2389
-	if (!empty($verification_errors))
2390
-		return $verification_errors;
2485
+	if (!empty($verification_errors)) {
2486
+			return $verification_errors;
2487
+	}
2391 2488
 	// If we had a test that one, make a note.
2392
-	elseif ($do_test)
2393
-		$_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true;
2489
+	elseif ($do_test) {
2490
+			$_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true;
2491
+	}
2394 2492
 
2395 2493
 	// Say that everything went well chaps.
2396 2494
 	return true;
@@ -2415,8 +2513,9 @@  discard block
 block discarded – undo
2415 2513
 	call_integration_hook('integrate_autosuggest', array(&$searchTypes));
2416 2514
 
2417 2515
 	// If we're just checking the callback function is registered return true or false.
2418
-	if ($checkRegistered != null)
2419
-		return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered);
2516
+	if ($checkRegistered != null) {
2517
+			return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered);
2518
+	}
2420 2519
 
2421 2520
 	checkSession('get');
2422 2521
 	loadTemplate('Xml');
@@ -2567,24 +2666,27 @@  discard block
 block discarded – undo
2567 2666
 		foreach ($possible_versions as $ver)
2568 2667
 		{
2569 2668
 			$ver = trim($ver);
2570
-			if (strpos($ver, 'SMF') === 0)
2571
-				$versions[] = $ver;
2669
+			if (strpos($ver, 'SMF') === 0) {
2670
+							$versions[] = $ver;
2671
+			}
2572 2672
 		}
2573 2673
 	}
2574 2674
 	$smcFunc['db_free_result']($request);
2575 2675
 
2576 2676
 	// Just in case we don't have ANYthing.
2577
-	if (empty($versions))
2578
-		$versions = array('SMF 2.0');
2677
+	if (empty($versions)) {
2678
+			$versions = array('SMF 2.0');
2679
+	}
2579 2680
 
2580
-	foreach ($versions as $id => $version)
2581
-		if (strpos($version, strtoupper($_REQUEST['search'])) !== false)
2681
+	foreach ($versions as $id => $version) {
2682
+			if (strpos($version, strtoupper($_REQUEST['search'])) !== false)
2582 2683
 			$xml_data['items']['children'][] = array(
2583 2684
 				'attributes' => array(
2584 2685
 					'id' => $id,
2585 2686
 				),
2586 2687
 				'value' => $version,
2587 2688
 			);
2689
+	}
2588 2690
 
2589 2691
 	return $xml_data;
2590 2692
 }
Please login to merge, or discard this patch.
Sources/ManagePosts.php 1 patch
Braces   +39 added lines, -29 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 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
  * The main entrance point for the 'Posts and topics' screen.
@@ -98,23 +99,23 @@  discard block
 block discarded – undo
98 99
 		{
99 100
 			$_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => '')));
100 101
 
101
-			foreach ($_POST['censortext'] as $c)
102
-				list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, '');
103
-		}
104
-		elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper']))
102
+			foreach ($_POST['censortext'] as $c) {
103
+							list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, '');
104
+			}
105
+		} elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper']))
105 106
 		{
106 107
 			if (is_array($_POST['censor_vulgar']))
107 108
 			{
108 109
 				foreach ($_POST['censor_vulgar'] as $i => $value)
109 110
 				{
110
-					if (trim(strtr($value, '*', ' ')) == '')
111
-						unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]);
111
+					if (trim(strtr($value, '*', ' ')) == '') {
112
+											unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]);
113
+					}
112 114
 				}
113 115
 
114 116
 				$censored_vulgar = $_POST['censor_vulgar'];
115 117
 				$censored_proper = $_POST['censor_proper'];
116
-			}
117
-			else
118
+			} else
118 119
 			{
119 120
 				$censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => '')));
120 121
 				$censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => '')));
@@ -151,12 +152,14 @@  discard block
 block discarded – undo
151 152
 	$context['censored_words'] = array();
152 153
 	for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++)
153 154
 	{
154
-		if (empty($censor_vulgar[$i]))
155
-			continue;
155
+		if (empty($censor_vulgar[$i])) {
156
+					continue;
157
+		}
156 158
 
157 159
 		// Skip it, it's either spaces or stars only.
158
-		if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '')
159
-			continue;
160
+		if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') {
161
+					continue;
162
+		}
160 163
 
161 164
 		$context['censored_words'][$smcFunc['htmlspecialchars'](trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? $smcFunc['htmlspecialchars']($censor_proper[$i]) : '';
162 165
 	}
@@ -187,10 +190,11 @@  discard block
 block discarded – undo
187 190
 
188 191
 	// Make an inline conditional a little shorter...
189 192
 	$can_spell_check = false;
190
-	if (function_exists('pspell_new'))
191
-		$can_spell_check = true;
192
-	elseif (function_exists('enchant_broker_init') && ($txt['lang_character_set'] == 'UTF-8' || function_exists('iconv')))
193
-		$can_spell_check = true;
193
+	if (function_exists('pspell_new')) {
194
+			$can_spell_check = true;
195
+	} elseif (function_exists('enchant_broker_init') && ($txt['lang_character_set'] == 'UTF-8' || function_exists('iconv'))) {
196
+			$can_spell_check = true;
197
+	}
194 198
 
195 199
 	// All the settings...
196 200
 	$config_vars = array(
@@ -220,8 +224,9 @@  discard block
 block discarded – undo
220 224
 
221 225
 	call_integration_hook('integrate_modify_post_settings', array(&$config_vars));
222 226
 
223
-	if ($return_config)
224
-		return $config_vars;
227
+	if ($return_config) {
228
+			return $config_vars;
229
+	}
225 230
 
226 231
 	// We'll want this for our easy save.
227 232
 	require_once($sourcedir . '/ManageServer.php');
@@ -241,17 +246,20 @@  discard block
 block discarded – undo
241 246
 			db_extend('packages');
242 247
 
243 248
 			$colData = $smcFunc['db_list_columns']('{db_prefix}messages', true);
244
-			foreach ($colData as $column)
245
-				if ($column['name'] == 'body')
249
+			foreach ($colData as $column) {
250
+							if ($column['name'] == 'body')
246 251
 					$body_type = $column['type'];
252
+			}
247 253
 
248
-			if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text')
249
-				fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database'));
254
+			if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') {
255
+							fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database'));
256
+			}
250 257
 		}
251 258
 
252 259
 		// If we're changing the post preview length let's check its valid
253
-		if (!empty($_POST['preview_characters']))
254
-			$_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512);
260
+		if (!empty($_POST['preview_characters'])) {
261
+					$_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512);
262
+		}
255 263
 
256 264
 		call_integration_hook('integrate_save_post_settings');
257 265
 
@@ -312,8 +320,9 @@  discard block
 block discarded – undo
312 320
 
313 321
 	call_integration_hook('integrate_modify_topic_settings', array(&$config_vars));
314 322
 
315
-	if ($return_config)
316
-		return $config_vars;
323
+	if ($return_config) {
324
+			return $config_vars;
325
+	}
317 326
 
318 327
 	// Get the settings template ready.
319 328
 	require_once($sourcedir . '/ManageServer.php');
@@ -366,8 +375,9 @@  discard block
 block discarded – undo
366 375
 		array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']),
367 376
 	);
368 377
 
369
-	if ($return_config)
370
-		return $config_vars;
378
+	if ($return_config) {
379
+			return $config_vars;
380
+	}
371 381
 
372 382
 	// Get the settings template ready.
373 383
 	require_once($sourcedir . '/ManageServer.php');
Please login to merge, or discard this patch.