Completed
Push — release-2.1 ( 2ccfa4...ab13ea )
by Michael
07:51
created
other/install.php 1 patch
Braces   +441 added lines, -328 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
 		},
@@ -126,10 +130,11 @@  discard block
 block discarded – undo
126 130
 		$incontext['skip'] = false;
127 131
 
128 132
 		// Call the step and if it returns false that means pause!
129
-		if (function_exists($step[2]) && $step[2]() === false)
130
-			break;
131
-		elseif (function_exists($step[2]))
132
-			$incontext['current_step']++;
133
+		if (function_exists($step[2]) && $step[2]() === false) {
134
+					break;
135
+		} elseif (function_exists($step[2])) {
136
+					$incontext['current_step']++;
137
+		}
133 138
 
134 139
 		// No warnings pass on.
135 140
 		$incontext['warning'] = '';
@@ -145,12 +150,14 @@  discard block
 block discarded – undo
145 150
 	global $databases, $incontext;
146 151
 
147 152
 	// Just so people using older versions of PHP aren't left in the cold.
148
-	if (!isset($_SERVER['PHP_SELF']))
149
-		$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
153
+	if (!isset($_SERVER['PHP_SELF'])) {
154
+			$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
155
+	}
150 156
 
151 157
 	// Turn off magic quotes runtime and enable error reporting.
152
-	if (function_exists('set_magic_quotes_runtime'))
153
-		@set_magic_quotes_runtime(0);
158
+	if (function_exists('set_magic_quotes_runtime')) {
159
+			@set_magic_quotes_runtime(0);
160
+	}
154 161
 	error_reporting(E_ALL);
155 162
 
156 163
 	// Fun.  Low PHP version...
@@ -164,21 +171,23 @@  discard block
 block discarded – undo
164 171
 	{
165 172
 		ob_start();
166 173
 
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
174
+		if (ini_get('session.save_handler') == 'user') {
175
+					@ini_set('session.save_handler', 'files');
176
+		}
177
+		if (function_exists('session_start')) {
178
+					@session_start();
179
+		}
180
+	} else
173 181
 	{
174 182
 		ob_start('ob_gzhandler');
175 183
 
176
-		if (ini_get('session.save_handler') == 'user')
177
-			@ini_set('session.save_handler', 'files');
184
+		if (ini_get('session.save_handler') == 'user') {
185
+					@ini_set('session.save_handler', 'files');
186
+		}
178 187
 		session_start();
179 188
 
180
-		if (!headers_sent())
181
-			echo '<!DOCTYPE html>
189
+		if (!headers_sent()) {
190
+					echo '<!DOCTYPE html>
182 191
 <html>
183 192
 	<head>
184 193
 		<title>', htmlspecialchars($_GET['pass_string']), '</title>
@@ -187,6 +196,7 @@  discard block
 block discarded – undo
187 196
 		<strong>', htmlspecialchars($_GET['pass_string']), '</strong>
188 197
 	</body>
189 198
 </html>';
199
+		}
190 200
 		exit;
191 201
 	}
192 202
 
@@ -195,16 +205,18 @@  discard block
 block discarded – undo
195 205
 	{
196 206
 		$incontext['remote_files_available'] = false;
197 207
 		$test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1);
198
-		if ($test)
199
-			$incontext['remote_files_available'] = true;
208
+		if ($test) {
209
+					$incontext['remote_files_available'] = true;
210
+		}
200 211
 		@fclose($test);
201 212
 	}
202 213
 
203 214
 	// Add slashes, as long as they aren't already being added.
204
-	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0)
205
-		foreach ($_POST as $k => $v)
215
+	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) {
216
+			foreach ($_POST as $k => $v)
206 217
 			if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false)
207 218
 				$_POST[$k] = addslashes($v);
219
+	}
208 220
 
209 221
 	// This is really quite simple; if ?delete is on the URL, delete the installer...
210 222
 	if (isset($_GET['delete']))
@@ -225,8 +237,7 @@  discard block
 block discarded – undo
225 237
 			$ftp->close();
226 238
 
227 239
 			unset($_SESSION['installer_temp_ftp']);
228
-		}
229
-		else
240
+		} else
230 241
 		{
231 242
 			@unlink(__FILE__);
232 243
 
@@ -247,10 +258,11 @@  discard block
 block discarded – undo
247 258
 	{
248 259
 		// Get PHP's default timezone, if set
249 260
 		$ini_tz = ini_get('date.timezone');
250
-		if (!empty($ini_tz))
251
-			$timezone_id = $ini_tz;
252
-		else
253
-			$timezone_id = '';
261
+		if (!empty($ini_tz)) {
262
+					$timezone_id = $ini_tz;
263
+		} else {
264
+					$timezone_id = '';
265
+		}
254 266
 
255 267
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
256 268
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -280,8 +292,9 @@  discard block
 block discarded – undo
280 292
 		$dir = dir(dirname(__FILE__) . '/Themes/default/languages');
281 293
 		while ($entry = $dir->read())
282 294
 		{
283
-			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php')
284
-				$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
295
+			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') {
296
+							$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
297
+			}
285 298
 		}
286 299
 		$dir->close();
287 300
 	}
@@ -316,10 +329,11 @@  discard block
 block discarded – undo
316 329
 	}
317 330
 
318 331
 	// Override the language 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'];
332
+	if (isset($_GET['lang_file'])) {
333
+			$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
334
+	} elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) {
335
+			$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
336
+	}
323 337
 
324 338
 	// Make sure it exists, if it doesn't reset it.
325 339
 	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']))
@@ -328,8 +342,9 @@  discard block
 block discarded – undo
328 342
 		list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
329 343
 
330 344
 		// If we have english and some other language, use the other language.  We Americans hate english :P.
331
-		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1)
332
-			list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
345
+		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) {
346
+					list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
347
+		}
333 348
 	}
334 349
 
335 350
 	// And now include the actual language file itself.
@@ -342,15 +357,18 @@  discard block
 block discarded – undo
342 357
 	global $db_prefix, $db_connection, $sourcedir;
343 358
 	global $smcFunc, $modSettings, $db_type, $db_name, $db_user, $db_persist;
344 359
 
345
-	if (empty($sourcedir))
346
-		$sourcedir = dirname(__FILE__) . '/Sources';
360
+	if (empty($sourcedir)) {
361
+			$sourcedir = dirname(__FILE__) . '/Sources';
362
+	}
347 363
 
348 364
 	// Need this to check whether we need the database password.
349 365
 	require(dirname(__FILE__) . '/Settings.php');
350
-	if (!defined('SMF'))
351
-		define('SMF', 1);
352
-	if (empty($smcFunc))
353
-		$smcFunc = array();
366
+	if (!defined('SMF')) {
367
+			define('SMF', 1);
368
+	}
369
+	if (empty($smcFunc)) {
370
+			$smcFunc = array();
371
+	}
354 372
 
355 373
 	$modSettings['disableQueryCheck'] = true;
356 374
 
@@ -358,8 +376,9 @@  discard block
 block discarded – undo
358 376
 	if (!$db_connection)
