Completed
Push — release-2.1 ( e15e64...996344 )
by Mathias
11s
created
Sources/LogInOut.php 1 patch
Braces   +163 added lines, -127 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
  * Ask them for their login information. (shows a page for the user to type
@@ -29,8 +30,9 @@  discard block
 block discarded – undo
29 30
 	global $txt, $context, $scripturl, $user_info;
30 31
 
31 32
 	// You are already logged in, go take a tour of the boards
32
-	if (!empty($user_info['id']))
33
-		redirectexit();
33
+	if (!empty($user_info['id'])) {
34
+			redirectexit();
35
+	}
34 36
 
35 37
 	// We need to load the Login template/language file.
36 38
 	loadLanguage('Login');
@@ -57,10 +59,11 @@  discard block
 block discarded – undo
57 59
 	);
58 60
 
59 61
 	// Set the login URL - will be used when the login process is done (but careful not to send us to an attachment).
60
-	if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0)
61
-		$_SESSION['login_url'] = $_SESSION['old_url'];
62
-	elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false)
63
-		unset($_SESSION['login_url']);
62
+	if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) {
63
+			$_SESSION['login_url'] = $_SESSION['old_url'];
64
+	} elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) {
65
+			unset($_SESSION['login_url']);
66
+	}
64 67
 
65 68
 	// Create a one time token.
66 69
 	createToken('login');
@@ -83,8 +86,9 @@  discard block
 block discarded – undo
83 86
 	global $cookiename, $modSettings, $context, $sourcedir, $maintenance;
84 87
 
85 88
 	// Check to ensure we're forcing SSL for authentication
86
-	if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
87
-		fatal_lang_error('login_ssl_required');
89
+	if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
90
+			fatal_lang_error('login_ssl_required');
91
+	}
88 92
 
89 93
 	// Load cookie authentication stuff.
90 94
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -98,23 +102,26 @@  discard block
 block discarded – undo
98 102
 	if (isset($_GET['sa']) && $_GET['sa'] == 'salt' && !$user_info['is_guest'])
99 103
 	{
100 104
 		// First check for 2.1 json-format cookie in $_COOKIE
101
-		if (isset($_COOKIE[$cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_COOKIE[$cookiename]) === 1)
102
-			list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true);
105
+		if (isset($_COOKIE[$cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_COOKIE[$cookiename]) === 1) {
106
+					list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true);
107
+		}
103 108
 
104 109
 		// Try checking for 2.1 json-format cookie in $_SESSION
105
-		elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_SESSION['login_' . $cookiename]) === 1)
106
-			list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]);
110
+		elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_SESSION['login_' . $cookiename]) === 1) {
111
+					list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]);
112
+		}
107 113
 
108 114
 		// Next, try checking for 2.0 serialized string cookie in $_COOKIE
109
-		elseif (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_COOKIE[$cookiename]) === 1)
110
-			list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]);
115
+		elseif (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_COOKIE[$cookiename]) === 1) {
116
+					list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]);
117
+		}
111 118
 
112 119
 		// Last, see if you need to fall back on checking for 2.0 serialized string cookie in $_SESSION
113
-		elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_SESSION['login_' . $cookiename]) === 1)
114
-			list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]);
115
-
116
-		else
117
-			trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR);
120
+		elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_SESSION['login_' . $cookiename]) === 1) {
121
+					list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]);
122
+		} else {
123
+					trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR);
124
+		}
118 125
 
119 126
 		$user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4);
120 127
 		updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt']));
@@ -127,10 +134,11 @@  discard block
 block discarded – undo
127 134
 			list ($tfamember, $tfasecret, $exp, $domain, $path, $preserve) = $tfadata;
128 135
 
129 136
 			// If we're preserving the cookie, reset it with updated salt
130
-			if (isset($tfamember, $tfasecret, $exp, $domain, $path, $preserve) && $preserve && time() < $exp)
131
-				setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true);
132
-			else
133
-				setTFACookie(-3600, 0, '');
137
+			if (isset($tfamember, $tfasecret, $exp, $domain, $path, $preserve) && $preserve && time() < $exp) {
138
+							setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true);
139
+			} else {
140
+							setTFACookie(-3600, 0, '');
141
+			}
134 142
 		}
135 143
 
136 144
 		setLoginCookie($timeout - time(), $user_info['id'], hash_salt($user_settings['passwd'], $user_settings['password_salt']));
@@ -141,20 +149,20 @@  discard block
 block discarded – undo
141 149
 	elseif (isset($_GET['sa']) && $_GET['sa'] == 'check')
142 150
 	{
143 151
 		// Strike!  You're outta there!
144
-		if ($_GET['member'] != $user_info['id'])
145
-			fatal_lang_error('login_cookie_error', false);
152
+		if ($_GET['member'] != $user_info['id']) {
153
+					fatal_lang_error('login_cookie_error', false);
154
+		}
146 155
 
147 156
 		$user_info['can_mod'] = allowedTo('access_mod_center') || (!$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || ($modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']))));
148 157
 
149 158
 		// Some whitelisting for login_url...
150
-		if (empty($_SESSION['login_url']))
151
-			redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
152
-		elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false))
159
+		if (empty($_SESSION['login_url'])) {
160
+					redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
161
+		} elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false))
153 162
 		{
154 163
 			unset ($_SESSION['login_url']);
155 164
 			redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
156
-		}
157
-		else
165
+		} else
158 166
 		{
159 167
 			// Best not to clutter the session data too much...
160 168
 			$temp = $_SESSION['login_url'];
@@ -165,8 +173,9 @@  discard block
 block discarded – undo
165 173
 	}
166 174
 
167 175
 	// Beyond this point you are assumed to be a guest trying to login.
168
-	if (!$user_info['is_guest'])
169
-		redirectexit();
176
+	if (!$user_info['is_guest']) {
177
+			redirectexit();
178
+	}
170 179
 
171 180
 	// Are you guessing with a script?
172 181
 	checkSession();
@@ -174,18 +183,21 @@  discard block
 block discarded – undo
174 183
 	spamProtection('login');
175 184
 
176 185
 	// Set the login_url if it's not already set (but careful not to send us to an attachment).
177
-	if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false))
178
-		$_SESSION['login_url'] = $_SESSION['old_url'];
186
+	if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) {
187
+			$_SESSION['login_url'] = $_SESSION['old_url'];
188
+	}
179 189
 
180 190
 	// Been guessing a lot, haven't we?
181
-	if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3)
182
-		fatal_lang_error('login_threshold_fail', 'login');
191
+	if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) {
192
+			fatal_lang_error('login_threshold_fail', 'login');
193
+	}
183 194
 
184 195
 	// Set up the cookie length.  (if it's invalid, just fall through and use the default.)
185
-	if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1))
186
-		$modSettings['cookieTime'] = 3153600;
187
-	elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600))
188
-		$modSettings['cookieTime'] = (int) $_POST['cookielength'];
196
+	if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) {
197
+			$modSettings['cookieTime'] = 3153600;
198
+	} elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) {
199
+			$modSettings['cookieTime'] = (int) $_POST['cookielength'];
200
+	}
189 201
 
190 202
 	loadLanguage('Login');
191 203
 	// Load the template stuff.
@@ -305,8 +317,9 @@  discard block
 block discarded – undo
305 317
 			$other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd']));
306 318
 
307 319
 			// Snitz style - SHA-256.  Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway.
308
-			if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256'))
309
-				$other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd']));
320
+			if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) {
321
+							$other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd']));
322
+			}
310 323
 
311 324
 			// phpBB3 users new hashing.  We now support it as well ;).
312 325
 			$other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']);
@@ -326,27 +339,29 @@  discard block
 block discarded – undo
326 339
 			// Some common md5 ones.
327 340
 			$other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']);
328 341
 			$other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']);
329
-		}
330
-		elseif (strlen($user_settings['passwd']) == 40)
342
+		} elseif (strlen($user_settings['passwd']) == 40)
331 343
 		{
332 344
 			// Maybe they are using a hash from before the password fix.
333 345
 			// This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1
334 346
 			$other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd']));
335 347
 
336 348
 			// BurningBoard3 style of hashing.
337
-			if (!empty($modSettings['enable_password_conversion']))
338
-				$other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd'])));
349
+			if (!empty($modSettings['enable_password_conversion'])) {
350
+							$other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd'])));
351
+			}
339 352
 
340 353
 			// Perhaps we converted to UTF-8 and have a valid password being hashed differently.
341 354
 			if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8')
342 355
 			{
343 356
 				// Try iconv first, for no particular reason.
344
-				if (function_exists('iconv'))
345
-					$other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd'])));
357
+				if (function_exists('iconv')) {
358
+									$other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd'])));
359
+				}
346 360
 
347 361
 				// Say it aint so, iconv failed!
348
-				if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding'))
349
-					$other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet'])));
362
+				if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) {
363
+									$other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet'])));
364
+				}
350 365
 			}
351 366
 		}
352 367
 
@@ -376,8 +391,9 @@  discard block
 block discarded – undo
376 391
 			$_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1;
377 392
 
378 393
 			// Hmm... don't remember it, do you?  Here, try the password reminder ;).
379
-			if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold'])
380
-				redirectexit('action=reminder');
394
+			if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) {
395
+							redirectexit('action=reminder');
396
+			}
381 397
 			// We'll give you another chance...
382 398
 			else
383 399
 			{
@@ -388,8 +404,7 @@  discard block
 block discarded – undo
388 404
 				return;
389 405
 			}
390 406
 		}
391
-	}
392
-	elseif (!empty($user_settings['passwd_flood']))
407
+	} elseif (!empty($user_settings['passwd_flood']))
393 408
 	{
394 409
 		// Let's be sure they weren't a little hacker.
395 410
 		validatePasswordFlood($user_settings['id_member'], $user_settings['member_name'], $user_settings['passwd_flood'], true);
@@ -406,8 +421,9 @@  discard block
 block discarded – undo
406 421
 	}
407 422
 
408 423
 	// Check their activation status.
409
-	if (!checkActivation())
410
-		return;
424
+	if (!checkActivation()) {
425
+			return;
426
+	}
411 427
 
412 428
 	DoLogin();
413 429
 }
@@ -419,8 +435,9 @@  discard block
 block discarded – undo
419 435
 {
420 436
 	global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl;
421 437
 
422
-	if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode']))
423
-		fatal_lang_error('no_access', false);
438
+	if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) {
439
+			fatal_lang_error('no_access', false);
440
+	}
424 441
 
425 442
 	loadLanguage('Profile');
426 443
 	require_once($sourcedir . '/Class-TOTP.php');
@@ -428,8 +445,9 @@  discard block
 block discarded – undo
428 445
 	$member = $context['tfa_member'];
429 446
 
430 447
 	// Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA
431
-	if (time() - $member['last_login'] < 120)
432
-		fatal_lang_error('tfa_wait', false);
448
+	if (time() - $member['last_login'] < 120) {
449
+			fatal_lang_error('tfa_wait', false);
450
+	}
433 451
 
434 452
 	$totp = new \TOTP\Auth($member['tfa_secret']);
435 453
 	$totp->setRange(1);
@@ -443,8 +461,9 @@  discard block
 block discarded – undo
443 461
 	if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup']))
444 462
 	{
445 463
 		// Check to ensure we're forcing SSL for authentication
446
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
447
-			fatal_lang_error('login_ssl_required');
464
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
465
+					fatal_lang_error('login_ssl_required');
466
+		}
448 467
 
449 468
 		$code = $_POST['tfa_code'];
450 469
 
@@ -454,20 +473,19 @@  discard block
 block discarded – undo
454 473
 
455 474
 			setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']), !empty($_POST['tfa_preserve']));
456 475
 			redirectexit();
457
-		}
458
-		else
476
+		} else
459 477
 		{
460 478
 			validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true);
461 479
 
462 480
 			$context['tfa_error'] = true;
463 481
 			$context['tfa_value'] = $_POST['tfa_code'];
464 482
 		}
465
-	}
466
-	elseif (!empty($_POST['tfa_backup']))
483
+	} elseif (!empty($_POST['tfa_backup']))
467 484
 	{
468 485
 		// Check to ensure we're forcing SSL for authentication
469
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
470
-			fatal_lang_error('login_ssl_required');
486
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
487
+					fatal_lang_error('login_ssl_required');
488
+		}
471 489
 
472 490
 		$backup = $_POST['tfa_backup'];
473 491
 
@@ -481,8 +499,7 @@  discard block
 block discarded – undo
481 499
 			));
482 500
 			setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']));
483 501
 			redirectexit('action=profile;area=tfasetup;backup');
484
-		}
485
-		else
502
+		} else
486 503
 		{
487 504
 			validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true);
488 505
 
@@ -505,8 +522,9 @@  discard block
 block discarded – undo
505 522
 {
506 523
 	global $context, $txt, $scripturl, $user_settings, $modSettings;
507 524
 
508
-	if (!isset($context['login_errors']))
509
-		$context['login_errors'] = array();
525
+	if (!isset($context['login_errors'])) {
526
+			$context['login_errors'] = array();
527
+	}
510 528
 
511 529
 	// What is the true activation status of this account?
512 530
 	$activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated'];
@@ -518,8 +536,9 @@  discard block
 block discarded – undo
518 536
 		return false;
519 537
 	}
520 538
 	// Awaiting approval still?
521
-	elseif ($activation_status == 3)
522
-		fatal_lang_error('still_awaiting_approval', 'user');
539
+	elseif ($activation_status == 3) {
540
+			fatal_lang_error('still_awaiting_approval', 'user');
541
+	}
523 542
 	// Awaiting deletion, changed their mind?
524 543
 	elseif ($activation_status == 4)
525 544
 	{
@@ -527,8 +546,7 @@  discard block
 block discarded – undo
527 546
 		{
528 547
 			updateMemberData($user_settings['id_member'], array('is_activated' => 1));
529 548
 			updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0)));
530
-		}
531
-		else
549
+		} else
532 550
 		{
533 551
 			$context['disable_login_hashing'] = true;
534 552
 			$context['login_errors'][] = $txt['awaiting_delete_account'];
@@ -568,8 +586,9 @@  discard block
 block discarded – undo
568 586
 	setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt']));
569 587
 
570 588
 	// Reset the login threshold.
571
-	if (isset($_SESSION['failed_login']))
572
-		unset($_SESSION['failed_login']);
589
+	if (isset($_SESSION['failed_login'])) {
590
+			unset($_SESSION['failed_login']);
591
+	}
573 592
 
574 593
 	$user_info['is_guest'] = false;
575 594
 	$user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']);
@@ -591,16 +610,18 @@  discard block
 block discarded – undo
591 610
 			'id_member' => $user_info['id'],
592 611
 		)
593 612
 	);
594
-	if ($smcFunc['db_num_rows']($request) == 1)
595
-		$_SESSION['first_login'] = true;
596
-	else
597
-		unset($_SESSION['first_login']);
613
+	if ($smcFunc['db_num_rows']($request) == 1) {
614
+			$_SESSION['first_login'] = true;
615
+	} else {
616
+			unset($_SESSION['first_login']);
617
+	}
598 618
 	$smcFunc['db_free_result']($request);
599 619
 
600 620
 	// You've logged in, haven't you?
601 621
 	$update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']);
602
-	if (empty($user_settings['tfa_secret']))
603
-		$update['last_login'] = time();
622
+	if (empty($user_settings['tfa_secret'])) {
623
+			$update['last_login'] = time();
624
+	}
604 625
 	updateMemberData($user_info['id'], $update);
605 626
 
606 627
 	// Get rid of the online entry for that old guest....
@@ -614,8 +635,8 @@  discard block
 block discarded – undo
614 635
 	$_SESSION['log_time'] = 0;
615 636
 
616 637
 	// Log this entry, only if we have it enabled.
617
-	if (!empty($modSettings['loginHistoryDays']))
618
-		$smcFunc['db_insert']('insert',
638
+	if (!empty($modSettings['loginHistoryDays'])) {
639
+			$smcFunc['db_insert']('insert',
619 640
 			'{db_prefix}member_logins',
620 641
 			array(
621 642
 				'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet',
@@ -627,13 +648,15 @@  discard block
 block discarded – undo
627 648
 				'id_member', 'time'
628 649
 			)
629 650
 		);
651
+	}
630 652
 
631 653
 	// Just log you back out if it's in maintenance mode and you AREN'T an admin.
632
-	if (empty($maintenance) || allowedTo('admin_forum'))
633
-		redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']);
634
-	else
635
-		redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']);
636
-}
654
+	if (empty($maintenance) || allowedTo('admin_forum')) {
655
+			redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']);
656
+	} else {
657
+			redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']);
658
+	}
659
+	}
637 660
 
