Completed
Push — release-2.1 ( 38950a...16d9e9 )
by Jeremy
11:52 queued 05:50
created
other/install.php 1 patch
Braces   +472 added lines, -350 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;',
@@ -76,12 +78,14 @@  discard block
 block discarded – undo
76 78
 			$value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value);
77 79
 
78 80
 			// Is it reserved?
79
-			if ($value == 'pg_')
80
-				return $txt['error_db_prefix_reserved'];
81
+			if ($value == 'pg_') {
82
+							return $txt['error_db_prefix_reserved'];
83
+			}
81 84
 
82 85
 			// Is the prefix numeric?
83
-			if (preg_match('~^\d~', $value))
84
-				return $txt['error_db_prefix_numeric'];
86
+			if (preg_match('~^\d~', $value)) {
87
+							return $txt['error_db_prefix_numeric'];
88
+			}
85 89
 
86 90
 			return true;
87 91
 		},
@@ -128,10 +132,11 @@  discard block
 block discarded – undo
128 132
 		$incontext['skip'] = false;
129 133
 
130 134
 		// Call the step and if it returns false that means pause!
131
-		if (function_exists($step[2]) && $step[2]() === false)
132
-			break;
133
-		elseif (function_exists($step[2]))
134
-			$incontext['current_step']++;
135
+		if (function_exists($step[2]) && $step[2]() === false) {
136
+					break;
137
+		} elseif (function_exists($step[2])) {
138
+					$incontext['current_step']++;
139
+		}
135 140
 
136 141
 		// No warnings pass on.
137 142
 		$incontext['warning'] = '';
@@ -147,8 +152,9 @@  discard block
 block discarded – undo
147 152
 	global $databases;
148 153
 
149 154
 	// Just so people using older versions of PHP aren't left in the cold.
150
-	if (!isset($_SERVER['PHP_SELF']))
151
-		$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
155
+	if (!isset($_SERVER['PHP_SELF'])) {
156
+			$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
157
+	}
152 158
 
153 159
 	// Enable error reporting for fatal errors.
154 160
 	error_reporting(E_ERROR | E_PARSE);
@@ -164,21 +170,23 @@  discard block
 block discarded – undo
164 170
 	{
165 171
 		ob_start();
166 172
 
167
-		if (ini_get('session.save_handler') == 'user')
168
-			@ini_set('session.save_handler', 'files');
169
-		if (function_exists('session_start'))
170
-			@session_start();
171
-	}
172
-	else
173
+		if (ini_get('session.save_handler') == 'user') {
174
+					@ini_set('session.save_handler', 'files');
175
+		}
176
+		if (function_exists('session_start')) {
177
+					@session_start();
178
+		}
179
+	} else
173 180
 	{
174 181
 		ob_start('ob_gzhandler');
175 182
 
176
-		if (ini_get('session.save_handler') == 'user')
177
-			@ini_set('session.save_handler', 'files');
183
+		if (ini_get('session.save_handler') == 'user') {
184
+					@ini_set('session.save_handler', 'files');
185
+		}
178 186
 		session_start();
179 187
 
180
-		if (!headers_sent())
181
-			echo '<!DOCTYPE html>
188
+		if (!headers_sent()) {
189
+					echo '<!DOCTYPE html>
182 190
 <html>
183 191
 	<head>
184 192
 		<title>', htmlspecialchars($_GET['pass_string']), '</title>
@@ -187,14 +195,16 @@  discard block
 block discarded – undo
187 195
 		<strong>', htmlspecialchars($_GET['pass_string']), '</strong>
188 196
 	</body>
189 197
 </html>';
198
+		}
190 199
 		exit;
191 200
 	}
192 201
 
193 202
 	// Add slashes, as long as they aren't already being added.
194
-	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0)
195
-		foreach ($_POST as $k => $v)
203
+	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) {
204
+			foreach ($_POST as $k => $v)
196 205
 			if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false)
197 206
 				$_POST[$k] = addslashes($v);
207
+	}
198 208
 
199 209
 	// This is really quite simple; if ?delete is on the URL, delete the installer...
200 210
 	if (isset($_GET['delete']))
@@ -215,8 +225,7 @@  discard block
 block discarded – undo
215 225
 			$ftp->close();
216 226
 
217 227
 			unset($_SESSION['installer_temp_ftp']);
218
-		}
219
-		else
228
+		} else
220 229
 		{
221 230
 			@unlink(__FILE__);
222 231
 
@@ -230,10 +239,11 @@  discard block
 block discarded – undo
230 239
 		// Now just redirect to a blank.png...
231 240
 		$secure = false;
232 241
 
233
-		if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
234
-			$secure = true;
235
-		elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on')
236
-			$secure = true;
242
+		if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
243
+					$secure = true;
244
+		} elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
245
+					$secure = true;
246
+		}
237 247
 
238 248
 		header('location: http' . ($secure ? 's' : '') . '://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) . dirname($_SERVER['PHP_SELF']) . '/Themes/default/images/blank.png');
239 249
 		exit;
@@ -244,10 +254,11 @@  discard block
 block discarded – undo
244 254
 	{
245 255
 		// Get PHP's default timezone, if set
246 256
 		$ini_tz = ini_get('date.timezone');
247
-		if (!empty($ini_tz))
248
-			$timezone_id = $ini_tz;
249
-		else
250
-			$timezone_id = '';
257
+		if (!empty($ini_tz)) {
258
+					$timezone_id = $ini_tz;
259
+		} else {
260
+					$timezone_id = '';
261
+		}
251 262
 
252 263
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
253 264
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -277,8 +288,9 @@  discard block
 block discarded – undo
277 288
 		$dir = dir(dirname(__FILE__) . '/Themes/default/languages');
278 289
 		while ($entry = $dir->read())
279 290
 		{
280
-			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php')
281
-				$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
291
+			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') {
292
+							$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
293
+			}
282 294
 		}
283 295
 		$dir->close();
284 296
 	}
@@ -325,10 +337,11 @@  discard block
 block discarded – undo
325 337
 	}
326 338
 
327 339
 	// Override the language file?
328
-	if (isset($_GET['lang_file']))
329
-		$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
330
-	elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file']))
331
-		$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
340
+	if (isset($_GET['lang_file'])) {
341
+			$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
342
+	} elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) {
343
+			$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
344
+	}
332 345
 
333 346
 	// Make sure it exists, if it doesn't reset it.
334 347
 	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']))
@@ -337,8 +350,9 @@  discard block
 block discarded – undo
337 350
 		list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
338 351
 
339 352
 		// If we have english and some other language, use the other language.  We Americans hate english :P.
340
-		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1)
341
-			list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
353
+		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) {
354
+					list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
355
+		}
342 356
 	}
343 357
 
344 358
 	// And now include the actual language file itself.
@@ -355,15 +369,18 @@  discard block
 block discarded – undo
355 369
 	global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings, $db_port;
356 370
 	global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist, $db_mb4;
357 371
 
358
-	if (empty($sourcedir))
359
-		$sourcedir = dirname(__FILE__) . '/Sources';
372
+	if (empty($sourcedir)) {
373
+			$sourcedir = dirname(__FILE__) . '/Sources';
374
+	}
360 375
 
361 376
 	// Need this to check whether we need the database password.
362 377
 	require(dirname(__FILE__) . '/Settings.php');
363
-	if (!defined('SMF'))
364
-		define('SMF', 1);
365
-	if (empty($smcFunc))
366
-		$smcFunc = array();
378
+	if (!defined('SMF')) {
379
+			define('SMF', 1);
380
+	}
381
+	if (empty($smcFunc)) {
382
+			$smcFunc = array();
383
+	}
367 384
 
368 385
 	$modSettings['disableQueryCheck'] = true;
369 386
 
@@ -374,14 +391,17 @@  discard block
 block discarded – undo
374 391
 