359 377
 	{
360 378
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
361
-		if (version_compare(PHP_VERSION, '5', '<'))
362
-			require_once($sourcedir . '/Subs-Compat.php');
379
+		if (version_compare(PHP_VERSION, '5', '<')) {
380
+					require_once($sourcedir . '/Subs-Compat.php');
381
+		}
363 382
 
364 383
 		$db_options = array('persist' => $db_persist);
365 384
 		$port = '';
@@ -370,19 +389,20 @@  discard block
 block discarded – undo
370 389
 			if ($db_type == 'mysql')
371 390
 			{
372 391
 				$port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port'];
373
-			}
374
-			elseif ($db_type == 'postgresql')
392
+			} elseif ($db_type == 'postgresql')
375 393
 			{
376 394
 				// PostgreSQL doesn't have a default port setting in php.ini, so just check against the default
377 395
 				$port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port'];
378 396
 			}
379 397
 		}
380 398
 
381
-		if (!empty($port))
382
-			$db_options['port'] = $port;
399
+		if (!empty($port)) {
400
+					$db_options['port'] = $port;
401
+		}
383 402
 
384
-		if (!$db_connection)
385
-			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options);
403
+		if (!$db_connection) {
404
+					$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options);
405
+		}
386 406
 	}
387 407
 }
388 408
 
@@ -410,8 +430,9 @@  discard block
 block discarded – undo
410 430
 		// @todo REMOVE THIS!!
411 431
 		else
412 432
 		{
413
-			if (function_exists('doStep' . $_GET['step']))
414
-				call_user_func('doStep' . $_GET['step']);
433
+			if (function_exists('doStep' . $_GET['step'])) {
434
+							call_user_func('doStep' . $_GET['step']);
435
+			}
415 436
 		}
416 437
 		// Show the footer.
417 438
 		template_install_below();
@@ -429,8 +450,9 @@  discard block
 block discarded – undo
429 450
 	$incontext['sub_template'] = 'welcome_message';
430 451
 
431 452
 	// Done the submission?
432
-	if (isset($_POST['contbutt']))
433
-		return true;
453
+	if (isset($_POST['contbutt'])) {
454
+			return true;
455
+	}
434 456
 
435 457
 	// See if we think they have already installed it?
436 458
 	if (is_readable(dirname(__FILE__) . '/Settings.php'))
@@ -438,14 +460,17 @@  discard block
 block discarded – undo
438 460
 		$probably_installed = 0;
439 461
 		foreach (file(dirname(__FILE__) . '/Settings.php') as $line)
440 462
 		{
441
-			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line))
442
-				$probably_installed++;
443
-			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line))
444
-				$probably_installed++;
463
+			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) {
464
+							$probably_installed++;
465
+			}
466
+			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) {
467
+							$probably_installed++;
468
+			}
445 469
 		}
446 470
 
447
-		if ($probably_installed == 2)
448
-			$incontext['warning'] = $txt['error_already_installed'];
471
+		if ($probably_installed == 2) {
472
+					$incontext['warning'] = $txt['error_already_installed'];
473
+		}
449 474
 	}
450 475
 
451 476
 	// Is some database support even compiled in?
@@ -460,36 +485,43 @@  discard block
 block discarded – undo
460 485
 				$databases[$key]['supported'] = false;
461 486
 				$notFoundSQLFile = true;
462 487
 				$txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql');
488
+			} else {
489
+							$incontext['supported_databases'][] = $db;
463 490
 			}
464
-			else
465
-				$incontext['supported_databases'][] = $db;
466 491
 		}
467 492
 	}
468 493
 
469 494
 	// Check the PHP version.
470
-	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>')))
471
-		$error = 'error_php_too_low';
495
+	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>'))) {
496
+			$error = 'error_php_too_low';
497
+	}
472 498
 	// Make sure we have a supported database
473
-	elseif (empty($incontext['supported_databases']))
474
-		$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
499
+	elseif (empty($incontext['supported_databases'])) {
500
+			$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
501
+	}
475 502
 	// How about session support?  Some crazy sysadmin remove it?
476
-	elseif (!function_exists('session_start'))
477
-		$error = 'error_session_missing';
503
+	elseif (!function_exists('session_start')) {
504
+			$error = 'error_session_missing';
505
+	}
478 506
 	// Make sure they uploaded all the files.
479
-	elseif (!file_exists(dirname(__FILE__) . '/index.php'))
480
-		$error = 'error_missing_files';
507
+	elseif (!file_exists(dirname(__FILE__) . '/index.php')) {
508
+			$error = 'error_missing_files';
509
+	}
481 510
 	// Very simple check on the session.save_path for Windows.
482 511
 	// @todo Move this down later if they don't use database-driven sessions?
483
-	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\')
484
-		$error = 'error_session_save_path';
512
+	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') {
513
+			$error = 'error_session_save_path';
514
+	}
485 515
 
486 516
 	// Since each of the three messages would look the same, anyway...
487
-	if (isset($error))
488
-		$incontext['error'] = $txt[$error];
517
+	if (isset($error)) {
518
+			$incontext['error'] = $txt[$error];
519
+	}
489 520
 
490 521
 	// Mod_security blocks everything that smells funny. Let SMF handle security.
491
-	if (!fixModSecurity() && !isset($_GET['overmodsecurity']))
492
-		$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
522
+	if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) {
523
+			$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
524
+	}
493 525
 
494 526
 	return false;
495 527
 }
@@ -515,12 +547,14 @@  discard block
 block discarded – undo
515 547
 		'db_last_error.php',
516 548
 	);
517 549
 
518
-	foreach ($incontext['detected_languages'] as $lang => $temp)
519
-		$extra_files[] = 'Themes/default/languages/' . $lang;
550
+	foreach ($incontext['detected_languages'] as $lang => $temp) {
551
+			$extra_files[] = 'Themes/default/languages/' . $lang;
552
+	}
520 553
 
521 554
 	// With mod_security installed, we could attempt to fix it with .htaccess.
522
-	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules()))
523
-		$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
555
+	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) {
556
+			$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
557
+	}
524 558
 
525 559
 	$failed_files = array();
526 560
 
@@ -536,12 +570,14 @@  discard block
 block discarded – undo
536 570
 				@chmod(dirname(__FILE__) . '/' . $file, 0755);
537 571
 
538 572
 				// Well, 755 hopefully worked... if not, try 777.
539
-				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777))
540
-					$failed_files[] = $file;
573
+				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) {
574
+									$failed_files[] = $file;
575
+				}
541 576
 			}
542 577
 		}
543
-		foreach ($extra_files as $file)
544
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
578
+		foreach ($extra_files as $file) {
579
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
580
+		}
545 581
 	}
546 582
 	// Windows is trickier.  Let's try opening for r+...
547 583
 	else
@@ -551,30 +587,35 @@  discard block
 block discarded – undo
551 587
 		foreach ($writable_files as $file)
552 588
 		{
553 589
 			// Folders can't be opened for write... but the index.php in them can ;)
554
-			if (is_dir(dirname(__FILE__) . '/' . $file))
555
-				$file .= '/index.php';
590
+			if (is_dir(dirname(__FILE__) . '/' . $file)) {
591
+							$file .= '/index.php';
592
+			}
556 593
 
557 594
 			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
558 595
 			@chmod(dirname(__FILE__) . '/' . $file, 0777);
559 596
 			$fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+');
560 597
 
561 598
 			// Hmm, okay, try just for write in that case...
562
-			if (!is_resource($fp))
563
-				$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
599
+			if (!is_resource($fp)) {
600
+							$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
601
+			}
564 602
 
565
-			if (!is_resource($fp))
566
-				$failed_files[] = $file;
603
+			if (!is_resource($fp)) {
604
+							$failed_files[] = $file;
605
+			}
567 606
 
568 607
 			@fclose($fp);
569 608
 		}
