Completed
Push — release-2.1 ( 15f485...0da2ef )
by Mathias
07:51
created
other/install.php 2 patches
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1619,8 +1619,7 @@
 block discarded – undo
1619 1619
 	updateStats('topic');
1620 1620
 
1621 1621
 	// This function is needed to do the updateStats('subject') call.
1622
-	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1623
-		function($string){
1622
+	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) {
1624 1623
 			global $sourcedir;
1625 1624
 			if (function_exists('mb_strtolower'))
1626 1625
 				return mb_strtolower($string, 'UTF-8');
Please login to merge, or discard this patch.
Braces   +438 added lines, -326 removed lines patch added patch discarded remove patch
@@ -20,8 +20,9 @@  discard block
 block discarded – undo
20 20
 // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;">
21 21
 
22 22
 // Let's pull in useful classes
23
-if (!defined('SMF'))
23
+if (!defined('SMF')) {
24 24
 	define('SMF', 1);
25
+}
25 26
 
26 27
 require_once('Sources/Class-Package.php');
27 28
 
@@ -63,10 +64,11 @@  discard block
 block discarded – undo
63 64
 			
64 65
 			list ($charcode) = pg_fetch_row($request);
65 66
 			
66
-			if ($charcode == 'UTF8')			
67
-				return true;
68
-			else
69
-				return false;
67
+			if ($charcode == 'UTF8') {
68
+							return true;
69
+			} else {
70
+							return false;
71
+			}
70 72
 		},
71 73
 		'utf8_version' => '8.0',
72 74
 		'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;',
@@ -74,12 +76,14 @@  discard block
 block discarded – undo
74 76
 			$value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value);
75 77
 
76 78
 			// Is it reserved?
77
-			if ($value == 'pg_')
78
-				return $txt['error_db_prefix_reserved'];
79
+			if ($value == 'pg_') {
80
+							return $txt['error_db_prefix_reserved'];
81
+			}
79 82
 
80 83
 			// Is the prefix numeric?
81
-			if (preg_match('~^\d~', $value))
82
-				return $txt['error_db_prefix_numeric'];
84
+			if (preg_match('~^\d~', $value)) {
85
+							return $txt['error_db_prefix_numeric'];
86
+			}
83 87
 
84 88
 			return true;
85 89
 		},
@@ -124,10 +128,11 @@  discard block
 block discarded – undo
124 128
 		$incontext['skip'] = false;
125 129
 
126 130
 		// Call the step and if it returns false that means pause!
127
-		if (function_exists($step[2]) && $step[2]() === false)
128
-			break;
129
-		elseif (function_exists($step[2]))
130
-			$incontext['current_step']++;
131
+		if (function_exists($step[2]) && $step[2]() === false) {
132
+					break;
133
+		} elseif (function_exists($step[2])) {
134
+					$incontext['current_step']++;
135
+		}
131 136
 
132 137
 		// No warnings pass on.
133 138
 		$incontext['warning'] = '';
@@ -143,12 +148,14 @@  discard block
 block discarded – undo
143 148
 	global $databases, $incontext;
144 149
 
145 150
 	// Just so people using older versions of PHP aren't left in the cold.
146
-	if (!isset($_SERVER['PHP_SELF']))
147
-		$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
151
+	if (!isset($_SERVER['PHP_SELF'])) {
152
+			$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
153
+	}
148 154
 
149 155
 	// Turn off magic quotes runtime and enable error reporting.
150
-	if (function_exists('set_magic_quotes_runtime'))
151
-		@set_magic_quotes_runtime(0);
156
+	if (function_exists('set_magic_quotes_runtime')) {
157
+			@set_magic_quotes_runtime(0);
158
+	}
152 159
 	error_reporting(E_ALL);
153 160
 
154 161
 	// Fun.  Low PHP version...
@@ -162,21 +169,23 @@  discard block
 block discarded – undo
162 169
 	{
163 170
 		ob_start();
164 171
 
165
-		if (ini_get('session.save_handler') == 'user')
166
-			@ini_set('session.save_handler', 'files');
167
-		if (function_exists('session_start'))
168
-			@session_start();
169
-	}
170
-	else
172
+		if (ini_get('session.save_handler') == 'user') {
173
+					@ini_set('session.save_handler', 'files');
174
+		}
175
+		if (function_exists('session_start')) {
176
+					@session_start();
177
+		}
178
+	} else
171 179
 	{
172 180
 		ob_start('ob_gzhandler');
173 181
 
174
-		if (ini_get('session.save_handler') == 'user')
175
-			@ini_set('session.save_handler', 'files');
182
+		if (ini_get('session.save_handler') == 'user') {
183
+					@ini_set('session.save_handler', 'files');
184
+		}
176 185
 		session_start();
177 186
 
178
-		if (!headers_sent())
179
-			echo '<!DOCTYPE html>
187
+		if (!headers_sent()) {
188
+					echo '<!DOCTYPE html>
180 189
 <html>
181 190
 	<head>
182 191
 		<title>', htmlspecialchars($_GET['pass_string']), '</title>
@@ -185,14 +194,16 @@  discard block
 block discarded – undo
185 194
 		<strong>', htmlspecialchars($_GET['pass_string']), '</strong>
186 195
 	</body>
187 196
 </html>';
197
+		}
188 198
 		exit;
189 199
 	}
190 200
 
191 201
 	// Add slashes, as long as they aren't already being added.
192
-	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0)
193
-		foreach ($_POST as $k => $v)
202
+	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) {
203
+			foreach ($_POST as $k => $v)
194 204
 			if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false)
195 205
 				$_POST[$k] = addslashes($v);
206
+	}
196 207
 
197 208
 	// This is really quite simple; if ?delete is on the URL, delete the installer...
198 209
 	if (isset($_GET['delete']))
@@ -213,8 +224,7 @@  discard block
 block discarded – undo
213 224
 			$ftp->close();
214 225
 
215 226
 			unset($_SESSION['installer_temp_ftp']);
216
-		}
217
-		else
227
+		} else
218 228
 		{
219 229
 			@unlink(__FILE__);
220 230
 
@@ -235,10 +245,11 @@  discard block
 block discarded – undo
235 245
 	{
236 246
 		// Get PHP's default timezone, if set
237 247
 		$ini_tz = ini_get('date.timezone');
238
-		if (!empty($ini_tz))
239
-			$timezone_id = $ini_tz;
240
-		else
241
-			$timezone_id = '';
248
+		if (!empty($ini_tz)) {
249
+					$timezone_id = $ini_tz;
250
+		} else {
251
+					$timezone_id = '';
252
+		}
242 253
 
243 254
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
244 255
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -268,8 +279,9 @@  discard block
 block discarded – undo
268 279
 		$dir = dir(dirname(__FILE__) . '/Themes/default/languages');
269 280
 		while ($entry = $dir->read())
270 281
 		{
271
-			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php')
272
-				$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
282
+			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') {
283
+							$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
284
+			}
273 285
 		}
274 286
 		$dir->close();
275 287
 	}
@@ -304,10 +316,11 @@  discard block
 block discarded – undo
304 316
 	}
305 317
 
306 318
 	// Override the language file?
307
-	if (isset($_GET['lang_file']))
308
-		$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
309
-	elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file']))
310
-		$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
319
+	if (isset($_GET['lang_file'])) {
320
+			$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
321
+	} elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) {
322
+			$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
323
+	}
311 324
 
312 325
 	// Make sure it exists, if it doesn't reset it.
313 326
 	if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang']))
@@ -316,8 +329,9 @@  discard block
 block discarded – undo
316 329
 		list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
317 330
 
318 331
 		// If we have english and some other language, use the other language.  We Americans hate english :P.
319
-		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1)
320
-			list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
332
+		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) {
333
+					list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
334
+		}
321 335
 	}
322 336
 
323 337
 	// And now include the actual language file itself.
@@ -330,15 +344,18 @@  discard block
 block discarded – undo
330 344
 	global $db_prefix, $db_connection, $sourcedir;
331 345
 	global $smcFunc, $modSettings, $db_type, $db_name, $db_user, $db_persist;
332 346
 
333
-	if (empty($sourcedir))
334
-		$sourcedir = dirname(__FILE__) . '/Sources';
347
+	if (empty($sourcedir)) {
348
+			$sourcedir = dirname(__FILE__) . '/Sources';
349
+	}
335 350
 
336 351
 	// Need this to check whether we need the database password.
337 352
 	require(dirname(__FILE__) . '/Settings.php');
338
-	if (!defined('SMF'))
339
-		define('SMF', 1);
340
-	if (empty($smcFunc))
341
-		$smcFunc = array();
353
+	if (!defined('SMF')) {
354
+			define('SMF', 1);
355
+	}
356
+	if (empty($smcFunc)) {
357
+			$smcFunc = array();
358
+	}
342 359
 
343 360
 	$modSettings['disableQueryCheck'] = true;
344 361
 
@@ -346,8 +363,9 @@  discard block
 block discarded – undo
346 363
 	if (!$db_connection)
347 364
 	{
348 365
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
349
-		if (version_compare(PHP_VERSION, '5', '<'))
350
-			require_once($sourcedir . '/Subs-Compat.php');
366
+		if (version_compare(PHP_VERSION, '5', '<')) {
367
+					require_once($sourcedir . '/Subs-Compat.php');
368
+		}
351 369
 
352 370
 		$db_options = array('persist' => $db_persist);
353 371
 		$port = '';
@@ -358,19 +376,20 @@  discard block
 block discarded – undo
358 376
 			if ($db_type == 'mysql')
359 377
 			{
360 378
 				$port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port'];
361
-			}
362
-			elseif ($db_type == 'postgresql')
379
+			} elseif ($db_type == 'postgresql')
363 380
 			{
364 381
 				// PostgreSQL doesn't have a default port setting in php.ini, so just check against the default
365 382
 				$port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port'];
366 383
 			}
367 384
 		}
368 385
 
369
-		if (!empty($port))
370
-			$db_options['port'] = $port;
386
+		if (!empty($port)) {
387
+					$db_options['port'] = $port;
388
+		}
371 389
 
372
-		if (!$db_connection)
373
-			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options);
390
+		if (!$db_connection) {
391
+					$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options);
392
+		}
374 393
 	}
375 394
 }
376 395
 
@@ -398,8 +417,9 @@  discard block
 block discarded – undo
398 417
 		// @todo REMOVE THIS!!
399 418
 		else
400 419
 		{
401
-			if (function_exists('doStep' . $_GET['step']))
402
-				call_user_func('doStep' . $_GET['step']);
420
+			if (function_exists('doStep' . $_GET['step'])) {
421
+							call_user_func('doStep' . $_GET['step']);
422
+			}
403 423
 		}
404 424
 		// Show the footer.
405 425
 		template_install_below();
@@ -417,8 +437,9 @@  discard block
 block discarded – undo
417 437
 	$incontext['sub_template'] = 'welcome_message';
418 438
 
419 439
 	// Done the submission?
420
-	if (isset($_POST['contbutt']))
421
-		return true;
440
+	if (isset($_POST['contbutt'])) {
441
+			return true;
442
+	}
422 443
 
423 444
 	// See if we think they have already installed it?
424 445
 	if (is_readable(dirname(__FILE__) . '/Settings.php'))
@@ -426,14 +447,17 @@  discard block
 block discarded – undo
426 447
 		$probably_installed = 0;
427 448
 		foreach (file(dirname(__FILE__) . '/Settings.php') as $line)
428 449
 		{
429
-			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line))
430
-				$probably_installed++;
431
-			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line))
432
-				$probably_installed++;
450
+			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) {
451
+							$probably_installed++;
452
+			}
453
+			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) {
454
+							$probably_installed++;
455
+			}
433 456
 		}
434 457
 
435
-		if ($probably_installed == 2)
436
-			$incontext['warning'] = $txt['error_already_installed'];
458
+		if ($probably_installed == 2) {
459
+					$incontext['warning'] = $txt['error_already_installed'];
460
+		}
437 461
 	}
438 462
 
439 463
 	// Is some database support even compiled in?
@@ -448,36 +472,43 @@  discard block
 block discarded – undo
448 472
 				$databases[$key]['supported'] = false;
449 473
 				$notFoundSQLFile = true;
450 474
 				$txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql');
475
+			} else {
476
+							$incontext['supported_databases'][] = $db;
451 477
 			}
452
-			else
453
-				$incontext['supported_databases'][] = $db;
454 478
 		}
455 479
 	}
456 480
 
457 481
 	// Check the PHP version.
458
-	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>')))
459
-		$error = 'error_php_too_low';
482
+	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>'))) {
483
+			$error = 'error_php_too_low';
484
+	}
460 485
 	// Make sure we have a supported database
461
-	elseif (empty($incontext['supported_databases']))
462
-		$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
486
+	elseif (empty($incontext['supported_databases'])) {
487
+			$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
488
+	}
463 489
 	// How about session support?  Some crazy sysadmin remove it?
464
-	elseif (!function_exists('session_start'))
465
-		$error = 'error_session_missing';
490
+	elseif (!function_exists('session_start')) {
491
+			$error = 'error_session_missing';
492
+	}
466 493
 	// Make sure they uploaded all the files.
467
-	elseif (!file_exists(dirname(__FILE__) . '/index.php'))
468
-		$error = 'error_missing_files';
494
+	elseif (!file_exists(dirname(__FILE__) . '/index.php')) {
495
+			$error = 'error_missing_files';
496
+	}
469 497
 	// Very simple check on the session.save_path for Windows.
470 498
 	// @todo Move this down later if they don't use database-driven sessions?
471
-	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\')
472
-		$error = 'error_session_save_path';
499
+	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') {
500
+			$error = 'error_session_save_path';
501
+	}
473 502
 
474 503
 	// Since each of the three messages would look the same, anyway...
475
-	if (isset($error))
476
-		$incontext['error'] = $txt[$error];
504
+	if (isset($error)) {
505
+			$incontext['error'] = $txt[$error];
506
+	}
477 507
 
478 508
 	// Mod_security blocks everything that smells funny. Let SMF handle security.
479
-	if (!fixModSecurity() && !isset($_GET['overmodsecurity']))
480
-		$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
509
+	if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) {
510
+			$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
511
+	}
481 512
 
482 513
 	return false;
483 514
 }
@@ -503,12 +534,14 @@  discard block
 block discarded – undo
503 534
 		'db_last_error.php',
504 535
 	);
505 536
 
506
-	foreach ($incontext['detected_languages'] as $lang => $temp)
507
-		$extra_files[] = 'Themes/default/languages/' . $lang;
537
+	foreach ($incontext['detected_languages'] as $lang => $temp) {
538
+			$extra_files[] = 'Themes/default/languages/' . $lang;
539
+	}
508 540
 
509 541
 	// With mod_security installed, we could attempt to fix it with .htaccess.
510
-	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules()))
511
-		$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
542
+	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) {
543
+			$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
544
+	}
512 545
 
513 546
 	$failed_files = array();
514 547
 
@@ -524,12 +557,14 @@  discard block
 block discarded – undo
524 557
 				@chmod(dirname(__FILE__) . '/' . $file, 0755);
525 558
 
526 559
 				// Well, 755 hopefully worked... if not, try 777.
527
-				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777))
528
-					$failed_files[] = $file;
560
+				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) {
561
+									$failed_files[] = $file;
562
+				}
529 563
 			}
530 564
 		}
531
-		foreach ($extra_files as $file)
532
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
565
+		foreach ($extra_files as $file) {
566
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
567
+		}
533 568
 	}
534 569
 	// Windows is trickier.  Let's try opening for r+...
535 570
 	else
@@ -539,30 +574,35 @@  discard block
 block discarded – undo
539 574
 		foreach ($writable_files as $file)
540 575
 		{
541 576
 			// Folders can't be opened for write... but the index.php in them can ;)
542
-			if (is_dir(dirname(__FILE__) . '/' . $file))
543
-				$file .= '/index.php';
577
+			if (is_dir(dirname(__FILE__) . '/' . $file)) {
578
+							$file .= '/index.php';
579
+			}
544 580
 
545 581
 			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
546 582
 			@chmod(dirname(__FILE__) . '/' . $file, 0777);
547 583
 			$fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+');
548 584
 
549 585
 			// Hmm, okay, try just for write in that case...
550
-			if (!is_resource($fp))
551
-				$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
586
+			if (!is_resource($fp)) {
587
+							$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
588
+			}
552 589
 
553
-			if (!is_resource($fp))
554
-				$failed_files[] = $file;
590
+			if (!is_resource($fp)) {
591
+							$failed_files[] = $file;
592
+			}
555 593
 
556 594
 			@fclose($fp);
557 595
 		}
558
-		foreach ($extra_files as $file)
559
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
596
+		foreach ($extra_files as $file) {
597
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
598
+		}
560 599
 	}
561 600
 
562 601
 	$failure = count($failed_files) >= 1;
563 602
 
564
-	if (!isset($_SERVER))
565
-		return !$failure;
603
+	if (!isset($_SERVER)) {
604
+			return !$failure;
605
+	}
566 606
 
567 607
 	// Put the list into context.
568 608
 	$incontext['failed_files'] = $failed_files;
@@ -610,19 +650,23 @@  discard block
 block discarded – undo
610 650
 
611 651
 		if (!isset($ftp) || $ftp->error !== false)
612 652
 		{
613
-			if (!isset($ftp))
614
-				$ftp = new ftp_connection(null);
653
+			if (!isset($ftp)) {
654
+							$ftp = new ftp_connection(null);
655
+			}
615 656
 			// Save the error so we can mess with listing...
616
-			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message))
617
-				$incontext['ftp_errors'][] = $ftp->last_message;
657
+			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) {
658
+							$incontext['ftp_errors'][] = $ftp->last_message;
659
+			}
618 660
 
619 661
 			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
620 662
 
621
-			if (empty($_POST['ftp_path']) && $found_path)
622
-				$_POST['ftp_path'] = $detect_path;
663
+			if (empty($_POST['ftp_path']) && $found_path) {
664
+							$_POST['ftp_path'] = $detect_path;
665
+			}
623 666
 
624
-			if (!isset($_POST['ftp_username']))
625
-				$_POST['ftp_username'] = $username;
667
+			if (!isset($_POST['ftp_username'])) {
668
+							$_POST['ftp_username'] = $username;
669
+			}
626 670
 
627 671
 			// Set the username etc, into context.
628 672
 			$incontext['ftp'] = array(
@@ -634,8 +678,7 @@  discard block
 block discarded – undo
634 678
 			);
635 679
 
636 680
 			return false;
637
-		}
638
-		else
681
+		} else
639 682
 		{
640 683
 			$_SESSION['installer_temp_ftp'] = array(
641 684
 				'server' => $_POST['ftp_server'],
@@ -649,10 +692,12 @@  discard block
 block discarded – undo
649 692
 
650 693
 			foreach ($failed_files as $file)
651 694
 			{
652
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
653
-					$ftp->chmod($file, 0755);
654
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
655
-					$ftp->chmod($file, 0777);
695
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
696
+									$ftp->chmod($file, 0755);
697
+				}
698
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
699
+									$ftp->chmod($file, 0777);
700
+				}
656 701
 				if (!is_writable(dirname(__FILE__) . '/' . $file))
657 702
 				{
658 703
 					$failed_files_updated[] = $file;
@@ -707,15 +752,17 @@  discard block
 block discarded – undo
707 752
 
708 753
 			if (!$foundOne)
709 754
 			{
710
-				if (isset($db['default_host']))
711
-					$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
755
+				if (isset($db['default_host'])) {
756
+									$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
757
+				}
712 758
 				if (isset($db['default_user']))
713 759
 				{
714 760
 					$incontext['db']['user'] = ini_get($db['default_user']);
715 761
 					$incontext['db']['name'] = ini_get($db['default_user']);
716 762
 				}
717
-				if (isset($db['default_password']))
718
-					$incontext['db']['pass'] = ini_get($db['default_password']);
763
+				if (isset($db['default_password'])) {
764
+									$incontext['db']['pass'] = ini_get($db['default_password']);
765
+				}
719 766
 
720 767
 				// For simplicity and less confusion, leave the port blank by default
721 768
 				$incontext['db']['port'] = '';
@@ -734,10 +781,10 @@  discard block
 block discarded – undo
734 781
 		$incontext['db']['server'] = $_POST['db_server'];
735 782
 		$incontext['db']['prefix'] = $_POST['db_prefix'];
736 783
 
737
-		if (!empty($_POST['db_port']))
738
-			$incontext['db']['port'] = $_POST['db_port'];
739
-	}
740
-	else
784
+		if (!empty($_POST['db_port'])) {
785
+					$incontext['db']['port'] = $_POST['db_port'];
786
+		}
787
+	} else
741 788
 	{
742 789
 		$incontext['db']['prefix'] = 'smf_';
743 790
 	}
@@ -773,10 +820,11 @@  discard block
 block discarded – undo
773 820
 		if (!empty($_POST['db_port']))
774 821
 		{
775 822
 			// For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though.
776
-			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port'))
777
-				$vars['db_port'] = (int) $_POST['db_port'];
778
-			elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432)
779
-				$vars['db_port'] = (int) $_POST['db_port'];
823
+			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) {
824
+							$vars['db_port'] = (int) $_POST['db_port'];
825
+			} elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) {
826
+							$vars['db_port'] = (int) $_POST['db_port'];
827
+			}
780 828
 		}
781 829
 
782 830
 		// God I hope it saved!
@@ -789,8 +837,9 @@  discard block
 block discarded – undo
789 837
 		// Make sure it works.
790 838
 		require(dirname(__FILE__) . '/Settings.php');
791 839
 
792
-		if (empty($sourcedir))
793
-			$sourcedir = dirname(__FILE__) . '/Sources';
840
+		if (empty($sourcedir)) {
841
+					$sourcedir = dirname(__FILE__) . '/Sources';
842
+		}
794 843
 
795 844
 		// Better find the database file!
796 845
 		if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
@@ -800,18 +849,21 @@  discard block
 block discarded – undo
800 849
 		}
801 850
 
802 851
 		// Now include it for database functions!
803
-		if (!defined('SMF'))
804
-			define('SMF', 1);
852
+		if (!defined('SMF')) {
853
+					define('SMF', 1);
854
+		}
805 855
 
806 856
 		$modSettings['disableQueryCheck'] = true;
807
-		if (empty($smcFunc))
808
-			$smcFunc = array();
857
+		if (empty($smcFunc)) {
858
+					$smcFunc = array();
859
+		}
809 860
 
810 861
 			require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
811 862
 
812 863
 		// What - running PHP4? The shame!
813
-		if (version_compare(PHP_VERSION, '5', '<'))
814
-			require_once($sourcedir . '/Subs-Compat.php');
864
+		if (version_compare(PHP_VERSION, '5', '<')) {
865
+					require_once($sourcedir . '/Subs-Compat.php');
866
+		}
815 867
 
816 868
 		// Attempt a connection.
817 869
 		$needsDB = !empty($databases[$db_type]['always_has_db']);
@@ -899,12 +951,14 @@  discard block
 block discarded – undo
899 951
 	$incontext['page_title'] = $txt['install_settings'];
900 952
 
901 953
 	// Let's see if we got the database type correct.
902
-	if (isset($_POST['db_type'], $databases[$_POST['db_type']]))
903
-		$db_type = $_POST['db_type'];
954
+	if (isset($_POST['db_type'], $databases[$_POST['db_type']])) {
955
+			$db_type = $_POST['db_type'];
956
+	}
904 957
 
905 958
 	// Else we'd better be able to get the connection.
906
-	else
907
-		load_database();
959
+	else {
960
+			load_database();
961
+	}
908 962
 
909 963
 	$db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type;
910 964
 
@@ -924,12 +978,14 @@  discard block
 block discarded – undo
924 978
 	// Submitting?
925 979
 	if (isset($_POST['boardurl']))
926 980
 	{
927
-		if (substr($_POST['boardurl'], -10) == '/index.php')
928
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
929
-		elseif (substr($_POST['boardurl'], -1) == '/')
930
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
931
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
932
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
981
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
982
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
983
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
984
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
985
+		}
986
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
987
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
988
+		}
933 989
 
934 990
 		// Save these variables.
935 991
 		$vars = array(
@@ -966,10 +1022,10 @@  discard block
 block discarded – undo
966 1022
 			{
967 1023
 				$incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']);
968 1024
 				return false;
969
-			}
970
-			else
971
-				// Set the character set here.
1025
+			} else {
1026
+							// Set the character set here.
972 1027
 				updateSettingsFile(array('db_character_set' => 'utf8'));
1028
+			}
973 1029
 		}
974 1030
 
975 1031
 		// Good, skip on.
@@ -989,8 +1045,9 @@  discard block
 block discarded – undo
989 1045
 	$incontext['continue'] = 1;
990 1046
 
991 1047
 	// Already done?
992
-	if (isset($_POST['pop_done']))
993
-		return true;
1048
+	if (isset($_POST['pop_done'])) {
1049
+			return true;
1050
+	}
994 1051
 
995 1052
 	// Reload settings.
996 1053
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1008,8 +1065,9 @@  discard block
 block discarded – undo
1008 1065
 	$modSettings = array();
1009 1066
 	if ($result !== false)
1010 1067
 	{
1011
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1012
-			$modSettings[$row['variable']] = $row['value'];
1068
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1069
+					$modSettings[$row['variable']] = $row['value'];
1070
+		}
1013 1071
 		$smcFunc['db_free_result']($result);
1014 1072
 
1015 1073
 		// Do they match?  If so, this is just a refresh so charge on!
@@ -1022,20 +1080,22 @@  discard block
 block discarded – undo
1022 1080
 	$modSettings['disableQueryCheck'] = true;
1023 1081
 
1024 1082
 	// If doing UTF8, select it. PostgreSQL requires passing it as a string...
1025
-	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support']))
1026
-		$smcFunc['db_query']('', '
1083
+	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) {
1084
+			$smcFunc['db_query']('', '
1027 1085
 			SET NAMES {string:utf8}',
1028 1086
 			array(
1029 1087
 				'db_error_skip' => true,
1030 1088
 				'utf8' => 'utf8',
1031 1089
 			)
1032 1090
 		);
1091
+	}
1033 1092
 