375 392
 		$options = array('persist' => $db_persist);
376 393
 
377
-		if (!empty($db_port))
378
-			$options['port'] = $db_port;
394
+		if (!empty($db_port)) {
395
+					$options['port'] = $db_port;
396
+		}
379 397
 
380
-		if (!empty($db_mb4))
381
-			$options['db_mb4'] = $db_mb4;
398
+		if (!empty($db_mb4)) {
399
+					$options['db_mb4'] = $db_mb4;
400
+		}
382 401
 
383
-		if (!$db_connection)
384
-			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $options);
402
+		if (!$db_connection) {
403
+					$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $options);
404
+		}
385 405
 	}
386 406
 }
387 407
 
@@ -409,8 +429,9 @@  discard block
 block discarded – undo
409 429
 		// @todo REMOVE THIS!!
410 430
 		else
411 431
 		{
412
-			if (function_exists('doStep' . $_GET['step']))
413
-				call_user_func('doStep' . $_GET['step']);
432
+			if (function_exists('doStep' . $_GET['step'])) {
433
+							call_user_func('doStep' . $_GET['step']);
434
+			}
414 435
 		}
415 436
 		// Show the footer.
416 437
 		template_install_below();
@@ -428,8 +449,9 @@  discard block
 block discarded – undo
428 449
 	$incontext['sub_template'] = 'welcome_message';
429 450
 
430 451
 	// Done the submission?
431
-	if (isset($_POST['contbutt']))
432
-		return true;
452
+	if (isset($_POST['contbutt'])) {
453
+			return true;
454
+	}
433 455
 
434 456
 	// See if we think they have already installed it?
435 457
 	if (is_readable(dirname(__FILE__) . '/Settings.php'))
@@ -437,14 +459,17 @@  discard block
 block discarded – undo
437 459
 		$probably_installed = 0;
438 460
 		foreach (file(dirname(__FILE__) . '/Settings.php') as $line)
439 461
 		{
440
-			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line))
441
-				$probably_installed++;
442
-			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line))
443
-				$probably_installed++;
462
+			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) {
463
+							$probably_installed++;
464
+			}
465
+			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) {
466
+							$probably_installed++;
467
+			}
444 468
 		}
445 469
 
446
-		if ($probably_installed == 2)
447
-			$incontext['warning'] = $txt['error_already_installed'];
470
+		if ($probably_installed == 2) {
471
+					$incontext['warning'] = $txt['error_already_installed'];
472
+		}
448 473
 	}
449 474
 
450 475
 	// Is some database support even compiled in?
@@ -459,45 +484,54 @@  discard block
 block discarded – undo
459 484
 				$databases[$key]['supported'] = false;
460 485
 				$notFoundSQLFile = true;
461 486
 				$txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql');
487
+			} else {
488
+							$incontext['supported_databases'][] = $db;
462 489
 			}
463
-			else
464
-				$incontext['supported_databases'][] = $db;
465 490
 		}
466 491
 	}
467 492
 
468 493
 	// Check the PHP version.
469
-	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>=')))
470
-		$error = 'error_php_too_low';
494
+	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) {
495
+			$error = 'error_php_too_low';
496
+	}
471 497
 	// Make sure we have a supported database
472
-	elseif (empty($incontext['supported_databases']))
473
-		$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
498
+	elseif (empty($incontext['supported_databases'])) {
499
+			$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
500
+	}
474 501
 	// How about session support?  Some crazy sysadmin remove it?
475
-	elseif (!function_exists('session_start'))
476
-		$error = 'error_session_missing';
502
+	elseif (!function_exists('session_start')) {
503
+			$error = 'error_session_missing';
504
+	}
477 505
 	// Make sure they uploaded all the files.
478
-	elseif (!file_exists(dirname(__FILE__) . '/index.php'))
479
-		$error = 'error_missing_files';
506
+	elseif (!file_exists(dirname(__FILE__) . '/index.php')) {
507
+			$error = 'error_missing_files';
508
+	}
480 509
 	// Very simple check on the session.save_path for Windows.
481 510
 	// @todo Move this down later if they don't use database-driven sessions?
482
-	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\')
483
-		$error = 'error_session_save_path';
511
+	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') {
512
+			$error = 'error_session_save_path';
513
+	}
484 514
 
485 515
 	// Since each of the three messages would look the same, anyway...
486
-	if (isset($error))
487
-		$incontext['error'] = $txt[$error];
516
+	if (isset($error)) {
517
+			$incontext['error'] = $txt[$error];
518
+	}
488 519
 
489 520
 	// Mod_security blocks everything that smells funny. Let SMF handle security.
490
-	if (!fixModSecurity() && !isset($_GET['overmodsecurity']))
491
-		$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
521
+	if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) {
522
+			$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
523
+	}
492 524
 
493 525
 	// Confirm mbstring is loaded...
494
-	if (!extension_loaded('mbstring'))
495
-		$incontext['error'] = $txt['install_no_mbstring'];
526
+	if (!extension_loaded('mbstring')) {
527
+			$incontext['error'] = $txt['install_no_mbstring'];
528
+	}
496 529
 
497 530
 	// Check for https stream support.
498 531
 	$supported_streams = stream_get_wrappers();
499
-	if (!in_array('https', $supported_streams))
500
-		$incontext['warning'] = $txt['install_no_https'];
532
+	if (!in_array('https', $supported_streams)) {
533
+			$incontext['warning'] = $txt['install_no_https'];
534
+	}
501 535
 
502 536
 	return false;
503 537
 }
@@ -522,12 +556,14 @@  discard block
 block discarded – undo
522 556
 		'Settings_bak.php',
523 557
 	);
524 558
 
525
-	foreach ($incontext['detected_languages'] as $lang => $temp)
526
-		$extra_files[] = 'Themes/default/languages/' . $lang;
559
+	foreach ($incontext['detected_languages'] as $lang => $temp) {
560
+			$extra_files[] = 'Themes/default/languages/' . $lang;
561
+	}
527 562
 
528 563
 	// With mod_security installed, we could attempt to fix it with .htaccess.
529
-	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules()))
530
-		$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
564
+	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) {
565
+			$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
566
+	}
531 567
 
532 568
 	$failed_files = array();
533 569
 
@@ -539,20 +575,23 @@  discard block
 block discarded – undo
539 575
 		foreach ($writable_files as $file)
540 576
 		{
541 577
 			// Some files won't exist, try to address up front
542
-			if (!file_exists(dirname(__FILE__) . '/' . $file))
543
-				@touch(dirname(__FILE__) . '/' . $file);
578
+			if (!file_exists(dirname(__FILE__) . '/' . $file)) {
579
+							@touch(dirname(__FILE__) . '/' . $file);
580
+			}
544 581
 			// NOW do the writable check...
545 582
 			if (!is_writable(dirname(__FILE__) . '/' . $file))
546 583
 			{
547 584
 				@chmod(dirname(__FILE__) . '/' . $file, 0755);
548 585
 
549 586
 				// Well, 755 hopefully worked... if not, try 777.
550
-				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777))
551
-					$failed_files[] = $file;
587
+				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) {
588
+									$failed_files[] = $file;
589
+				}
552 590
 			}
553 591
 		}
554
-		foreach ($extra_files as $file)
555
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
592
+		foreach ($extra_files as $file) {
593
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
594
+		}
556 595
 	}
557 596
 	// Windows is trickier.  Let's try opening for r+...
558 597
 	else
@@ -562,30 +601,35 @@  discard block
 block discarded – undo
562 601
 		foreach ($writable_files as $file)