570
-		foreach ($extra_files as $file)
571
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
609
+		foreach ($extra_files as $file) {
610
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
611
+		}
572 612
 	}
573 613
 
574 614
 	$failure = count($failed_files) >= 1;
575 615
 
576
-	if (!isset($_SERVER))
577
-		return !$failure;
616
+	if (!isset($_SERVER)) {
617
+			return !$failure;
618
+	}
578 619
 
579 620
 	// Put the list into context.
580 621
 	$incontext['failed_files'] = $failed_files;
@@ -622,19 +663,23 @@  discard block
 block discarded – undo
622 663
 
623 664
 		if (!isset($ftp) || $ftp->error !== false)
624 665
 		{
625
-			if (!isset($ftp))
626
-				$ftp = new ftp_connection(null);
666
+			if (!isset($ftp)) {
667
+							$ftp = new ftp_connection(null);
668
+			}
627 669
 			// Save the error so we can mess with listing...
628
-			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message))
629
-				$incontext['ftp_errors'][] = $ftp->last_message;
670
+			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) {
671
+							$incontext['ftp_errors'][] = $ftp->last_message;
672
+			}
630 673
 
631 674
 			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
632 675
 
633
-			if (empty($_POST['ftp_path']) && $found_path)
634
-				$_POST['ftp_path'] = $detect_path;
676
+			if (empty($_POST['ftp_path']) && $found_path) {
677
+							$_POST['ftp_path'] = $detect_path;
678
+			}
635 679
 
636
-			if (!isset($_POST['ftp_username']))
637
-				$_POST['ftp_username'] = $username;
680
+			if (!isset($_POST['ftp_username'])) {
681
+							$_POST['ftp_username'] = $username;
682
+			}
638 683
 
639 684
 			// Set the username etc, into context.
640 685
 			$incontext['ftp'] = array(
@@ -646,8 +691,7 @@  discard block
 block discarded – undo
646 691
 			);
647 692
 
648 693
 			return false;
649
-		}
650
-		else
694
+		} else
651 695
 		{
652 696
 			$_SESSION['installer_temp_ftp'] = array(
653 697
 				'server' => $_POST['ftp_server'],
@@ -661,10 +705,12 @@  discard block
 block discarded – undo
661 705
 
662 706
 			foreach ($failed_files as $file)
663 707
 			{
664
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
665
-					$ftp->chmod($file, 0755);
666
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
667
-					$ftp->chmod($file, 0777);
708
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
709
+									$ftp->chmod($file, 0755);
710
+				}
711
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
712
+									$ftp->chmod($file, 0777);
713
+				}
668 714
 				if (!is_writable(dirname(__FILE__) . '/' . $file))
669 715
 				{
670 716
 					$failed_files_updated[] = $file;
@@ -719,15 +765,17 @@  discard block
 block discarded – undo
719 765
 
720 766
 			if (!$foundOne)
721 767
 			{
722
-				if (isset($db['default_host']))
723
-					$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
768
+				if (isset($db['default_host'])) {
769
+									$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
770
+				}
724 771
 				if (isset($db['default_user']))
725 772
 				{
726 773
 					$incontext['db']['user'] = ini_get($db['default_user']);
727 774
 					$incontext['db']['name'] = ini_get($db['default_user']);
728 775
 				}
729
-				if (isset($db['default_password']))
730
-					$incontext['db']['pass'] = ini_get($db['default_password']);
776
+				if (isset($db['default_password'])) {
777
+									$incontext['db']['pass'] = ini_get($db['default_password']);
778
+				}
731 779
 
732 780
 				// For simplicity and less confusion, leave the port blank by default
733 781
 				$incontext['db']['port'] = '';
@@ -746,10 +794,10 @@  discard block
 block discarded – undo
746 794
 		$incontext['db']['server'] = $_POST['db_server'];
747 795
 		$incontext['db']['prefix'] = $_POST['db_prefix'];
748 796
 
749
-		if (!empty($_POST['db_port']))
750
-			$incontext['db']['port'] = $_POST['db_port'];
751
-	}
752
-	else
797
+		if (!empty($_POST['db_port'])) {
798
+					$incontext['db']['port'] = $_POST['db_port'];
799
+		}
800
+	} else
753 801
 	{
754 802
 		$incontext['db']['prefix'] = 'smf_';
755 803
 	}
@@ -785,10 +833,11 @@  discard block
 block discarded – undo
785 833
 		if (!empty($_POST['db_port']))
786 834
 		{
787 835
 			// For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though.
788
-			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port'))
789
-				$vars['db_port'] = (int) $_POST['db_port'];
790
-			elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432)
791
-				$vars['db_port'] = (int) $_POST['db_port'];
836
+			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) {
837
+							$vars['db_port'] = (int) $_POST['db_port'];
838
+			} elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) {
839
+							$vars['db_port'] = (int) $_POST['db_port'];
840
+			}
792 841
 		}
793 842
 
794 843
 		// God I hope it saved!
@@ -801,8 +850,9 @@  discard block
 block discarded – undo
801 850
 		// Make sure it works.
802 851
 		require(dirname(__FILE__) . '/Settings.php');
803 852
 
804
-		if (empty($sourcedir))
805
-			$sourcedir = dirname(__FILE__) . '/Sources';
853
+		if (empty($sourcedir)) {
854
+					$sourcedir = dirname(__FILE__) . '/Sources';
855
+		}
806 856
 
807 857
 		// Better find the database file!
808 858
 		if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
@@ -812,18 +862,21 @@  discard block
 block discarded – undo
812 862
 		}
813 863
 
814 864
 		// Now include it for database functions!
815
-		if (!defined('SMF'))
816
-			define('SMF', 1);
865
+		if (!defined('SMF')) {
866
+					define('SMF', 1);
867
+		}
817 868
 
818 869
 		$modSettings['disableQueryCheck'] = true;
819
-		if (empty($smcFunc))
820
-			$smcFunc = array();
870
+		if (empty($smcFunc)) {
871
+					$smcFunc = array();
872
+		}
821 873
 
822 874
 			require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
823 875
 
824 876
 		// What - running PHP4? The shame!
825
-		if (version_compare(PHP_VERSION, '5', '<'))
826
-			require_once($sourcedir . '/Subs-Compat.php');
877
+		if (version_compare(PHP_VERSION, '5', '<')) {
878
+					require_once($sourcedir . '/Subs-Compat.php');
879
+		}
827 880
 
828 881
 		// Attempt a connection.
829 882
 		$needsDB = !empty($databases[$db_type]['always_has_db']);
@@ -911,12 +964,14 @@  discard block
 block discarded – undo
911 964
 	$incontext['page_title'] = $txt['install_settings'];
912 965
 
913 966
 	// Let's see if we got the database type correct.