1034 1093
 	// Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments...
1035
-	if (substr(__DIR__, -1) == '\\')
1036
-		$attachdir = __DIR__ . 'attachments';
1037
-	else
1038
-		$attachdir = __DIR__ . '/attachments';
1094
+	if (substr(__DIR__, -1) == '\\') {
1095
+			$attachdir = __DIR__ . 'attachments';
1096
+	} else {
1097
+			$attachdir = __DIR__ . '/attachments';
1098
+	}
1039 1099
 
1040 1100
 	$replaces = array(
1041 1101
 		'{$db_prefix}' => $db_prefix,
@@ -1052,8 +1112,9 @@  discard block
 block discarded – undo
1052 1112
 
1053 1113
 	foreach ($txt as $key => $value)
1054 1114
 	{
1055
-		if (substr($key, 0, 8) == 'default_')
1056
-			$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1115
+		if (substr($key, 0, 8) == 'default_') {
1116
+					$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1117
+		}
1057 1118
 	}
1058 1119
 	$replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n'));
1059 1120
 
@@ -1068,8 +1129,9 @@  discard block
 block discarded – undo
1068 1129
 
1069 1130
 		while ($row = $smcFunc['db_fetch_assoc']($get_engines))
1070 1131
 		{
1071
-			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT')
1072
-				$engines[] = $row['Engine'];
1132
+			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') {
1133
+							$engines[] = $row['Engine'];
1134
+			}
1073 1135
 		}
1074 1136
 
1075 1137
 		// Done with this now
@@ -1093,8 +1155,7 @@  discard block
 block discarded – undo
1093 1155
 			$replaces['START TRANSACTION;'] = '';
1094 1156
 			$replaces['COMMIT;'] = '';
1095 1157
 		}
1096
-	}
1097
-	else
1158
+	} else
1098 1159
 	{
1099 1160
 		$has_innodb = false;
1100 1161
 	}
@@ -1116,21 +1177,24 @@  discard block
 block discarded – undo
1116 1177
 	foreach ($sql_lines as $count => $line)
1117 1178
 	{
1118 1179
 		// No comments allowed!
1119
-		if (substr(trim($line), 0, 1) != '#')
1120
-			$current_statement .= "\n" . rtrim($line);
1180
+		if (substr(trim($line), 0, 1) != '#') {
1181
+					$current_statement .= "\n" . rtrim($line);
1182
+		}
1121 1183
 
1122 1184
 		// Is this the end of the query string?
1123
-		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines)))
1124
-			continue;
1185
+		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) {
1186
+					continue;
1187
+		}
1125 1188
 
1126 1189
 		// Does this table already exist?  If so, don't insert more data into it!
1127 1190
 		if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists))
1128 1191
 		{
1129 1192
 			preg_match_all('~\)[,;]~', $current_statement, $matches);
1130
-			if (!empty($matches[0]))
1131
-				$incontext['sql_results']['insert_dups'] += count($matches[0]);
1132
-			else
1133
-				$incontext['sql_results']['insert_dups']++;
1193
+			if (!empty($matches[0])) {
1194
+							$incontext['sql_results']['insert_dups'] += count($matches[0]);
1195
+			} else {
1196
+							$incontext['sql_results']['insert_dups']++;
1197
+			}
1134 1198
 
1135 1199
 			$current_statement = '';
1136 1200
 			continue;
@@ -1139,8 +1203,9 @@  discard block
 block discarded – undo
1139 1203
 		if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false)
1140 1204
 		{
1141 1205
 			// Use the appropriate function based on the DB type
1142
-			if ($db_type == 'mysql' || $db_type == 'mysqli')
1143
-				$db_errorno = $db_type . '_errno';
1206
+			if ($db_type == 'mysql' || $db_type == 'mysqli') {
1207
+							$db_errorno = $db_type . '_errno';
1208
+			}
1144 1209
 
1145 1210
 			// Error 1050: Table already exists!
1146 1211
 			// @todo Needs to be made better!
@@ -1155,18 +1220,18 @@  discard block
 block discarded – undo
1155 1220
 				// MySQLi requires a connection object. It's optional with MySQL and Postgres
1156 1221
 				$incontext['failures'][$count] = $smcFunc['db_error']($db_connection);
1157 1222
 			}
1158
-		}
1159
-		else
1223
+		} else
1160 1224
 		{
1161
-			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1162
-				$incontext['sql_results']['tables']++;
1163
-			elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1225
+			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) {
1226
+							$incontext['sql_results']['tables']++;
1227
+			} elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1164 1228
 			{
1165 1229
 				preg_match_all('~\)[,;]~', $current_statement, $matches);
1166
-				if (!empty($matches[0]))
1167
-					$incontext['sql_results']['inserts'] += count($matches[0]);
1168
-				else
1169
-					$incontext['sql_results']['inserts']++;
1230
+				if (!empty($matches[0])) {
1231
+									$incontext['sql_results']['inserts'] += count($matches[0]);
1232
+				} else {
1233
+									$incontext['sql_results']['inserts']++;
1234
+				}
1170 1235
 			}
1171 1236
 		}
1172 1237
 
@@ -1179,15 +1244,17 @@  discard block
 block discarded – undo
1179 1244
 	// Sort out the context for the SQL.
1180 1245
 	foreach ($incontext['sql_results'] as $key => $number)
1181 1246
 	{
1182
-		if ($number == 0)
1183
-			unset($incontext['sql_results'][$key]);
1184
-		else
1185
-			$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1247
+		if ($number == 0) {
1248
+					unset($incontext['sql_results'][$key]);
1249
+		} else {
1250
+					$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1251
+		}
1186 1252
 	}
1187 1253
 
1188 1254
 	// Make sure UTF will be used globally.
1189
-	if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8'])))
1190
-		$newSettings[] = array('global_character_set', 'UTF-8');
1255
+	if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) {
1256
+			$newSettings[] = array('global_character_set', 'UTF-8');
1257
+	}
1191 1258
 
1192 1259
 	// Maybe we can auto-detect better cookie settings?
1193 1260
 	preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches);
@@ -1198,16 +1265,20 @@  discard block
 block discarded – undo
1198 1265
 		$globalCookies = false;
1199 1266
 
1200 1267
 		// Okay... let's see.  Using a subdomain other than www.? (not a perfect check.)
1201
-		if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www'))))
1202
-			$globalCookies = true;
1268
+		if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) {
1269
+					$globalCookies = true;
1270
+		}
1203 1271
 		// If there's a / in the middle of the path, or it starts with ~... we want local.
1204
-		if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false))
1205
-			$localCookies = true;
1272
+		if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) {
1273
+					$localCookies = true;
1274
+		}
1206 1275
 
1207
-		if ($globalCookies)
1208
-			$newSettings[] = array('globalCookies', '1');
1209
-		if ($localCookies)
1210
-			$newSettings[] = array('localCookies', '1');
1276
+		if ($globalCookies) {
1277
+					$newSettings[] = array('globalCookies', '1');
1278
+		}
1279
+		if ($localCookies) {
1280
+					$newSettings[] = array('localCookies', '1');
1281
+		}
1211 1282
 	}
1212 1283
 
1213 1284
 	// Are we allowing stat collection?
@@ -1223,32 +1294,36 @@  discard block
 block discarded – undo
1223 1294
 			fwrite($fp, $out);
1224 1295
 
1225 1296
 			$return_data = '';
1226
-			while (!feof($fp))
1227
-				$return_data .= fgets($fp, 128);
1297
+			while (!feof($fp)) {
1298
+							$return_data .= fgets($fp, 128);
1299
+			}
1228 1300
 
1229 1301
 			fclose($fp);
1230 1302
 
1231 1303
 			// Get the unique site ID.
1232 1304
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1233 1305
 
1234
-			if (!empty($ID[1]))
1235
-				$newSettings[] = array('allow_sm_stats', $ID[1]);
1306
+			if (!empty($ID[1])) {
1307
+							$newSettings[] = array('allow_sm_stats', $ID[1]);
1308
+			}
1236 1309
 		}
1237 1310
 	}
1238 1311
 
1239 1312
 	// Are we enabling SSL?
1240
-	if (!empty($_POST['force_ssl']))
1241
-		$newSettings[] = array('force_ssl', 2);
1313
+	if (!empty($_POST['force_ssl'])) {
1314
+			$newSettings[] = array('force_ssl', 2);
1315
+	}
1242 1316
 
1243 1317
 	// Setting a timezone is required.
1244 1318
 	if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set'))
1245 1319
 	{
1246 1320
 		// Get PHP's default timezone, if set
1247 1321
 		$ini_tz = ini_get('date.timezone');
1248
-		if (!empty($ini_tz))
1249
-			$timezone_id = $ini_tz;
1250
-		else
1251
-			$timezone_id = '';
1322
+		if (!empty($ini_tz)) {
1323
+					$timezone_id = $ini_tz;
1324
+		} else {
1325
+					$timezone_id = '';
1326
+		}
1252 1327
 
1253 1328
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
1254 1329
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -1257,8 +1332,9 @@  discard block
 block discarded – undo
1257 1332
 			$timezone_id = timezone_name_from_abbr('', $server_offset, 0);
1258 1333
 		}
1259 1334
 
1260
-		if (date_default_timezone_set($timezone_id))
1261
-			$newSettings[] = array('default_timezone', $timezone_id);
1335
+		if (date_default_timezone_set($timezone_id)) {
1336
+					$newSettings[] = array('default_timezone', $timezone_id);
1337
+		}
1262 1338
 	}
1263 1339
 
1264 1340
 	if (!empty($newSettings))
@@ -1289,16 +1365,18 @@  discard block
 block discarded – undo
1289 1365
 	}
1290 1366
 
1291 1367
 	// MySQL specific stuff
1292
-	if (substr($db_type, 0, 5) != 'mysql')
1293
-		return false;
1368
+	if (substr($db_type, 0, 5) != 'mysql') {
1369
+			return false;
1370
+	}
1294 1371
 
1295 1372
 	// Find database user privileges.
1296 1373
 	$privs = array();
1297 1374
 	$get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array());
1298 1375
 	while ($row = $smcFunc['db_fetch_assoc']($get_privs))
1299 1376
 	{
1300
-		if ($row['Privilege'] == 'Alter')
1301
-			$privs[] = $row['Privilege'];
1377
+		if ($row['Privilege'] == 'Alter') {
1378
+					$privs[] = $row['Privilege'];
1379
+		}
1302 1380
 	}
1303 1381
 	$smcFunc['db_free_result']($get_privs);
1304 1382
 
@@ -1328,8 +1406,9 @@  discard block
 block discarded – undo
1328 1406
 	$incontext['continue'] = 1;
1329 1407
 
1330 1408
 	// Skipping?
1331
-	if (!empty($_POST['skip']))
1332
-		return true;
1409
+	if (!empty($_POST['skip'])) {
1410
+			return true;
1411
+	}
1333 1412
 
1334 1413
 	// Need this to check whether we need the database password.
1335 1414
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1342,18 +1421,22 @@  discard block
 block discarded – undo
1342 1421
 	// We need this to properly hash the password for Admin
1343 1422
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) {
1344 1423
 			global $sourcedir;
1345
-			if (function_exists('mb_strtolower'))
1346
-				return mb_strtolower($string, 'UTF-8');
1424
+			if (function_exists('mb_strtolower')) {
1425
+							return mb_strtolower($string, 'UTF-8');
1426
+			}
1347 1427
 			require_once($sourcedir . '/Subs-Charset.php');
1348 1428
 			return utf8_strtolower($string);
1349 1429
 		};
1350 1430
 
1351
-	if (!isset($_POST['username']))
1352
-		$_POST['username'] = '';
1353
-	if (!isset($_POST['email']))
1354
-		$_POST['email'] = '';
1355
-	if (!isset($_POST['server_email']))
1356
-		$_POST['server_email'] = '';
1431
+	if (!isset($_POST['username'])) {
1432
+			$_POST['username'] = '';
1433
+	}
1434
+	if (!isset($_POST['email'])) {
1435
+			$_POST['email'] = '';
1436
+	}
1437
+	if (!isset($_POST['server_email'])) {
1438
+			$_POST['server_email'] = '';
1439
+	}
1357 1440
 
1358 1441
 	$incontext['username'] = htmlspecialchars(stripslashes($_POST['username']));
1359 1442
 	$incontext['email'] = htmlspecialchars(stripslashes($_POST['email']));
@@ -1372,8 +1455,9 @@  discard block
 block discarded – undo
1372 1455
 			'admin_group' => 1,
1373 1456
 		)
1374 1457
 	);
1375
-	if ($smcFunc['db_num_rows']($request) != 0)
1376
-		$incontext['skip'] = 1;
1458
+	if ($smcFunc['db_num_rows']($request) != 0) {
1459
+			$incontext['skip'] = 1;
1460
+	}
1377 1461
 	$smcFunc['db_free_result']($request);
1378 1462
 
1379 1463
 	// Trying to create an account?
@@ -1404,8 +1488,9 @@  discard block
 block discarded – undo
1404 1488
 		}
1405 1489
 
1406 1490
 		// Update the webmaster's email?
1407
-		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]'))
1408
-			updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1491
+		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) {
1492
+					updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1493
+		}
1409 1494
 
1410 1495
 		// Work out whether we're going to have dodgy characters and remove them.
1411 1496
 		$invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0;
@@ -1428,32 +1513,27 @@  discard block
 block discarded – undo
1428 1513
 			$smcFunc['db_free_result']($result);
1429 1514
 
1430 1515
 			$incontext['account_existed'] = $txt['error_user_settings_taken'];
1431
-		}
1432
-		elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1516
+		} elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1433 1517
 		{
1434 1518
 			// Try the previous step again.
1435 1519
 			$incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long'];
1436 1520
 			return false;
1437
-		}
1438
-		elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1521
+		} elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1439 1522
 		{
1440 1523
 			// Try the previous step again.
1441 1524
 			$incontext['error'] = $txt['error_invalid_characters_username'];
1442 1525
 			return false;
1443
-		}
1444
-		elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1526
+		} elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1445 1527
 		{
1446 1528
 			// One step back, this time fill out a proper admin email address.
1447 1529
 			$incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']);
1448 1530
 			return false;
1449
-		}
1450
-		elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1531
+		} elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1451 1532
 		{
1452 1533
 			// One step back, this time fill out a proper admin email address.
1453 1534
 			$incontext['error'] = $txt['error_valid_server_email_needed'];
1454 1535
 			return false;
1455
-		}
1456
-		elseif ($_POST['username'] != '')
1536
+		} elseif ($_POST['username'] != '')
1457 1537
 		{
1458 1538
 			$incontext['member_salt'] = substr(md5(mt_rand()), 0, 4);
1459 1539
 
@@ -1519,17 +1599,19 @@  discard block
 block discarded – undo
1519 1599
 	require_once($sourcedir . '/Subs-Auth.php');
1520 1600
 
1521 1601
 	// Bring a warning over.
1522
-	if (!empty($incontext['account_existed']))
1523
-		$incontext['warning'] = $incontext['account_existed'];
1602
+	if (!empty($incontext['account_existed'])) {
1603
+			$incontext['warning'] = $incontext['account_existed'];
1604
+	}
1524 1605
 
1525
-	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support']))
1526
-		$smcFunc['db_query']('', '
1606
+	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) {
1607
+			$smcFunc['db_query']('', '
1527 1608
 			SET NAMES {string:db_character_set}',
1528 1609
 			array(
1529 1610
 				'db_character_set' => $db_character_set,
1530 1611
 				'db_error_skip' => true,
1531 1612
 			)
1532 1613
 		);
1614
+	}
1533 1615
 
1534 1616
 	// As track stats is by default enabled let's add some activity.
1535 1617
 	$smcFunc['db_insert']('ignore',
@@ -1550,14 +1632,16 @@  discard block
 block discarded – undo
1550 1632
 	// Only proceed if we can load the data.
1551 1633
 	if ($request)
1552 1634
 	{
1553
-		while ($row = $smcFunc['db_fetch_row']($request))
1554
-			$modSettings[$row[0]] = $row[1];
1635
+		while ($row = $smcFunc['db_fetch_row']($request)) {
1636
+					$modSettings[$row[0]] = $row[1];
1637
+		}
1555 1638
 		$smcFunc['db_free_result']($request);
1556 1639
 	}
1557 1640
 
1558 1641
 	// Automatically log them in ;)
1559
-	if (isset($incontext['member_id']) && isset($incontext['member_salt']))
1560
-		setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1642
+	if (isset($incontext['member_id']) && isset($incontext['member_salt'])) {
1643
+			setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1644
+	}
1561 1645
 
1562 1646
 	$result = $smcFunc['db_query']('', '
1563 1647
 		SELECT value
@@ -1568,13 +1652,14 @@  discard block
 block discarded – undo
1568 1652
 			'db_error_skip' => true,
1569 1653
 		)
1570 1654
 	);
1571
-	if ($smcFunc['db_num_rows']($result) != 0)
1572
-		list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1655
+	if ($smcFunc['db_num_rows']($result) != 0) {
1656
+			list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1657
+	}
1573 1658
 	$smcFunc['db_free_result']($result);
1574 1659
 
1575
-	if (empty($db_sessions))
1576
-		$_SESSION['admin_time'] = time();
1577
-	else
1660
+	if (empty($db_sessions)) {
1661
+			$_SESSION['admin_time'] = time();
1662
+	} else
1578 1663
 	{
1579 1664
 		$_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211);
1580 1665
 
@@ -1598,8 +1683,9 @@  discard block
 block discarded – undo
1598 1683
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1599 1684
 		function($string){
1600 1685
 			global $sourcedir;
1601
-			if (function_exists('mb_strtolower'))
1602
-				return mb_strtolower($string, 'UTF-8');
1686
+			if (function_exists('mb_strtolower')) {
1687
+							return mb_strtolower($string, 'UTF-8');
1688
+			}
1603 1689
 			require_once($sourcedir . '/Subs-Charset.php');
1604 1690
 			return utf8_strtolower($string);
1605 1691
 		};
@@ -1615,8 +1701,9 @@  discard block
 block discarded – undo
1615 1701
 		)
1616 1702
 	);
1617 1703
 	$context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8';
1618
-	if ($smcFunc['db_num_rows']($request) > 0)
1619
-		updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1704
+	if ($smcFunc['db_num_rows']($request) > 0) {
1705
+			updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1706
+	}
1620 1707
 	$smcFunc['db_free_result']($request);
1621 1708
 
1622 1709
 	// Now is the perfect time to fetch the SM files.
@@ -1635,8 +1722,9 @@  discard block
 block discarded – undo
1635 1722
 
1636 1723
 	// Check if we need some stupid MySQL fix.
1637 1724
 	$server_version = $smcFunc['db_server_info']();
1638
-	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1639
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1725
+	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1726
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1727
+	}
1640 1728
 
1641 1729
 	// Some final context for the template.
1642 1730
 	$incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\';
@@ -1656,8 +1744,9 @@  discard block
 block discarded – undo
1656 1744
 	$settingsArray = file(dirname(__FILE__) . '/Settings.php');
1657 1745
 
1658 1746
 	// @todo Do we just want to read the file in clean, and split it this way always?
1659
-	if (count($settingsArray) == 1)
1660
-		$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1747
+	if (count($settingsArray) == 1) {
1748
+			$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1749
+	}
1661 1750
 
1662 1751
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
1663 1752
 	{
@@ -1672,19 +1761,22 @@  discard block
 block discarded – undo
1672 1761
 			continue;
1673 1762
 		}
1674 1763
 
1675
-		if (trim($settingsArray[$i]) == '?' . '>')
1676
-			$settingsArray[$i] = '';
1764
+		if (trim($settingsArray[$i]) == '?' . '>') {
1765
+					$settingsArray[$i] = '';
1766
+		}
1677 1767
 
1678 1768
 		// Don't trim or bother with it if it's not a variable.
1679
-		if (substr($settingsArray[$i], 0, 1) != '$')
1680
-			continue;
1769
+		if (substr($settingsArray[$i], 0, 1) != '$') {
1770
+					continue;
1771
+		}
1681 1772
 
1682 1773
 		$settingsArray[$i] = rtrim($settingsArray[$i]) . "\n";
1683 1774
 
1684
-		foreach ($vars as $var => $val)
1685
-			if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1775
+		foreach ($vars as $var => $val) {
1776
+					if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1686 1777
 			{
1687 1778
 				$comment = strstr($settingsArray[$i], '#');
1779
+		}
1688 1780
 				$settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n");
1689 1781
 				unset($vars[$var]);
1690 1782
 			}
@@ -1694,36 +1786,41 @@  discard block
 block discarded – undo
1694 1786
 	if (!empty($vars))
1695 1787
 	{
1696 1788
 		$settingsArray[$i++] = '';
1697
-		foreach ($vars as $var => $val)
1698
-			$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1789
+		foreach ($vars as $var => $val) {
1790
+					$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1791
+		}
1699 1792
 	}
1700 1793
 
1701 1794
 	// Blank out the file - done to fix a oddity with some servers.
1702 1795
 	$fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w');
1703
-	if (!$fp)
1704
-		return false;
1796
+	if (!$fp) {
1797
+			return false;
1798
+	}
1705 1799
 	fclose($fp);
1706 1800
 
1707 1801
 	$fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+');
1708 1802
 
1709 1803
 	// Gotta have one of these ;)
1710
-	if (trim($settingsArray[0]) != '<?php')
1711
-		fwrite($fp, "<?php\n");
1804
+	if (trim($settingsArray[0]) != '<?php') {
1805
+			fwrite($fp, "<?php\n");
1806
+	}
1712 1807
 
1713 1808
 	$lines = count($settingsArray);
1714 1809
 	for ($i = 0; $i < $lines - 1; $i++)
1715 1810
 	{
1716 1811
 		// Don't just write a bunch of blank lines.
1717
-		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '')
1718
-			fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1812
+		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') {
1813
+					fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1814
+		}
1719 1815
 	}
1720 1816
 	fwrite($fp, $settingsArray[$i] . '?' . '>');
1721 1817
 	fclose($fp);
1722 1818
 
1723 1819
 	// Even though on normal installations the filemtime should prevent this being used by the installer incorrectly
1724 1820
 	// it seems that there are times it might not. So let's MAKE it dump the cache.
1725
-	if (function_exists('opcache_invalidate'))
1726
-		opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1821
+	if (function_exists('opcache_invalidate')) {
1822
+			opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1823
+	}
1727 1824
 
1728 1825
 	return true;
1729 1826
 }
@@ -1748,9 +1845,9 @@  discard block
 block discarded – undo
1748 1845
 	SecFilterScanPOST Off
1749 1846
 </IfModule>';
1750 1847
 
1751
-	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules()))
1752
-		return true;
1753
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1848
+	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) {
1849
+			return true;
1850
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1754 1851
 	{
1755 1852
 		$current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess'));
1756 1853
 
@@ -1762,29 +1859,28 @@  discard block
 block discarded – undo
1762 1859
 				fwrite($ht_handle, $htaccess_addition);
1763 1860
 				fclose($ht_handle);
1764 1861
 				return true;
1862
+			} else {
1863
+							return false;
1765 1864
 			}
1766
-			else
1767
-				return false;
1865
+		} else {
1866
+					return true;
1768 1867
 		}
1769
-		else
1770
-			return true;
1771
-	}
1772
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess'))
1773
-		return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1774
-	elseif (is_writable(dirname(__FILE__)))
1868
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess')) {
1869
+			return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1870
+	} elseif (is_writable(dirname(__FILE__)))
1775 1871
 	{
1776 1872
 		if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w'))
1777 1873
 		{
1778 1874
 			fwrite($ht_handle, $htaccess_addition);
1779 1875
 			fclose($ht_handle);
1780 1876
 			return true;
1877
+		} else {
1878
+					return false;
1781 1879
 		}
1782
-		else
1880
+	} else {
1783 1881
 			return false;
1784 1882
 	}
1785
-	else
1786
-		return false;
1787
-}
1883
+	}
1788 1884
 
1789 1885
 function template_install_above()
1790 1886
 {
@@ -1822,9 +1918,10 @@  discard block
 block discarded – undo
1822 1918
 								<label for="installer_language">', $txt['installer_language'], ':</label>
1823 1919
 								<select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">';
1824 1920
 
1825
-		foreach ($incontext['detected_languages'] as $lang => $name)
1826
-			echo '
1921
+		foreach ($incontext['detected_languages'] as $lang => $name) {
1922
+					echo '
1827 1923
 									<option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>';
1924
+		}
1828 1925
 
1829 1926
 		echo '
1830 1927
 								</select>
@@ -1844,9 +1941,10 @@  discard block
 block discarded – undo
1844 1941
 						<h2>', $txt['upgrade_progress'], '</h2>
1845 1942
 						<ul>';
1846 1943
 
1847
-	foreach ($incontext['steps'] as $num => $step)
1848
-		echo '
1944
+	foreach ($incontext['steps'] as $num => $step) {
1945
+			echo '
1849 1946
 							<li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
1947
+	}
1850 1948
 
1851 1949
 	echo '
1852 1950
 						</ul>
@@ -1871,20 +1969,23 @@  discard block
 block discarded – undo
1871 1969
 		echo '
1872 1970
 								<div>';
1873 1971
 
1874
-		if (!empty($incontext['continue']))
1875
-			echo '
1972
+		if (!empty($incontext['continue'])) {
1973
+					echo '
1876 1974
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button_submit" />';
1877
-		if (!empty($incontext['skip']))
1878
-			echo '
1975
+		}
1976
+		if (!empty($incontext['skip'])) {
1977
+					echo '
1879 1978
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button_submit" />';
1979
+		}
1880 1980
 		echo '
1881 1981
 								</div>';
1882 1982
 	}
1883 1983
 
1884 1984
 	// Show the closing form tag and other data only if not in the last step
1885
-	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step'])
1886
-		echo '
1985
+	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) {
1986
+			echo '
1887 1987
 							</form>';
1988
+	}
1888 1989
 
1889 1990
 	echo '
1890 1991
 						</div>
@@ -1919,13 +2020,15 @@  discard block
 block discarded – undo
1919 2020
 		</div>';