563 602
 		{
564 603
 			// Folders can't be opened for write... but the index.php in them can ;)
565
-			if (is_dir(dirname(__FILE__) . '/' . $file))
566
-				$file .= '/index.php';
604
+			if (is_dir(dirname(__FILE__) . '/' . $file)) {
605
+							$file .= '/index.php';
606
+			}
567 607
 
568 608
 			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
569 609
 			@chmod(dirname(__FILE__) . '/' . $file, 0777);
570 610
 			$fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+');
571 611
 
572 612
 			// Hmm, okay, try just for write in that case...
573
-			if (!is_resource($fp))
574
-				$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
613
+			if (!is_resource($fp)) {
614
+							$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
615
+			}
575 616
 
576
-			if (!is_resource($fp))
577
-				$failed_files[] = $file;
617
+			if (!is_resource($fp)) {
618
+							$failed_files[] = $file;
619
+			}
578 620
 
579 621
 			@fclose($fp);
580 622
 		}
581
-		foreach ($extra_files as $file)
582
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
623
+		foreach ($extra_files as $file) {
624
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
625
+		}
583 626
 	}
584 627
 
585 628
 	$failure = count($failed_files) >= 1;
586 629
 
587
-	if (!isset($_SERVER))
588
-		return !$failure;
630
+	if (!isset($_SERVER)) {
631
+			return !$failure;
632
+	}
589 633
 
590 634
 	// Put the list into context.
591 635
 	$incontext['failed_files'] = $failed_files;
@@ -633,19 +677,23 @@  discard block
 block discarded – undo
633 677
 
634 678
 		if (!isset($ftp) || $ftp->error !== false)
635 679
 		{
636
-			if (!isset($ftp))
637
-				$ftp = new ftp_connection(null);
680
+			if (!isset($ftp)) {
681
+							$ftp = new ftp_connection(null);
682
+			}
638 683
 			// Save the error so we can mess with listing...
639
-			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message))
640
-				$incontext['ftp_errors'][] = $ftp->last_message;
684
+			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) {
685
+							$incontext['ftp_errors'][] = $ftp->last_message;
686
+			}
641 687
 
642 688
 			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
643 689
 
644
-			if (empty($_POST['ftp_path']) && $found_path)
645
-				$_POST['ftp_path'] = $detect_path;
690
+			if (empty($_POST['ftp_path']) && $found_path) {
691
+							$_POST['ftp_path'] = $detect_path;
692
+			}
646 693
 
647
-			if (!isset($_POST['ftp_username']))
648
-				$_POST['ftp_username'] = $username;
694
+			if (!isset($_POST['ftp_username'])) {
695
+							$_POST['ftp_username'] = $username;
696
+			}
649 697
 
650 698
 			// Set the username etc, into context.
651 699
 			$incontext['ftp'] = array(
@@ -657,8 +705,7 @@  discard block
 block discarded – undo
657 705
 			);
658 706
 
659 707
 			return false;
660
-		}
661
-		else
708
+		} else
662 709
 		{
663 710
 			$_SESSION['installer_temp_ftp'] = array(
664 711
 				'server' => $_POST['ftp_server'],
@@ -672,10 +719,12 @@  discard block
 block discarded – undo
672 719
 
673 720
 			foreach ($failed_files as $file)
674 721
 			{
675
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
676
-					$ftp->chmod($file, 0755);
677
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
678
-					$ftp->chmod($file, 0777);
722
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
723
+									$ftp->chmod($file, 0755);
724
+				}
725
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
726
+									$ftp->chmod($file, 0777);
727
+				}
679 728
 				if (!is_writable(dirname(__FILE__) . '/' . $file))
680 729
 				{
681 730
 					$failed_files_updated[] = $file;
@@ -731,15 +780,17 @@  discard block
 block discarded – undo
731 780
 
732 781
 			if (!$foundOne)
733 782
 			{
734
-				if (isset($db['default_host']))
735
-					$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
783
+				if (isset($db['default_host'])) {
784
+									$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
785
+				}
736 786
 				if (isset($db['default_user']))
737 787
 				{
738 788
 					$incontext['db']['user'] = ini_get($db['default_user']);
739 789
 					$incontext['db']['name'] = ini_get($db['default_user']);
740 790
 				}
741
-				if (isset($db['default_password']))
742
-					$incontext['db']['pass'] = ini_get($db['default_password']);
791
+				if (isset($db['default_password'])) {
792
+									$incontext['db']['pass'] = ini_get($db['default_password']);
793
+				}
743 794
 
744 795
 				// For simplicity and less confusion, leave the port blank by default
745 796
 				$incontext['db']['port'] = '';
@@ -758,10 +809,10 @@  discard block
 block discarded – undo
758 809
 		$incontext['db']['server'] = $_POST['db_server'];
759 810
 		$incontext['db']['prefix'] = $_POST['db_prefix'];
760 811
 
761
-		if (!empty($_POST['db_port']))
762
-			$incontext['db']['port'] = $_POST['db_port'];
763
-	}
764
-	else
812
+		if (!empty($_POST['db_port'])) {
813
+					$incontext['db']['port'] = $_POST['db_port'];
814
+		}
815
+	} else
765 816
 	{
766 817
 		$incontext['db']['prefix'] = 'smf_';
767 818
 	}
@@ -797,10 +848,11 @@  discard block
 block discarded – undo
797 848
 		if (!empty($_POST['db_port']))
798 849
 		{
799 850
 			// For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though.
800
-			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port'))
801
-				$vars['db_port'] = (int) $_POST['db_port'];
802
-			elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432)
803
-				$vars['db_port'] = (int) $_POST['db_port'];
851
+			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) {
852
+							$vars['db_port'] = (int) $_POST['db_port'];
853
+			} elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) {
854
+							$vars['db_port'] = (int) $_POST['db_port'];
855
+			}
804 856
 		}
805 857
 
806 858
 		// God I hope it saved!
@@ -813,8 +865,9 @@  discard block
 block discarded – undo
813 865
 		// Make sure it works.
814 866
 		require(dirname(__FILE__) . '/Settings.php');
815 867
 
816
-		if (empty($sourcedir))
817
-			$sourcedir = dirname(__FILE__) . '/Sources';
868
+		if (empty($sourcedir)) {
869
+					$sourcedir = dirname(__FILE__) . '/Sources';
870
+		}
818 871
 
819 872
 		// Better find the database file!
820 873
 		if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
@@ -824,12 +877,14 @@  discard block
 block discarded – undo
824 877
 		}
825 878
 
826 879
 		// Now include it for database functions!
827
-		if (!defined('SMF'))
828
-			define('SMF', 1);
880
+		if (!defined('SMF')) {
881
+					define('SMF', 1);
882
+		}
829 883
 
830 884
 		$modSettings['disableQueryCheck'] = true;
831
-		if (empty($smcFunc))
832
-			$smcFunc = array();
885
+		if (empty($smcFunc)) {
886
+					$smcFunc = array();
887
+		}
833 888
 
834 889
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
835 890
 
@@ -838,11 +893,13 @@  discard block
 block discarded – undo
838 893
 
839 894
 		$options = array('non_fatal' => true, 'dont_select_db' => !$needsDB);
840 895
 		// Add in the port if needed
841
-		if (!empty($db_port))
842
-			$options['port'] = $db_port;
896
+		if (!empty($db_port)) {
897
+					$options['port'] = $db_port;
898
+		}
843 899
 		
844
-		if (!empty($db_mb4))
845
-			$options['db_mb4'] = $db_mb4;
900
+		if (!empty($db_mb4)) {
901
+					$options['db_mb4'] = $db_mb4;
902
+		}
846 903
 
847 904
 		$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $options);
848 905
 
@@ -928,12 +985,14 @@  discard block
 block discarded – undo
928 985
 	$incontext['page_title'] = $txt['install_settings'];
929 986
 
930 987
 	// Let's see if we got the database type correct.
931
-	if (isset($_POST['db_type'], $databases[$_POST['db_type']]))
932
-		$db_type = $_POST['db_type'];
988
+	if (isset($_POST['db_type'], $databases[$_POST['db_type']])) {
989
+			$db_type = $_POST['db_type'];
990
+	}
933 991
 