914
-	if (isset($_POST['db_type'], $databases[$_POST['db_type']]))
915
-		$db_type = $_POST['db_type'];
967
+	if (isset($_POST['db_type'], $databases[$_POST['db_type']])) {
968
+			$db_type = $_POST['db_type'];
969
+	}
916 970
 
917 971
 	// Else we'd better be able to get the connection.
918
-	else
919
-		load_database();
972
+	else {
973
+			load_database();
974
+	}
920 975
 
921 976
 	$db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type;
922 977
 
@@ -936,12 +991,14 @@  discard block
 block discarded – undo
936 991
 	// Submitting?
937 992
 	if (isset($_POST['boardurl']))
938 993
 	{
939
-		if (substr($_POST['boardurl'], -10) == '/index.php')
940
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
941
-		elseif (substr($_POST['boardurl'], -1) == '/')
942
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
943
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
944
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
994
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
995
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
996
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
997
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
998
+		}
999
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
1000
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1001
+		}
945 1002
 
946 1003
 		// Save these variables.
947 1004
 		$vars = array(
@@ -978,10 +1035,10 @@  discard block
 block discarded – undo
978 1035
 			{
979 1036
 				$incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']);
980 1037
 				return false;
981
-			}
982
-			else
983
-				// Set the character set here.
1038
+			} else {
1039
+							// Set the character set here.
984 1040
 				updateSettingsFile(array('db_character_set' => 'utf8'));
1041
+			}
985 1042
 		}
986 1043
 
987 1044
 		// Good, skip on.
@@ -1001,8 +1058,9 @@  discard block
 block discarded – undo
1001 1058
 	$incontext['continue'] = 1;
1002 1059
 
1003 1060
 	// Already done?
1004
-	if (isset($_POST['pop_done']))
1005
-		return true;
1061
+	if (isset($_POST['pop_done'])) {
1062
+			return true;
1063
+	}
1006 1064
 
1007 1065
 	// Reload settings.
1008 1066
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1020,8 +1078,9 @@  discard block
 block discarded – undo
1020 1078
 	$modSettings = array();
1021 1079
 	if ($result !== false)
1022 1080
 	{
1023
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1024
-			$modSettings[$row['variable']] = $row['value'];
1081
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1082
+					$modSettings[$row['variable']] = $row['value'];
1083
+		}
1025 1084
 		$smcFunc['db_free_result']($result);
1026 1085
 
1027 1086
 		// Do they match?  If so, this is just a refresh so charge on!
@@ -1034,20 +1093,22 @@  discard block
 block discarded – undo
1034 1093
 	$modSettings['disableQueryCheck'] = true;
1035 1094
 
1036 1095
 	// If doing UTF8, select it. PostgreSQL requires passing it as a string...
1037
-	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support']))
1038
-		$smcFunc['db_query']('', '
1096
+	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) {
1097
+			$smcFunc['db_query']('', '
1039 1098
 			SET NAMES {string:utf8}',
1040 1099
 			array(
1041 1100
 				'db_error_skip' => true,
1042 1101
 				'utf8' => 'utf8',
1043 1102
 			)
1044 1103
 		);
1104
+	}
1045 1105
 
1046 1106
 	// Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments...
1047
-	if (substr(__DIR__, -1) == '\\')
1048
-		$attachdir = __DIR__ . 'attachments';
1049
-	else
1050
-		$attachdir = __DIR__ . '/attachments';
1107
+	if (substr(__DIR__, -1) == '\\') {
1108
+			$attachdir = __DIR__ . 'attachments';
1109
+	} else {
1110
+			$attachdir = __DIR__ . '/attachments';
1111
+	}
1051 1112
 
1052 1113
 	$replaces = array(
1053 1114
 		'{$db_prefix}' => $db_prefix,
@@ -1064,8 +1125,9 @@  discard block
 block discarded – undo
1064 1125
 
1065 1126
 	foreach ($txt as $key => $value)
1066 1127
 	{
1067
-		if (substr($key, 0, 8) == 'default_')
1068
-			$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1128
+		if (substr($key, 0, 8) == 'default_') {
1129
+					$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1130
+		}
1069 1131
 	}
1070 1132
 	$replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n'));
1071 1133
 
@@ -1080,8 +1142,9 @@  discard block
 block discarded – undo
1080 1142
 
1081 1143
 		while ($row = $smcFunc['db_fetch_assoc']($get_engines))
1082 1144
 		{
1083
-			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT')
1084
-				$engines[] = $row['Engine'];
1145
+			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') {
1146
+							$engines[] = $row['Engine'];
1147
+			}
1085 1148
 		}
1086 1149
 
1087 1150
 		// Done with this now
@@ -1105,8 +1168,7 @@  discard block
 block discarded – undo
1105 1168
 			$replaces['START TRANSACTION;'] = '';
1106 1169
 			$replaces['COMMIT;'] = '';
1107 1170
 		}
1108
-	}
1109
-	else
1171
+	} else
1110 1172
 	{
1111 1173
 		$has_innodb = false;
1112 1174
 	}
@@ -1128,21 +1190,24 @@  discard block
 block discarded – undo
1128 1190
 	foreach ($sql_lines as $count => $line)
1129 1191
 	{
1130 1192
 		// No comments allowed!
1131
-		if (substr(trim($line), 0, 1) != '#')
1132
-			$current_statement .= "\n" . rtrim($line);
1193
+		if (substr(trim($line), 0, 1) != '#') {
1194
+					$current_statement .= "\n" . rtrim($line);
1195
+		}
1133 1196
 
1134 1197
 		// Is this the end of the query string?
1135
-		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines)))
1136
-			continue;
1198
+		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) {
1199
+					continue;
1200
+		}
1137 1201
 
1138 1202
 		// Does this table already exist?  If so, don't insert more data into it!
1139 1203
 		if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists))
1140 1204
 		{
1141 1205
 			preg_match_all('~\)[,;]~', $current_statement, $matches);
1142
-			if (!empty($matches[0]))
1143
-				$incontext['sql_results']['insert_dups'] += count($matches[0]);
1144
-			else
1145
-				$incontext['sql_results']['insert_dups']++;
1206
+			if (!empty($matches[0])) {
1207
+							$incontext['sql_results']['insert_dups'] += count($matches[0]);
1208
+			} else {
1209
+							$incontext['sql_results']['insert_dups']++;
1210
+			}
1146 1211
 
1147 1212
 			$current_statement = '';
1148 1213
 			continue;
@@ -1151,8 +1216,9 @@  discard block
 block discarded – undo
1151 1216
 		if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false)
1152 1217
 		{
1153 1218
 			// Use the appropriate function based on the DB type
1154
-			if ($db_type == 'mysql' || $db_type == 'mysqli')
1155
-				$db_errorno = $db_type . '_errno';
1219
+			if ($db_type == 'mysql' || $db_type == 'mysqli') {
1220
+							$db_errorno = $db_type . '_errno';
1221
+			}
1156 1222
 
1157 1223
 			// Error 1050: Table already exists!
1158 1224
 			// @todo Needs to be made better!
@@ -1167,18 +1233,18 @@  discard block
 block discarded – undo
1167 1233
 				// MySQLi requires a connection object. It's optional with MySQL and Postgres
1168 1234
 				$incontext['failures'][$count] = $smcFunc['db_error']($db_connection);
1169 1235
 			}