1920 2021
 
1921 2022
 	// Show the warnings, or not.
1922
-	if (template_warning_divs())
1923
-		echo '
2023
+	if (template_warning_divs()) {
2024
+			echo '
1924 2025
 		<h3>', $txt['install_all_lovely'], '</h3>';
2026
+	}
1925 2027
 
1926 2028
 	// Say we want the continue button!
1927
-	if (empty($incontext['error']))
1928
-		$incontext['continue'] = 1;
2029
+	if (empty($incontext['error'])) {
2030
+			$incontext['continue'] = 1;
2031
+	}
1929 2032
 
1930 2033
 	// For the latest version stuff.
1931 2034
 	echo '
@@ -1959,8 +2062,8 @@  discard block
 block discarded – undo
1959 2062
 	global $txt, $incontext;
1960 2063
 
1961 2064
 	// Errors are very serious..
1962
-	if (!empty($incontext['error']))
1963
-		echo '
2065
+	if (!empty($incontext['error'])) {
2066
+			echo '
1964 2067
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
1965 2068
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
1966 2069
 			<strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br>
@@ -1968,9 +2071,10 @@  discard block
 block discarded – undo
1968 2071
 				', $incontext['error'], '
1969 2072
 			</div>
1970 2073
 		</div>';
2074
+	}
1971 2075
 	// A warning message?
1972
-	elseif (!empty($incontext['warning']))
1973
-		echo '
2076
+	elseif (!empty($incontext['warning'])) {
2077
+			echo '
1974 2078
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
1975 2079
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
1976 2080
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -1978,6 +2082,7 @@  discard block
 block discarded – undo
1978 2082
 				', $incontext['warning'], '
1979 2083
 			</div>
1980 2084
 		</div>';
2085
+	}
1981 2086
 
1982 2087
 	return empty($incontext['error']) && empty($incontext['warning']);
1983 2088
 }
@@ -1993,27 +2098,30 @@  discard block
 block discarded – undo
1993 2098
 			<li>', $incontext['failed_files']), '</li>
1994 2099
 		</ul>';
1995 2100
 
1996
-	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux')
1997
-		echo '
2101
+	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') {
2102
+			echo '
1998 2103
 		<hr>
1999 2104
 		<p>', $txt['chmod_linux_info'], '</p>
2000 2105
 		<tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>';
2106
+	}
2001 2107
 
2002 2108
 	// This is serious!
2003
-	if (!template_warning_divs())
2004
-		return;
2109
+	if (!template_warning_divs()) {
2110
+			return;
2111
+	}
2005 2112
 
2006 2113
 	echo '
2007 2114
 		<hr>
2008 2115
 		<p>', $txt['ftp_setup_info'], '</p>';
2009 2116
 
2010
-	if (!empty($incontext['ftp_errors']))
2011
-		echo '
2117
+	if (!empty($incontext['ftp_errors'])) {
2118
+			echo '
2012 2119
 		<div class="error_message">
2013 2120
 			', $txt['error_ftp_no_connect'], '<br><br>
2014 2121
 			<code>', implode('<br>', $incontext['ftp_errors']), '</code>
2015 2122
 		</div>
2016 2123
 		<br>';
2124
+	}
2017 2125
 
2018 2126
 	echo '
2019 2127
 		<form action="', $incontext['form_url'], '" method="post">
@@ -2073,17 +2181,17 @@  discard block
 block discarded – undo
2073 2181
 				<td>
2074 2182
 					<select name="db_type" id="db_type_input" onchange="toggleDBInput();">';
2075 2183
 
2076
-	foreach ($incontext['supported_databases'] as $key => $db)
2077
-			echo '
2184
+	foreach ($incontext['supported_databases'] as $key => $db) {
2185
+				echo '
2078 2186
 						<option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>';
2187
+	}
2079 2188
 
2080 2189
 	echo '
2081 2190
 					</select>
2082 2191
 					<div class="smalltext block">', $txt['db_settings_type_info'], '</div>
2083 2192
 				</td>
2084 2193
 			</tr>';
2085
-	}
2086
-	else
2194
+	} else
2087 2195
 	{
2088 2196
 		echo '
2089 2197
 			<tr style="display: none;">
@@ -2275,9 +2383,10 @@  discard block
 block discarded – undo
2275 2383
 				<div style="color: red;">', $txt['error_db_queries'], '</div>
2276 2384
 				<ul>';
2277 2385
 
2278
-		foreach ($incontext['failures'] as $line => $fail)
2279
-			echo '
2386
+		foreach ($incontext['failures'] as $line => $fail) {
2387
+					echo '
2280 2388
 						<li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>';
2389
+		}
2281 2390
 
2282 2391
 		echo '
2283 2392
 				</ul>';
@@ -2338,15 +2447,16 @@  discard block
 block discarded – undo
2338 2447
 			</tr>
2339 2448
 		</table>';
2340 2449
 
2341
-	if ($incontext['require_db_confirm'])
2342
-		echo '
2450
+	if ($incontext['require_db_confirm']) {
2451
+			echo '
2343 2452
 		<h2>', $txt['user_settings_database'], '</h2>
2344 2453
 		<p>', $txt['user_settings_database_info'], '</p>
2345 2454
 
2346 2455
 		<div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;">
2347 2456
 			<input type="password" name="password3" size="30" class="input_password" />
2348 2457
 		</div>';
2349
-}
2458
+	}
2459
+	}
2350 2460
 
2351 2461
 // Tell them it's done, and to delete.
2352 2462
 function template_delete_install()
@@ -2359,14 +2469,15 @@  discard block
 block discarded – undo
2359 2469
 	template_warning_divs();
2360 2470
 
2361 2471
 	// Install directory still writable?
2362
-	if ($incontext['dir_still_writable'])
2363
-		echo '
2472
+	if ($incontext['dir_still_writable']) {
2473
+			echo '
2364 2474
 		<em>', $txt['still_writable'], '</em><br>
2365 2475
 		<br>';
2476
+	}
2366 2477
 
2367 2478
 	// Don't show the box if it's like 99% sure it won't work :P.
2368
-	if ($incontext['probably_delete_install'])
2369
-		echo '
2479
+	if ($incontext['probably_delete_install']) {
2480
+			echo '
2370 2481
 		<div style="margin: 1ex; font-weight: bold;">
2371 2482
 			<label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" class="input_check" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label>
2372 2483
 		</div>
@@ -2382,6 +2493,7 @@  discard block
 block discarded – undo
2382 2493
 			}
2383 2494
 		</script>
2384 2495
 		<br>';
2496
+	}
2385 2497
 
2386 2498
 	echo '
2387 2499
 		', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br>
Please login to merge, or discard this patch.
index.php 2 patches
Braces   +37 added lines, -25 removed lines patch added patch discarded remove patch
@@ -25,8 +25,9 @@  discard block
 block discarded – undo
25 25
 
26 26
 // Get everything started up...
27 27
 define('SMF', 1);
28
-if (function_exists('set_magic_quotes_runtime') && strnatcmp(phpversion(), '5.3.0') < 0)
28
+if (function_exists('set_magic_quotes_runtime') && strnatcmp(phpversion(), '5.3.0') < 0) {
29 29
 	@set_magic_quotes_runtime(0);
30
+}
30 31
 error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL);
31 32
 $time_start = microtime();
32 33
 
@@ -34,16 +35,18 @@  discard block
 block discarded – undo
34 35
 ob_start();
35 36
 
36 37
 // Do some cleaning, just in case.
37
-foreach (array('db_character_set', 'cachedir') as $variable)
38
+foreach (array('db_character_set', 'cachedir') as $variable) {
38 39
 	if (isset($GLOBALS[$variable]))
39 40
 		unset($GLOBALS[$variable], $GLOBALS[$variable]);
41
+}
40 42
 
41 43
 // Load the settings...
42 44
 require_once(dirname(__FILE__) . '/Settings.php');
43 45
 
44 46
 // Make absolutely sure the cache directory is defined.
45
-if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache'))
47
+if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) {
46 48
 	$cachedir = $boarddir . '/cache';
49
+}
47 50
 
48 51
 // Without those we can't go anywhere
49 52
 require_once($sourcedir . '/QueryString.php');
@@ -53,8 +56,9 @@  discard block
 block discarded – undo
53 56
 require_once($sourcedir . '/Load.php');
54 57
 
55 58
 // If $maintenance is set specifically to 2, then we're upgrading or something.
56
-if (!empty($maintenance) && $maintenance == 2)
59
+if (!empty($maintenance) && $maintenance == 2) {
57 60
 	display_maintenance_message();
61
+}
58 62
 
59 63
 // Create a variable to store some SMF specific functions in.
60 64
 $smcFunc = array();
@@ -69,8 +73,9 @@  discard block
 block discarded – undo
69 73
 cleanRequest();
70 74
 
71 75
 // Seed the random generator.
72
-if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69)
76
+if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) {
73 77
 	smf_seed_generator();
78
+}
74 79
 
75 80
 // Before we get carried away, are we doing a scheduled task? If so save CPU cycles by jumping out!
76 81
 if (isset($_GET['scheduled']))
@@ -90,9 +95,9 @@  discard block
 block discarded – undo
90 95
 if (!empty($modSettings['enableCompressedOutput']) && !headers_sent())
91 96
 {
92 97
 	// If zlib is being used, turn off output compression.
93
-	if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler')
94
-		$modSettings['enableCompressedOutput'] = '0';
95
-	else
98
+	if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') {
99
+			$modSettings['enableCompressedOutput'] = '0';
100
+	} else
96 101
 	{
97 102
 		ob_end_clean();
98 103
 		ob_start('ob_gzhandler');
@@ -141,18 +146,21 @@  discard block
 block discarded – undo
141 146
 	loadPermissions();
142 147
 
143 148
 	// Attachments don't require the entire theme to be loaded.
144
-	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach')
145
-		detectBrowser();
149
+	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') {
150
+			detectBrowser();
151
+	}
146 152
 	// Load the current theme.  (note that ?theme=1 will also work, may be used for guest theming.)
147
-	else
148
-		loadTheme();
153
+	else {
154
+			loadTheme();
155
+	}
149 156
 
150 157
 	// Check if the user should be disallowed access.
151 158
 	is_not_banned();
152 159
 
153 160
 	// If we are in a topic and don't have permission to approve it then duck out now.
154
-	if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest']))
155
-		fatal_lang_error('not_a_topic', false);
161
+	if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) {
162
+			fatal_lang_error('not_a_topic', false);
163
+	}
156 164
 
157 165
 	$no_stat_actions = array('clock', 'dlattach', 'findmember', 'jsoption', 'likes', 'loadeditorlocale', 'modifycat', 'requestmembers', 'smstats', 'suggest', 'about:unknown', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile');
158 166
 	call_integration_hook('integrate_pre_log_stats', array(&$no_stat_actions));
@@ -163,8 +171,9 @@  discard block
 block discarded – undo
163 171
 		writeLog();
164 172
 
165 173
 		// Track forum statistics and hits...?
166
-		if (!empty($modSettings['hitStats']))
167
-			trackStats(array('hits' => '+'));
174
+		if (!empty($modSettings['hitStats'])) {
175
+					trackStats(array('hits' => '+'));
176
+		}
168 177
 	}
169 178
 	unset($no_stat_actions);
170 179
 
@@ -178,13 +187,14 @@  discard block
 block discarded – undo
178 187
 			return ($_REQUEST['action'] == 'login2' ? 'Login2' : ($_REQUEST['action'] == 'logintfa' ? 'LoginTFA' : 'Logout'));
179 188
 		}
180 189
 		// Don't even try it, sonny.
181
-		else
182
-			return 'InMaintenance';
190
+		else {
191
+					return 'InMaintenance';
192
+		}
183 193
 	}
184 194
 	// If guest access is off, a guest can only do one of the very few following actions.
185
-	elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2'))))
186
-		return 'KickGuest';
187
-	elseif (empty($_REQUEST['action']))
195
+	elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) {
196
+			return 'KickGuest';
197
+	} elseif (empty($_REQUEST['action']))
188 198
 	{
189 199
 		// Action and board are both empty... BoardIndex! Unless someone else wants to do something different.
190 200
 		if (empty($board) && empty($topic))
@@ -198,8 +208,9 @@  discard block
 block discarded – undo
198 208
 
199 209
 				$call = call_helper($defaultAction, true);
200 210
 
201
-				if (!empty($call))
202
-					return $call;
211
+				if (!empty($call)) {
212
+									return $call;
213
+				}
203 214
 			}
204 215
 
205 216
 			// No default action huh? then go to our good old BoardIndex.
@@ -329,8 +340,9 @@  discard block
 block discarded – undo
329 340
 
330 341
 			$call = call_helper($fallbackAction, true);
331 342
 
332
-			if (!empty($call))
333
-				return $call;
343
+			if (!empty($call)) {
344
+							return $call;
345
+			}
334 346
 		}
335 347
 
336 348
 		// No fallback action, huh?
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@
 block discarded – undo
104 104
  *
105 105
  * @param string $class The fully-qualified class name.
106 106
  */