934 992
 	// Else we'd better be able to get the connection.
935
-	else
936
-		load_database();
993
+	else {
994
+			load_database();
995
+	}
937 996
 
938 997
 	$db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type;
939 998
 
@@ -942,10 +1001,11 @@  discard block
 block discarded – undo
942 1001
 
943 1002
 		$secure = false;
944 1003
 
945
-		if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
946
-			$secure = true;
947
-		elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on')
948
-			$secure = true;
1004
+		if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
1005
+					$secure = true;
1006
+		} elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
1007
+					$secure = true;
1008
+		}
949 1009
 
950 1010
 	// Now, to put what we've learned together... and add a path.
951 1011
 	$incontext['detected_url'] = 'http' . ($secure ? 's' : '') . '://' . $host . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'));
@@ -977,18 +1037,21 @@  discard block
 block discarded – undo
977 1037
 	// Submitting?
978 1038
 	if (isset($_POST['boardurl']))
979 1039
 	{
980
-		if (substr($_POST['boardurl'], -10) == '/index.php')
981
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
982
-		elseif (substr($_POST['boardurl'], -1) == '/')
983
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
984
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
985
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1040
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
1041
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1042
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
1043
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1044
+		}
1045
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
1046
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1047
+		}
986 1048
 
987 1049
 		//Make sure boardurl is aligned with ssl setting
988
-		if (empty($_POST['force_ssl']))
989
-			$_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://'));
990
-		else
991
-			$_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://'));
1050
+		if (empty($_POST['force_ssl'])) {
1051
+					$_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://'));
1052
+		} else {
1053
+					$_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://'));
1054
+		}
992 1055
 
993 1056
 		// Save these variables.
994 1057
 		$vars = array(
@@ -1027,10 +1090,10 @@  discard block
 block discarded – undo
1027 1090
 			{
1028 1091
 				$incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']);
1029 1092
 				return false;
1030
-			}
1031
-			else
1032
-				// Set the character set here.
1093
+			} else {
1094
+							// Set the character set here.
1033 1095
 				updateSettingsFile(array('db_character_set' => 'utf8'));
1096
+			}
1034 1097
 		}
1035 1098
 
1036 1099
 		// Good, skip on.
@@ -1050,8 +1113,9 @@  discard block
 block discarded – undo
1050 1113
 	$incontext['continue'] = 1;
1051 1114
 
1052 1115
 	// Already done?
1053
-	if (isset($_POST['pop_done']))
1054
-		return true;
1116
+	if (isset($_POST['pop_done'])) {
1117
+			return true;
1118
+	}
1055 1119
 
1056 1120
 	// Reload settings.
1057 1121
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1069,8 +1133,9 @@  discard block
 block discarded – undo
1069 1133
 	$modSettings = array();
1070 1134
 	if ($result !== false)
1071 1135
 	{
1072
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1073
-			$modSettings[$row['variable']] = $row['value'];
1136
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1137
+					$modSettings[$row['variable']] = $row['value'];
1138
+		}
1074 1139
 		$smcFunc['db_free_result']($result);
1075 1140
 
1076 1141
 		// Do they match?  If so, this is just a refresh so charge on!
@@ -1083,20 +1148,22 @@  discard block
 block discarded – undo
1083 1148
 	$modSettings['disableQueryCheck'] = true;
1084 1149
 
1085 1150
 	// If doing UTF8, select it. PostgreSQL requires passing it as a string...
1086
-	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support']))
1087
-		$smcFunc['db_query']('', '
1151
+	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) {
1152
+			$smcFunc['db_query']('', '
1088 1153
 			SET NAMES {string:utf8}',
1089 1154
 			array(
1090 1155
 				'db_error_skip' => true,
1091 1156
 				'utf8' => 'utf8',
1092 1157
 			)
1093 1158
 		);
1159
+	}
1094 1160
 
1095 1161
 	// Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments...
1096
-	if (substr(__DIR__, -1) == '\\')
1097
-		$attachdir = __DIR__ . 'attachments';
1098
-	else
1099
-		$attachdir = __DIR__ . '/attachments';
1162
+	if (substr(__DIR__, -1) == '\\') {
1163
+			$attachdir = __DIR__ . 'attachments';
1164
+	} else {
1165
+			$attachdir = __DIR__ . '/attachments';
1166
+	}
1100 1167
 
1101 1168
 	$replaces = array(
1102 1169
 		'{$db_prefix}' => $db_prefix,
@@ -1113,8 +1180,9 @@  discard block
 block discarded – undo
1113 1180
 
1114 1181
 	foreach ($txt as $key => $value)
1115 1182
 	{
1116
-		if (substr($key, 0, 8) == 'default_')
1117
-			$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1183
+		if (substr($key, 0, 8) == 'default_') {
1184
+					$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1185
+		}
1118 1186
 	}
1119 1187
 	$replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n'));
1120 1188
 
@@ -1129,8 +1197,9 @@  discard block
 block discarded – undo
1129 1197
 
1130 1198
 		while ($row = $smcFunc['db_fetch_assoc']($get_engines))
1131 1199
 		{
1132
-			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT')
1133
-				$engines[] = $row['Engine'];
1200
+			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') {
1201
+							$engines[] = $row['Engine'];
1202
+			}
1134 1203
 		}
1135 1204
 
1136 1205
 		// Done with this now
@@ -1154,8 +1223,7 @@  discard block
 block discarded – undo
1154 1223
 			$replaces['START TRANSACTION;'] = '';
1155 1224
 			$replaces['COMMIT;'] = '';
1156 1225
 		}
1157
-	}
1158
-	else
1226
+	} else
1159 1227
 	{
1160 1228
 		$has_innodb = false;
1161 1229
 	}
@@ -1177,21 +1245,24 @@  discard block
 block discarded – undo
1177 1245
 	foreach ($sql_lines as $count => $line)
1178 1246
 	{
1179 1247
 		// No comments allowed!
1180
-		if (substr(trim($line), 0, 1) != '#')
1181
-			$current_statement .= "\n" . rtrim($line);
1248
+		if (substr(trim($line), 0, 1) != '#') {
1249
+					$current_statement .= "\n" . rtrim($line);
1250
+		}
1182 1251
 
1183 1252
 		// Is this the end of the query string?
1184
-		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines)))
1185
-			continue;
1253
+		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) {
1254
+					continue;
1255
+		}
1186 1256
 
1187 1257
 		// Does this table already exist?  If so, don't insert more data into it!
1188 1258
 		if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists))
1189 1259
 		{
1190 1260
 			preg_match_all('~\)[,;]~', $current_statement, $matches);
1191
-			if (!empty($matches[0]))
1192
-				$incontext['sql_results']['insert_dups'] += count($matches[0]);
1193
-			else
1194
-				$incontext['sql_results']['insert_dups']++;
1261
+			if (!empty($matches[0])) {
1262
+							$incontext['sql_results']['insert_dups'] += count($matches[0]);
1263
+			} else {
1264
+							$incontext['sql_results']['insert_dups']++;
1265
+			}
1195 1266
 
1196 1267
 			$current_statement = '';
1197 1268
 			continue;
@@ -1200,8 +1271,9 @@  discard block
 block discarded – undo
1200 1271
 		if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false)
1201 1272
 		{
1202 1273
 			// Use the appropriate function based on the DB type
1203
-			if ($db_type == 'mysql' || $db_type == 'mysqli')
1204
-				$db_errorno = $db_type . '_errno';
1274
+			if ($db_type == 'mysql' || $db_type == 'mysqli') {
1275
+							$db_errorno = $db_type . '_errno';
1276
+			}
1205 1277
 
1206 1278
 			// Error 1050: Table already exists!
1207 1279
 			// @todo Needs to be made better!
@@ -1216,18 +1288,18 @@  discard block
 block discarded – undo
1216 1288
 				// MySQLi requires a connection object. It's optional with MySQL and Postgres
1217 1289
 				$incontext['failures'][$count] = $smcFunc['db_error']($db_connection);
1218 1290
 			}