1170
-		}
1171
-		else
1236
+		} else
1172 1237
 		{
1173
-			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1174
-				$incontext['sql_results']['tables']++;
1175
-			elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1238
+			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) {
1239
+							$incontext['sql_results']['tables']++;
1240
+			} elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1176 1241
 			{
1177 1242
 				preg_match_all('~\)[,;]~', $current_statement, $matches);
1178
-				if (!empty($matches[0]))
1179
-					$incontext['sql_results']['inserts'] += count($matches[0]);
1180
-				else
1181
-					$incontext['sql_results']['inserts']++;
1243
+				if (!empty($matches[0])) {
1244
+									$incontext['sql_results']['inserts'] += count($matches[0]);
1245
+				} else {
1246
+									$incontext['sql_results']['inserts']++;
1247
+				}
1182 1248
 			}
1183 1249
 		}
1184 1250
 
@@ -1191,15 +1257,17 @@  discard block
 block discarded – undo
1191 1257
 	// Sort out the context for the SQL.
1192 1258
 	foreach ($incontext['sql_results'] as $key => $number)
1193 1259
 	{
1194
-		if ($number == 0)
1195
-			unset($incontext['sql_results'][$key]);
1196
-		else
1197
-			$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1260
+		if ($number == 0) {
1261
+					unset($incontext['sql_results'][$key]);
1262
+		} else {
1263
+					$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1264
+		}
1198 1265
 	}
1199 1266
 
1200 1267
 	// Make sure UTF will be used globally.
1201
-	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'])))
1202
-		$newSettings[] = array('global_character_set', 'UTF-8');
1268
+	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']))) {
1269
+			$newSettings[] = array('global_character_set', 'UTF-8');
1270
+	}
1203 1271
 
1204 1272
 	// Maybe we can auto-detect better cookie settings?
1205 1273
 	preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches);
@@ -1210,16 +1278,20 @@  discard block
 block discarded – undo
1210 1278
 		$globalCookies = false;
1211 1279
 
1212 1280
 		// Okay... let's see.  Using a subdomain other than www.? (not a perfect check.)
1213
-		if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www'))))
1214
-			$globalCookies = true;
1281
+		if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) {
1282
+					$globalCookies = true;
1283
+		}
1215 1284
 		// If there's a / in the middle of the path, or it starts with ~... we want local.
1216
-		if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false))
1217
-			$localCookies = true;
1285
+		if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) {
1286
+					$localCookies = true;
1287
+		}
1218 1288
 
1219
-		if ($globalCookies)
1220
-			$newSettings[] = array('globalCookies', '1');
1221
-		if ($localCookies)
1222
-			$newSettings[] = array('localCookies', '1');
1289
+		if ($globalCookies) {
1290
+					$newSettings[] = array('globalCookies', '1');
1291
+		}
1292
+		if ($localCookies) {
1293
+					$newSettings[] = array('localCookies', '1');
1294
+		}
1223 1295
 	}
1224 1296
 
1225 1297
 	// Are we allowing stat collection?
@@ -1235,32 +1307,36 @@  discard block
 block discarded – undo
1235 1307
 			fwrite($fp, $out);
1236 1308
 
1237 1309
 			$return_data = '';
1238
-			while (!feof($fp))
1239
-				$return_data .= fgets($fp, 128);
1310
+			while (!feof($fp)) {
1311
+							$return_data .= fgets($fp, 128);
1312
+			}
1240 1313
 
1241 1314
 			fclose($fp);
1242 1315
 
1243 1316
 			// Get the unique site ID.
1244 1317
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1245 1318
 
1246
-			if (!empty($ID[1]))
1247
-				$newSettings[] = array('allow_sm_stats', $ID[1]);
1319
+			if (!empty($ID[1])) {
1320
+							$newSettings[] = array('allow_sm_stats', $ID[1]);
1321
+			}
1248 1322
 		}
1249 1323
 	}
1250 1324
 
1251 1325
 	// Are we enabling SSL?
1252
-	if (!empty($_POST['force_ssl']))
1253
-		$newSettings[] = array('force_ssl', 2);
1326
+	if (!empty($_POST['force_ssl'])) {
1327
+			$newSettings[] = array('force_ssl', 2);
1328
+	}
1254 1329
 
1255 1330
 	// Setting a timezone is required.
1256 1331
 	if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set'))
1257 1332
 	{
1258 1333
 		// Get PHP's default timezone, if set
1259 1334
 		$ini_tz = ini_get('date.timezone');
1260
-		if (!empty($ini_tz))
1261
-			$timezone_id = $ini_tz;
1262
-		else
1263
-			$timezone_id = '';
1335
+		if (!empty($ini_tz)) {
1336
+					$timezone_id = $ini_tz;
1337
+		} else {
1338
+					$timezone_id = '';
1339
+		}
1264 1340
 
1265 1341
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
1266 1342
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -1269,8 +1345,9 @@  discard block
 block discarded – undo
1269 1345
 			$timezone_id = timezone_name_from_abbr('', $server_offset, 0);
1270 1346
 		}
1271 1347
 
1272
-		if (date_default_timezone_set($timezone_id))
1273
-			$newSettings[] = array('default_timezone', $timezone_id);
1348
+		if (date_default_timezone_set($timezone_id)) {
1349
+					$newSettings[] = array('default_timezone', $timezone_id);
1350
+		}
1274 1351
 	}
1275 1352
 
1276 1353
 	if (!empty($newSettings))
@@ -1301,16 +1378,18 @@  discard block
 block discarded – undo
1301 1378
 	}
1302 1379
 
1303 1380
 	// MySQL specific stuff
1304
-	if (substr($db_type, 0, 5) != 'mysql')
1305
-		return false;
1381
+	if (substr($db_type, 0, 5) != 'mysql') {
1382
+			return false;
1383
+	}
1306 1384
 
1307 1385
 	// Find database user privileges.
1308 1386
 	$privs = array();
1309 1387
 	$get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array());
1310 1388
 	while ($row = $smcFunc['db_fetch_assoc']($get_privs))
1311 1389
 	{
1312
-		if ($row['Privilege'] == 'Alter')
1313
-			$privs[] = $row['Privilege'];
1390
+		if ($row['Privilege'] == 'Alter') {
1391
+					$privs[] = $row['Privilege'];
1392
+		}
1314 1393
 	}
1315 1394
 	$smcFunc['db_free_result']($get_privs);
1316 1395
 
@@ -1340,8 +1419,9 @@  discard block
 block discarded – undo
1340 1419
 	$incontext['continue'] = 1;
1341 1420
 
1342 1421
 	// Skipping?
1343
-	if (!empty($_POST['skip']))
1344
-		return true;
1422
+	if (!empty($_POST['skip'])) {
1423
+			return true;
1424
+	}
1345 1425
 
1346 1426
 	// Need this to check whether we need the database password.
1347 1427
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1354,18 +1434,22 @@  discard block
 block discarded – undo
1354 1434
 	// We need this to properly hash the password for Admin
1355 1435
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) {
1356 1436
 			global $sourcedir;
1357
-			if (function_exists('mb_strtolower'))
1358
-				return mb_strtolower($string, 'UTF-8');
1437
+			if (function_exists('mb_strtolower')) {
1438
+							return mb_strtolower($string, 'UTF-8');
1439
+			}
1359 1440
 			require_once($sourcedir . '/Subs-Charset.php');
1360 1441
 			return utf8_strtolower($string);
1361 1442
 		};