638 661
 /**
639 662
  * Logs the current user out of their account.
@@ -649,13 +672,15 @@  discard block
 block discarded – undo
649 672
 	global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings;
650 673
 
651 674
 	// Make sure they aren't being auto-logged out.
652
-	if (!$internal)
653
-		checkSession('get');
675
+	if (!$internal) {
676
+			checkSession('get');
677
+	}
654 678
 
655 679
 	require_once($sourcedir . '/Subs-Auth.php');
656 680
 
657
-	if (isset($_SESSION['pack_ftp']))
658
-		$_SESSION['pack_ftp'] = null;
681
+	if (isset($_SESSION['pack_ftp'])) {
682
+			$_SESSION['pack_ftp'] = null;
683
+	}
659 684
 
660 685
 	// It won't be first login anymore.
661 686
 	unset($_SESSION['first_login']);
@@ -683,8 +708,9 @@  discard block
 block discarded – undo
683 708
 
684 709
 	// And some other housekeeping while we're at it.
685 710
 	$salt = substr(md5(mt_rand()), 0, 4);
686
-	if (!empty($user_info['id']))
687
-		updateMemberData($user_info['id'], array('password_salt' => $salt));
711
+	if (!empty($user_info['id'])) {
712
+			updateMemberData($user_info['id'], array('password_salt' => $salt));
713
+	}
688 714
 
689 715
 	if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa']))
690 716
 	{
@@ -693,10 +719,11 @@  discard block
 block discarded – undo
693 719
 		list ($tfamember, $tfasecret, $exp, $domain, $path, $preserve) = $tfadata;
694 720
 
695 721
 		// If we're preserving the cookie, reset it with updated salt
696
-		if (isset($tfamember, $tfasecret, $exp, $domain, $path, $preserve) && $preserve && time() < $exp)
697
-			setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true);
698
-		else
699
-			setTFACookie(-3600, 0, '');
722
+		if (isset($tfamember, $tfasecret, $exp, $domain, $path, $preserve) && $preserve && time() < $exp) {
723
+					setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true);
724
+		} else {
725
+					setTFACookie(-3600, 0, '');
726
+		}
700 727
 	}
701 728
 
702 729
 	session_destroy();
@@ -704,14 +731,13 @@  discard block
 block discarded – undo
704 731
 	// Off to the merry board index we go!
705 732
 	if ($redirect)
706 733
 	{
707
-		if (empty($_SESSION['logout_url']))
708
-			redirectexit('', $context['server']['needs_login_fix']);
709
-		elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false))
734
+		if (empty($_SESSION['logout_url'])) {
735
+					redirectexit('', $context['server']['needs_login_fix']);
736
+		} elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false))
710 737
 		{
711 738
 			unset ($_SESSION['logout_url']);
712 739
 			redirectexit();
713
-		}
714
-		else
740
+		} else
715 741
 		{
716 742
 			$temp = $_SESSION['logout_url'];
717 743
 			unset($_SESSION['logout_url']);
@@ -744,8 +770,9 @@  discard block
 block discarded – undo
744 770
 function phpBB3_password_check($passwd, $passwd_hash)
745 771
 {
746 772
 	// Too long or too short?
747
-	if (strlen($passwd_hash) != 34)
748
-		return;
773
+	if (strlen($passwd_hash) != 34) {
774
+			return;
775
+	}
749 776
 
750 777
 	// Range of characters allowed.
751 778
 	$range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
@@ -756,8 +783,9 @@  discard block
 block discarded – undo
756 783
 	$salt = substr($passwd_hash, 4, 8);
757 784
 
758 785
 	$hash = md5($salt . $passwd, true);
759
-	for (; $count != 0; --$count)
760
-		$hash = md5($hash . $passwd, true);
786
+	for (; $count != 0; --$count) {
787
+			$hash = md5($hash . $passwd, true);
788
+	}
761 789
 
762 790
 	$output = substr($passwd_hash, 0, 12);
763 791
 	$i = 0;
@@ -766,21 +794,25 @@  discard block
 block discarded – undo
766 794
 		$value = ord($hash[$i++]);
767 795
 		$output .= $range[$value & 0x3f];
768 796
 
769
-		if ($i < 16)
770
-			$value |= ord($hash[$i]) << 8;
797
+		if ($i < 16) {
798
+					$value |= ord($hash[$i]) << 8;
799
+		}
771 800
 
772 801
 		$output .= $range[($value >> 6) & 0x3f];
773 802
 
774
-		if ($i++ >= 16)
775
-			break;
803
+		if ($i++ >= 16) {
804
+					break;
805
+		}
776 806
 
777
-		if ($i < 16)
778
-			$value |= ord($hash[$i]) << 16;
807
+		if ($i < 16) {
808
+					$value |= ord($hash[$i]) << 16;
809
+		}
779 810
 
780 811
 		$output .= $range[($value >> 12) & 0x3f];
781 812
 
782
-		if ($i++ >= 16)
783
-			break;
813
+		if ($i++ >= 16) {
814
+					break;
815
+		}
784 816
 
785 817
 		$output .= $range[($value >> 18) & 0x3f];
786 818
 	}
@@ -812,8 +844,9 @@  discard block
 block discarded – undo
812 844
 		require_once($sourcedir . '/Subs-Auth.php');
813 845
 		setLoginCookie(-3600, 0);
814 846
 
815
-		if (isset($_SESSION['login_' . $cookiename]))
816
-			unset($_SESSION['login_' . $cookiename]);
847
+		if (isset($_SESSION['login_' . $cookiename])) {
848
+					unset($_SESSION['login_' . $cookiename]);
849
+		}
817 850
 	}
818 851
 
819 852
 	// We need a member!
@@ -827,8 +860,9 @@  discard block
 block discarded – undo
827 860
 	}
828 861
 
829 862
 	// Right, have we got a flood value?
830
-	if ($password_flood_value !== false)
831
-		@list ($time_stamp, $number_tries) = explode('|', $password_flood_value);
863
+	if ($password_flood_value !== false) {
864
+			@list ($time_stamp, $number_tries) = explode('|', $password_flood_value);
865
+	}
832 866
 
833 867
 	// Timestamp or number of tries invalid?
834 868
 	if (empty($number_tries) || empty($time_stamp))
@@ -844,15 +878,17 @@  discard block
 block discarded – undo
844 878
 		$number_tries = $time_stamp < time() - 20 ? 2 : $number_tries;
845 879
 
846 880
 		// They are trying too fast, make them wait longer
847
-		if ($time_stamp < time() - 10)
848
-			$time_stamp = time();
881
+		if ($time_stamp < time() - 10) {
882
+					$time_stamp = time();
883
+		}
849 884
 	}
850 885
 
851 886
 	$number_tries++;
852 887
 
853 888
 	// Broken the law?
854
-	if ($number_tries > 5)
855
-		fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]);
889
+	if ($number_tries > 5) {
890
+			fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]);
891
+	}
856 892
 
857 893
 	// Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it!
858 894
 	updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries));
Please login to merge, or discard this patch.
Themes/default/MoveTopic.template.php 1 patch
Braces   +32 added lines, -23 removed lines patch added patch discarded remove patch
@@ -37,9 +37,10 @@  discard block
 block discarded – undo
37 37
 		echo '
38 38
 								<optgroup label="', $category['name'], '">';
39 39
 
40
-		foreach ($category['boards'] as $board)
41
-			echo '
40
+		foreach ($category['boards'] as $board) {
41
+					echo '
42 42
 									<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', $board['id'] == $context['current_board'] ? ' disabled' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level']-1) . '=&gt; ' : '', $board['name'], '</option>';
43
+		}
43 44
 		echo '
44 45
 								</optgroup>';
45 46
 	}
@@ -70,9 +71,10 @@  discard block
 block discarded – undo
70 71
 				</div><!-- .move_topic -->
71 72
 			</div><!-- .windowbg -->';
72 73
 
73
-	if ($context['back_to_topic'])
74
-		echo '
74
+	if ($context['back_to_topic']) {
75
+			echo '
75 76
 			<input type="hidden" name="goback" value="1">';
77
+	}
76 78
 
77 79
 	echo '
78 80
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -125,10 +127,10 @@  discard block
 block discarded – undo
125 127
 									<option value="86400">', $txt['two_months'], '</option>
126 128
 								</select>
127 129
 							</dd>';
128
-	}
129
-	else
130
-		echo '
130
+	} else {
131
+			echo '
131 132
 							<input type="hidden" name="redirect_expires" value="0">';
133
+	}
132 134
 
133 135
 	echo '
134 136
 						</dl>
@@ -207,9 +209,10 @@  discard block
 block discarded – undo
207 209
 			echo '
208 210
 							<optgroup label="', $cat['name'], '">';
209 211
 
210
-			foreach ($cat['boards'] as $board)
211
-				echo '
212
+			foreach ($cat['boards'] as $board) {
213
+							echo '
212 214
 								<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
215
+			}
213 216
 
214 217
 			echo '
215 218
 							</optgroup>';
@@ -220,9 +223,9 @@  discard block
 block discarded – undo
220 223
 						<input type="submit" value="', $txt['go'], '" class="button">
221 224
 					</form>';
222 225
 
226
+	} else {
227
+			echo $txt['target_below'];
223 228
 	}
224
-	else
225
-		echo $txt['target_below'];
226 229
 
227 230
 	echo '		</h4>
228 231
 			</div><!-- .title_bar -->
@@ -240,12 +243,13 @@  discard block
 block discarded – undo
240 243
 
241 244
 		$merge_button = create_button('merge', 'merge', '');
242 245
 
243
-		foreach ($context['topics'] as $topic)
244
-			echo '
246
+		foreach ($context['topics'] as $topic) {
247
+					echo '
245 248
 						<li>
246 249
 							<a href="', $scripturl, '?action=mergetopics;sa=options;board=', $context['current_board'], '.0;from=', $context['origin_topic'], ';to=', $topic['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $merge_button, '</a>
247 250
 							<a href="', $scripturl, '?topic=', $topic['id'], '.0" target="_blank" rel="noopener">', $topic['subject'], '</a> ', $txt['started_by'], ' ', $topic['poster']['link'], '
248 251
 						</li>';
252
+		}
249 253
 
250 254
 		echo '
251 255
 					</ul>
@@ -256,9 +260,10 @@  discard block
 block discarded – undo
256 260
 				</div>';
257 261
 	}
258 262
 	// Just a nice "There aren't any topics" message
259
-	else
260
-		echo '
263
+	else {
264
+			echo '
261 265
 				<div class="windowbg2">', $txt['topic_alert_none'], '</div>';
266
+	}
262 267
 
263 268
 	echo '
264 269
 				<br>
@@ -308,8 +313,8 @@  discard block
 block discarded – undo
308 313
 				</thead>
309 314
 				<tbody>';
310 315
 
311
-	foreach ($context['topics'] as $topic)
312
-		echo '
316
+	foreach ($context['topics'] as $topic) {
317
+			echo '
313 318
 					<tr class="windowbg">
314 319
 						<td>
315 320
 							<input type="checkbox" name="topics[]" value="' . $topic['id'] . '" checked>
@@ -329,6 +334,7 @@  discard block
 block discarded – undo
329 334
 							<input type="checkbox" name="notifications[]" value="' . $topic['id'] . '" checked>
330 335
 						</td>
331 336
 					</tr>';
337
+	}
332 338
 	echo '
333 339
 				</tbody>
334 340
 			</table>
@@ -338,9 +344,10 @@  discard block
 block discarded – undo
338 344
 					<legend>', $txt['merge_select_subject'], '</legend>
339 345
 					<select name="subject" onchange="this.form.custom_subject.style.display = (this.options[this.selectedIndex].value != 0) ? \'none\': \'\' ;">';
340 346
 
341
-	foreach ($context['topics'] as $topic)
342
-		echo '
347
+	foreach ($context['topics'] as $topic) {
348
+			echo '
343 349
 						<option value="', $topic['id'], '"' . ($topic['selected'] ? ' selected' : '') . '>', $topic['subject'], '</option>';
350
+	}
344 351
 	echo '
345 352
 						<option value="0">', $txt['merge_custom_subject'], ':</option>
346 353
 					</select>
@@ -359,11 +366,12 @@  discard block
 block discarded – undo
359 366
 					<legend>', $txt['merge_select_target_board'], '</legend>
360 367
 					<ul>';
361 368
 
362
-		foreach ($context['boards'] as $board)
363
-			echo '
369
+		foreach ($context['boards'] as $board) {
370
+					echo '
364 371
 						<li>
365 372
 							<input type="radio" name="board" value="' . $board['id'] . '"' . ($board['selected'] ? ' checked' : '') . '> ' . $board['name'] . '
366 373
 						</li>';
374
+		}
367 375
 		echo '
368 376
 					</ul>
369 377
 				</fieldset>';
@@ -375,11 +383,12 @@  discard block
 block discarded – undo
375 383
 					<legend>' . $txt['merge_select_poll'] . '</legend>
376 384
 					<ul>';
377 385
 
378
-		foreach ($context['polls'] as $poll)
379
-			echo '
386
+		foreach ($context['polls'] as $poll) {
387
+					echo '
380 388
 						<li>
381 389
 							<input type="radio" name="poll" value="' . $poll['id'] . '"' . ($poll['selected'] ? ' checked' : '') . '> ' . $poll['question'] . ' (' . $txt['topic'] . ': <a href="' . $scripturl . '?topic=' . $poll['topic']['id'] . '.0" target="_blank" rel="noopener">' . $poll['topic']['subject'] . '</a>)
382 390
 						</li>';
391
+		}
383 392
 		echo '
384 393
 						<li>
385 394
 							<input type="radio" name="poll" value="-1"> (' . $txt['merge_no_poll'] . ')
Please login to merge, or discard this patch.
Themes/default/GenericControls.template.php 1 patch
Braces   +79 added lines, -60 removed lines patch added patch discarded remove patch
@@ -53,14 +53,15 @@  discard block
 block discarded – undo
53 53
 			foreach ($context['smileys'] as $location => $smileyRows)
54 54
 			{
55 55
 				$countLocations--;
56
-				if ($location == 'postform')
57
-					echo '
56
+				if ($location == 'postform') {
57
+									echo '
58 58
 						dropdown:
59 59
 						{';
60
-				elseif ($location == 'popup')
61
-					echo '
60
+				} elseif ($location == 'popup') {
61
+									echo '
62 62
 						popup:
63 63
 						{';
64
+				}
64 65
 
65 66
 				$numRows = count($smileyRows);
66 67
 
@@ -68,25 +69,27 @@  discard block
 block discarded – undo
68 69
 				$emptyPlaceholder = 0;
69 70
 				foreach ($smileyRows as $smileyRow)
70 71
 				{
71
-					foreach ($smileyRow['smileys'] as $smiley)
72
-						echo '
72
+					foreach ($smileyRow['smileys'] as $smiley) {
73
+											echo '
73 74
 							', JavaScriptEscape($smiley['code']), ': ', JavaScriptEscape($settings['smileys_url'] . '/' . $smiley['filename']), empty($smiley['isLast']) ? ',' : '';
75
+					}
74 76
 
75
-					if (empty($smileyRow['isLast']) && $numRows != 1)
76
-						echo ',
77
+					if (empty($smileyRow['isLast']) && $numRows != 1) {
78
+											echo ',
77 79
 						\'-', $emptyPlaceholder++, '\': \'\',';
80
+					}
78 81
 				}
79 82
 				echo '
80 83
 						}', $countLocations != 0 ? ',' : '';
81 84
 			}
82 85
 			echo '
83 86
 					}';
84
-		}
85
-		else
86
-			echo ',
87
+		} else {
88
+					echo ',
87 89
 					emoticons:
88 90
 					{},
89 91
 					emoticonsEnabled:false';
92
+		}
90 93
 
91 94
 		if ($context['show_bbc'] && $bbcContainer !== null)
92 95
 		{
@@ -100,15 +103,16 @@  discard block
 block discarded – undo
100 103
 
101 104
 				$count_tags--;
102 105
 
103
-				if (!empty($count_tags))
104
-					echo '||';
106
+				if (!empty($count_tags)) {
107
+									echo '||';
108
+				}
105 109
 			}
106 110
 
107 111
 			echo '",';
108
-		}
109
-		else
110
-			echo ',
112
+		} else {
113
+					echo ',
111 114
 					toolbar: "",';
115
+		}
112 116
 
113 117
 		echo '
114 118
 				});
@@ -150,42 +154,47 @@  discard block
 block discarded – undo
150 154
 
151 155
 	$tempTab = $context['tabindex'];
152 156
 
153
-	if (!empty($context['drafts_pm_save']))
154
-		$tempTab++;
155
-	elseif (!empty($context['drafts_save']))
156
-		$tempTab++;
157
-	elseif ($editor_context['preview_type'])
158
-		$tempTab++;
159
-	elseif ($context['show_spellchecking'])
160
-		$tempTab++;
157
+	if (!empty($context['drafts_pm_save'])) {
158
+			$tempTab++;
159
+	} elseif (!empty($context['drafts_save'])) {
160
+			$tempTab++;
161
+	} elseif ($editor_context['preview_type']) {
162
+			$tempTab++;
163
+	} elseif ($context['show_spellchecking']) {
164
+			$tempTab++;
165
+	}
161 166
 
162 167
 	$tempTab++;
163 168
 	$context['tabindex'] = $tempTab;
164 169
 
165
-	if (!empty($context['drafts_pm_save']))
166
-		echo '
170
+	if (!empty($context['drafts_pm_save'])) {
171
+			echo '
167 172
 		<input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="submitThisOnce(this);" accesskey="d" class="button">
168 173
 		<input type="hidden" id="id_pm_draft" name="id_pm_draft" value="', empty($context['id_pm_draft']) ? 0 : $context['id_pm_draft'], '">';
174
+	}
169 175
 
170
-	if (!empty($context['drafts_save']))
171
-		echo '
176
+	if (!empty($context['drafts_save'])) {
177
+			echo '
172 178
 		<input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="return confirm(' . JavaScriptEscape($txt['draft_save_note']) . ') && submitThisOnce(this);" accesskey="d" class="button">
173 179
 		<input type="hidden" id="id_draft" name="id_draft" value="', empty($context['id_draft']) ? 0 : $context['id_draft'], '">';
180
+	}
174 181
 
175
-	if ($context['show_spellchecking'])
176
-		echo '
182
+	if ($context['show_spellchecking']) {
183
+			echo '
177 184
 		<input type="button" value="', $txt['spell_check'], '" tabindex="', --$tempTab, '" onclick="oEditorHandle_', $editor_id, '.spellCheckStart();" class="button">';
185
+	}
178 186
 
179
-	if ($editor_context['preview_type'])
180
-		echo '
187
+	if ($editor_context['preview_type']) {
188
+			echo '
181 189
 		<input type="submit" name="preview" value="', isset($editor_context['labels']['preview_button']) ? $editor_context['labels']['preview_button'] : $txt['preview'], '" tabindex="', --$tempTab, '" onclick="', $editor_context['preview_type'] == 2 ? 'return event.ctrlKey || previewPost();' : 'return submitThisOnce(this);', '" accesskey="p" class="button">';
190
+	}
182 191
 
183 192
 	echo '
184 193
 		<input type="submit" value="', isset($editor_context['labels']['post_button']) ? $editor_context['labels']['post_button'] : $txt['post'], '" name="post" tabindex="', --$tempTab, '" onclick="return submitThisOnce(this);" accesskey="s" class="button">';
185 194
 
186 195
 	// Load in the PM autosaver if it's enabled
187
-	if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave']))
188
-		echo '
196
+	if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) {
197
+			echo '
189 198
 		<span class="righttext padding" style="display: block">
190 199
 			<span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon"></span>
191 200
 			<span id="draft_lastautosave" ></span>
@@ -203,10 +212,11 @@  discard block
 block discarded – undo
203 212
 				iFreq: ', (empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000), '
204 213
 			});
205 214
 		</script>';
215
+	}
206 216
 
207 217
 	// Start an instance of the auto saver if its enabled
208
-	if (!empty($context['drafts_save']) && !empty($context['drafts_autosave']))
209
-		echo '
218
+	if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) {
219
+			echo '
210 220
 		<span class="righttext padding" style="display: block">
211 221
 			<span id="throbber" style="display:none"><img src="', $settings['images_url'], '/loading_sm.gif" alt="" class="centericon"></span>
212 222
 			<span id="draft_lastautosave" ></span>
@@ -223,7 +233,8 @@  discard block
 block discarded – undo
223 233
 				iFreq: ', $context['drafts_autosave_frequency'], '
224 234
 			});
225 235
 		</script>';
226
-}
236
+	}
237
+	}
227 238
 
228 239
 /**
229 240
  * This template displays a verification form
@@ -240,51 +251,57 @@  discard block
 block discarded – undo
240 251
 	$verify_context = &$context['controls']['verification'][$verify_id];
241 252
 
242 253
 	// Keep track of where we are.
243
-	if (empty($verify_context['tracking']) || $reset)
244
-		$verify_context['tracking'] = 0;
254
+	if (empty($verify_context['tracking']) || $reset) {
255
+			$verify_context['tracking'] = 0;
256
+	}
245 257
 
246 258
 	// How many items are there to display in total.
247 259
 	$total_items = count($verify_context['questions']) + ($verify_context['show_visual'] || $verify_context['can_recaptcha'] ? 1 : 0);
248 260
 
249 261
 	// If we've gone too far, stop.
250
-	if ($verify_context['tracking'] > $total_items)
251
-		return false;
262
+	if ($verify_context['tracking'] > $total_items) {
263
+			return false;
264
+	}
252 265
 
253 266
 	// Loop through each item to show them.
254 267
 	for ($i = 0; $i < $total_items; $i++)
255 268
 	{
256 269
 		// If we're after a single item only show it if we're in the right place.
257
-		if ($display_type == 'single' && $verify_context['tracking'] != $i)
258
-			continue;
270
+		if ($display_type == 'single' && $verify_context['tracking'] != $i) {
271
+					continue;
272
+		}
259 273
 
260
-		if ($display_type != 'single')
261
-			echo '
274
+		if ($display_type != 'single') {
275
+					echo '
262 276
 			<div id="verification_control_', $i, '" class="verification_control">';
277
+		}
263 278
 
264 279
 		// Display empty field, but only if we have one, and it's the first time.
265
-		if ($verify_context['empty_field'] && empty($i))
266
-			echo '
280
+		if ($verify_context['empty_field'] && empty($i)) {
281
+					echo '
267 282
 				<div class="smalltext vv_special">
268 283
 					', $txt['visual_verification_hidden'], ':
269 284
 					<input type="text" name="', $_SESSION[$verify_id . '_vv']['empty_field'], '" autocomplete="off" size="30" value="">
270 285
 				</div>';
286
+		}
271 287
 
272 288
 		// Do the actual stuff
273 289
 		if ($i == 0 && ($verify_context['show_visual'] || $verify_context['can_recaptcha']))
274 290
 		{
275 291
 			if ($verify_context['show_visual'])
276 292
 			{
277
-				if ($context['use_graphic_library'])
278
-					echo '
293
+				if ($context['use_graphic_library']) {
294
+									echo '
279 295
 				<img src="', $verify_context['image_href'], '" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '">';
280
-				else
281
-					echo '
296
+				} else {
297
+									echo '
282 298
 				<img src="', $verify_context['image_href'], ';letter=1" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_1">
283 299
 				<img src="', $verify_context['image_href'], ';letter=2" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_2">
284 300
 				<img src="', $verify_context['image_href'], ';letter=3" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_3">
285 301
 				<img src="', $verify_context['image_href'], ';letter=4" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_4">
286 302
 				<img src="', $verify_context['image_href'], ';letter=5" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_5">
287 303
 				<img src="', $verify_context['image_href'], ';letter=6" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_6">';
304
+				}
288 305
 
289 306
 				echo '
290 307
 				<div class="smalltext" style="margin: 4px 0 8px 0;">
@@ -302,8 +319,7 @@  discard block
 block discarded – undo
302 319
 				<br>
303 320
 				<script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl='.$lang.'"></script>';
304 321
 			}
305
-		}
306
-		else
322
+		} else
307 323
 		{
308 324
 			// Where in the question array is this question?
309 325
 			$qIndex = $verify_context['show_visual'] ? $i - 1 : $i;
@@ -315,21 +331,24 @@  discard block
 block discarded – undo
315 331
 				</div>';
316 332
 		}
317 333
 
318
-		if ($display_type != 'single')
319
-			echo '
334
+		if ($display_type != 'single') {
335
+					echo '
320 336
 			</div><!-- #verification_control_[i] -->';
337
+		}
321 338
 
322 339
 		// If we were displaying just one and we did it, break.
323
-		if ($display_type == 'single' && $verify_context['tracking'] == $i)
324
-			break;
340
+		if ($display_type == 'single' && $verify_context['tracking'] == $i) {
341
+					break;
342
+		}
325 343
 	}
326 344
 
327 345
 	// Assume we found something, always.
328 346
 	$verify_context['tracking']++;
329 347
 
330 348
 	// Tell something displaying piecemeal to keep going.
331
-	if ($display_type == 'single')
332
-		return true;
333
-}
349
+	if ($display_type == 'single') {
350
+			return true;
351
+	}
352
+	}
334 353
 
335 354
 ?>
336 355
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Security.php 1 patch
Braces   +258 added lines, -199 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
  * Check if the user is who he/she says he is
@@ -42,12 +43,14 @@  discard block
 block discarded – undo
42 43
 	$refreshTime = isset($_GET['xml']) ? 4200 : 3600;
43 44
 
44 45
 	// Is the security option off?
45
-	if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')]))
46
-		return;
46
+	if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) {
47
+			return;
48
+	}
47 49
 
48 50
 	// Or are they already logged in?, Moderator or admin session is need for this area
49
-	if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time()))
50
-		return;
51
+	if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) {
52
+			return;
53
+	}
51 54
 
52 55
 	require_once($sourcedir . '/Subs-Auth.php');
53 56
 
@@ -55,8 +58,9 @@  discard block
 block discarded – undo
55 58
 	if (isset($_POST[$type . '_pass']))
56 59
 	{
57 60
 		// Check to ensure we're forcing SSL for authentication
58
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
59
-			fatal_lang_error('login_ssl_required');
61
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
62
+					fatal_lang_error('login_ssl_required');
63
+		}
60 64
 
61 65
 		checkSession();
62 66
 
@@ -72,17 +76,19 @@  discard block
 block discarded – undo
72 76
 	}
73 77
 
74 78
 	// Better be sure to remember the real referer
75
-	if (empty($_SESSION['request_referer']))
76
-		$_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
77
-	elseif (empty($_POST))
78
-		unset($_SESSION['request_referer']);
79
+	if (empty($_SESSION['request_referer'])) {
80
+			$_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
81
+	} elseif (empty($_POST)) {
82
+			unset($_SESSION['request_referer']);
83
+	}
79 84
 
80 85
 	// Need to type in a password for that, man.
81
-	if (!isset($_GET['xml']))
82
-		adminLogin($type);
83
-	else
84
-		return 'session_verify_fail';
85
-}
86
+	if (!isset($_GET['xml'])) {
87
+			adminLogin($type);
88
+	} else {
89
+			return 'session_verify_fail';
90
+	}
91
+	}
86 92
 
87 93
 /**
88 94
  * Require a user who is logged in. (not a guest.)
@@ -96,25 +102,30 @@  discard block
 block discarded – undo
96 102
 	global $user_info, $txt, $context, $scripturl, $modSettings;
97 103
 
98 104
 	// Luckily, this person isn't a guest.
99
-	if (!$user_info['is_guest'])
100
-		return;
105
+	if (!$user_info['is_guest']) {
106
+			return;
107
+	}
101 108
 
102 109
 	// Log what they were trying to do didn't work)
103
-	if (!empty($modSettings['who_enabled']))
104
-		$_GET['error'] = 'guest_login';
110
+	if (!empty($modSettings['who_enabled'])) {
111
+			$_GET['error'] = 'guest_login';
112
+	}
105 113
 	writeLog(true);
106 114
 
107 115
 	// Just die.
108
-	if (isset($_REQUEST['xml']))
109
-		obExit(false);
116
+	if (isset($_REQUEST['xml'])) {
117
+			obExit(false);
118
+	}
110 119
 
111 120
 	// Attempt to detect if they came from dlattach.
112
-	if (SMF != 'SSI' && empty($context['theme_loaded']))
113
-		loadTheme();
121
+	if (SMF != 'SSI' && empty($context['theme_loaded'])) {
122
+			loadTheme();
123
+	}
114 124
 
115 125
 	// Never redirect to an attachment
116
-	if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false)
117
-		$_SESSION['login_url'] = $_SERVER['REQUEST_URL'];
126
+	if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) {
127
+			$_SESSION['login_url'] = $_SERVER['REQUEST_URL'];
128
+	}
118 129
 
119 130
 	// Load the Login template and language file.
120 131
 	loadLanguage('Login');
@@ -124,8 +135,7 @@  discard block
 block discarded – undo
124 135
 	{
125 136
 		$_SESSION['login_url'] = $scripturl . '?' . $_SERVER['QUERY_STRING'];
126 137
 		redirectexit('action=login');
127
-	}
128
-	else
138
+	} else
129 139
 	{
130 140
 		loadTemplate('Login');
131 141
 		$context['sub_template'] = 'kick_guest';
@@ -155,8 +165,9 @@  discard block
 block discarded – undo
155 165
 	global $sourcedir, $cookiename, $user_settings, $smcFunc;
156 166
 
157 167
 	// You cannot be banned if you are an admin - doesn't help if you log out.
158
-	if ($user_info['is_admin'])
159
-		return;
168
+	if ($user_info['is_admin']) {
169
+			return;
170
+	}
160 171
 
161 172
 	// Only check the ban every so often. (to reduce load.)
162 173
 	if ($forceCheck || !isset($_SESSION['ban']) || empty($modSettings['banLastUpdated']) || ($_SESSION['ban']['last_checked'] < $modSettings['banLastUpdated']) || $_SESSION['ban']['id_member'] != $user_info['id'] || $_SESSION['ban']['ip'] != $user_info['ip'] || $_SESSION['ban']['ip2'] != $user_info['ip2'] || (isset($user_info['email'], $_SESSION['ban']['email']) && $_SESSION['ban']['email'] != $user_info['email']))
@@ -177,8 +188,9 @@  discard block
 block discarded – undo
177 188
 		// Check both IP addresses.
178 189
 		foreach (array('ip', 'ip2') as $ip_number)
179 190
 		{
180
-			if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip'])
181
-				continue;
191
+			if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) {
192
+							continue;
193
+			}
182 194
 			$ban_query[] = ' {inet:' . $ip_number . '} BETWEEN bi.ip_low and bi.ip_high';
183 195
 			$ban_query_vars[$ip_number] = $user_info[$ip_number];
184 196
 			// IP was valid, maybe there's also a hostname...
@@ -228,24 +240,28 @@  discard block
 block discarded – undo
228 240
 			// Store every type of ban that applies to you in your session.
229 241
 			while ($row = $smcFunc['db_fetch_assoc']($request))
230 242
 			{
231
-				foreach ($restrictions as $restriction)
232
-					if (!empty($row[$restriction]))
243
+				foreach ($restrictions as $restriction) {
244
+									if (!empty($row[$restriction]))
233 245
 					{
234 246
 						$_SESSION['ban'][$restriction]['reason'] = $row['reason'];
247
+				}
235 248
 						$_SESSION['ban'][$restriction]['ids'][] = $row['id_ban'];
236
-						if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time'])))
237
-							$_SESSION['ban']['expire_time'] = $row['expire_time'];
249
+						if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) {
250
+													$_SESSION['ban']['expire_time'] = $row['expire_time'];
251
+						}
238 252
 
239
-						if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email']))
240
-							$flag_is_activated = true;
253
+						if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) {
254
+													$flag_is_activated = true;
255
+						}
241 256
 					}
242 257
 			}
243 258
 			$smcFunc['db_free_result']($request);
244 259
 		}
245 260
 
246 261
 		// Mark the cannot_access and cannot_post bans as being 'hit'.
247
-		if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login']))
248
-			log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array()));
262
+		if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) {
263
+					log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array()));
264
+		}
249 265
 
250 266
 		// If for whatever reason the is_activated flag seems wrong, do a little work to clear it up.
251 267
 		if ($user_info['id'] && (($user_settings['is_activated'] >= 10 && !$flag_is_activated)
@@ -260,8 +276,9 @@  discard block
 block discarded – undo
260 276
 	if (!isset($_SESSION['ban']['cannot_access']) && !empty($_COOKIE[$cookiename . '_']))
261 277
 	{
262 278
 		$bans = explode(',', $_COOKIE[$cookiename . '_']);
263
-		foreach ($bans as $key => $value)
264
-			$bans[$key] = (int) $value;
279
+		foreach ($bans as $key => $value) {
280
+					$bans[$key] = (int) $value;
281
+		}
265 282
 		$request = $smcFunc['db_query']('', '
266 283
 			SELECT bi.id_ban, bg.reason
267 284
 			FROM {db_prefix}ban_items AS bi
@@ -297,14 +314,15 @@  discard block
 block discarded – undo
297 314
 	if (isset($_SESSION['ban']['cannot_access']))
298 315
 	{
299 316
 		// We don't wanna see you!
300
-		if (!$user_info['is_guest'])
301
-			$smcFunc['db_query']('', '
317
+		if (!$user_info['is_guest']) {
318
+					$smcFunc['db_query']('', '
302 319
 				DELETE FROM {db_prefix}log_online
303 320
 				WHERE id_member = {int:current_member}',
304 321
 				array(
305 322
 					'current_member' => $user_info['id'],
306 323
 				)
307 324
 			);
325
+		}
308 326
 
309 327
 		// 'Log' the user out.  Can't have any funny business... (save the name!)
310 328
 		$old_name = isset($user_info['name']) && $user_info['name'] != '' ? $user_info['name'] : $txt['guest_title'];
@@ -390,9 +408,10 @@  discard block
 block discarded – undo
390 408
 	}
391 409
 
392 410
 	// Fix up the banning permissions.
393
-	if (isset($user_info['permissions']))
394
-		banPermissions();
395
-}
411
+	if (isset($user_info['permissions'])) {
412
+			banPermissions();
413
+	}
414
+	}
396 415
 
397 416
 /**
398 417
  * Fix permissions according to ban status.
@@ -403,8 +422,9 @@  discard block
 block discarded – undo
403 422
 	global $user_info, $sourcedir, $modSettings, $context;
404 423
 
405 424
 	// Somehow they got here, at least take away all permissions...
406
-	if (isset($_SESSION['ban']['cannot_access']))
407
-		$user_info['permissions'] = array();
425
+	if (isset($_SESSION['ban']['cannot_access'])) {
426
+			$user_info['permissions'] = array();
427
+	}
408 428
 	// Okay, well, you can watch, but don't touch a thing.
409 429
 	elseif (isset($_SESSION['ban']['cannot_post']) || (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $user_info['warning']))
410 430
 	{
@@ -446,19 +466,20 @@  discard block
 block discarded – undo
446 466
 		call_integration_hook('integrate_warn_permissions', array(&$permission_change));
447 467
 		foreach ($permission_change as $old => $new)
448 468
 		{
449
-			if (!in_array($old, $user_info['permissions']))
450
-				unset($permission_change[$old]);
451
-			else
452
-				$user_info['permissions'][] = $new;
469
+			if (!in_array($old, $user_info['permissions'])) {
470
+							unset($permission_change[$old]);
471
+			} else {
472
+							$user_info['permissions'][] = $new;
473
+			}
453 474
 		}
454 475
 		$user_info['permissions'] = array_diff($user_info['permissions'], array_keys($permission_change));
455 476
 	}
456 477
 
457 478
 	// @todo Find a better place to call this? Needs to be after permissions loaded!
458 479
 	// Finally, some bits we cache in the session because it saves queries.
459
-	if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id'])
460
-		$user_info['mod_cache'] = $_SESSION['mc'];
461
-	else
480
+	if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) {
481
+			$user_info['mod_cache'] = $_SESSION['mc'];
482
+	} else
462 483
 	{
463 484
 		require_once($sourcedir . '/Subs-Auth.php');
464 485
 		rebuildModCache();
@@ -469,14 +490,12 @@  discard block
 block discarded – undo
469 490
 	{
470 491
 		$context['open_mod_reports'] = $_SESSION['rc']['reports'];
471 492
 		$context['open_member_reports'] = $_SESSION['rc']['member_reports'];
472
-	}
473
-	elseif ($_SESSION['mc']['bq'] != '0=1')
493
+	} elseif ($_SESSION['mc']['bq'] != '0=1')
474 494
 	{
475 495
 		require_once($sourcedir . '/Subs-ReportedContent.php');
476 496
 		$context['open_mod_reports'] = recountOpenReports('posts');
477 497
 		$context['open_member_reports'] = recountOpenReports('members');
478
-	}
479
-	else
498
+	} else
480 499
 	{
481 500
 		$context['open_mod_reports'] = 0;
482 501
 		$context['open_member_reports'] = 0;
@@ -496,8 +515,9 @@  discard block
 block discarded – undo
496 515
 	global $user_info, $smcFunc;
497 516
 
498 517
 	// Don't log web accelerators, it's very confusing...
499
-	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
500
-		return;
518
+	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') {
519
+			return;
520
+	}
501 521
 
502 522
 	$smcFunc['db_insert']('',
503 523
 		'{db_prefix}log_banned',
@@ -507,8 +527,8 @@  discard block
 block discarded – undo
507 527
 	);
508 528
 
509 529
 	// One extra point for these bans.
510
-	if (!empty($ban_ids))
511
-		$smcFunc['db_query']('', '
530
+	if (!empty($ban_ids)) {
531
+			$smcFunc['db_query']('', '
512 532
 			UPDATE {db_prefix}ban_items
513 533
 			SET hits = hits + 1
514 534
 			WHERE id_ban IN ({array_int:ban_ids})',
@@ -516,7 +536,8 @@  discard block
 block discarded – undo
516 536
 				'ban_ids' => $ban_ids,
517 537
 			)
518 538
 		);
519
-}
539
+	}
540
+	}
520 541
 
521 542
 /**
522 543
  * Checks if a given email address might be banned.
@@ -532,8 +553,9 @@  discard block
 block discarded – undo
532 553
 	global $txt, $smcFunc;
533 554
 
534 555
 	// Can't ban an empty email
535
-	if (empty($email) || trim($email) == '')
536
-		return;
556
+	if (empty($email) || trim($email) == '') {
557
+			return;
558
+	}
537 559
 
538 560
 	// Let's start with the bans based on your IP/hostname/memberID...
539 561
 	$ban_ids = isset($_SESSION['ban'][$restriction]) ? $_SESSION['ban'][$restriction]['ids'] : array();
@@ -606,16 +628,18 @@  discard block
 block discarded – undo
606 628
 	if ($type == 'post')
607 629
 	{
608 630
 		$check = isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null);
609
-		if ($check !== $sc)
610
-			$error = 'session_timeout';
631
+		if ($check !== $sc) {
632
+					$error = 'session_timeout';
633
+		}
611 634
 	}
612 635
 
613 636
 	// How about $_GET['sesc']?
614 637
 	elseif ($type == 'get')
615 638
 	{
616 639
 		$check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : null);
617
-		if ($check !== $sc)
618
-			$error = 'session_verify_fail';
640
+		if ($check !== $sc) {
641
+					$error = 'session_verify_fail';
642
+		}
619 643
 	}
620 644
 
621 645
 	// Or can it be in either?
@@ -623,13 +647,15 @@  discard block
 block discarded – undo
623 647
 	{
624 648
 		$check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : (isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null)));
625 649
 
626
-		if ($check !== $sc)
627
-			$error = 'session_verify_fail';
650
+		if ($check !== $sc) {
651
+					$error = 'session_verify_fail';
652
+		}
628 653
 	}
629 654
 
630 655
 	// Verify that they aren't changing user agents on us - that could be bad.
631
-	if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA']))
632
-		$error = 'session_verify_fail';
656
+	if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) {
657
+			$error = 'session_verify_fail';
658
+	}
633 659
 
634 660
 	// Make sure a page with session check requirement is not being prefetched.
635 661
 	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
@@ -640,30 +666,35 @@  discard block
 block discarded – undo
640 666
 	}
641 667
 
642 668
 	// Check the referring site - it should be the same server at least!
643
-	if (isset($_SESSION['request_referer']))
644
-		$referrer = $_SESSION['request_referer'];
645
-	else
646
-		$referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
669
+	if (isset($_SESSION['request_referer'])) {
670
+			$referrer = $_SESSION['request_referer'];
671
+	} else {
672
+			$referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
673
+	}
647 674
 	if (!empty($referrer['host']))
648 675
 	{
649
-		if (strpos($_SERVER['HTTP_HOST'], ':') !== false)
650
-			$real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':'));
651
-		else
652
-			$real_host = $_SERVER['HTTP_HOST'];
676
+		if (strpos($_SERVER['HTTP_HOST'], ':') !== false) {
677
+					$real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':'));
678
+		} else {
679
+					$real_host = $_SERVER['HTTP_HOST'];
680
+		}
653 681
 
654 682
 		$parsed_url = parse_url($boardurl);
655 683
 
656 684
 		// Are global cookies on?  If so, let's check them ;).
657 685
 		if (!empty($modSettings['globalCookies']))
658 686
 		{
659
-			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1)
660
-				$parsed_url['host'] = $parts[1];
687
+			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) {
688
+							$parsed_url['host'] = $parts[1];
689
+			}
661 690
 
662
-			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1)
663
-				$referrer['host'] = $parts[1];
691
+			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) {
692
+							$referrer['host'] = $parts[1];
693
+			}
664 694
 
665
-			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1)
666
-				$real_host = $parts[1];
695
+			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) {
696
+							$real_host = $parts[1];
697
+			}
667 698
 		}
668 699
 
669 700
 		// Okay: referrer must either match parsed_url or real_host.
@@ -681,12 +712,14 @@  discard block
 block discarded – undo
681 712
 		$log_error = true;
682 713
 	}
683 714
 
684
-	if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker')
685
-		fatal_error('Sound the alarm!  It\'s a hacker!  Close the castle gates!!', false);
715
+	if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') {
716
+			fatal_error('Sound the alarm!  It\'s a hacker!  Close the castle gates!!', false);
717
+	}
686 718
 
687 719
 	// Everything is ok, return an empty string.
688
-	if (!isset($error))
689
-		return '';
720
+	if (!isset($error)) {
721
+			return '';
722
+	}
690 723
 	// A session error occurred, show the error.
691 724
 	elseif ($is_fatal)
692 725
 	{
@@ -695,13 +728,14 @@  discard block
 block discarded – undo
695 728
 			ob_end_clean();
696 729
 			header('HTTP/1.1 403 Forbidden - Session timeout');
697 730
 			die;
731
+		} else {
732
+					fatal_lang_error($error, isset($log_error) ? 'user' : false);
698 733
 		}
699
-		else
700
-			fatal_lang_error($error, isset($log_error) ? 'user' : false);
701 734
 	}
702 735
 	// A session error occurred, return the error to the calling function.
703
-	else
704
-		return $error;
736
+	else {
737
+			return $error;
738
+	}
705 739
 
706 740
 	// We really should never fall through here, for very important reasons.  Let's make sure.
707 741
 	trigger_error('Hacking attempt...', E_USER_ERROR);
@@ -717,10 +751,9 @@  discard block
 block discarded – undo
717 751
 {
718 752
 	global $modSettings;
719 753
 
720
-	if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action])
721
-		return true;
722
-
723
-	else
754
+	if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) {
755
+			return true;
756
+	} else
724 757
 	{
725 758
 		$token = md5(mt_rand() . session_id() . (string) microtime() . $modSettings['rand_seed']);
726 759
 		$_SESSION['confirm_' . $action] = md5($token . $_SERVER['HTTP_USER_AGENT']);
@@ -771,9 +804,9 @@  discard block
 block discarded – undo
771 804
 			$return = $_SESSION['token'][$type . '-' . $action][3];
772 805
 			unset($_SESSION['token'][$type . '-' . $action]);
773 806
 			return $return;
807
+		} else {
808
+					return '';
774 809
 		}
775
-		else
776
-			return '';
777 810
 	}
778 811
 
779 812
 	// This nasty piece of code validates a token.
@@ -804,12 +837,14 @@  discard block
 block discarded – undo
804 837
 		fatal_lang_error('token_verify_fail', false);
805 838
 	}
806 839
 	// Remove this token as its useless
807
-	else
808
-		unset($_SESSION['token'][$type . '-' . $action]);
840
+	else {
841
+			unset($_SESSION['token'][$type . '-' . $action]);
842
+	}
809 843
 
810 844
 	// Randomly check if we should remove some older tokens.
811
-	if (mt_rand(0, 138) == 23)
812
-		cleanTokens();
845
+	if (mt_rand(0, 138) == 23) {
846
+			cleanTokens();
847
+	}
813 848
 
814 849
 	return false;
815 850
 }
@@ -824,14 +859,16 @@  discard block
 block discarded – undo
824 859
 function cleanTokens($complete = false)
825 860
 {
826 861
 	// We appreciate cleaning up after yourselves.
827
-	if (!isset($_SESSION['token']))
828
-		return;
862
+	if (!isset($_SESSION['token'])) {
863
+			return;
864
+	}
829 865
 
830 866
 	// Clean up tokens, trying to give enough time still.
831
-	foreach ($_SESSION['token'] as $key => $data)
832
-		if ($data[2] + 10800 < time() || $complete)
867
+	foreach ($_SESSION['token'] as $key => $data) {
868
+			if ($data[2] + 10800 < time() || $complete)
833 869
 			unset($_SESSION['token'][$key]);
834
-}
870
+	}
871
+	}
835 872
 
836 873
 /**
837 874
  * Check whether a form has been submitted twice.
@@ -849,37 +886,40 @@  discard block
 block discarded – undo
849 886
 {
850 887
 	global $context;
851 888
 
852
-	if (!isset($_SESSION['forms']))
853
-		$_SESSION['forms'] = array();
889
+	if (!isset($_SESSION['forms'])) {
890
+			$_SESSION['forms'] = array();
891
+	}
854 892
 
855 893
 	// Register a form number and store it in the session stack. (use this on the page that has the form.)
856 894
 	if ($action == 'register')
857 895
 	{
858 896
 		$context['form_sequence_number'] = 0;
859
-		while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms']))
860
-			$context['form_sequence_number'] = mt_rand(1, 16000000);
897
+		while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) {
898
+					$context['form_sequence_number'] = mt_rand(1, 16000000);
899
+		}
861 900
 	}
862 901
 	// Check whether the submitted number can be found in the session.
863 902
 	elseif ($action == 'check')
864 903
 	{
865
-		if (!isset($_REQUEST['seqnum']))
866
-			return true;
867
-		elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms']))
904
+		if (!isset($_REQUEST['seqnum'])) {
905
+					return true;
906
+		} elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms']))
868 907
 		{
869 908
 			$_SESSION['forms'][] = (int) $_REQUEST['seqnum'];
870 909
 			return true;
910
+		} elseif ($is_fatal) {
911
+					fatal_lang_error('error_form_already_submitted', false);
912
+		} else {
913
+					return false;
871 914
 		}
872
-		elseif ($is_fatal)
873
-			fatal_lang_error('error_form_already_submitted', false);
874
-		else
875
-			return false;
876 915
 	}
877 916
 	// Don't check, just free the stack number.
878
-	elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms']))
879
-		$_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum']));
880
-	elseif ($action != 'free')
881
-		trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING);
882
-}
917
+	elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) {
918
+			$_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum']));
919
+	} elseif ($action != 'free') {
920
+			trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING);
921
+	}
922
+	}
883 923
 
884 924
 /**
885 925
  * Check the user's permissions.
@@ -898,16 +938,19 @@  discard block
 block discarded – undo
898 938
 	global $user_info, $smcFunc;
899 939
 
900 940
 	// You're always allowed to do nothing. (unless you're a working man, MR. LAZY :P!)
901
-	if (empty($permission))
902
-		return true;
941
+	if (empty($permission)) {
942
+			return true;
943
+	}
903 944
 
904 945
 	// You're never allowed to do something if your data hasn't been loaded yet!
905
-	if (empty($user_info))
906
-		return false;
946
+	if (empty($user_info)) {
947
+			return false;
948
+	}
907 949
 
908 950
 	// Administrators are supermen :P.
909
-	if ($user_info['is_admin'])
910
-		return true;
951
+	if ($user_info['is_admin']) {
952
+			return true;
953
+	}
911 954
 
912 955
 	// Let's ensure this is an array.
913 956
 	$permission = (array) $permission;
@@ -915,14 +958,16 @@  discard block
 block discarded – undo
915 958
 	// Are we checking the _current_ board, or some other boards?
916 959
 	if ($boards === null)
917 960
 	{
918
-		if (count(array_intersect($permission, $user_info['permissions'])) != 0)
919
-			return true;
961
+		if (count(array_intersect($permission, $user_info['permissions'])) != 0) {
962
+					return true;
963
+		}
920 964
 		// You aren't allowed, by default.
921
-		else
922
-			return false;
965
+		else {
966
+					return false;
967
+		}
968
+	} elseif (!is_array($boards)) {
969
+			$boards = array($boards);
923 970
 	}
924
-	elseif (!is_array($boards))
925
-		$boards = array($boards);
926 971
 
927 972
 	$request = $smcFunc['db_query']('', '
928 973
 		SELECT MIN(bp.add_deny) AS add_deny
@@ -950,20 +995,23 @@  discard block
 block discarded – undo
950 995
 		while ($row = $smcFunc['db_fetch_assoc']($request))
951 996
 		{
952 997
 			$result = !empty($row['add_deny']);
953
-			if ($result == true)
954
-				break;
998
+			if ($result == true) {
999
+							break;
1000
+			}
955 1001
 		}
956 1002
 		$smcFunc['db_free_result']($request);
957 1003
 		return $result;
958 1004
 	}
959 1005
 
960 1006
 	// Make sure they can do it on all of the boards.
961
-	if ($smcFunc['db_num_rows']($request) != count($boards))
962
-		return false;
1007
+	if ($smcFunc['db_num_rows']($request) != count($boards)) {
1008
+			return false;
1009
+	}
963 1010
 
964 1011
 	$result = true;
965
-	while ($row = $smcFunc['db_fetch_assoc']($request))
966
-		$result &= !empty($row['add_deny']);
1012
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1013
+			$result &= !empty($row['add_deny']);
1014
+	}
967 1015
 	$smcFunc['db_free_result']($request);
968 1016
 
969 1017
 	// If the query returned 1, they can do it... otherwise, they can't.
@@ -1030,9 +1078,10 @@  discard block
 block discarded – undo
1030 1078
 
1031 1079
 	// If you're doing something on behalf of some "heavy" permissions, validate your session.
1032 1080
 	// (take out the heavy permissions, and if you can't do anything but those, you need a validated session.)
1033
-	if (!allowedTo(array_diff($permission, $heavy_permissions), $boards))
1034
-		validateSession();
1035
-}
1081
+	if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) {
1082
+			validateSession();
1083
+	}
1084
+	}
1036 1085
 
1037 1086
 /**
1038 1087
  * Return the boards a user has a certain (board) permission on. (array(0) if all.)
@@ -1051,8 +1100,9 @@  discard block
 block discarded – undo
1051 1100
 	global $user_info, $smcFunc;
1052 1101
 
1053 1102
 	// Arrays are nice, most of the time.
1054
-	if (!is_array($permissions))
1055
-		$permissions = array($permissions);
1103
+	if (!is_array($permissions)) {
1104
+			$permissions = array($permissions);
1105
+	}
1056 1106
 
1057 1107
 	/*
1058 1108
 	 * Set $simple to true to use this function as it were in SMF 2.0.x.
@@ -1064,13 +1114,14 @@  discard block
 block discarded – undo
1064 1114
 	// Administrators are all powerful, sorry.
1065 1115
 	if ($user_info['is_admin'])
1066 1116
 	{
1067
-		if ($simple)
1068
-			return array(0);
1069
-		else
1117
+		if ($simple) {
1118
+					return array(0);
1119
+		} else
1070 1120
 		{
1071 1121
 			$boards = array();
1072
-			foreach ($permissions as $permission)
1073
-				$boards[$permission] = array(0);
1122
+			foreach ($permissions as $permission) {
1123
+							$boards[$permission] = array(0);
1124
+			}
1074 1125
 
1075 1126
 			return $boards;
1076 1127
 		}
@@ -1102,31 +1153,32 @@  discard block
 block discarded – undo
1102 1153
 	{
1103 1154
 		if ($simple)
1104 1155
 		{
1105
-			if (empty($row['add_deny']))
1106
-				$deny_boards[] = $row['id_board'];
1107
-			else
1108
-				$boards[] = $row['id_board'];
1109
-		}
1110
-		else
1156
+			if (empty($row['add_deny'])) {
1157
+							$deny_boards[] = $row['id_board'];
1158
+			} else {
1159
+							$boards[] = $row['id_board'];
1160
+			}
1161
+		} else
1111 1162
 		{
1112
-			if (empty($row['add_deny']))
1113
-				$deny_boards[$row['permission']][] = $row['id_board'];
1114
-			else
1115
-				$boards[$row['permission']][] = $row['id_board'];
1163
+			if (empty($row['add_deny'])) {
1164
+							$deny_boards[$row['permission']][] = $row['id_board'];
1165
+			} else {
1166
+							$boards[$row['permission']][] = $row['id_board'];
1167
+			}
1116 1168
 		}
1117 1169
 	}
1118 1170
 	$smcFunc['db_free_result']($request);
1119 1171
 
1120
-	if ($simple)
1121
-		$boards = array_unique(array_values(array_diff($boards, $deny_boards)));
1122
-	else
1172
+	if ($simple) {
1173
+			$boards = array_unique(array_values(array_diff($boards, $deny_boards)));
1174
+	} else
1123 1175
 	{
1124 1176
 		foreach ($permissions as $permission)
1125 1177
 		{
1126 1178
 			// never had it to start with
1127
-			if (empty($boards[$permission]))
1128
-				$boards[$permission] = array();
1129
-			else
1179
+			if (empty($boards[$permission])) {
1180
+							$boards[$permission] = array();
1181
+			} else
1130 1182
 			{
1131 1183
 				// Or it may have been removed
1132 1184
 				$deny_boards[$permission] = isset($deny_boards[$permission]) ? $deny_boards[$permission] : array();
@@ -1162,10 +1214,11 @@  discard block
 block discarded – undo
1162 1214
 
1163 1215
 
1164 1216
 	// Moderators are free...
1165
-	if (!allowedTo('moderate_board'))
1166
-		$timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime'];
1167
-	else
1168
-		$timeLimit = 2;
1217
+	if (!allowedTo('moderate_board')) {
1218
+			$timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime'];
1219
+	} else {
1220
+			$timeLimit = 2;
1221
+	}
1169 1222
 
1170 1223
 	call_integration_hook('integrate_spam_protection', array(&$timeOverrides, &$timeLimit));
1171 1224
 
@@ -1192,8 +1245,9 @@  discard block
 block discarded – undo
1192 1245
 	if ($smcFunc['db_affected_rows']() != 1)
1193 1246
 	{
1194 1247
 		// Spammer!  You only have to wait a *few* seconds!
1195
-		if (!$only_return_result)
1196
-			fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit));
1248
+		if (!$only_return_result) {
1249
+					fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit));
1250
+		}
1197 1251
 
1198 1252
 		return true;
1199 1253
 	}
@@ -1211,11 +1265,13 @@  discard block
 block discarded – undo
1211 1265
  */