1219
-		}
1220
-		else
1291
+		} else
1221 1292
 		{
1222
-			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1223
-				$incontext['sql_results']['tables']++;
1224
-			elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1293
+			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) {
1294
+							$incontext['sql_results']['tables']++;
1295
+			} elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1225 1296
 			{
1226 1297
 				preg_match_all('~\)[,;]~', $current_statement, $matches);
1227
-				if (!empty($matches[0]))
1228
-					$incontext['sql_results']['inserts'] += count($matches[0]);
1229
-				else
1230
-					$incontext['sql_results']['inserts']++;
1298
+				if (!empty($matches[0])) {
1299
+									$incontext['sql_results']['inserts'] += count($matches[0]);
1300
+				} else {
1301
+									$incontext['sql_results']['inserts']++;
1302
+				}
1231 1303
 			}
1232 1304
 		}
1233 1305
 
@@ -1240,15 +1312,17 @@  discard block
 block discarded – undo
1240 1312
 	// Sort out the context for the SQL.
1241 1313
 	foreach ($incontext['sql_results'] as $key => $number)
1242 1314
 	{
1243
-		if ($number == 0)
1244
-			unset($incontext['sql_results'][$key]);
1245
-		else
1246
-			$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1315
+		if ($number == 0) {
1316
+					unset($incontext['sql_results'][$key]);
1317
+		} else {
1318
+					$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1319
+		}
1247 1320
 	}
1248 1321
 
1249 1322
 	// Make sure UTF will be used globally.
1250
-	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'])))
1251
-		$newSettings[] = array('global_character_set', 'UTF-8');
1323
+	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']))) {
1324
+			$newSettings[] = array('global_character_set', 'UTF-8');
1325
+	}
1252 1326
 
1253 1327
 	// Auto-detect local & global cookie settings
1254 1328
 	$url_parts = parse_url($boardurl);
@@ -1277,15 +1351,19 @@  discard block
 block discarded – undo
1277 1351
 
1278 1352
 		// Look for subfolder, if found, set localCookie
1279 1353
 		// Checking for len > 1 ensures you don't have just a slash...
1280
-		if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1)
1281
-			$localCookies = '1';
1354
+		if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) {
1355
+					$localCookies = '1';
1356
+		}
1282 1357
 
1283
-		if (isset($globalCookies))
1284
-			$newSettings[] = array('globalCookies', $globalCookies);
1285
-		if (isset($globalCookiesDomain))
1286
-			$newSettings[] = array('globalCookiesDomain', $globalCookiesDomain);
1287
-		if (isset($localCookies))
1288
-			$newSettings[] = array('localCookies', $localCookies);
1358
+		if (isset($globalCookies)) {
1359
+					$newSettings[] = array('globalCookies', $globalCookies);
1360
+		}
1361
+		if (isset($globalCookiesDomain)) {
1362
+					$newSettings[] = array('globalCookiesDomain', $globalCookiesDomain);
1363
+		}
1364
+		if (isset($localCookies)) {
1365
+					$newSettings[] = array('localCookies', $localCookies);
1366
+		}
1289 1367
 	}
1290 1368
 
1291 1369
 	// Are we allowing stat collection?
@@ -1303,16 +1381,17 @@  discard block
 block discarded – undo
1303 1381
 			fwrite($fp, $out);
1304 1382
 
1305 1383
 			$return_data = '';
1306
-			while (!feof($fp))
1307
-				$return_data .= fgets($fp, 128);
1384
+			while (!feof($fp)) {
1385
+							$return_data .= fgets($fp, 128);
1386
+			}
1308 1387
 
1309 1388
 			fclose($fp);
1310 1389
 
1311 1390
 			// Get the unique site ID.
1312 1391
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1313 1392
 
1314
-			if (!empty($ID[1]))
1315
-				$smcFunc['db_insert']('replace',
1393
+			if (!empty($ID[1])) {
1394
+							$smcFunc['db_insert']('replace',
1316 1395
 					$db_prefix . 'settings',
1317 1396
 					array('variable' => 'string', 'value' => 'string'),
1318 1397
 					array(
@@ -1321,11 +1400,12 @@  discard block
 block discarded – undo
1321 1400
 					),
1322 1401
 					array('variable')
1323 1402
 				);
1403
+			}
1324 1404
 		}
1325 1405
 	}
1326 1406
 	// Don't remove stat collection unless we unchecked the box for real, not from the loop.
1327
-	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats']))
1328
-		$smcFunc['db_query']('', '
1407
+	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) {
1408
+			$smcFunc['db_query']('', '
1329 1409
 			DELETE FROM {db_prefix}settings
1330 1410
 			WHERE variable = {string:enable_sm_stats}',
1331 1411
 			array(
@@ -1333,20 +1413,23 @@  discard block
 block discarded – undo
1333 1413
 				'db_error_skip' => true,
1334 1414
 			)
1335 1415
 		);
1416
+	}
1336 1417
 
1337 1418
 	// Are we enabling SSL?
1338
-	if (!empty($_POST['force_ssl']))
1339
-		$newSettings[] = array('force_ssl', 1);
1419
+	if (!empty($_POST['force_ssl'])) {
1420
+			$newSettings[] = array('force_ssl', 1);
1421
+	}
1340 1422
 
1341 1423
 	// Setting a timezone is required.
1342 1424
 	if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set'))
1343 1425
 	{
1344 1426
 		// Get PHP's default timezone, if set
1345 1427
 		$ini_tz = ini_get('date.timezone');
1346
-		if (!empty($ini_tz))
1347
-			$timezone_id = $ini_tz;
1348
-		else
1349
-			$timezone_id = '';
1428
+		if (!empty($ini_tz)) {
1429
+					$timezone_id = $ini_tz;
1430
+		} else {
1431
+					$timezone_id = '';
1432
+		}
1350 1433
 
1351 1434
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
1352 1435
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -1355,8 +1438,9 @@  discard block
 block discarded – undo
1355 1438
 			$timezone_id = timezone_name_from_abbr('', $server_offset, 0);
1356 1439
 		}
1357 1440
 
1358
-		if (date_default_timezone_set($timezone_id))
1359
-			$newSettings[] = array('default_timezone', $timezone_id);
1441
+		if (date_default_timezone_set($timezone_id)) {
1442
+					$newSettings[] = array('default_timezone', $timezone_id);
1443
+		}
1360 1444
 	}
1361 1445
 
1362 1446
 	if (!empty($newSettings))
@@ -1387,16 +1471,18 @@  discard block
 block discarded – undo
1387 1471
 	}
1388 1472
 
1389 1473
 	// MySQL specific stuff
1390
-	if (substr($db_type, 0, 5) != 'mysql')
1391
-		return false;
1474
+	if (substr($db_type, 0, 5) != 'mysql') {
1475
+			return false;
1476
+	}
1392 1477
 
1393 1478
 	// Find database user privileges.
1394 1479
 	$privs = array();
1395 1480
 	$get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array());
1396 1481
 	while ($row = $smcFunc['db_fetch_assoc']($get_privs))
1397 1482
 	{
1398
-		if ($row['Privilege'] == 'Alter')
1399
-			$privs[] = $row['Privilege'];
1483
+		if ($row['Privilege'] == 'Alter') {
1484
+					$privs[] = $row['Privilege'];
1485
+		}
1400 1486
 	}
1401 1487
 	$smcFunc['db_free_result']($get_privs);
1402 1488
 
@@ -1426,8 +1512,9 @@  discard block
 block discarded – undo
1426 1512
 	$incontext['continue'] = 1;
1427 1513
 
1428 1514
 	// Skipping?