1362 1443
 
1363
-	if (!isset($_POST['username']))
1364
-		$_POST['username'] = '';
1365
-	if (!isset($_POST['email']))
1366
-		$_POST['email'] = '';
1367
-	if (!isset($_POST['server_email']))
1368
-		$_POST['server_email'] = '';
1444
+	if (!isset($_POST['username'])) {
1445
+			$_POST['username'] = '';
1446
+	}
1447
+	if (!isset($_POST['email'])) {
1448
+			$_POST['email'] = '';
1449
+	}
1450
+	if (!isset($_POST['server_email'])) {
1451
+			$_POST['server_email'] = '';
1452
+	}
1369 1453
 
1370 1454
 	$incontext['username'] = htmlspecialchars(stripslashes($_POST['username']));
1371 1455
 	$incontext['email'] = htmlspecialchars(stripslashes($_POST['email']));
@@ -1384,8 +1468,9 @@  discard block
 block discarded – undo
1384 1468
 			'admin_group' => 1,
1385 1469
 		)
1386 1470
 	);
1387
-	if ($smcFunc['db_num_rows']($request) != 0)
1388
-		$incontext['skip'] = 1;
1471
+	if ($smcFunc['db_num_rows']($request) != 0) {
1472
+			$incontext['skip'] = 1;
1473
+	}
1389 1474
 	$smcFunc['db_free_result']($request);
1390 1475
 
1391 1476
 	// Trying to create an account?
@@ -1416,8 +1501,9 @@  discard block
 block discarded – undo
1416 1501
 		}
1417 1502
 
1418 1503
 		// Update the webmaster's email?
1419
-		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]'))
1420
-			updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1504
+		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) {
1505
+					updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1506
+		}
1421 1507
 
1422 1508
 		// Work out whether we're going to have dodgy characters and remove them.
1423 1509
 		$invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0;
@@ -1440,32 +1526,27 @@  discard block
 block discarded – undo
1440 1526
 			$smcFunc['db_free_result']($result);
1441 1527
 
1442 1528
 			$incontext['account_existed'] = $txt['error_user_settings_taken'];
1443
-		}
1444
-		elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1529
+		} elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1445 1530
 		{
1446 1531
 			// Try the previous step again.
1447 1532
 			$incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long'];
1448 1533
 			return false;
1449
-		}
1450
-		elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1534
+		} elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1451 1535
 		{
1452 1536
 			// Try the previous step again.
1453 1537
 			$incontext['error'] = $txt['error_invalid_characters_username'];
1454 1538
 			return false;
1455
-		}
1456
-		elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1539
+		} elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1457 1540
 		{
1458 1541
 			// One step back, this time fill out a proper admin email address.
1459 1542
 			$incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']);
1460 1543
 			return false;
1461
-		}
1462
-		elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1544
+		} elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1463 1545
 		{
1464 1546
 			// One step back, this time fill out a proper admin email address.
1465 1547
 			$incontext['error'] = $txt['error_valid_server_email_needed'];
1466 1548
 			return false;
1467
-		}
1468
-		elseif ($_POST['username'] != '')
1549
+		} elseif ($_POST['username'] != '')
1469 1550
 		{
1470 1551
 			$incontext['member_salt'] = substr(md5(mt_rand()), 0, 4);
1471 1552
 
@@ -1531,17 +1612,19 @@  discard block
 block discarded – undo
1531 1612
 	require_once($sourcedir . '/Subs-Auth.php');
1532 1613
 
1533 1614
 	// Bring a warning over.
1534
-	if (!empty($incontext['account_existed']))
1535
-		$incontext['warning'] = $incontext['account_existed'];
1615
+	if (!empty($incontext['account_existed'])) {
1616
+			$incontext['warning'] = $incontext['account_existed'];
1617
+	}
1536 1618
 
1537
-	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support']))
1538
-		$smcFunc['db_query']('', '
1619
+	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) {
1620
+			$smcFunc['db_query']('', '
1539 1621
 			SET NAMES {string:db_character_set}',
1540 1622
 			array(
1541 1623
 				'db_character_set' => $db_character_set,
1542 1624
 				'db_error_skip' => true,
1543 1625
 			)
1544 1626
 		);
1627
+	}
1545 1628
 
1546 1629
 	// As track stats is by default enabled let's add some activity.
1547 1630
 	$smcFunc['db_insert']('ignore',
@@ -1562,14 +1645,16 @@  discard block
 block discarded – undo
1562 1645
 	// Only proceed if we can load the data.
1563 1646
 	if ($request)
1564 1647
 	{
1565
-		while ($row = $smcFunc['db_fetch_row']($request))
1566
-			$modSettings[$row[0]] = $row[1];
1648
+		while ($row = $smcFunc['db_fetch_row']($request)) {
1649
+					$modSettings[$row[0]] = $row[1];
1650
+		}
1567 1651
 		$smcFunc['db_free_result']($request);
1568 1652
 	}
1569 1653
 
1570 1654
 	// Automatically log them in ;)
1571
-	if (isset($incontext['member_id']) && isset($incontext['member_salt']))
1572
-		setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1655
+	if (isset($incontext['member_id']) && isset($incontext['member_salt'])) {
1656
+			setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1657
+	}
1573 1658
 
1574 1659
 	$result = $smcFunc['db_query']('', '
1575 1660
 		SELECT value
@@ -1580,13 +1665,14 @@  discard block
 block discarded – undo
1580 1665
 			'db_error_skip' => true,
1581 1666
 		)
1582 1667
 	);
1583
-	if ($smcFunc['db_num_rows']($result) != 0)
1584
-		list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1668
+	if ($smcFunc['db_num_rows']($result) != 0) {
1669
+			list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1670
+	}
1585 1671
 	$smcFunc['db_free_result']($result);
1586 1672
 
1587
-	if (empty($db_sessions))
1588
-		$_SESSION['admin_time'] = time();
1589
-	else
1673
+	if (empty($db_sessions)) {
1674
+			$_SESSION['admin_time'] = time();
1675
+	} else
1590 1676
 	{
1591 1677
 		$_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211);
1592 1678
 
@@ -1610,8 +1696,9 @@  discard block
 block discarded – undo
1610 1696
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1611 1697
 		function($string){
1612 1698
 			global $sourcedir;
1613
-			if (function_exists('mb_strtolower'))
1614
-				return mb_strtolower($string, 'UTF-8');
1699
+			if (function_exists('mb_strtolower')) {
1700
+							return mb_strtolower($string, 'UTF-8');
1701
+			}
1615 1702
 			require_once($sourcedir . '/Subs-Charset.php');
1616 1703
 			return utf8_strtolower($string);
1617 1704
 		};
@@ -1627,8 +1714,9 @@  discard block
 block discarded – undo
1627 1714
 		)
1628 1715
 	);
1629 1716
 	$context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8';
1630
-	if ($smcFunc['db_num_rows']($request) > 0)
1631
-		updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1717
+	if ($smcFunc['db_num_rows']($request) > 0) {
1718
+			updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1719
+	}
1632 1720
 	$smcFunc['db_free_result']($request);
1633 1721
 