107
-spl_autoload_register(function ($class) use ($sourcedir)
107
+spl_autoload_register(function($class) use ($sourcedir)
108 108
 {
109 109
 	$classMap = array(
110 110
 		'ReCaptcha\\' => 'ReCaptcha/',
Please login to merge, or discard this patch.
Themes/default/Profile.template.php 2 patches
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3031,8 +3031,7 @@
 block discarded – undo
3031 3031
 							<div class="roundframe">
3032 3032
 								<div>
3033 3033
 		', !empty($context['tfa_backup']) ? '
3034
-									<div class="smalltext error">' . $txt['tfa_backup_used_desc'] . '</div>' :
3035
-			($modSettings['tfa_mode'] == 2 ? '
3034
+									<div class="smalltext error">' . $txt['tfa_backup_used_desc'] . '</div>' : ($modSettings['tfa_mode'] == 2 ? '
3036 3035
 									<div class="smalltext"><strong>' . $txt['tfa_forced_desc'] . '</strong></div>' : ''), '
3037 3036
 									<div class="smalltext">', $txt['tfa_desc'], '</div>
3038 3037
 									<div id="basicinfo" style="width: 60%">
Please login to merge, or discard this patch.
Braces   +461 added lines, -344 removed lines patch added patch discarded remove patch
@@ -18,23 +18,25 @@  discard block
 block discarded – undo
18 18
 	global $context;
19 19
 
20 20
 	// Prevent Chrome from auto completing fields when viewing/editing other members profiles
21
-	if (isBrowser('is_chrome') && !$context['user']['is_owner'])
22
-		echo '
21
+	if (isBrowser('is_chrome') && !$context['user']['is_owner']) {
22
+			echo '
23 23
 	<script>
24 24
 		disableAutoComplete();
25 25
 	</script>';
26
+	}
26 27
 
27 28
 	// If an error occurred while trying to save previously, give the user a clue!
28 29
 	echo '
29 30
 					', template_error_message();
30 31
 
31 32
 	// If the profile was update successfully, let the user know this.
32
-	if (!empty($context['profile_updated']))
33
-		echo '
33
+	if (!empty($context['profile_updated'])) {
34
+			echo '
34 35
 					<div class="infobox">
35 36
 						', $context['profile_updated'], '
36 37
 					</div>';
37
-}
38
+	}
39
+	}
38 40
 
39 41
 /**
40 42
  * Template for any HTML needed below the profile (closing off divs/tables, etc.)
@@ -102,8 +104,7 @@  discard block
 block discarded – undo
102 104
 	if (empty($context['unread_alerts']))
103 105
 	{
104 106
 		template_alerts_all_read();
105
-	}
106
-	else
107
+	} else
107 108
 	{
108 109
 		foreach ($context['unread_alerts'] as $id_alert => $details)
109 110
 		{
@@ -164,10 +165,11 @@  discard block
 block discarded – undo
164 165
 			<div class="custom_fields_above_name">
165 166
 				<ul >';
166 167
 
167
-		foreach ($context['print_custom_fields']['above_member'] as $field)
168
-			if (!empty($field['output_html']))
168
+		foreach ($context['print_custom_fields']['above_member'] as $field) {
169
+					if (!empty($field['output_html']))
169 170
 				echo '
170 171
 					<li>', $field['output_html'], '</li>';
172
+		}
171 173
 
172 174
 		echo '
173 175
 				</ul>
@@ -188,10 +190,11 @@  discard block
 block discarded – undo
188 190
 			<div class="custom_fields_below_avatar">
189 191
 				<ul >';
190 192
 
191
-		foreach ($context['print_custom_fields']['below_avatar'] as $field)
192
-			if (!empty($field['output_html']))
193
+		foreach ($context['print_custom_fields']['below_avatar'] as $field) {
194
+					if (!empty($field['output_html']))
193 195
 				echo '
194 196
 					<li>', $field['output_html'], '</li>';
197
+		}
195 198
 
196 199
 		echo '
197 200
 				</ul>
@@ -202,22 +205,25 @@  discard block
 block discarded – undo
202 205
 		echo '
203 206
 			<ul class="clear">';
204 207
 	// Email is only visible if it's your profile or you have the moderate_forum permission
205
-	if ($context['member']['show_email'])
206
-		echo '
208
+	if ($context['member']['show_email']) {
209
+			echo '
207 210
 				<li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>';
211
+	}
208 212
 
209 213
 	// Don't show an icon if they haven't specified a website.
210
-	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website']))
211
-		echo '
214
+	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) {
215
+			echo '
212 216
 				<li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
217
+	}
213 218
 
214 219
 	// Are there any custom profile fields as icons?
215 220
 	if (!empty($context['print_custom_fields']['icons']))
216 221
 	{
217
-		foreach ($context['print_custom_fields']['icons'] as $field)
218
-			if (!empty($field['output_html']))
222
+		foreach ($context['print_custom_fields']['icons'] as $field) {
223
+					if (!empty($field['output_html']))
219 224
 				echo '
220 225
 					<li class="custom_field">', $field['output_html'], '</li>';
226
+		}
221 227
 	}
222 228
 
223 229
 	echo '
@@ -225,23 +231,26 @@  discard block
 block discarded – undo
225 231
 			<span id="userstatus">', $context['can_send_pm'] ? '<a href="' . $context['member']['online']['href'] . '" title="' . $context['member']['online']['text'] . '" rel="nofollow">' : '', $settings['use_image_buttons'] ? '<span class="' . ($context['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $context['member']['online']['text'] . '"></span>' : $context['member']['online']['label'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $context['member']['online']['label'] . '</span>' : '';
226 232
 
227 233
 	// Can they add this member as a buddy?
228
-	if (!empty($context['can_have_buddy']) && !$context['user']['is_owner'])
229
-		echo '
234
+	if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) {
235
+			echo '
230 236
 				<br><a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a>';
237
+	}
231 238
 
232 239
 	echo '
233 240
 			</span>';
234 241
 
235
-	if (!$context['user']['is_owner'] && $context['can_send_pm'])
236
-		echo '
242
+	if (!$context['user']['is_owner'] && $context['can_send_pm']) {
243
+			echo '
237 244
 			<a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>';
245
+	}
238 246
 
239 247
 	echo '
240 248
 			<a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>';
241 249
 
242
-	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled']))
243
-		echo '
250
+	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) {
251
+			echo '
244 252
 			<a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>';
253
+	}
245 254
 
246 255
 	echo '
247 256
 			<a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>';
@@ -253,10 +262,11 @@  discard block
 block discarded – undo
253 262
 			<div class="custom_fields_bottom">
254 263
 				<ul class="nolist">';
255 264
 
256
-		foreach ($context['print_custom_fields']['bottom_poster'] as $field)
257
-			if (!empty($field['output_html']))
265
+		foreach ($context['print_custom_fields']['bottom_poster'] as $field) {
266
+					if (!empty($field['output_html']))
258 267
 				echo '
259 268
 					<li>', $field['output_html'], '</li>';
269
+		}
260 270
 
261 271
 		echo '
262 272
 				</ul>
@@ -270,15 +280,17 @@  discard block
 block discarded – undo
270 280
 		<div id="detailedinfo">
271 281
 			<dl class="settings">';
272 282
 
273
-	if ($context['user']['is_owner'] || $context['user']['is_admin'])
274
-		echo '
283
+	if ($context['user']['is_owner'] || $context['user']['is_admin']) {
284
+			echo '
275 285
 				<dt>', $txt['username'], ': </dt>
276 286
 				<dd>', $context['member']['username'], '</dd>';
287
+	}
277 288
 
278
-	if (!isset($context['disabled_fields']['posts']))
279
-		echo '
289
+	if (!isset($context['disabled_fields']['posts'])) {
290
+			echo '
280 291
 				<dt>', $txt['profile_posts'], ': </dt>
281 292
 				<dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>';
293
+	}
282 294
 
283 295
 	if ($context['member']['show_email'])
284 296
 	{
@@ -287,15 +299,17 @@  discard block
 block discarded – undo
287 299
 				<dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>';
288 300
 	}
289 301
 
290
-	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title']))
291
-		echo '
302
+	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) {
303
+			echo '
292 304
 				<dt>', $txt['custom_title'], ': </dt>
293 305
 				<dd>', $context['member']['title'], '</dd>';
306
+	}
294 307
 
295
-	if (!empty($context['member']['blurb']))
296
-		echo '
308
+	if (!empty($context['member']['blurb'])) {
309
+			echo '
297 310
 				<dt>', $txt['personal_text'], ': </dt>
298 311
 				<dd>', $context['member']['blurb'], '</dd>';
312
+	}
299 313
 
300 314
 	echo '
301 315
 				<dt>', $txt['age'], ':</dt>
@@ -310,11 +324,12 @@  discard block
 block discarded – undo
310 324
 		echo '
311 325
 				<dl class="settings">';
312 326
 
313
-		foreach ($context['print_custom_fields']['standard'] as $field)
314
-			if (!empty($field['output_html']))
327
+		foreach ($context['print_custom_fields']['standard'] as $field) {
328
+					if (!empty($field['output_html']))
315 329
 				echo '
316 330
 					<dt>', $field['name'], ':</dt>
317 331
 					<dd>', $field['output_html'], '</dd>';
332
+		}
318 333
 
319 334
 		echo '
320 335
 				</dl>';
@@ -332,9 +347,10 @@  discard block
 block discarded – undo
332 347
 						<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>';
333 348
 
334 349
 		// Can we provide information on what this means?
335
-		if (!empty($context['warning_status']))
336
-			echo '
350
+		if (!empty($context['warning_status'])) {
351
+					echo '
337 352
 						<span class="smalltext">(', $context['warning_status'], ')</span>';
353
+		}
338 354
 
339 355
 		echo '
340 356
 					</dd>';
@@ -345,9 +361,10 @@  discard block
 block discarded – undo
345 361
 	{
346 362
 
347 363
 		// If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves.
348
-		if (!empty($context['activate_message']))
349
-			echo '
364
+		if (!empty($context['activate_message'])) {
365
+					echo '
350 366
 					<dt class="clear"><span class="alert">', $context['activate_message'], '</span>&nbsp;(<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>)</dt>';
367
+		}
351 368
 
352 369
 		// If the current member is banned, show a message and possibly a link to the ban.
353 370
 		if (!empty($context['member']['bans']))
@@ -357,9 +374,10 @@  discard block
 block discarded – undo
357 374
 					<dt class="clear" id="ban_info" style="display: none;">
358 375
 						<strong>', $txt['user_banned_by_following'], ':</strong>';
359 376
 
360
-			foreach ($context['member']['bans'] as $ban)
361
-				echo '
377
+			foreach ($context['member']['bans'] as $ban) {
378
+							echo '
362 379
 						<br><span class="smalltext">', $ban['explanation'], '</span>';
380
+			}
363 381
 
364 382
 			echo '
365 383
 					</dt>';
@@ -373,30 +391,34 @@  discard block
 block discarded – undo
373 391
 	// If the person looking is allowed, they can check the members IP address and hostname.
374 392
 	if ($context['can_see_ip'])
375 393
 	{
376
-		if (!empty($context['member']['ip']))
377
-		echo '
394
+		if (!empty($context['member']['ip'])) {
395
+				echo '
378 396
 					<dt>', $txt['ip'], ': </dt>
379 397
 					<dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>';
398
+		}
380 399
 
381
-		if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip']))
382
-			echo '
400
+		if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) {
401
+					echo '
383 402
 					<dt>', $txt['hostname'], ': </dt>
384 403
 					<dd>', $context['member']['hostname'], '</dd>';
404
+		}
385 405
 	}
386 406
 
387 407
 	echo '
388 408
 					<dt>', $txt['local_time'], ':</dt>
389 409
 					<dd>', $context['member']['local_time'], '</dd>';
390 410
 
391
-	if (!empty($modSettings['userLanguage']) && !empty($context['member']['language']))
392
-		echo '
411
+	if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) {
412
+			echo '
393 413
 					<dt>', $txt['language'], ':</dt>
394 414
 					<dd>', $context['member']['language'], '</dd>';
415
+	}
395 416
 
396
-	if ($context['member']['show_last_login'])
397
-		echo '
417
+	if ($context['member']['show_last_login']) {
418
+			echo '
398 419
 					<dt>', $txt['lastLoggedIn'], ': </dt>
399 420
 					<dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>';
421
+	}
400 422
 
401 423
 	echo '
402 424
 				</dl>';
@@ -408,10 +430,11 @@  discard block
 block discarded – undo
408 430
 				<div class="custom_fields_above_signature">
409 431
 					<ul class="nolist">';
410 432
 
411
-		foreach ($context['print_custom_fields']['above_signature'] as $field)
412
-			if (!empty($field['output_html']))
433
+		foreach ($context['print_custom_fields']['above_signature'] as $field) {
434
+					if (!empty($field['output_html']))
413 435
 				echo '
414 436
 						<li>', $field['output_html'], '</li>';
437
+		}
415 438
 
416 439
 		echo '
417 440
 					</ul>
@@ -419,12 +442,13 @@  discard block
 block discarded – undo
419 442
 	}
420 443
 
421 444
 	// Show the users signature.
422
-	if ($context['signature_enabled'] && !empty($context['member']['signature']))
423
-		echo '
445
+	if ($context['signature_enabled'] && !empty($context['member']['signature'])) {
446
+			echo '
424 447
 				<div class="signature">
425 448
 					<h5>', $txt['signature'], ':</h5>
426 449
 					', $context['member']['signature'], '
427 450
 				</div>';
451
+	}
428 452
 
429 453
 	// Are there any custom profile fields for below the signature?
430 454
 	if (!empty($context['print_custom_fields']['below_signature']))
@@ -433,10 +457,11 @@  discard block
 block discarded – undo
433 457
 				<div class="custom_fields_below_signature">
434 458
 					<ul class="nolist">';
435 459
 
436
-		foreach ($context['print_custom_fields']['below_signature'] as $field)
437
-			if (!empty($field['output_html']))
460
+		foreach ($context['print_custom_fields']['below_signature'] as $field) {
461
+					if (!empty($field['output_html']))
438 462
 				echo '
439 463
 						<li>', $field['output_html'], '</li>';
464
+		}
440 465
 
441 466
 		echo '
442 467
 					</ul>
@@ -481,62 +506,70 @@  discard block
 block discarded – undo
481 506
 				</div>
482 507
 				<div class="list_posts">';
483 508
 
484
-			if (!$post['approved'])
485
-				echo '
509
+			if (!$post['approved']) {
510
+							echo '
486 511
 					<div class="approve_post">
487 512
 						<em>', $txt['post_awaiting_approval'], '</em>
488 513
 					</div>';
514
+			}
489 515
 
490 516
 			echo '
491 517
 					', $post['body'], '
492 518
 				</div>';
493 519
 
494
-			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
495
-				echo '
520
+			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
521
+							echo '
496 522
 				<div class="floatright">
497 523
 					<ul class="quickbuttons">';
524
+			}
498 525
 
499 526
 			// If they *can* reply?
500
-			if ($post['can_reply'])
501
-				echo '
527
+			if ($post['can_reply']) {
528
+							echo '
502 529
 						<li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>';
530
+			}
503 531
 
504 532
 			// If they *can* quote?
505
-			if ($post['can_quote'])
506
-				echo '
533
+			if ($post['can_quote']) {
534
+							echo '
507 535
 						<li><a href="', $scripturl . '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>';
536
+			}
508 537
 
509 538
 			// How about... even... remove it entirely?!
510
-			if ($post['can_delete'])
511
-				echo '
539
+			if ($post['can_delete']) {
540
+							echo '
512 541
 						<li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
542
+			}
513 543
 
514
-			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
515
-				echo '
544
+			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
545
+							echo '
516 546
 					</ul>
517 547
 				</div>';
548
+			}
518 549
 
519 550
 			echo '
520 551
 			</div>';
521 552
 		}
553
+	} else {
554
+			template_show_list('attachments');
522 555
 	}
523
-	else
524
-		template_show_list('attachments');
525 556
 
526 557
 	// No posts? Just end with a informative message.
527
-	if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts'])))
528
-		echo '
558
+	if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) {
559
+			echo '
529 560
 			<div class="windowbg2">
530 561
 				', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), '
531 562
 			</div>';
563
+	}
532 564
 
533 565
 	// Show more page numbers.
534
-	if (!empty($context['page_index']))
535
-		echo '
566
+	if (!empty($context['page_index'])) {
567
+			echo '
536 568
 		<div class="pagesection">
537 569
 			<div class="pagelinks">', $context['page_index'], '</div>
538 570
 		</div>';
539
-}
571
+	}
572
+	}
540 573
 
541 574
 /**
542 575
  * Template for showing alerts within the alerts popup
@@ -546,11 +579,12 @@  discard block
 block discarded – undo
546 579
 	global $context, $txt, $scripturl;
547 580
 
548 581
 	// Do we have an update message?
549
-	if (!empty($context['update_message']))
550
-		echo '
582
+	if (!empty($context['update_message'])) {
583
+			echo '
551 584
 		<div class="infobox">
552 585
 			', $context['update_message'], '.
553 586
 		</div>';
587
+	}
554 588
 
555 589
 	echo '
556 590
 		<div class="cat_bar">
@@ -559,13 +593,12 @@  discard block
 block discarded – undo
559 593
 			</h3>
560 594
 		</div>';
561 595
 
562
-	if (empty($context['alerts']))
563
-		echo '
596
+	if (empty($context['alerts'])) {
597
+			echo '
564 598
 		<div class="information">
565 599
 			', $txt['alerts_none'], '
566 600
 		</div>';
567
-
568
-	else
601
+	} else
569 602
 	{
570 603
 		// Start the form.
571 604
 		echo '
@@ -627,12 +660,12 @@  discard block
 block discarded – undo
627 660
 		</div>' : '';
628 661
 
629 662
 	// No drafts? Just show an informative message.
630
-	if (empty($context['drafts']))
631
-		echo '
663
+	if (empty($context['drafts'])) {
664
+			echo '
632 665
 		<div class="windowbg2 centertext">
633 666
 			', $txt['draft_none'], '
634 667
 		</div>';
635
-	else
668
+	} else
636 669
 	{
637 670
 		// For every draft to be displayed, give it its own div, and show the important details of the draft.
638 671
 		foreach ($context['drafts'] as $draft)
@@ -643,11 +676,13 @@  discard block
 block discarded – undo
643 676
 					<div class="topic_details">
644 677
 						<h5><strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> &nbsp; &nbsp;';
645 678
 
646
-			if (!empty($draft['sticky']))
647
-				echo '<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>';
679
+			if (!empty($draft['sticky'])) {
680
+							echo '<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>';
681
+			}
648 682
 
649
-			if (!empty($draft['locked']))
650
-				echo '<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>';
683
+			if (!empty($draft['locked'])) {
684
+							echo '<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>';
685
+			}
651 686
 
652 687
 			echo '
653 688
 						</h5>
@@ -680,12 +715,13 @@  discard block
 block discarded – undo
680 715
 {
681 716
 	global $context, $scripturl, $txt;
682 717
 
683
-	if (!empty($context['saved_successful']))
684
-		echo '
718
+	if (!empty($context['saved_successful'])) {
719
+			echo '
685 720
 					<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
686
-	elseif (!empty($context['saved_failed']))
687
-		echo '
721
+	} elseif (!empty($context['saved_failed'])) {
722
+			echo '
688 723
 					<div class="errorbox">', $context['saved_failed'], '</div>';
724
+	}
689 725
 
690 726
 	echo '
691 727
 	<div id="edit_buddies">
@@ -699,24 +735,27 @@  discard block
 block discarded – undo
699 735
 				<th scope="col" class="quarter_table">', $txt['name'], '</th>
700 736
 				<th scope="col">', $txt['status'], '</th>';
701 737
 
702
-	if (allowedTo('moderate_forum'))
703
-		echo '
738
+	if (allowedTo('moderate_forum')) {
739
+			echo '
704 740
 				<th scope="col">', $txt['email'], '</th>';
741
+	}
705 742
 
706
-	if (!empty($context['custom_pf']))
707
-		foreach ($context['custom_pf'] as $column)
743
+	if (!empty($context['custom_pf'])) {
744
+			foreach ($context['custom_pf'] as $column)
708 745
 				echo '<th scope="col">', $column['label'], '</th>';
746
+	}
709 747
 
710 748
 	echo '
711 749
 				<th scope="col">', $txt['remove'], '</th>
712 750
 			</tr>';
713 751
 
714 752
 	// If they don't have any buddies don't list them!
715
-	if (empty($context['buddies']))
716
-		echo '
753
+	if (empty($context['buddies'])) {
754
+			echo '
717 755
 			<tr class="windowbg">
718 756
 				<td colspan="', allowedTo('moderate_forum') ? '10' : '9', '"><strong>', $txt['no_buddies'], '</strong></td>
719 757
 			</tr>';
758
+	}
720 759
 
721 760
 		// Now loop through each buddy showing info on each.
722 761
 	else
@@ -728,15 +767,17 @@  discard block
 block discarded – undo
728 767
 					<td>', $buddy['link'], '</td>
729 768
 					<td><a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a></td>';
730 769
 
731
-			if ($buddy['show_email'])
732
-				echo '
770
+			if ($buddy['show_email']) {
771
+							echo '
733 772
 					<td><a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a></td>';
773
+			}
734 774
 
735 775
 			// Show the custom profile fields for this user.
736
-			if (!empty($context['custom_pf']))
737
-				foreach ($context['custom_pf'] as $key => $column)
776
+			if (!empty($context['custom_pf'])) {
777
+							foreach ($context['custom_pf'] as $key => $column)
738 778
 					echo '
739 779
 						<td class="lefttext">', $buddy['options'][$key], '</td>';
780
+			}
740 781
 
741 782
 			echo '
742 783
 					<td><a href="', $scripturl, '?action=profile;area=lists;sa=buddies;u=', $context['id_member'], ';remove=', $buddy['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['buddy_remove'], '"></span></a></td>
@@ -766,9 +807,10 @@  discard block
 block discarded – undo
766 807
 			</dl>
767 808
 		</div>';
768 809
 
769
-	if (!empty($context['token_check']))
770
-		echo '
810
+	if (!empty($context['token_check'])) {
811
+			echo '
771 812
 			<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
813
+	}
772 814
 
773 815
 	echo '
774 816
 		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -794,12 +836,13 @@  discard block
 block discarded – undo
794 836
 {
795 837
 	global $context, $scripturl, $txt;
796 838
 
797
-	if (!empty($context['saved_successful']))
798
-		echo '
839
+	if (!empty($context['saved_successful'])) {
840
+			echo '
799 841
 					<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
800
-	elseif (!empty($context['saved_failed']))
801
-		echo '
842
+	} elseif (!empty($context['saved_failed'])) {
843
+			echo '
802 844
 					<div class="errorbox">', $context['saved_failed'], '</div>';
845
+	}
803 846
 
804 847
 	echo '
805 848
 	<div id="edit_buddies">
@@ -813,20 +856,22 @@  discard block
 block discarded – undo
813 856
 				<th scope="col" class="quarter_table">', $txt['name'], '</th>
814 857
 				<th scope="col">', $txt['status'], '</th>';
815 858
 
816
-	if (allowedTo('moderate_forum'))
817
-		echo '
859
+	if (allowedTo('moderate_forum')) {
860
+			echo '
818 861
 				<th scope="col">', $txt['email'], '</th>';
862
+	}
819 863
 
820 864
 	echo '
821 865
 				<th scope="col">', $txt['ignore_remove'], '</th>
822 866
 			</tr>';
823 867
 
824 868
 	// If they don't have anyone on their ignore list, don't list it!
825
-	if (empty($context['ignore_list']))
826
-		echo '
869
+	if (empty($context['ignore_list'])) {
870
+			echo '
827 871
 			<tr class="windowbg">
828 872
 				<td colspan="', allowedTo('moderate_forum') ? '4' : '3', '"><strong>', $txt['no_ignore'], '</strong></td>
829 873
 			</tr>';
874
+	}
830 875
 
831 876
 	// Now loop through each buddy showing info on each.
832 877
 	foreach ($context['ignore_list'] as $member)
@@ -836,9 +881,10 @@  discard block
 block discarded – undo
836 881
 				<td>', $member['link'], '</td>
837 882
 				<td><a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a></td>';
838 883
 
839
-		if ($member['show_email'])
840
-			echo '
884
+		if ($member['show_email']) {
885
+					echo '
841 886
 				<td><a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a></td>';
887
+		}
842 888
 		echo '
843 889
 				<td><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['ignore_remove'], '"></span></a></td>
844 890
 			</tr>';
@@ -865,9 +911,10 @@  discard block
 block discarded – undo
865 911
 			</dl>
866 912
 		</div>';
867 913
 
868
-	if (!empty($context['token_check']))
869
-		echo '
914
+	if (!empty($context['token_check'])) {
915
+			echo '
870 916
 		<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
917
+	}
871 918
 
872 919
 	echo '
873 920
 		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -912,9 +959,10 @@  discard block
 block discarded – undo
912 959
 					<a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>';
913 960
 
914 961
 	// Second address detected?
915
-	if (!empty($context['last_ip2']))
916
-		echo '
962
+	if (!empty($context['last_ip2'])) {
963
+			echo '
917 964
 					, <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>';
965
+	}
918 966
 
919 967
 	echo '
920 968
 				</dd>';
@@ -979,9 +1027,10 @@  discard block
 block discarded – undo
979 1027
 				<h3 class="catbg">', $txt['whois_title'], ' ', $context['ip'], '</h3>
980 1028
 			</div>
981 1029
 			<div class="windowbg2 noup">';
982
-			foreach ($context['whois_servers'] as $server)
983
-			echo '
1030
+			foreach ($context['whois_servers'] as $server) {
1031
+						echo '
984 1032
 				<a href="', $server['url'], '" target="_blank" class="new_win"', isset($context['auto_whois_server']) && $context['auto_whois_server']['name'] == $server['name'] ? ' style="font-weight: bold;"' : '', '>', $server['name'], '</a><br>';
1033
+			}
985 1034
 			echo '
986 1035
 			</div>
987 1036
 			<br>';
@@ -992,10 +1041,10 @@  discard block
 block discarded – undo
992 1041
 		<div class="cat_bar">
993 1042
 			<h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3>
994 1043
 		</div>';
995
-	if (empty($context['ips']))
996
-		echo '
1044
+	if (empty($context['ips'])) {
1045
+			echo '
997 1046
 		<p class="windowbg2 description"><em>', $txt['no_members_from_ip'], '</em></p>';
998
-	else
1047
+	} else
999 1048
 	{
1000 1049
 		echo '
1001 1050
 		<table class="table_grid">
@@ -1008,12 +1057,13 @@  discard block
 block discarded – undo
1008 1057
 			<tbody>';
1009 1058
 
1010 1059
 		// Loop through each of the members and display them.
1011
-		foreach ($context['ips'] as $ip => $memberlist)
1012
-			echo '
1060
+		foreach ($context['ips'] as $ip => $memberlist) {
1061
+					echo '
1013 1062
 				<tr class="windowbg">
1014 1063
 					<td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td>
1015 1064
 					<td>', implode(', ', $memberlist), '</td>
1016 1065
 				</tr>';
1066
+		}
1017 1067
 
1018 1068
 		echo '
1019 1069
 			</tbody>
@@ -1059,8 +1109,7 @@  discard block
 block discarded – undo
1059 1109
 	{
1060 1110
 		echo '
1061 1111
 		<div class="information">', $txt['showPermissions_all'], '</div>';
1062
-	}
1063
-	else
1112
+	} else
1064 1113
 	{
1065 1114
 		echo '
1066 1115
 		<div class="information">',$txt['showPermissions_help'], '</div>
@@ -1074,9 +1123,10 @@  discard block
 block discarded – undo
1074 1123
 				</div>
1075 1124
 				<div class="windowbg smalltext">
1076 1125
 					', $txt['showPermissions_restricted_boards_desc'], ':<br>';
1077
-				foreach ($context['no_access_boards'] as $no_access_board)
1078
-					echo '
1126
+				foreach ($context['no_access_boards'] as $no_access_board) {
1127
+									echo '
1079 1128
 						<a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', ';
1129
+				}
1080 1130
 				echo '
1081 1131
 				</div>';
1082 1132
 		}
@@ -1108,12 +1158,13 @@  discard block
 block discarded – undo
1108 1158
 								</td>
1109 1159
 								<td class="smalltext">';
1110 1160
 
1111
-				if ($permission['is_denied'])
1112
-					echo '
1161
+				if ($permission['is_denied']) {
1162
+									echo '
1113 1163
 									<span class="alert">', $txt['showPermissions_denied'], ':&nbsp;', implode(', ', $permission['groups']['denied']), '</span>';
1114
-				else
1115
-					echo '
1164
+				} else {
1165
+									echo '
1116 1166
 									', $txt['showPermissions_given'], ':&nbsp;', implode(', ', $permission['groups']['allowed']);
1167
+				}
1117 1168
 
1118 1169
 					echo '
1119 1170
 								</td>
@@ -1123,10 +1174,10 @@  discard block
 block discarded – undo
1123 1174
 						</tbody>
1124 1175
 					</table>
1125 1176
 				</div><br>';
1126
-		}
1127
-		else
1128
-			echo '
1177
+		} else {
1178
+					echo '
1129 1179
 			<p class="windowbg2">', $txt['showPermissions_none_general'], '</p>';
1180
+		}
1130 1181
 
1131 1182
 		// Board permission section.
1132 1183
 		echo '
@@ -1136,14 +1187,16 @@  discard block
 block discarded – undo
1136 1187
 						<a id="board_permissions"></a>', $txt['showPermissions_select'], ':
1137 1188
 						<select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();">
1138 1189
 							<option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], '&nbsp;</option>';
1139
-				if (!empty($context['boards']))
1140
-					echo '
1190
+				if (!empty($context['boards'])) {
1191
+									echo '
1141 1192
 							<option value="" disabled>---------------------------</option>';
1193
+				}
1142 1194
 
1143 1195
 				// Fill the box with any local permission boards.
1144
-				foreach ($context['boards'] as $board)
1145
-					echo '
1196
+				foreach ($context['boards'] as $board) {
1197
+									echo '
1146 1198
 							<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>';
1199
+				}
1147 1200
 
1148 1201
 				echo '
1149 1202
 						</select>
@@ -1174,8 +1227,7 @@  discard block
 block discarded – undo
1174 1227
 				{
1175 1228
 					echo '
1176 1229
 							<span class="alert">', $txt['showPermissions_denied'], ':&nbsp;', implode(', ', $permission['groups']['denied']), '</span>';
1177
-				}
1178
-				else
1230
+				} else
1179 1231
 				{
1180 1232
 					echo '
1181 1233
 							', $txt['showPermissions_given'], ': &nbsp;', implode(', ', $permission['groups']['allowed']);
@@ -1187,10 +1239,10 @@  discard block
 block discarded – undo
1187 1239
 			echo '
1188 1240
 				</tbody>
1189 1241
 			</table>';
1190
-		}
1191
-		else
1192
-			echo '
1242
+		} else {
1243
+					echo '
1193 1244
 			<p class="windowbg2">', $txt['showPermissions_none_board'], '</p>';
1245
+		}
1194 1246
 	echo '
1195 1247
 			</div>
1196 1248
 		</div>';
@@ -1232,9 +1284,10 @@  discard block
 block discarded – undo
1232 1284
 			</div>';
1233 1285
 
1234 1286
 	// If they haven't post at all, don't draw the graph.
1235
-	if (empty($context['posts_by_time']))
1236
-		echo '
1287
+	if (empty($context['posts_by_time'])) {
1288
+			echo '
1237 1289
 			<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1290
+	}
1238 1291
 	// Otherwise do!
1239 1292
 	else
1240 1293
 	{
@@ -1273,11 +1326,10 @@  discard block
 block discarded – undo
1273 1326
 					</h3>
1274 1327
 				</div>';
1275 1328
 
1276
-	if (empty($context['popular_boards']))
1277
-		echo '
1329
+	if (empty($context['popular_boards'])) {
1330
+			echo '
1278 1331
 				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1279
-
1280
-	else
1332
+	} else
1281 1333
 	{
1282 1334
 		echo '
1283 1335
 				<dl class="stats">';
@@ -1308,10 +1360,10 @@  discard block
 block discarded – undo
1308 1360
 					</h3>
1309 1361
 				</div>';
1310 1362
 
1311
-	if (empty($context['board_activity']))
1312
-		echo '
1363
+	if (empty($context['board_activity'])) {
1364
+			echo '
1313 1365
 				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1314
-	else
1366
+	} else
1315 1367
 	{
1316 1368
 		echo '
1317 1369
 				<dl class="stats">';
@@ -1359,41 +1411,46 @@  discard block
 block discarded – undo
1359 1411
 				<h3 class="catbg profile_hd">';
1360 1412
 
1361 1413
 		// Don't say "Profile" if this isn't the profile...
1362
-		if (!empty($context['profile_header_text']))
1363
-			echo '
1414
+		if (!empty($context['profile_header_text'])) {
1415
+					echo '
1364 1416
 					', $context['profile_header_text'];
1365
-		else
1366
-			echo '
1417
+		} else {
1418
+					echo '
1367 1419
 					', $txt['profile'];
1420
+		}
1368 1421
 
1369 1422
 		echo '
1370 1423
 				</h3>
1371 1424
 			</div>';
1372 1425
 
1373 1426
 	// Have we some description?
1374
-	if ($context['page_desc'])
1375
-		echo '
1427
+	if ($context['page_desc']) {
1428
+			echo '
1376 1429
 			<p class="information">', $context['page_desc'], '</p>';
1430
+	}
1377 1431
 
1378 1432
 	echo '
1379 1433
 			<div class="roundframe">';
1380 1434
 
1381 1435
 	// Any bits at the start?
1382
-	if (!empty($context['profile_prehtml']))
1383
-		echo '
1436
+	if (!empty($context['profile_prehtml'])) {
1437
+			echo '
1384 1438
 				<div>', $context['profile_prehtml'], '</div>';
1439
+	}
1385 1440
 
1386
-	if (!empty($context['profile_fields']))
1387
-		echo '
1441
+	if (!empty($context['profile_fields'])) {
1442
+			echo '
1388 1443
 				<dl class="settings">';
1444
+	}
1389 1445
 
1390 1446
 	// Start the big old loop 'of love.
1391 1447
 	$lastItem = 'hr';
1392 1448
 	foreach ($context['profile_fields'] as $key => $field)
1393 1449
 	{
1394 1450
 		// We add a little hack to be sure we never get more than one hr in a row!
1395
-		if ($lastItem == 'hr' && $field['type'] == 'hr')
1396
-			continue;
1451
+		if ($lastItem == 'hr' && $field['type'] == 'hr') {
1452
+					continue;
1453
+		}
1397 1454
 
1398 1455
 		$lastItem = $field['type'];
1399 1456
 		if ($field['type'] == 'hr')
@@ -1402,48 +1459,50 @@  discard block
 block discarded – undo
1402 1459
 				</dl>
1403 1460
 				<hr>
1404 1461
 				<dl class="settings">';
1405
-		}
1406
-		elseif ($field['type'] == 'callback')
1462
+		} elseif ($field['type'] == 'callback')
1407 1463
 		{
1408 1464
 			if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func']))
1409 1465
 			{
1410 1466
 				$callback_func = 'template_profile_' . $field['callback_func'];
1411 1467
 				$callback_func();
1412 1468
 			}
1413
-		}
1414
-		else
1469
+		} else
1415 1470
 		{
1416 1471
 			echo '
1417 1472
 					<dt>
1418 1473
 						<strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>';
1419 1474
 
1420 1475
 			// Does it have any subtext to show?
1421
-			if (!empty($field['subtext']))
1422
-				echo '
1476
+			if (!empty($field['subtext'])) {
1477
+							echo '
1423 1478
 						<br>
1424 1479
 						<span class="smalltext">', $field['subtext'], '</span>';
1480
+			}
1425 1481
 
1426 1482
 			echo '
1427 1483
 					</dt>
1428 1484
 					<dd>';
1429 1485
 
1430 1486
 			// Want to put something infront of the box?
1431
-			if (!empty($field['preinput']))
1432
-				echo '
1487
+			if (!empty($field['preinput'])) {
1488
+							echo '
1433 1489
 						', $field['preinput'];
1490
+			}
1434 1491
 
1435 1492
 			// What type of data are we showing?
1436
-			if ($field['type'] == 'label')
1437
-				echo '
1493
+			if ($field['type'] == 'label') {
1494
+							echo '
1438 1495
 						', $field['value'];
1496
+			}
1439 1497
 
1440 1498
 			// Maybe it's a text box - very likely!
1441 1499
 			elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url')))
1442 1500
 			{
1443
-				if ($field['type'] == 'int' || $field['type'] == 'float')
1444
-					$type = 'number';
1445
-				else
1446
-					$type = $field['type'];
1501
+				if ($field['type'] == 'int' || $field['type'] == 'float') {
1502
+									$type = 'number';
1503
+				} else {
1504
+									$type = $field['type'];
1505
+				}
1447 1506
 				$step = $field['type'] == 'float' ? ' step="0.1"' : '';
1448 1507
 
1449 1508
 
@@ -1451,9 +1510,10 @@  discard block
 block discarded – undo
1451 1510
 						<input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' class="input_', $field['type'] == 'password' ? 'password' : 'text', '"', $step, '>';
1452 1511
 			}
1453 1512
 			// You "checking" me out? ;)
1454
-			elseif ($field['type'] == 'check')
1455
-				echo '
1513
+			elseif ($field['type'] == 'check') {
1514
+							echo '
1456 1515
 						<input type="hidden" name="', $key, '" value="0"><input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" class="input_check" ', $field['input_attr'], '>';
1516
+			}
1457 1517
 
1458 1518
 			// Always fun - select boxes!
1459 1519
 			elseif ($field['type'] == 'select')
@@ -1464,13 +1524,15 @@  discard block
 block discarded – undo
1464 1524
 				if (isset($field['options']))
1465 1525
 				{
1466 1526
 					// Is this some code to generate the options?
1467
-					if (!is_array($field['options']))
1468
-						$field['options'] = $field['options']();
1527
+					if (!is_array($field['options'])) {
1528
+											$field['options'] = $field['options']();
1529
+					}
1469 1530
 					// Assuming we now have some!
1470
-					if (is_array($field['options']))
1471
-						foreach ($field['options'] as $value => $name)
1531
+					if (is_array($field['options'])) {
1532
+											foreach ($field['options'] as $value => $name)
1472 1533
 							echo '
1473 1534
 								<option value="', $value, '"', $value == $field['value'] ? ' selected' : '', '>', $name, '</option>';
1535
+					}
1474 1536
 				}
1475 1537
 
1476 1538
 				echo '
@@ -1478,25 +1540,28 @@  discard block
 block discarded – undo
1478 1540
 			}
1479 1541
 
1480 1542
 			// Something to end with?
1481
-			if (!empty($field['postinput']))
1482
-				echo '
1543
+			if (!empty($field['postinput'])) {
1544
+							echo '
1483 1545
 							', $field['postinput'];
1546
+			}
1484 1547
 
1485 1548
 			echo '
1486 1549
 					</dd>';
1487 1550
 		}
1488 1551
 	}
1489 1552
 
1490
-	if (!empty($context['profile_fields']))
1491
-		echo '
1553
+	if (!empty($context['profile_fields'])) {
1554
+			echo '
1492 1555
 				</dl>';
1556
+	}
1493 1557
 
1494 1558
 	// Are there any custom profile fields - if so print them!
1495 1559
 	if (!empty($context['custom_fields']))
1496 1560
 	{
1497
-		if ($lastItem != 'hr')
1498
-			echo '
1561
+		if ($lastItem != 'hr') {
1562
+					echo '
1499 1563
 				<hr>';
1564
+		}
1500 1565
 
1501 1566
 		echo '
1502 1567
 				<dl class="settings">';
@@ -1519,13 +1584,14 @@  discard block
 block discarded – undo
1519 1584
 	}
1520 1585
 
1521 1586
 	// Any closing HTML?
1522
-	if (!empty($context['profile_posthtml']))
1523
-		echo '
1587
+	if (!empty($context['profile_posthtml'])) {
1588
+			echo '
1524 1589
 				<div>', $context['profile_posthtml'], '</div>';
1590
+	}
1525 1591
 
1526 1592
 	// Only show the password box if it's actually needed.
1527
-	if ($context['require_password'])
1528
-		echo '
1593
+	if ($context['require_password']) {
1594
+			echo '
1529 1595
 				<dl class="settings">
1530 1596
 					<dt>
1531 1597
 						<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br>
@@ -1535,18 +1601,21 @@  discard block
 block discarded – undo
1535 1601
 						<input type="password" name="oldpasswrd" id="oldpasswrd" size="20" style="margin-right: 4ex;" class="input_password">
1536 1602
 					</dd>
1537 1603
 				</dl>';
1604
+	}
1538 1605
 
1539 1606
 	// The button shouldn't say "Change profile" unless we're changing the profile...
1540
-	if (!empty($context['submit_button_text']))
1541
-		echo '
1607
+	if (!empty($context['submit_button_text'])) {
1608
+			echo '
1542 1609
 				<input type="submit" name="save" value="', $context['submit_button_text'], '" class="button_submit">';
1543
-	else
1544
-		echo '
1610
+	} else {
1611
+			echo '
1545 1612
 				<input type="submit" name="save" value="', $txt['change_profile'], '" class="button_submit">';
1613
+	}
1546 1614
 
1547
-	if (!empty($context['token_check']))
1548
-		echo '
1615
+	if (!empty($context['token_check'])) {
1616
+			echo '
1549 1617
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
1618
+	}
1550 1619
 
1551 1620
 	echo '
1552 1621
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -1556,10 +1625,11 @@  discard block
 block discarded – undo
1556 1625
 		</form>';
1557 1626
 
1558 1627
 	// Any final spellchecking stuff?
1559
-	if (!empty($context['show_spellchecking']))
1560
-		echo '
1628
+	if (!empty($context['show_spellchecking'])) {
1629
+			echo '
1561 1630
 		<form name="spell_form" id="spell_form" method="post" accept-charset="', $context['character_set'], '" target="spellWindow" action="', $scripturl, '?action=spellcheck"><input type="hidden" name="spellstring" value=""></form>';
1562
-}
1631
+	}
1632
+	}
1563 1633
 
1564 1634
 /**
1565 1635
  * Personal Message settings.
@@ -1596,10 +1666,11 @@  discard block
 block discarded – undo
1596 1666
 										<select name="pm_receive_from" id="pm_receive_from">
1597 1667
 												<option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>';
1598 1668
 
1599
-	if (!empty($modSettings['enable_buddylist']))
1600
-		echo '
1669
+	if (!empty($modSettings['enable_buddylist'])) {
1670
+			echo '
1601 1671
 												<option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option>
1602 1672
 												<option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>';
1673
+	}
1603 1674
 
1604 1675
 	echo '
1605 1676
 												<option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option>
@@ -1642,11 +1713,12 @@  discard block
 block discarded – undo
1642 1713
 		if (empty($setting) || !is_array($setting))
1643 1714
 		{
1644 1715
 			// Insert a separator (unless this is the first item in the list)
1645
-			if ($i !== $first_option_key)
1646
-				echo '
1716
+			if ($i !== $first_option_key) {
1717
+							echo '
1647 1718
 				</dl>
1648 1719
 				<hr>
1649 1720
 				<dl class="settings">';
1721
+			}
1650 1722
 
1651 1723
 			// Should we give a name to this section?
1652 1724
 			if (is_string($setting) && !empty($setting))
@@ -1654,48 +1726,52 @@  discard block
 block discarded – undo
1654 1726
 				$titled_section = true;
1655 1727
 				echo '
1656 1728
 					<dt><b>' . $setting . '</b></dt><dd></dd>';
1729
+			} else {
1730
+							$titled_section = false;
1657 1731
 			}
1658
-			else
1659
-				$titled_section = false;
1660 1732
 
1661 1733
 			continue;
1662 1734
 		}
1663 1735
 
1664 1736
 		// Is this disabled?
1665
-		if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled']))
1666
-			continue;
1667
-		elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage']))
1668
-			continue;
1669
-		elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored']))
1670
-			continue;
1671
-		elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist']))
1672
-			continue;
1673
-		elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg']))
1674
-			continue;
1675
-		elseif ($setting['id'] == 'topics_per_page' && !empty($modSettings['disableCustomPerPage']))
1676
-			continue;
1677
-		elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled']))))
1678
-			continue;
1679
-		elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled']))))
1680
-			continue;
1737
+		if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) {
1738
+					continue;
1739
+		} elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) {
1740
+					continue;
1741
+		} elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) {
1742
+					continue;
1743
+		} elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) {
1744
+					continue;
1745
+		} elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) {
1746
+					continue;
1747
+		} elseif ($setting['id'] == 'topics_per_page' && !empty($modSettings['disableCustomPerPage'])) {
1748
+					continue;
1749
+		} elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) {
1750
+					continue;
1751
+		} elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) {
1752
+					continue;
1753
+		}
1681 1754
 
1682
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
1683
-			$setting['type'] = 'checkbox';
1684
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
1685
-			$setting['type'] = 'number';
1686
-		elseif ($setting['type'] == 'string')
1687
-			$setting['type'] = 'text';
1755
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
1756
+					$setting['type'] = 'checkbox';
1757
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
1758
+					$setting['type'] = 'number';
1759
+		} elseif ($setting['type'] == 'string') {
1760
+					$setting['type'] = 'text';
1761
+		}
1688 1762
 
1689
-		if (isset($setting['options']))
1690
-			$setting['type'] = 'list';
1763
+		if (isset($setting['options'])) {
1764
+					$setting['type'] = 'list';
1765
+		}
1691 1766
 
1692 1767
 		echo '
1693 1768
 					<dt>
1694 1769
 						<label for="', $setting['id'], '">', !$titled_section ? '<b>' : '', $setting['label'], !$titled_section ? '</b>' : '', '</label>';
1695 1770
 
1696
-		if (isset($setting['description']))
1697
-			echo '
1771
+		if (isset($setting['description'])) {
1772
+					echo '
1698 1773
 						<br><span class="smalltext">', $setting['description'], '</span>';
1774
+		}
1699 1775
 		echo '
1700 1776
 					</dt>
1701 1777
 					<dd>';
@@ -1733,13 +1809,11 @@  discard block
 block discarded – undo
1733 1809
 
1734 1810
 				echo '
1735 1811
 						<input type="number"', $min . $max . $step;
1736
-			}
1737
-			else if (isset($setting['type']) && $setting['type'] == 'url')
1812
+			} else if (isset($setting['type']) && $setting['type'] == 'url')
1738 1813
 			{
1739 1814
 				echo'
1740 1815
 						<input type="url"';
1741
-			}
1742
-			else
1816
+			} else
1743 1817
 			{
1744 1818
 				echo '
1745 1819
 						<input type="text"';
@@ -1778,8 +1852,8 @@  discard block
 block discarded – undo
1778 1852
 				<dl class="settings">';
1779 1853
 
1780 1854
 	// Allow notification on announcements to be disabled?
1781
-	if (!empty($modSettings['allow_disableAnnounce']))
1782
-		echo '
1855
+	if (!empty($modSettings['allow_disableAnnounce'])) {
1856
+			echo '
1783 1857
 					<dt>
1784 1858
 						<label for="notify_announcements">', $txt['notify_important_email'], '</label>
1785 1859
 					</dt>
@@ -1787,9 +1861,10 @@  discard block
 block discarded – undo
1787 1861
 						<input type="hidden" name="notify_announcements" value="0">
1788 1862
 						<input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', ' class="input_check">
1789 1863
 					</dd>';
1864
+	}
1790 1865
 
1791
-	if (!empty($modSettings['enable_ajax_alerts']))
1792
-		echo '
1866
+	if (!empty($modSettings['enable_ajax_alerts'])) {
1867
+			echo '
1793 1868
 					<dt>
1794 1869
 						<label for="notify_send_body">', $txt['notify_alert_timeout'], '</label>
1795 1870
 					</dt>
@@ -1797,6 +1872,7 @@  discard block
 block discarded – undo
1797 1872
 						<input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '" class="input_text">
1798 1873
 					</dd>
1799 1874
 		';
1875
+	}
1800 1876
 
1801 1877
 	echo '
1802 1878
 				</dl>
@@ -1826,9 +1902,10 @@  discard block
 block discarded – undo
1826 1902
 					<td colspan="3">';
1827 1903
 				$label = $txt['alert_opt_' . $opts[1]];
1828 1904
 				$label_pos = isset($opts['label']) ? $opts['label'] : '';
1829
-				if ($label_pos == 'before')
1830
-					echo '
1905
+				if ($label_pos == 'before') {
1906
+									echo '
1831 1907
 					<label for="opt_', $opts[1], '">', $label, '</label>';
1908
+				}
1832 1909
 
1833 1910
 				$this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0;
1834 1911
 				switch ($opts[0])
@@ -1840,17 +1917,19 @@  discard block
 block discarded – undo
1840 1917
 					case 'select':
1841 1918
 						echo '
1842 1919
 						<select name="opt_', $opts[1], '" id="opt_', $opts[1], '">';
1843
-						foreach ($opts['opts'] as $k => $v)
1844
-							echo '
1920
+						foreach ($opts['opts'] as $k => $v) {
1921
+													echo '
1845 1922
 							<option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>';
1923
+						}
1846 1924
 						echo '
1847 1925
 						</select>';
1848 1926
 						break;
1849 1927
 				}
1850 1928
 
1851
-				if ($label_pos == 'after')
1852
-					echo '
1929
+				if ($label_pos == 'after') {
1930
+									echo '
1853 1931
 					<label for="opt_', $opts[1], '">', $label, '</label>';
1932
+				}
1854 1933
 
1855 1934
 				echo '
1856 1935
 					</td>
@@ -1964,11 +2043,12 @@  discard block
 block discarded – undo
1964 2043
 			<p class="information">', $txt['groupMembership_info'], '</p>';
1965 2044
 
1966 2045
 	// Do we have an update message?
1967
-	if (!empty($context['update_message']))
1968
-		echo '
2046
+	if (!empty($context['update_message'])) {
2047
+			echo '
1969 2048
 			<div class="infobox">
1970 2049
 				', $context['update_message'], '.
1971 2050
 			</div>';
2051
+	}
1972 2052
 
1973 2053
 	echo '
1974 2054
 		<div id="groups">';
@@ -1990,8 +2070,7 @@  discard block
 block discarded – undo
1990 2070
 					</div>
1991 2071
 				</div>
1992 2072
 			</div>';
1993
-	}
1994
-	else
2073
+	} else
1995 2074
 	{
1996 2075
 		echo '
1997 2076
 			<div class="title_bar">
@@ -2003,27 +2082,30 @@  discard block
 block discarded – undo
2003 2082
 			echo '
2004 2083
 					<div class="windowbg" id="primdiv_', $group['id'], '">';
2005 2084
 
2006
-				if ($context['can_edit_primary'])
2007
-					echo '
2085
+				if ($context['can_edit_primary']) {
2086
+									echo '
2008 2087
 						<input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '"', $group['is_primary'] ? ' checked' : '', ' onclick="highlightSelected(\'primdiv_' . $group['id'] . '\');"', $group['can_be_primary'] ? '' : ' disabled', ' class="input_radio">';
2088
+				}
2009 2089
 
2010 2090
 				echo '
2011 2091
 						<label for="primary_', $group['id'], '"><strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '</label>';
2012 2092
 
2013 2093
 				// Can they leave their group?
2014
-				if ($group['can_leave'])
2015
-					echo '
2094
+				if ($group['can_leave']) {
2095
+									echo '
2016 2096
 						<a href="' . $scripturl . '?action=profile;save;u=' . $context['id_member'] . ';area=groupmembership;' . $context['session_var'] . '=' . $context['session_id'] . ';gid=' . $group['id'] . ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">' . $txt['leave_group'] . '</a>';
2097
+				}
2017 2098
 
2018 2099
 				echo '
2019 2100
 					</div>';
2020 2101
 		}
2021 2102
 
2022
-		if ($context['can_edit_primary'])
2023
-			echo '
2103
+		if ($context['can_edit_primary']) {
2104
+					echo '
2024 2105
 			<div class="padding righttext">
2025 2106
 				<input type="submit" value="', $txt['make_primary'], '" class="button_submit">
2026 2107
 			</div>';
2108
+		}
2027 2109
 
2028 2110
 		// Any groups they can join?
2029 2111
 		if (!empty($context['groups']['available']))
@@ -2039,15 +2121,16 @@  discard block
 block discarded – undo
2039 2121
 					<div class="windowbg">
2040 2122
 						<strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '';
2041 2123
 
2042
-				if ($group['type'] == 3)
2043
-					echo '
2124
+				if ($group['type'] == 3) {
2125
+									echo '
2044 2126
 						<a href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '" class="button floatright">', $txt['join_group'], '</a>';
2045
-				elseif ($group['type'] == 2 && $group['pending'])
2046
-					echo '
2127
+				} elseif ($group['type'] == 2 && $group['pending']) {
2128
+									echo '
2047 2129
 						<span class="floatright">', $txt['approval_pending'], '</span>';
2048
-				elseif ($group['type'] == 2)
2049
-					echo '
2130
+				} elseif ($group['type'] == 2) {
2131
+									echo '
2050 2132
 						<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>';
2133
+				}
2051 2134
 
2052 2135
 				echo '
2053 2136
 					</div>';
@@ -2070,9 +2153,10 @@  discard block
 block discarded – undo
2070 2153
 
2071 2154
 			prevDiv.className = "windowbg";
2072 2155
 		}';
2073
-		if (isset($context['groups']['member'][$context['primary_group']]))
2074
-			echo '
2156
+		if (isset($context['groups']['member'][$context['primary_group']])) {
2157
+					echo '
2075 2158
 		highlightSelected("primdiv_' . $context['primary_group'] . '");';
2159
+		}
2076 2160
 		echo '
2077 2161
 	</script>';
2078 2162
 	}
@@ -2080,9 +2164,10 @@  discard block
 block discarded – undo
2080 2164
 	echo '
2081 2165
 		</div>';
2082 2166
 
2083
-	if (!empty($context['token_check']))
2084
-		echo '
2167
+	if (!empty($context['token_check'])) {
2168
+			echo '
2085 2169
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2170
+	}
2086 2171
 
2087 2172
 	echo '
2088 2173
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2129,14 +2214,15 @@  discard block
 block discarded – undo
2129 2214
 
2130 2215
 		foreach ($category['boards'] as $board)
2131 2216
 		{
2132
-			if ($i == $limit)
2133
-				echo '
2217
+			if ($i == $limit) {
2218
+							echo '
2134 2219
 						</ul>
2135 2220
 					</li>
2136 2221
 				</ul>
2137 2222
 				<ul class="ignoreboards floatright">
2138 2223
 					<li class="category">
2139 2224
 						<ul>';
2225
+			}
2140 2226
 
2141 2227
 			echo '
2142 2228
 							<li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
@@ -2182,10 +2268,11 @@  discard block
 block discarded – undo
2182 2268
 
2183 2269
 	// Work out the starting color.
2184 2270
 	$context['current_color'] = $context['colors'][0];
2185
-	foreach ($context['colors'] as $limit => $color)
2186
-		if ($context['member']['warning'] >= $limit)
2271
+	foreach ($context['colors'] as $limit => $color) {
2272
+			if ($context['member']['warning'] >= $limit)
2187 2273
 			$context['current_color'] = $color;
2188
-}
2274
+	}
2275
+	}
2189 2276
 
2190 2277
 // Show all warnings of a user?
2191 2278
 function template_viewWarning()
@@ -2224,14 +2311,15 @@  discard block
 block discarded – undo
2224 2311
 				</dd>';
2225 2312
 
2226 2313
 		// There's some impact of this?
2227
-		if (!empty($context['level_effects'][$context['current_level']]))
2228
-			echo '
2314
+		if (!empty($context['level_effects'][$context['current_level']])) {
2315
+					echo '
2229 2316
 				<dt>
2230 2317
 					<strong>', $txt['profile_viewwarning_impact'], ':</strong>
2231 2318
 				</dt>
2232 2319
 				<dd>
2233 2320
 					', $context['level_effects'][$context['current_level']], '
2234 2321
 				</dd>';
2322
+		}
2235 2323
 
2236 2324
 		echo '
2237 2325
 			</dl>
@@ -2269,10 +2357,11 @@  discard block
 block discarded – undo
2269 2357
 
2270 2358
 			// Otherwise see what we can do...';
2271 2359
 
2272
-	foreach ($context['notification_templates'] as $k => $type)
2273
-		echo '
2360
+	foreach ($context['notification_templates'] as $k => $type) {
2361
+			echo '
2274 2362
 			if (index == ', $k, ')
2275 2363
 				document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";';
2364
+	}
2276 2365
 
2277 2366
 	echo '
2278 2367
 		}
@@ -2282,10 +2371,11 @@  discard block
 block discarded – undo
2282 2371
 			// Also set the right effect.
2283 2372
 			effectText = "";';
2284 2373
 
2285
-	foreach ($context['level_effects'] as $limit => $text)
2286
-		echo '
2374
+	foreach ($context['level_effects'] as $limit => $text) {
2375
+			echo '
2287 2376
 			if (slideAmount >= ', $limit, ')
2288 2377
 				effectText = "', $text, '";';
2378
+	}
2289 2379
 
2290 2380
 	echo '
2291 2381
 			setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\');
@@ -2300,31 +2390,34 @@  discard block
 block discarded – undo
2300 2390
 			</h3>
2301 2391
 		</div>';
2302 2392
 
2303
-	if (!$context['user']['is_owner'])
2304
-		echo '
2393
+	if (!$context['user']['is_owner']) {
2394
+			echo '
2305 2395
 		<p class="information">', $txt['profile_warning_desc'], '</p>';
2396
+	}
2306 2397
 
2307 2398
 	echo '
2308 2399
 		<div class="windowbg">
2309 2400
 			<dl class="settings">';
2310 2401
 
2311
-	if (!$context['user']['is_owner'])
2312
-		echo '
2402
+	if (!$context['user']['is_owner']) {
2403
+			echo '
2313 2404
 				<dt>
2314 2405
 					<strong>', $txt['profile_warning_name'], ':</strong>
2315 2406
 				</dt>
2316 2407
 				<dd>
2317 2408
 					<strong>', $context['member']['name'], '</strong>
2318 2409
 				</dd>';
2410
+	}
2319 2411
 
2320 2412
 	echo '
2321 2413
 				<dt>
2322 2414
 					<strong>', $txt['profile_warning_level'], ':</strong>';
2323 2415
 
2324 2416
 	// Is there only so much they can apply?
2325
-	if ($context['warning_limit'])
2326
-		echo '
2417
+	if ($context['warning_limit']) {
2418
+			echo '
2327 2419
 					<br><span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>';
2420
+	}
2328 2421
 
2329 2422
 	echo '
2330 2423
 				</dt>
@@ -2377,9 +2470,10 @@  discard block
 block discarded – undo
2377 2470
 						<option value="-1">', $txt['profile_warning_notify_template'], '</option>
2378 2471
 						<option value="-1" disabled>------------------------------</option>';
2379 2472
 
2380
-		foreach ($context['notification_templates'] as $id_template => $template)
2381
-			echo '
2473
+		foreach ($context['notification_templates'] as $id_template => $template) {
2474
+					echo '
2382 2475
 						<option value="', $id_template, '">', $template['title'], '</option>';
2476
+		}
2383 2477
 
2384 2478
 		echo '
2385 2479
 					</select>
@@ -2391,9 +2485,10 @@  discard block
 block discarded – undo
2391 2485
 			</dl>
2392 2486
 			<div class="righttext">';
2393 2487
 
2394
-	if (!empty($context['token_check']))
2395
-		echo '
2488
+	if (!empty($context['token_check'])) {
2489
+			echo '
2396 2490
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2491
+	}
2397 2492
 
2398 2493
 	echo '
2399 2494
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2409,8 +2504,8 @@  discard block
 block discarded – undo
2409 2504
 	echo '
2410 2505
 	<script>';
2411 2506
 
2412
-	if (!$context['user']['is_owner'])
2413
-		echo '
2507
+	if (!$context['user']['is_owner']) {
2508
+			echo '
2414 2509
 		modifyWarnNotify();
2415 2510
 		$(document).ready(function() {
2416 2511
 			$("#preview_button").click(function() {
@@ -2449,6 +2544,7 @@  discard block
 block discarded – undo
2449 2544
 			});
2450 2545
 			return false;
2451 2546
 		}';
2547
+	}
2452 2548
 
2453 2549
 	echo '
2454 2550
 	</script>';
@@ -2471,16 +2567,18 @@  discard block
 block discarded – undo
2471 2567
 			</div>';
2472 2568
 
2473 2569
 	// If deleting another account give them a lovely info box.
2474
-	if (!$context['user']['is_owner'])
2475
-		echo '
2570
+	if (!$context['user']['is_owner']) {
2571
+			echo '
2476 2572
 			<p class="information">', $txt['deleteAccount_desc'], '</p>';
2573
+	}
2477 2574
 	echo '
2478 2575
 			<div class="windowbg2">';
2479 2576
 
2480 2577
 	// If they are deleting their account AND the admin needs to approve it - give them another piece of info ;)
2481
-	if ($context['needs_approval'])
2482
-		echo '
2578
+	if ($context['needs_approval']) {
2579
+			echo '
2483 2580
 				<div class="errorbox">', $txt['deleteAccount_approval'], '</div>';
2581
+	}
2484 2582
 
2485 2583
 	// If the user is deleting their own account warn them first - and require a password!
2486 2584
 	if ($context['user']['is_owner'])
@@ -2492,9 +2590,10 @@  discard block
 block discarded – undo
2492 2590
 					<input type="password" name="oldpasswrd" size="20" class="input_password">&nbsp;&nbsp;&nbsp;&nbsp;
2493 2591
 					<input type="submit" value="', $txt['yes'], '" class="button_submit">';
2494 2592
 
2495
-		if (!empty($context['token_check']))
2496
-			echo '
2593
+		if (!empty($context['token_check'])) {
2594
+					echo '
2497 2595
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2596
+		}
2498 2597
 
2499 2598
 		echo '
2500 2599
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2520,9 +2619,10 @@  discard block
 block discarded – undo
2520 2619
 						<option value="topics">', $txt['deleteAccount_topics'], '</option>
2521 2620
 					</select>';
2522 2621
 
2523
-			if ($context['show_perma_delete'])
2524
-				echo '
2622
+			if ($context['show_perma_delete']) {
2623
+							echo '
2525 2624
 					<br><label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1" class="input_check">', $txt['deleteAccount_permanent'], ':</label>';
2625
+			}
2526 2626
 
2527 2627
 			echo '
2528 2628
 				</div>';
@@ -2535,9 +2635,10 @@  discard block
 block discarded – undo
2535 2635
 				<div>
2536 2636
 					<input type="submit" value="', $txt['delete'], '" class="button_submit">';
2537 2637
 
2538
-		if (!empty($context['token_check']))
2539
-			echo '
2638
+		if (!empty($context['token_check'])) {
2639
+					echo '
2540 2640
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2641
+		}
2541 2642
 
2542 2643
 		echo '
2543 2644
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2563,8 +2664,8 @@  discard block
 block discarded – undo
2563 2664
 					<hr>';
2564 2665
 
2565 2666
 	// Only show the password box if it's actually needed.
2566
-	if ($context['require_password'])
2567
-		echo '
2667
+	if ($context['require_password']) {
2668
+			echo '
2568 2669
 					<dl class="settings">
2569 2670
 						<dt>
2570 2671
 							<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br>
@@ -2574,13 +2675,15 @@  discard block
 block discarded – undo
2574 2675
 							<input type="password" name="oldpasswrd" size="20" style="margin-right: 4ex;" class="input_password">
2575 2676
 						</dd>
2576 2677
 					</dl>';
2678
+	}
2577 2679
 
2578 2680
 	echo '
2579 2681
 					<div class="righttext">';
2580 2682
 
2581
-		if (!empty($context['token_check']))
2582
-			echo '
2683
+		if (!empty($context['token_check'])) {
2684
+					echo '
2583 2685
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2686
+		}
2584 2687
 
2585 2688
 	echo '
2586 2689
 						<input type="submit" value="', $txt['change_profile'], '" class="button_submit">
@@ -2607,9 +2710,10 @@  discard block
 block discarded – undo
2607 2710
 			<ul id="list_errors">';
2608 2711
 
2609 2712
 		// Cycle through each error and display an error message.
2610
-		foreach ($context['post_errors'] as $error)
2611
-			echo '
2713
+		foreach ($context['post_errors'] as $error) {
2714
+					echo '
2612 2715
 				<li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>';
2716
+		}
2613 2717
 
2614 2718
 		echo '
2615 2719
 			</ul>';
@@ -2635,12 +2739,13 @@  discard block
 block discarded – undo
2635 2739
 								<select name="id_group" ', ($context['user']['is_owner'] && $context['member']['group_id'] == 1 ? 'onchange="if (this.value != 1 &amp;&amp; !confirm(\'' . $txt['deadmin_confirm'] . '\')) this.value = 1;"' : ''), '>';
2636 2740
 
2637 2741
 		// Fill the select box with all primary member groups that can be assigned to a member.
2638
-		foreach ($context['member_groups'] as $member_group)
2639
-			if (!empty($member_group['can_be_primary']))
2742
+		foreach ($context['member_groups'] as $member_group) {
2743
+					if (!empty($member_group['can_be_primary']))
2640 2744
 				echo '
2641 2745
 									<option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '>
2642 2746
 										', $member_group['name'], '
2643 2747
 									</option>';
2748
+		}
2644 2749
 		echo '
2645 2750
 								</select>
2646 2751
 							</dd>
@@ -2652,10 +2757,11 @@  discard block
 block discarded – undo
2652 2757
 									<input type="hidden" name="additional_groups[]" value="0">';
2653 2758
 
2654 2759
 		// For each membergroup show a checkbox so members can be assigned to more than one group.
2655
-		foreach ($context['member_groups'] as $member_group)
2656
-			if ($member_group['can_be_additional'])
2760
+		foreach ($context['member_groups'] as $member_group) {
2761
+					if ($member_group['can_be_additional'])
2657 2762
 				echo '
2658 2763
 									<label for="additional_groups-', $member_group['id'], '"><input type="checkbox" name="additional_groups[]" value="', $member_group['id'], '" id="additional_groups-', $member_group['id'], '"', $member_group['is_additional'] ? ' checked' : '', ' class="input_check"> ', $member_group['name'], '</label><br>';
2764
+		}
2659 2765
 		echo '
2660 2766
 								</span>
2661 2767
 								<a href="javascript:void(0);" onclick="document.getElementById(\'additional_groupsList\').style.display = \'block\'; document.getElementById(\'additional_groupsLink\').style.display = \'none\'; return false;" id="additional_groupsLink" style="display: none;" class="toggle_down">', $txt['additional_membergroups_show'], '</a>
@@ -2715,9 +2821,10 @@  discard block
 block discarded – undo
2715 2821
 								<span class="smalltext">', $txt['sig_info'], '</span><br>
2716 2822
 								<br>';
2717 2823
 
2718
-	if ($context['show_spellchecking'])
2719
-		echo '
2824
+	if ($context['show_spellchecking']) {
2825
+			echo '
2720 2826
 								<input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button_submit">';
2827
+	}
2721 2828
 
2722 2829
 		echo '
2723 2830
 							</dt>
@@ -2725,17 +2832,20 @@  discard block
 block discarded – undo
2725 2832
 								<textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50" style="min-width: 50%; max-width: 99%;">', $context['member']['signature'], '</textarea><br>';
2726 2833
 
2727 2834
 	// If there is a limit at all!
2728
-	if (!empty($context['signature_limits']['max_length']))
2729
-		echo '
2835
+	if (!empty($context['signature_limits']['max_length'])) {
2836
+			echo '
2730 2837
 								<span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>';
2838
+	}
2731 2839
 
2732
-	if (!empty($context['show_preview_button']))
2733
-		echo '
2840
+	if (!empty($context['show_preview_button'])) {
2841
+			echo '
2734 2842
 								<input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button_submit">';
2843
+	}
2735 2844
 
2736
-	if ($context['signature_warning'])
2737
-		echo '
2845
+	if ($context['signature_warning']) {
2846
+			echo '
2738 2847
 								<span class="smalltext">', $context['signature_warning'], '</span>';
2848
+	}
2739 2849
 
2740 2850
 	// Some javascript used to count how many characters have been used so far in the signature.
2741 2851
 	echo '
@@ -2779,9 +2889,10 @@  discard block
 block discarded – undo
2779 2889
 									<div>
2780 2890
 										<select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">';
2781 2891
 		// This lists all the file categories.
2782
-		foreach ($context['avatars'] as $avatar)
2783
-			echo '
2892
+		foreach ($context['avatars'] as $avatar) {
2893
+					echo '
2784 2894
 											<option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>';
2895
+		}
2785 2896
 		echo '
2786 2897
 										</select>
2787 2898
 									</div>
@@ -2836,16 +2947,17 @@  discard block
 block discarded – undo
2836 2947
 								<div id="avatar_gravatar">
2837 2948
 									<img src="' . $context['member']['avatar']['href'] . '" alt="" />';
2838 2949
 
2839
-		if (empty($modSettings['gravatarAllowExtraEmail']))
2840
-			echo '
2950
+		if (empty($modSettings['gravatarAllowExtraEmail'])) {
2951
+					echo '
2841 2952
 									<div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>';
2842
-		else
2953
+		} else
2843 2954
 		{
2844 2955
 			// Depending on other stuff, the stored value here might have some odd things in it from other areas.
2845
-			if ($context['member']['avatar']['external'] == $context['member']['email'])
2846
-				$textbox_value = '';
2847
-			else
2848
-				$textbox_value = $context['member']['avatar']['external'];
2956
+			if ($context['member']['avatar']['external'] == $context['member']['email']) {
2957
+							$textbox_value = '';
2958
+			} else {
2959
+							$textbox_value = $context['member']['avatar']['external'];
2960
+			}
2849 2961
 
2850 2962
 			echo '
2851 2963
 									<div class="smalltext">', $txt['gravatar_alternateEmail'], '</div>
@@ -2917,8 +3029,9 @@  discard block
 block discarded – undo
2917 3029
 	$h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0;
2918 3030
 
2919 3031
 	$suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : '');
2920
-	if (empty($suffix))
2921
-		return;
3032
+	if (empty($suffix)) {
3033
+			return;
3034
+	}
2922 3035
 
2923 3036
 	echo '
2924 3037
 									<div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>';
@@ -2940,9 +3053,10 @@  discard block
 block discarded – undo
2940 3053
 							<dd>
2941 3054
 								<select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;" style="margin-bottom: 4px;">';
2942 3055
 	// Help the user by showing a list of common time formats.
2943
-	foreach ($context['easy_timeformats'] as $time_format)
2944
-		echo '
3056
+	foreach ($context['easy_timeformats'] as $time_format) {
3057
+			echo '
2945 3058
 									<option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>';
3059
+	}
2946 3060
 	echo '
2947 3061
 								</select><br>
2948 3062
 								<input type="text" name="time_format" id="time_format" value="', $context['member']['time_format'], '" size="30" class="input_text">
@@ -2978,9 +3092,10 @@  discard block
 block discarded – undo
2978 3092
 							</dt>
2979 3093
 							<dd>
2980 3094
 								<select name="smiley_set" id="smiley_set" onchange="document.getElementById(\'smileypr\').src = this.selectedIndex == 0 ? \'', $settings['images_url'], '/blank.png\' : \'', $modSettings['smileys_url'], '/\' + (this.selectedIndex != 1 ? this.options[this.selectedIndex].value : \'', !empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'], '\') + \'/smiley.gif\';">';
2981
-	foreach ($context['smiley_sets'] as $set)
2982
-		echo '
3095
+	foreach ($context['smiley_sets'] as $set) {
3096
+			echo '
2983 3097
 									<option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>';
3098
+	}
2984 3099
 	echo '
2985 3100
 								</select> <img id="smileypr" class="centericon" src="', $context['member']['smiley_set']['id'] != 'none' ? $modSettings['smileys_url'] . '/' . ($context['member']['smiley_set']['id'] != '' ? $context['member']['smiley_set']['id'] : (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'])) . '/smiley.gif' : $settings['images_url'] . '/blank.png', '" alt=":)"  style="padding-left: 20px;">
2986 3101
 							</dd>';
@@ -3031,10 +3146,11 @@  discard block
 block discarded – undo
3031 3146
 									</div>
3032 3147
 									<div class="clear"></div>';
3033 3148
 
3034
-	if (!empty($context['from_ajax']))
3035
-		echo '
3149
+	if (!empty($context['from_ajax'])) {
3150
+			echo '
3036 3151
 									<br>
3037 3152
 									<a href="javascript:self.close();"></a>';
3153
+	}
3038 3154
 
3039 3155
 	echo '
3040 3156
 								</div>
@@ -3073,15 +3189,16 @@  discard block
 block discarded – undo
3073 3189
 								<br /><div class="smalltext">', $txt['tfa_profile_desc'], '</div>
3074 3190
 							</dt>
3075 3191
 							<dd>';
3076
-	if (!$context['tfa_enabled'] && $context['user']['is_owner'])
3077
-		echo '
3192
+	if (!$context['tfa_enabled'] && $context['user']['is_owner']) {
3193
+			echo '
3078 3194
 								<a href="', !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>';
3079
-	elseif (!$context['tfa_enabled'])
3080
-		echo '
3195
+	} elseif (!$context['tfa_enabled']) {
3196
+			echo '
3081 3197
 								', $txt['tfa_profile_disabled'];
3082
-	else
3083
-		echo '
3198
+	} else {
3199
+			echo '
3084 3200
 							', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable');
3201
+	}
3085 3202
 	echo '
3086 3203
 							</dd>';
3087 3204
 }
Please login to merge, or discard this patch.
Themes/default/Recent.template.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 	<div id="recent" class="main_section">
22 22
 		<div class="cat_bar">
23 23
 			<h3 class="catbg">
24
-				<span class="xx"></span>',$txt['recent_posts'],'
24
+				<span class="xx"></span>',$txt['recent_posts'], '
25 25
 			</h3>
26 26
 		</div>
27 27
 		<div class="pagesection">', $context['page_index'], '</div>';
Please login to merge, or discard this patch.
Braces   +74 added lines, -52 removed lines patch added patch discarded remove patch
@@ -43,28 +43,33 @@  discard block
 block discarded – undo
43 43
 					</div>
44 44
 					<div class="list_posts">', $post['message'], '</div>';
45 45
 
46
-		if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
47
-			echo '
46
+		if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
47
+					echo '
48 48
 					<ul class="quickbuttons">';
49
+		}
49 50
 
50 51
 		// If they *can* reply?
51
-		if ($post['can_reply'])
52
-			echo '
52
+		if ($post['can_reply']) {
53
+					echo '
53 54
 						<li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>';
55
+		}
54 56
 
55 57
 		// If they *can* quote?
56
-		if ($post['can_quote'])
57
-			echo '
58
+		if ($post['can_quote']) {
59
+					echo '
58 60
 						<li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>';
61
+		}
59 62
 
60 63
 		// How about... even... remove it entirely?!
61
-		if ($post['can_delete'])
62
-			echo '
64
+		if ($post['can_delete']) {
65
+					echo '
63 66
 						<li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';recent;', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
67
+		}
64 68
 
65
-		if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
66
-			echo '
69
+		if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
70
+					echo '
67 71
 					</ul>';
72
+		}
68 73
 
69 74
 		echo '
70 75
 			</div>';
@@ -86,12 +91,13 @@  discard block
 block discarded – undo
86 91
 	echo '
87 92
 	<div id="recent" class="main_content">';
88 93
 
89
-	if ($context['showCheckboxes'])
90
-		echo '
94
+	if ($context['showCheckboxes']) {
95
+			echo '
91 96
 		<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;">
92 97
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
93 98
 			<input type="hidden" name="qaction" value="markread">
94 99
 			<input type="hidden" name="redirect_url" value="action=unread', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">';
100
+	}
95 101
 
96 102
 	if (!empty($context['topics']))
97 103
 	{
@@ -117,11 +123,12 @@  discard block
 block discarded – undo
117 123
 					</div>';
118 124
 
119 125
 		// Show a "select all" box for quick moderation?
120
-		if ($context['showCheckboxes'])
121
-			echo '
126
+		if ($context['showCheckboxes']) {
127
+					echo '
122 128
 					<div class="moderation">
123 129
 						<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="input_check">
124 130
 					</div>';
131
+		}
125 132
 
126 133
 		echo '
127 134
 				</div>
@@ -140,15 +147,18 @@  discard block
 block discarded – undo
140 147
 			// Now we handle the icons
141 148
 			echo '
142 149
 							<div class="icons floatright">';
143
-			if ($topic['is_locked'])
144
-				echo '
150
+			if ($topic['is_locked']) {
151
+							echo '
145 152
 								<span class="generic_icons lock"></span>';
146
-			if ($topic['is_sticky'])
147
-				echo '
153
+			}
154
+			if ($topic['is_sticky']) {
155
+							echo '
148 156
 								<span class="generic_icons sticky"></span>';
149
-			if ($topic['is_poll'])
150
-				echo '
157
+			}
158
+			if ($topic['is_poll']) {
159
+							echo '
151 160
 								<span class="generic_icons poll"></span>';
161
+			}
152 162
 			echo '
153 163
 							</div>';
154 164
 
@@ -173,19 +183,21 @@  discard block
 block discarded – undo
173 183
 							', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), '
174 184
 						</div>';
175 185
 
176
-			if ($context['showCheckboxes'])
177
-				echo '
186
+			if ($context['showCheckboxes']) {
187
+							echo '
178 188
 						<div class="moderation">
179 189
 							<input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check">
180 190
 						</div>';
191
+			}
181 192
 
182 193
 				echo '
183 194
 					</div>';
184 195
 		}
185 196
 
186
-		if (empty($context['topics']))
187
-			echo '
197
+		if (empty($context['topics'])) {
198
+					echo '
188 199
 						<div style="display: none;"></div>';
200
+		}
189 201
 
190 202
 		echo '
191 203
 				</div>
@@ -197,25 +209,27 @@  discard block
 block discarded – undo
197 209
 				', $context['menu_separator'], '<a href="#recent" class="topbottom floatleft">', $txt['go_up'], '</a>
198 210
 				<div class="pagelinks">', $context['page_index'], '</div>
199 211
 			</div>';
200
-	}
201
-	else
202
-		echo '
212
+	} else {
213
+			echo '
203 214
 			<div class="cat_bar">
204 215
 				<h3 class="catbg centertext">
205 216
 					', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], '
206 217
 				</h3>
207 218
 			</div>';
219
+	}
208 220
 
209
-	if ($context['showCheckboxes'])
210
-		echo '
221
+	if ($context['showCheckboxes']) {
222
+			echo '
211 223
 		</form>';
224
+	}
212 225
 
213 226
 	echo '
214 227
 	</div>';
215 228
 
216
-	if (empty($context['no_topic_listing']))
217
-		template_topic_legend();
218
-}
229
+	if (empty($context['no_topic_listing'])) {
230
+			template_topic_legend();
231
+	}
232
+	}
219 233
 
220 234
 /**
221 235
  * Template for showing unread replies (eg new replies to topics you've posted in)
@@ -227,12 +241,13 @@  discard block
 block discarded – undo
227 241
 	echo '
228 242
 	<div id="recent">';
229 243
 
230
-	if ($context['showCheckboxes'])
231
-		echo '
244
+	if ($context['showCheckboxes']) {
245
+			echo '
232 246
 		<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;">
233 247
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
234 248
 			<input type="hidden" name="qaction" value="markread">
235 249
 			<input type="hidden" name="redirect_url" value="action=unreadreplies', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">';
250
+	}
236 251
 
237 252
 	if (!empty($context['topics']))
238 253
 	{
@@ -258,11 +273,12 @@  discard block
 block discarded – undo
258 273
 					</div>';
259 274
 
260 275
 		// Show a "select all" box for quick moderation?
261
-		if ($context['showCheckboxes'])
262
-				echo '
276
+		if ($context['showCheckboxes']) {
277
+						echo '
263 278
 					<div class="moderation">
264 279
 						<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="input_check">
265 280
 					</div>';
281
+		}
266 282
 
267 283
 		echo '
268 284
 				</div>
@@ -281,15 +297,18 @@  discard block
 block discarded – undo
281 297
 			// Now we handle the icons
282 298
 			echo '
283 299
 								<div class="icons floatright">';
284
-			if ($topic['is_locked'])
285
-				echo '
300
+			if ($topic['is_locked']) {
301
+							echo '
286 302
 									<span class="generic_icons lock"></span>';
287
-			if ($topic['is_sticky'])
288
-				echo '
303
+			}
304
+			if ($topic['is_sticky']) {
305
+							echo '
289 306
 									<span class="generic_icons sticky"></span>';
290
-			if ($topic['is_poll'])
291
-				echo '
307
+			}
308
+			if ($topic['is_poll']) {
309
+							echo '
292 310
 									<span class="generic_icons poll"></span>';
311
+			}
293 312
 			echo '
294 313
 								</div>';
295 314
 
@@ -314,11 +333,12 @@  discard block
 block discarded – undo
314 333
 								', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), '
315 334
 							</div>';
316 335
 
317
-			if ($context['showCheckboxes'])
318
-				echo '
336
+			if ($context['showCheckboxes']) {
337
+							echo '
319 338
 							<div class="moderation">
320 339
 								<input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check">
321 340
 							</div>';
341
+			}
322 342
 			echo '
323 343
 						</div>';
324 344
 		}
@@ -331,24 +351,26 @@  discard block
 block discarded – undo
331 351
 				', $context['menu_separator'], '<a href="#recent" class="topbottom floatleft">', $txt['go_up'], '</a>
332 352
 				<div class="pagelinks">', $context['page_index'], '</div>
333 353
 			</div>';
334
-	}
335
-	else
336
-		echo '
354
+	} else {
355
+			echo '
337 356
 			<div class="cat_bar">
338 357
 				<h3 class="catbg centertext">
339 358
 					', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], '
340 359
 				</h3>
341 360
 			</div>';
361
+	}
342 362
 
343
-	if ($context['showCheckboxes'])
344
-		echo '
363
+	if ($context['showCheckboxes']) {
364
+			echo '
345 365
 		</form>';
366
+	}
346 367
 
347 368
 	echo '
348 369
 	</div>';
349 370
 
350
-	if (empty($context['no_topic_listing']))
351
-		template_topic_legend();
352
-}
371
+	if (empty($context['no_topic_listing'])) {
372
+			template_topic_legend();
373
+	}
374
+	}
353 375
 
354 376
 ?>
355 377
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/GenericMenu.template.php 1 patch
Braces   +50 added lines, -37 removed lines patch added patch discarded remove patch
@@ -89,8 +89,9 @@  discard block
 block discarded – undo
89 89
 		foreach ($section['areas'] as $i => $area)
90 90
 		{
91 91
 			// Not supposed to be printed?
92
-			if (empty($area['label']))
93
-				continue;
92
+			if (empty($area['label'])) {
93
+							continue;
94
+			}
94 95
 
95 96
 			echo '
96 97
 								<li', !empty($area['subsections']) ? ' class="subsections"' : '', '>';
@@ -99,8 +100,9 @@  discard block
 block discarded – undo
99 100
 									<a class="', $area['icon_class'], !empty($area['selected']) ? ' chosen ' : '', '" href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '">', $area['icon'], $area['label'], '</a>';
100 101
 
101 102
 			// Is this the current area, or just some area?
102
-			if (!empty($area['selected']) && empty($context['tabs']))
103
-					$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
103
+			if (!empty($area['selected']) && empty($context['tabs'])) {
104
+								$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
105
+			}
104 106
 
105 107
 			// Are there any subsections?
106 108
 			if (!empty($area['subsections']))
@@ -110,8 +112,9 @@  discard block
 block discarded – undo
110 112
 
111 113
 				foreach ($area['subsections'] as $sa => $sub)
112 114
 				{
113
-					if (!empty($sub['disabled']))
114
-						continue;
115
+					if (!empty($sub['disabled'])) {
116
+											continue;
117
+					}
115 118
 
116 119
 					$url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa;
117 120
 
@@ -158,8 +161,9 @@  discard block
 block discarded – undo
158 161
 							<h3 class="catbg">';
159 162
 
160 163
 		// The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available
161
-		if (function_exists('template_admin_quick_search'))
162
-			template_admin_quick_search();
164
+		if (function_exists('template_admin_quick_search')) {
165
+					template_admin_quick_search();
166
+		}
163 167
 
164 168
 		// Exactly how many tabs do we have?
165 169
 		if (!empty($context['tabs']))
@@ -174,30 +178,36 @@  discard block
 block discarded – undo
174 178
 				}
175 179
 
176 180
 				// Did this not even exist - or do we not have a label?
177
-				if (!isset($tab_context['tabs'][$id]))
178
-					$tab_context['tabs'][$id] = array('label' => $tab['label']);
179
-				elseif (!isset($tab_context['tabs'][$id]['label']))
180
-					$tab_context['tabs'][$id]['label'] = $tab['label'];
181
+				if (!isset($tab_context['tabs'][$id])) {
182
+									$tab_context['tabs'][$id] = array('label' => $tab['label']);
183
+				} elseif (!isset($tab_context['tabs'][$id]['label'])) {
184
+									$tab_context['tabs'][$id]['label'] = $tab['label'];
185
+				}
181 186
 
182 187
 				// Has a custom URL defined in the main admin structure?
183
-				if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url']))
184
-					$tab_context['tabs'][$id]['url'] = $tab['url'];
188
+				if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) {
189
+									$tab_context['tabs'][$id]['url'] = $tab['url'];
190
+				}
185 191
 
186 192
 				// Any additional paramaters for the url?
187
-				if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params']))
188
-					$tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
193
+				if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) {
194
+									$tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
195
+				}
189 196
 
190 197
 				// Has it been deemed selected?
191
-				if (!empty($tab['is_selected']))
192
-					$tab_context['tabs'][$id]['is_selected'] = true;
198
+				if (!empty($tab['is_selected'])) {
199
+									$tab_context['tabs'][$id]['is_selected'] = true;
200
+				}
193 201
 
194 202
 				// Does it have its own help?
195
-				if (!empty($tab['help']))
196
-					$tab_context['tabs'][$id]['help'] = $tab['help'];
203
+				if (!empty($tab['help'])) {
204
+									$tab_context['tabs'][$id]['help'] = $tab['help'];
205
+				}
197 206
 
198 207
 				// Is this the last one?
199
-				if (!empty($tab['is_last']) && !isset($tab_context['override_last']))
200
-					$tab_context['tabs'][$id]['is_last'] = true;
208
+				if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) {
209
+									$tab_context['tabs'][$id]['is_last'] = true;
210
+				}
201 211
 			}
202 212
 
203 213
 			// Find the selected tab
@@ -214,17 +224,18 @@  discard block
 block discarded – undo
214 224
 		// Show an icon and/or a help item?
215 225
 		if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']) || !empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help']))
216 226
 		{
217
-			if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']))
218
-				echo '<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>';
219
-			elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon']))
220
-				echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">';
227
+			if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) {
228
+							echo '<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>';
229
+			} elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) {
230
+							echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">';
231
+			}
221 232
 
222
-			if (!empty($selected_tab['help']) || !empty($tab_context['help']))
223
-				echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>';
233
+			if (!empty($selected_tab['help']) || !empty($tab_context['help'])) {
234
+							echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>';
235
+			}
224 236
 
225 237
 			echo $tab_context['title'];
226
-		}
227
-		else
238
+		} else
228 239
 		{
229 240
 			echo '
230 241
 							', $tab_context['title'];
@@ -237,11 +248,12 @@  discard block
 block discarded – undo
237 248
 	}
238 249
 
239 250
 	// Shall we use the tabs? Yes, it's the only known way!
240
-	if (!empty($selected_tab['description']) || !empty($tab_context['description']))
241
-		echo '
251
+	if (!empty($selected_tab['description']) || !empty($tab_context['description'])) {
252
+			echo '
242 253
 					<p class="information">
243 254
 						', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], '
244 255
 					</p>';
256
+	}
245 257
 
246 258
 	// Print out all the items in this tab (if any).
247 259
 	if (!empty($context['tabs']))
@@ -253,8 +265,9 @@  discard block
 block discarded – undo
253 265
 
254 266
 		foreach ($tab_context['tabs'] as $sa => $tab)
255 267
 		{
256
-			if (!empty($tab['disabled']))
257
-				continue;
268
+			if (!empty($tab['disabled'])) {
269
+							continue;
270
+			}
258 271
 
259 272
 			if (!empty($tab['is_selected']))
260 273
 			{
@@ -262,12 +275,12 @@  discard block
 block discarded – undo
262 275
 							<li>
263 276
 								<a class="active" href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a>
264 277
 							</li>';
265
-			}
266
-			else
267
-				echo '
278
+			} else {
279
+							echo '
268 280
 							<li>
269 281
 								<a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a>
270 282
 							</li>';
283
+			}
271 284
 		}
272 285
 
273 286
 		// the end of tabs
Please login to merge, or discard this patch.
Sources/Groups.php 1 patch
Braces   +80 added lines, -59 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Entry point function, permission checks, admin bars, etc.
@@ -99,27 +100,27 @@  discard block
 block discarded – undo
99 100
 					'function' => function($rowData) use ($scripturl)
100 101
 					{
101 102
 						// Since the moderator group has no explicit members, no link is needed.
102
-						if ($rowData['id_group'] == 3)
103
-							$group_name = $rowData['group_name'];
104
-						else
103
+						if ($rowData['id_group'] == 3) {
104
+													$group_name = $rowData['group_name'];
105
+						} else
105 106
 						{
106 107
 							$color_style = empty($rowData['online_color']) ? '' : sprintf(' style="color: %1$s;"', $rowData['online_color']);
107 108
 
108 109
 							if (allowedTo('manage_membergroups'))
109 110
 							{
110 111
 								$group_name = sprintf('<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']);
111
-							}
112
-							else
112
+							} else
113 113
 							{
114 114
 								$group_name = sprintf('<a href="%1$s?action=groups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']);
115 115
 							}
116 116
 						}
117 117
 
118 118
 						// Add a help option for moderator and administrator.
119
-						if ($rowData['id_group'] == 1)
120
-							$group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl);
121
-						elseif ($rowData['id_group'] == 3)
122
-							$group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl);
119
+						if ($rowData['id_group'] == 1) {
120
+													$group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl);
121
+						} elseif ($rowData['id_group'] == 3) {
122
+													$group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl);
123
+						}
123 124
 
124 125
 						return $group_name;
125 126
 					},
@@ -198,8 +199,9 @@  discard block
 block discarded – undo
198 199
 	$_REQUEST['group'] = isset($_REQUEST['group']) ? (int) $_REQUEST['group'] : 0;
199 200
 
200 201
 	// No browsing of guests, membergroup 0 or moderators.
201
-	if (in_array($_REQUEST['group'], array(-1, 0, 3)))
202
-		fatal_lang_error('membergroup_does_not_exist', false);
202
+	if (in_array($_REQUEST['group'], array(-1, 0, 3))) {
203
+			fatal_lang_error('membergroup_does_not_exist', false);
204
+	}
203 205
 
204 206
 	// Load up the group details.
205 207
 	$request = $smcFunc['db_query']('', '
@@ -214,8 +216,9 @@  discard block
 block discarded – undo
214 216
 		)
215 217
 	);
216 218
 	// Doesn't exist?
217
-	if ($smcFunc['db_num_rows']($request) == 0)
218
-		fatal_lang_error('membergroup_does_not_exist', false);
219
+	if ($smcFunc['db_num_rows']($request) == 0) {
220
+			fatal_lang_error('membergroup_does_not_exist', false);
221
+	}
219 222
 	$context['group'] = $smcFunc['db_fetch_assoc']($request);
220 223
 	$smcFunc['db_free_result']($request);
221 224
 
@@ -248,21 +251,25 @@  discard block
 block discarded – undo
248 251
 			'name' => $row['real_name']
249 252
 		);
250 253
 
251
-		if ($user_info['id'] == $row['id_member'] && $context['group']['group_type'] != 1)
252
-			$context['group']['can_moderate'] = true;
254
+		if ($user_info['id'] == $row['id_member'] && $context['group']['group_type'] != 1) {
255
+					$context['group']['can_moderate'] = true;
256
+		}
253 257
 	}
254 258
 	$smcFunc['db_free_result']($request);
255 259
 
256 260
 	// If this group is hidden then it can only "exists" if the user can moderate it!
257
-	if ($context['group']['hidden'] && !$context['group']['can_moderate'])
258
-		fatal_lang_error('membergroup_does_not_exist', false);
261
+	if ($context['group']['hidden'] && !$context['group']['can_moderate']) {
262
+			fatal_lang_error('membergroup_does_not_exist', false);
263
+	}
259 264
 
260 265
 	// You can only assign membership if you are the moderator and/or can manage groups!
261
-	if (!$context['group']['can_moderate'])
262
-		$context['group']['assignable'] = 0;
266
+	if (!$context['group']['can_moderate']) {
267
+			$context['group']['assignable'] = 0;
268
+	}
263 269
 	// Non-admins cannot assign admins.
264
-	elseif ($context['group']['id'] == 1 && !allowedTo('admin_forum'))
265
-		$context['group']['assignable'] = 0;
270
+	elseif ($context['group']['id'] == 1 && !allowedTo('admin_forum')) {
271
+			$context['group']['assignable'] = 0;
272
+	}
266 273
 
267 274
 	// Removing member from group?
268 275
 	if (isset($_POST['remove']) && !empty($_REQUEST['rem']) && is_array($_REQUEST['rem']) && $context['group']['assignable'])
@@ -271,8 +278,9 @@  discard block
 block discarded – undo
271 278
 		validateToken('mod-mgm');
272 279
 
273 280
 		// Make sure we're dealing with integers only.
274
-		foreach ($_REQUEST['rem'] as $key => $group)
275
-			$_REQUEST['rem'][$key] = (int) $group;
281
+		foreach ($_REQUEST['rem'] as $key => $group) {
282
+					$_REQUEST['rem'][$key] = (int) $group;
283
+		}
276 284
 
277 285
 		require_once($sourcedir . '/Subs-Membergroups.php');
278 286
 		removeMembersFromGroups($_REQUEST['rem'], $_REQUEST['group'], true);
@@ -295,16 +303,18 @@  discard block
 block discarded – undo
295 303
 		{
296 304
 			$member_names[$index] = trim($smcFunc['strtolower']($member_names[$index]));
297 305
 
298
-			if (strlen($member_names[$index]) == 0)
299
-				unset($member_names[$index]);
306
+			if (strlen($member_names[$index]) == 0) {
307
+							unset($member_names[$index]);
308
+			}
300 309
 		}
301 310
 
302 311
 		// Any passed by ID?
303 312
 		$member_ids = array();
304
-		if (!empty($_REQUEST['member_add']))
305
-			foreach ($_REQUEST['member_add'] as $id)
313
+		if (!empty($_REQUEST['member_add'])) {
314
+					foreach ($_REQUEST['member_add'] as $id)
306 315
 				if ($id > 0)
307 316
 					$member_ids[] = (int) $id;
317
+		}
308 318
 
309 319
 		// Construct the query pelements.
310 320
 		if (!empty($member_ids))
@@ -332,8 +342,9 @@  discard block
 block discarded – undo
332 342
 					'id_group' => $_REQUEST['group'],
333 343
 				))
334 344
 			);
335
-			while ($row = $smcFunc['db_fetch_assoc']($request))
336
-				$members[] = $row['id_member'];
345
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
346
+							$members[] = $row['id_member'];
347
+			}
337 348
 			$smcFunc['db_free_result']($request);
338 349
 		}
339 350
 
@@ -372,10 +383,11 @@  discard block
 block discarded – undo
372 383
 	$context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up';
373 384
 
374 385
 	// The where on the query is interesting. Non-moderators should only see people who are in this group as primary.
375
-	if ($context['group']['can_moderate'])
376
-		$where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group} OR FIND_IN_SET({int:group}, additional_groups) != 0';
377
-	else
378
-		$where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group}';
386
+	if ($context['group']['can_moderate']) {
387
+			$where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group} OR FIND_IN_SET({int:group}, additional_groups) != 0';
388
+	} else {
389
+			$where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group}';
390
+	}
379 391
 
380 392
 	// Count members of the group.
381 393
 	$request = $smcFunc['db_query']('', '
@@ -416,8 +428,9 @@  discard block
 block discarded – undo
416 428
 		$last_online = empty($row['last_login']) ? $txt['never'] : timeformat($row['last_login']);
417 429
 
418 430
 		// Italicize the online note if they aren't activated.
419
-		if ($row['is_activated'] % 10 != 1)
420
-			$last_online = '<em title="' . $txt['not_activated'] . '">' . $last_online . '</em>';
431
+		if ($row['is_activated'] % 10 != 1) {
432
+					$last_online = '<em title="' . $txt['not_activated'] . '">' . $last_online . '</em>';
433
+		}
421 434
 
422 435
 		$context['members'][] = array(
423 436
 			'id' => $row['id_member'],
@@ -437,9 +450,10 @@  discard block
 block discarded – undo
437 450
 	$context['page_title'] = $txt['membergroups_members_title'] . ': ' . $context['group']['name'];
438 451
 	createToken('mod-mgm');
439 452
 
440
-	if ($context['group']['assignable'])
441
-		loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest');
442
-}
453
+	if ($context['group']['assignable']) {
454
+			loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest');
455
+	}
456
+	}
443 457
 
444 458
 /**
445 459
  * Show and manage all group requests.
@@ -453,16 +467,18 @@  discard block
 block discarded – undo
453 467
 	$context['sub_template'] = 'show_list';
454 468
 
455 469
 	// Verify we can be here.
456
-	if ($user_info['mod_cache']['gq'] == '0=1')
457
-		isAllowedTo('manage_membergroups');
470
+	if ($user_info['mod_cache']['gq'] == '0=1') {
471
+			isAllowedTo('manage_membergroups');
472
+	}
458 473
 
459 474
 	// Normally, we act normally...
460 475
 	$where = ($user_info['mod_cache']['gq'] == '1=1' || $user_info['mod_cache']['gq'] == '0=1' ? $user_info['mod_cache']['gq'] : 'lgr.' . $user_info['mod_cache']['gq']);
461 476
 
462
-	if (isset($_GET['closed']))
463
-		$where .= ' AND lgr.status != {int:status_open}';
464
-	else
465
-		$where .= ' AND lgr.status = {int:status_open}';
477
+	if (isset($_GET['closed'])) {
478
+			$where .= ' AND lgr.status != {int:status_open}';
479
+	} else {
480
+			$where .= ' AND lgr.status = {int:status_open}';
481
+	}
466 482
 
467 483
 	$where_parameters = array(
468 484
 		'status_open' => 0,
@@ -475,8 +491,9 @@  discard block
 block discarded – undo
475 491
 		validateToken('mod-gr');
476 492
 
477 493
 		// Clean the values.
478
-		foreach ($_POST['groupr'] as $k => $request)
479
-			$_POST['groupr'][$k] = (int) $request;
494
+		foreach ($_POST['groupr'] as $k => $request) {
495
+					$_POST['groupr'][$k] = (int) $request;
496
+		}
480 497
 
481 498
 		$log_changes = array();
482 499
 
@@ -513,8 +530,8 @@  discard block
 block discarded – undo
513 530
 			$request_list = array();
514 531
 			while ($row = $smcFunc['db_fetch_assoc']($request))
515 532
 			{
516
-				if (!isset($log_changes[$row['id_request']]))
517
-					$log_changes[$row['id_request']] = array(
533
+				if (!isset($log_changes[$row['id_request']])) {
534
+									$log_changes[$row['id_request']] = array(
518 535
 						'id_request' => $row['id_request'],
519 536
 						'status' => $_POST['req_action'] == 'approve' ? 1 : 2, // 1 = approved, 2 = rejected
520 537
 						'id_member_acted' => $user_info['id'],
@@ -522,6 +539,7 @@  discard block
 block discarded – undo
522 539
 						'time_acted' => time(),
523 540
 						'act_reason' => $_POST['req_action'] != 'approve' && !empty($_POST['groupreason']) && !empty($_POST['groupreason'][$row['id_request']]) ? $smcFunc['htmlspecialchars']($_POST['groupreason'][$row['id_request']], ENT_QUOTES) : '',
524 541
 					);
542
+				}
525 543
 				$request_list[] = $row['id_request'];
526 544
 			}
527 545
 			$smcFunc['db_free_result']($request);
@@ -744,21 +762,24 @@  discard block
 block discarded – undo
744 762
 	$group_requests = array();
745 763
 	while ($row = $smcFunc['db_fetch_assoc']($request))
746 764
 	{
747
-		if (empty($row['reason']))
748
-			$reason = '<em>(' . $txt['mc_groupr_no_reason'] . ')</em>';
749
-		else
750
-			$reason = censorText($row['reason']);
765
+		if (empty($row['reason'])) {
766
+					$reason = '<em>(' . $txt['mc_groupr_no_reason'] . ')</em>';
767
+		} else {
768
+					$reason = censorText($row['reason']);
769
+		}
751 770
 
752 771
 		if (isset($_GET['closed']))
753 772
 		{
754
-			if ($row['status'] == 1)
755
-				$reason .= '<br><br><strong>' . $txt['mc_groupr_approved'] . '</strong>';
756
-			elseif ($row['status'] == 2)
757
-				$reason .= '<br><br><strong>' . $txt['mc_groupr_rejected'] . '</strong>';
773
+			if ($row['status'] == 1) {
774
+							$reason .= '<br><br><strong>' . $txt['mc_groupr_approved'] . '</strong>';
775
+			} elseif ($row['status'] == 2) {
776
+							$reason .= '<br><br><strong>' . $txt['mc_groupr_rejected'] . '</strong>';
777
+			}
758 778
 
759 779
 				$reason .= ' (' . timeformat($row['time_acted']) . ')';
760
-			if (!empty($row['act_reason']))
761
-				$reason .= '<br><br>' . censorText($row['act_reason']);
780
+			if (!empty($row['act_reason'])) {
781
+							$reason .= '<br><br>' . censorText($row['act_reason']);
782
+			}
762 783
 		}
763 784
 
764 785
 		$group_requests[] = array(
Please login to merge, or discard this patch.
Sources/LogInOut.php 1 patch
Braces   +164 added lines, -128 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * 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) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on'))
87
-		fatal_lang_error('login_ssl_required');
89
+	if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) {
90
+			fatal_lang_error('login_ssl_required');
91
+	}
88 92
 
89 93
 	// Load cookie authentication stuff.
90 94
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -102,19 +106,20 @@  discard block
 block discarded – undo
102 106
 			list (,, $timeout) = smf_json_decode($_COOKIE[$cookiename], true);
103 107
 
104 108
 			// That didn't work... Maybe it's using serialize?
105
-			if (is_null($timeout))
106
-				list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]);
107
-		}
108
-		elseif (isset($_SESSION['login_' . $cookiename]))
109
+			if (is_null($timeout)) {
110
+							list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]);
111
+			}
112
+		} elseif (isset($_SESSION['login_' . $cookiename]))
109 113
 		{
110 114
 			list (,, $timeout) = smf_json_decode($_SESSION['login_' . $cookiename]);
111 115
 
112 116
 			// Try for old format
113
-			if (is_null($timeout))
114
-				list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]);
117
+			if (is_null($timeout)) {
118
+							list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]);
119
+			}
120
+		} else {
121
+					trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR);
115 122
 		}
116
-		else
117
-			trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR);
118 123
 
119 124
 		$user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4);
120 125
 		updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt']));
@@ -125,16 +130,18 @@  discard block
 block discarded – undo
125 130
 			$tfadata = smf_json_decode($_COOKIE[$cookiename . '_tfa'], true);
126 131
 
127 132
 			// If that didn't work, try unserialize instead...
128
-			if (is_null($tfadata))
129
-				$tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']);
133
+			if (is_null($tfadata)) {
134
+							$tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']);
135
+			}
130 136
 
131 137
 			list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata;
132 138
 
133 139
 			// If we're preserving the cookie, reset it with updated salt
134
-			if ($preserve && time() < $exp)
135
-				setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true);
136
-			else
137
-				setTFACookie(-3600, 0, '');
140
+			if ($preserve && time() < $exp) {
141
+							setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true);
142
+			} else {
143
+							setTFACookie(-3600, 0, '');
144
+			}
138 145
 		}
139 146
 
140 147
 		setLoginCookie($timeout - time(), $user_info['id'], hash_salt($user_settings['passwd'], $user_settings['password_salt']));
@@ -145,20 +152,20 @@  discard block
 block discarded – undo
145 152
 	elseif (isset($_GET['sa']) && $_GET['sa'] == 'check')
146 153
 	{
147 154
 		// Strike!  You're outta there!
148
-		if ($_GET['member'] != $user_info['id'])
149
-			fatal_lang_error('login_cookie_error', false);
155
+		if ($_GET['member'] != $user_info['id']) {
156
+					fatal_lang_error('login_cookie_error', false);
157
+		}
150 158
 
151 159
 		$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']))));
152 160
 
153 161
 		// Some whitelisting for login_url...
154
-		if (empty($_SESSION['login_url']))
155
-			redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
156
-		elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false))
162
+		if (empty($_SESSION['login_url'])) {
163
+					redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
164
+		} elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false))
157 165
 		{
158 166
 			unset ($_SESSION['login_url']);
159 167
 			redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
160
-		}
161
-		else
168
+		} else
162 169
 		{
163 170
 			// Best not to clutter the session data too much...
164 171
 			$temp = $_SESSION['login_url'];
@@ -169,8 +176,9 @@  discard block
 block discarded – undo
169 176
 	}
170 177
 
171 178
 	// Beyond this point you are assumed to be a guest trying to login.
172
-	if (!$user_info['is_guest'])
173
-		redirectexit();
179
+	if (!$user_info['is_guest']) {
180
+			redirectexit();
181
+	}
174 182
 
175 183
 	// Are you guessing with a script?
176 184
 	checkSession();
@@ -178,18 +186,21 @@  discard block
 block discarded – undo
178 186
 	spamProtection('login');
179 187
 
180 188
 	// Set the login_url if it's not already set (but careful not to send us to an attachment).
181
-	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))
182
-		$_SESSION['login_url'] = $_SESSION['old_url'];
189
+	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)) {
190
+			$_SESSION['login_url'] = $_SESSION['old_url'];
191
+	}
183 192
 
184 193
 	// Been guessing a lot, haven't we?
185
-	if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3)
186
-		fatal_lang_error('login_threshold_fail', 'critical');
194
+	if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) {
195
+			fatal_lang_error('login_threshold_fail', 'critical');
196
+	}
187 197
 
188 198
 	// Set up the cookie length.  (if it's invalid, just fall through and use the default.)
189
-	if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1))
190
-		$modSettings['cookieTime'] = 3153600;
191
-	elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600))
192
-		$modSettings['cookieTime'] = (int) $_POST['cookielength'];
199
+	if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) {
200
+			$modSettings['cookieTime'] = 3153600;
201
+	} elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) {
202
+			$modSettings['cookieTime'] = (int) $_POST['cookielength'];
203
+	}
193 204
 
194 205
 	loadLanguage('Login');
195 206
 	// Load the template stuff.
@@ -309,8 +320,9 @@  discard block
 block discarded – undo
309 320
 			$other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd']));
310 321
 
311 322
 			// Snitz style - SHA-256.  Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway.
312
-			if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256'))
313
-				$other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd']));
323
+			if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) {
324
+							$other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd']));
325
+			}
314 326
 
315 327
 			// phpBB3 users new hashing.  We now support it as well ;).
316 328
 			$other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']);
@@ -330,27 +342,29 @@  discard block
 block discarded – undo
330 342
 			// Some common md5 ones.
331 343
 			$other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']);
332 344
 			$other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']);
333
-		}
334
-		elseif (strlen($user_settings['passwd']) == 40)
345
+		} elseif (strlen($user_settings['passwd']) == 40)
335 346
 		{
336 347
 			// Maybe they are using a hash from before the password fix.
337 348
 			// This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1
338 349
 			$other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd']));
339 350
 
340 351
 			// BurningBoard3 style of hashing.
341
-			if (!empty($modSettings['enable_password_conversion']))
342
-				$other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd'])));
352
+			if (!empty($modSettings['enable_password_conversion'])) {
353
+							$other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd'])));
354
+			}
343 355
 
344 356
 			// Perhaps we converted to UTF-8 and have a valid password being hashed differently.
345 357
 			if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8')
346 358
 			{
347 359
 				// Try iconv first, for no particular reason.
348
-				if (function_exists('iconv'))
349
-					$other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd'])));
360
+				if (function_exists('iconv')) {
361
+									$other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd'])));
362
+				}
350 363
 
351 364
 				// Say it aint so, iconv failed!
352
-				if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding'))
353
-					$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'])));
365
+				if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) {
366
+									$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'])));
367
+				}
354 368
 			}
355 369
 		}
356 370
 
@@ -380,8 +394,9 @@  discard block
 block discarded – undo
380 394
 			$_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1;
381 395
 
382 396
 			// Hmm... don't remember it, do you?  Here, try the password reminder ;).
383
-			if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold'])
384
-				redirectexit('action=reminder');
397
+			if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) {
398
+							redirectexit('action=reminder');
399
+			}
385 400
 			// We'll give you another chance...
386 401
 			else
387 402
 			{
@@ -392,8 +407,7 @@  discard block
 block discarded – undo
392 407
 				return;
393 408
 			}
394 409
 		}
395
-	}
396
-	elseif (!empty($user_settings['passwd_flood']))
410
+	} elseif (!empty($user_settings['passwd_flood']))
397 411
 	{
398 412
 		// Let's be sure they weren't a little hacker.
399 413
 		validatePasswordFlood($user_settings['id_member'], $user_settings['passwd_flood'], true);
@@ -410,8 +424,9 @@  discard block
 block discarded – undo
410 424
 	}
411 425
 
412 426
 	// Check their activation status.
413
-	if (!checkActivation())
414
-		return;
427
+	if (!checkActivation()) {
428
+			return;
429
+	}
415 430
 
416 431
 	DoLogin();
417 432
 }
@@ -423,8 +438,9 @@  discard block
 block discarded – undo
423 438
 {
424 439
 	global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl;
425 440
 
426
-	if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode']))
427
-		fatal_lang_error('no_access', false);
441
+	if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) {
442
+			fatal_lang_error('no_access', false);
443
+	}
428 444
 
429 445
 	loadLanguage('Profile');
430 446
 	require_once($sourcedir . '/Class-TOTP.php');
@@ -432,8 +448,9 @@  discard block
 block discarded – undo
432 448
 	$member = $context['tfa_member'];
433 449
 
434 450
 	// Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA
435
-	if (time() - $member['last_login'] < 120)
436
-		fatal_lang_error('tfa_wait', false);
451
+	if (time() - $member['last_login'] < 120) {
452
+			fatal_lang_error('tfa_wait', false);
453
+	}
437 454
 
438 455
 	$totp = new \TOTP\Auth($member['tfa_secret']);
439 456
 	$totp->setRange(1);
@@ -447,8 +464,9 @@  discard block
 block discarded – undo
447 464
 	if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup']))
448 465
 	{
449 466
 		// Check to ensure we're forcing SSL for authentication
450
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on'))
451
-			fatal_lang_error('login_ssl_required');
467
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) {
468
+					fatal_lang_error('login_ssl_required');
469
+		}
452 470
 
453 471
 		$code = $_POST['tfa_code'];
454 472
 
@@ -458,20 +476,19 @@  discard block
 block discarded – undo
458 476
 
459 477
 			setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']), !empty($_POST['tfa_preserve']));
460 478
 			redirectexit();
461
-		}
462
-		else
479
+		} else
463 480
 		{
464 481
 			validatePasswordFlood($member['id_member'], $member['passwd_flood'], false, true);
465 482
 
466 483
 			$context['tfa_error'] = true;
467 484
 			$context['tfa_value'] = $_POST['tfa_code'];
468 485
 		}
469
-	}
470
-	elseif (!empty($_POST['tfa_backup']))
486
+	} elseif (!empty($_POST['tfa_backup']))
471 487
 	{
472 488
 		// Check to ensure we're forcing SSL for authentication
473
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on'))
474
-			fatal_lang_error('login_ssl_required');
489
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) {
490
+					fatal_lang_error('login_ssl_required');
491
+		}
475 492
 
476 493
 		$backup = $_POST['tfa_backup'];
477 494
 
@@ -485,8 +502,7 @@  discard block
 block discarded – undo
485 502
 			));
486 503
 			setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']));
487 504
 			redirectexit('action=profile;area=tfasetup;backup');
488
-		}
489
-		else
505
+		} else
490 506
 		{
491 507
 			validatePasswordFlood($member['id_member'], $member['passwd_flood'], false, true);
492 508
 
@@ -509,8 +525,9 @@  discard block
 block discarded – undo
509 525
 {
510 526
 	global $context, $txt, $scripturl, $user_settings, $modSettings;
511 527
 
512
-	if (!isset($context['login_errors']))
513
-		$context['login_errors'] = array();
528
+	if (!isset($context['login_errors'])) {
529
+			$context['login_errors'] = array();
530
+	}
514 531
 
515 532
 	// What is the true activation status of this account?
516 533
 	$activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated'];
@@ -522,8 +539,9 @@  discard block
 block discarded – undo
522 539
 		return false;
523 540
 	}
524 541
 	// Awaiting approval still?
525
-	elseif ($activation_status == 3)
526
-		fatal_lang_error('still_awaiting_approval', 'user');
542
+	elseif ($activation_status == 3) {
543
+			fatal_lang_error('still_awaiting_approval', 'user');
544
+	}
527 545
 	// Awaiting deletion, changed their mind?
528 546
 	elseif ($activation_status == 4)
529 547
 	{
@@ -531,8 +549,7 @@  discard block
 block discarded – undo
531 549
 		{
532 550
 			updateMemberData($user_settings['id_member'], array('is_activated' => 1));
533 551
 			updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0)));
534
-		}
535
-		else
552
+		} else
536 553
 		{
537 554
 			$context['disable_login_hashing'] = true;
538 555
 			$context['login_errors'][] = $txt['awaiting_delete_account'];
@@ -572,8 +589,9 @@  discard block
 block discarded – undo
572 589
 	setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt']));
573 590
 
574 591
 	// Reset the login threshold.
575
-	if (isset($_SESSION['failed_login']))
576
-		unset($_SESSION['failed_login']);
592
+	if (isset($_SESSION['failed_login'])) {
593
+			unset($_SESSION['failed_login']);
594
+	}
577 595
 
578 596
 	$user_info['is_guest'] = false;
579 597
 	$user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']);
@@ -595,16 +613,18 @@  discard block
 block discarded – undo
595 613
 			'id_member' => $user_info['id'],
596 614
 		)
597 615
 	);
598
-	if ($smcFunc['db_num_rows']($request) == 1)
599
-		$_SESSION['first_login'] = true;
600
-	else
601
-		unset($_SESSION['first_login']);
616
+	if ($smcFunc['db_num_rows']($request) == 1) {
617
+			$_SESSION['first_login'] = true;
618
+	} else {
619
+			unset($_SESSION['first_login']);
620
+	}
602 621
 	$smcFunc['db_free_result']($request);
603 622
 
604 623
 	// You've logged in, haven't you?
605 624
 	$update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']);
606
-	if (empty($user_settings['tfa_secret']))
607
-		$update['last_login'] = time();
625
+	if (empty($user_settings['tfa_secret'])) {
626
+			$update['last_login'] = time();
627
+	}
608 628
 	updateMemberData($user_info['id'], $update);
609 629
 
610 630
 	// Get rid of the online entry for that old guest....
@@ -618,8 +638,8 @@  discard block
 block discarded – undo
618 638
 	$_SESSION['log_time'] = 0;
619 639
 
620 640
 	// Log this entry, only if we have it enabled.
621
-	if (!empty($modSettings['loginHistoryDays']))
622
-		$smcFunc['db_insert']('insert',
641
+	if (!empty($modSettings['loginHistoryDays'])) {
642
+			$smcFunc['db_insert']('insert',
623 643
 			'{db_prefix}member_logins',
624 644
 			array(
625 645
 				'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet',
@@ -631,13 +651,15 @@  discard block
 block discarded – undo
631 651
 				'id_member', 'time'
632 652
 			)
633 653
 		);
654
+	}
634 655
 
635 656
 	// Just log you back out if it's in maintenance mode and you AREN'T an admin.
636
-	if (empty($maintenance) || allowedTo('admin_forum'))
637
-		redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']);
638
-	else
639
-		redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']);
640
-}
657
+	if (empty($maintenance) || allowedTo('admin_forum')) {
658
+			redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']);
659
+	} else {
660
+			redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']);
661
+	}
662
+	}
641 663
 
642 664
 /**
643 665
  * Logs the current user out of their account.
@@ -653,13 +675,15 @@  discard block
 block discarded – undo
653 675
 	global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings;
654 676
 
655 677
 	// Make sure they aren't being auto-logged out.
656
-	if (!$internal)
657
-		checkSession('get');
678
+	if (!$internal) {
679
+			checkSession('get');
680
+	}
658 681
 
659 682
 	require_once($sourcedir . '/Subs-Auth.php');
660 683
 
661
-	if (isset($_SESSION['pack_ftp']))
662
-		$_SESSION['pack_ftp'] = null;
684
+	if (isset($_SESSION['pack_ftp'])) {
685
+			$_SESSION['pack_ftp'] = null;
686
+	}
663 687
 
664 688
 	// It won't be first login anymore.
665 689
 	unset($_SESSION['first_login']);
@@ -687,24 +711,27 @@  discard block
 block discarded – undo
687 711
 
688 712
 	// And some other housekeeping while we're at it.
689 713
 	$salt = substr(md5(mt_rand()), 0, 4);
690
-	if (!empty($user_info['id']))
691
-		updateMemberData($user_info['id'], array('password_salt' => $salt));
714
+	if (!empty($user_info['id'])) {
715
+			updateMemberData($user_info['id'], array('password_salt' => $salt));
716
+	}
692 717
 
693 718
 	if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa']))
694 719
 	{
695 720
 		$tfadata = smf_json_decode($_COOKIE[$cookiename . '_tfa'], true);
696 721
 
697 722
 		// If that failed, try the old method
698
-		if (is_null($tfadata))
699
-			$tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']);
723
+		if (is_null($tfadata)) {
724
+					$tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']);
725
+		}
700 726
 
701 727
 		list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata;
702 728
 
703 729
 		// If we're preserving the cookie, reset it with updated salt
704
-		if ($preserve && time() < $exp)
705
-			setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true);
706
-		else
707
-			setTFACookie(-3600, 0, '');
730
+		if ($preserve && time() < $exp) {
731
+					setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true);
732
+		} else {
733
+					setTFACookie(-3600, 0, '');
734
+		}
708 735
 	}
709 736
 
710 737
 	session_destroy();
@@ -712,14 +739,13 @@  discard block
 block discarded – undo
712 739
 	// Off to the merry board index we go!
713 740
 	if ($redirect)
714 741
 	{
715
-		if (empty($_SESSION['logout_url']))
716
-			redirectexit('', $context['server']['needs_login_fix']);
717
-		elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false))
742
+		if (empty($_SESSION['logout_url'])) {
743
+					redirectexit('', $context['server']['needs_login_fix']);
744
+		} elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false))
718 745
 		{
719 746
 			unset ($_SESSION['logout_url']);
720 747
 			redirectexit();
721
-		}
722
-		else
748
+		} else
723 749
 		{
724 750
 			$temp = $_SESSION['logout_url'];
725 751
 			unset($_SESSION['logout_url']);
@@ -752,8 +778,9 @@  discard block
 block discarded – undo
752 778
 function phpBB3_password_check($passwd, $passwd_hash)
753 779
 {
754 780
 	// Too long or too short?
755
-	if (strlen($passwd_hash) != 34)
756
-		return;
781
+	if (strlen($passwd_hash) != 34) {
782
+			return;
783
+	}
757 784
 
758 785
 	// Range of characters allowed.
759 786
 	$range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
@@ -764,8 +791,9 @@  discard block
 block discarded – undo
764 791
 	$salt = substr($passwd_hash, 4, 8);
765 792
 
766 793
 	$hash = md5($salt . $passwd, true);
767
-	for (; $count != 0; --$count)
768
-		$hash = md5($hash . $passwd, true);
794
+	for (; $count != 0; --$count) {
795
+			$hash = md5($hash . $passwd, true);
796
+	}
769 797
 
770 798
 	$output = substr($passwd_hash, 0, 12);
771 799
 	$i = 0;
@@ -774,21 +802,25 @@  discard block
 block discarded – undo
774 802
 		$value = ord($hash[$i++]);
775 803
 		$output .= $range[$value & 0x3f];
776 804
 
777
-		if ($i < 16)
778
-			$value |= ord($hash[$i]) << 8;
805
+		if ($i < 16) {
806
+					$value |= ord($hash[$i]) << 8;
807
+		}
779 808
 
780 809
 		$output .= $range[($value >> 6) & 0x3f];
781 810
 
782
-		if ($i++ >= 16)
783
-			break;
811
+		if ($i++ >= 16) {
812
+					break;
813
+		}
784 814
 
785
-		if ($i < 16)
786
-			$value |= ord($hash[$i]) << 16;
815
+		if ($i < 16) {
816
+					$value |= ord($hash[$i]) << 16;
817
+		}
787 818
 
788 819
 		$output .= $range[($value >> 12) & 0x3f];
789 820
 
790
-		if ($i++ >= 16)
791
-			break;
821
+		if ($i++ >= 16) {
822
+					break;
823
+		}
792 824
 
793 825
 		$output .= $range[($value >> 18) & 0x3f];
794 826
 	}
@@ -819,8 +851,9 @@  discard block
 block discarded – undo
819 851
 		require_once($sourcedir . '/Subs-Auth.php');
820 852
 		setLoginCookie(-3600, 0);
821 853
 
822
-		if (isset($_SESSION['login_' . $cookiename]))
823
-			unset($_SESSION['login_' . $cookiename]);
854
+		if (isset($_SESSION['login_' . $cookiename])) {
855
+					unset($_SESSION['login_' . $cookiename]);
856
+		}
824 857
 	}
825 858
 
826 859
 	// We need a member!
@@ -834,8 +867,9 @@  discard block
 block discarded – undo
834 867
 	}
835 868
 
836 869
 	// Right, have we got a flood value?
837
-	if ($password_flood_value !== false)
838
-		@list ($time_stamp, $number_tries) = explode('|', $password_flood_value);
870
+	if ($password_flood_value !== false) {
871
+			@list ($time_stamp, $number_tries) = explode('|', $password_flood_value);
872
+	}
839 873
 
840 874
 	// Timestamp or number of tries invalid?
841 875
 	if (empty($number_tries) || empty($time_stamp))
@@ -851,15 +885,17 @@  discard block
 block discarded – undo
851 885
 		$number_tries = $time_stamp < time() - 20 ? 2 : $number_tries;
852 886
 
853 887
 		// They are trying too fast, make them wait longer
854
-		if ($time_stamp < time() - 10)
855
-			$time_stamp = time();
888
+		if ($time_stamp < time() - 10) {
889
+					$time_stamp = time();
890
+		}
856 891
 	}
857 892
 
858 893
 	$number_tries++;
859 894
 
860 895
 	// Broken the law?
861
-	if ($number_tries > 5)
862
-		fatal_lang_error('login_threshold_brute_fail', 'critical');
896
+	if ($number_tries > 5) {
897
+			fatal_lang_error('login_threshold_brute_fail', 'critical');
898
+	}
863 899
 
864 900
 	// Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it!
865 901
 	updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries));
Please login to merge, or discard this patch.
Sources/DbExtra-mysql.php 1 patch
Braces   +66 added lines, -46 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Add the functions implemented in this file to the $smcFunc array.
@@ -23,8 +24,8 @@  discard block
 block discarded – undo
23 24
 {
24 25
 	global $smcFunc;
25 26
 
26
-	if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table')
27
-		$smcFunc += array(
27
+	if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') {
28
+			$smcFunc += array(
28 29
 			'db_backup_table' => 'smf_db_backup_table',
29 30
 			'db_optimize_table' => 'smf_db_optimize_table',
30 31
 			'db_table_sql' => 'smf_db_table_sql',
@@ -32,7 +33,8 @@  discard block
 block discarded – undo
32 33
 			'db_get_version' => 'smf_db_get_version',
33 34
 			'db_get_engine' => 'smf_db_get_engine',
34 35
 		);
35
-}
36
+	}
37
+	}
36 38
 
37 39
 /**
38 40
  * Backup $table to $backup_table.
@@ -74,8 +76,9 @@  discard block
 block discarded – undo
74 76
 			));
75 77
 
76 78
 		// Old school or no school?
77
-		if ($request)
78
-			return $request;
79
+		if ($request) {
80
+					return $request;
81
+		}
79 82
 	}
80 83
 
81 84
 	// At this point, the quick method failed.
@@ -99,8 +102,9 @@  discard block
 block discarded – undo
99 102
 	foreach ($create as $k => $l)
100 103
 	{
101 104
 		// Get the name of the auto_increment column.
102
-		if (strpos($l, 'auto_increment'))
103
-			$auto_inc = trim($l);
105
+		if (strpos($l, 'auto_increment')) {
106
+					$auto_inc = trim($l);
107
+		}
104 108
 
105 109
 		// For the engine type, see if we can work out what it is.
106 110
 		if (strpos($l, 'ENGINE') !== false || strpos($l, 'TYPE') !== false)
@@ -108,30 +112,36 @@  discard block
 block discarded – undo
108 112
 			// Extract the engine type.
109 113
 			preg_match('~(ENGINE|TYPE)=(\w+)(\sDEFAULT)?(\sCHARSET=(\w+))?(\sCOLLATE=(\w+))?~', $l, $match);
110 114
 
111
-			if (!empty($match[1]))
112
-				$engine = $match[1];
115
+			if (!empty($match[1])) {
116
+							$engine = $match[1];
117
+			}
113 118
 
114
-			if (!empty($match[2]))
115
-				$engine = $match[2];
119
+			if (!empty($match[2])) {
120
+							$engine = $match[2];
121
+			}
116 122
 
117
-			if (!empty($match[5]))
118
-				$charset = $match[5];
123
+			if (!empty($match[5])) {
124
+							$charset = $match[5];
125
+			}
119 126
 
120
-			if (!empty($match[7]))
121
-				$collate = $match[7];
127
+			if (!empty($match[7])) {
128
+							$collate = $match[7];
129
+			}
122 130
 		}
123 131
 
124 132
 		// Skip everything but keys...
125
-		if (strpos($l, 'KEY') === false)
126
-			unset($create[$k]);
133
+		if (strpos($l, 'KEY') === false) {
134
+					unset($create[$k]);
135
+		}
127 136
 	}
128 137
 
129
-	if (!empty($create))
130
-		$create = '(
138
+	if (!empty($create)) {
139
+			$create = '(
131 140
 			' . implode('
132 141
 			', $create) . ')';
133
-	else
134
-		$create = '';
142
+	} else {
143
+			$create = '';
144
+	}
135 145
 
136 146
 	$request = $smcFunc['db_query']('', '
137 147
 		CREATE TABLE {raw:backup_table} {raw:create}
@@ -150,8 +160,9 @@  discard block
 block discarded – undo
150 160
 
151 161
 	if ($auto_inc != '')
152 162
 	{
153
-		if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',')
154
-			$auto_inc = substr($auto_inc, 0, -1);
163
+		if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') {
164
+					$auto_inc = substr($auto_inc, 0, -1);
165
+		}
155 166
 
156 167
 		$smcFunc['db_query']('', '
157 168
 			ALTER TABLE {raw:backup_table}
@@ -195,8 +206,9 @@  discard block
 block discarded – undo
195 206
 				'table' => $table,
196 207
 			)
197 208
 		);
198
-	if (!$request)
199
-		return -1;
209
+	if (!$request) {
210
+			return -1;
211
+	}
200 212
 
201 213
 	// How much left?
202 214
 	$request = $smcFunc['db_query']('', '
@@ -239,8 +251,9 @@  discard block
 block discarded – undo
239 251
 		)
240 252
 	);
241 253
 	$tables = array();
242
-	while ($row = $smcFunc['db_fetch_row']($request))
243
-		$tables[] = $row[0];
254
+	while ($row = $smcFunc['db_fetch_row']($request)) {
255
+			$tables[] = $row[0];
256
+	}
244 257
 	$smcFunc['db_free_result']($request);
245 258
 
246 259
 	return $tables;
@@ -284,8 +297,9 @@  discard block
 block discarded – undo
284 297
 		if (!empty($row['Default']) || $row['Null'] !== 'YES')
285 298
 		{
286 299
 			// Make a special case of auto-timestamp.
287
-			if ($row['Default'] == 'CURRENT_TIMESTAMP')
288
-				$schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */';
300
+			if ($row['Default'] == 'CURRENT_TIMESTAMP') {
301
+							$schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */';
302
+			}
289 303
 			// Text shouldn't have a default.
290 304
 			elseif ($row['Default'] !== null)
291 305
 			{
@@ -320,14 +334,16 @@  discard block
 block discarded – undo
320 334
 		$row['Key_name'] = $row['Key_name'] == 'PRIMARY' ? 'PRIMARY KEY' : (empty($row['Non_unique']) ? 'UNIQUE ' : ($row['Comment'] == 'FULLTEXT' || (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') ? 'FULLTEXT ' : 'KEY ')) . '`' . $row['Key_name'] . '`';
321 335
 
322 336
 		// Is this the first column in the index?
323
-		if (empty($indexes[$row['Key_name']]))
324
-			$indexes[$row['Key_name']] = array();
337
+		if (empty($indexes[$row['Key_name']])) {
338
+					$indexes[$row['Key_name']] = array();
339
+		}
325 340
 
326 341
 		// A sub part, like only indexing 15 characters of a varchar.
327
-		if (!empty($row['Sub_part']))
328
-			$indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')';
329
-		else
330
-			$indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`';
342
+		if (!empty($row['Sub_part'])) {
343
+					$indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')';
344
+		} else {
345
+					$indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`';
346
+		}
331 347
 	}
332 348
 	$smcFunc['db_free_result']($result);
333 349
 
@@ -365,8 +381,9 @@  discard block
 block discarded – undo
365 381
 {
366 382
 	static $ver;
367 383
 
368
-	if (!empty($ver))
369
-		return $ver;
384
+	if (!empty($ver)) {
385
+			return $ver;
386
+	}
370 387
 
371 388
 	global $smcFunc;
372 389
 
@@ -391,8 +408,9 @@  discard block
 block discarded – undo
391 408
 	global $smcFunc;
392 409
 	static $db_type;
393 410
 
394
-	if (!empty($db_type))
395
-		return $db_type;
411
+	if (!empty($db_type)) {
412
+			return $db_type;
413
+	}
396 414
 
397 415
 	$request = $smcFunc['db_query']('', 'SELECT @@version_comment');
398 416
 	list ($comment) = $smcFunc['db_fetch_row']($request);
@@ -401,13 +419,15 @@  discard block
 block discarded – undo
401 419
 	// Skip these if we don't have a comment.
402 420
 	if (!empty($comment))
403 421
 	{
404
-		if (stripos($comment, 'percona') !== false)
405
-			return 'Percona';
406
-		if (stripos($comment, 'mariadb') !== false)
407
-			return 'MariaDB';
422
+		if (stripos($comment, 'percona') !== false) {
423
+					return 'Percona';
424
+		}
425
+		if (stripos($comment, 'mariadb') !== false) {
426
+					return 'MariaDB';
427
+		}
428
+	} else {
429
+			return 'fail';
408 430
 	}
409
-	else
410
-		return 'fail';
411 431
 
412 432
 	return 'MySQL';
413 433
 }
Please login to merge, or discard this patch.
Sources/ReportedContent.php 1 patch
Braces   +61 added lines, -46 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Sets and call a function based on the given subaction. Acts as a dispatcher function.
@@ -54,8 +55,9 @@  discard block
 block discarded – undo
54 55
 	);
55 56
 
56 57
 	// This comes under the umbrella of moderating posts.
57
-	if ($context['report_type'] == 'members' || $user_info['mod_cache']['bq'] == '0=1')
58
-		isAllowedTo('moderate_forum');
58
+	if ($context['report_type'] == 'members' || $user_info['mod_cache']['bq'] == '0=1') {
59
+			isAllowedTo('moderate_forum');
60
+	}
59 61
 
60 62
 	$subActions = array(
61 63
 		'show' => 'ShowReports',
@@ -70,11 +72,11 @@  discard block
 block discarded – undo
70 72
 	call_integration_hook('integrate_reported_' . $context['report_type'], array(&$subActions));
71 73
 
72 74
 	// By default we call the open sub-action.
73
-	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]))
74
-		$context['sub_action'] = $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_REQUEST['sa']), ENT_QUOTES);
75
-
76
-	else
77
-		$context['sub_action'] = 'show';
75
+	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
76
+			$context['sub_action'] = $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_REQUEST['sa']), ENT_QUOTES);
77
+	} else {
78
+			$context['sub_action'] = 'show';
79
+	}
78 80
 