1429
-	if (!empty($_POST['skip']))
1430
-		return true;
1515
+	if (!empty($_POST['skip'])) {
1516
+			return true;
1517
+	}
1431 1518
 
1432 1519
 	// Need this to check whether we need the database password.
1433 1520
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1444,18 +1531,22 @@  discard block
 block discarded – undo
1444 1531
 	// We need this to properly hash the password for Admin
1445 1532
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) {
1446 1533
 			global $sourcedir;
1447
-			if (function_exists('mb_strtolower'))
1448
-				return mb_strtolower($string, 'UTF-8');
1534
+			if (function_exists('mb_strtolower')) {
1535
+							return mb_strtolower($string, 'UTF-8');
1536
+			}
1449 1537
 			require_once($sourcedir . '/Subs-Charset.php');
1450 1538
 			return utf8_strtolower($string);
1451 1539
 		};
1452 1540
 
1453
-	if (!isset($_POST['username']))
1454
-		$_POST['username'] = '';
1455
-	if (!isset($_POST['email']))
1456
-		$_POST['email'] = '';
1457
-	if (!isset($_POST['server_email']))
1458
-		$_POST['server_email'] = '';
1541
+	if (!isset($_POST['username'])) {
1542
+			$_POST['username'] = '';
1543
+	}
1544
+	if (!isset($_POST['email'])) {
1545
+			$_POST['email'] = '';
1546
+	}
1547
+	if (!isset($_POST['server_email'])) {
1548
+			$_POST['server_email'] = '';
1549
+	}
1459 1550
 
1460 1551
 	$incontext['username'] = htmlspecialchars(stripslashes($_POST['username']));
1461 1552
 	$incontext['email'] = htmlspecialchars(stripslashes($_POST['email']));
@@ -1474,8 +1565,9 @@  discard block
 block discarded – undo
1474 1565
 			'admin_group' => 1,
1475 1566
 		)
1476 1567
 	);
1477
-	if ($smcFunc['db_num_rows']($request) != 0)
1478
-		$incontext['skip'] = 1;
1568
+	if ($smcFunc['db_num_rows']($request) != 0) {
1569
+			$incontext['skip'] = 1;
1570
+	}
1479 1571
 	$smcFunc['db_free_result']($request);
1480 1572
 
1481 1573
 	// Trying to create an account?
@@ -1506,8 +1598,9 @@  discard block
 block discarded – undo
1506 1598
 		}
1507 1599
 
1508 1600
 		// Update the webmaster's email?
1509
-		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]'))
1510
-			updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1601
+		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) {
1602
+					updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1603
+		}
1511 1604
 
1512 1605
 		// Work out whether we're going to have dodgy characters and remove them.
1513 1606
 		$invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0;
@@ -1530,32 +1623,27 @@  discard block
 block discarded – undo
1530 1623
 			$smcFunc['db_free_result']($result);
1531 1624
 
1532 1625
 			$incontext['account_existed'] = $txt['error_user_settings_taken'];
1533
-		}
1534
-		elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1626
+		} elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1535 1627
 		{
1536 1628
 			// Try the previous step again.
1537 1629
 			$incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long'];
1538 1630
 			return false;
1539
-		}
1540
-		elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1631
+		} elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1541 1632
 		{
1542 1633
 			// Try the previous step again.
1543 1634
 			$incontext['error'] = $txt['error_invalid_characters_username'];
1544 1635
 			return false;
1545
-		}
1546
-		elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1636
+		} elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1547 1637
 		{
1548 1638
 			// One step back, this time fill out a proper admin email address.
1549 1639
 			$incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']);
1550 1640
 			return false;
1551
-		}
1552
-		elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1641
+		} elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1553 1642
 		{
1554 1643
 			// One step back, this time fill out a proper admin email address.
1555 1644
 			$incontext['error'] = $txt['error_valid_server_email_needed'];
1556 1645
 			return false;
1557
-		}
1558
-		elseif ($_POST['username'] != '')
1646
+		} elseif ($_POST['username'] != '')
1559 1647
 		{
1560 1648
 			$incontext['member_salt'] = substr(md5(mt_rand()), 0, 4);
1561 1649
 
@@ -1623,17 +1711,19 @@  discard block
 block discarded – undo
1623 1711
 	reloadSettings();
1624 1712
 
1625 1713
 	// Bring a warning over.
1626
-	if (!empty($incontext['account_existed']))
1627
-		$incontext['warning'] = $incontext['account_existed'];
1714
+	if (!empty($incontext['account_existed'])) {
1715
+			$incontext['warning'] = $incontext['account_existed'];
1716
+	}
1628 1717
 
1629
-	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support']))
1630
-		$smcFunc['db_query']('', '
1718
+	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) {
1719
+			$smcFunc['db_query']('', '
1631 1720
 			SET NAMES {string:db_character_set}',
1632 1721
 			array(
1633 1722
 				'db_character_set' => $db_character_set,
1634 1723
 				'db_error_skip' => true,
1635 1724
 			)
1636 1725
 		);
1726
+	}
1637 1727
 
1638 1728
 	// As track stats is by default enabled let's add some activity.
1639 1729
 	$smcFunc['db_insert']('ignore',
@@ -1654,14 +1744,16 @@  discard block
 block discarded – undo
1654 1744
 	// Only proceed if we can load the data.
1655 1745
 	if ($request)
1656 1746
 	{
1657
-		while ($row = $smcFunc['db_fetch_row']($request))
1658
-			$modSettings[$row[0]] = $row[1];
1747
+		while ($row = $smcFunc['db_fetch_row']($request)) {
1748
+					$modSettings[$row[0]] = $row[1];
1749
+		}
1659 1750
 		$smcFunc['db_free_result']($request);
1660 1751
 	}
1661 1752
 
1662 1753
 	// Automatically log them in ;)
1663
-	if (isset($incontext['member_id']) && isset($incontext['member_salt']))
1664
-		setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1754
+	if (isset($incontext['member_id']) && isset($incontext['member_salt'])) {
1755
+			setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1756
+	}
1665 1757
 
1666 1758
 	$result = $smcFunc['db_query']('', '
1667 1759
 		SELECT value
@@ -1672,13 +1764,14 @@  discard block
 block discarded – undo
1672 1764
 			'db_error_skip' => true,
1673 1765
 		)
1674 1766
 	);
1675
-	if ($smcFunc['db_num_rows']($result) != 0)
1676
-		list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1767
+	if ($smcFunc['db_num_rows']($result) != 0) {
1768
+			list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1769
+	}
1677 1770
 	$smcFunc['db_free_result']($result);
1678 1771
 
1679
-	if (empty($db_sessions))
1680
-		$_SESSION['admin_time'] = time();
1681
-	else
1772
+	if (empty($db_sessions)) {
1773
+			$_SESSION['admin_time'] = time();
1774
+	} else
1682 1775
 	{
1683 1776
 		$_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211);
1684 1777
 
@@ -1702,8 +1795,9 @@  discard block
 block discarded – undo
1702 1795
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1703 1796
 		function($string){
1704 1797
 			global $sourcedir;
1705
-			if (function_exists('mb_strtolower'))
1706
-				return mb_strtolower($string, 'UTF-8');
1798
+			if (function_exists('mb_strtolower')) {
1799
+							return mb_strtolower($string, 'UTF-8');
1800
+			}
1707 1801
 			require_once($sourcedir . '/Subs-Charset.php');
1708 1802
 			return utf8_strtolower($string);
1709 1803
 		};
@@ -1719,8 +1813,9 @@  discard block
 block discarded – undo
1719 1813
 		)
1720 1814
 	);
1721 1815
 	$context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8';
1722
-	if ($smcFunc['db_num_rows']($request) > 0)
1723
-		updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1816
+	if ($smcFunc['db_num_rows']($request) > 0) {
1817
+			updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1818
+	}
1724 1819
 	$smcFunc['db_free_result']($request);