1634 1722
 	// Now is the perfect time to fetch the SM files.
@@ -1647,8 +1735,9 @@  discard block
 block discarded – undo
1647 1735
 
1648 1736
 	// Check if we need some stupid MySQL fix.
1649 1737
 	$server_version = $smcFunc['db_server_info']();
1650
-	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1651
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1738
+	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1739
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1740
+	}
1652 1741
 
1653 1742
 	// Some final context for the template.
1654 1743
 	$incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\';
@@ -1668,8 +1757,9 @@  discard block
 block discarded – undo
1668 1757
 	$settingsArray = file(dirname(__FILE__) . '/Settings.php');
1669 1758
 
1670 1759
 	// @todo Do we just want to read the file in clean, and split it this way always?
1671
-	if (count($settingsArray) == 1)
1672
-		$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1760
+	if (count($settingsArray) == 1) {
1761
+			$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1762
+	}
1673 1763
 
1674 1764
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
1675 1765
 	{
@@ -1684,19 +1774,22 @@  discard block
 block discarded – undo
1684 1774
 			continue;
1685 1775
 		}
1686 1776
 
1687
-		if (trim($settingsArray[$i]) == '?' . '>')
1688
-			$settingsArray[$i] = '';
1777
+		if (trim($settingsArray[$i]) == '?' . '>') {
1778
+					$settingsArray[$i] = '';
1779
+		}
1689 1780
 
1690 1781
 		// Don't trim or bother with it if it's not a variable.
1691
-		if (substr($settingsArray[$i], 0, 1) != '$')
1692
-			continue;
1782
+		if (substr($settingsArray[$i], 0, 1) != '$') {
1783
+					continue;
1784
+		}
1693 1785
 
1694 1786
 		$settingsArray[$i] = rtrim($settingsArray[$i]) . "\n";
1695 1787
 
1696
-		foreach ($vars as $var => $val)
1697
-			if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1788
+		foreach ($vars as $var => $val) {
1789
+					if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1698 1790
 			{
1699 1791
 				$comment = strstr($settingsArray[$i], '#');
1792
+		}
1700 1793
 				$settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n");
1701 1794
 				unset($vars[$var]);
1702 1795
 			}
@@ -1706,36 +1799,41 @@  discard block
 block discarded – undo
1706 1799
 	if (!empty($vars))
1707 1800
 	{
1708 1801
 		$settingsArray[$i++] = '';
1709
-		foreach ($vars as $var => $val)
1710
-			$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1802
+		foreach ($vars as $var => $val) {
1803
+					$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1804
+		}
1711 1805
 	}
1712 1806
 
1713 1807
 	// Blank out the file - done to fix a oddity with some servers.
1714 1808
 	$fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w');
1715
-	if (!$fp)
1716
-		return false;
1809
+	if (!$fp) {
1810
+			return false;
1811
+	}
1717 1812
 	fclose($fp);
1718 1813
 
1719 1814
 	$fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+');
1720 1815
 
1721 1816
 	// Gotta have one of these ;)
1722
-	if (trim($settingsArray[0]) != '<?php')
1723
-		fwrite($fp, "<?php\n");
1817
+	if (trim($settingsArray[0]) != '<?php') {
1818
+			fwrite($fp, "<?php\n");
1819
+	}
1724 1820
 
1725 1821
 	$lines = count($settingsArray);
1726 1822
 	for ($i = 0; $i < $lines - 1; $i++)
1727 1823
 	{
1728 1824
 		// Don't just write a bunch of blank lines.
1729
-		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '')
1730
-			fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1825
+		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') {
1826
+					fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1827
+		}
1731 1828
 	}
1732 1829
 	fwrite($fp, $settingsArray[$i] . '?' . '>');
1733 1830
 	fclose($fp);
1734 1831
 
1735 1832
 	// Even though on normal installations the filemtime should prevent this being used by the installer incorrectly
1736 1833
 	// it seems that there are times it might not. So let's MAKE it dump the cache.
1737
-	if (function_exists('opcache_invalidate'))
1738
-		opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1834
+	if (function_exists('opcache_invalidate')) {
1835
+			opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1836
+	}
1739 1837
 
1740 1838
 	return true;
1741 1839
 }
@@ -1760,9 +1858,9 @@  discard block
 block discarded – undo
1760 1858
 	SecFilterScanPOST Off
1761 1859
 </IfModule>';
1762 1860
 
1763
-	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules()))
1764
-		return true;
1765
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1861
+	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) {
1862
+			return true;
1863
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1766 1864
 	{
1767 1865
 		$current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess'));
1768 1866
 
@@ -1774,29 +1872,28 @@  discard block
 block discarded – undo
1774 1872
 				fwrite($ht_handle, $htaccess_addition);
1775 1873
 				fclose($ht_handle);
1776 1874
 				return true;
1875
+			} else {
1876
+							return false;
1777 1877
 			}
1778
-			else
1779
-				return false;
1878
+		} else {
1879
+					return true;
1780 1880
 		}
1781
-		else
1782
-			return true;
1783
-	}
1784
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess'))
1785
-		return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1786
-	elseif (is_writable(dirname(__FILE__)))
1881
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess')) {
1882
+			return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1883
+	} elseif (is_writable(dirname(__FILE__)))
1787 1884
 	{
1788 1885
 		if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w'))
1789 1886
 		{
1790 1887
 			fwrite($ht_handle, $htaccess_addition);
1791 1888
 			fclose($ht_handle);
1792 1889
 			return true;
1890
+		} else {
1891
+					return false;
1793 1892
 		}
1794
-		else
1893
+	} else {
1795 1894
 			return false;
1796 1895
 	}
1797
-	else
1798
-		return false;
1799
-}
1896
+	}
1800 1897
 
1801 1898
 function template_install_above()
1802 1899
 {
@@ -1834,9 +1931,10 @@  discard block
 block discarded – undo
1834 1931
 								<label for="installer_language">', $txt['installer_language'], ':</label>
1835 1932
 								<select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">';
1836 1933
 
1837
-		foreach ($incontext['detected_languages'] as $lang => $name)
1838
-			echo '
1934
+		foreach ($incontext['detected_languages'] as $lang => $name) {
1935
+					echo '
1839 1936
 									<option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>';
1937
+		}
1840 1938
 
1841 1939
 		echo '
1842 1940
 								</select>
@@ -1856,9 +1954,10 @@  discard block
 block discarded – undo
1856 1954
 						<h2>', $txt['upgrade_progress'], '</h2>
1857 1955
 						<ul>';
1858 1956
 
1859
-	foreach ($incontext['steps'] as $num => $step)
1860
-		echo '
1957
+	foreach ($incontext['steps'] as $num => $step) {
1958
+			echo '
1861 1959
 							<li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
1960
+	}
1862 1961
 
1863 1962
 	echo '
1864 1963
 						</ul>
@@ -1883,20 +1982,23 @@  discard block
 block discarded – undo
1883 1982
 		echo '
1884 1983
 								<div>';
1885 1984
 
1886
-		if (!empty($incontext['continue']))
1887
-			echo '
1985
+		if (!empty($incontext['continue'])) {
1986
+					echo '
1888 1987
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button_submit" />';
1889
-		if (!empty($incontext['skip']))
1890
-			echo '
1988
+		}
1989
+		if (!empty($incontext['skip'])) {
1990
+					echo '
1891 1991
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button_submit" />';
1992
+		}
1892 1993
 		echo '
1893 1994
 								</div>';
1894 1995
 	}