79 81
 	// Hi Ho Silver Away!
80 82
 	call_helper($subActions[$context['sub_action']]);
@@ -116,11 +118,13 @@  discard block
 block discarded – undo
116 118
 
117 119
 		// All the ones to update...
118 120
 		$toClose = array();
119
-		foreach ($_POST['close'] as $rid)
120
-			$toClose[] = (int) $rid;
121
+		foreach ($_POST['close'] as $rid) {
122
+					$toClose[] = (int) $rid;
123
+		}
121 124
 
122
-		if (!empty($toClose))
123
-			updateReport('closed', 1, $toClose);
125
+		if (!empty($toClose)) {
126
+					updateReport('closed', 1, $toClose);
127
+		}
124 128
 
125 129
 		// Set the confirmation message.
126 130
 		$_SESSION['rc_confirmation'] = 'close_all';
@@ -175,8 +179,9 @@  discard block
 block discarded – undo
175 179
 	global $context, $sourcedir, $scripturl, $txt;
176 180
 
177 181
 	// Have to at least give us something to work with.
178
-	if (empty($_REQUEST['rid']))
179
-		fatal_lang_error('mc_reportedp_none_found');
182
+	if (empty($_REQUEST['rid'])) {
183
+			fatal_lang_error('mc_reportedp_none_found');
184
+	}
180 185
 