1725 1820
 
1726 1821
 	// Now is the perfect time to fetch the SM files.
@@ -1739,8 +1834,9 @@  discard block
 block discarded – undo
1739 1834
 
1740 1835
 	// Check if we need some stupid MySQL fix.
1741 1836
 	$server_version = $smcFunc['db_server_info']();
1742
-	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1743
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1837
+	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1838
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1839
+	}
1744 1840
 
1745 1841
 	// Some final context for the template.
1746 1842
 	$incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\';
@@ -1760,8 +1856,9 @@  discard block
 block discarded – undo
1760 1856
 	$settingsArray = file(dirname(__FILE__) . '/Settings.php');
1761 1857
 
1762 1858
 	// @todo Do we just want to read the file in clean, and split it this way always?
1763
-	if (count($settingsArray) == 1)
1764
-		$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1859
+	if (count($settingsArray) == 1) {
1860
+			$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1861
+	}
1765 1862
 
1766 1863
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
1767 1864
 	{
@@ -1769,25 +1866,29 @@  discard block
 block discarded – undo
1769 1866
 		if (trim($settingsArray[$i]) == 'if (file_exists(dirname(__FILE__) . \'/install.php\'))' && trim($settingsArray[$i + 1]) == '{' && trim($settingsArray[$i + 9]) == '}')
1770 1867
 		{
1771 1868
 			// Set the ten lines to nothing.
1772
-			for ($j=0; $j < 10; $j++)
1773
-				$settingsArray[$i++] = '';
1869
+			for ($j=0; $j < 10; $j++) {
1870
+							$settingsArray[$i++] = '';
1871
+			}
1774 1872
 
1775 1873
 			continue;
1776 1874
 		}
1777 1875
 
1778
-		if (trim($settingsArray[$i]) == '?' . '>')
1779
-			$settingsArray[$i] = '';
1876
+		if (trim($settingsArray[$i]) == '?' . '>') {
1877
+					$settingsArray[$i] = '';
1878
+		}
1780 1879
 
1781 1880
 		// Don't trim or bother with it if it's not a variable.
1782
-		if (substr($settingsArray[$i], 0, 1) != '$')
1783
-			continue;
1881
+		if (substr($settingsArray[$i], 0, 1) != '$') {
1882
+					continue;
1883
+		}
1784 1884
 
1785 1885
 		$settingsArray[$i] = rtrim($settingsArray[$i]) . "\n";
1786 1886
 
1787
-		foreach ($vars as $var => $val)
1788
-			if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1887
+		foreach ($vars as $var => $val) {
1888
+					if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1789 1889
 			{
1790 1890
 				$comment = strstr($settingsArray[$i], '#');
1891
+		}
1791 1892
 				$settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n");
1792 1893
 				unset($vars[$var]);
1793 1894
 			}
@@ -1797,36 +1898,41 @@  discard block
 block discarded – undo
1797 1898
 	if (!empty($vars))
1798 1899
 	{
1799 1900
 		$settingsArray[$i++] = '';
1800
-		foreach ($vars as $var => $val)
1801
-			$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1901
+		foreach ($vars as $var => $val) {
1902
+					$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1903
+		}
1802 1904
 	}
1803 1905
 
1804 1906
 	// Blank out the file - done to fix a oddity with some servers.
1805 1907
 	$fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w');
1806
-	if (!$fp)
1807
-		return false;
1908
+	if (!$fp) {
1909
+			return false;
1910
+	}
1808 1911
 	fclose($fp);
1809 1912
 
1810 1913
 	$fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+');
1811 1914
 
1812 1915
 	// Gotta have one of these ;)
1813
-	if (trim($settingsArray[0]) != '<?php')
1814
-		fwrite($fp, "<?php\n");
1916
+	if (trim($settingsArray[0]) != '<?php') {
1917
+			fwrite($fp, "<?php\n");
1918
+	}
1815 1919
 
1816 1920
 	$lines = count($settingsArray);
1817 1921
 	for ($i = 0; $i < $lines - 1; $i++)
1818 1922
 	{
1819 1923
 		// Don't just write a bunch of blank lines.
1820
-		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '')
1821
-			fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1924
+		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') {
1925
+					fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1926
+		}
1822 1927
 	}
1823 1928
 	fwrite($fp, $settingsArray[$i] . '?' . '>');
1824 1929
 	fclose($fp);
1825 1930
 
1826 1931
 	// Even though on normal installations the filemtime should prevent this being used by the installer incorrectly
1827 1932
 	// it seems that there are times it might not. So let's MAKE it dump the cache.
1828
-	if (function_exists('opcache_invalidate'))
1829
-		opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1933
+	if (function_exists('opcache_invalidate')) {
1934
+			opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1935
+	}
1830 1936
 
1831 1937
 	return true;
1832 1938
 }
@@ -1836,10 +1942,11 @@  discard block
 block discarded – undo
1836 1942
 	global $cachedir;
1837 1943
 
1838 1944
 	// Write out the db_last_error file with the error timestamp
1839
-	if (!empty($cachedir) && is_writable($cachedir))
1840
-		file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>');
1841
-	else
1842
-		file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>');
1945
+	if (!empty($cachedir) && is_writable($cachedir)) {
1946
+			file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>');
1947
+	} else {
1948
+			file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>');
1949
+	}
1843 1950
 
1844 1951
 	return true;
1845 1952
 }
@@ -1856,9 +1963,9 @@  discard block
 block discarded – undo
1856 1963
 	SecFilterScanPOST Off
1857 1964
 </IfModule>';
1858 1965
 
1859
-	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules()))
1860
-		return true;
1861
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1966
+	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) {
1967
+			return true;
1968
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1862 1969
 	{
1863 1970
 		$current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess'));
1864 1971
 
@@ -1870,29 +1977,28 @@  discard block
 block discarded – undo
1870 1977
 				fwrite($ht_handle, $htaccess_addition);
1871 1978
 				fclose($ht_handle);
1872 1979
 				return true;
1980
+			} else {
1981
+							return false;
1873 1982
 			}
1874
-			else
1875
-				return false;
1983
+		} else {
1984
+					return true;
1876 1985
 		}
1877
-		else
1878
-			return true;
1879
-	}
1880
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess'))
1881
-		return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1882
-	elseif (is_writable(dirname(__FILE__)))
1986
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess')) {
1987
+			return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1988
+	} elseif (is_writable(dirname(__FILE__)))
1883 1989
 	{
1884 1990
 		if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w'))
1885 1991
 		{
1886 1992
 			fwrite($ht_handle, $htaccess_addition);
1887 1993
 			fclose($ht_handle);
1888 1994
 			return true;
1995
+		} else {
1996
+					return false;
1889 1997
 		}
1890
-		else
1998
+	} else {
1891 1999
 			return false;
1892 2000
 	}
1893
-	else
1894
-		return false;
1895
-}
2001
+	}
1896 2002
 
1897 2003
 function template_install_above()