1895 1996
 
1896 1997
 	// Show the closing form tag and other data only if not in the last step
1897
-	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step'])
1898
-		echo '
1998
+	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) {
1999
+			echo '
1899 2000
 							</form>';
2001
+	}
1900 2002
 
1901 2003
 	echo '
1902 2004
 						</div>
@@ -1931,13 +2033,15 @@  discard block
 block discarded – undo
1931 2033
 		</div>';
1932 2034
 
1933 2035
 	// Show the warnings, or not.
1934
-	if (template_warning_divs())
1935
-		echo '
2036
+	if (template_warning_divs()) {
2037
+			echo '
1936 2038
 		<h3>', $txt['install_all_lovely'], '</h3>';
2039
+	}
1937 2040
 
1938 2041
 	// Say we want the continue button!
1939
-	if (empty($incontext['error']))
1940
-		$incontext['continue'] = 1;
2042
+	if (empty($incontext['error'])) {
2043
+			$incontext['continue'] = 1;
2044
+	}
1941 2045
 
1942 2046
 	// For the latest version stuff.
1943 2047
 	echo '
@@ -1971,8 +2075,8 @@  discard block
 block discarded – undo
1971 2075
 	global $txt, $incontext;
1972 2076
 
1973 2077
 	// Errors are very serious..
1974
-	if (!empty($incontext['error']))
1975
-		echo '
2078
+	if (!empty($incontext['error'])) {
2079
+			echo '
1976 2080
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
1977 2081
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
1978 2082
 			<strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br>
@@ -1980,9 +2084,10 @@  discard block
 block discarded – undo
1980 2084
 				', $incontext['error'], '
1981 2085
 			</div>
1982 2086
 		</div>';
2087
+	}
1983 2088
 	// A warning message?
1984
-	elseif (!empty($incontext['warning']))
1985
-		echo '
2089
+	elseif (!empty($incontext['warning'])) {
2090
+			echo '
1986 2091
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
1987 2092
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
1988 2093
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -1990,6 +2095,7 @@  discard block
 block discarded – undo
1990 2095
 				', $incontext['warning'], '
1991 2096
 			</div>
1992 2097
 		</div>';
2098
+	}
1993 2099
 
1994 2100
 	return empty($incontext['error']) && empty($incontext['warning']);
1995 2101
 }
@@ -2005,27 +2111,30 @@  discard block
 block discarded – undo
2005 2111
 			<li>', $incontext['failed_files']), '</li>
2006 2112
 		</ul>';
2007 2113
 
2008
-	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux')
2009
-		echo '
2114
+	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') {
2115
+			echo '
2010 2116
 		<hr>
2011 2117
 		<p>', $txt['chmod_linux_info'], '</p>
2012 2118
 		<tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>';
2119
+	}
2013 2120
 
2014 2121
 	// This is serious!
2015
-	if (!template_warning_divs())
2016
-		return;
2122
+	if (!template_warning_divs()) {
2123
+			return;
2124
+	}
2017 2125
 
2018 2126
 	echo '
2019 2127
 		<hr>
2020 2128
 		<p>', $txt['ftp_setup_info'], '</p>';
2021 2129
 
2022
-	if (!empty($incontext['ftp_errors']))
2023
-		echo '
2130
+	if (!empty($incontext['ftp_errors'])) {
2131
+			echo '
2024 2132
 		<div class="error_message">
2025 2133
 			', $txt['error_ftp_no_connect'], '<br><br>
2026 2134
 			<code>', implode('<br>', $incontext['ftp_errors']), '</code>
2027 2135
 		</div>
2028 2136
 		<br>';
2137
+	}
2029 2138
 
2030 2139
 	echo '
2031 2140
 		<form action="', $incontext['form_url'], '" method="post">
@@ -2085,17 +2194,17 @@  discard block
 block discarded – undo
2085 2194
 				<td>
2086 2195
 					<select name="db_type" id="db_type_input" onchange="toggleDBInput();">';
2087 2196
 
2088
-	foreach ($incontext['supported_databases'] as $key => $db)
2089
-			echo '
2197
+	foreach ($incontext['supported_databases'] as $key => $db) {
2198
+				echo '
2090 2199
 						<option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>';
2200
+	}
2091 2201
 
2092 2202
 	echo '
2093 2203
 					</select>
2094 2204
 					<div class="smalltext block">', $txt['db_settings_type_info'], '</div>
2095 2205
 				</td>
2096 2206
 			</tr>';
2097
-	}
2098
-	else
2207
+	} else
2099 2208
 	{
2100 2209
 		echo '
2101 2210
 			<tr style="display: none;">
@@ -2287,9 +2396,10 @@  discard block
 block discarded – undo
2287 2396
 				<div style="color: red;">', $txt['error_db_queries'], '</div>
2288 2397
 				<ul>';
2289 2398
 
2290
-		foreach ($incontext['failures'] as $line => $fail)
2291
-			echo '
2399
+		foreach ($incontext['failures'] as $line => $fail) {
2400
+					echo '
2292 2401
 						<li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>';
2402
+		}
2293 2403
 
2294 2404
 		echo '
2295 2405
 				</ul>';
@@ -2350,15 +2460,16 @@  discard block
 block discarded – undo
2350 2460
 			</tr>
2351 2461
 		</table>';
2352 2462
 
2353
-	if ($incontext['require_db_confirm'])
2354
-		echo '
2463
+	if ($incontext['require_db_confirm']) {
2464
+			echo '
2355 2465
 		<h2>', $txt['user_settings_database'], '</h2>
2356 2466
 		<p>', $txt['user_settings_database_info'], '</p>
2357 2467
 
2358 2468
 		<div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;">
2359 2469
 			<input type="password" name="password3" size="30" class="input_password" />
2360 2470
 		</div>';
2361
-}
2471
+	}
2472
+	}
2362 2473
 
2363 2474
 // Tell them it's done, and to delete.
2364 2475
 function template_delete_install()
@@ -2371,14 +2482,15 @@  discard block
 block discarded – undo
2371 2482
 	template_warning_divs();
2372 2483
 
2373 2484
 	// Install directory still writable?
2374
-	if ($incontext['dir_still_writable'])
2375
-		echo '
2485
+	if ($incontext['dir_still_writable']) {
2486
+			echo '
2376 2487
 		<em>', $txt['still_writable'], '</em><br>
2377 2488
 		<br>';
2489
+	}
2378 2490
 
2379 2491
 	// Don't show the box if it's like 99% sure it won't work :P.
2380
-	if ($incontext['probably_delete_install'])
2381
-		echo '
2492
+	if ($incontext['probably_delete_install']) {
2493
+			echo '
2382 2494
 		<div style="margin: 1ex; font-weight: bold;">
2383 2495
 			<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>
2384 2496
 		</div>
@@ -2394,6 +2506,7 @@  discard block
 block discarded – undo
2394 2506
 			}
2395 2507
 		</script>
2396 2508
 		<br>';
2509
+	}
2397 2510
 
2398 2511
 	echo '
2399 2512
 		', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br>
Please login to merge, or discard this patch.