181 186
 	// Integers only please
182 187
 	$report_id = (int) $_REQUEST['rid'];
@@ -184,8 +189,9 @@  discard block
 block discarded – undo
184 189
 	// Get the report details.
185 190
 	$report = getReportDetails($report_id);
186 191
 
187
-	if (!$report)
188
-		fatal_lang_error('mc_no_modreport_found');
192
+	if (!$report) {
193
+			fatal_lang_error('mc_no_modreport_found');
194
+	}
189 195
 
190 196
 	// Build the report data - basic details first, then extra stuff based on the type
191 197
 	$context['report'] = array(
@@ -211,8 +217,7 @@  discard block
 block discarded – undo
211 217
 				'href' => $scripturl . '?action=profile;u=' . $report['id_user'],
212 218
 			),
213 219
 		);
214
-	}
215
-	else
220
+	} else
216 221
 	{
217 222
 		$extraDetails = array(
218 223
 			'topic_id' => $report['id_topic'],
@@ -235,8 +240,9 @@  discard block
 block discarded – undo
235 240
 
236 241
 	$reportComments = getReportComments($report_id);
237 242
 
238
-	if (!empty($reportComments))
239
-		$context['report'] = array_merge($context['report'], $reportComments);
243
+	if (!empty($reportComments)) {
244
+			$context['report'] = array_merge($context['report'], $reportComments);
245
+	}
240 246
 
241 247
 	// What have the other moderators done to this message?
242 248
 	require_once($sourcedir . '/Modlog.php');
@@ -257,8 +263,7 @@  discard block
 block discarded – undo
257 263
 			1,
258 264
 			true,
259 265
 		);
260
-	}
261
-	else
266
+	} else
262 267
 	{
263 268
 		$params = array(
264 269
 			'lm.id_topic = {int:id_topic}
@@ -358,16 +363,16 @@  discard block
 block discarded – undo
358 363
 	createList($listOptions);
359 364
 
360 365
 	// Make sure to get the correct tab selected.
361
-	if ($context['report']['closed'])
362
-		$context[$context['moderation_menu_name']]['current_subsection'] = 'closed';
366
+	if ($context['report']['closed']) {
367
+			$context[$context['moderation_menu_name']]['current_subsection'] = 'closed';
368
+	}
363 369
 
364 370
 	// Finally we are done :P
365 371
 	if ($context['report_type'] == 'members')
366 372
 	{
367 373
 		$context['page_title'] = sprintf($txt['mc_viewmemberreport'], $context['report']['user']['name']);
368 374
 		$context['sub_template'] = 'viewmemberreport';
369
-	}
370
-	else
375
+	} else
371 376
 	{
372 377
 		$context['page_title'] = sprintf($txt['mc_viewmodreport'], $context['report']['subject'], $context['report']['author']['name']);
373 378
 		$context['sub_template'] = 'viewmodreport';
@@ -390,8 +395,9 @@  discard block
 block discarded – undo
390 395
 	global $smcFunc, $scripturl, $user_info, $context;
391 396
 
392 397
 	// The report ID is a must.
393
-	if (empty($_REQUEST['rid']))
394
-		fatal_lang_error('mc_reportedp_none_found');
398
+	if (empty($_REQUEST['rid'])) {
399
+			fatal_lang_error('mc_reportedp_none_found');
400
+	}
395 401
 
396 402
 	// Integers only please.
397 403
 	$report_id = (int) $_REQUEST['rid'];
@@ -416,8 +422,9 @@  discard block
 block discarded – undo
416 422
 		checkSession('get');
417 423
 		validateToken('mod-reportC-delete', 'get');
418 424
 
419
-		if (empty($_REQUEST['mid']))
420
-			fatal_lang_error('mc_reportedp_comment_none_found');
425
+		if (empty($_REQUEST['mid'])) {
426
+					fatal_lang_error('mc_reportedp_comment_none_found');
427
+		}
421 428
 
422 429
 		$comment_id = (int) $_REQUEST['mid'];
423 430
 
@@ -425,15 +432,17 @@  discard block
 block discarded – undo
425 432
 		$comment = getCommentModDetails($comment_id);
426 433
 
427 434
 		// Perhaps somebody else already deleted this fine gem...
428
-		if (empty($comment))
429
-			fatal_lang_error('report_action_message_delete_issue');
435
+		if (empty($comment)) {
436
+					fatal_lang_error('report_action_message_delete_issue');
437
+		}
430 438
 
431 439
 		// Can you actually do this?
432 440
 		$comment_owner = $user_info['id'] == $comment['id_member'];
433 441
 
434 442
 		// Nope! sorry.
435
-		if (!allowedTo('admin_forum') && !$comment_owner)
436
-			fatal_lang_error('report_action_message_delete_cannot');
443
+		if (!allowedTo('admin_forum') && !$comment_owner) {
444
+					fatal_lang_error('report_action_message_delete_cannot');
445
+		}
437 446
 
438 447
 		// All good!
439 448
 		deleteModComment($comment_id);
@@ -458,11 +467,13 @@  discard block
 block discarded – undo
458 467
 	checkSession(isset($_REQUEST['save']) ? 'post' : 'get');
459 468
 
460 469
 	// The report ID is a must.
461
-	if (empty($_REQUEST['rid']))
462
-		fatal_lang_error('mc_reportedp_none_found');
470
+	if (empty($_REQUEST['rid'])) {
471
+			fatal_lang_error('mc_reportedp_none_found');
472
+	}
463 473
 
464
-	if (empty($_REQUEST['mid']))
465
-		fatal_lang_error('mc_reportedp_comment_none_found');
474
+	if (empty($_REQUEST['mid'])) {
475
+			fatal_lang_error('mc_reportedp_comment_none_found');
476
+	}
466 477
 
467 478
 	// Integers only please.
468 479
 	$context['report_id'] = (int) $_REQUEST['rid'];
@@ -470,8 +481,9 @@  discard block
 block discarded – undo
470 481
 
471 482
 	$context['comment'] = getCommentModDetails($context['comment_id']);
472 483
 
473
-	if (empty($context['comment']))
474
-		fatal_lang_error('mc_reportedp_comment_none_found');
484
+	if (empty($context['comment'])) {
485
+			fatal_lang_error('mc_reportedp_comment_none_found');
486
+	}
475 487
 
476 488
 	// Set up the comforting bits...
477 489
 	$context['page_title'] = $txt['mc_reported_posts'];
@@ -482,15 +494,17 @@  discard block
 block discarded – undo
482 494
 		validateToken('mod-reportC-edit');
483 495
 
484 496
 		// Make sure there is some data to edit on the DB.
485
-		if (empty($context['comment']))
486
-			fatal_lang_error('report_action_message_edit_issue');
497
+		if (empty($context['comment'])) {
498
+					fatal_lang_error('report_action_message_edit_issue');
499
+		}
487 500
 
488 501
 		// Still there, good, now lets see if you can actually edit it...
489 502
 		$comment_owner = $user_info['id'] == $context['comment']['id_member'];
490 503
 
491 504
 		// So, you aren't neither an admin or the comment owner huh? that's too bad.
492
-		if (!allowedTo('admin_forum') && !$comment_owner)
493
-			fatal_lang_error('report_action_message_edit_cannot');
505
+		if (!allowedTo('admin_forum') && !$comment_owner) {
506
+					fatal_lang_error('report_action_message_edit_cannot');
507
+		}
494 508
 
495 509
 		// All good!
496 510
 		$edited_comment = trim($smcFunc['htmlspecialchars']($_POST['mod_comment']));
@@ -516,8 +530,9 @@  discard block
 block discarded – undo
516 530
 	checkSession('get');
517 531
 
518 532
 	// We need to do something!
519
-	if (empty($_GET['rid']) && (!isset($_GET['ignore']) || !isset($_GET['closed'])))
520
-		fatal_lang_error('mc_reportedp_none_found');
533
+	if (empty($_GET['rid']) && (!isset($_GET['ignore']) || !isset($_GET['closed']))) {
534
+			fatal_lang_error('mc_reportedp_none_found');
535
+	}
521 536
 
522 537
 	// What are we gonna do?
523 538
 	$action = isset($_GET['ignore']) ? 'ignore' : 'closed';
Please login to merge, or discard this patch.