1898 2004
 {
@@ -1931,9 +2037,10 @@  discard block
 block discarded – undo
1931 2037
 							<label for="installer_language">', $txt['installer_language'], ':</label>
1932 2038
 							<select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">';
1933 2039
 
1934
-		foreach ($incontext['detected_languages'] as $lang => $name)
1935
-			echo '
2040
+		foreach ($incontext['detected_languages'] as $lang => $name) {
2041
+					echo '
1936 2042
 								<option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>';
2043
+		}
1937 2044
 
1938 2045
 		echo '
1939 2046
 							</select>
@@ -1953,9 +2060,10 @@  discard block
 block discarded – undo
1953 2060
 					<h2>', $txt['upgrade_progress'], '</h2>
1954 2061
 					<ul>';
1955 2062
 
1956
-	foreach ($incontext['steps'] as $num => $step)
1957
-		echo '
2063
+	foreach ($incontext['steps'] as $num => $step) {
2064
+			echo '
1958 2065
 						<li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
2066
+	}
1959 2067
 
1960 2068
 	echo '
1961 2069
 					</ul>
@@ -1981,20 +2089,23 @@  discard block
 block discarded – undo
1981 2089
 		echo '
1982 2090
 							<div class="floatright">';
1983 2091
 
1984
-		if (!empty($incontext['continue']))
1985
-			echo '
2092
+		if (!empty($incontext['continue'])) {
2093
+					echo '
1986 2094
 								<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button">';
1987
-		if (!empty($incontext['skip']))
1988
-			echo '
2095
+		}
2096
+		if (!empty($incontext['skip'])) {
2097
+					echo '
1989 2098
 								<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button">';
2099
+		}
1990 2100
 		echo '
1991 2101
 							</div>';
1992 2102
 	}
1993 2103
 
1994 2104
 	// Show the closing form tag and other data only if not in the last step
1995
-	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step'])
1996
-		echo '
2105
+	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) {
2106
+			echo '
1997 2107
 						</form>';
2108
+	}
1998 2109
 
1999 2110
 	echo '
2000 2111
 					</div><!-- .panel -->
@@ -2027,13 +2138,15 @@  discard block
 block discarded – undo
2027 2138
 		</div>';
2028 2139
 
2029 2140
 	// Show the warnings, or not.
2030
-	if (template_warning_divs())
2031
-		echo '
2141
+	if (template_warning_divs()) {
2142
+			echo '
2032 2143
 		<h3>', $txt['install_all_lovely'], '</h3>';
2144
+	}
2033 2145
 
2034 2146
 	// Say we want the continue button!
2035
-	if (empty($incontext['error']))
2036
-		$incontext['continue'] = 1;
2147
+	if (empty($incontext['error'])) {
2148
+			$incontext['continue'] = 1;
2149
+	}
2037 2150
 
2038 2151
 	// For the latest version stuff.
2039 2152
 	echo '
@@ -2067,19 +2180,21 @@  discard block
 block discarded – undo
2067 2180
 	global $txt, $incontext;
2068 2181
 
2069 2182
 	// Errors are very serious..
2070
-	if (!empty($incontext['error']))
2071
-		echo '
2183
+	if (!empty($incontext['error'])) {
2184
+			echo '
2072 2185
 		<div class="errorbox">
2073 2186
 			<h3>', $txt['upgrade_critical_error'], '</h3>
2074 2187
 			', $incontext['error'], '
2075 2188
 		</div>';
2189
+	}
2076 2190
 	// A warning message?
2077
-	elseif (!empty($incontext['warning']))
2078
-		echo '
2191
+	elseif (!empty($incontext['warning'])) {
2192
+			echo '
2079 2193
 		<div class="errorbox">
2080 2194
 			<h3>', $txt['upgrade_warning'], '</h3>
2081 2195
 			', $incontext['warning'], '
2082 2196
 		</div>';
2197
+	}
2083 2198
 
2084 2199
 	return empty($incontext['error']) && empty($incontext['warning']);
2085 2200
 }
@@ -2095,26 +2210,29 @@  discard block
 block discarded – undo
2095 2210
 			<li>', $incontext['failed_files']), '</li>
2096 2211
 		</ul>';
2097 2212
 
2098
-	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux')
2099
-		echo '
2213
+	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') {
2214
+			echo '
2100 2215
 		<hr>
2101 2216
 		<p>', $txt['chmod_linux_info'], '</p>
2102 2217
 		<samp># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</samp>';
2218
+	}
2103 2219
 
2104 2220
 	// This is serious!
2105
-	if (!template_warning_divs())
2106
-		return;
2221
+	if (!template_warning_divs()) {
2222
+			return;
2223
+	}
2107 2224
 
2108 2225
 	echo '
2109 2226
 		<hr>
2110 2227
 		<p>', $txt['ftp_setup_info'], '</p>';
2111 2228
 
2112
-	if (!empty($incontext['ftp_errors']))
2113
-		echo '
2229
+	if (!empty($incontext['ftp_errors'])) {
2230
+			echo '
2114 2231
 		<div class="error_message">
2115 2232
 			', $txt['error_ftp_no_connect'], '<br><br>
2116 2233
 			<code>', implode('<br>', $incontext['ftp_errors']), '</code>
2117 2234
 		</div>';
2235
+	}
2118 2236
 
2119 2237
 	echo '
2120 2238
 		<form action="', $incontext['form_url'], '" method="post">
@@ -2183,16 +2301,16 @@  discard block
 block discarded – undo
2183 2301
 			<dd>
2184 2302
 				<select name="db_type" id="db_type_input" onchange="toggleDBInput();">';
2185 2303
 
2186
-	foreach ($incontext['supported_databases'] as $key => $db)
2187
-			echo '
2304
+	foreach ($incontext['supported_databases'] as $key => $db) {
2305
+				echo '
2188 2306
 					<option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>';
2307
+	}
2189 2308
 
2190 2309
 	echo '
2191 2310
 				</select>
2192 2311
 				<div class="smalltext">', $txt['db_settings_type_info'], '</div>
2193 2312
 			</dd>';
2194
-	}
2195
-	else
2313
+	} else
2196 2314
 	{
2197 2315
 		echo '
2198 2316
 			<dd>
@@ -2360,9 +2478,10 @@  discard block
 block discarded – undo
2360 2478
 		<div class="red">', $txt['error_db_queries'], '</div>
2361 2479
 		<ul>';
2362 2480
 
2363
-		foreach ($incontext['failures'] as $line => $fail)
2364
-			echo '
2481
+		foreach ($incontext['failures'] as $line => $fail) {
2482
+					echo '
2365 2483
 			<li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>';
2484
+		}
2366 2485
 
2367 2486
 		echo '
2368 2487
 		</ul>';
@@ -2427,15 +2546,16 @@  discard block
 block discarded – undo
2427 2546
 			</dd>
2428 2547
 		</dl>';
2429 2548
 
2430
-	if ($incontext['require_db_confirm'])
2431
-		echo '
2549
+	if ($incontext['require_db_confirm']) {
2550
+			echo '
2432 2551
 		<h2>', $txt['user_settings_database'], '</h2>
2433 2552
 		<p>', $txt['user_settings_database_info'], '</p>
2434 2553
 
2435 2554
 		<div class="lefttext">
2436 2555
 			<input type="password" name="password3" size="30">
2437 2556
 		</div>';
2438
-}
2557
+	}
2558
+	}
2439 2559
 
2440 2560
 // Tell them it's done, and to delete.
2441 2561
 function template_delete_install()
@@ -2448,13 +2568,14 @@  discard block
 block discarded – undo
2448 2568
 	template_warning_divs();
2449 2569
 
2450 2570
 	// Install directory still writable?
2451
-	if ($incontext['dir_still_writable'])
2452
-		echo '
2571
+	if ($incontext['dir_still_writable']) {
2572
+			echo '
2453 2573
 		<p><em>', $txt['still_writable'], '</em></p>';
2574
+	}
2454 2575
 
2455 2576
 	// Don't show the box if it's like 99% sure it won't work :P.
2456
-	if ($incontext['probably_delete_install'])
2457
-		echo '
2577
+	if ($incontext['probably_delete_install']) {
2578
+			echo '
2458 2579
 		<label>
2459 2580
 			<input type="checkbox" id="delete_self" onclick="doTheDelete();">
2460 2581
 			<strong>', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</strong>
@@ -2470,6 +2591,7 @@  discard block
 block discarded – undo
2470 2591
 				theCheck.disabled = true;
2471 2592
 			}
2472 2593
 		</script>';
2594
+	}
2473 2595
 
2474 2596
 	echo '
2475 2597
 		<p>', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '</p>
Please login to merge, or discard this patch.