1212 1266
 function secureDirectory($path, $attachments = false)
1213 1267
 {
1214
-	if (empty($path))
1215
-		return 'empty_path';
1268
+	if (empty($path)) {
1269
+			return 'empty_path';
1270
+	}
1216 1271
 
1217
-	if (!is_writable($path))
1218
-		return 'path_not_writable';
1272
+	if (!is_writable($path)) {
1273
+			return 'path_not_writable';
1274
+	}
1219 1275
 
1220 1276
 	$directoryname = basename($path);
1221 1277
 
@@ -1227,9 +1283,9 @@  discard block
 block discarded – undo
1227 1283
 
1228 1284
 RemoveHandler .php .php3 .phtml .cgi .fcgi .pl .fpl .shtml';
1229 1285
 
1230
-	if (file_exists($path . '/.htaccess'))
1231
-		$errors[] = 'htaccess_exists';
1232
-	else
1286
+	if (file_exists($path . '/.htaccess')) {
1287
+			$errors[] = 'htaccess_exists';
1288
+	} else
1233 1289
 	{
1234 1290
 		$fh = @fopen($path . '/.htaccess', 'w');
1235 1291
 		if ($fh) {
@@ -1241,9 +1297,9 @@  discard block
 block discarded – undo
1241 1297
 		$errors[] = 'htaccess_cannot_create_file';
1242 1298
 	}
1243 1299
 
1244
-	if (file_exists($path . '/index.php'))
1245
-		$errors[] = 'index-php_exists';
1246
-	else
1300
+	if (file_exists($path . '/index.php')) {
1301
+			$errors[] = 'index-php_exists';
1302
+	} else
1247 1303
 	{
1248 1304
 		$fh = @fopen($path . '/index.php', 'w');
1249 1305
 		if ($fh) {
@@ -1270,11 +1326,12 @@  discard block
 block discarded – undo
1270 1326
 		$errors[] = 'index-php_cannot_create_file';
1271 1327
 	}
1272 1328
 
1273
-	if (!empty($errors))
1274
-		return $errors;
1275
-	else
1276
-		return true;
1277
-}
1329
+	if (!empty($errors)) {
1330
+			return $errors;
1331
+	} else {
1332
+			return true;
1333
+	}
1334
+	}
1278 1335
 
1279 1336
 /**
1280 1337
 * This sets the X-Frame-Options header.
@@ -1287,14 +1344,16 @@  discard block
 block discarded – undo
1287 1344
 	global $modSettings;
1288 1345
 
1289 1346
 	$option = 'SAMEORIGIN';
1290
-	if (is_null($override) && !empty($modSettings['frame_security']))
1291
-		$option = $modSettings['frame_security'];
1292
-	elseif (in_array($override, array('SAMEORIGIN', 'DENY')))
1293
-		$option = $override;
1347
+	if (is_null($override) && !empty($modSettings['frame_security'])) {
1348
+			$option = $modSettings['frame_security'];
1349
+	} elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) {
1350
+			$option = $override;
1351
+	}
1294 1352
 
1295 1353
 	// Don't bother setting the header if we have disabled it.
1296
-	if ($option == 'DISABLE')
1297
-		return;
1354
+	if ($option == 'DISABLE') {
1355
+			return;
1356
+	}
1298 1357
 
1299 1358
 	// Finally set it.
1300 1359
 	header('X-Frame-Options: ' . $option);
Please login to merge, or discard this patch.
Sources/Profile-View.php 1 patch
Braces   +302 added lines, -221 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 4
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('No direct access...');
16
+}
16 17
 
17 18
 /**
18 19
  * View a summary.
@@ -23,8 +24,9 @@  discard block
 block discarded – undo
23 24
 	global $context, $memberContext, $txt, $modSettings, $user_profile, $sourcedir, $scripturl, $smcFunc;
24 25
 
25 26
 	// Attempt to load the member's profile data.
26
-	if (!loadMemberContext($memID) || !isset($memberContext[$memID]))
27
-		fatal_lang_error('not_a_user', false, 404);
27
+	if (!loadMemberContext($memID) || !isset($memberContext[$memID])) {
28
+			fatal_lang_error('not_a_user', false, 404);
29
+	}
28 30
 
29 31
 	// Set up the stuff and load the user.
30 32
 	$context += array(
@@ -49,19 +51,21 @@  discard block
 block discarded – undo
49 51
 
50 52
 	// See if they have broken any warning levels...
51 53
 	list ($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']);
52
-	if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning'])
53
-		$context['warning_status'] = $txt['profile_warning_is_muted'];
54
-	elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning'])
55
-		$context['warning_status'] = $txt['profile_warning_is_moderation'];
56
-	elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning'])
57
-		$context['warning_status'] = $txt['profile_warning_is_watch'];
54
+	if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) {
55
+			$context['warning_status'] = $txt['profile_warning_is_muted'];
56
+	} elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) {
57
+			$context['warning_status'] = $txt['profile_warning_is_moderation'];
58
+	} elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) {
59
+			$context['warning_status'] = $txt['profile_warning_is_watch'];
60
+	}
58 61
 
59 62
 	// They haven't even been registered for a full day!?
60 63
 	$days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24));
61
-	if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1)
62
-		$context['member']['posts_per_day'] = $txt['not_applicable'];
63
-	else
64
-		$context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3);
64
+	if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) {
65
+			$context['member']['posts_per_day'] = $txt['not_applicable'];
66
+	} else {
67
+			$context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3);
68
+	}
65 69
 
66 70
 	// Set the age...
67 71
 	if (empty($context['member']['birth_date']) || substr($context['member']['birth_date'], 0, 4) < 1002)
@@ -70,8 +74,7 @@  discard block
 block discarded – undo
70 74
 			'age' => $txt['not_applicable'],
71 75
 			'today_is_birthday' => false
72 76
 		);
73
-	}
74
-	else
77
+	} else
75 78
 	{
76 79
 		list ($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d');
77 80
 		$datearray = getdate(forum_time());
@@ -84,15 +87,16 @@  discard block
 block discarded – undo
84 87
 	if (allowedTo('moderate_forum'))
85 88
 	{
86 89
 		// Make sure it's a valid ip address; otherwise, don't bother...
87
-		if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup']))
88
-			$context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']);
89
-		else
90
-			$context['member']['hostname'] = '';
90
+		if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) {
91
+					$context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']);
92
+		} else {
93
+					$context['member']['hostname'] = '';
94
+		}
91 95
 
92 96
 		$context['can_see_ip'] = true;
97
+	} else {
98
+			$context['can_see_ip'] = false;
93 99
 	}
94
-	else
95
-		$context['can_see_ip'] = false;
96 100
 
97 101
 	// Are they hidden?
98 102
 	$context['member']['is_hidden'] = empty($user_profile[$memID]['show_online']);
@@ -103,8 +107,9 @@  discard block
 block discarded – undo
103 107
 		include_once($sourcedir . '/Who.php');
104 108
 		$action = determineActions($user_profile[$memID]['url']);
105 109
 
106
-		if ($action !== false)
107
-			$context['member']['action'] = $action;
110
+		if ($action !== false) {
111
+					$context['member']['action'] = $action;
112
+		}
108 113
 	}
109 114
 
110 115
 	// If the user is awaiting activation, and the viewer has permission - setup some activation context messages.
@@ -167,13 +172,15 @@  discard block
 block discarded – undo
167 172
 		{
168 173
 			// Work out what restrictions we actually have.
169 174
 			$ban_restrictions = array();
170
-			foreach (array('access', 'login', 'post') as $type)
171
-				if ($row['cannot_' . $type])
175
+			foreach (array('access', 'login', 'post') as $type) {
176
+							if ($row['cannot_' . $type])
172 177
 					$ban_restrictions[] = $txt['ban_type_' . $type];
178
+			}
173 179
 
174 180
 			// No actual ban in place?
175
-			if (empty($ban_restrictions))
176
-				continue;
181
+			if (empty($ban_restrictions)) {
182
+							continue;
183
+			}
177 184
 
178 185
 			// Prepare the link for context.
179 186
 			$ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=admin;area=ban;sa=edit;bg=' . $row['id_ban_group'] . '">' . $row['name'] . '</a>');
@@ -195,9 +202,10 @@  discard block
 block discarded – undo
195 202
 	$context['print_custom_fields'] = array();
196 203
 
197 204
 	// Any custom profile fields?
198
-	if (!empty($context['custom_fields']))
199
-		foreach ($context['custom_fields'] as $custom)
205
+	if (!empty($context['custom_fields'])) {
206
+			foreach ($context['custom_fields'] as $custom)
200 207
 			$context['print_custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom;
208
+	}
201 209
 
202 210
 }
203 211
 
@@ -245,16 +253,18 @@  discard block
 block discarded – undo
245 253
 		$row['extra'] = !empty($row['extra']) ? $smcFunc['json_decode']($row['extra'], true) : array();
246 254
 		$alerts[$id_alert] = $row;
247 255
 
248
-		if (!empty($row['sender_id']))
249
-			$senders[] = $row['sender_id'];
256
+		if (!empty($row['sender_id'])) {
257
+					$senders[] = $row['sender_id'];
258
+		}
250 259
 	}
251 260
 	$smcFunc['db_free_result']($request);
252 261
 
253 262
 	if($withSender)
254 263
 	{
255 264
 		$senders = loadMemberData($senders);
256
-		foreach ($senders as $member)
257
-			loadMemberContext($member);
265
+		foreach ($senders as $member) {
266
+					loadMemberContext($member);
267
+		}
258 268
 	}
259 269
 
260 270
 	// Now go through and actually make with the text.
@@ -269,12 +279,15 @@  discard block
 block discarded – undo
269 279
 	$msgs = array();
270 280
 	foreach ($alerts as $id_alert => $alert)
271 281
 	{
272
-		if (isset($alert['extra']['board']))
273
-			$boards[$alert['extra']['board']] = $txt['board_na'];
274
-		if (isset($alert['extra']['topic']))
275
-			$topics[$alert['extra']['topic']] = $txt['topic_na'];
276
-		if ($alert['content_type'] == 'msg')
277
-			$msgs[$alert['content_id']] = $txt['topic_na'];
282
+		if (isset($alert['extra']['board'])) {
283
+					$boards[$alert['extra']['board']] = $txt['board_na'];
284
+		}
285
+		if (isset($alert['extra']['topic'])) {
286
+					$topics[$alert['extra']['topic']] = $txt['topic_na'];
287
+		}
288
+		if ($alert['content_type'] == 'msg') {
289
+					$msgs[$alert['content_id']] = $txt['topic_na'];
290
+		}
278 291
 	}
279 292
 
280 293
 	// Having figured out what boards etc. there are, let's now get the names of them if we can see them. If not, there's already a fallback set up.
@@ -289,8 +302,9 @@  discard block
 block discarded – undo
289 302
 				'boards' => array_keys($boards),
290 303
 			)
291 304
 		);
292
-		while ($row = $smcFunc['db_fetch_assoc']($request))
293
-			$boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
305
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
306
+					$boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
307
+		}
294 308
 	}
295 309
 	if (!empty($topics))
296 310
 	{
@@ -305,8 +319,9 @@  discard block
 block discarded – undo
305 319
 				'topics' => array_keys($topics),
306 320
 			)
307 321
 		);
308
-		while ($row = $smcFunc['db_fetch_assoc']($request))
309
-			$topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>';
322
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
323
+					$topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>';
324
+		}
310 325
 	}
311 326
 	if (!empty($msgs))
312 327
 	{
@@ -321,44 +336,51 @@  discard block
 block discarded – undo
321 336
 				'msgs' => array_keys($msgs),
322 337
 			)
323 338
 		);
324
-		while ($row = $smcFunc['db_fetch_assoc']($request))
325
-			$msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
339
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
340
+					$msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
341
+		}
326 342
 	}
327 343
 
328 344
 	// Now to go back through the alerts, reattach this extra information and then try to build the string out of it (if a hook didn't already)
329 345
 	foreach ($alerts as $id_alert => $alert)
330 346
 	{
331
-		if (!empty($alert['text']))
332
-			continue;
333
-		if (isset($alert['extra']['board']))
334
-			if ($boards[$alert['extra']['board']] == $txt['board_na'])
347
+		if (!empty($alert['text'])) {
348
+					continue;
349
+		}
350
+		if (isset($alert['extra']['board'])) {
351
+					if ($boards[$alert['extra']['board']] == $txt['board_na'])
335 352
 			{
336 353
 				unset($alerts[$id_alert]);
354
+		}
337 355
 				continue;
356
+			} else {
357
+							$alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']];
338 358
 			}
339
-			else
340
-				$alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']];
341
-		if (isset($alert['extra']['topic']))
342
-			if ($alert['extra']['topic'] == $txt['topic_na'])
359
+		if (isset($alert['extra']['topic'])) {
360
+					if ($alert['extra']['topic'] == $txt['topic_na'])
343 361
 			{
344 362
 				unset($alerts[$id_alert]);
363
+		}
345 364
 				continue;
365
+			} else {
366
+							$alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']];
346 367
 			}
347
-			else
348
-				$alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']];
349
-		if ($alert['content_type'] == 'msg')
350
-			if ($msgs[$alert['content_id']] == $txt['topic_na'])
368
+		if ($alert['content_type'] == 'msg') {
369
+					if ($msgs[$alert['content_id']] == $txt['topic_na'])
351 370
 			{
352 371
 				unset($alerts[$id_alert]);
372
+		}
353 373
 				continue;
374
+			} else {
375
+							$alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']];
354 376
 			}
355
-			else
356
-				$alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']];
357
-		if ($alert['content_type'] == 'profile')
358
-			$alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>';
377
+		if ($alert['content_type'] == 'profile') {
378
+					$alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>';
379
+		}
359 380
 
360
-		if (!empty($memberContext[$alert['sender_id']]))
361
-			$alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']];
381
+		if (!empty($memberContext[$alert['sender_id']])) {
382
+					$alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']];
383
+		}
362 384
 
363 385
 		$string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action'];
364 386
 		if (isset($txt[$string]))
@@ -446,11 +468,11 @@  discard block
 block discarded – undo
446 468
 		checkSession('request');
447 469
 
448 470
 		// Call it!
449
-		if ($action == 'remove')
450
-			alert_delete($toMark, $memID);
451
-
452
-		else
453
-			alert_mark($memID, $toMark, $action == 'read' ? 1 : 0);
471
+		if ($action == 'remove') {
472
+					alert_delete($toMark, $memID);
473
+		} else {
474
+					alert_mark($memID, $toMark, $action == 'read' ? 1 : 0);
475
+		}
454 476
 
455 477
 		// Set a nice update message.
456 478
 		$_SESSION['update_message'] = true;
@@ -500,23 +522,27 @@  discard block
 block discarded – undo
500 522
 	);
501 523
 
502 524
 	// Set the page title
503
-	if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title))
504
-		$context['page_title'] = $txt['show' . $title[$_GET['sa']]];
505
-	else
506
-		$context['page_title'] = $txt['showPosts'];
525
+	if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) {
526
+			$context['page_title'] = $txt['show' . $title[$_GET['sa']]];
527
+	} else {
528
+			$context['page_title'] = $txt['showPosts'];
529
+	}
507 530
 
508 531
 	$context['page_title'] .= ' - ' . $user_profile[$memID]['real_name'];
509 532
 
510 533
 	// Is the load average too high to allow searching just now?
511
-	if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts'])
512
-		fatal_lang_error('loadavg_show_posts_disabled', false);
534
+	if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) {
535
+			fatal_lang_error('loadavg_show_posts_disabled', false);
536
+	}
513 537
 
514 538
 	// If we're specifically dealing with attachments use that function!
515
-	if (isset($_GET['sa']) && $_GET['sa'] == 'attach')
516
-		return showAttachments($memID);
539
+	if (isset($_GET['sa']) && $_GET['sa'] == 'attach') {
540
+			return showAttachments($memID);
541
+	}
517 542
 	// Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function.
518
-	elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics')
519
-		return showUnwatched($memID);
543
+	elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') {
544
+			return showUnwatched($memID);
545
+	}
520 546
 
521 547
 	// Are we just viewing topics?
522 548
 	$context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false;
@@ -539,27 +565,30 @@  discard block
 block discarded – undo
539 565
 		$smcFunc['db_free_result']($request);
540 566
 
541 567
 		// Trying to remove a message that doesn't exist.
542
-		if (empty($info))
543
-			redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']);
568
+		if (empty($info)) {
569
+					redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']);
570
+		}
544 571
 
545 572
 		// We can be lazy, since removeMessage() will check the permissions for us.
546 573
 		require_once($sourcedir . '/RemoveTopic.php');
547 574
 		removeMessage((int) $_GET['delete']);
548 575
 
549 576
 		// Add it to the mod log.
550
-		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id']))
551
-			logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3]));
577
+		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) {
578
+					logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3]));
579
+		}
552 580
 
553 581
 		// Back to... where we are now ;).
554 582
 		redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']);
555 583
 	}
556 584
 
557 585
 	// Default to 10.
558
-	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
559
-		$_REQUEST['viewscount'] = '10';
586
+	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) {
587
+			$_REQUEST['viewscount'] = '10';
588
+	}
560 589
 
561
-	if ($context['is_topics'])
562
-		$request = $smcFunc['db_query']('', '
590
+	if ($context['is_topics']) {
591
+			$request = $smcFunc['db_query']('', '
563 592
 			SELECT COUNT(*)
564 593
 			FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : '
565 594
 				INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . '
@@ -572,8 +601,8 @@  discard block
 block discarded – undo
572 601
 				'board' => $board,
573 602
 			)
574 603
 		);
575
-	else
576
-		$request = $smcFunc['db_query']('', '
604
+	} else {
605
+			$request = $smcFunc['db_query']('', '
577 606
 			SELECT COUNT(*)
578 607
 			FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : '
579 608
 				INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . '
@@ -586,6 +615,7 @@  discard block
 block discarded – undo
586 615
 				'board' => $board,
587 616
 			)
588 617
 		);
618
+	}
589 619
 	list ($msgCount) = $smcFunc['db_fetch_row']($request);
590 620
 	$smcFunc['db_free_result']($request);
591 621
 
@@ -606,10 +636,11 @@  discard block
 block discarded – undo
606 636
 
607 637
 	$range_limit = '';
608 638
 
609
-	if ($context['is_topics'])
610
-		$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
611
-	else
612
-		$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
639
+	if ($context['is_topics']) {
640
+			$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
641
+	} else {
642
+			$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
643
+	}
613 644
 
614 645
 	$maxIndex = $maxPerPage;
615 646
 
@@ -635,9 +666,9 @@  discard block
 block discarded – undo
635 666
 		{
636 667
 			$margin *= 5;
637 668
 			$range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin);
669
+		} else {
670
+					$range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin);
638 671
 		}
639
-		else
640
-			$range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin);
641 672
 	}
642 673
 
643 674
 	// Find this user's posts.  The left join on categories somehow makes this faster, weird as it looks.
@@ -669,8 +700,7 @@  discard block
 block discarded – undo
669 700
 					'max' => $maxIndex,
670 701
 				)
671 702
 			);
672
-		}
673
-		else
703
+		} else
674 704
 		{
675 705
 			$request = $smcFunc['db_query']('', '
676 706
 				SELECT
@@ -699,8 +729,9 @@  discard block
 block discarded – undo
699 729
 		}
700 730
 
701 731
 		// Make sure we quit this loop.
702
-		if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped || $range_limit == '')
703
-			break;
732
+		if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped || $range_limit == '') {
733
+					break;
734
+		}
704 735
 		$looped = true;
705 736
 		$range_limit = '';
706 737
 	}
@@ -744,19 +775,21 @@  discard block
 block discarded – undo
744 775
 			'css_class' => $row['approved'] ? 'windowbg' : 'approvebg',
745 776
 		);
746 777
 
747
-		if ($user_info['id'] == $row['id_member_started'])
748
-			$board_ids['own'][$row['id_board']][] = $counter;
778
+		if ($user_info['id'] == $row['id_member_started']) {
779
+					$board_ids['own'][$row['id_board']][] = $counter;
780
+		}
749 781
 		$board_ids['any'][$row['id_board']][] = $counter;
750 782
 	}
751 783
 	$smcFunc['db_free_result']($request);
752 784
 
753 785
 	// All posts were retrieved in reverse order, get them right again.
754
-	if ($reverse)
755
-		$context['posts'] = array_reverse($context['posts'], true);
786
+	if ($reverse) {
787
+			$context['posts'] = array_reverse($context['posts'], true);
788
+	}
756 789
 
757 790
 	// These are all the permissions that are different from board to board..
758
-	if ($context['is_topics'])
759
-		$permissions = array(
791
+	if ($context['is_topics']) {
792
+			$permissions = array(
760 793
 			'own' => array(
761 794
 				'post_reply_own' => 'can_reply',
762 795
 			),
@@ -764,8 +797,8 @@  discard block
 block discarded – undo
764 797
 				'post_reply_any' => 'can_reply',
765 798
 			)
766 799
 		);
767
-	else
768
-		$permissions = array(
800
+	} else {
801
+			$permissions = array(
769 802
 			'own' => array(
770 803
 				'post_reply_own' => 'can_reply',
771 804
 				'delete_own' => 'can_delete',
@@ -775,6 +808,7 @@  discard block
 block discarded – undo
775 808
 				'delete_any' => 'can_delete',
776 809
 			)
777 810
 		);
811
+	}
778 812
 
779 813
 	// For every permission in the own/any lists...
780 814
 	foreach ($permissions as $type => $list)
@@ -785,19 +819,22 @@  discard block
 block discarded – undo
785 819
 			$boards = boardsAllowedTo($permission);
786 820
 
787 821
 			// Hmm, they can do it on all boards, can they?
788
-			if (!empty($boards) && $boards[0] == 0)
789
-				$boards = array_keys($board_ids[$type]);
822
+			if (!empty($boards) && $boards[0] == 0) {
823
+							$boards = array_keys($board_ids[$type]);
824
+			}
790 825
 
791 826
 			// Now go through each board they can do the permission on.
792 827
 			foreach ($boards as $board_id)
793 828
 			{
794 829
 				// There aren't any posts displayed from this board.
795
-				if (!isset($board_ids[$type][$board_id]))
796
-					continue;
830
+				if (!isset($board_ids[$type][$board_id])) {
831
+									continue;
832
+				}
797 833
 
798 834
 				// Set the permission to true ;).
799
-				foreach ($board_ids[$type][$board_id] as $counter)
800
-					$context['posts'][$counter][$allowed] = true;
835
+				foreach ($board_ids[$type][$board_id] as $counter) {
836
+									$context['posts'][$counter][$allowed] = true;
837
+				}
801 838
 			}
802 839
 		}
803 840
 	}
@@ -828,8 +865,9 @@  discard block
 block discarded – undo
828 865
 	$boardsAllowed = boardsAllowedTo('view_attachments');
829 866
 
830 867
 	// Make sure we can't actually see anything...
831
-	if (empty($boardsAllowed))
832
-		$boardsAllowed = array(-1);
868
+	if (empty($boardsAllowed)) {
869
+			$boardsAllowed = array(-1);
870
+	}
833 871
 
834 872
 	require_once($sourcedir . '/Subs-List.php');
835 873
 
@@ -980,8 +1018,8 @@  discard block
 block discarded – undo
980 1018
 		)
981 1019
 	);
982 1020
 	$attachments = array();
983
-	while ($row = $smcFunc['db_fetch_assoc']($request))
984
-		$attachments[] = array(
1021
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1022
+			$attachments[] = array(
985 1023
 			'id' => $row['id_attach'],
986 1024
 			'filename' => $row['filename'],
987 1025
 			'downloads' => $row['downloads'],
@@ -993,6 +1031,7 @@  discard block
 block discarded – undo
993 1031
 			'board_name' => $row['name'],
994 1032
 			'approved' => $row['approved'],
995 1033
 		);
1034
+	}
996 1035
 
997 1036
 	$smcFunc['db_free_result']($request);
998 1037
 
@@ -1047,8 +1086,9 @@  discard block
 block discarded – undo
1047 1086
 	global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir;
1048 1087
 
1049 1088
 	// Only the owner can see the list (if the function is enabled of course)
1050
-	if ($user_info['id'] != $memID)
1051
-		return;
1089
+	if ($user_info['id'] != $memID) {
1090
+			return;
1091
+	}
1052 1092
 
1053 1093
 	require_once($sourcedir . '/Subs-List.php');
1054 1094
 
@@ -1194,8 +1234,9 @@  discard block
 block discarded – undo
1194 1234
 	);
1195 1235
 
1196 1236
 	$topics = array();
1197
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1198
-		$topics[] = $row['id_topic'];
1237
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1238
+			$topics[] = $row['id_topic'];
1239
+	}
1199 1240
 
1200 1241
 	$smcFunc['db_free_result']($request);
1201 1242
 
@@ -1215,8 +1256,9 @@  discard block
 block discarded – undo
1215 1256
 				'topics' => $topics,
1216 1257
 			)
1217 1258
 		);
1218
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1219
-			$topicsInfo[] = $row;
1259
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1260
+					$topicsInfo[] = $row;
1261
+		}
1220 1262
 		$smcFunc['db_free_result']($request);
1221 1263
 	}
1222 1264
 
@@ -1264,8 +1306,9 @@  discard block
 block discarded – undo
1264 1306
 	$context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name'];
1265 1307
 
1266 1308
 	// Is the load average too high to allow searching just now?
1267
-	if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats'])
1268
-		fatal_lang_error('loadavg_userstats_disabled', false);
1309
+	if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) {
1310
+			fatal_lang_error('loadavg_userstats_disabled', false);
1311
+	}
1269 1312
 
1270 1313
 	// General user statistics.
1271 1314
 	$timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400);
@@ -1408,11 +1451,13 @@  discard block
 block discarded – undo
1408 1451
 	}
1409 1452
 	$smcFunc['db_free_result']($result);
1410 1453
 
1411
-	if ($maxPosts > 0)
1412
-		for ($hour = 0; $hour < 24; $hour++)
1454
+	if ($maxPosts > 0) {
1455
+			for ($hour = 0;
1456
+	}
1457
+	$hour < 24; $hour++)
1413 1458
 		{
1414
-			if (!isset($context['posts_by_time'][$hour]))
1415
-				$context['posts_by_time'][$hour] = array(
1459
+			if (!isset($context['posts_by_time'][$hour])) {
1460
+							$context['posts_by_time'][$hour] = array(
1416 1461
 					'hour' => $hour,
1417 1462
 					'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)),
1418 1463
 					'posts' => 0,
@@ -1420,7 +1465,7 @@  discard block
 block discarded – undo
1420 1465
 					'relative_percent' => 0,
1421 1466
 					'is_last' => $hour == 23,
1422 1467
 				);
1423
-			else
1468
+			} else
1424 1469
 			{
1425 1470
 				$context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts);
1426 1471
 				$context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts);
@@ -1453,8 +1498,9 @@  discard block
 block discarded – undo
1453 1498
 
1454 1499
 	foreach ($subActions as $sa => $action)
1455 1500
 	{
1456
-		if (!allowedTo($action[2]))
1457
-			unset($subActions[$sa]);
1501
+		if (!allowedTo($action[2])) {
1502
+					unset($subActions[$sa]);
1503
+		}
1458 1504
 	}
1459 1505
 
1460 1506
 	// Create the tabs for the template.
@@ -1472,15 +1518,18 @@  discard block
 block discarded – undo
1472 1518
 	);
1473 1519
 
1474 1520
 	// Moderation must be on to track edits.
1475
-	if (empty($modSettings['userlog_enabled']))
1476
-		unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']);
1521
+	if (empty($modSettings['userlog_enabled'])) {
1522
+			unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']);
1523
+	}
1477 1524
 
1478 1525
 	// Group requests must be active to show it...
1479
-	if (empty($modSettings['show_group_membership']))
1480
-		unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']);
1526
+	if (empty($modSettings['show_group_membership'])) {
1527
+			unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']);
1528
+	}
1481 1529
 
1482
-	if (empty($subActions))
1483
-		fatal_lang_error('no_access', false);
1530
+	if (empty($subActions)) {
1531
+			fatal_lang_error('no_access', false);
1532
+	}
1484 1533
 
1485 1534
 	$keys = array_keys($subActions);
1486 1535
 	$default = array_shift($keys);
@@ -1493,9 +1542,10 @@  discard block
 block discarded – undo
1493 1542
 	$context['sub_template'] = $subActions[$context['tracking_area']][0];
1494 1543
 	$call = call_helper($subActions[$context['tracking_area']][0], true);
1495 1544
 
1496
-	if (!empty($call))
1497
-		call_user_func($call, $memID);
1498
-}
1545
+	if (!empty($call)) {
1546
+			call_user_func($call, $memID);
1547
+	}
1548
+	}
1499 1549
 
1500 1550
 /**
1501 1551
  * Handles tracking a user's activity
@@ -1511,8 +1561,9 @@  discard block
 block discarded – undo
1511 1561
 	isAllowedTo('moderate_forum');
1512 1562
 
1513 1563
 	$context['last_ip'] = $user_profile[$memID]['member_ip'];
1514
-	if ($context['last_ip'] != $user_profile[$memID]['member_ip2'])
1515
-		$context['last_ip2'] = $user_profile[$memID]['member_ip2'];
1564
+	if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) {
1565
+			$context['last_ip2'] = $user_profile[$memID]['member_ip2'];
1566
+	}
1516 1567
 	$context['member']['name'] = $user_profile[$memID]['real_name'];
1517 1568
 
1518 1569
 	// Set the options for the list component.
@@ -1679,8 +1730,9 @@  discard block
 block discarded – undo
1679 1730
 			)
1680 1731
 		);
1681 1732
 		$message_members = array();
1682
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1683
-			$message_members[] = $row['id_member'];
1733
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1734
+					$message_members[] = $row['id_member'];
1735
+		}
1684 1736
 		$smcFunc['db_free_result']($request);
1685 1737
 
1686 1738
 		// Fetch their names, cause of the GROUP BY doesn't like giving us that normally.
@@ -1695,8 +1747,9 @@  discard block
 block discarded – undo
1695 1747
 					'ip_list' => $ips,
1696 1748
 				)
1697 1749
 			);
1698
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1699
-				$context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
1750
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1751
+							$context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
1752
+			}
1700 1753
 			$smcFunc['db_free_result']($request);
1701 1754
 		}
1702 1755
 
@@ -1710,8 +1763,9 @@  discard block
 block discarded – undo
1710 1763
 				'ip_list' => $ips,
1711 1764
 			)
1712 1765
 		);
1713
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1714
-			$context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
1766
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1767
+					$context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
1768
+		}
1715 1769
 		$smcFunc['db_free_result']($request);
1716 1770
 	}
1717 1771
 }
@@ -1771,8 +1825,8 @@  discard block
 block discarded – undo
1771 1825
 		))
1772 1826
 	);
1773 1827
 	$error_messages = array();
1774
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1775
-		$error_messages[] = array(
1828
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1829
+			$error_messages[] = array(
1776 1830
 			'ip' => inet_dtop($row['ip']),
1777 1831
 			'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'],
1778 1832
 			'message' => strtr($row['message'], array('&lt;span class=&quot;remove&quot;&gt;' => '', '&lt;/span&gt;' => '')),
@@ -1780,6 +1834,7 @@  discard block
 block discarded – undo
1780 1834
 			'time' => timeformat($row['log_time']),
1781 1835
 			'timestamp' => forum_time(true, $row['log_time']),
1782 1836
 		);
1837
+	}
1783 1838
 	$smcFunc['db_free_result']($request);
1784 1839
 
1785 1840
 	return $error_messages;
@@ -1842,8 +1897,8 @@  discard block
 block discarded – undo
1842 1897
 		))
1843 1898
 	);
1844 1899
 	$messages = array();
1845
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1846
-		$messages[] = array(
1900
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1901
+			$messages[] = array(
1847 1902
 			'ip' => inet_dtop($row['poster_ip']),
1848 1903
 			'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>',
1849 1904
 			'board' => array(
@@ -1856,6 +1911,7 @@  discard block
 block discarded – undo
1856 1911
 			'time' => timeformat($row['poster_time']),
1857 1912
 			'timestamp' => forum_time(true, $row['poster_time'])
1858 1913
 		);
1914
+	}
1859 1915
 	$smcFunc['db_free_result']($request);
1860 1916
 
1861 1917
 	return $messages;
@@ -1882,19 +1938,20 @@  discard block
 block discarded – undo
1882 1938
 		$context['sub_template'] = 'trackIP';
1883 1939
 		$context['page_title'] = $txt['profile'];
1884 1940
 		$context['base_url'] = $scripturl . '?action=trackip';
1885
-	}
1886
-	else
1941
+	} else
1887 1942
 	{
1888 1943
 		$context['ip'] = $user_profile[$memID]['member_ip'];
1889 1944
 		$context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID;
1890 1945
 	}
1891 1946
 
1892 1947
 	// Searching?
1893
-	if (isset($_REQUEST['searchip']))
1894
-		$context['ip'] = trim($_REQUEST['searchip']);
1948
+	if (isset($_REQUEST['searchip'])) {
1949
+			$context['ip'] = trim($_REQUEST['searchip']);
1950
+	}
1895 1951
 
1896
-	if (isValidIP($context['ip']) === false)
1897
-		fatal_lang_error('invalid_tracking_ip', false);
1952
+	if (isValidIP($context['ip']) === false) {
1953
+			fatal_lang_error('invalid_tracking_ip', false);
1954
+	}
1898 1955
 
1899 1956
 	//mysql didn't support like search with varbinary
1900 1957
 	//$ip_var = str_replace('*', '%', $context['ip']);
@@ -1902,8 +1959,9 @@  discard block
 block discarded – undo
1902 1959
 	$ip_var = $context['ip'];
1903 1960
 	$ip_string = '= {inet:ip_address}';
1904 1961
 
1905
-	if (empty($context['tracking_area']))
1906
-		$context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip'];
1962
+	if (empty($context['tracking_area'])) {
1963
+			$context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip'];
1964
+	}
1907 1965
 
1908 1966
 	$request = $smcFunc['db_query']('', '
1909 1967
 		SELECT id_member, real_name AS display_name, member_ip
@@ -1914,8 +1972,9 @@  discard block
 block discarded – undo
1914 1972
 		)
1915 1973
 	);
1916 1974
 	$context['ips'] = array();
1917
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1918
-		$context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>';
1975
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1976
+			$context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>';
1977
+	}
1919 1978
 	$smcFunc['db_free_result']($request);
1920 1979
 
1921 1980
 	ksort($context['ips']);
@@ -2144,8 +2203,9 @@  discard block
 block discarded – undo
2144 2203
 		foreach ($context['whois_servers'] as $whois)
2145 2204
 		{
2146 2205
 			// Strip off the "decimal point" and anything following...
2147
-			if (in_array((int) $context['ip'], $whois['range']))
2148
-				$context['auto_whois_server'] = $whois;
2206
+			if (in_array((int) $context['ip'], $whois['range'])) {
2207
+							$context['auto_whois_server'] = $whois;
2208
+			}
2149 2209
 		}
2150 2210
 	}
2151 2211
 }
@@ -2162,10 +2222,11 @@  discard block
 block discarded – undo
2162 2222
 	// Gonna want this for the list.
2163 2223
 	require_once($sourcedir . '/Subs-List.php');
2164 2224
 
2165
-	if ($memID == 0)
2166
-		$context['base_url'] = $scripturl . '?action=trackip';
2167
-	else
2168
-		$context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID;
2225
+	if ($memID == 0) {
2226
+			$context['base_url'] = $scripturl . '?action=trackip';
2227
+	} else {
2228
+			$context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID;
2229
+	}
2169 2230
 
2170 2231
 	// Start with the user messages.
2171 2232
 	$listOptions = array(
@@ -2275,12 +2336,13 @@  discard block
 block discarded – undo
2275 2336
 		)
2276 2337
 	);
2277 2338
 	$logins = array();
2278
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2279
-		$logins[] = array(
2339
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2340
+			$logins[] = array(
2280 2341
 			'time' => timeformat($row['time']),
2281 2342
 			'ip' => inet_dtop($row['ip']),
2282 2343
 			'ip2' => inet_dtop($row['ip2']),
2283 2344
 		);
2345
+	}
2284 2346
 	$smcFunc['db_free_result']($request);
2285 2347
 
2286 2348
 	return $logins;
@@ -2305,11 +2367,12 @@  discard block
 block discarded – undo
2305 2367
 		)
2306 2368
 	);
2307 2369
 	$context['custom_field_titles'] = array();
2308
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2309
-		$context['custom_field_titles']['customfield_' . $row['col_name']] = array(
2370
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2371
+			$context['custom_field_titles']['customfield_' . $row['col_name']] = array(
2310 2372
 			'title' => $row['field_name'],
2311 2373
 			'parse_bbc' => $row['bbc'],
2312 2374
 		);
2375
+	}
2313 2376
 	$smcFunc['db_free_result']($request);
2314 2377
 
2315 2378
 	// Set the options for the error lists.
@@ -2448,19 +2511,22 @@  discard block
 block discarded – undo
2448 2511
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2449 2512
 	{
2450 2513
 		$extra = $smcFunc['json_decode']($row['extra'], true);
2451
-		if (!empty($extra['applicator']))
2452
-			$members[] = $extra['applicator'];
2514
+		if (!empty($extra['applicator'])) {
2515
+					$members[] = $extra['applicator'];
2516
+		}
2453 2517
 
2454 2518
 		// Work out what the name of the action is.
2455
-		if (isset($txt['trackEdit_action_' . $row['action']]))
2456
-			$action_text = $txt['trackEdit_action_' . $row['action']];
2457
-		elseif (isset($txt[$row['action']]))
2458
-			$action_text = $txt[$row['action']];
2519
+		if (isset($txt['trackEdit_action_' . $row['action']])) {
2520
+					$action_text = $txt['trackEdit_action_' . $row['action']];
2521
+		} elseif (isset($txt[$row['action']])) {
2522
+					$action_text = $txt[$row['action']];
2523
+		}
2459 2524
 		// Custom field?
2460
-		elseif (isset($context['custom_field_titles'][$row['action']]))
2461
-			$action_text = $context['custom_field_titles'][$row['action']]['title'];
2462
-		else
2463
-			$action_text = $row['action'];
2525
+		elseif (isset($context['custom_field_titles'][$row['action']])) {
2526
+					$action_text = $context['custom_field_titles'][$row['action']]['title'];
2527
+		} else {
2528
+					$action_text = $row['action'];
2529
+		}
2464 2530
 
2465 2531
 		// Parse BBC?
2466 2532
 		$parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false;
@@ -2492,13 +2558,15 @@  discard block
 block discarded – undo
2492 2558
 			)
2493 2559
 		);
2494 2560
 		$members = array();
2495
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2496
-			$members[$row['id_member']] = $row['real_name'];
2561
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2562
+					$members[$row['id_member']] = $row['real_name'];
2563
+		}
2497 2564
 		$smcFunc['db_free_result']($request);
2498 2565
 
2499
-		foreach ($edits as $key => $value)
2500
-			if (isset($members[$value['id_member']]))
2566
+		foreach ($edits as $key => $value) {
2567
+					if (isset($members[$value['id_member']]))
2501 2568
 				$edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>';
2569
+		}
2502 2570
 	}
2503 2571
 
2504 2572
 	return $edits;
@@ -2699,10 +2767,11 @@  discard block
 block discarded – undo
2699 2767
 	$context['board'] = $board;
2700 2768
 
2701 2769
 	// Determine which groups this user is in.
2702
-	if (empty($user_profile[$memID]['additional_groups']))
2703
-		$curGroups = array();
2704
-	else
2705
-		$curGroups = explode(',', $user_profile[$memID]['additional_groups']);
2770
+	if (empty($user_profile[$memID]['additional_groups'])) {
2771
+			$curGroups = array();
2772
+	} else {
2773
+			$curGroups = explode(',', $user_profile[$memID]['additional_groups']);
2774
+	}
2706 2775
 	$curGroups[] = $user_profile[$memID]['id_group'];
2707 2776
 	$curGroups[] = $user_profile[$memID]['id_post_group'];
2708 2777
 
@@ -2722,28 +2791,30 @@  discard block
 block discarded – undo
2722 2791
 	$context['no_access_boards'] = array();
2723 2792
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2724 2793
 	{
2725
-		if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod'])
2726
-			$context['no_access_boards'][] = array(
2794
+		if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) {
2795
+					$context['no_access_boards'][] = array(
2727 2796
 				'id' => $row['id_board'],
2728 2797
 				'name' => $row['name'],
2729 2798
 				'is_last' => false,
2730 2799
 			);
2731
-		elseif ($row['id_profile'] != 1 || $row['is_mod'])
2732
-			$context['boards'][$row['id_board']] = array(
2800
+		} elseif ($row['id_profile'] != 1 || $row['is_mod']) {
2801
+					$context['boards'][$row['id_board']] = array(
2733 2802
 				'id' => $row['id_board'],
2734 2803
 				'name' => $row['name'],
2735 2804
 				'selected' => $board == $row['id_board'],
2736 2805
 				'profile' => $row['id_profile'],
2737 2806
 				'profile_name' => $context['profiles'][$row['id_profile']]['name'],
2738 2807
 			);
2808
+		}
2739 2809
 	}
2740 2810
 	$smcFunc['db_free_result']($request);
2741 2811
 
2742 2812
 	require_once($sourcedir . '/Subs-Boards.php');
2743 2813
 	sortBoards($context['boards']);
2744 2814
 
2745
-	if (!empty($context['no_access_boards']))
2746
-		$context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true;
2815
+	if (!empty($context['no_access_boards'])) {
2816
+			$context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true;
2817
+	}
2747 2818
 
2748 2819
 	$context['member']['permissions'] = array(
2749 2820
 		'general' => array(),
@@ -2752,8 +2823,9 @@  discard block
 block discarded – undo
2752 2823
 
2753 2824
 	// If you're an admin we know you can do everything, we might as well leave.
2754 2825
 	$context['member']['has_all_permissions'] = in_array(1, $curGroups);
2755
-	if ($context['member']['has_all_permissions'])
2756
-		return;
2826
+	if ($context['member']['has_all_permissions']) {
2827
+			return;
2828
+	}
2757 2829
 
2758 2830
 	$denied = array();
2759 2831
 
@@ -2772,21 +2844,24 @@  discard block
 block discarded – undo
2772 2844
 	while ($row = $smcFunc['db_fetch_assoc']($result))
2773 2845
 	{
2774 2846
 		// We don't know about this permission, it doesn't exist :P.
2775
-		if (!isset($txt['permissionname_' . $row['permission']]))
2776
-			continue;
2847
+		if (!isset($txt['permissionname_' . $row['permission']])) {
2848
+					continue;
2849
+		}
2777 2850
 
2778
-		if (empty($row['add_deny']))
2779
-			$denied[] = $row['permission'];
2851
+		if (empty($row['add_deny'])) {
2852
+					$denied[] = $row['permission'];
2853
+		}
2780 2854
 
2781 2855
 		// Permissions that end with _own or _any consist of two parts.
2782
-		if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)]))
2783
-			$name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
2784
-		else
2785
-			$name = $txt['permissionname_' . $row['permission']];
2856
+		if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) {
2857
+					$name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
2858
+		} else {
2859
+					$name = $txt['permissionname_' . $row['permission']];
2860
+		}
2786 2861
 
2787 2862
 		// Add this permission if it doesn't exist yet.
2788
-		if (!isset($context['member']['permissions']['general'][$row['permission']]))
2789
-			$context['member']['permissions']['general'][$row['permission']] = array(
2863
+		if (!isset($context['member']['permissions']['general'][$row['permission']])) {
2864
+					$context['member']['permissions']['general'][$row['permission']] = array(
2790 2865
 				'id' => $row['permission'],
2791 2866
 				'groups' => array(
2792 2867
 					'allowed' => array(),
@@ -2796,6 +2871,7 @@  discard block
 block discarded – undo
2796 2871
 				'is_denied' => false,
2797 2872
 				'is_global' => true,
2798 2873
 			);
2874
+		}
2799 2875
 
2800 2876
 		// Add the membergroup to either the denied or the allowed groups.
2801 2877
 		$context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name'];
@@ -2829,18 +2905,20 @@  discard block
 block discarded – undo
2829 2905
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2830 2906
 	{
2831 2907
 		// We don't know about this permission, it doesn't exist :P.
2832
-		if (!isset($txt['permissionname_' . $row['permission']]))
2833
-			continue;
2908
+		if (!isset($txt['permissionname_' . $row['permission']])) {
2909
+					continue;
2910
+		}
2834 2911
 
2835 2912
 		// The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'.
2836
-		if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)]))
2837
-			$name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
2838
-		else
2839
-			$name = $txt['permissionname_' . $row['permission']];
2913
+		if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) {
2914
+					$name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
2915
+		} else {
2916
+					$name = $txt['permissionname_' . $row['permission']];
2917
+		}
2840 2918
 
2841 2919
 		// Create the structure for this permission.
2842
-		if (!isset($context['member']['permissions']['board'][$row['permission']]))
2843
-			$context['member']['permissions']['board'][$row['permission']] = array(
2920
+		if (!isset($context['member']['permissions']['board'][$row['permission']])) {
2921
+					$context['member']['permissions']['board'][$row['permission']] = array(
2844 2922
 				'id' => $row['permission'],
2845 2923
 				'groups' => array(
2846 2924
 					'allowed' => array(),
@@ -2850,6 +2928,7 @@  discard block
 block discarded – undo
2850 2928
 				'is_denied' => false,
2851 2929
 				'is_global' => empty($board),
2852 2930
 			);
2931
+		}
2853 2932
 
2854 2933
 		$context['member']['permissions']['board'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][$row['id_group']] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name'];
2855 2934
 
@@ -2868,8 +2947,9 @@  discard block
 block discarded – undo
2868 2947
 	global $modSettings, $context, $sourcedir, $txt, $scripturl;
2869 2948
 
2870 2949
 	// Firstly, can we actually even be here?
2871
-	if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum'))
2872
-		fatal_lang_error('no_access', false);
2950
+	if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) {
2951
+			fatal_lang_error('no_access', false);
2952
+	}
2873 2953
 
2874 2954
 	// Make sure things which are disabled stay disabled.
2875 2955
 	$modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110;
@@ -2956,9 +3036,10 @@  discard block
 block discarded – undo
2956 3036
 		$modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'],
2957 3037
 	);
2958 3038
 	$context['current_level'] = 0;
2959
-	foreach ($context['level_effects'] as $limit => $dummy)
2960
-		if ($context['member']['warning'] >= $limit)
3039
+	foreach ($context['level_effects'] as $limit => $dummy) {
3040
+			if ($context['member']['warning'] >= $limit)
2961 3041
 			$context['current_level'] = $limit;
2962
-}
3042
+	}
3043
+	}
2963 3044
 
2964 3045
 ?>
2965 3046
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/DbPackages-postgresql.php 1 patch
Braces   +122 added lines, -95 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
  * Add the file functions to the $smcFunc array.
@@ -53,8 +54,9 @@  discard block
 block discarded – undo
53 54
 		'messages', 'moderator_groups', 'moderators', 'package_servers', 'permission_profiles', 'permissions', 'personal_messages',
54 55
 		'pm_labeled_messages', 'pm_labels', 'pm_recipients', 'pm_rules', 'poll_choices', 'polls', 'scheduled_tasks', 'sessions', 'settings', 'smileys',
55 56
 		'spiders', 'subscriptions', 'themes', 'topics', 'user_alerts', 'user_alerts_prefs', 'user_drafts', 'user_likes');
56
-	foreach ($reservedTables as $k => $table_name)
57
-		$reservedTables[$k] = strtolower($db_prefix . $table_name);
57
+	foreach ($reservedTables as $k => $table_name) {
58
+			$reservedTables[$k] = strtolower($db_prefix . $table_name);
59
+	}
58 60
 
59 61
 	// We in turn may need the extra stuff.
60 62
 	db_extend('extra');
@@ -107,8 +109,9 @@  discard block
 block discarded – undo
107 109
 	$table_name = str_replace('{db_prefix}', $db_prefix, $table_name);
108 110
 
109 111
 	// First - no way do we touch SMF tables.
110
-	if (in_array(strtolower($table_name), $reservedTables))
111
-		return false;
112
+	if (in_array(strtolower($table_name), $reservedTables)) {
113
+			return false;
114
+	}
112 115
 
113 116
 	// Log that we'll want to remove this on uninstall.
114 117
 	$db_package_log[] = array('remove_table', $table_name);
@@ -118,9 +121,9 @@  discard block
 block discarded – undo
118 121
 	if (in_array($full_table_name, $tables))
119 122
 	{
120 123
 		// This is a sad day... drop the table? If not, return false (error) by default.
121
-		if ($if_exists == 'overwrite')
122
-			$smcFunc['db_drop_table']($table_name);
123
-		else if ($if_exists == 'update')
124
+		if ($if_exists == 'overwrite') {
125
+					$smcFunc['db_drop_table']($table_name);
126
+		} else if ($if_exists == 'update')
124 127
 		{
125 128
 			$smcFunc['db_drop_table']($table_name.'_old');
126 129
 			$smcFunc['db_transaction']('begin');
@@ -132,47 +135,51 @@  discard block
 block discarded – undo
132 135
 				)
133 136
 			);
134 137
 			$old_table_exists = true;
138
+		} else {
139
+					return $if_exists == 'ignore';
135 140
 		}
136
-		else
137
-			return $if_exists == 'ignore';
138 141
 	}
139 142
 
140 143
 	// If we've got this far - good news - no table exists. We can build our own!
141
-	if (!$db_trans)
142
-		$smcFunc['db_transaction']('begin');
144
+	if (!$db_trans) {
145
+			$smcFunc['db_transaction']('begin');
146
+	}
143 147
 	$table_query = 'CREATE TABLE ' . $table_name . "\n" . '(';
144 148
 	foreach ($columns as $column)
145 149
 	{
146 150
 		// If we have an auto increment do it!
147 151
 		if (!empty($column['auto']))
148 152
 		{
149
-			if (!$old_table_exists)
150
-				$smcFunc['db_query']('', '
153
+			if (!$old_table_exists) {
154
+							$smcFunc['db_query']('', '
151 155
 					DROP SEQUENCE IF EXISTS ' . $table_name . '_seq',
152 156
 					array(
153 157
 						'security_override' => true,
154 158
 					)
155 159
 				);
160
+			}
156 161
 
157
-			if (!$old_table_exists)
158
-				$smcFunc['db_query']('', '
162
+			if (!$old_table_exists) {
163
+							$smcFunc['db_query']('', '
159 164
 					CREATE SEQUENCE ' . $table_name . '_seq',
160 165
 					array(
161 166
 						'security_override' => true,
162 167
 					)
163 168
 				);
169
+			}
164 170
 			$default = 'default nextval(\'' . $table_name . '_seq\')';
171
+		} elseif (isset($column['default']) && $column['default'] !== null) {
172
+					$default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\'';
173
+		} else {
174
+					$default = '';
165 175
 		}
166
-		elseif (isset($column['default']) && $column['default'] !== null)
167
-			$default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\'';
168
-		else
169
-			$default = '';
170 176
 
171 177
 		// Sort out the size...
172 178
 		$column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null;
173 179
 		list ($type, $size) = $smcFunc['db_calculate_type']($column['type'], $column['size']);
174
-		if ($size !== null)
175
-			$type = $type . '(' . $size . ')';
180
+		if ($size !== null) {
181
+					$type = $type . '(' . $size . ')';
182
+		}
176 183
 
177 184
 		// Now just put it together!
178 185
 		$table_query .= "\n\t\"" . $column['name'] . '" ' . $type . ' ' . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default . ',';
@@ -185,19 +192,21 @@  discard block
 block discarded – undo
185 192
 		$columns = implode(',', $index['columns']);
186 193
 
187 194
 		// Primary goes in the table...
188
-		if (isset($index['type']) && $index['type'] == 'primary')
189
-			$table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),';
190
-		else
195
+		if (isset($index['type']) && $index['type'] == 'primary') {
196
+					$table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),';
197
+		} else
191 198
 		{
192
-			if (empty($index['name']))
193
-				$index['name'] = implode('_', $index['columns']);
199
+			if (empty($index['name'])) {
200
+							$index['name'] = implode('_', $index['columns']);
201
+			}
194 202
 			$index_queries[] = 'CREATE ' . (isset($index['type']) && $index['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $table_name . '_' . $index['name'] . ' ON ' . $table_name . ' (' . $columns . ')';
195 203
 		}
196 204
 	}
197 205
 
198 206
 	// No trailing commas!
199
-	if (substr($table_query, -1) == ',')
200
-		$table_query = substr($table_query, 0, -1);
207
+	if (substr($table_query, -1) == ',') {
208
+			$table_query = substr($table_query, 0, -1);
209
+	}
201 210
 
202 211
 	$table_query .= ')';
203 212
 
@@ -242,18 +251,20 @@  discard block
 block discarded – undo
242 251
 	}
243 252
 
244 253
 	// And the indexes...
245
-	foreach ($index_queries as $query)
246
-		$smcFunc['db_query']('', $query,
254
+	foreach ($index_queries as $query) {
255
+			$smcFunc['db_query']('', $query,
247 256
 		array(
248 257
 			'security_override' => true,
249 258
 		)
250 259
 	);
260
+	}
251 261
 
252 262
 	// Go, go power rangers!
253 263
 	$smcFunc['db_transaction']('commit');
254 264
 
255
-	if ($old_table_exists)
256
-		$smcFunc['db_drop_table']($table_name . '_old');
265
+	if ($old_table_exists) {
266
+			$smcFunc['db_drop_table']($table_name . '_old');
267
+	}
257 268
 
258 269
 	return true;
259 270
 }
@@ -278,8 +289,9 @@  discard block
 block discarded – undo
278 289
 	$table_name = str_replace('{db_prefix}', $db_prefix, $table_name);
279 290
 
280 291
 	// God no - dropping one of these = bad.
281
-	if (in_array(strtolower($table_name), $reservedTables))
282
-		return false;
292
+	if (in_array(strtolower($table_name), $reservedTables)) {
293
+			return false;
294
+	}
283 295
 
284 296
 	// Does it exist?
285 297
 	if (in_array($full_table_name, $smcFunc['db_list_tables']()))
@@ -337,21 +349,24 @@  discard block
 block discarded – undo
337 349
 
338 350
 	// Does it exist - if so don't add it again!
339 351
 	$columns = $smcFunc['db_list_columns']($table_name, false);
340
-	foreach ($columns as $column)
341
-		if ($column == $column_info['name'])
352
+	foreach ($columns as $column) {
353
+			if ($column == $column_info['name'])
342 354
 		{
343 355
 			// If we're going to overwrite then use change column.
344 356
 			if ($if_exists == 'update')
345 357
 				return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info);
346
-			else
347
-				return false;
358
+	}
359
+			else {
360
+							return false;
361
+			}
348 362
 		}
349 363
 
350 364
 	// Get the specifics...
351 365
 	$column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null;
352 366
 	list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']);
353
-	if ($size !== null)
354
-		$type = $type . '(' . $size . ')';
367
+	if ($size !== null) {
368
+			$type = $type . '(' . $size . ')';
369
+	}
355 370
 
356 371
 	// Now add the thing!
357 372
 	$query = '
@@ -366,11 +381,12 @@  discard block
 block discarded – undo
366 381
 	// If there's more attributes they need to be done via a change on PostgreSQL.
367 382
 	unset($column_info['type'], $column_info['size']);
368 383
 
369
-	if (count($column_info) != 1)
370
-		return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info);
371
-	else
372
-		return true;
373
-}
384
+	if (count($column_info) != 1) {
385
+			return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info);
386
+	} else {
387
+			return true;
388
+	}
389
+	}
374 390
 
375 391
 /**
376 392
  * Removes a column.
@@ -389,8 +405,8 @@  discard block
 block discarded – undo
389 405
 
390 406
 	// Does it exist?
391 407
 	$columns = $smcFunc['db_list_columns']($table_name, true);
392
-	foreach ($columns as $column)
393
-		if ($column['name'] == $column_name)
408
+	foreach ($columns as $column) {
409
+			if ($column['name'] == $column_name)
394 410
 		{
395 411
 			// If there is an auto we need remove it!
396 412
 			if ($column['auto'])
@@ -400,6 +416,7 @@  discard block
 block discarded – undo
400 416
 						'security_override' => true,
401 417
 					)
402 418
 				);
419
+	}
403 420
 
404 421
 			$smcFunc['db_query']('', '
405 422
 				ALTER TABLE ' . $table_name . '
@@ -433,13 +450,15 @@  discard block
 block discarded – undo
433 450
 	// Check it does exist!
434 451
 	$columns = $smcFunc['db_list_columns']($table_name, true);
435 452
 	$old_info = null;
436
-	foreach ($columns as $column)
437
-		if ($column['name'] == $old_column)
453
+	foreach ($columns as $column) {
454
+			if ($column['name'] == $old_column)
438 455
 			$old_info = $column;
456
+	}
439 457
 
440 458
 	// Nothing?
441
-	if ($old_info == null)
442
-		return false;
459
+	if ($old_info == null) {
460
+			return false;
461
+	}
443 462
 
444 463
 	// Now we check each bit individually and ALTER as required.
445 464
 	if (isset($column_info['name']) && $column_info['name'] != $old_column)
@@ -496,8 +515,9 @@  discard block
 block discarded – undo
496 515
 	{
497 516
 		$column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null;
498 517
 		list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']);
499
-		if ($size !== null)
500
-			$type = $type . '(' . $size . ')';
518
+		if ($size !== null) {
519
+					$type = $type . '(' . $size . ')';
520
+		}
501 521
 
502 522
 		// The alter is a pain.
503 523
 		$smcFunc['db_transaction']('begin');
@@ -598,21 +618,23 @@  discard block
 block discarded – undo
598 618
 	$table_name = str_replace('{db_prefix}', $db_prefix, $table_name);
599 619
 
600 620
 	// No columns = no index.
601
-	if (empty($index_info['columns']))
602
-		return false;
621
+	if (empty($index_info['columns'])) {
622
+			return false;
623
+	}
603 624
 	$columns = implode(',', $index_info['columns']);
604 625
 
605 626
 	// No name - make it up!
606 627
 	if (empty($index_info['name']))
607 628
 	{
608 629
 		// No need for primary.
609
-		if (isset($index_info['type']) && $index_info['type'] == 'primary')
610
-			$index_info['name'] = '';
611
-		else
612
-			$index_info['name'] = $table_name . implode('_', $index_info['columns']);
630
+		if (isset($index_info['type']) && $index_info['type'] == 'primary') {
631
+					$index_info['name'] = '';
632
+		} else {
633
+					$index_info['name'] = $table_name . implode('_', $index_info['columns']);
634
+		}
635
+	} else {
636
+			$index_info['name'] = $table_name . $index_info['name'];
613 637
 	}
614
-	else
615
-		$index_info['name'] = $table_name . $index_info['name'];
616 638
 
617 639
 	// Log that we are going to want to remove this!
618 640
 	$db_package_log[] = array('remove_index', $table_name, $index_info['name']);
@@ -625,10 +647,11 @@  discard block
 block discarded – undo
625 647
 		if ($index['name'] == $index_info['name'] || ($index['type'] == 'primary' && isset($index_info['type']) && $index_info['type'] == 'primary'))
626 648
 		{
627 649
 			// If we want to overwrite simply remove the current one then continue.
628
-			if ($if_exists != 'update' || $index['type'] == 'primary')
629
-				return false;
630
-			else
631
-				$smcFunc['db_remove_index']($table_name, $index_info['name']);
650
+			if ($if_exists != 'update' || $index['type'] == 'primary') {
651
+							return false;
652
+			} else {
653
+							$smcFunc['db_remove_index']($table_name, $index_info['name']);
654
+			}
632 655
 		}
633 656
 	}
634 657
 
@@ -642,8 +665,7 @@  discard block
 block discarded – undo
642 665
 				'security_override' => true,
643 666
 			)
644 667
 		);
645
-	}
646
-	else
668
+	} else
647 669
 	{
648 670
 		$smcFunc['db_query']('', '
649 671
 			CREATE ' . (isset($index_info['type']) && $index_info['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $index_info['name'] . ' ON ' . $table_name . ' (' . $columns . ')',
@@ -671,8 +693,9 @@  discard block
 block discarded – undo
671 693
 
672 694
 	// Better exist!
673 695
 	$indexes = $smcFunc['db_list_indexes']($table_name, true);
674
-	if ($index_name != 'primary')
675
-		$index_name = $table_name . '_' . $index_name;
696
+	if ($index_name != 'primary') {
697
+			$index_name = $table_name . '_' . $index_name;
698
+	}
676 699
 
677 700
 	foreach ($indexes as $index)
678 701
 	{
@@ -736,8 +759,7 @@  discard block
 block discarded – undo
736 759
 			'datetime' => 'timestamp without time zone',
737 760
 			'timestamp' => 'timestamp without time zone',
738 761
 		);
739
-	}
740
-	else
762
+	} else
741 763
 	{
742 764
 		$types = array(
743 765
 			'character varying' => 'varchar',
@@ -753,14 +775,16 @@  discard block
 block discarded – undo
753 775
 	// Got it? Change it!
754 776
 	if (isset($types[$type_name]))
755 777
 	{
756
-		if ($type_name == 'tinytext')
757
-			$type_size = 255;
778
+		if ($type_name == 'tinytext') {
779
+					$type_size = 255;
780
+		}
758 781
 		$type_name = $types[$type_name];
759 782
 	}
760 783
 
761 784
 	// Only char fields got size
762
-	if (strpos($type_name, 'char') === false)
763
-			$type_size = null;
785
+	if (strpos($type_name, 'char') === false) {
786
+				$type_size = null;
787
+	}
764 788
 
765 789
 
766 790
 	return array($type_name, $type_size);
@@ -816,8 +840,7 @@  discard block
 block discarded – undo
816 840
 		if (!$detail)
817 841
 		{
818 842
 			$columns[] = $row['column_name'];
819
-		}
820
-		else
843
+		} else
821 844
 		{
822 845
 			$auto = false;
823 846
 			// What is the default?
@@ -825,11 +848,11 @@  discard block
 block discarded – undo
825 848
 			{
826 849
 				$default = null;
827 850
 				$auto = true;
851
+			} elseif (trim($row['column_default']) != '') {
852
+							$default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::'));
853
+			} else {
854
+							$default = null;
828 855
 			}
829
-			elseif (trim($row['column_default']) != '')
830
-				$default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::'));
831
-			else
832
-				$default = null;
833 856
 
834 857
 			// Make the type generic.
835 858
 			list ($type, $size) = $smcFunc['db_calculate_type']($row['data_type'], $row['character_maximum_length'], true);
@@ -880,26 +903,30 @@  discard block
 block discarded – undo
880 903
 	while ($row = $smcFunc['db_fetch_assoc']($result))
881 904
 	{
882 905
 		// Try get the columns that make it up.
883
-		if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0)
884
-			continue;
906
+		if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) {
907
+					continue;
908
+		}
885 909
 
886 910
 		$columns = explode(',', $matches[1]);
887 911
 
888
-		if (empty($columns))
889
-			continue;
912
+		if (empty($columns)) {
913
+					continue;
914
+		}
890 915
 
891
-		foreach ($columns as $k => $v)
892
-			$columns[$k] = trim($v);
916
+		foreach ($columns as $k => $v) {
917
+					$columns[$k] = trim($v);
918
+		}
893 919
 
894 920
 		// Fix up the name to be consistent cross databases
895
-		if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1)
896
-			$row['name'] = 'PRIMARY';
897
-		else
898
-			$row['name'] = str_replace($table_name . '_', '', $row['name']);
921
+		if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1) {
922
+					$row['name'] = 'PRIMARY';
923
+		} else {
924
+					$row['name'] = str_replace($table_name . '_', '', $row['name']);
925
+		}
899 926
 
900
-		if (!$detail)
901
-			$indexes[] = $row['name'];
902
-		else
927
+		if (!$detail) {
928
+					$indexes[] = $row['name'];
929
+		} else
903 930
 		{
904 931
 			$indexes[$row['name']] = array(
905 932
 				'name' => $row['name'],
Please login to merge, or discard this patch.
Sources/Errors.php 1 patch
Braces   +127 added lines, -91 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
  * Log an error, if the error logging is enabled.
@@ -41,17 +42,19 @@  discard block
 block discarded – undo
41 42
 	// are we in a loop?
42 43
 	if($error_call > 2)
43 44
 	{
44
-		if (!isset($db_show_debug) || $db_show_debug === false)
45
-			$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
46
-		else
47
-			$backtrace = debug_backtrace();
45
+		if (!isset($db_show_debug) || $db_show_debug === false) {
46
+					$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
47
+		} else {
48
+					$backtrace = debug_backtrace();
49
+		}
48 50
 		var_dump($backtrace);
49 51
 		die('Error loop.');
50 52
 	}
51 53
 
52 54
 	// Check if error logging is actually on.
53
-	if (empty($modSettings['enableErrorLogging']))
54
-		return $error_message;
55
+	if (empty($modSettings['enableErrorLogging'])) {
56
+			return $error_message;
57
+	}
55 58
 
56 59
 	// Basically, htmlspecialchars it minus &. (for entities!)
57 60
 	$error_message = strtr($error_message, array('<' => '&lt;', '>' => '&gt;', '"' => '&quot;'));
@@ -59,33 +62,39 @@  discard block
 block discarded – undo
59 62
 
60 63
 	// Add a file and line to the error message?
61 64
 	// Don't use the actual txt entries for file and line but instead use %1$s for file and %2$s for line
62
-	if ($file == null)
63
-		$file = '';
64
-	else
65
-		// Window style slashes don't play well, lets convert them to the unix style.
65
+	if ($file == null) {
66
+			$file = '';
67
+	} else {
68
+			// Window style slashes don't play well, lets convert them to the unix style.
66 69
 		$file = str_replace('\\', '/', $file);
70
+	}
67 71
 
68
-	if ($line == null)
69
-		$line = 0;
70
-	else
71
-		$line = (int) $line;
72
+	if ($line == null) {
73
+			$line = 0;
74
+	} else {
75
+			$line = (int) $line;
76
+	}
72 77
 
73 78
 	// Just in case there's no id_member or IP set yet.
74
-	if (empty($user_info['id']))
75
-		$user_info['id'] = 0;
76
-	if (empty($user_info['ip']))
77
-		$user_info['ip'] = '';
79
+	if (empty($user_info['id'])) {
80
+			$user_info['id'] = 0;
81
+	}
82
+	if (empty($user_info['ip'])) {
83
+			$user_info['ip'] = '';
84
+	}
78 85
 
79 86
 	// Find the best query string we can...
80 87
 	$query_string = empty($_SERVER['QUERY_STRING']) ? (empty($_SERVER['REQUEST_URL']) ? '' : str_replace($scripturl, '', $_SERVER['REQUEST_URL'])) : $_SERVER['QUERY_STRING'];
81 88
 
82 89
 	// Don't log the session hash in the url twice, it's a waste.
83
-	if (!empty($smcFunc['htmlspecialchars']))
84
-		$query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string));
90
+	if (!empty($smcFunc['htmlspecialchars'])) {
91
+			$query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string));
92
+	}
85 93
 
86 94
 	// Just so we know what board error messages are from.
87
-	if (isset($_POST['board']) && !isset($_GET['board']))
88
-		$query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board'];
95
+	if (isset($_POST['board']) && !isset($_GET['board'])) {
96
+			$query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board'];
97
+	}
89 98
 
90 99
 	// What types of categories do we have?
91 100
 	$known_error_types = array(
@@ -134,9 +143,9 @@  discard block
 block discarded – undo
134 143
 
135 144
 			list($context['num_errors']) = $smcFunc['db_fetch_row']($query);
136 145
 			$smcFunc['db_free_result']($query);
146
+		} else {
147
+					$context['num_errors']++;
137 148
 		}
138
-		else
139
-			$context['num_errors']++;
140 149
 	}
141 150
 
142 151
 	// reset error call
@@ -158,12 +167,14 @@  discard block
 block discarded – undo
158 167
 	global $txt;
159 168
 
160 169
 	// Send the appropriate HTTP status header - set this to 0 or false if you don't want to send one at all
161
-	if (!empty($status))
162
-		send_http_status($status);
170
+	if (!empty($status)) {
171
+			send_http_status($status);
172
+	}
163 173
 
164 174
 	// We don't have $txt yet, but that's okay...
165
-	if (empty($txt))
166
-		die($error);
175
+	if (empty($txt)) {
176
+			die($error);
177
+	}
167 178
 
168 179
 	log_error_online($error, false);
169 180
 	setup_fatal_error_context($log ? log_error($error, $log) : $error);
@@ -190,8 +201,9 @@  discard block
 block discarded – undo
190 201
 	static $fatal_error_called = false;
191 202
 
192 203
 	// Send the status header - set this to 0 or false if you don't want to send one at all
193
-	if (!empty($status))
194
-		send_http_status($status);
204
+	if (!empty($status)) {
205
+			send_http_status($status);
206
+	}
195 207
 
196 208
 	// Try to load a theme if we don't have one.
197 209
 	if (empty($context['theme_loaded']) && empty($fatal_error_called))
@@ -201,8 +213,9 @@  discard block
 block discarded – undo
201 213
 	}
202 214
 
203 215
 	// If we have no theme stuff we can't have the language file...
204
-	if (empty($context['theme_loaded']))
205
-		die($error);
216
+	if (empty($context['theme_loaded'])) {
217
+			die($error);
218
+	}
206 219
 
207 220
 	$reload_lang_file = true;
208 221
 	// Log the error in the forum's language, but don't waste the time if we aren't logging
@@ -238,8 +251,9 @@  discard block
 block discarded – undo
238 251
 	global $settings, $modSettings, $db_show_debug;
239 252
 
240 253
 	// Ignore errors if we're ignoring them or they are strict notices from PHP 5
241
-	if (error_reporting() == 0)
242
-		return;
254
+	if (error_reporting() == 0) {
255
+			return;
256
+	}
243 257
 
244 258
 	if (strpos($file, 'eval()') !== false && !empty($settings['current_include_filename']))
245 259
 	{
@@ -247,19 +261,22 @@  discard block
 block discarded – undo
247 261
 		$count = count($array);
248 262
 		for ($i = 0; $i < $count; $i++)
249 263
 		{
250
-			if ($array[$i]['function'] != 'loadSubTemplate')
251
-				continue;
264
+			if ($array[$i]['function'] != 'loadSubTemplate') {
265
+							continue;
266
+			}
252 267
 
253 268
 			// This is a bug in PHP, with eval, it seems!
254
-			if (empty($array[$i]['args']))
255
-				$i++;
269
+			if (empty($array[$i]['args'])) {
270
+							$i++;
271
+			}
256 272
 			break;
257 273
 		}
258 274
 
259
-		if (isset($array[$i]) && !empty($array[$i]['args']))
260
-			$file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)';
261
-		else
262
-			$file = realpath($settings['current_include_filename']) . ' (eval?)';
275
+		if (isset($array[$i]) && !empty($array[$i]['args'])) {
276
+					$file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)';
277
+		} else {
278
+					$file = realpath($settings['current_include_filename']) . ' (eval?)';
279
+		}
263 280
 	}
264 281
 
265 282
 	if (isset($db_show_debug) && $db_show_debug === true)
@@ -268,8 +285,9 @@  discard block
 block discarded – undo
268 285
 		if ($error_level % 255 != E_ERROR)
269 286
 		{
270 287
 			$temporary = ob_get_contents();
271
-			if (substr($temporary, -2) == '="')
272
-				echo '"';
288
+			if (substr($temporary, -2) == '="') {
289
+							echo '"';
290
+			}
273 291
 		}
274 292
 
275 293
 		// Debugging!  This should look like a PHP error message.
@@ -285,23 +303,27 @@  discard block
 block discarded – undo
285 303
 	call_integration_hook('integrate_output_error', array($message, $error_type, $error_level, $file, $line));
286 304
 
287 305
 	// Dying on these errors only causes MORE problems (blank pages!)
288
-	if ($file == 'Unknown')
289
-		return;
306
+	if ($file == 'Unknown') {
307
+			return;
308
+	}
290 309
 
291 310
 	// If this is an E_ERROR or E_USER_ERROR.... die.  Violently so.
292
-	if ($error_level % 255 == E_ERROR)
293
-		obExit(false);
294
-	else
295
-		return;
311
+	if ($error_level % 255 == E_ERROR) {
312
+			obExit(false);
313
+	} else {
314
+			return;
315
+	}
296 316
 
297 317
 	// If this is an E_ERROR, E_USER_ERROR, E_WARNING, or E_USER_WARNING.... die.  Violently so.
298
-	if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING)
299
-		fatal_error(allowedTo('admin_forum') ? $message : $error_string, false);
318
+	if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) {
319
+			fatal_error(allowedTo('admin_forum') ? $message : $error_string, false);
320
+	}
300 321
 
301 322
 	// We should NEVER get to this point.  Any fatal error MUST quit, or very bad things can happen.
302
-	if ($error_level % 255 == E_ERROR)
303
-		die('No direct access...');
304
-}
323
+	if ($error_level % 255 == E_ERROR) {
324
+			die('No direct access...');
325
+	}
326
+	}
305 327
 
306 328
 /**
307 329
  * It is called by {@link fatal_error()} and {@link fatal_lang_error()}.
@@ -317,24 +339,28 @@  discard block
 block discarded – undo
317 339
 
318 340
 	// Attempt to prevent a recursive loop.
319 341
 	++$level;
320
-	if ($level > 1)
321
-		return false;
342
+	if ($level > 1) {
343
+			return false;
344
+	}
322 345
 
323 346
 	// Maybe they came from dlattach or similar?
324
-	if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded']))
325
-		loadTheme();
347
+	if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) {
348
+			loadTheme();
349
+	}
326 350
 
327 351
 	// Don't bother indexing errors mate...
328 352
 	$context['robot_no_index'] = true;
329 353
 
330
-	if (!isset($context['error_title']))
331
-		$context['error_title'] = $txt['error_occured'];
354
+	if (!isset($context['error_title'])) {
355
+			$context['error_title'] = $txt['error_occured'];
356
+	}
332 357
 	$context['error_message'] = isset($context['error_message']) ? $context['error_message'] : $error_message;
333 358
 
334 359
 	$context['error_code'] = isset($error_code) ? 'id="' . $error_code . '" ' : '';
335 360
 
336
-	if (empty($context['page_title']))
337
-		$context['page_title'] = $context['error_title'];
361
+	if (empty($context['page_title'])) {
362
+			$context['page_title'] = $context['error_title'];
363
+	}
338 364
 
339 365
 	loadTemplate('Errors');
340 366
 	$context['sub_template'] = 'fatal_error';
@@ -342,23 +368,26 @@  discard block
 block discarded – undo
342 368
 	// If this is SSI, what do they want us to do?
343 369
 	if (SMF == 'SSI')
344 370
 	{
345
-		if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method))
346
-			$ssi_on_error_method();
347
-		elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true)
348
-			loadSubTemplate('fatal_error');
371
+		if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) {
372
+					$ssi_on_error_method();
373
+		} elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) {
374
+					loadSubTemplate('fatal_error');
375
+		}
349 376
 
350 377
 		// No layers?
351
-		if (empty($ssi_on_error_method) || $ssi_on_error_method !== true)
352
-			exit;
378
+		if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) {
379
+					exit;
380
+		}
353 381
 	}
354 382
 	// Alternatively from the cron call?
355 383
 	elseif (SMF == 'BACKGROUND')
356 384
 	{
357 385
 		// We can't rely on even having language files available.
358
-		if (defined('FROM_CLI') && FROM_CLI)
359
-			echo 'cron error: ', $context['error_message'];
360
-		else
361
-			echo 'An error occurred. More information may be available in your logs.';
386
+		if (defined('FROM_CLI') && FROM_CLI) {
387
+					echo 'cron error: ', $context['error_message'];
388
+		} else {
389
+					echo 'An error occurred. More information may be available in your logs.';
390
+		}
362 391
 		exit;
363 392
 	}
364 393
 
@@ -386,8 +415,8 @@  discard block
 block discarded – undo
386 415
 
387 416
 	set_fatal_error_headers();
388 417
 
389
-	if (!empty($maintenance))
390
-		echo '<!DOCTYPE html>
418
+	if (!empty($maintenance)) {
419
+			echo '<!DOCTYPE html>
391 420
 <html>
392 421
 	<head>
393 422
 		<meta name="robots" content="noindex">
@@ -398,6 +427,7 @@  discard block
 block discarded – undo
398 427
 		', $mmessage, '
399 428
 	</body>
400 429
 </html>';
430
+	}
401 431
 
402 432
 	die();
403 433
 }
@@ -419,15 +449,17 @@  discard block
 block discarded – undo
419 449
 	// For our purposes, we're gonna want this on if at all possible.
420 450
 	$modSettings['cache_enable'] = '1';
421 451
 
422
-	if (($temp = cache_get_data('db_last_error', 600)) !== null)
423
-		$db_last_error = max($db_last_error, $temp);
452
+	if (($temp = cache_get_data('db_last_error', 600)) !== null) {
453
+			$db_last_error = max($db_last_error, $temp);
454
+	}
424 455
 
425 456
 	if ($db_last_error < time() - 3600 * 24 * 3 && empty($maintenance) && !empty($db_error_send))
426 457
 	{
427 458
 		// Avoid writing to the Settings.php file if at all possible; use shared memory instead.
428 459
 		cache_put_data('db_last_error', time(), 600);
429
-		if (($temp = cache_get_data('db_last_error', 600)) === null)
430
-			logLastDatabaseError();
460
+		if (($temp = cache_get_data('db_last_error', 600)) === null) {
461
+					logLastDatabaseError();
462
+		}
431 463
 
432 464
 		// Language files aren't loaded yet :(.
433 465
 		$db_error = @$smcFunc['db_error']($db_connection);
@@ -508,12 +540,14 @@  discard block
 block discarded – undo
508 540
 	global $smcFunc, $user_info, $modSettings;
509 541
 
510 542
 	// Don't bother if Who's Online is disabled.
511
-	if (empty($modSettings['who_enabled']))
512
-		return;
543
+	if (empty($modSettings['who_enabled'])) {
544
+			return;
545
+	}
513 546
 
514 547
 	// Maybe they came from SSI or similar where sessions are not recorded?
515
-	if (SMF == 'SSI' || SMF == 'BACKGROUND')
516
-		return;
548
+	if (SMF == 'SSI' || SMF == 'BACKGROUND') {
549
+			return;
550
+	}
517 551
 
518 552
 	$session_id = !empty($user_info['is_guest']) ? 'ip' . $user_info['ip'] : session_id();
519 553
 
@@ -539,8 +573,9 @@  discard block
 block discarded – undo
539 573
 		$url = $smcFunc['json_decode']($url, true);
540 574
 		$url['error'] = $error;
541 575
 
542
-		if (!empty($sprintf))
543
-			$url['error_params'] = $sprintf;
576
+		if (!empty($sprintf)) {
577
+					$url['error_params'] = $sprintf;
578
+		}
544 579
 
545 580
 		$smcFunc['db_query']('', '
546 581
 			UPDATE {db_prefix}log_online
@@ -571,10 +606,11 @@  discard block
 block discarded – undo
571 606
 
572 607
 	$protocol = preg_match('~HTTP/1\.[01]~i', $_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0';
573 608
 
574
-	if (!isset($statuses[$code]))
575
-		header($protocol . ' 500 Internal Server Error');
576
-	else
577
-		header($protocol . ' ' . $code . ' ' . $statuses[$code]);
578
-}
609
+	if (!isset($statuses[$code])) {
610
+			header($protocol . ' 500 Internal Server Error');
611
+	} else {
612
+			header($protocol . ' ' . $code . ' ' . $statuses[$code]);
613
+	}
614
+	}
579 615
 
580 616
 ?>
581 617
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/Login.template.php 1 patch
Braces   +35 added lines, -24 removed lines patch added patch discarded remove patch
@@ -28,15 +28,17 @@  discard block
 block discarded – undo
28 28
 				<form class="login" action="', $context['login_url'], '" name="frmLogin" id="frmLogin" method="post" accept-charset="', $context['character_set'], '">';
29 29
 
30 30
 	// Did they make a mistake last time?
31
-	if (!empty($context['login_errors']))
32
-		echo '
31
+	if (!empty($context['login_errors'])) {
32
+			echo '
33 33
 					<div class="errorbox">', implode('<br>', $context['login_errors']), '</div>
34 34
 					<br>';
35
+	}
35 36
 
36 37
 	// Or perhaps there's some special description for this time?
37
-	if (isset($context['description']))
38
-		echo '
38
+	if (isset($context['description'])) {
39
+			echo '
39 40
 					<div class="information">', $context['description'], '</div>';
41
+	}
40 42
 
41 43
 	// Now just get the basic information - username, password, etc.
42 44
 	echo '
@@ -61,10 +63,11 @@  discard block
 block discarded – undo
61 63
 						</dd>';
62 64
 
63 65
 	// If they have deleted their account, give them a chance to change their mind.
64
-	if (isset($context['login_show_undelete']))
65
-		echo '
66
+	if (isset($context['login_show_undelete'])) {
67
+			echo '
66 68
 						<dt class="alert">', $txt['undelete_account'], ':</dt>
67 69
 						<dd><input type="checkbox" name="undelete"></dd>';
70
+	}
68 71
 
69 72
 	echo '
70 73
 					</dl>
@@ -82,8 +85,8 @@  discard block
 block discarded – undo
82 85
 							document.getElementById("', !empty($context['from_ajax']) ? 'ajax_' : '', isset($context['default_username']) && $context['default_username'] != '' ? 'loginpass' : 'loginuser', '").focus();
83 86
 						}, 150);';
84 87
 
85
-	if (!empty($context['from_ajax']))
86
-		echo '
88
+	if (!empty($context['from_ajax'])) {
89
+			echo '
87 90
 						form = $("#frmLogin");
88 91
 						form.submit(function(e) {
89 92
 							e.preventDefault();
@@ -116,16 +119,18 @@  discard block
 block discarded – undo
116 119
 
117 120
 							return false;
118 121
 						});';
122
+	}
119 123
 
120 124
 	echo '
121 125
 					</script>
122 126
 				</form>';
123 127
 
124 128
 	// It is a long story as to why we have this when we're clearly not going to use it.
125
-	if (!empty($context['from_ajax']))
126
-		echo '
129
+	if (!empty($context['from_ajax'])) {
130
+			echo '
127 131
 				<br>
128 132
 				<a href="javascript:self.close();"></a>';
133
+	}
129 134
 
130 135
 	echo '
131 136
 			</div><!-- .roundframe -->
@@ -148,11 +153,12 @@  discard block
 block discarded – undo
148 153
 			</div>
149 154
 			<div class="roundframe noup">';
150 155
 
151
-	if (!empty($context['tfa_error']) || !empty($context['tfa_backup_error']))
152
-		echo '
156
+	if (!empty($context['tfa_error']) || !empty($context['tfa_backup_error'])) {
157
+			echo '
153 158
 				<div class="error">
154 159
 					', $txt['tfa_' . (!empty($context['tfa_error']) ? 'code_' : 'backup_') . 'invalid'], '
155 160
 				</div>';
161
+	}
156 162
 
157 163
 	echo '
158 164
 				<form action="', $context['tfa_url'], '" method="post" id="frmTfa">
@@ -181,8 +187,8 @@  discard block
 block discarded – undo
181 187
 				<script>
182 188
 					form = $("#frmTfa");';
183 189
 
184
-	if (!empty($context['from_ajax']))
185
-		echo '
190
+	if (!empty($context['from_ajax'])) {
191
+			echo '
186 192
 					form.submit(function(e) {
187 193
 						// If we are submitting backup code, let normal workflow follow since it redirects a couple times into a different page
188 194
 						if (form.find("input[name=tfa_backup]:first").val().length > 0)
@@ -201,6 +207,7 @@  discard block
 block discarded – undo
201 207
 
202 208
 						return false;
203 209
 					});';
210
+	}
204 211
 
205 212
 	echo '
206 213
 					form.find("input[name=backup]").click(function(e) {
@@ -232,10 +239,11 @@  discard block
 block discarded – undo
232 239
 			<p class="information centertext">
233 240
 				', empty($context['kick_message']) ? $txt['only_members_can_access'] : $context['kick_message'], '<br>';
234 241
 
235
-	if ($context['can_register'])
236
-		echo sprintf($txt['login_below_or_register'], $scripturl . '?action=signup', $context['forum_name_html_safe']);
237
-	else
238
-		echo $txt['login_below'];
242
+	if ($context['can_register']) {
243
+			echo sprintf($txt['login_below_or_register'], $scripturl . '?action=signup', $context['forum_name_html_safe']);
244
+	} else {
245
+			echo $txt['login_below'];
246
+	}
239 247
 
240 248
 	// And now the login information.
241 249
 	echo '
@@ -335,9 +343,10 @@  discard block
 block discarded – undo
335 343
 			</div>
336 344
 			<div class="roundframe centertext noup">';
337 345
 
338
-	if (!empty($context['incorrect_password']))
339
-		echo '
346
+	if (!empty($context['incorrect_password'])) {
347
+			echo '
340 348
 				<div class="error">', $txt['admin_incorrect_password'], '</div>';
349
+	}
341 350
 
342 351
 	echo '
343 352
 				<strong>', $txt['password'], ':</strong>
@@ -378,10 +387,11 @@  discard block
 block discarded – undo
378 387
 				<dl>';
379 388
 
380 389
 	// You didn't even have an ID?
381
-	if (empty($context['member_id']))
382
-		echo '
390
+	if (empty($context['member_id'])) {
391
+			echo '
383 392
 					<dt>', $txt['invalid_activation_username'], ':</dt>
384 393
 					<dd><input type="text" name="user" size="30"></dd>';
394
+	}
385 395
 
386 396
 	echo '
387 397
 					<dt>', $txt['invalid_activation_retry'], ':</dt>
@@ -418,13 +428,14 @@  discard block
 block discarded – undo
418 428
 					<dd><input type="password" name="passwd" size="30"></dd>
419 429
 				</dl>';
420 430
 
421
-	if ($context['can_activate'])
422
-		echo '
431
+	if ($context['can_activate']) {
432
+			echo '
423 433
 				<p>', $txt['invalid_activation_known'], '</p>
424 434
 				<dl>
425 435
 					<dt>', $txt['invalid_activation_retry'], ':</dt>
426 436
 					<dd><input type="text" name="code" size="30"></dd>
427 437
 				</dl>';
438
+	}
428 439
 
429 440
 	echo '
430 441
 				<p><input type="submit" value="', $txt['invalid_activation_resend'], '" class="button"></p>
Please login to merge, or discard this patch.
Sources/ManageServer.php 1 patch
Braces   +312 added lines, -241 removed lines patch added patch discarded remove patch
@@ -59,8 +59,9 @@  discard block
 block discarded – undo
59 59
  * @version 2.1 Beta 4
60 60
  */
61 61
 
62
-if (!defined('SMF'))
62
+if (!defined('SMF')) {
63 63
 	die('No direct access...');
64
+}
64 65
 
65 66
 /**
66 67
  * This is the main dispatcher. Sets up all the available sub-actions, all the tabs and selects
@@ -111,10 +112,11 @@  discard block
 block discarded – undo
111 112
 	$settings_not_writable = !is_writable($boarddir . '/Settings.php');
112 113
 	$settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
113 114
 
114
-	if ($settings_not_writable)
115
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
116
-	elseif ($settings_backup_fail)
117
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
115
+	if ($settings_not_writable) {
116
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
117
+	} elseif ($settings_backup_fail) {
118
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
119
+	}
118 120
 
119 121
 	$context['settings_not_writable'] = $settings_not_writable;
120 122
 
@@ -142,10 +144,11 @@  discard block
 block discarded – undo
142 144
 
143 145
 	// If no cert, force_ssl must remain 0
144 146
 	require_once($sourcedir . '/Subs.php');
145
-	if (!ssl_cert_found($boardurl) && empty($modSettings['force_ssl']))
146
-		$disable_force_ssl = true;
147
-	else
148
-		$disable_force_ssl = false;
147
+	if (!ssl_cert_found($boardurl) && empty($modSettings['force_ssl'])) {
148
+			$disable_force_ssl = true;
149
+	} else {
150
+			$disable_force_ssl = false;
151
+	}
149 152
 
150 153
 	/* If you're writing a mod, it's a bad idea to add things here....
151 154
 	For each option:
@@ -175,8 +178,9 @@  discard block
 block discarded – undo
175 178
 
176 179
 	call_integration_hook('integrate_general_settings', array(&$config_vars));
177 180
 
178
-	if ($return_config)
179
-		return $config_vars;
181
+	if ($return_config) {
182
+			return $config_vars;
183
+	}
180 184
 
181 185
 	// Setup the template stuff.
182 186
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=general;save';
@@ -193,16 +197,18 @@  discard block
 block discarded – undo
193 197
 			$registerSMStats = registerSMStats();
194 198
 
195 199
 			// Failed to register, disable it again.
196
-			if (empty($registerSMStats))
197
-				$_POST['enable_sm_stats'] = 0;
200
+			if (empty($registerSMStats)) {
201
+							$_POST['enable_sm_stats'] = 0;
202
+			}
198 203
 		}
199 204
 
200 205
 		// Ensure all URLs are aligned with the new force_ssl setting
201 206
 		// Treat unset like 0
202
-		if (isset($_POST['force_ssl']))
203
-			AlignURLsWithSSLSetting($_POST['force_ssl']);
204
-		else
205
-			AlignURLsWithSSLSetting(0);
207
+		if (isset($_POST['force_ssl'])) {
208
+					AlignURLsWithSSLSetting($_POST['force_ssl']);
209
+		} else {
210
+					AlignURLsWithSSLSetting(0);
211
+		}
206 212
 
207 213
 		saveSettings($config_vars);
208 214
 		$_SESSION['adm-save'] = true;
@@ -255,10 +261,11 @@  discard block
 block discarded – undo
255 261
 	require_once($sourcedir . '/Subs-Admin.php');
256 262
 
257 263
 	// Check $boardurl
258
-	if (!empty($new_force_ssl))
259
-		$newval = strtr($boardurl, array('http://' => 'https://'));
260
-	else
261
-		$newval = strtr($boardurl, array('https://' => 'http://'));
264
+	if (!empty($new_force_ssl)) {
265
+			$newval = strtr($boardurl, array('http://' => 'https://'));
266
+	} else {
267
+			$newval = strtr($boardurl, array('https://' => 'http://'));
268
+	}
262 269
 	updateSettingsFile(array('boardurl' => '\'' . addslashes($newval) . '\''));
263 270
 
264 271
 	$new_settings = array();
@@ -266,20 +273,22 @@  discard block
 block discarded – undo
266 273
 	// Check $smileys_url, but only if it points to a subfolder of $boardurl
267 274
 	if (BoardurlMatch($modSettings['smileys_url']))
268 275
 	{
269
-		if (!empty($new_force_ssl))
270
-			$newval = strtr($modSettings['smileys_url'], array('http://' => 'https://'));
271
-		else
272
-			$newval = strtr($modSettings['smileys_url'], array('https://' => 'http://'));
276
+		if (!empty($new_force_ssl)) {
277
+					$newval = strtr($modSettings['smileys_url'], array('http://' => 'https://'));
278
+		} else {
279
+					$newval = strtr($modSettings['smileys_url'], array('https://' => 'http://'));
280
+		}
273 281
 		$new_settings['smileys_url'] = $newval;
274 282
 	}
275 283
 
276 284
 	// Check $avatar_url, but only if it points to a subfolder of $boardurl
277 285
 	if (BoardurlMatch($modSettings['avatar_url']))
278 286
 	{
279
-		if (!empty($new_force_ssl))
280
-			$newval = strtr($modSettings['avatar_url'], array('http://' => 'https://'));
281
-		else
282
-			$newval = strtr($modSettings['avatar_url'], array('https://' => 'http://'));
287
+		if (!empty($new_force_ssl)) {
288
+					$newval = strtr($modSettings['avatar_url'], array('http://' => 'https://'));
289
+		} else {
290
+					$newval = strtr($modSettings['avatar_url'], array('https://' => 'http://'));
291
+		}
283 292
 		$new_settings['avatar_url'] = $newval;
284 293
 	}
285 294
 
@@ -287,16 +296,18 @@  discard block
 block discarded – undo
287 296
 	// This one had been optional in the past, make sure it is set first
288 297
 	if (isset($modSettings['custom_avatar_url']) && BoardurlMatch($modSettings['custom_avatar_url']))
289 298
 	{
290
-		if (!empty($new_force_ssl))
291
-			$newval = strtr($modSettings['custom_avatar_url'], array('http://' => 'https://'));
292
-		else
293
-			$newval = strtr($modSettings['custom_avatar_url'], array('https://' => 'http://'));
299
+		if (!empty($new_force_ssl)) {
300
+					$newval = strtr($modSettings['custom_avatar_url'], array('http://' => 'https://'));
301
+		} else {
302
+					$newval = strtr($modSettings['custom_avatar_url'], array('https://' => 'http://'));
303
+		}
294 304
 		$new_settings['custom_avatar_url'] = $newval;
295 305
 	}
296 306
 
297 307
 	// Save updates to the settings table
298
-	if (!empty($new_settings))
299
-		updateSettings($new_settings, true);
308
+	if (!empty($new_settings)) {
309
+			updateSettings($new_settings, true);
310
+	}
300 311
 
301 312
 	// Now we move onto the themes.
302 313
 	// First, get a list of theme URLs...
@@ -317,10 +328,11 @@  discard block
 block discarded – undo
317 328
 		// First check to see if it points to a subfolder of $boardurl
318 329
 		if (BoardurlMatch($row['value']))
319 330
 		{
320
-			if (!empty($new_force_ssl))
321
-				$newval = strtr($row['value'], array('http://' => 'https://'));
322
-			else
323
-				$newval = strtr($row['value'], array('https://' => 'http://'));
331
+			if (!empty($new_force_ssl)) {
332
+							$newval = strtr($row['value'], array('http://' => 'https://'));
333
+			} else {
334
+							$newval = strtr($row['value'], array('https://' => 'http://'));
335
+			}
324 336
 			$smcFunc['db_query']('', '
325 337
 				UPDATE {db_prefix}themes
326 338
 				   SET value = {string:theme_val}
@@ -360,11 +372,12 @@  discard block
 block discarded – undo
360 372
 
361 373
 	// If leftmost portion of path matches boardurl, return true
362 374
 	$result = strpos($urlpath, $boardurlpath);
363
-	if ($result === false || $result != 0)
364
-		return false;
365
-	else
366
-		return true;
367
-}
375
+	if ($result === false || $result != 0) {
376
+			return false;
377
+	} else {
378
+			return true;
379
+	}
380
+	}
368 381
 
369 382
 /**
370 383
  * Basic database and paths settings - database name, host, etc.
@@ -402,8 +415,9 @@  discard block
 block discarded – undo
402 415
 		$request = $smcFunc['db_query']('', 'SELECT cfgname FROM pg_ts_config', array());
403 416
 		$fts_language = array();
404 417
 
405
-		while ($row = $smcFunc['db_fetch_assoc']($request))
406
-			$fts_language[$row['cfgname']] = $row['cfgname'];
418
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
419
+					$fts_language[$row['cfgname']] = $row['cfgname'];
420
+		}
407 421
 
408 422
 		$config_vars = array_merge ($config_vars, array(
409 423
 				'',
@@ -415,8 +429,9 @@  discard block
 block discarded – undo
415 429
 
416 430
 	call_integration_hook('integrate_database_settings', array(&$config_vars));
417 431
 
418
-	if ($return_config)
419
-		return $config_vars;
432
+	if ($return_config) {
433
+			return $config_vars;
434
+	}
420 435
 
421 436
 	// Setup the template stuff.
422 437
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=database;save';
@@ -491,13 +506,15 @@  discard block
 block discarded – undo
491 506
 		hideGlobalCookies();
492 507
 	});', true);
493 508
 
494
-	if (empty($user_settings['tfa_secret']))
495
-		addInlineJavaScript('');
509
+	if (empty($user_settings['tfa_secret'])) {
510
+			addInlineJavaScript('');
511
+	}
496 512
 
497 513
 	call_integration_hook('integrate_cookie_settings', array(&$config_vars));
498 514
 
499
-	if ($return_config)
500
-		return $config_vars;
515
+	if ($return_config) {
516
+			return $config_vars;
517
+	}
501 518
 
502 519
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cookie;save';
503 520
 	$context['settings_title'] = $txt['cookies_sessions_settings'];
@@ -508,14 +525,17 @@  discard block
 block discarded – undo
508 525
 		call_integration_hook('integrate_save_cookie_settings');
509 526
 
510 527
 		// Local and global do not play nicely together.
511
-		if (!empty($_POST['localCookies']) && empty($_POST['globalCookies']))
512
-			unset ($_POST['globalCookies']);
528
+		if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) {
529
+					unset ($_POST['globalCookies']);
530
+		}
513 531
 
514
-		if (empty($modSettings['localCookies']) != empty($_POST['localCookies']) || empty($modSettings['globalCookies']) != empty($_POST['globalCookies']))
515
-			$scope_changed = true;
532
+		if (empty($modSettings['localCookies']) != empty($_POST['localCookies']) || empty($modSettings['globalCookies']) != empty($_POST['globalCookies'])) {
533
+					$scope_changed = true;
534
+		}
516 535
 
517
-		if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false)
518
-			fatal_lang_error('invalid_cookie_domain', false);
536
+		if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) {
537
+					fatal_lang_error('invalid_cookie_domain', false);
538
+		}
519 539
 
520 540
 		saveSettings($config_vars);
521 541
 
@@ -598,8 +618,9 @@  discard block
 block discarded – undo
598 618
 
599 619
 	call_integration_hook('integrate_general_security_settings', array(&$config_vars));
600 620
 
601
-	if ($return_config)
602
-		return $config_vars;
621
+	if ($return_config) {
622
+			return $config_vars;
623
+	}
603 624
 
604 625
 	// Saving?
605 626
 	if (isset($_GET['save']))
@@ -638,8 +659,7 @@  discard block
 block discarded – undo
638 659
 		$txt['cache_settings_message'] = $txt['detected_no_caching'];
639 660
 		$cache_level = array($txt['cache_off']);
640 661
 		$detected['none'] = $txt['cache_off'];
641
-	}
642
-	else
662
+	} else
643 663
 	{
644 664
 		$txt['cache_settings_message'] = sprintf($txt['detected_accelerators'], implode(', ', $detected));
645 665
 		$cache_level = array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']);
@@ -676,8 +696,9 @@  discard block
 block discarded – undo
676 696
 			}
677 697
 		}
678 698
 	}
679
-	if ($return_config)
680
-		return $config_vars;
699
+	if ($return_config) {
700
+			return $config_vars;
701
+	}
681 702
 
682 703
 	// Saving again?
683 704
 	if (isset($_GET['save']))
@@ -705,8 +726,9 @@  discard block
 block discarded – undo
705 726
 	$context['save_disabled'] = $context['settings_not_writable'];
706 727
 
707 728
 	// Decide what message to show.
708
-	if (!$context['save_disabled'])
709
-		$context['settings_message'] = $txt['caching_information'];
729
+	if (!$context['save_disabled']) {
730
+			$context['settings_message'] = $txt['caching_information'];
731
+	}
710 732
 
711 733
 	// Prepare the template.
712 734
 	prepareServerSettingsContext($config_vars);
@@ -729,24 +751,25 @@  discard block
 block discarded – undo
729 751
 	if (stripos(PHP_OS, 'win') === 0)
730 752
 	{
731 753
 		$context['settings_message'] = $txt['loadavg_disabled_windows'];
732
-		if (isset($_GET['save']))
733
-			$_SESSION['adm-save'] = $txt['loadavg_disabled_windows'];
734
-	}
735
-	elseif (stripos(PHP_OS, 'darwin') === 0)
754
+		if (isset($_GET['save'])) {
755
+					$_SESSION['adm-save'] = $txt['loadavg_disabled_windows'];
756
+		}
757
+	} elseif (stripos(PHP_OS, 'darwin') === 0)
736 758
 	{
737 759
 		$context['settings_message'] = $txt['loadavg_disabled_osx'];
738
-		if (isset($_GET['save']))
739
-			$_SESSION['adm-save'] = $txt['loadavg_disabled_osx'];
740
-	}
741
-	else
760
+		if (isset($_GET['save'])) {
761
+					$_SESSION['adm-save'] = $txt['loadavg_disabled_osx'];
762
+		}
763
+	} else
742 764
 	{
743 765
 		$modSettings['load_average'] = @file_get_contents('/proc/loadavg');
744
-		if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0)
745
-			$modSettings['load_average'] = (float) $matches[1];
746
-		elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0)
747
-			$modSettings['load_average'] = (float) $matches[1];
748
-		else
749
-			unset($modSettings['load_average']);
766
+		if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) {
767
+					$modSettings['load_average'] = (float) $matches[1];
768
+		} elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) {
769
+					$modSettings['load_average'] = (float) $matches[1];
770
+		} else {
771
+					unset($modSettings['load_average']);
772
+		}
750 773
 
751 774
 		if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0)
752 775
 		{
@@ -782,8 +805,9 @@  discard block
 block discarded – undo
782 805
 
783 806
 	call_integration_hook('integrate_loadavg_settings', array(&$config_vars));
784 807
 
785
-	if ($return_config)
786
-		return $config_vars;
808
+	if ($return_config) {
809
+			return $config_vars;
810
+	}
787 811
 
788 812
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=loads;save';
789 813
 	$context['settings_title'] = $txt['load_balancing_settings'];
@@ -794,24 +818,27 @@  discard block
 block discarded – undo
794 818
 		// Stupidity is not allowed.
795 819
 		foreach ($_POST as $key => $value)
796 820
 		{
797
-			if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values)))
798
-				continue;
799
-			else
800
-				$_POST[$key] = (float) $value;
801
-
802
-			if ($key == 'loadavg_auto_opt' && $value <= 1)
803
-				$_POST['loadavg_auto_opt'] = 1.0;
804
-			elseif ($key == 'loadavg_forum' && $value < 10)
805
-				$_POST['loadavg_forum'] = 10.0;
806
-			elseif ($value < 2)
807
-				$_POST[$key] = 2.0;
821
+			if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) {
822
+							continue;
823
+			} else {
824
+							$_POST[$key] = (float) $value;
825
+			}
826
+
827
+			if ($key == 'loadavg_auto_opt' && $value <= 1) {
828
+							$_POST['loadavg_auto_opt'] = 1.0;
829
+			} elseif ($key == 'loadavg_forum' && $value < 10) {
830
+							$_POST['loadavg_forum'] = 10.0;
831
+			} elseif ($value < 2) {
832
+							$_POST[$key] = 2.0;
833
+			}
808 834
 		}
809 835
 
810 836
 		call_integration_hook('integrate_save_loadavg_settings');
811 837
 
812 838
 		saveDBSettings($config_vars);
813
-		if (!isset($_SESSION['adm-save']))
814
-			$_SESSION['adm-save'] = true;
839
+		if (!isset($_SESSION['adm-save'])) {
840
+					$_SESSION['adm-save'] = true;
841
+		}
815 842
 		redirectexit('action=admin;area=serversettings;sa=loads;' . $context['session_var'] . '=' . $context['session_id']);
816 843
 	}
817 844
 
@@ -847,10 +874,11 @@  discard block
 block discarded – undo
847 874
 
848 875
 	if (isset($_SESSION['adm-save']))
849 876
 	{
850
-		if ($_SESSION['adm-save'] === true)
851
-			$context['saved_successful'] = true;
852
-		else
853
-			$context['saved_failed'] = $_SESSION['adm-save'];
877
+		if ($_SESSION['adm-save'] === true) {
878
+					$context['saved_successful'] = true;
879
+		} else {
880
+					$context['saved_failed'] = $_SESSION['adm-save'];
881
+		}
854 882
 
855 883
 		unset($_SESSION['adm-save']);
856 884
 	}
@@ -858,9 +886,9 @@  discard block
 block discarded – undo
858 886
 	$context['config_vars'] = array();
859 887
 	foreach ($config_vars as $identifier => $config_var)
860 888
 	{
861
-		if (!is_array($config_var) || !isset($config_var[1]))
862
-			$context['config_vars'][] = $config_var;
863
-		else
889
+		if (!is_array($config_var) || !isset($config_var[1])) {
890
+					$context['config_vars'][] = $config_var;
891
+		} else
864 892
 		{
865 893
 			$varname = $config_var[0];
866 894
 			global $$varname;
@@ -895,16 +923,19 @@  discard block
 block discarded – undo
895 923
 			if ($config_var[3] == 'int' || $config_var[3] == 'float')
896 924
 			{
897 925
 				// Default to a min of 0 if one isn't set
898
-				if (isset($config_var['min']))
899
-					$context['config_vars'][$config_var[0]]['min'] = $config_var['min'];
900
-				else
901
-					$context['config_vars'][$config_var[0]]['min'] = 0;
926
+				if (isset($config_var['min'])) {
927
+									$context['config_vars'][$config_var[0]]['min'] = $config_var['min'];
928
+				} else {
929
+									$context['config_vars'][$config_var[0]]['min'] = 0;
930
+				}
902 931
 
903
-				if (isset($config_var['max']))
904
-					$context['config_vars'][$config_var[0]]['max'] = $config_var['max'];
932
+				if (isset($config_var['max'])) {
933
+									$context['config_vars'][$config_var[0]]['max'] = $config_var['max'];
934
+				}
905 935
 
906
-				if (isset($config_var['step']))
907
-					$context['config_vars'][$config_var[0]]['step'] = $config_var['step'];
936
+				if (isset($config_var['step'])) {
937
+									$context['config_vars'][$config_var[0]]['step'] = $config_var['step'];
938
+				}
908 939
 			}
909 940
 
910 941
 			// If this is a select box handle any data.
@@ -912,12 +943,13 @@  discard block
 block discarded – undo
912 943
 			{
913 944
 				// If it's associative
914 945
 				$config_values = array_values($config_var[4]);
915
-				if (isset($config_values[0]) && is_array($config_values[0]))
916
-					$context['config_vars'][$config_var[0]]['data'] = $config_var[4];
917
-				else
946
+				if (isset($config_values[0]) && is_array($config_values[0])) {
947
+									$context['config_vars'][$config_var[0]]['data'] = $config_var[4];
948
+				} else
918 949
 				{
919
-					foreach ($config_var[4] as $key => $item)
920
-						$context['config_vars'][$config_var[0]]['data'][] = array($key, $item);
950
+					foreach ($config_var[4] as $key => $item) {
951
+											$context['config_vars'][$config_var[0]]['data'][] = array($key, $item);
952
+					}
921 953
 				}
922 954
 			}
923 955
 		}
@@ -942,10 +974,11 @@  discard block
 block discarded – undo
942 974
 
943 975
 	if (isset($_SESSION['adm-save']))
944 976
 	{
945
-		if ($_SESSION['adm-save'] === true)
946
-			$context['saved_successful'] = true;
947
-		else
948
-			$context['saved_failed'] = $_SESSION['adm-save'];
977
+		if ($_SESSION['adm-save'] === true) {
978
+					$context['saved_successful'] = true;
979
+		} else {
980
+					$context['saved_failed'] = $_SESSION['adm-save'];
981
+		}
949 982
 
950 983
 		unset($_SESSION['adm-save']);
951 984
 	}
@@ -957,26 +990,30 @@  discard block
 block discarded – undo
957 990
 	foreach ($config_vars as $config_var)
958 991
 	{
959 992
 		// HR?
960
-		if (!is_array($config_var))
961
-			$context['config_vars'][] = $config_var;
962
-		else
993
+		if (!is_array($config_var)) {
994
+					$context['config_vars'][] = $config_var;
995
+		} else
963 996
 		{
964 997
 			// If it has no name it doesn't have any purpose!
965
-			if (empty($config_var[1]))
966
-				continue;
998
+			if (empty($config_var[1])) {
999
+							continue;
1000
+			}
967 1001
 
968 1002
 			// Special case for inline permissions
969
-			if ($config_var[0] == 'permissions' && allowedTo('manage_permissions'))
970
-				$inlinePermissions[] = $config_var[1];
971
-			elseif ($config_var[0] == 'permissions')
972
-				continue;
1003
+			if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) {
1004
+							$inlinePermissions[] = $config_var[1];
1005
+			} elseif ($config_var[0] == 'permissions') {
1006
+							continue;
1007
+			}
973 1008
 
974
-			if ($config_var[0] == 'boards')
975
-				$board_list = true;
1009
+			if ($config_var[0] == 'boards') {
1010
+							$board_list = true;
1011
+			}
976 1012
 
977 1013
 			// Are we showing the BBC selection box?
978
-			if ($config_var[0] == 'bbc')
979
-				$bbcChoice[] = $config_var[1];
1014
+			if ($config_var[0] == 'bbc') {
1015
+							$bbcChoice[] = $config_var[1];
1016
+			}
980 1017
 
981 1018
 			// We need to do some parsing of the value before we pass it in.
982 1019
 			if (isset($modSettings[$config_var[1]]))
@@ -995,8 +1032,7 @@  discard block
 block discarded – undo
995 1032
 					default:
996 1033
 						$value = $smcFunc['htmlspecialchars']($modSettings[$config_var[1]]);
997 1034
 				}
998
-			}
999
-			else
1035
+			} else
1000 1036
 			{
1001 1037
 				// Darn, it's empty. What type is expected?
1002 1038
 				switch ($config_var[0])
@@ -1036,16 +1072,19 @@  discard block
 block discarded – undo
1036 1072
 			if ($config_var[0] == 'int' || $config_var[0] == 'float')
1037 1073
 			{
1038 1074
 				// Default to a min of 0 if one isn't set
1039
-				if (isset($config_var['min']))
1040
-					$context['config_vars'][$config_var[1]]['min'] = $config_var['min'];
1041
-				else
1042
-					$context['config_vars'][$config_var[1]]['min'] = 0;
1075
+				if (isset($config_var['min'])) {
1076
+									$context['config_vars'][$config_var[1]]['min'] = $config_var['min'];
1077
+				} else {
1078
+									$context['config_vars'][$config_var[1]]['min'] = 0;
1079
+				}
1043 1080
 
1044
-				if (isset($config_var['max']))
1045
-					$context['config_vars'][$config_var[1]]['max'] = $config_var['max'];
1081
+				if (isset($config_var['max'])) {
1082
+									$context['config_vars'][$config_var[1]]['max'] = $config_var['max'];
1083
+				}
1046 1084
 
1047
-				if (isset($config_var['step']))
1048
-					$context['config_vars'][$config_var[1]]['step'] = $config_var['step'];
1085
+				if (isset($config_var['step'])) {
1086
+									$context['config_vars'][$config_var[1]]['step'] = $config_var['step'];
1087
+				}
1049 1088
 			}
1050 1089
 
1051 1090
 			// If this is a select box handle any data.
@@ -1059,12 +1098,13 @@  discard block
 block discarded – undo
1059 1098
 				}
1060 1099
 
1061 1100
 				// If it's associative
1062
-				if (isset($config_var[2][0]) && is_array($config_var[2][0]))
1063
-					$context['config_vars'][$config_var[1]]['data'] = $config_var[2];
1064
-				else
1101
+				if (isset($config_var[2][0]) && is_array($config_var[2][0])) {
1102
+									$context['config_vars'][$config_var[1]]['data'] = $config_var[2];
1103
+				} else
1065 1104
 				{
1066
-					foreach ($config_var[2] as $key => $item)
1067
-						$context['config_vars'][$config_var[1]]['data'][] = array($key, $item);
1105
+					foreach ($config_var[2] as $key => $item) {
1106
+											$context['config_vars'][$config_var[1]]['data'][] = array($key, $item);
1107
+					}
1068 1108
 				}
1069 1109
 			}
1070 1110
 
@@ -1073,17 +1113,19 @@  discard block
 block discarded – undo
1073 1113
 			{
1074 1114
 				if (!is_numeric($k))
1075 1115
 				{
1076
-					if (substr($k, 0, 2) == 'on')
1077
-						$context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"';
1078
-					else
1079
-						$context['config_vars'][$config_var[1]][$k] = $v;
1116
+					if (substr($k, 0, 2) == 'on') {
1117
+											$context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"';
1118
+					} else {
1119
+											$context['config_vars'][$config_var[1]][$k] = $v;
1120
+					}
1080 1121
 				}
1081 1122
 
1082 1123
 				// See if there are any other labels that might fit?
1083
-				if (isset($txt['setting_' . $config_var[1]]))
1084
-					$context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]];
1085
-				elseif (isset($txt['groups_' . $config_var[1]]))
1086
-					$context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]];
1124
+				if (isset($txt['setting_' . $config_var[1]])) {
1125
+									$context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]];
1126
+				} elseif (isset($txt['groups_' . $config_var[1]])) {
1127
+									$context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]];
1128
+				}
1087 1129
 			}
1088 1130
 
1089 1131
 			// Set the subtext in case it's part of the label.
@@ -1116,8 +1158,9 @@  discard block
 block discarded – undo
1116 1158
 		// What are the options, eh?
1117 1159
 		$temp = parse_bbc(false);
1118 1160
 		$bbcTags = array();
1119
-		foreach ($temp as $tag)
1120
-			$bbcTags[] = $tag['tag'];
1161
+		foreach ($temp as $tag) {
1162
+					$bbcTags[] = $tag['tag'];
1163
+		}
1121 1164
 
1122 1165
 		$bbcTags = array_unique($bbcTags);
1123 1166
 		$totalTags = count($bbcTags);
@@ -1132,8 +1175,9 @@  discard block
 block discarded – undo
1132 1175
 		$col = 0; $i = 0;
1133 1176
 		foreach ($bbcTags as $tag)
1134 1177
 		{
1135
-			if ($i % $tagsPerColumn == 0 && $i != 0)
1136
-				$col++;
1178
+			if ($i % $tagsPerColumn == 0 && $i != 0) {
1179
+							$col++;
1180
+			}
1137 1181
 
1138 1182
 			$context['bbc_columns'][$col][] = array(
1139 1183
 				'tag' => $tag,
@@ -1176,18 +1220,21 @@  discard block
 block discarded – undo
1176 1220
 	validateToken('admin-ssc');
1177 1221
 
1178 1222
 	// Fix the darn stupid cookiename! (more may not be allowed, but these for sure!)
1179
-	if (isset($_POST['cookiename']))
1180
-		$_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']);
1223
+	if (isset($_POST['cookiename'])) {
1224
+			$_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']);
1225
+	}
1181 1226
 
1182 1227
 	// Fix the forum's URL if necessary.
1183 1228
 	if (isset($_POST['boardurl']))
1184 1229
 	{
1185
-		if (substr($_POST['boardurl'], -10) == '/index.php')
1186
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1187
-		elseif (substr($_POST['boardurl'], -1) == '/')
1188
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1189
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
1190
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1230
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
1231
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1232
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
1233
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1234
+		}
1235
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
1236
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1237
+		}
1191 1238
 	}
1192 1239
 
1193 1240
 	// Any passwords?
@@ -1222,21 +1269,21 @@  discard block
 block discarded – undo
1222 1269
 	// Figure out which config vars we're saving here...
1223 1270
 	foreach ($config_vars as $var)
1224 1271
 	{
1225
-		if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]])))
1226
-			continue;
1272
+		if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) {
1273
+					continue;
1274
+		}
1227 1275
 
1228 1276
 		$config_var = $var[0];
1229 1277
 
1230 1278
 		if (in_array($config_var, $config_passwords))
1231 1279
 		{
1232
-			if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1])
1233
-				$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\'';
1234
-		}
1235
-		elseif (in_array($config_var, $config_strs))
1280
+			if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) {
1281
+							$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\'';
1282
+			}
1283
+		} elseif (in_array($config_var, $config_strs))
1236 1284
 		{
1237 1285
 			$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var], '\'\\') . '\'';
1238
-		}
1239
-		elseif (in_array($config_var, $config_ints))
1286
+		} elseif (in_array($config_var, $config_ints))
1240 1287
 		{
1241 1288
 			$new_settings[$config_var] = (int) $_POST[$config_var];
1242 1289
 
@@ -1245,17 +1292,17 @@  discard block
 block discarded – undo
1245 1292
 			$new_settings[$config_var] = max($min, $new_settings[$config_var]);
1246 1293
 
1247 1294
 			// Is there a max value for this as well?
1248
-			if (isset($var['max']))
1249
-				$new_settings[$config_var] = min($var['max'], $new_settings[$config_var]);
1250
-		}
1251
-		elseif (in_array($config_var, $config_bools))
1295
+			if (isset($var['max'])) {
1296
+							$new_settings[$config_var] = min($var['max'], $new_settings[$config_var]);
1297
+			}
1298
+		} elseif (in_array($config_var, $config_bools))
1252 1299
 		{
1253
-			if (!empty($_POST[$config_var]))
1254
-				$new_settings[$config_var] = '1';
1255
-			else
1256
-				$new_settings[$config_var] = '0';
1257
-		}
1258
-		else
1300
+			if (!empty($_POST[$config_var])) {
1301
+							$new_settings[$config_var] = '1';
1302
+			} else {
1303
+							$new_settings[$config_var] = '0';
1304
+			}
1305
+		} else
1259 1306
 		{
1260 1307
 			// This shouldn't happen, but it might...
1261 1308
 			fatal_error('Unknown config_var \'' . $config_var . '\'');
@@ -1271,30 +1318,35 @@  discard block
 block discarded – undo
1271 1318
 	foreach ($config_vars as $config_var)
1272 1319
 	{
1273 1320
 		// We just saved the file-based settings, so skip their definitions.
1274
-		if (!is_array($config_var) || $config_var[2] == 'file')
1275
-			continue;
1321
+		if (!is_array($config_var) || $config_var[2] == 'file') {
1322
+					continue;
1323
+		}
1276 1324
 
1277 1325
 		$new_setting = array($config_var[3], $config_var[0]);
1278 1326
 
1279 1327
 		// Select options need carried over, too.
1280
-		if (isset($config_var[4]))
1281
-			$new_setting[] = $config_var[4];
1328
+		if (isset($config_var[4])) {
1329
+					$new_setting[] = $config_var[4];
1330
+		}
1282 1331
 
1283 1332
 		// Include min and max if necessary
1284
-		if (isset($config_var['min']))
1285
-			$new_setting['min'] = $config_var['min'];
1333
+		if (isset($config_var['min'])) {
1334
+					$new_setting['min'] = $config_var['min'];
1335
+		}
1286 1336
 
1287
-		if (isset($config_var['max']))
1288
-			$new_setting['max'] = $config_var['max'];
1337
+		if (isset($config_var['max'])) {
1338
+					$new_setting['max'] = $config_var['max'];
1339
+		}
1289 1340
 
1290 1341
 		// Rewrite the definition a bit.
1291 1342
 		$new_settings[] = $new_setting;
1292 1343
 	}
1293 1344
 
1294 1345
 	// Save the new database-based settings, if any.
1295
-	if (!empty($new_settings))
1296
-		saveDBSettings($new_settings);
1297
-}
1346
+	if (!empty($new_settings)) {
1347
+			saveDBSettings($new_settings);
1348
+	}
1349
+	}
1298 1350
 
1299 1351
 /**
1300 1352
  * Helper function for saving database settings.
@@ -1312,22 +1364,25 @@  discard block
 block discarded – undo
1312 1364
 	$inlinePermissions = array();
1313 1365
 	foreach ($config_vars as $var)
1314 1366
 	{
1315
-		if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags']))))
1316
-			continue;
1367
+		if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) {
1368
+					continue;
1369
+		}
1317 1370
 
1318 1371
 		// Checkboxes!
1319
-		elseif ($var[0] == 'check')
1320
-			$setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0';
1372
+		elseif ($var[0] == 'check') {
1373
+					$setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0';
1374
+		}
1321 1375
 		// Select boxes!
1322
-		elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2])))
1323
-			$setArray[$var[1]] = $_POST[$var[1]];
1324
-		elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array())
1376
+		elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) {
1377
+					$setArray[$var[1]] = $_POST[$var[1]];
1378
+		} elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array())
1325 1379
 		{
1326 1380
 			// For security purposes we validate this line by line.
1327 1381
 			$lOptions = array();
1328
-			foreach ($_POST[$var[1]] as $invar)
1329
-				if (in_array($invar, array_keys($var[2])))
1382
+			foreach ($_POST[$var[1]] as $invar) {
1383
+							if (in_array($invar, array_keys($var[2])))
1330 1384
 					$lOptions[] = $invar;
1385
+			}
1331 1386
 
1332 1387
 			$setArray[$var[1]] = $smcFunc['json_encode']($lOptions);
1333 1388
 		}
@@ -1341,18 +1396,20 @@  discard block
 block discarded – undo
1341 1396
 				$request = $smcFunc['db_query']('', '
1342 1397
 					SELECT id_board
1343 1398
 					FROM {db_prefix}boards');
1344
-				while ($row = $smcFunc['db_fetch_row']($request))
1345
-					$board_list[$row[0]] = true;
1399
+				while ($row = $smcFunc['db_fetch_row']($request)) {
1400
+									$board_list[$row[0]] = true;
1401
+				}
1346 1402
 
1347 1403
 				$smcFunc['db_free_result']($request);
1348 1404
 			}
1349 1405
 
1350 1406
 			$lOptions = array();
1351 1407
 
1352
-			if (!empty($_POST[$var[1]]))
1353
-				foreach ($_POST[$var[1]] as $invar => $dummy)
1408
+			if (!empty($_POST[$var[1]])) {
1409
+							foreach ($_POST[$var[1]] as $invar => $dummy)
1354 1410
 					if (isset($board_list[$invar]))
1355 1411
 						$lOptions[] = $invar;
1412
+			}
1356 1413
 
1357 1414
 			$setArray[$var[1]] = !empty($lOptions) ? implode(',', $lOptions) : '';
1358 1415
 		}
@@ -1366,8 +1423,9 @@  discard block
 block discarded – undo
1366 1423
 			$setArray[$var[1]] = max($min, $setArray[$var[1]]);
1367 1424
 
1368 1425
 			// Do we have a max value for this as well?
1369
-			if (isset($var['max']))
1370
-				$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1426
+			if (isset($var['max'])) {
1427
+							$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1428
+			}
1371 1429
 		}
1372 1430
 		// Floating point!
1373 1431
 		elseif ($var[0] == 'float')
@@ -1379,40 +1437,47 @@  discard block
 block discarded – undo
1379 1437
 			$setArray[$var[1]] = max($min, $setArray[$var[1]]);
1380 1438
 
1381 1439
 			// Do we have a max value for this as well?
1382
-			if (isset($var['max']))
1383
-				$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1440
+			if (isset($var['max'])) {
1441
+							$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1442
+			}
1384 1443
 		}
1385 1444
 		// Text!
1386
-		elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time')))
1387
-			$setArray[$var[1]] = $_POST[$var[1]];
1445
+		elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) {
1446
+					$setArray[$var[1]] = $_POST[$var[1]];
1447
+		}
1388 1448
 		// Passwords!
1389 1449
 		elseif ($var[0] == 'password')
1390 1450
 		{
1391
-			if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1])
1392
-				$setArray[$var[1]] = $_POST[$var[1]][0];
1451
+			if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) {
1452
+							$setArray[$var[1]] = $_POST[$var[1]][0];
1453
+			}
1393 1454
 		}
1394 1455
 		// BBC.
1395 1456
 		elseif ($var[0] == 'bbc')
1396 1457
 		{
1397 1458
 
1398 1459
 			$bbcTags = array();
1399
-			foreach (parse_bbc(false) as $tag)
1400
-				$bbcTags[] = $tag['tag'];
1460
+			foreach (parse_bbc(false) as $tag) {
1461
+							$bbcTags[] = $tag['tag'];
1462
+			}
1401 1463
 
1402
-			if (!isset($_POST[$var[1] . '_enabledTags']))
1403
-				$_POST[$var[1] . '_enabledTags'] = array();
1404
-			elseif (!is_array($_POST[$var[1] . '_enabledTags']))
1405
-				$_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']);
1464
+			if (!isset($_POST[$var[1] . '_enabledTags'])) {
1465
+							$_POST[$var[1] . '_enabledTags'] = array();
1466
+			} elseif (!is_array($_POST[$var[1] . '_enabledTags'])) {
1467
+							$_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']);
1468
+			}
1406 1469
 
1407 1470
 			$setArray[$var[1]] = implode(',', array_diff($bbcTags, $_POST[$var[1] . '_enabledTags']));
1408 1471
 		}
1409 1472
 		// Permissions?
1410
-		elseif ($var[0] == 'permissions')
1411
-			$inlinePermissions[] = $var[1];
1473
+		elseif ($var[0] == 'permissions') {
1474
+					$inlinePermissions[] = $var[1];
1475
+		}
1412 1476
 	}
1413 1477
 
1414
-	if (!empty($setArray))
1415
-		updateSettings($setArray);
1478
+	if (!empty($setArray)) {
1479
+			updateSettings($setArray);
1480
+	}
1416 1481
 
1417 1482
 	// If we have inline permissions we need to save them.
1418 1483
 	if (!empty($inlinePermissions) && allowedTo('manage_permissions'))
@@ -1449,18 +1514,21 @@  discard block
 block discarded – undo
1449 1514
 	// put all of it into an array
1450 1515
 	foreach ($info_lines as $line)
1451 1516
 	{
1452
-		if (preg_match('~(' . $remove . ')~', $line))
1453
-			continue;
1517
+		if (preg_match('~(' . $remove . ')~', $line)) {
1518
+					continue;
1519
+		}
1454 1520
 
1455 1521
 		// new category?
1456
-		if (strpos($line, '<h2>') !== false)
1457
-			$category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category;
1522
+		if (strpos($line, '<h2>') !== false) {
1523
+					$category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category;
1524
+		}
1458 1525
 
1459 1526
 		// load it as setting => value or the old setting local master
1460
-		if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val))
1461
-			$pinfo[$category][$val[1]] = $val[2];
1462
-		elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val))
1463
-			$pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]);
1527
+		if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) {
1528
+					$pinfo[$category][$val[1]] = $val[2];
1529
+		} elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) {
1530
+					$pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]);
1531
+		}
1464 1532
 	}
1465 1533
 
1466 1534
 	// load it in to context and display it
@@ -1495,8 +1563,9 @@  discard block
 block discarded – undo
1495 1563
 				$testAPI = new $cache_class_name();
1496 1564
 
1497 1565
 				// No Support?  NEXT!
1498
-				if (!$testAPI->isSupported(true))
1499
-					continue;
1566
+				if (!$testAPI->isSupported(true)) {
1567
+									continue;
1568
+				}
1500 1569
 
1501 1570
 				$apis[$tryCache] = isset($txt[$tryCache . '_cache']) ? $txt[$tryCache . '_cache'] : $tryCache;
1502 1571
 			}
@@ -1521,8 +1590,9 @@  discard block
 block discarded – undo
1521 1590
 	global $modSettings, $boardurl, $smcFunc;
1522 1591
 
1523 1592
 	// Already have a key?  Can't register again.
1524
-	if (!empty($modSettings['sm_stats_key']))
1525
-		return true;
1593
+	if (!empty($modSettings['sm_stats_key'])) {
1594
+			return true;
1595
+	}
1526 1596
 
1527 1597
 	$fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr);
1528 1598
 	if ($fp)
@@ -1533,8 +1603,9 @@  discard block
 block discarded – undo
1533 1603
 		fwrite($fp, $out);
1534 1604
 
1535 1605
 		$return_data = '';
1536
-		while (!feof($fp))
1537
-			$return_data .= fgets($fp, 128);
1606
+		while (!feof($fp)) {
1607
+					$return_data .= fgets($fp, 128);
1608
+		}
1538 1609
 
1539 1610
 		fclose($fp);
1540 1611
 
Please login to merge, or discard this patch.