Completed
Push — release-2.1 ( 31f046...98fee7 )
by Jeremy
08:18
created
other/install.php 1 patch
Braces   +470 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
 	}
@@ -313,10 +325,11 @@  discard block
 block discarded – undo
313 325
 	}
314 326
 
315 327
 	// Override the language file?
316
-	if (isset($_GET['lang_file']))
317
-		$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
318
-	elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file']))
319
-		$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_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'];
332
+	}
320 333
 
321 334
 	// Make sure it exists, if it doesn't reset it.
322 335
 	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']))
@@ -325,8 +338,9 @@  discard block
 block discarded – undo
325 338
 		list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
326 339
 
327 340
 		// If we have english and some other language, use the other language.  We Americans hate english :P.
328
-		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1)
329
-			list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
341
+		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) {
342
+					list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
343
+		}
330 344
 	}
331 345
 
332 346
 	// And now include the actual language file itself.
@@ -343,15 +357,18 @@  discard block
 block discarded – undo
343 357
 	global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings;
344 358
 	global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist;
345 359
 
346
-	if (empty($sourcedir))
347
-		$sourcedir = dirname(__FILE__) . '/Sources';
360
+	if (empty($sourcedir)) {
361
+			$sourcedir = dirname(__FILE__) . '/Sources';
362
+	}
348 363
 
349 364
 	// Need this to check whether we need the database password.
350 365
 	require(dirname(__FILE__) . '/Settings.php');
351
-	if (!defined('SMF'))
352
-		define('SMF', 1);
353
-	if (empty($smcFunc))
354
-		$smcFunc = array();
366
+	if (!defined('SMF')) {
367
+			define('SMF', 1);
368
+	}
369
+	if (empty($smcFunc)) {
370
+			$smcFunc = array();
371
+	}
355 372
 
356 373
 	$modSettings['disableQueryCheck'] = true;
357 374
 
@@ -359,8 +376,9 @@  discard block
 block discarded – undo
359 376
 	if (!$db_connection)
360 377
 	{
361 378
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
362
-		if (version_compare(PHP_VERSION, '5', '<'))
363
-			require_once($sourcedir . '/Subs-Compat.php');
379
+		if (version_compare(PHP_VERSION, '5', '<')) {
380
+					require_once($sourcedir . '/Subs-Compat.php');
381
+		}
364 382
 
365 383
 		$db_options = array('persist' => $db_persist);
366 384
 		$port = '';
@@ -371,19 +389,20 @@  discard block
 block discarded – undo
371 389
 			if ($db_type == 'mysql')
372 390
 			{
373 391
 				$port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port'];
374
-			}
375
-			elseif ($db_type == 'postgresql')
392
+			} elseif ($db_type == 'postgresql')
376 393
 			{
377 394
 				// PostgreSQL doesn't have a default port setting in php.ini, so just check against the default
378 395
 				$port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port'];
379 396
 			}
380 397
 		}
381 398
 
382
-		if (!empty($port))
383
-			$db_options['port'] = $port;
399
+		if (!empty($port)) {
400
+					$db_options['port'] = $port;
401
+		}
384 402
 
385
-		if (!$db_connection)
386
-			$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
+		}
387 406
 	}
388 407
 }
389 408
 
@@ -411,8 +430,9 @@  discard block
 block discarded – undo
411 430
 		// @todo REMOVE THIS!!
412 431
 		else
413 432
 		{
414
-			if (function_exists('doStep' . $_GET['step']))
415
-				call_user_func('doStep' . $_GET['step']);
433
+			if (function_exists('doStep' . $_GET['step'])) {
434
+							call_user_func('doStep' . $_GET['step']);
435
+			}
416 436
 		}
417 437
 		// Show the footer.
418 438
 		template_install_below();
@@ -430,8 +450,9 @@  discard block
 block discarded – undo
430 450
 	$incontext['sub_template'] = 'welcome_message';
431 451
 
432 452
 	// Done the submission?
433
-	if (isset($_POST['contbutt']))
434
-		return true;
453
+	if (isset($_POST['contbutt'])) {
454
+			return true;
455
+	}
435 456
 
436 457
 	// See if we think they have already installed it?
437 458
 	if (is_readable(dirname(__FILE__) . '/Settings.php'))
@@ -439,14 +460,17 @@  discard block
 block discarded – undo
439 460
 		$probably_installed = 0;
440 461
 		foreach (file(dirname(__FILE__) . '/Settings.php') as $line)
441 462
 		{
442
-			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line))
443
-				$probably_installed++;
444
-			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line))
445
-				$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
+			}
446 469
 		}
447 470
 
448
-		if ($probably_installed == 2)
449
-			$incontext['warning'] = $txt['error_already_installed'];
471
+		if ($probably_installed == 2) {
472
+					$incontext['warning'] = $txt['error_already_installed'];
473
+		}
450 474
 	}
451 475
 
452 476
 	// Is some database support even compiled in?
@@ -461,45 +485,54 @@  discard block
 block discarded – undo
461 485
 				$databases[$key]['supported'] = false;
462 486
 				$notFoundSQLFile = true;
463 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;
464 490
 			}
465
-			else
466
-				$incontext['supported_databases'][] = $db;
467 491
 		}
468 492
 	}
469 493
 
470 494
 	// Check the PHP version.
471
-	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>=')))
472
-		$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
+	}
473 498
 	// Make sure we have a supported database
474
-	elseif (empty($incontext['supported_databases']))
475
-		$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
+	}
476 502
 	// How about session support?  Some crazy sysadmin remove it?
477
-	elseif (!function_exists('session_start'))
478
-		$error = 'error_session_missing';
503
+	elseif (!function_exists('session_start')) {
504
+			$error = 'error_session_missing';
505
+	}
479 506
 	// Make sure they uploaded all the files.
480
-	elseif (!file_exists(dirname(__FILE__) . '/index.php'))
481
-		$error = 'error_missing_files';
507
+	elseif (!file_exists(dirname(__FILE__) . '/index.php')) {
508
+			$error = 'error_missing_files';
509
+	}
482 510
 	// Very simple check on the session.save_path for Windows.
483 511
 	// @todo Move this down later if they don't use database-driven sessions?
484
-	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\')
485
-		$error = 'error_session_save_path';
512
+	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') {
513
+			$error = 'error_session_save_path';
514
+	}
486 515
 
487 516
 	// Since each of the three messages would look the same, anyway...
488
-	if (isset($error))
489
-		$incontext['error'] = $txt[$error];
517
+	if (isset($error)) {
518
+			$incontext['error'] = $txt[$error];
519
+	}
490 520
 
491 521
 	// Mod_security blocks everything that smells funny. Let SMF handle security.
492
-	if (!fixModSecurity() && !isset($_GET['overmodsecurity']))
493
-		$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
+	}
494 525
 
495 526
 	// Confirm mbstring is loaded...
496
-	if (!extension_loaded('mbstring'))
497
-		$incontext['error'] = $txt['install_no_mbstring'];
527
+	if (!extension_loaded('mbstring')) {
528
+			$incontext['error'] = $txt['install_no_mbstring'];
529
+	}
498 530
 
499 531
 	// Check for https stream support.
500 532
 	$supported_streams = stream_get_wrappers();
501
-	if (!in_array('https', $supported_streams))
502
-		$incontext['warning'] = $txt['install_no_https'];
533
+	if (!in_array('https', $supported_streams)) {
534
+			$incontext['warning'] = $txt['install_no_https'];
535
+	}
503 536
 
504 537
 	return false;
505 538
 }
@@ -524,12 +557,14 @@  discard block
 block discarded – undo
524 557
 		'Settings_bak.php',
525 558
 	);
526 559
 
527
-	foreach ($incontext['detected_languages'] as $lang => $temp)
528
-		$extra_files[] = 'Themes/default/languages/' . $lang;
560
+	foreach ($incontext['detected_languages'] as $lang => $temp) {
561
+			$extra_files[] = 'Themes/default/languages/' . $lang;
562
+	}
529 563
 
530 564
 	// With mod_security installed, we could attempt to fix it with .htaccess.
531
-	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules()))
532
-		$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
565
+	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) {
566
+			$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
567
+	}
533 568
 
534 569
 	$failed_files = array();
535 570
 
@@ -541,20 +576,23 @@  discard block
 block discarded – undo
541 576
 		foreach ($writable_files as $file)
542 577
 		{
543 578
 			// Some files won't exist, try to address up front
544
-			if (!file_exists(dirname(__FILE__) . '/' . $file))
545
-				@touch(dirname(__FILE__) . '/' . $file);
579
+			if (!file_exists(dirname(__FILE__) . '/' . $file)) {
580
+							@touch(dirname(__FILE__) . '/' . $file);
581
+			}
546 582
 			// NOW do the writable check...
547 583
 			if (!is_writable(dirname(__FILE__) . '/' . $file))
548 584
 			{
549 585
 				@chmod(dirname(__FILE__) . '/' . $file, 0755);
550 586
 
551 587
 				// Well, 755 hopefully worked... if not, try 777.
552
-				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777))
553
-					$failed_files[] = $file;
588
+				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) {
589
+									$failed_files[] = $file;
590
+				}
554 591
 			}
555 592
 		}
556
-		foreach ($extra_files as $file)
557
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
593
+		foreach ($extra_files as $file) {
594
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
595
+		}
558 596
 	}
559 597
 	// Windows is trickier.  Let's try opening for r+...
560 598
 	else
@@ -564,30 +602,35 @@  discard block
 block discarded – undo
564 602
 		foreach ($writable_files as $file)
565 603
 		{
566 604
 			// Folders can't be opened for write... but the index.php in them can ;)
567
-			if (is_dir(dirname(__FILE__) . '/' . $file))
568
-				$file .= '/index.php';
605
+			if (is_dir(dirname(__FILE__) . '/' . $file)) {
606
+							$file .= '/index.php';
607
+			}
569 608
 
570 609
 			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
571 610
 			@chmod(dirname(__FILE__) . '/' . $file, 0777);
572 611
 			$fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+');
573 612
 
574 613
 			// Hmm, okay, try just for write in that case...
575
-			if (!is_resource($fp))
576
-				$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
614
+			if (!is_resource($fp)) {
615
+							$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
616
+			}
577 617
 
578
-			if (!is_resource($fp))
579
-				$failed_files[] = $file;
618
+			if (!is_resource($fp)) {
619
+							$failed_files[] = $file;
620
+			}
580 621
 
581 622
 			@fclose($fp);
582 623
 		}
583
-		foreach ($extra_files as $file)
584
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
624
+		foreach ($extra_files as $file) {
625
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
626
+		}
585 627
 	}
586 628
 
587 629
 	$failure = count($failed_files) >= 1;
588 630
 
589
-	if (!isset($_SERVER))
590
-		return !$failure;
631
+	if (!isset($_SERVER)) {
632
+			return !$failure;
633
+	}
591 634
 
592 635
 	// Put the list into context.
593 636
 	$incontext['failed_files'] = $failed_files;
@@ -635,19 +678,23 @@  discard block
 block discarded – undo
635 678
 
636 679
 		if (!isset($ftp) || $ftp->error !== false)
637 680
 		{
638
-			if (!isset($ftp))
639
-				$ftp = new ftp_connection(null);
681
+			if (!isset($ftp)) {
682
+							$ftp = new ftp_connection(null);
683
+			}
640 684
 			// Save the error so we can mess with listing...
641
-			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message))
642
-				$incontext['ftp_errors'][] = $ftp->last_message;
685
+			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) {
686
+							$incontext['ftp_errors'][] = $ftp->last_message;
687
+			}
643 688
 
644 689
 			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
645 690
 
646
-			if (empty($_POST['ftp_path']) && $found_path)
647
-				$_POST['ftp_path'] = $detect_path;
691
+			if (empty($_POST['ftp_path']) && $found_path) {
692
+							$_POST['ftp_path'] = $detect_path;
693
+			}
648 694
 
649
-			if (!isset($_POST['ftp_username']))
650
-				$_POST['ftp_username'] = $username;
695
+			if (!isset($_POST['ftp_username'])) {
696
+							$_POST['ftp_username'] = $username;
697
+			}
651 698
 
652 699
 			// Set the username etc, into context.
653 700
 			$incontext['ftp'] = array(
@@ -659,8 +706,7 @@  discard block
 block discarded – undo
659 706
 			);
660 707
 
661 708
 			return false;
662
-		}
663
-		else
709
+		} else
664 710
 		{
665 711
 			$_SESSION['installer_temp_ftp'] = array(
666 712
 				'server' => $_POST['ftp_server'],
@@ -674,10 +720,12 @@  discard block
 block discarded – undo
674 720
 
675 721
 			foreach ($failed_files as $file)
676 722
 			{
677
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
678
-					$ftp->chmod($file, 0755);
679
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
680
-					$ftp->chmod($file, 0777);
723
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
724
+									$ftp->chmod($file, 0755);
725
+				}
726
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
727
+									$ftp->chmod($file, 0777);
728
+				}
681 729
 				if (!is_writable(dirname(__FILE__) . '/' . $file))
682 730
 				{
683 731
 					$failed_files_updated[] = $file;
@@ -733,15 +781,17 @@  discard block
 block discarded – undo
733 781
 
734 782
 			if (!$foundOne)
735 783
 			{
736
-				if (isset($db['default_host']))
737
-					$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
784
+				if (isset($db['default_host'])) {
785
+									$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
786
+				}
738 787
 				if (isset($db['default_user']))
739 788
 				{
740 789
 					$incontext['db']['user'] = ini_get($db['default_user']);
741 790
 					$incontext['db']['name'] = ini_get($db['default_user']);
742 791
 				}
743
-				if (isset($db['default_password']))
744
-					$incontext['db']['pass'] = ini_get($db['default_password']);
792
+				if (isset($db['default_password'])) {
793
+									$incontext['db']['pass'] = ini_get($db['default_password']);
794
+				}
745 795
 
746 796
 				// For simplicity and less confusion, leave the port blank by default
747 797
 				$incontext['db']['port'] = '';
@@ -760,10 +810,10 @@  discard block
 block discarded – undo
760 810
 		$incontext['db']['server'] = $_POST['db_server'];
761 811
 		$incontext['db']['prefix'] = $_POST['db_prefix'];
762 812
 
763
-		if (!empty($_POST['db_port']))
764
-			$incontext['db']['port'] = $_POST['db_port'];
765
-	}
766
-	else
813
+		if (!empty($_POST['db_port'])) {
814
+					$incontext['db']['port'] = $_POST['db_port'];
815
+		}
816
+	} else
767 817
 	{
768 818
 		$incontext['db']['prefix'] = 'smf_';
769 819
 	}
@@ -799,10 +849,11 @@  discard block
 block discarded – undo
799 849
 		if (!empty($_POST['db_port']))
800 850
 		{
801 851
 			// For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though.
802
-			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port'))
803
-				$vars['db_port'] = (int) $_POST['db_port'];
804
-			elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432)
805
-				$vars['db_port'] = (int) $_POST['db_port'];
852
+			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) {
853
+							$vars['db_port'] = (int) $_POST['db_port'];
854
+			} elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) {
855
+							$vars['db_port'] = (int) $_POST['db_port'];
856
+			}
806 857
 		}
807 858
 
808 859
 		// God I hope it saved!
@@ -815,8 +866,9 @@  discard block
 block discarded – undo
815 866
 		// Make sure it works.
816 867
 		require(dirname(__FILE__) . '/Settings.php');
817 868
 
818
-		if (empty($sourcedir))
819
-			$sourcedir = dirname(__FILE__) . '/Sources';
869
+		if (empty($sourcedir)) {
870
+					$sourcedir = dirname(__FILE__) . '/Sources';
871
+		}
820 872
 
821 873
 		// Better find the database file!
822 874
 		if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
@@ -826,18 +878,21 @@  discard block
 block discarded – undo
826 878
 		}
827 879
 
828 880
 		// Now include it for database functions!
829
-		if (!defined('SMF'))
830
-			define('SMF', 1);
881
+		if (!defined('SMF')) {
882
+					define('SMF', 1);
883
+		}
831 884
 
832 885
 		$modSettings['disableQueryCheck'] = true;
833
-		if (empty($smcFunc))
834
-			$smcFunc = array();
886
+		if (empty($smcFunc)) {
887
+					$smcFunc = array();
888
+		}
835 889
 
836 890
 			require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
837 891
 
838 892
 		// What - running PHP4? The shame!
839
-		if (version_compare(PHP_VERSION, '5', '<'))
840
-			require_once($sourcedir . '/Subs-Compat.php');
893
+		if (version_compare(PHP_VERSION, '5', '<')) {
894
+					require_once($sourcedir . '/Subs-Compat.php');
895
+		}
841 896
 
842 897
 		// Attempt a connection.
843 898
 		$needsDB = !empty($databases[$db_type]['always_has_db']);
@@ -925,12 +980,14 @@  discard block
 block discarded – undo
925 980
 	$incontext['page_title'] = $txt['install_settings'];
926 981
 
927 982
 	// Let's see if we got the database type correct.
928
-	if (isset($_POST['db_type'], $databases[$_POST['db_type']]))
929
-		$db_type = $_POST['db_type'];
983
+	if (isset($_POST['db_type'], $databases[$_POST['db_type']])) {
984
+			$db_type = $_POST['db_type'];
985
+	}
930 986
 
931 987
 	// Else we'd better be able to get the connection.
932
-	else
933
-		load_database();
988
+	else {
989
+			load_database();
990
+	}
934 991
 
935 992
 	$db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type;
936 993
 
@@ -939,10 +996,11 @@  discard block
 block discarded – undo
939 996
 
940 997
 		$secure = false;
941 998
 
942
-		if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
943
-			$secure = true;
944
-		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')
945
-			$secure = true;
999
+		if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
1000
+					$secure = true;
1001
+		} 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') {
1002
+					$secure = true;
1003
+		}
946 1004
 
947 1005
 	// Now, to put what we've learned together... and add a path.
948 1006
 	$incontext['detected_url'] = 'http' . ($secure ? 's' : '') . '://' . $host . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'));
@@ -974,18 +1032,21 @@  discard block
 block discarded – undo
974 1032
 	// Submitting?
975 1033
 	if (isset($_POST['boardurl']))
976 1034
 	{
977
-		if (substr($_POST['boardurl'], -10) == '/index.php')
978
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
979
-		elseif (substr($_POST['boardurl'], -1) == '/')
980
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
981
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
982
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1035
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
1036
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1037
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
1038
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1039
+		}
1040
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
1041
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1042
+		}
983 1043
 
984 1044
 		//Make sure boardurl is aligned with ssl setting
985
-		if (empty($_POST['force_ssl']))
986
-			$_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://'));
987
-		else
988
-			$_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://'));
1045
+		if (empty($_POST['force_ssl'])) {
1046
+					$_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://'));
1047
+		} else {
1048
+					$_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://'));
1049
+		}
989 1050
 
990 1051
 		// Save these variables.
991 1052
 		$vars = array(
@@ -1024,10 +1085,10 @@  discard block
 block discarded – undo
1024 1085
 			{
1025 1086
 				$incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']);
1026 1087
 				return false;
1027
-			}
1028
-			else
1029
-				// Set the character set here.
1088
+			} else {
1089
+							// Set the character set here.
1030 1090
 				updateSettingsFile(array('db_character_set' => 'utf8'));
1091
+			}
1031 1092
 		}
1032 1093
 
1033 1094
 		// Good, skip on.
@@ -1047,8 +1108,9 @@  discard block
 block discarded – undo
1047 1108
 	$incontext['continue'] = 1;
1048 1109
 
1049 1110
 	// Already done?
1050
-	if (isset($_POST['pop_done']))
1051
-		return true;
1111
+	if (isset($_POST['pop_done'])) {
1112
+			return true;
1113
+	}
1052 1114
 
1053 1115
 	// Reload settings.
1054 1116
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1066,8 +1128,9 @@  discard block
 block discarded – undo
1066 1128
 	$modSettings = array();
1067 1129
 	if ($result !== false)
1068 1130
 	{
1069
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1070
-			$modSettings[$row['variable']] = $row['value'];
1131
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1132
+					$modSettings[$row['variable']] = $row['value'];
1133
+		}
1071 1134
 		$smcFunc['db_free_result']($result);
1072 1135
 
1073 1136
 		// Do they match?  If so, this is just a refresh so charge on!
@@ -1080,20 +1143,22 @@  discard block
 block discarded – undo
1080 1143
 	$modSettings['disableQueryCheck'] = true;
1081 1144
 
1082 1145
 	// If doing UTF8, select it. PostgreSQL requires passing it as a string...
1083
-	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support']))
1084
-		$smcFunc['db_query']('', '
1146
+	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) {
1147
+			$smcFunc['db_query']('', '
1085 1148
 			SET NAMES {string:utf8}',
1086 1149
 			array(
1087 1150
 				'db_error_skip' => true,
1088 1151
 				'utf8' => 'utf8',
1089 1152
 			)
1090 1153
 		);
1154
+	}
1091 1155
 
1092 1156
 	// Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments...
1093
-	if (substr(__DIR__, -1) == '\\')
1094
-		$attachdir = __DIR__ . 'attachments';
1095
-	else
1096
-		$attachdir = __DIR__ . '/attachments';
1157
+	if (substr(__DIR__, -1) == '\\') {
1158
+			$attachdir = __DIR__ . 'attachments';
1159
+	} else {
1160
+			$attachdir = __DIR__ . '/attachments';
1161
+	}
1097 1162
 
1098 1163
 	$replaces = array(
1099 1164
 		'{$db_prefix}' => $db_prefix,
@@ -1110,8 +1175,9 @@  discard block
 block discarded – undo
1110 1175
 
1111 1176
 	foreach ($txt as $key => $value)
1112 1177
 	{
1113
-		if (substr($key, 0, 8) == 'default_')
1114
-			$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1178
+		if (substr($key, 0, 8) == 'default_') {
1179
+					$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1180
+		}
1115 1181
 	}
1116 1182
 	$replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n'));
1117 1183
 
@@ -1126,8 +1192,9 @@  discard block
 block discarded – undo
1126 1192
 
1127 1193
 		while ($row = $smcFunc['db_fetch_assoc']($get_engines))
1128 1194
 		{
1129
-			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT')
1130
-				$engines[] = $row['Engine'];
1195
+			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') {
1196
+							$engines[] = $row['Engine'];
1197
+			}
1131 1198
 		}
1132 1199
 
1133 1200
 		// Done with this now
@@ -1151,8 +1218,7 @@  discard block
 block discarded – undo
1151 1218
 			$replaces['START TRANSACTION;'] = '';
1152 1219
 			$replaces['COMMIT;'] = '';
1153 1220
 		}
1154
-	}
1155
-	else
1221
+	} else
1156 1222
 	{
1157 1223
 		$has_innodb = false;
1158 1224
 	}
@@ -1174,21 +1240,24 @@  discard block
 block discarded – undo
1174 1240
 	foreach ($sql_lines as $count => $line)
1175 1241
 	{
1176 1242
 		// No comments allowed!
1177
-		if (substr(trim($line), 0, 1) != '#')
1178
-			$current_statement .= "\n" . rtrim($line);
1243
+		if (substr(trim($line), 0, 1) != '#') {
1244
+					$current_statement .= "\n" . rtrim($line);
1245
+		}
1179 1246
 
1180 1247
 		// Is this the end of the query string?
1181
-		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines)))
1182
-			continue;
1248
+		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) {
1249
+					continue;
1250
+		}
1183 1251
 
1184 1252
 		// Does this table already exist?  If so, don't insert more data into it!
1185 1253
 		if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists))
1186 1254
 		{
1187 1255
 			preg_match_all('~\)[,;]~', $current_statement, $matches);
1188
-			if (!empty($matches[0]))
1189
-				$incontext['sql_results']['insert_dups'] += count($matches[0]);
1190
-			else
1191
-				$incontext['sql_results']['insert_dups']++;
1256
+			if (!empty($matches[0])) {
1257
+							$incontext['sql_results']['insert_dups'] += count($matches[0]);
1258
+			} else {
1259
+							$incontext['sql_results']['insert_dups']++;
1260
+			}
1192 1261
 
1193 1262
 			$current_statement = '';
1194 1263
 			continue;
@@ -1197,8 +1266,9 @@  discard block
 block discarded – undo
1197 1266
 		if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false)
1198 1267
 		{
1199 1268
 			// Use the appropriate function based on the DB type
1200
-			if ($db_type == 'mysql' || $db_type == 'mysqli')
1201
-				$db_errorno = $db_type . '_errno';
1269
+			if ($db_type == 'mysql' || $db_type == 'mysqli') {
1270
+							$db_errorno = $db_type . '_errno';
1271
+			}
1202 1272
 
1203 1273
 			// Error 1050: Table already exists!
1204 1274
 			// @todo Needs to be made better!
@@ -1213,18 +1283,18 @@  discard block
 block discarded – undo
1213 1283
 				// MySQLi requires a connection object. It's optional with MySQL and Postgres
1214 1284
 				$incontext['failures'][$count] = $smcFunc['db_error']($db_connection);
1215 1285
 			}
1216
-		}
1217
-		else
1286
+		} else
1218 1287
 		{
1219
-			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1220
-				$incontext['sql_results']['tables']++;
1221
-			elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1288
+			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) {
1289
+							$incontext['sql_results']['tables']++;
1290
+			} elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1222 1291
 			{
1223 1292
 				preg_match_all('~\)[,;]~', $current_statement, $matches);
1224
-				if (!empty($matches[0]))
1225
-					$incontext['sql_results']['inserts'] += count($matches[0]);
1226
-				else
1227
-					$incontext['sql_results']['inserts']++;
1293
+				if (!empty($matches[0])) {
1294
+									$incontext['sql_results']['inserts'] += count($matches[0]);
1295
+				} else {
1296
+									$incontext['sql_results']['inserts']++;
1297
+				}
1228 1298
 			}
1229 1299
 		}
1230 1300
 
@@ -1237,15 +1307,17 @@  discard block
 block discarded – undo
1237 1307
 	// Sort out the context for the SQL.
1238 1308
 	foreach ($incontext['sql_results'] as $key => $number)
1239 1309
 	{
1240
-		if ($number == 0)
1241
-			unset($incontext['sql_results'][$key]);
1242
-		else
1243
-			$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1310
+		if ($number == 0) {
1311
+					unset($incontext['sql_results'][$key]);
1312
+		} else {
1313
+					$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1314
+		}
1244 1315
 	}
1245 1316
 
1246 1317
 	// Make sure UTF will be used globally.
1247
-	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'])))
1248
-		$newSettings[] = array('global_character_set', 'UTF-8');
1318
+	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']))) {
1319
+			$newSettings[] = array('global_character_set', 'UTF-8');
1320
+	}
1249 1321
 
1250 1322
 	// Auto-detect local & global cookie settings
1251 1323
 	$url_parts = parse_url($boardurl);
@@ -1274,15 +1346,19 @@  discard block
 block discarded – undo
1274 1346
 
1275 1347
 		// Look for subfolder, if found, set localCookie
1276 1348
 		// Checking for len > 1 ensures you don't have just a slash...
1277
-		if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1)
1278
-			$localCookies = '1';
1349
+		if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) {
1350
+					$localCookies = '1';
1351
+		}
1279 1352
 
1280
-		if (isset($globalCookies))
1281
-			$newSettings[] = array('globalCookies', $globalCookies);
1282
-		if (isset($globalCookiesDomain))
1283
-			$newSettings[] = array('globalCookiesDomain', $globalCookiesDomain);
1284
-		if (isset($localCookies))
1285
-			$newSettings[] = array('localCookies', $localCookies);
1353
+		if (isset($globalCookies)) {
1354
+					$newSettings[] = array('globalCookies', $globalCookies);
1355
+		}
1356
+		if (isset($globalCookiesDomain)) {
1357
+					$newSettings[] = array('globalCookiesDomain', $globalCookiesDomain);
1358
+		}
1359
+		if (isset($localCookies)) {
1360
+					$newSettings[] = array('localCookies', $localCookies);
1361
+		}
1286 1362
 	}
1287 1363
 
1288 1364
 	// Are we allowing stat collection?
@@ -1300,16 +1376,17 @@  discard block
 block discarded – undo
1300 1376
 			fwrite($fp, $out);
1301 1377
 
1302 1378
 			$return_data = '';
1303
-			while (!feof($fp))
1304
-				$return_data .= fgets($fp, 128);
1379
+			while (!feof($fp)) {
1380
+							$return_data .= fgets($fp, 128);
1381
+			}
1305 1382
 
1306 1383
 			fclose($fp);
1307 1384
 
1308 1385
 			// Get the unique site ID.
1309 1386
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1310 1387
 
1311
-			if (!empty($ID[1]))
1312
-				$smcFunc['db_insert']('replace',
1388
+			if (!empty($ID[1])) {
1389
+							$smcFunc['db_insert']('replace',
1313 1390
 					$db_prefix . 'settings',
1314 1391
 					array('variable' => 'string', 'value' => 'string'),
1315 1392
 					array(
@@ -1318,11 +1395,12 @@  discard block
 block discarded – undo
1318 1395
 					),
1319 1396
 					array('variable')
1320 1397
 				);
1398
+			}
1321 1399
 		}
1322 1400
 	}
1323 1401
 	// Don't remove stat collection unless we unchecked the box for real, not from the loop.
1324
-	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats']))
1325
-		$smcFunc['db_query']('', '
1402
+	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) {
1403
+			$smcFunc['db_query']('', '
1326 1404
 			DELETE FROM {db_prefix}settings
1327 1405
 			WHERE variable = {string:enable_sm_stats}',
1328 1406
 			array(
@@ -1330,20 +1408,23 @@  discard block
 block discarded – undo
1330 1408
 				'db_error_skip' => true,
1331 1409
 			)
1332 1410
 		);
1411
+	}
1333 1412
 
1334 1413
 	// Are we enabling SSL?
1335
-	if (!empty($_POST['force_ssl']))
1336
-		$newSettings[] = array('force_ssl', 1);
1414
+	if (!empty($_POST['force_ssl'])) {
1415
+			$newSettings[] = array('force_ssl', 1);
1416
+	}
1337 1417
 
1338 1418
 	// Setting a timezone is required.
1339 1419
 	if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set'))
1340 1420
 	{
1341 1421
 		// Get PHP's default timezone, if set
1342 1422
 		$ini_tz = ini_get('date.timezone');
1343
-		if (!empty($ini_tz))
1344
-			$timezone_id = $ini_tz;
1345
-		else
1346
-			$timezone_id = '';
1423
+		if (!empty($ini_tz)) {
1424
+					$timezone_id = $ini_tz;
1425
+		} else {
1426
+					$timezone_id = '';
1427
+		}
1347 1428
 
1348 1429
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
1349 1430
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -1352,8 +1433,9 @@  discard block
 block discarded – undo
1352 1433
 			$timezone_id = timezone_name_from_abbr('', $server_offset, 0);
1353 1434
 		}
1354 1435
 
1355
-		if (date_default_timezone_set($timezone_id))
1356
-			$newSettings[] = array('default_timezone', $timezone_id);
1436
+		if (date_default_timezone_set($timezone_id)) {
1437
+					$newSettings[] = array('default_timezone', $timezone_id);
1438
+		}
1357 1439
 	}
1358 1440
 
1359 1441
 	if (!empty($newSettings))
@@ -1384,16 +1466,18 @@  discard block
 block discarded – undo
1384 1466
 	}
1385 1467
 
1386 1468
 	// MySQL specific stuff
1387
-	if (substr($db_type, 0, 5) != 'mysql')
1388
-		return false;
1469
+	if (substr($db_type, 0, 5) != 'mysql') {
1470
+			return false;
1471
+	}
1389 1472
 
1390 1473
 	// Find database user privileges.
1391 1474
 	$privs = array();
1392 1475
 	$get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array());
1393 1476
 	while ($row = $smcFunc['db_fetch_assoc']($get_privs))
1394 1477
 	{
1395
-		if ($row['Privilege'] == 'Alter')
1396
-			$privs[] = $row['Privilege'];
1478
+		if ($row['Privilege'] == 'Alter') {
1479
+					$privs[] = $row['Privilege'];
1480
+		}
1397 1481
 	}
1398 1482
 	$smcFunc['db_free_result']($get_privs);
1399 1483
 
@@ -1423,8 +1507,9 @@  discard block
 block discarded – undo
1423 1507
 	$incontext['continue'] = 1;
1424 1508
 
1425 1509
 	// Skipping?
1426
-	if (!empty($_POST['skip']))
1427
-		return true;
1510
+	if (!empty($_POST['skip'])) {
1511
+			return true;
1512
+	}
1428 1513
 
1429 1514
 	// Need this to check whether we need the database password.
1430 1515
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1441,18 +1526,22 @@  discard block
 block discarded – undo
1441 1526
 	// We need this to properly hash the password for Admin
1442 1527
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) {
1443 1528
 			global $sourcedir;
1444
-			if (function_exists('mb_strtolower'))
1445
-				return mb_strtolower($string, 'UTF-8');
1529
+			if (function_exists('mb_strtolower')) {
1530
+							return mb_strtolower($string, 'UTF-8');
1531
+			}
1446 1532
 			require_once($sourcedir . '/Subs-Charset.php');
1447 1533
 			return utf8_strtolower($string);
1448 1534
 		};
1449 1535
 
1450
-	if (!isset($_POST['username']))
1451
-		$_POST['username'] = '';
1452
-	if (!isset($_POST['email']))
1453
-		$_POST['email'] = '';
1454
-	if (!isset($_POST['server_email']))
1455
-		$_POST['server_email'] = '';
1536
+	if (!isset($_POST['username'])) {
1537
+			$_POST['username'] = '';
1538
+	}
1539
+	if (!isset($_POST['email'])) {
1540
+			$_POST['email'] = '';
1541
+	}
1542
+	if (!isset($_POST['server_email'])) {
1543
+			$_POST['server_email'] = '';
1544
+	}
1456 1545
 
1457 1546
 	$incontext['username'] = htmlspecialchars(stripslashes($_POST['username']));
1458 1547
 	$incontext['email'] = htmlspecialchars(stripslashes($_POST['email']));
@@ -1471,8 +1560,9 @@  discard block
 block discarded – undo
1471 1560
 			'admin_group' => 1,
1472 1561
 		)
1473 1562
 	);
1474
-	if ($smcFunc['db_num_rows']($request) != 0)
1475
-		$incontext['skip'] = 1;
1563
+	if ($smcFunc['db_num_rows']($request) != 0) {
1564
+			$incontext['skip'] = 1;
1565
+	}
1476 1566
 	$smcFunc['db_free_result']($request);
1477 1567
 
1478 1568
 	// Trying to create an account?
@@ -1503,8 +1593,9 @@  discard block
 block discarded – undo
1503 1593
 		}
1504 1594
 
1505 1595
 		// Update the webmaster's email?
1506
-		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]'))
1507
-			updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1596
+		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) {
1597
+					updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1598
+		}
1508 1599
 
1509 1600
 		// Work out whether we're going to have dodgy characters and remove them.
1510 1601
 		$invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0;
@@ -1527,32 +1618,27 @@  discard block
 block discarded – undo
1527 1618
 			$smcFunc['db_free_result']($result);
1528 1619
 
1529 1620
 			$incontext['account_existed'] = $txt['error_user_settings_taken'];
1530
-		}
1531
-		elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1621
+		} elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1532 1622
 		{
1533 1623
 			// Try the previous step again.
1534 1624
 			$incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long'];
1535 1625
 			return false;
1536
-		}
1537
-		elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1626
+		} elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1538 1627
 		{
1539 1628
 			// Try the previous step again.
1540 1629
 			$incontext['error'] = $txt['error_invalid_characters_username'];
1541 1630
 			return false;
1542
-		}
1543
-		elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1631
+		} elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1544 1632
 		{
1545 1633
 			// One step back, this time fill out a proper admin email address.
1546 1634
 			$incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']);
1547 1635
 			return false;
1548
-		}
1549
-		elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1636
+		} elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1550 1637
 		{
1551 1638
 			// One step back, this time fill out a proper admin email address.
1552 1639
 			$incontext['error'] = $txt['error_valid_server_email_needed'];
1553 1640
 			return false;
1554
-		}
1555
-		elseif ($_POST['username'] != '')
1641
+		} elseif ($_POST['username'] != '')
1556 1642
 		{
1557 1643
 			$incontext['member_salt'] = substr(md5(mt_rand()), 0, 4);
1558 1644
 
@@ -1620,17 +1706,19 @@  discard block
 block discarded – undo
1620 1706
 	reloadSettings();
1621 1707
 
1622 1708
 	// Bring a warning over.
1623
-	if (!empty($incontext['account_existed']))
1624
-		$incontext['warning'] = $incontext['account_existed'];
1709
+	if (!empty($incontext['account_existed'])) {
1710
+			$incontext['warning'] = $incontext['account_existed'];
1711
+	}
1625 1712
 
1626
-	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support']))
1627
-		$smcFunc['db_query']('', '
1713
+	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) {
1714
+			$smcFunc['db_query']('', '
1628 1715
 			SET NAMES {string:db_character_set}',
1629 1716
 			array(
1630 1717
 				'db_character_set' => $db_character_set,
1631 1718
 				'db_error_skip' => true,
1632 1719
 			)
1633 1720
 		);
1721
+	}
1634 1722
 
1635 1723
 	// As track stats is by default enabled let's add some activity.
1636 1724
 	$smcFunc['db_insert']('ignore',
@@ -1651,14 +1739,16 @@  discard block
 block discarded – undo
1651 1739
 	// Only proceed if we can load the data.
1652 1740
 	if ($request)
1653 1741
 	{
1654
-		while ($row = $smcFunc['db_fetch_row']($request))
1655
-			$modSettings[$row[0]] = $row[1];
1742
+		while ($row = $smcFunc['db_fetch_row']($request)) {
1743
+					$modSettings[$row[0]] = $row[1];
1744
+		}
1656 1745
 		$smcFunc['db_free_result']($request);
1657 1746
 	}
1658 1747
 
1659 1748
 	// Automatically log them in ;)
1660
-	if (isset($incontext['member_id']) && isset($incontext['member_salt']))
1661
-		setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1749
+	if (isset($incontext['member_id']) && isset($incontext['member_salt'])) {
1750
+			setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1751
+	}
1662 1752
 
1663 1753
 	$result = $smcFunc['db_query']('', '
1664 1754
 		SELECT value
@@ -1669,13 +1759,14 @@  discard block
 block discarded – undo
1669 1759
 			'db_error_skip' => true,
1670 1760
 		)
1671 1761
 	);
1672
-	if ($smcFunc['db_num_rows']($result) != 0)
1673
-		list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1762
+	if ($smcFunc['db_num_rows']($result) != 0) {
1763
+			list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1764
+	}
1674 1765
 	$smcFunc['db_free_result']($result);
1675 1766
 
1676
-	if (empty($db_sessions))
1677
-		$_SESSION['admin_time'] = time();
1678
-	else
1767
+	if (empty($db_sessions)) {
1768
+			$_SESSION['admin_time'] = time();
1769
+	} else
1679 1770
 	{
1680 1771
 		$_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211);
1681 1772
 
@@ -1699,8 +1790,9 @@  discard block
 block discarded – undo
1699 1790
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1700 1791
 		function($string){
1701 1792
 			global $sourcedir;
1702
-			if (function_exists('mb_strtolower'))
1703
-				return mb_strtolower($string, 'UTF-8');
1793
+			if (function_exists('mb_strtolower')) {
1794
+							return mb_strtolower($string, 'UTF-8');
1795
+			}
1704 1796
 			require_once($sourcedir . '/Subs-Charset.php');
1705 1797
 			return utf8_strtolower($string);
1706 1798
 		};
@@ -1716,8 +1808,9 @@  discard block
 block discarded – undo
1716 1808
 		)
1717 1809
 	);
1718 1810
 	$context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8';
1719
-	if ($smcFunc['db_num_rows']($request) > 0)
1720
-		updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1811
+	if ($smcFunc['db_num_rows']($request) > 0) {
1812
+			updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1813
+	}
1721 1814
 	$smcFunc['db_free_result']($request);
1722 1815
 
1723 1816
 	// Now is the perfect time to fetch the SM files.
@@ -1736,8 +1829,9 @@  discard block
 block discarded – undo
1736 1829
 
1737 1830
 	// Check if we need some stupid MySQL fix.
1738 1831
 	$server_version = $smcFunc['db_server_info']();
1739
-	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1740
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1832
+	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1833
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1834
+	}
1741 1835
 
1742 1836
 	// Some final context for the template.
1743 1837
 	$incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\';
@@ -1757,8 +1851,9 @@  discard block
 block discarded – undo
1757 1851
 	$settingsArray = file(dirname(__FILE__) . '/Settings.php');
1758 1852
 
1759 1853
 	// @todo Do we just want to read the file in clean, and split it this way always?
1760
-	if (count($settingsArray) == 1)
1761
-		$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1854
+	if (count($settingsArray) == 1) {
1855
+			$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1856
+	}
1762 1857
 
1763 1858
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
1764 1859
 	{
@@ -1766,25 +1861,29 @@  discard block
 block discarded – undo
1766 1861
 		if (trim($settingsArray[$i]) == 'if (file_exists(dirname(__FILE__) . \'/install.php\'))' && trim($settingsArray[$i + 1]) == '{' && trim($settingsArray[$i + 9]) == '}')
1767 1862
 		{
1768 1863
 			// Set the ten lines to nothing.
1769
-			for ($j=0; $j < 10; $j++)
1770
-				$settingsArray[$i++] = '';
1864
+			for ($j=0; $j < 10; $j++) {
1865
+							$settingsArray[$i++] = '';
1866
+			}
1771 1867
 
1772 1868
 			continue;
1773 1869
 		}
1774 1870
 
1775
-		if (trim($settingsArray[$i]) == '?' . '>')
1776
-			$settingsArray[$i] = '';
1871
+		if (trim($settingsArray[$i]) == '?' . '>') {
1872
+					$settingsArray[$i] = '';
1873
+		}
1777 1874
 
1778 1875
 		// Don't trim or bother with it if it's not a variable.
1779
-		if (substr($settingsArray[$i], 0, 1) != '$')
1780
-			continue;
1876
+		if (substr($settingsArray[$i], 0, 1) != '$') {
1877
+					continue;
1878
+		}
1781 1879
 
1782 1880
 		$settingsArray[$i] = rtrim($settingsArray[$i]) . "\n";
1783 1881
 
1784
-		foreach ($vars as $var => $val)
1785
-			if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1882
+		foreach ($vars as $var => $val) {
1883
+					if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1786 1884
 			{
1787 1885
 				$comment = strstr($settingsArray[$i], '#');
1886
+		}
1788 1887
 				$settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n");
1789 1888
 				unset($vars[$var]);
1790 1889
 			}
@@ -1794,36 +1893,41 @@  discard block
 block discarded – undo
1794 1893
 	if (!empty($vars))
1795 1894
 	{
1796 1895
 		$settingsArray[$i++] = '';
1797
-		foreach ($vars as $var => $val)
1798
-			$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1896
+		foreach ($vars as $var => $val) {
1897
+					$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1898
+		}
1799 1899
 	}
1800 1900
 
1801 1901
 	// Blank out the file - done to fix a oddity with some servers.
1802 1902
 	$fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w');
1803
-	if (!$fp)
1804
-		return false;
1903
+	if (!$fp) {
1904
+			return false;
1905
+	}
1805 1906
 	fclose($fp);
1806 1907
 
1807 1908
 	$fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+');
1808 1909
 
1809 1910
 	// Gotta have one of these ;)
1810
-	if (trim($settingsArray[0]) != '<?php')
1811
-		fwrite($fp, "<?php\n");
1911
+	if (trim($settingsArray[0]) != '<?php') {
1912
+			fwrite($fp, "<?php\n");
1913
+	}
1812 1914
 
1813 1915
 	$lines = count($settingsArray);
1814 1916
 	for ($i = 0; $i < $lines - 1; $i++)
1815 1917
 	{
1816 1918
 		// Don't just write a bunch of blank lines.
1817
-		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '')
1818
-			fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1919
+		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') {
1920
+					fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1921
+		}
1819 1922
 	}
1820 1923
 	fwrite($fp, $settingsArray[$i] . '?' . '>');
1821 1924
 	fclose($fp);
1822 1925
 
1823 1926
 	// Even though on normal installations the filemtime should prevent this being used by the installer incorrectly
1824 1927
 	// it seems that there are times it might not. So let's MAKE it dump the cache.
1825
-	if (function_exists('opcache_invalidate'))
1826
-		opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1928
+	if (function_exists('opcache_invalidate')) {
1929
+			opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1930
+	}
1827 1931
 
1828 1932
 	return true;
1829 1933
 }
@@ -1833,10 +1937,11 @@  discard block
 block discarded – undo
1833 1937
 	global $cachedir;
1834 1938
 
1835 1939
 	// Write out the db_last_error file with the error timestamp
1836
-	if (!empty($cachedir) && is_writable($cachedir))
1837
-		file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>');
1838
-	else
1839
-		file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>');
1940
+	if (!empty($cachedir) && is_writable($cachedir)) {
1941
+			file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>');
1942
+	} else {
1943
+			file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>');
1944
+	}
1840 1945
 
1841 1946
 	return true;
1842 1947
 }
@@ -1853,9 +1958,9 @@  discard block
 block discarded – undo
1853 1958
 	SecFilterScanPOST Off
1854 1959
 </IfModule>';
1855 1960
 
1856
-	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules()))
1857
-		return true;
1858
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1961
+	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) {
1962
+			return true;
1963
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1859 1964
 	{
1860 1965
 		$current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess'));
1861 1966
 
@@ -1867,29 +1972,28 @@  discard block
 block discarded – undo
1867 1972
 				fwrite($ht_handle, $htaccess_addition);
1868 1973
 				fclose($ht_handle);
1869 1974
 				return true;
1975
+			} else {
1976
+							return false;
1870 1977
 			}
1871
-			else
1872
-				return false;
1978
+		} else {
1979
+					return true;
1873 1980
 		}
1874
-		else
1875
-			return true;
1876
-	}
1877
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess'))
1878
-		return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1879
-	elseif (is_writable(dirname(__FILE__)))
1981
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess')) {
1982
+			return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1983
+	} elseif (is_writable(dirname(__FILE__)))
1880 1984
 	{
1881 1985
 		if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w'))
1882 1986
 		{
1883 1987
 			fwrite($ht_handle, $htaccess_addition);
1884 1988
 			fclose($ht_handle);
1885 1989
 			return true;
1990
+		} else {
1991
+					return false;
1886 1992
 		}
1887
-		else
1993
+	} else {
1888 1994
 			return false;
1889 1995
 	}
1890
-	else
1891
-		return false;
1892
-}
1996
+	}
1893 1997
 
1894 1998
 function template_install_above()
1895 1999
 {
@@ -1928,9 +2032,10 @@  discard block
 block discarded – undo
1928 2032
 							<label for="installer_language">', $txt['installer_language'], ':</label>
1929 2033
 							<select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">';
1930 2034
 
1931
-		foreach ($incontext['detected_languages'] as $lang => $name)
1932
-			echo '
2035
+		foreach ($incontext['detected_languages'] as $lang => $name) {
2036
+					echo '
1933 2037
 								<option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>';
2038
+		}
1934 2039
 
1935 2040
 		echo '
1936 2041
 							</select>
@@ -1950,9 +2055,10 @@  discard block
 block discarded – undo
1950 2055
 					<h2>', $txt['upgrade_progress'], '</h2>
1951 2056
 					<ul>';
1952 2057
 
1953
-	foreach ($incontext['steps'] as $num => $step)
1954
-		echo '
2058
+	foreach ($incontext['steps'] as $num => $step) {
2059
+			echo '
1955 2060
 						<li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
2061
+	}
1956 2062
 
1957 2063
 	echo '
1958 2064
 					</ul>
@@ -1977,20 +2083,23 @@  discard block
 block discarded – undo
1977 2083
 		echo '
1978 2084
 							<div class="floatright">';
1979 2085
 
1980
-		if (!empty($incontext['continue']))
1981
-			echo '
2086
+		if (!empty($incontext['continue'])) {
2087
+					echo '
1982 2088
 								<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button">';
1983
-		if (!empty($incontext['skip']))
1984
-			echo '
2089
+		}
2090
+		if (!empty($incontext['skip'])) {
2091
+					echo '
1985 2092
 								<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button">';
2093
+		}
1986 2094
 		echo '
1987 2095
 							</div>';
1988 2096
 	}
1989 2097
 
1990 2098
 	// Show the closing form tag and other data only if not in the last step
1991
-	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step'])
1992
-		echo '
2099
+	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) {
2100
+			echo '
1993 2101
 						</form>';
2102
+	}
1994 2103
 
1995 2104
 	echo '
1996 2105
 					</div><!-- .panel -->
@@ -2026,13 +2135,15 @@  discard block
 block discarded – undo
2026 2135
 		</div>';
2027 2136
 
2028 2137
 	// Show the warnings, or not.
2029
-	if (template_warning_divs())
2030
-		echo '
2138
+	if (template_warning_divs()) {
2139
+			echo '
2031 2140
 		<h3>', $txt['install_all_lovely'], '</h3>';
2141
+	}
2032 2142
 
2033 2143
 	// Say we want the continue button!
2034
-	if (empty($incontext['error']))
2035
-		$incontext['continue'] = 1;
2144
+	if (empty($incontext['error'])) {
2145
+			$incontext['continue'] = 1;
2146
+	}
2036 2147
 
2037 2148
 	// For the latest version stuff.
2038 2149
 	echo '
@@ -2066,8 +2177,8 @@  discard block
 block discarded – undo
2066 2177
 	global $txt, $incontext;
2067 2178
 
2068 2179
 	// Errors are very serious..
2069
-	if (!empty($incontext['error']))
2070
-		echo '
2180
+	if (!empty($incontext['error'])) {
2181
+			echo '
2071 2182
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
2072 2183
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
2073 2184
 			<strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br>
@@ -2075,9 +2186,10 @@  discard block
 block discarded – undo
2075 2186
 				', $incontext['error'], '
2076 2187
 			</div>
2077 2188
 		</div>';
2189
+	}
2078 2190
 	// A warning message?
2079
-	elseif (!empty($incontext['warning']))
2080
-		echo '
2191
+	elseif (!empty($incontext['warning'])) {
2192
+			echo '
2081 2193
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
2082 2194
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
2083 2195
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -2085,6 +2197,7 @@  discard block
 block discarded – undo
2085 2197
 				', $incontext['warning'], '
2086 2198
 			</div>
2087 2199
 		</div>';
2200
+	}
2088 2201
 
2089 2202
 	return empty($incontext['error']) && empty($incontext['warning']);
2090 2203
 }
@@ -2100,27 +2213,30 @@  discard block
 block discarded – undo
2100 2213
 			<li>', $incontext['failed_files']), '</li>
2101 2214
 		</ul>';
2102 2215
 
2103
-	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux')
2104
-		echo '
2216
+	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') {
2217
+			echo '
2105 2218
 		<hr>
2106 2219
 		<p>', $txt['chmod_linux_info'], '</p>
2107 2220
 		<tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>';
2221
+	}
2108 2222
 
2109 2223
 	// This is serious!
2110
-	if (!template_warning_divs())
2111
-		return;
2224
+	if (!template_warning_divs()) {
2225
+			return;
2226
+	}
2112 2227
 
2113 2228
 	echo '
2114 2229
 		<hr>
2115 2230
 		<p>', $txt['ftp_setup_info'], '</p>';
2116 2231
 
2117
-	if (!empty($incontext['ftp_errors']))
2118
-		echo '
2232
+	if (!empty($incontext['ftp_errors'])) {
2233
+			echo '
2119 2234
 		<div class="error_message">
2120 2235
 			', $txt['error_ftp_no_connect'], '<br><br>
2121 2236
 			<code>', implode('<br>', $incontext['ftp_errors']), '</code>
2122 2237
 		</div>
2123 2238
 		<br>';
2239
+	}
2124 2240
 
2125 2241
 	echo '
2126 2242
 		<form action="', $incontext['form_url'], '" method="post">
@@ -2182,17 +2298,17 @@  discard block
 block discarded – undo
2182 2298
 				<td>
2183 2299
 					<select name="db_type" id="db_type_input" onchange="toggleDBInput();">';
2184 2300
 
2185
-	foreach ($incontext['supported_databases'] as $key => $db)
2186
-			echo '
2301
+	foreach ($incontext['supported_databases'] as $key => $db) {
2302
+				echo '
2187 2303
 						<option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>';
2304
+	}
2188 2305
 
2189 2306
 	echo '
2190 2307
 					</select>
2191 2308
 					<div class="smalltext block">', $txt['db_settings_type_info'], '</div>
2192 2309
 				</td>
2193 2310
 			</tr>';
2194
-	}
2195
-	else
2311
+	} else
2196 2312
 	{
2197 2313
 		echo '
2198 2314
 			<tr style="display: none;">
@@ -2385,9 +2501,10 @@  discard block
 block discarded – undo
2385 2501
 		<div style="color: red;">', $txt['error_db_queries'], '</div>
2386 2502
 		<ul>';
2387 2503
 
2388
-		foreach ($incontext['failures'] as $line => $fail)
2389
-			echo '
2504
+		foreach ($incontext['failures'] as $line => $fail) {
2505
+					echo '
2390 2506
 			<li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>';
2507
+		}
2391 2508
 
2392 2509
 		echo '
2393 2510
 		</ul>';
@@ -2448,15 +2565,16 @@  discard block
 block discarded – undo
2448 2565
 			</tr>
2449 2566
 		</table>';
2450 2567
 
2451
-	if ($incontext['require_db_confirm'])
2452
-		echo '
2568
+	if ($incontext['require_db_confirm']) {
2569
+			echo '
2453 2570
 		<h2>', $txt['user_settings_database'], '</h2>
2454 2571
 		<p>', $txt['user_settings_database_info'], '</p>
2455 2572
 
2456 2573
 		<div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;">
2457 2574
 			<input type="password" name="password3" size="30">
2458 2575
 		</div>';
2459
-}
2576
+	}
2577
+	}
2460 2578
 
2461 2579
 // Tell them it's done, and to delete.
2462 2580
 function template_delete_install()
@@ -2469,14 +2587,15 @@  discard block
 block discarded – undo
2469 2587
 	template_warning_divs();
2470 2588
 
2471 2589
 	// Install directory still writable?
2472
-	if ($incontext['dir_still_writable'])
2473
-		echo '
2590
+	if ($incontext['dir_still_writable']) {
2591
+			echo '
2474 2592
 		<em>', $txt['still_writable'], '</em><br>
2475 2593
 		<br>';
2594
+	}
2476 2595
 
2477 2596
 	// Don't show the box if it's like 99% sure it won't work :P.
2478
-	if ($incontext['probably_delete_install'])
2479
-		echo '
2597
+	if ($incontext['probably_delete_install']) {
2598
+			echo '
2480 2599
 		<div style="margin: 1ex; font-weight: bold;">
2481 2600
 			<label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();"> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label>
2482 2601
 		</div>
@@ -2492,6 +2611,7 @@  discard block
 block discarded – undo
2492 2611
 			}
2493 2612
 		</script>
2494 2613
 		<br>';
2614
+	}
2495 2615
 
2496 2616
 	echo '
2497 2617
 		', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br>
Please login to merge, or discard this patch.
other/upgrade.php 2 patches
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -1758,7 +1758,7 @@  discard block
 block discarded – undo
1758 1758
 
1759 1759
 	// Our custom error handler - does nothing but does stop public errors from XML!
1760 1760
 	set_error_handler(
1761
-		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1761
+		function($errno, $errstr, $errfile, $errline) use ($support_js)
1762 1762
 		{
1763 1763
 			if ($support_js)
1764 1764
 				return true;
@@ -2757,94 +2757,94 @@  discard block
 block discarded – undo
2757 2757
 		// Translation table for the character sets not native for MySQL.
2758 2758
 		$translation_tables = array(
2759 2759
 			'windows-1255' => array(
2760
-				'0x81' => '\'\'',		'0x8A' => '\'\'',		'0x8C' => '\'\'',
2761
-				'0x8D' => '\'\'',		'0x8E' => '\'\'',		'0x8F' => '\'\'',
2762
-				'0x90' => '\'\'',		'0x9A' => '\'\'',		'0x9C' => '\'\'',
2763
-				'0x9D' => '\'\'',		'0x9E' => '\'\'',		'0x9F' => '\'\'',
2764
-				'0xCA' => '\'\'',		'0xD9' => '\'\'',		'0xDA' => '\'\'',
2765
-				'0xDB' => '\'\'',		'0xDC' => '\'\'',		'0xDD' => '\'\'',
2766
-				'0xDE' => '\'\'',		'0xDF' => '\'\'',		'0xFB' => '0xD792',
2767
-				'0xFC' => '0xE282AC',		'0xFF' => '0xD6B2',		'0xC2' => '0xFF',
2768
-				'0x80' => '0xFC',		'0xE2' => '0xFB',		'0xA0' => '0xC2A0',
2769
-				'0xA1' => '0xC2A1',		'0xA2' => '0xC2A2',		'0xA3' => '0xC2A3',
2770
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
2771
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
2772
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
2773
-				'0xAF' => '0xC2AF',		'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',
2774
-				'0xB2' => '0xC2B2',		'0xB3' => '0xC2B3',		'0xB4' => '0xC2B4',
2775
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
2776
-				'0xB8' => '0xC2B8',		'0xB9' => '0xC2B9',		'0xBB' => '0xC2BB',
2777
-				'0xBC' => '0xC2BC',		'0xBD' => '0xC2BD',		'0xBE' => '0xC2BE',
2778
-				'0xBF' => '0xC2BF',		'0xD7' => '0xD7B3',		'0xD1' => '0xD781',
2779
-				'0xD4' => '0xD7B0',		'0xD5' => '0xD7B1',		'0xD6' => '0xD7B2',
2780
-				'0xE0' => '0xD790',		'0xEA' => '0xD79A',		'0xEC' => '0xD79C',
2781
-				'0xED' => '0xD79D',		'0xEE' => '0xD79E',		'0xEF' => '0xD79F',
2782
-				'0xF0' => '0xD7A0',		'0xF1' => '0xD7A1',		'0xF2' => '0xD7A2',
2783
-				'0xF3' => '0xD7A3',		'0xF5' => '0xD7A5',		'0xF6' => '0xD7A6',
2784
-				'0xF7' => '0xD7A7',		'0xF8' => '0xD7A8',		'0xF9' => '0xD7A9',
2785
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
2786
-				'0x86' => '0xE280A0',	'0x87' => '0xE280A1',	'0x89' => '0xE280B0',
2787
-				'0x8B' => '0xE280B9',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
2788
-				'0x95' => '0xE280A2',	'0x97' => '0xE28094',	'0x99' => '0xE284A2',
2789
-				'0xC0' => '0xD6B0',		'0xC1' => '0xD6B1',		'0xC3' => '0xD6B3',
2790
-				'0xC4' => '0xD6B4',		'0xC5' => '0xD6B5',		'0xC6' => '0xD6B6',
2791
-				'0xC7' => '0xD6B7',		'0xC8' => '0xD6B8',		'0xC9' => '0xD6B9',
2792
-				'0xCB' => '0xD6BB',		'0xCC' => '0xD6BC',		'0xCD' => '0xD6BD',
2793
-				'0xCE' => '0xD6BE',		'0xCF' => '0xD6BF',		'0xD0' => '0xD780',
2794
-				'0xD2' => '0xD782',		'0xE3' => '0xD793',		'0xE4' => '0xD794',
2795
-				'0xE5' => '0xD795',		'0xE7' => '0xD797',		'0xE9' => '0xD799',
2796
-				'0xFD' => '0xE2808E',	'0xFE' => '0xE2808F',	'0x92' => '0xE28099',
2797
-				'0x83' => '0xC692',		'0xD3' => '0xD783',		'0x88' => '0xCB86',
2798
-				'0x98' => '0xCB9C',		'0x91' => '0xE28098',	'0x96' => '0xE28093',
2799
-				'0xBA' => '0xC3B7',		'0x9B' => '0xE280BA',	'0xAA' => '0xC397',
2800
-				'0xA4' => '0xE282AA',	'0xE1' => '0xD791',		'0xE6' => '0xD796',
2801
-				'0xE8' => '0xD798',		'0xEB' => '0xD79B',		'0xF4' => '0xD7A4',
2760
+				'0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'',
2761
+				'0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'',
2762
+				'0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'',
2763
+				'0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'',
2764
+				'0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'',
2765
+				'0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'',
2766
+				'0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792',
2767
+				'0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF',
2768
+				'0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0',
2769
+				'0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3',
2770
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
2771
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
2772
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
2773
+				'0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1',
2774
+				'0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4',
2775
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
2776
+				'0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB',
2777
+				'0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE',
2778
+				'0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781',
2779
+				'0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2',
2780
+				'0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C',
2781
+				'0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F',
2782
+				'0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2',
2783
+				'0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6',
2784
+				'0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9',
2785
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
2786
+				'0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0',
2787
+				'0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
2788
+				'0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2',
2789
+				'0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3',
2790
+				'0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6',
2791
+				'0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9',
2792
+				'0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD',
2793
+				'0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780',
2794
+				'0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794',
2795
+				'0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799',
2796
+				'0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099',
2797
+				'0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86',
2798
+				'0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093',
2799
+				'0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397',
2800
+				'0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796',
2801
+				'0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4',
2802 2802
 				'0xFA' => '0xD7AA',
2803 2803
 			),
2804 2804
 			'windows-1253' => array(
2805
-				'0x81' => '\'\'',			'0x88' => '\'\'',			'0x8A' => '\'\'',
2806
-				'0x8C' => '\'\'',			'0x8D' => '\'\'',			'0x8E' => '\'\'',
2807
-				'0x8F' => '\'\'',			'0x90' => '\'\'',			'0x98' => '\'\'',
2808
-				'0x9A' => '\'\'',			'0x9C' => '\'\'',			'0x9D' => '\'\'',
2809
-				'0x9E' => '\'\'',			'0x9F' => '\'\'',			'0xAA' => '\'\'',
2810
-				'0xD2' => '0xE282AC',			'0xFF' => '0xCE92',			'0xCE' => '0xCE9E',
2811
-				'0xB8' => '0xCE88',		'0xBA' => '0xCE8A',		'0xBC' => '0xCE8C',
2812
-				'0xBE' => '0xCE8E',		'0xBF' => '0xCE8F',		'0xC0' => '0xCE90',
2813
-				'0xC8' => '0xCE98',		'0xCA' => '0xCE9A',		'0xCC' => '0xCE9C',
2814
-				'0xCD' => '0xCE9D',		'0xCF' => '0xCE9F',		'0xDA' => '0xCEAA',
2815
-				'0xE8' => '0xCEB8',		'0xEA' => '0xCEBA',		'0xEC' => '0xCEBC',
2816
-				'0xEE' => '0xCEBE',		'0xEF' => '0xCEBF',		'0xC2' => '0xFF',
2817
-				'0xBD' => '0xC2BD',		'0xED' => '0xCEBD',		'0xB2' => '0xC2B2',
2818
-				'0xA0' => '0xC2A0',		'0xA3' => '0xC2A3',		'0xA4' => '0xC2A4',
2819
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
2820
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
2821
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
2822
-				'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',		'0xB3' => '0xC2B3',
2823
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
2824
-				'0xBB' => '0xC2BB',		'0xE2' => '0xCEB2',		'0x80' => '0xD2',
2825
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
2826
-				'0x86' => '0xE280A0',	'0xA1' => '0xCE85',		'0xA2' => '0xCE86',
2827
-				'0x87' => '0xE280A1',	'0x89' => '0xE280B0',	'0xB9' => '0xCE89',
2828
-				'0x8B' => '0xE280B9',	'0x91' => '0xE28098',	'0x99' => '0xE284A2',
2829
-				'0x92' => '0xE28099',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
2830
-				'0x95' => '0xE280A2',	'0x96' => '0xE28093',	'0x97' => '0xE28094',
2831
-				'0x9B' => '0xE280BA',	'0xAF' => '0xE28095',	'0xB4' => '0xCE84',
2832
-				'0xC1' => '0xCE91',		'0xC3' => '0xCE93',		'0xC4' => '0xCE94',
2833
-				'0xC5' => '0xCE95',		'0xC6' => '0xCE96',		'0x83' => '0xC692',
2834
-				'0xC7' => '0xCE97',		'0xC9' => '0xCE99',		'0xCB' => '0xCE9B',
2835
-				'0xD0' => '0xCEA0',		'0xD1' => '0xCEA1',		'0xD3' => '0xCEA3',
2836
-				'0xD4' => '0xCEA4',		'0xD5' => '0xCEA5',		'0xD6' => '0xCEA6',
2837
-				'0xD7' => '0xCEA7',		'0xD8' => '0xCEA8',		'0xD9' => '0xCEA9',
2838
-				'0xDB' => '0xCEAB',		'0xDC' => '0xCEAC',		'0xDD' => '0xCEAD',
2839
-				'0xDE' => '0xCEAE',		'0xDF' => '0xCEAF',		'0xE0' => '0xCEB0',
2840
-				'0xE1' => '0xCEB1',		'0xE3' => '0xCEB3',		'0xE4' => '0xCEB4',
2841
-				'0xE5' => '0xCEB5',		'0xE6' => '0xCEB6',		'0xE7' => '0xCEB7',
2842
-				'0xE9' => '0xCEB9',		'0xEB' => '0xCEBB',		'0xF0' => '0xCF80',
2843
-				'0xF1' => '0xCF81',		'0xF2' => '0xCF82',		'0xF3' => '0xCF83',
2844
-				'0xF4' => '0xCF84',		'0xF5' => '0xCF85',		'0xF6' => '0xCF86',
2845
-				'0xF7' => '0xCF87',		'0xF8' => '0xCF88',		'0xF9' => '0xCF89',
2846
-				'0xFA' => '0xCF8A',		'0xFB' => '0xCF8B',		'0xFC' => '0xCF8C',
2847
-				'0xFD' => '0xCF8D',		'0xFE' => '0xCF8E',
2805
+				'0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'',
2806
+				'0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'',
2807
+				'0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'',
2808
+				'0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'',
2809
+				'0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'',
2810
+				'0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E',
2811
+				'0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C',
2812
+				'0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90',
2813
+				'0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C',
2814
+				'0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA',
2815
+				'0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC',
2816
+				'0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF',
2817
+				'0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2',
2818
+				'0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4',
2819
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
2820
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
2821
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
2822
+				'0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3',
2823
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
2824
+				'0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2',
2825
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
2826
+				'0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86',
2827
+				'0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89',
2828
+				'0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2',
2829
+				'0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
2830
+				'0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094',
2831
+				'0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84',
2832
+				'0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94',
2833
+				'0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692',
2834
+				'0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B',
2835
+				'0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3',
2836
+				'0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6',
2837
+				'0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9',
2838
+				'0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD',
2839
+				'0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0',
2840
+				'0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4',
2841
+				'0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7',
2842
+				'0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80',
2843
+				'0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83',
2844
+				'0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86',
2845
+				'0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89',
2846
+				'0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C',
2847
+				'0xFD' => '0xCF8D', '0xFE' => '0xCF8E',
2848 2848
 			),
2849 2849
 		);
2850 2850
 
@@ -3785,7 +3785,7 @@  discard block
 block discarded – undo
3785 3785
 
3786 3786
 		if ($active < 600)
3787 3787
 			echo '
3788
-						', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], '';
3788
+						', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'], ' ', $txt['upgrade_run_script2'], '';
3789 3789
 
3790 3790
 		if ($active > $upcontext['inactive_timeout'])
3791 3791
 			echo '
@@ -3988,7 +3988,7 @@  discard block
 block discarded – undo
3988 3988
 				<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
3989 3989
 					<input type="hidden" name="backup_done" id="backup_done" value="0">
3990 3990
 					<strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong>
3991
-					<div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;">
3991
+					<div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;">
3992 3992
 						<span id="debuginfo"></span>
3993 3993
 					</div>';
3994 3994
 
@@ -4492,7 +4492,7 @@  discard block
 block discarded – undo
4492 4492
 				<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
4493 4493
 					<input type="hidden" name="utf8_done" id="utf8_done" value="0">
4494 4494
 					<strong>', $txt['upgrade_completed'], ' <span id="tab_done">', $upcontext['cur_table_num'], '</span> ', $txt['upgrade_outof'], ' ', $upcontext['table_count'], ' ', $txt['upgrade_tables'], '</strong>
4495
-					<div id="debug_section" style="height: ', ($is_debug ? '97' : '12') , 'px; overflow: auto;">
4495
+					<div id="debug_section" style="height: ', ($is_debug ? '97' : '12'), 'px; overflow: auto;">
4496 4496
 						<span id="debuginfo"></span>
4497 4497
 					</div>';
4498 4498
 
@@ -4591,7 +4591,7 @@  discard block
 block discarded – undo
4591 4591
 				<form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post">
4592 4592
 					<input type="hidden" name="json_done" id="json_done" value="0">
4593 4593
 					<strong>', $txt['upgrade_completed'], ' <span id="tab_done">', $upcontext['cur_table_num'], '</span> ', $txt['upgrade_outof'], ' ', $upcontext['table_count'], ' ', $txt['upgrade_tables'], '</strong>
4594
-					<div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;">
4594
+					<div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;">
4595 4595
 						<span id="debuginfo"></span>
4596 4596
 					</div>';
4597 4597
 
Please login to merge, or discard this patch.
Braces   +908 added lines, -665 removed lines patch added patch discarded remove patch
@@ -75,8 +75,9 @@  discard block
 block discarded – undo
75 75
 $upcontext['inactive_timeout'] = 10;
76 76
 
77 77
 // The helper is crucial. Include it first thing.
78
-if (!file_exists($upgrade_path . '/upgrade-helper.php'))
78
+if (!file_exists($upgrade_path . '/upgrade-helper.php')) {
79 79
 	die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.');
80
+}
80 81
 
81 82
 require_once($upgrade_path . '/upgrade-helper.php');
82 83
 
@@ -107,11 +108,14 @@  discard block
 block discarded – undo
107 108
 	ini_set('default_socket_timeout', 900);
108 109
 }
109 110
 // Clean the upgrade path if this is from the client.
110
-if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']))
111
-	for ($i = 1; $i < $_SERVER['argc']; $i++)
111
+if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
112
+	for ($i = 1;
113
+}
114
+$i < $_SERVER['argc']; $i++)
112 115
 	{
113
-		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0)
114
-			$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
116
+		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) {
117
+					$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
118
+		}
115 119
 	}
116 120
 
117 121
 // Are we from the client?
@@ -119,16 +123,17 @@  discard block
 block discarded – undo
119 123
 {
120 124
 	$command_line = true;
121 125
 	$disable_security = true;
122
-}
123
-else
126
+} else {
124 127
 	$command_line = false;
128
+}
125 129
 
126 130
 // Load this now just because we can.
127 131
 require_once($upgrade_path . '/Settings.php');
128 132
 
129 133
 // We don't use "-utf8" anymore...  Tweak the entry that may have been loaded by Settings.php
130
-if (isset($language))
134
+if (isset($language)) {
131 135
 	$language = str_ireplace('-utf8', '', $language);
136
+}
132 137
 
133 138
 // Are we logged in?
134 139
 if (isset($upgradeData))
@@ -136,10 +141,12 @@  discard block
 block discarded – undo
136 141
 	$upcontext['user'] = json_decode(base64_decode($upgradeData), true);
137 142
 
138 143
 	// Check for sensible values.
139
-	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400)
140
-		$upcontext['user']['started'] = time();
141
-	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400)
142
-		$upcontext['user']['updated'] = 0;
144
+	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) {
145
+			$upcontext['user']['started'] = time();
146
+	}
147
+	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) {
148
+			$upcontext['user']['updated'] = 0;
149
+	}
143 150
 
144 151
 	$upcontext['started'] = $upcontext['user']['started'];
145 152
 	$upcontext['updated'] = $upcontext['user']['updated'];
@@ -204,8 +211,9 @@  discard block
 block discarded – undo
204 211
 			'db_error_skip' => true,
205 212
 		)
206 213
 	);
207
-	while ($row = $smcFunc['db_fetch_assoc']($request))
208
-		$modSettings[$row['variable']] = $row['value'];
214
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
215
+			$modSettings[$row['variable']] = $row['value'];
216
+	}
209 217
 	$smcFunc['db_free_result']($request);
210 218
 }
211 219
 
@@ -215,14 +223,17 @@  discard block
 block discarded – undo
215 223
 	$modSettings['theme_url'] = 'Themes/default';
216 224
 	$modSettings['images_url'] = 'Themes/default/images';
217 225
 }
218
-if (!isset($settings['default_theme_url']))
226
+if (!isset($settings['default_theme_url'])) {
219 227
 	$settings['default_theme_url'] = $modSettings['theme_url'];
220
-if (!isset($settings['default_theme_dir']))
228
+}
229
+if (!isset($settings['default_theme_dir'])) {
221 230
 	$settings['default_theme_dir'] = $modSettings['theme_dir'];
231
+}
222 232
 
223 233
 // This is needed in case someone invokes the upgrader using https when upgrading an http forum
224
-if (httpsOn())
234
+if (httpsOn()) {
225 235
 	$settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://'));
236
+}
226 237
 
227 238
 $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000;
228 239
 // Default title...
@@ -240,13 +251,15 @@  discard block
 block discarded – undo
240 251
 	$support_js = $upcontext['upgrade_status']['js'];
241 252
 
242 253
 	// Only set this if the upgrader status says so.
243
-	if (empty($is_debug))
244
-		$is_debug = $upcontext['upgrade_status']['debug'];
254
+	if (empty($is_debug)) {
255
+			$is_debug = $upcontext['upgrade_status']['debug'];
256
+	}
245 257
 
246 258
 	// Load the language.
247
-	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
248
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
249
-}
259
+	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
260
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
261
+	}
262
+	}
250 263
 // Set the defaults.
251 264
 else
252 265
 {
@@ -264,15 +277,18 @@  discard block
 block discarded – undo
264 277
 }
265 278
 
266 279
 // If this isn't the first stage see whether they are logging in and resuming.
267
-if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step']))
280
+if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) {
268 281
 	checkLogin();
282
+}
269 283
 
270
-if ($command_line)
284
+if ($command_line) {
271 285
 	cmdStep0();
286
+}
272 287
 
273 288
 // Don't error if we're using xml.
274
-if (isset($_GET['xml']))
289
+if (isset($_GET['xml'])) {
275 290
 	$upcontext['return_error'] = true;
291
+}
276 292
 
277 293
 // Loop through all the steps doing each one as required.
278 294
 $upcontext['overall_percent'] = 0;
@@ -293,9 +309,9 @@  discard block
 block discarded – undo
293 309
 		}
294 310
 
295 311
 		// Call the step and if it returns false that means pause!
296
-		if (function_exists($step[2]) && $step[2]() === false)
297
-			break;
298
-		elseif (function_exists($step[2])) {
312
+		if (function_exists($step[2]) && $step[2]() === false) {
313
+					break;
314
+		} elseif (function_exists($step[2])) {
299 315
 			//Start each new step with this unset, so the 'normal' template is called first
300 316
 			unset($_GET['xml']);
301 317
 			//Clear out warnings at the start of each step
@@ -341,17 +357,18 @@  discard block
 block discarded – undo
341 357
 		// This should not happen my dear... HELP ME DEVELOPERS!!
342 358
 		if (!empty($command_line))
343 359
 		{
344
-			if (function_exists('debug_print_backtrace'))
345
-				debug_print_backtrace();
360
+			if (function_exists('debug_print_backtrace')) {
361
+							debug_print_backtrace();
362
+			}
346 363
 
347 364
 			echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.';
348 365
 			flush();
349 366
 			die();
350 367
 		}
351 368
 
352
-		if (!isset($_GET['xml']))
353
-			template_upgrade_above();
354
-		else
369
+		if (!isset($_GET['xml'])) {
370
+					template_upgrade_above();
371
+		} else
355 372
 		{
356 373
 			header('content-type: text/xml; charset=UTF-8');
357 374
 			// Sadly we need to retain the $_GET data thanks to the old upgrade scripts.
@@ -373,25 +390,29 @@  discard block
 block discarded – undo
373 390
 			$upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&amp;substep=' . $_GET['substep'] . '&amp;data=' . base64_encode(json_encode($upcontext['upgrade_status']));
374 391
 
375 392
 			// Custom stuff to pass back?
376
-			if (!empty($upcontext['query_string']))
377
-				$upcontext['form_url'] .= $upcontext['query_string'];
393
+			if (!empty($upcontext['query_string'])) {
394
+							$upcontext['form_url'] .= $upcontext['query_string'];
395
+			}
378 396
 
379 397
 			// Call the appropriate subtemplate
380
-			if (is_callable('template_' . $upcontext['sub_template']))
381
-				call_user_func('template_' . $upcontext['sub_template']);
382
-			else
383
-				die('Upgrade aborted!  Invalid template: template_' . $upcontext['sub_template']);
398
+			if (is_callable('template_' . $upcontext['sub_template'])) {
399
+							call_user_func('template_' . $upcontext['sub_template']);
400
+			} else {
401
+							die('Upgrade aborted!  Invalid template: template_' . $upcontext['sub_template']);
402
+			}
384 403
 		}
385 404
 
386 405
 		// Was there an error?
387
-		if (!empty($upcontext['forced_error_message']))
388
-			echo $upcontext['forced_error_message'];
406
+		if (!empty($upcontext['forced_error_message'])) {
407
+					echo $upcontext['forced_error_message'];
408
+		}
389 409
 
390 410
 		// Show the footer.
391
-		if (!isset($_GET['xml']))
392
-			template_upgrade_below();
393
-		else
394
-			template_xml_below();
411
+		if (!isset($_GET['xml'])) {
412
+					template_upgrade_below();
413
+		} else {
414
+					template_xml_below();
415
+		}
395 416
 	}
396 417
 
397 418
 
@@ -403,15 +424,19 @@  discard block
 block discarded – undo
403 424
 		$seconds = intval($active % 60);
404 425
 
405 426
 		$totalTime = '';
406
-		if ($hours > 0)
407
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
408
-		if ($minutes > 0)
409
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
410
-		if ($seconds > 0)
411
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
427
+		if ($hours > 0) {
428
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
429
+		}
430
+		if ($minutes > 0) {
431
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
432
+		}
433
+		if ($seconds > 0) {
434
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
435
+		}
412 436
 
413
-		if (!empty($totalTime))
414
-			echo "\n" . '', $txt['upgrade_completed_time'], ' ' . $totalTime . "\n";
437
+		if (!empty($totalTime)) {
438
+					echo "\n" . '', $txt['upgrade_completed_time'], ' ' . $totalTime . "\n";
439
+		}
415 440
 	}
416 441
 
417 442
 	// Bang - gone!
@@ -432,8 +457,9 @@  discard block
 block discarded – undo
432 457
 		$dir = dir(dirname(__FILE__) . '/Themes/default/languages');
433 458
 		while ($entry = $dir->read())
434 459
 		{
435
-			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php')
436
-				$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
460
+			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') {
461
+							$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
462
+			}
437 463
 		}
438 464
 		$dir->close();
439 465
 	}
@@ -468,10 +494,11 @@  discard block
 block discarded – undo
468 494
 	}
469 495
 
470 496
 	// Override the language file?
471
-	if (isset($_GET['lang_file']))
472
-		$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
473
-	elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file']))
474
-		$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
497
+	if (isset($_GET['lang_file'])) {
498
+			$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
499
+	} elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) {
500
+			$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
501
+	}
475 502
 
476 503
 	// Make sure it exists, if it doesn't reset it.
477 504
 	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']))
@@ -480,12 +507,14 @@  discard block
 block discarded – undo
480 507
 		list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
481 508
 
482 509
 		// If we have english and some other language, use the other language.  We Americans hate english :P.
483
-		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1)
484
-			list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
510
+		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) {
511
+					list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
512
+		}
485 513
 
486 514
 		// For backup we load the english at first -> second language overwrite the english one
487
-		if (count($incontext['detected_languages']) > 1)
488
-			require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php');
515
+		if (count($incontext['detected_languages']) > 1) {
516
+					require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php');
517
+		}
489 518
 	}
490 519
 
491 520
 	// And now include the actual language file itself.
@@ -493,11 +522,12 @@  discard block
 block discarded – undo
493 522
 
494 523
 	// Which language did we load? Assume that he likes his language.
495 524
 	preg_match('~^Install\.(.+[^-utf8])\.php$~', $_SESSION['installer_temp_lang'], $matches);
496
-	if (empty($matches[1]))
497
-		$matches = [
525
+	if (empty($matches[1])) {
526
+			$matches = [
498 527
 			0 => 'nothing',
499 528
 			1 => 'english',
500 529
 		];
530
+	}
501 531
 	$user_info['language'] = $matches[1];
502 532
 }
503 533
 
@@ -507,8 +537,9 @@  discard block
 block discarded – undo
507 537
 	global $upgradeurl, $upcontext, $command_line;
508 538
 
509 539
 	// Command line users can't be redirected.
510
-	if ($command_line)
511
-		upgradeExit(true);
540
+	if ($command_line) {
541
+			upgradeExit(true);
542
+	}
512 543
 
513 544
 	// Are we providing the core info?
514 545
 	if ($addForm)
@@ -534,12 +565,14 @@  discard block
 block discarded – undo
534 565
 	define('SMF', 1);
535 566
 
536 567
 	// Start the session.
537
-	if (@ini_get('session.save_handler') == 'user')
538
-		@ini_set('session.save_handler', 'files');
568
+	if (@ini_get('session.save_handler') == 'user') {
569
+			@ini_set('session.save_handler', 'files');
570
+	}
539 571
 	@session_start();
540 572
 
541
-	if (empty($smcFunc))
542
-		$smcFunc = array();
573
+	if (empty($smcFunc)) {
574
+			$smcFunc = array();
575
+	}
543 576
 
544 577
 	// We need this for authentication and some upgrade code
545 578
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -566,24 +599,27 @@  discard block
 block discarded – undo
566 599
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
567 600
 
568 601
 		// Make the connection...
569
-		if (empty($db_connection))
570
-			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
571
-		else
572
-			// If we've returned here, ping/reconnect to be safe
602
+		if (empty($db_connection)) {
603
+					$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
604
+		} else {
605
+					// If we've returned here, ping/reconnect to be safe
573 606
 			$smcFunc['db_ping']($db_connection);
607
+		}
574 608
 
575 609
 		// Oh dear god!!
576
-		if ($db_connection === null)
577
-			die('Unable to connect to database - please check username and password are correct in Settings.php');
610
+		if ($db_connection === null) {
611
+					die('Unable to connect to database - please check username and password are correct in Settings.php');
612
+		}
578 613
 
579
-		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1)
580
-			$smcFunc['db_query']('', '
614
+		if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) {
615
+					$smcFunc['db_query']('', '
581 616
 			SET NAMES {string:db_character_set}',
582 617
 			array(
583 618
 				'db_error_skip' => true,
584 619
 				'db_character_set' => $db_character_set,
585 620
 			)
586 621
 		);
622
+		}
587 623
 
588 624
 		// Load the modSettings data...
589 625
 		$request = $smcFunc['db_query']('', '
@@ -594,11 +630,11 @@  discard block
 block discarded – undo
594 630
 			)
595 631
 		);
596 632
 		$modSettings = array();
597
-		while ($row = $smcFunc['db_fetch_assoc']($request))
598
-			$modSettings[$row['variable']] = $row['value'];
633
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
634
+					$modSettings[$row['variable']] = $row['value'];
635
+		}
599 636
 		$smcFunc['db_free_result']($request);
600
-	}
601
-	else
637
+	} else
602 638
 	{
603 639
 		return throw_error('Cannot find ' . $sourcedir . '/Subs-Db-' . $db_type . '.php' . '. Please check you have uploaded all source files and have the correct paths set.');
604 640
 	}
@@ -612,9 +648,10 @@  discard block
 block discarded – undo
612 648
 		cleanRequest();
613 649
 	}
614 650
 
615
-	if (!isset($_GET['substep']))
616
-		$_GET['substep'] = 0;
617
-}
651
+	if (!isset($_GET['substep'])) {
652
+			$_GET['substep'] = 0;
653
+	}
654
+	}
618 655
 
619 656
 function initialize_inputs()
620 657
 {
@@ -644,8 +681,9 @@  discard block
 block discarded – undo
644 681
 		$dh = opendir(dirname(__FILE__));
645 682
 		while ($file = readdir($dh))
646 683
 		{
647
-			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1]))
648
-				@unlink(dirname(__FILE__) . '/' . $file);
684
+			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) {
685
+							@unlink(dirname(__FILE__) . '/' . $file);
686
+			}
649 687
 		}
650 688
 		closedir($dh);
651 689
 
@@ -674,8 +712,9 @@  discard block
 block discarded – undo
674 712
 	$temp = 'upgrade_php?step';
675 713
 	while (strlen($temp) > 4)
676 714
 	{
677
-		if (isset($_GET[$temp]))
678
-			unset($_GET[$temp]);
715
+		if (isset($_GET[$temp])) {
716
+					unset($_GET[$temp]);
717
+		}
679 718
 		$temp = substr($temp, 1);
680 719
 	}
681 720
 
@@ -702,32 +741,39 @@  discard block
 block discarded – undo
702 741
 		&& @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql');
703 742
 
704 743
 	// Need legacy scripts?
705
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1)
706
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
707
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0)
708
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
709
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1)
710
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
744
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) {
745
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql');
746
+	}
747
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) {
748
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
749
+	}
750
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) {
751
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
752
+	}
711 753
 
712 754
 	// We don't need "-utf8" files anymore...
713 755
 	$upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']);
714 756
 
715 757
 	// This needs to exist!
716
-	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
717
-		return throw_error('The upgrader could not find the &quot;Install&quot; language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br>&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
718
-	else
719
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
758
+	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
759
+			return throw_error('The upgrader could not find the &quot;Install&quot; language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br>&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
760
+	} else {
761
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
762
+	}
720 763
 
721
-	if (!$check)
722
-		// Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb.
764
+	if (!$check) {
765
+			// Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb.
723 766
 		return throw_error('The upgrader was unable to find some crucial files.<br><br>Please make sure you uploaded all of the files included in the package, including the Themes, Sources, and other directories.');
767
+	}
724 768
 
725 769
 	// Do they meet the install requirements?
726
-	if (!php_version_check())
727
-		return throw_error('Warning!  You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.');
770
+	if (!php_version_check()) {
771
+			return throw_error('Warning!  You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.');
772
+	}
728 773
 
729
-	if (!db_version_check())
730
-		return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.');
774
+	if (!db_version_check()) {
775
+			return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.');
776
+	}
731 777
 
732 778
 	// Do some checks to make sure they have proper privileges
733 779
 	db_extend('packages');
@@ -742,14 +788,16 @@  discard block
 block discarded – undo
742 788
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
743 789
 
744 790
 	// Sorry... we need CREATE, ALTER and DROP
745
-	if (!$create || !$alter || !$drop)
746
-		return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.');
791
+	if (!$create || !$alter || !$drop) {
792
+			return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.');
793
+	}
747 794
 
748 795
 	// Do a quick version spot check.
749 796
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
750 797
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
751
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
752
-		return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.');
798
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
799
+			return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.');
800
+	}
753 801
 
754 802
 	// What absolutely needs to be writable?
755 803
 	$writable_files = array(
@@ -758,12 +806,13 @@  discard block
 block discarded – undo
758 806
 	);
759 807
 
760 808
 	// Only check for minified writable files if we have it enabled or not set.
761
-	if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files']))
762
-		$writable_files += array(
809
+	if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) {
810
+			$writable_files += array(
763 811
 			$modSettings['theme_dir'] . '/css/minified.css',
764 812
 			$modSettings['theme_dir'] . '/scripts/minified.js',
765 813
 			$modSettings['theme_dir'] . '/scripts/minified_deferred.js',
766 814
 		);
815
+	}
767 816
 
768 817
 	// Do we need to add this setting?
769 818
 	$need_settings_update = empty($modSettings['custom_avatar_dir']);
@@ -775,12 +824,13 @@  discard block
 block discarded – undo
775 824
 	quickFileWritable($custom_av_dir);
776 825
 
777 826
 	// Are we good now?
778
-	if (!is_writable($custom_av_dir))
779
-		return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir));
780
-	elseif ($need_settings_update)
827
+	if (!is_writable($custom_av_dir)) {
828
+			return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir));
829
+	} elseif ($need_settings_update)
781 830
 	{
782
-		if (!function_exists('cache_put_data'))
783
-			require_once($sourcedir . '/Load.php');
831
+		if (!function_exists('cache_put_data')) {
832
+					require_once($sourcedir . '/Load.php');
833
+		}
784 834
 
785 835
 		updateSettings(array('custom_avatar_dir' => $custom_av_dir));
786 836
 		updateSettings(array('custom_avatar_url' => $custom_av_url));
@@ -790,29 +840,34 @@  discard block
 block discarded – undo
790 840
 
791 841
 	// Check the cache directory.
792 842
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
793
-	if (!file_exists($cachedir_temp))
794
-		@mkdir($cachedir_temp);
843
+	if (!file_exists($cachedir_temp)) {
844
+			@mkdir($cachedir_temp);
845
+	}
795 846
 
796
-	if (!file_exists($cachedir_temp))
797
-		return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called &quot;cache&quot; in your forum directory before continuing.');
847
+	if (!file_exists($cachedir_temp)) {
848
+			return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called &quot;cache&quot; in your forum directory before continuing.');
849
+	}
798 850
 
799
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
800
-		return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.');
801
-	elseif (!isset($_GET['skiplang']))
851
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
852
+			return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.');
853
+	} elseif (!isset($_GET['skiplang']))
802 854
 	{
803 855
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
804 856
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
805 857
 
806
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
807
-			return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br>&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
858
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
859
+					return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br>&nbsp;&nbsp;&nbsp;[<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]');
860
+		}
808 861
 	}
809 862
 
810
-	if (!makeFilesWritable($writable_files))
811
-		return false;
863
+	if (!makeFilesWritable($writable_files)) {
864
+			return false;
865
+	}
812 866
 
813 867
 	// Check agreement.txt. (it may not exist, in which case $boarddir must be writable.)
814
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
815
-		return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.');
868
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
869
+			return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.');
870
+	}
816 871
 
817 872
 	// Upgrade the agreement.
818 873
 	elseif (isset($modSettings['agreement']))
@@ -823,8 +878,8 @@  discard block
 block discarded – undo
823 878
 	}
824 879
 
825 880
 	// We're going to check that their board dir setting is right in case they've been moving stuff around.
826
-	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => '')))
827
-		$upcontext['warning'] = '
881
+	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) {
882
+			$upcontext['warning'] = '
828 883
 			It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to &quot;' . $boarddir . '&quot; but should probably be &quot;' . dirname(__FILE__) . '&quot;. Settings.php currently lists your paths as:<br>
829 884
 			<ul>
830 885
 				<li>Board Directory: ' . $boarddir . '</li>
@@ -832,19 +887,23 @@  discard block
 block discarded – undo
832 887
 				<li>Cache Directory: ' . $cachedir_temp . '</li>
833 888
 			</ul>
834 889
 			If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="https://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.';
890
+	}
835 891
 
836 892
 	// Confirm mbstring is loaded...
837
-	if (!extension_loaded('mbstring'))
838
-		return throw_error($txt['install_no_mbstring']);
893
+	if (!extension_loaded('mbstring')) {
894
+			return throw_error($txt['install_no_mbstring']);
895
+	}
839 896
 
840 897
 	// Check for https stream support.
841 898
 	$supported_streams = stream_get_wrappers();
842
-	if (!in_array('https', $supported_streams))
843
-		$upcontext['custom_warning'] = $txt['install_no_https'];
899
+	if (!in_array('https', $supported_streams)) {
900
+			$upcontext['custom_warning'] = $txt['install_no_https'];
901
+	}
844 902
 
845 903
 	// Either we're logged in or we're going to present the login.
846
-	if (checkLogin())
847
-		return true;
904
+	if (checkLogin()) {
905
+			return true;
906
+	}
848 907
 
849 908
 	$upcontext += createToken('login');
850 909
 
@@ -858,15 +917,17 @@  discard block
 block discarded – undo
858 917
 	global $smcFunc, $db_type, $support_js;
859 918
 
860 919
 	// Don't bother if the security is disabled.
861
-	if ($disable_security)
862
-		return true;
920
+	if ($disable_security) {
921
+			return true;
922
+	}
863 923
 
864 924
 	// Are we trying to login?
865 925
 	if (isset($_POST['contbutt']) && (!empty($_POST['user'])))
866 926
 	{
867 927
 		// If we've disabled security pick a suitable name!
868
-		if (empty($_POST['user']))
869
-			$_POST['user'] = 'Administrator';
928
+		if (empty($_POST['user'])) {
929
+					$_POST['user'] = 'Administrator';
930
+		}
870 931
 
871 932
 		// Before 2.0 these column names were different!
872 933
 		$oldDB = false;
@@ -881,16 +942,17 @@  discard block
 block discarded – undo
881 942
 					'db_error_skip' => true,
882 943
 				)
883 944
 			);
884
-			if ($smcFunc['db_num_rows']($request) != 0)
885
-				$oldDB = true;
945
+			if ($smcFunc['db_num_rows']($request) != 0) {
946
+							$oldDB = true;
947
+			}
886 948
 			$smcFunc['db_free_result']($request);
887 949
 		}
888 950
 
889 951
 		// Get what we believe to be their details.
890 952
 		if (!$disable_security)
891 953
 		{
892
-			if ($oldDB)
893
-				$request = $smcFunc['db_query']('', '
954
+			if ($oldDB) {
955
+							$request = $smcFunc['db_query']('', '
894 956
 					SELECT id_member, memberName AS member_name, passwd, id_group,
895 957
 					additionalGroups AS additional_groups, lngfile
896 958
 					FROM {db_prefix}members
@@ -900,8 +962,8 @@  discard block
 block discarded – undo
900 962
 						'db_error_skip' => true,
901 963
 					)
902 964
 				);
903
-			else
904
-				$request = $smcFunc['db_query']('', '
965
+			} else {
966
+							$request = $smcFunc['db_query']('', '
905 967
 					SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile
906 968
 					FROM {db_prefix}members
907 969
 					WHERE member_name = {string:member_name}',
@@ -910,6 +972,7 @@  discard block
 block discarded – undo
910 972
 						'db_error_skip' => true,
911 973
 					)
912 974
 				);
975
+			}
913 976
 			if ($smcFunc['db_num_rows']($request) != 0)
914 977
 			{
915 978
 				list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request);
@@ -917,16 +980,17 @@  discard block
 block discarded – undo
917 980
 				$groups = explode(',', $addGroups);
918 981
 				$groups[] = $id_group;
919 982
 
920
-				foreach ($groups as $k => $v)
921
-					$groups[$k] = (int) $v;
983
+				foreach ($groups as $k => $v) {
984
+									$groups[$k] = (int) $v;
985
+				}
922 986
 
923 987
 				$sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd']));
924 988
 
925 989
 				// We don't use "-utf8" anymore...
926 990
 				$user_language = str_ireplace('-utf8', '', $user_language);
991
+			} else {
992
+							$upcontext['username_incorrect'] = true;
927 993
 			}
928
-			else
929
-				$upcontext['username_incorrect'] = true;
930 994
 
931 995
 			$smcFunc['db_free_result']($request);
932 996
 		}
@@ -937,13 +1001,14 @@  discard block
 block discarded – undo
937 1001
 		{
938 1002
 			$upcontext['upgrade_status']['js'] = 1;
939 1003
 			$support_js = 1;
1004
+		} else {
1005
+					$support_js = 0;
940 1006
 		}
941
-		else
942
-			$support_js = 0;
943 1007
 
944 1008
 		// Note down the version we are coming from.
945
-		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version']))
946
-			$upcontext['user']['version'] = $modSettings['smfVersion'];
1009
+		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) {
1010
+					$upcontext['user']['version'] = $modSettings['smfVersion'];
1011
+		}
947 1012
 
948 1013
 		// Didn't get anywhere?
949 1014
 		if (!$disable_security && (empty($sha_passwd) || (!empty($password) ? $password : '') != $sha_passwd) && !hash_verify_password((!empty($name) ? $name : ''), $_REQUEST['passwrd'], (!empty($password) ? $password : '')) && empty($upcontext['username_incorrect']))
@@ -977,15 +1042,15 @@  discard block
 block discarded – undo
977 1042
 							'db_error_skip' => true,
978 1043
 						)
979 1044
 					);
980
-					if ($smcFunc['db_num_rows']($request) == 0)
981
-						return throw_error('You need to be an admin to perform an upgrade!');
1045
+					if ($smcFunc['db_num_rows']($request) == 0) {
1046
+											return throw_error('You need to be an admin to perform an upgrade!');
1047
+					}
982 1048
 					$smcFunc['db_free_result']($request);
983 1049
 				}
984 1050
 
985 1051
 				$upcontext['user']['id'] = $id_member;
986 1052
 				$upcontext['user']['name'] = $name;
987
-			}
988
-			else
1053
+			} else
989 1054
 			{
990 1055
 				$upcontext['user']['id'] = 1;
991 1056
 				$upcontext['user']['name'] = 'Administrator';
@@ -1001,11 +1066,11 @@  discard block
 block discarded – undo
1001 1066
 				$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096);
1002 1067
 				preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
1003 1068
 
1004
-				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
1005
-					$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
1006
-				elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php'))
1007
-					$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the &quot;Install&quot; language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
1008
-				else
1069
+				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
1070
+									$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
1071
+				} elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) {
1072
+									$upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the &quot;Install&quot; language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.';
1073
+				} else
1009 1074
 				{
1010 1075
 					// Set this as the new language.
1011 1076
 					$upcontext['language'] = $user_language;
@@ -1049,8 +1114,9 @@  discard block
 block discarded – undo
1049 1114
 	unset($member_columns);
1050 1115
 
1051 1116
 	// If we've not submitted then we're done.
1052
-	if (empty($_POST['upcont']))
1053
-		return false;
1117
+	if (empty($_POST['upcont'])) {
1118
+			return false;
1119
+	}
1054 1120
 
1055 1121
 	// Firstly, if they're enabling SM stat collection just do it.
1056 1122
 	if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats']))
@@ -1070,16 +1136,17 @@  discard block
 block discarded – undo
1070 1136
 				fwrite($fp, $out);
1071 1137
 
1072 1138
 				$return_data = '';
1073
-				while (!feof($fp))
1074
-					$return_data .= fgets($fp, 128);
1139
+				while (!feof($fp)) {
1140
+									$return_data .= fgets($fp, 128);
1141
+				}
1075 1142
 
1076 1143
 				fclose($fp);
1077 1144
 
1078 1145
 				// Get the unique site ID.
1079 1146
 				preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1080 1147
 
1081
-				if (!empty($ID[1]))
1082
-					$smcFunc['db_insert']('replace',
1148
+				if (!empty($ID[1])) {
1149
+									$smcFunc['db_insert']('replace',
1083 1150
 						$db_prefix . 'settings',
1084 1151
 						array('variable' => 'string', 'value' => 'string'),
1085 1152
 						array(
@@ -1088,9 +1155,9 @@  discard block
 block discarded – undo
1088 1155
 						),
1089 1156
 						array('variable')
1090 1157
 					);
1158
+				}
1091 1159
 			}
1092
-		}
1093
-		else
1160
+		} else
1094 1161
 		{
1095 1162
 			$smcFunc['db_insert']('replace',
1096 1163
 				$db_prefix . 'settings',
@@ -1101,8 +1168,8 @@  discard block
 block discarded – undo
1101 1168
 		}
1102 1169
 	}
1103 1170
 	// Don't remove stat collection unless we unchecked the box for real, not from the loop.
1104
-	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats']))
1105
-		$smcFunc['db_query']('', '
1171
+	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) {
1172
+			$smcFunc['db_query']('', '
1106 1173
 			DELETE FROM {db_prefix}settings
1107 1174
 			WHERE variable = {string:enable_sm_stats}',
1108 1175
 			array(
@@ -1110,6 +1177,7 @@  discard block
 block discarded – undo
1110 1177
 				'db_error_skip' => true,
1111 1178
 			)
1112 1179
 		);
1180
+	}
1113 1181
 
1114 1182
 	// Deleting old karma stuff?
1115 1183
 	if (!empty($_POST['delete_karma']))
@@ -1124,20 +1192,22 @@  discard block
 block discarded – undo
1124 1192
 		);
1125 1193
 
1126 1194
 		// Cleaning up old karma member settings.
1127
-		if ($upcontext['karma_installed']['good'])
1128
-			$smcFunc['db_query']('', '
1195
+		if ($upcontext['karma_installed']['good']) {
1196
+					$smcFunc['db_query']('', '
1129 1197
 				ALTER TABLE {db_prefix}members
1130 1198
 				DROP karma_good',
1131 1199
 				array()
1132 1200
 			);
1201
+		}
1133 1202
 
1134 1203
 		// Does karma bad was enable?
1135
-		if ($upcontext['karma_installed']['bad'])
1136
-			$smcFunc['db_query']('', '
1204
+		if ($upcontext['karma_installed']['bad']) {
1205
+					$smcFunc['db_query']('', '
1137 1206
 				ALTER TABLE {db_prefix}members
1138 1207
 				DROP karma_bad',
1139 1208
 				array()
1140 1209
 			);
1210
+		}
1141 1211
 
1142 1212
 		// Cleaning up old karma permissions.
1143 1213
 		$smcFunc['db_query']('', '
@@ -1155,32 +1225,37 @@  discard block
 block discarded – undo
1155 1225
 	}
1156 1226
 
1157 1227
 	// Emptying the error log?
1158
-	if (!empty($_POST['empty_error']))
1159
-		$smcFunc['db_query']('truncate_table', '
1228
+	if (!empty($_POST['empty_error'])) {
1229
+			$smcFunc['db_query']('truncate_table', '
1160 1230
 			TRUNCATE {db_prefix}log_errors',
1161 1231
 			array(
1162 1232
 			)
1163 1233
 		);
1234
+	}
1164 1235
 
1165 1236
 	$changes = array();
1166 1237
 
1167 1238
 	// Add proxy settings.
1168
-	if (!isset($GLOBALS['image_proxy_maxsize']))
1169
-		$changes += array(
1239
+	if (!isset($GLOBALS['image_proxy_maxsize'])) {
1240
+			$changes += array(
1170 1241
 			'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'',
1171 1242
 			'image_proxy_maxsize' => 5190,
1172 1243
 			'image_proxy_enabled' => 0,
1173 1244
 		);
1245
+	}
1174 1246
 
1175 1247
 	// If $boardurl reflects https, set force_ssl
1176
-	if (!function_exists('cache_put_data'))
1177
-		require_once($sourcedir . '/Load.php');
1178
-	if (stripos($boardurl, 'https://') !== false)
1179
-		updateSettings(array('force_ssl' => '1'));
1248
+	if (!function_exists('cache_put_data')) {
1249
+			require_once($sourcedir . '/Load.php');
1250
+	}
1251
+	if (stripos($boardurl, 'https://') !== false) {
1252
+			updateSettings(array('force_ssl' => '1'));
1253
+	}
1180 1254
 
1181 1255
 	// If we're overriding the language follow it through.
1182
-	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php'))
1183
-		$changes['language'] = '\'' . $_GET['lang'] . '\'';
1256
+	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) {
1257
+			$changes['language'] = '\'' . $_GET['lang'] . '\'';
1258
+	}
1184 1259
 
1185 1260
 	if (!empty($_POST['maint']))
1186 1261
 	{
@@ -1192,26 +1267,29 @@  discard block
 block discarded – undo
1192 1267
 		{
1193 1268
 			$changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\'';
1194 1269
 			$changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\'';
1195
-		}
1196
-		else
1270
+		} else
1197 1271
 		{
1198 1272
 			$changes['mtitle'] = '\'Upgrading the forum...\'';
1199 1273
 			$changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum.  It will only be a minute ;).\'';
1200 1274
 		}
1201 1275
 	}
1202 1276
 
1203
-	if ($command_line)
1204
-		echo ' * Updating Settings.php...';
1277
+	if ($command_line) {
1278
+			echo ' * Updating Settings.php...';
1279
+	}
1205 1280
 
1206 1281
 	// Fix some old paths.
1207
-	if (substr($boarddir, 0, 1) == '.')
1208
-		$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1282
+	if (substr($boarddir, 0, 1) == '.') {
1283
+			$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1284
+	}
1209 1285
 
1210
-	if (substr($sourcedir, 0, 1) == '.')
1211
-		$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1286
+	if (substr($sourcedir, 0, 1) == '.') {
1287
+			$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1288
+	}
1212 1289
 
1213
-	if (empty($cachedir) || substr($cachedir, 0, 1) == '.')
1214
-		$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1290
+	if (empty($cachedir) || substr($cachedir, 0, 1) == '.') {
1291
+			$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1292
+	}
1215 1293
 
1216 1294
 	// If they have a "host:port" setup for the host, split that into separate values
1217 1295
 	// You should never have a : in the hostname if you're not on MySQL, but better safe than sorry
@@ -1222,32 +1300,36 @@  discard block
 block discarded – undo
1222 1300
 		$changes['db_server'] = '\'' . $db_server . '\'';
1223 1301
 
1224 1302
 		// Only set this if we're not using the default port
1225
-		if ($db_port != ini_get('mysqli.default_port'))
1226
-			$changes['db_port'] = (int) $db_port;
1227
-	}
1228
-	elseif (!empty($db_port))
1303
+		if ($db_port != ini_get('mysqli.default_port')) {
1304
+					$changes['db_port'] = (int) $db_port;
1305
+		}
1306
+	} elseif (!empty($db_port))
1229 1307
 	{
1230 1308
 		// If db_port is set and is the same as the default, set it to ''
1231 1309
 		if ($db_type == 'mysql')
1232 1310
 		{
1233
-			if ($db_port == ini_get('mysqli.default_port'))
1234
-				$changes['db_port'] = '\'\'';
1235
-			elseif ($db_type == 'postgresql' && $db_port == 5432)
1236
-				$changes['db_port'] = '\'\'';
1311
+			if ($db_port == ini_get('mysqli.default_port')) {
1312
+							$changes['db_port'] = '\'\'';
1313
+			} elseif ($db_type == 'postgresql' && $db_port == 5432) {
1314
+							$changes['db_port'] = '\'\'';
1315
+			}
1237 1316
 		}
1238 1317
 	}
1239 1318
 
1240 1319
 	// Maybe we haven't had this option yet?
1241
-	if (empty($packagesdir))
1242
-		$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1320
+	if (empty($packagesdir)) {
1321
+			$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1322
+	}
1243 1323
 
1244 1324
 	// Add support for $tasksdir var.
1245
-	if (empty($tasksdir))
1246
-		$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1325
+	if (empty($tasksdir)) {
1326
+			$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1327
+	}
1247 1328
 
1248 1329
 	// Make sure we fix the language as well.
1249
-	if (stristr($language, '-utf8'))
1250
-		$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1330
+	if (stristr($language, '-utf8')) {
1331
+			$changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\'';
1332
+	}
1251 1333
 
1252 1334
 	// @todo Maybe change the cookie name if going to 1.1, too?
1253 1335
 
@@ -1258,8 +1340,9 @@  discard block
 block discarded – undo
1258 1340
 	// Tell Settings.php to store db_last_error.php in the cache
1259 1341
 	move_db_last_error_to_cachedir();
1260 1342
 
1261
-	if ($command_line)
1262
-		echo ' Successful.' . "\n";
1343
+	if ($command_line) {
1344
+			echo ' Successful.' . "\n";
1345
+	}
1263 1346
 
1264 1347
 	// Are we doing debug?
1265 1348
 	if (isset($_POST['debug']))
@@ -1269,8 +1352,9 @@  discard block
 block discarded – undo
1269 1352
 	}
1270 1353
 
1271 1354
 	// If we're not backing up then jump one.
1272
-	if (empty($_POST['backup']))
1273
-		$upcontext['current_step']++;
1355
+	if (empty($_POST['backup'])) {
1356
+			$upcontext['current_step']++;
1357
+	}
1274 1358
 
1275 1359
 	// If we've got here then let's proceed to the next step!
1276 1360
 	return true;
@@ -1285,8 +1369,9 @@  discard block
 block discarded – undo
1285 1369
 	$upcontext['page_title'] = $txt['backup_database'];
1286 1370
 
1287 1371
 	// Done it already - js wise?
1288
-	if (!empty($_POST['backup_done']))
1289
-		return true;
1372
+	if (!empty($_POST['backup_done'])) {
1373
+			return true;
1374
+	}
1290 1375
 
1291 1376
 	// Some useful stuff here.
1292 1377
 	db_extend();
@@ -1300,9 +1385,10 @@  discard block
 block discarded – undo
1300 1385
 	$tables = $smcFunc['db_list_tables']($db, $filter);
1301 1386
 
1302 1387
 	$table_names = array();
1303
-	foreach ($tables as $table)
1304
-		if (substr($table, 0, 7) !== 'backup_')
1388
+	foreach ($tables as $table) {
1389
+			if (substr($table, 0, 7) !== 'backup_')
1305 1390
 			$table_names[] = $table;
1391
+	}
1306 1392
 
1307 1393
 	$upcontext['table_count'] = count($table_names);
1308 1394
 	$upcontext['cur_table_num'] = $_GET['substep'];
@@ -1312,12 +1398,14 @@  discard block
 block discarded – undo
1312 1398
 	$file_steps = $upcontext['table_count'];
1313 1399
 
1314 1400
 	// What ones have we already done?
1315
-	foreach ($table_names as $id => $table)
1316
-		if ($id < $_GET['substep'])
1401
+	foreach ($table_names as $id => $table) {
1402
+			if ($id < $_GET['substep'])
1317 1403
 			$upcontext['previous_tables'][] = $table;
1404
+	}
1318 1405
 
1319
-	if ($command_line)
1320
-		echo 'Backing Up Tables.';
1406
+	if ($command_line) {
1407
+			echo 'Backing Up Tables.';
1408
+	}
1321 1409
 
1322 1410
 	// If we don't support javascript we backup here.
1323 1411
 	if (!$support_js || isset($_GET['xml']))
@@ -1336,8 +1424,9 @@  discard block
 block discarded – undo
1336 1424
 			backupTable($table_names[$substep]);
1337 1425
 
1338 1426
 			// If this is XML to keep it nice for the user do one table at a time anyway!
1339
-			if (isset($_GET['xml']))
1340
-				return upgradeExit();
1427
+			if (isset($_GET['xml'])) {
1428
+							return upgradeExit();
1429
+			}
1341 1430
 		}
1342 1431
 
1343 1432
 		if ($command_line)
@@ -1370,9 +1459,10 @@  discard block
 block discarded – undo
1370 1459
 
1371 1460
 	$smcFunc['db_backup_table']($table, 'backup_' . $table);
1372 1461
 
1373
-	if ($command_line)
1374
-		echo ' done.';
1375
-}
1462
+	if ($command_line) {
1463
+			echo ' done.';
1464
+	}
1465
+	}
1376 1466
 
1377 1467
 // Step 2: Everything.
1378 1468
 function DatabaseChanges()
@@ -1381,8 +1471,9 @@  discard block
 block discarded – undo
1381 1471
 	global $upcontext, $support_js, $db_type;
1382 1472
 
1383 1473
 	// Have we just completed this?
1384
-	if (!empty($_POST['database_done']))
1385
-		return true;
1474
+	if (!empty($_POST['database_done'])) {
1475
+			return true;
1476
+	}
1386 1477
 
1387 1478
 	$upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes';
1388 1479
 	$upcontext['page_title'] = $txt['database_changes'];
@@ -1397,15 +1488,16 @@  discard block
 block discarded – undo
1397 1488
 	);
1398 1489
 
1399 1490
 	// How many files are there in total?
1400
-	if (isset($_GET['filecount']))
1401
-		$upcontext['file_count'] = (int) $_GET['filecount'];
1402
-	else
1491
+	if (isset($_GET['filecount'])) {
1492
+			$upcontext['file_count'] = (int) $_GET['filecount'];
1493
+	} else
1403 1494
 	{
1404 1495
 		$upcontext['file_count'] = 0;
1405 1496
 		foreach ($files as $file)
1406 1497
 		{
1407
-			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1])
1408
-				$upcontext['file_count']++;
1498
+			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) {
1499
+							$upcontext['file_count']++;
1500
+			}
1409 1501
 		}
1410 1502
 	}
1411 1503
 
@@ -1415,9 +1507,9 @@  discard block
 block discarded – undo
1415 1507
 	$upcontext['cur_file_num'] = 0;
1416 1508
 	foreach ($files as $file)
1417 1509
 	{
1418
-		if ($did_not_do)
1419
-			$did_not_do--;
1420
-		else
1510
+		if ($did_not_do) {
1511
+					$did_not_do--;
1512
+		} else
1421 1513
 		{
1422 1514
 			$upcontext['cur_file_num']++;
1423 1515
 			$upcontext['cur_file_name'] = $file[0];
@@ -1444,12 +1536,13 @@  discard block
 block discarded – undo
1444 1536
 					// Flag to move on to the next.
1445 1537
 					$upcontext['completed_step'] = true;
1446 1538
 					// Did we complete the whole file?
1447
-					if ($nextFile)
1448
-						$upcontext['current_debug_item_num'] = -1;
1539
+					if ($nextFile) {
1540
+											$upcontext['current_debug_item_num'] = -1;
1541
+					}
1449 1542
 					return upgradeExit();
1543
+				} elseif ($support_js) {
1544
+									break;
1450 1545
 				}
1451
-				elseif ($support_js)
1452
-					break;
1453 1546
 			}
1454 1547
 			// Set the progress bar to be right as if we had - even if we hadn't...
1455 1548
 			$upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100;
@@ -1475,8 +1568,9 @@  discard block
 block discarded – undo
1475 1568
 	global $user_info, $maintenance, $smcFunc, $db_type, $txt, $settings;
1476 1569
 
1477 1570
 	// Now it's nice to have some of the basic SMF source files.
1478
-	if (!isset($_GET['ssi']) && !$command_line)
1479
-		redirectLocation('&ssi=1');
1571
+	if (!isset($_GET['ssi']) && !$command_line) {
1572
+			redirectLocation('&ssi=1');
1573
+	}
1480 1574
 
1481 1575
 	$upcontext['sub_template'] = 'upgrade_complete';
1482 1576
 	$upcontext['page_title'] = $txt['upgrade_complete'];
@@ -1492,14 +1586,16 @@  discard block
 block discarded – undo
1492 1586
 	// Are we in maintenance mode?
1493 1587
 	if (isset($upcontext['user']['main']))
1494 1588
 	{
1495
-		if ($command_line)
1496
-			echo ' * ';
1589
+		if ($command_line) {
1590
+					echo ' * ';
1591
+		}
1497 1592
 		$upcontext['removed_maintenance'] = true;
1498 1593
 		$changes['maintenance'] = $upcontext['user']['main'];
1499 1594
 	}
1500 1595
 	// Otherwise if somehow we are in 2 let's go to 1.
1501
-	elseif (!empty($maintenance) && $maintenance == 2)
1502
-		$changes['maintenance'] = 1;
1596
+	elseif (!empty($maintenance) && $maintenance == 2) {
1597
+			$changes['maintenance'] = 1;
1598
+	}
1503 1599
 
1504 1600
 	// Wipe this out...
1505 1601
 	$upcontext['user'] = array();
@@ -1514,21 +1610,23 @@  discard block
 block discarded – undo
1514 1610
 	$upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__);
1515 1611
 
1516 1612
 	// Now is the perfect time to fetch the SM files.
1517
-	if ($command_line)
1518
-		cli_scheduled_fetchSMfiles();
1519
-	else
1613
+	if ($command_line) {
1614
+			cli_scheduled_fetchSMfiles();
1615
+	} else
1520 1616
 	{
1521 1617
 		require_once($sourcedir . '/ScheduledTasks.php');
1522 1618
 		$forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us.
1523 1619
 		scheduled_fetchSMfiles(); // Now go get those files!
1524 1620
 		// This is needed in case someone invokes the upgrader using https when upgrading an http forum
1525
-		if (httpsOn())
1526
-			$settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://'));
1621
+		if (httpsOn()) {
1622
+					$settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://'));
1623
+		}
1527 1624
 	}
1528 1625
 
1529 1626
 	// Log what we've done.
1530
-	if (empty($user_info['id']))
1531
-		$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1627
+	if (empty($user_info['id'])) {
1628
+			$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
1629
+	}
1532 1630
 
1533 1631
 	// Log the action manually, so CLI still works.
1534 1632
 	$smcFunc['db_insert']('',
@@ -1547,8 +1645,9 @@  discard block
 block discarded – undo
1547 1645
 
1548 1646
 	// Save the current database version.
1549 1647
 	$server_version = $smcFunc['db_server_info']();
1550
-	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1551
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1648
+	if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1649
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1650
+	}
1552 1651
 
1553 1652
 	if ($command_line)
1554 1653
 	{
@@ -1560,8 +1659,9 @@  discard block
 block discarded – undo
1560 1659
 
1561 1660
 	// Make sure it says we're done.
1562 1661
 	$upcontext['overall_percent'] = 100;
1563
-	if (isset($upcontext['step_progress']))
1564
-		unset($upcontext['step_progress']);
1662
+	if (isset($upcontext['step_progress'])) {
1663
+			unset($upcontext['step_progress']);
1664
+	}
1565 1665
 
1566 1666
 	$_GET['substep'] = 0;
1567 1667
 	return false;
@@ -1572,8 +1672,9 @@  discard block
 block discarded – undo
1572 1672
 {
1573 1673
 	global $sourcedir, $language, $forum_version, $modSettings, $smcFunc;
1574 1674
 
1575
-	if (empty($modSettings['time_format']))
1576
-		$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1675
+	if (empty($modSettings['time_format'])) {
1676
+			$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
1677
+	}
1577 1678
 
1578 1679
 	// What files do we want to get
1579 1680
 	$request = $smcFunc['db_query']('', '
@@ -1607,8 +1708,9 @@  discard block
 block discarded – undo
1607 1708
 		$file_data = fetch_web_data($url);
1608 1709
 
1609 1710
 		// If we got an error - give up - the site might be down.
1610
-		if ($file_data === false)
1611
-			return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1711
+		if ($file_data === false) {
1712
+					return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
1713
+		}
1612 1714
 
1613 1715
 		// Save the file to the database.
1614 1716
 		$smcFunc['db_query']('substring', '
@@ -1650,8 +1752,9 @@  discard block
 block discarded – undo
1650 1752
 	$themeData = array();
1651 1753
 	foreach ($values as $variable => $value)
1652 1754
 	{
1653
-		if (!isset($value) || $value === null)
1654
-			$value = 0;
1755
+		if (!isset($value) || $value === null) {
1756
+					$value = 0;
1757
+		}
1655 1758
 
1656 1759
 		$themeData[] = array(0, 1, $variable, $value);
1657 1760
 	}
@@ -1680,8 +1783,9 @@  discard block
 block discarded – undo
1680 1783
 
1681 1784
 	foreach ($values as $variable => $value)
1682 1785
 	{
1683
-		if (empty($modSettings[$value[0]]))
1684
-			continue;
1786
+		if (empty($modSettings[$value[0]])) {
1787
+					continue;
1788
+		}
1685 1789
 
1686 1790
 		$smcFunc['db_query']('', '
1687 1791
 			INSERT IGNORE INTO {db_prefix}themes
@@ -1767,19 +1871,21 @@  discard block
 block discarded – undo
1767 1871
 	set_error_handler(
1768 1872
 		function ($errno, $errstr, $errfile, $errline) use ($support_js)
1769 1873
 		{
1770
-			if ($support_js)
1771
-				return true;
1772
-			else
1773
-				echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1874
+			if ($support_js) {
1875
+							return true;
1876
+			} else {
1877
+							echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
1878
+			}
1774 1879
 		}
1775 1880
 	);
1776 1881
 
1777 1882
 	// If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8
1778 1883
 	// Note it is expected to be in the format: ENGINE=MyISAM{$db_collation};
1779
-	if ($db_type == 'mysql')
1780
-		$db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
1781
-	else
1782
-		$db_collation = '';
1884
+	if ($db_type == 'mysql') {
1885
+			$db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
1886
+	} else {
1887
+			$db_collation = '';
1888
+	}
1783 1889
 
1784 1890
 	$endl = $command_line ? "\n" : '<br>' . "\n";
1785 1891
 
@@ -1791,8 +1897,9 @@  discard block
 block discarded – undo
1791 1897
 	$last_step = '';
1792 1898
 
1793 1899
 	// Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php
1794
-	if (isset($db_character_set) && $db_character_set === 'utf8')
1795
-		$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1900
+	if (isset($db_character_set) && $db_character_set === 'utf8') {
1901
+			$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
1902
+	}
1796 1903
 
1797 1904
 	// Count the total number of steps within this file - for progress.
1798 1905
 	$file_steps = substr_count(implode('', $lines), '---#');
@@ -1812,15 +1919,18 @@  discard block
 block discarded – undo
1812 1919
 		$do_current = $substep >= $_GET['substep'];
1813 1920
 
1814 1921
 		// Get rid of any comments in the beginning of the line...
1815
-		if (substr(trim($line), 0, 2) === '/*')
1816
-			$line = preg_replace('~/\*.+?\*/~', '', $line);
1922
+		if (substr(trim($line), 0, 2) === '/*') {
1923
+					$line = preg_replace('~/\*.+?\*/~', '', $line);
1924
+		}
1817 1925
 
1818 1926
 		// Always flush.  Flush, flush, flush.  Flush, flush, flush, flush!  FLUSH!
1819
-		if ($is_debug && !$support_js && $command_line)
1820
-			flush();
1927
+		if ($is_debug && !$support_js && $command_line) {
1928
+					flush();
1929
+		}
1821 1930
 
1822
-		if (trim($line) === '')
1823
-			continue;
1931
+		if (trim($line) === '') {
1932
+					continue;
1933
+		}
1824 1934
 
1825 1935
 		if (trim(substr($line, 0, 3)) === '---')
1826 1936
 		{
@@ -1830,8 +1940,9 @@  discard block
 block discarded – undo
1830 1940
 			if (trim($current_data) != '' && $type !== '}')
1831 1941
 			{
1832 1942
 				$upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl;
1833
-				if ($command_line)
1834
-					echo $upcontext['error_message'];
1943
+				if ($command_line) {
1944
+									echo $upcontext['error_message'];
1945
+				}
1835 1946
 			}
1836 1947
 
1837 1948
 			if ($type == ' ')
@@ -1849,17 +1960,18 @@  discard block
 block discarded – undo
1849 1960
 				if ($do_current)
1850 1961
 				{
1851 1962
 					$upcontext['actioned_items'][] = $last_step;
1852
-					if ($command_line)
1853
-						echo ' * ';
1963
+					if ($command_line) {
1964
+											echo ' * ';
1965
+					}
1854 1966
 				}
1855
-			}
1856
-			elseif ($type == '#')
1967
+			} elseif ($type == '#')
1857 1968
 			{
1858 1969
 				$upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps;
1859 1970
 
1860 1971
 				$upcontext['current_debug_item_num']++;
1861
-				if (trim($line) != '---#')
1862
-					$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1972
+				if (trim($line) != '---#') {
1973
+									$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
1974
+				}
1863 1975
 
1864 1976
 				// Have we already done something?
1865 1977
 				if (isset($_GET['xml']) && $done_something)
@@ -1870,34 +1982,36 @@  discard block
 block discarded – undo
1870 1982
 
1871 1983
 				if ($do_current)
1872 1984
 				{
1873
-					if (trim($line) == '---#' && $command_line)
1874
-						echo ' done.', $endl;
1875
-					elseif ($command_line)
1876
-						echo ' +++ ', rtrim(substr($line, 4));
1877
-					elseif (trim($line) != '---#')
1985
+					if (trim($line) == '---#' && $command_line) {
1986
+											echo ' done.', $endl;
1987
+					} elseif ($command_line) {
1988
+											echo ' +++ ', rtrim(substr($line, 4));
1989
+					} elseif (trim($line) != '---#')
1878 1990
 					{
1879
-						if ($is_debug)
1880
-							$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1991
+						if ($is_debug) {
1992
+													$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
1993
+						}
1881 1994
 					}
1882 1995
 				}
1883 1996
 
1884 1997
 				if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep'])
1885 1998
 				{
1886
-					if ($command_line)
1887
-						echo ' * ';
1888
-					else
1889
-						$upcontext['actioned_items'][] = $last_step;
1999
+					if ($command_line) {
2000
+											echo ' * ';
2001
+					} else {
2002
+											$upcontext['actioned_items'][] = $last_step;
2003
+					}
1890 2004
 				}
1891 2005
 
1892 2006
 				// Small step - only if we're actually doing stuff.
1893
-				if ($do_current)
1894
-					nextSubstep(++$substep);
1895
-				else
1896
-					$substep++;
1897
-			}
1898
-			elseif ($type == '{')
1899
-				$current_type = 'code';
1900
-			elseif ($type == '}')
2007
+				if ($do_current) {
2008
+									nextSubstep(++$substep);
2009
+				} else {
2010
+									$substep++;
2011
+				}
2012
+			} elseif ($type == '{') {
2013
+							$current_type = 'code';
2014
+			} elseif ($type == '}')
1901 2015
 			{
1902 2016
 				$current_type = 'sql';
1903 2017
 
@@ -1910,8 +2024,9 @@  discard block
 block discarded – undo
1910 2024
 				if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false)
1911 2025
 				{
1912 2026
 					$upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl;
1913
-					if ($command_line)
1914
-						echo $upcontext['error_message'];
2027
+					if ($command_line) {
2028
+											echo $upcontext['error_message'];
2029
+					}
1915 2030
 				}
1916 2031
 
1917 2032
 				// Done with code!
@@ -1999,8 +2114,9 @@  discard block
 block discarded – undo
1999 2114
 	$db_unbuffered = false;
2000 2115
 
2001 2116
 	// Failure?!
2002
-	if ($result !== false)
2003
-		return $result;
2117
+	if ($result !== false) {
2118
+			return $result;
2119
+	}
2004 2120
 
2005 2121
 	$db_error_message = $smcFunc['db_error']($db_connection);
2006 2122
 	// If MySQL we do something more clever.
@@ -2028,54 +2144,61 @@  discard block
 block discarded – undo
2028 2144
 			{
2029 2145
 				mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`');
2030 2146
 				$result = mysqli_query($db_connection, $string);
2031
-				if ($result !== false)
2032
-					return $result;
2147
+				if ($result !== false) {
2148
+									return $result;
2149
+				}
2033 2150
 			}
2034
-		}
2035
-		elseif ($mysqli_errno == 2013)
2151
+		} elseif ($mysqli_errno == 2013)
2036 2152
 		{
2037 2153
 			$db_connection = mysqli_connect($db_server, $db_user, $db_passwd);
2038 2154
 			mysqli_select_db($db_connection, $db_name);
2039 2155
 			if ($db_connection)
2040 2156
 			{
2041 2157
 				$result = mysqli_query($db_connection, $string);
2042
-				if ($result !== false)
2043
-					return $result;
2158
+				if ($result !== false) {
2159
+									return $result;
2160
+				}
2044 2161
 			}
2045 2162
 		}
2046 2163
 		// Duplicate column name... should be okay ;).
2047
-		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091)))
2048
-			return false;
2164
+		elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) {
2165
+					return false;
2166
+		}
2049 2167
 		// Duplicate insert... make sure it's the proper type of query ;).
2050
-		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query)
2051
-			return false;
2168
+		elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) {
2169
+					return false;
2170
+		}
2052 2171
 		// Creating an index on a non-existent column.
2053
-		elseif ($mysqli_errno == 1072)
2054
-			return false;
2055
-		elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE')
2056
-			return false;
2172
+		elseif ($mysqli_errno == 1072) {
2173
+					return false;
2174
+		} elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') {
2175
+					return false;
2176
+		}
2057 2177
 	}
2058 2178
 	// If a table already exists don't go potty.
2059 2179
 	else
2060 2180
 	{
2061 2181
 		if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U')))
2062 2182
 		{
2063
-			if (strpos($db_error_message, 'exist') !== false)
2064
-				return true;
2065
-		}
2066
-		elseif (strpos(trim($string), 'INSERT ') !== false)
2183
+			if (strpos($db_error_message, 'exist') !== false) {
2184
+							return true;
2185
+			}
2186
+		} elseif (strpos(trim($string), 'INSERT ') !== false)
2067 2187
 		{
2068
-			if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error)
2069
-				return true;
2188
+			if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error) {
2189
+							return true;
2190
+			}
2070 2191
 		}
2071 2192
 	}
2072 2193
 
2073 2194
 	// Get the query string so we pass everything.
2074 2195
 	$query_string = '';
2075
-	foreach ($_GET as $k => $v)
2076
-		$query_string .= ';' . $k . '=' . $v;
2077
-	if (strlen($query_string) != 0)
2078
-		$query_string = '?' . substr($query_string, 1);
2196
+	foreach ($_GET as $k => $v) {
2197
+			$query_string .= ';' . $k . '=' . $v;
2198
+	}
2199
+	if (strlen($query_string) != 0) {
2200
+			$query_string = '?' . substr($query_string, 1);
2201
+	}
2079 2202
 
2080 2203
 	if ($command_line)
2081 2204
 	{
@@ -2130,16 +2253,18 @@  discard block
 block discarded – undo
2130 2253
 			{
2131 2254
 				$found |= 1;
2132 2255
 				// Do some checks on the data if we have it set.
2133
-				if (isset($change['col_type']))
2134
-					$found &= $change['col_type'] === $column['type'];
2135
-				if (isset($change['null_allowed']))
2136
-					$found &= $column['null'] == $change['null_allowed'];
2137
-				if (isset($change['default']))
2138
-					$found &= $change['default'] === $column['default'];
2256
+				if (isset($change['col_type'])) {
2257
+									$found &= $change['col_type'] === $column['type'];
2258
+				}
2259
+				if (isset($change['null_allowed'])) {
2260
+									$found &= $column['null'] == $change['null_allowed'];
2261
+				}
2262
+				if (isset($change['default'])) {
2263
+									$found &= $change['default'] === $column['default'];
2264
+				}
2139 2265
 			}
2140 2266
 		}
2141
-	}
2142
-	elseif ($change['type'] === 'index')
2267
+	} elseif ($change['type'] === 'index')
2143 2268
 	{
2144 2269
 		$request = upgrade_query('
2145 2270
 			SHOW INDEX
@@ -2148,9 +2273,10 @@  discard block
 block discarded – undo
2148 2273
 		{
2149 2274
 			$cur_index = array();
2150 2275
 
2151
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2152
-				if ($row['Key_name'] === $change['name'])
2276
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2277
+							if ($row['Key_name'] === $change['name'])
2153 2278
 					$cur_index[(int) $row['Seq_in_index']] = $row['Column_name'];
2279
+			}
2154 2280
 
2155 2281
 			ksort($cur_index, SORT_NUMERIC);
2156 2282
 			$found = array_values($cur_index) === $change['target_columns'];
@@ -2160,14 +2286,17 @@  discard block
 block discarded – undo
2160 2286
 	}
2161 2287
 
2162 2288
 	// If we're trying to add and it's added, we're done.
2163
-	if ($found && in_array($change['method'], array('add', 'change')))
2164
-		return true;
2289
+	if ($found && in_array($change['method'], array('add', 'change'))) {
2290
+			return true;
2291
+	}
2165 2292
 	// Otherwise if we're removing and it wasn't found we're also done.
2166
-	elseif (!$found && in_array($change['method'], array('remove', 'change_remove')))
2167
-		return true;
2293
+	elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) {
2294
+			return true;
2295
+	}
2168 2296
 	// Otherwise is it just a test?
2169
-	elseif ($is_test)
2170
-		return false;
2297
+	elseif ($is_test) {
2298
+			return false;
2299
+	}
2171 2300
 
2172 2301
 	// Not found it yet? Bummer! How about we see if we're currently doing it?
2173 2302
 	$running = false;
@@ -2178,8 +2307,9 @@  discard block
 block discarded – undo
2178 2307
 			SHOW FULL PROCESSLIST');
2179 2308
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2180 2309
 		{
2181
-			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false)
2182
-				$found = true;
2310
+			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) {
2311
+							$found = true;
2312
+			}
2183 2313
 		}
2184 2314
 
2185 2315
 		// Can't find it? Then we need to run it fools!
@@ -2191,8 +2321,9 @@  discard block
 block discarded – undo
2191 2321
 				ALTER TABLE ' . $db_prefix . $change['table'] . '
2192 2322
 				' . $change['text'], true) !== false;
2193 2323
 
2194
-			if (!$success)
2195
-				return false;
2324
+			if (!$success) {
2325
+							return false;
2326
+			}
2196 2327
 
2197 2328
 			// Return
2198 2329
 			$running = true;
@@ -2234,8 +2365,9 @@  discard block
 block discarded – undo
2234 2365
 			'db_error_skip' => true,
2235 2366
 		)
2236 2367
 	);
2237
-	if ($smcFunc['db_num_rows']($request) === 0)
2238
-		die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2368
+	if ($smcFunc['db_num_rows']($request) === 0) {
2369
+			die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
2370
+	}
2239 2371
 	$table_row = $smcFunc['db_fetch_assoc']($request);
2240 2372
 	$smcFunc['db_free_result']($request);
2241 2373
 
@@ -2257,18 +2389,19 @@  discard block
 block discarded – undo
2257 2389
 			)
2258 2390
 		);
2259 2391
 		// No results? Just forget it all together.
2260
-		if ($smcFunc['db_num_rows']($request) === 0)
2261
-			unset($table_row['Collation']);
2262
-		else
2263
-			$collation_info = $smcFunc['db_fetch_assoc']($request);
2392
+		if ($smcFunc['db_num_rows']($request) === 0) {
2393
+					unset($table_row['Collation']);
2394
+		} else {
2395
+					$collation_info = $smcFunc['db_fetch_assoc']($request);
2396
+		}
2264 2397
 		$smcFunc['db_free_result']($request);
2265 2398
 	}
2266 2399
 
2267 2400
 	if ($column_fix)
2268 2401
 	{
2269 2402
 		// Make sure there are no NULL's left.
2270
-		if ($null_fix)
2271
-			$smcFunc['db_query']('', '
2403
+		if ($null_fix) {
2404
+					$smcFunc['db_query']('', '
2272 2405
 				UPDATE {db_prefix}' . $change['table'] . '
2273 2406
 				SET ' . $change['column'] . ' = {string:default}
2274 2407
 				WHERE ' . $change['column'] . ' IS NULL',
@@ -2277,6 +2410,7 @@  discard block
 block discarded – undo
2277 2410
 					'db_error_skip' => true,
2278 2411
 				)
2279 2412
 			);
2413
+		}
2280 2414
 
2281 2415
 		// Do the actual alteration.
2282 2416
 		$smcFunc['db_query']('', '
@@ -2305,8 +2439,9 @@  discard block
 block discarded – undo
2305 2439
 	}
2306 2440
 
2307 2441
 	// Not a column we need to check on?
2308
-	if (!in_array($change['name'], array('memberGroups', 'passwordSalt')))
2309
-		return;
2442
+	if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) {
2443
+			return;
2444
+	}
2310 2445
 
2311 2446
 	// Break it up you (six|seven).
2312 2447
 	$temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text']));
@@ -2325,13 +2460,13 @@  discard block
 block discarded – undo
2325 2460
 				'new_name' => $temp[2],
2326 2461
 		));
2327 2462
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2328
-		if ($smcFunc['db_num_rows'] != 1)
2329
-			return;
2463
+		if ($smcFunc['db_num_rows'] != 1) {
2464
+					return;
2465
+		}
2330 2466
 
2331 2467
 		list (, $current_type) = $smcFunc['db_fetch_assoc']($request);
2332 2468
 		$smcFunc['db_free_result']($request);
2333
-	}
2334
-	else
2469
+	} else
2335 2470
 	{
2336 2471
 		// Do this the old fashion, sure method way.
2337 2472
 		$request = $smcFunc['db_query']('', '
@@ -2342,21 +2477,24 @@  discard block
 block discarded – undo
2342 2477
 		));
2343 2478
 		// Mayday!
2344 2479
 		// !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet.
2345
-		if ($smcFunc['db_num_rows'] == 0)
2346
-			return;
2480
+		if ($smcFunc['db_num_rows'] == 0) {
2481
+					return;
2482
+		}
2347 2483
 
2348 2484
 		// Oh where, oh where has my little field gone. Oh where can it be...
2349
-		while ($row = $smcFunc['db_query']($request))
2350
-			if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2485
+		while ($row = $smcFunc['db_query']($request)) {
2486
+					if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
2351 2487
 			{
2352 2488
 				$current_type = $row['Type'];
2489
+		}
2353 2490
 				break;
2354 2491
 			}
2355 2492
 	}
2356 2493
 
2357 2494
 	// If this doesn't match, the column may of been altered for a reason.
2358
-	if (trim($current_type) != trim($temp[3]))
2359
-		$temp[3] = $current_type;
2495
+	if (trim($current_type) != trim($temp[3])) {
2496
+			$temp[3] = $current_type;
2497
+	}
2360 2498
 
2361 2499
 	// Piece this back together.
2362 2500
 	$change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp));
@@ -2368,8 +2506,9 @@  discard block
 block discarded – undo
2368 2506
 	global $start_time, $timeLimitThreshold, $command_line, $custom_warning;
2369 2507
 	global $step_progress, $is_debug, $upcontext;
2370 2508
 
2371
-	if ($_GET['substep'] < $substep)
2372
-		$_GET['substep'] = $substep;
2509
+	if ($_GET['substep'] < $substep) {
2510
+			$_GET['substep'] = $substep;
2511
+	}
2373 2512
 
2374 2513
 	if ($command_line)
2375 2514
 	{
@@ -2382,29 +2521,33 @@  discard block
 block discarded – undo
2382 2521
 	}
2383 2522
 
2384 2523
 	@set_time_limit(300);
2385
-	if (function_exists('apache_reset_timeout'))
2386
-		@apache_reset_timeout();
2524
+	if (function_exists('apache_reset_timeout')) {
2525
+			@apache_reset_timeout();
2526
+	}
2387 2527
 
2388
-	if (time() - $start_time <= $timeLimitThreshold)
2389
-		return;
2528
+	if (time() - $start_time <= $timeLimitThreshold) {
2529
+			return;
2530
+	}
2390 2531
 
2391 2532
 	// Do we have some custom step progress stuff?
2392 2533
 	if (!empty($step_progress))
2393 2534
 	{
2394 2535
 		$upcontext['substep_progress'] = 0;
2395 2536
 		$upcontext['substep_progress_name'] = $step_progress['name'];
2396
-		if ($step_progress['current'] > $step_progress['total'])
2397
-			$upcontext['substep_progress'] = 99.9;
2398
-		else
2399
-			$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2537
+		if ($step_progress['current'] > $step_progress['total']) {
2538
+					$upcontext['substep_progress'] = 99.9;
2539
+		} else {
2540
+					$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
2541
+		}
2400 2542
 
2401 2543
 		// Make it nicely rounded.
2402 2544
 		$upcontext['substep_progress'] = round($upcontext['substep_progress'], 1);
2403 2545
 	}
2404 2546
 
2405 2547
 	// If this is XML we just exit right away!
2406
-	if (isset($_GET['xml']))
2407
-		return upgradeExit();
2548
+	if (isset($_GET['xml'])) {
2549
+			return upgradeExit();
2550
+	}
2408 2551
 
2409 2552
 	// We're going to pause after this!
2410 2553
 	$upcontext['pause'] = true;
@@ -2412,13 +2555,15 @@  discard block
 block discarded – undo
2412 2555
 	$upcontext['query_string'] = '';
2413 2556
 	foreach ($_GET as $k => $v)
2414 2557
 	{
2415
-		if ($k != 'data' && $k != 'substep' && $k != 'step')
2416
-			$upcontext['query_string'] .= ';' . $k . '=' . $v;
2558
+		if ($k != 'data' && $k != 'substep' && $k != 'step') {
2559
+					$upcontext['query_string'] .= ';' . $k . '=' . $v;
2560
+		}
2417 2561
 	}
2418 2562
 
2419 2563
 	// Custom warning?
2420
-	if (!empty($custom_warning))
2421
-		$upcontext['custom_warning'] = $custom_warning;
2564
+	if (!empty($custom_warning)) {
2565
+			$upcontext['custom_warning'] = $custom_warning;
2566
+	}
2422 2567
 
2423 2568
 	upgradeExit();
2424 2569
 }
@@ -2433,25 +2578,26 @@  discard block
 block discarded – undo
2433 2578
 	ob_implicit_flush(true);
2434 2579
 	@set_time_limit(600);
2435 2580
 
2436
-	if (!isset($_SERVER['argv']))
2437
-		$_SERVER['argv'] = array();
2581
+	if (!isset($_SERVER['argv'])) {
2582
+			$_SERVER['argv'] = array();
2583
+	}
2438 2584
 	$_GET['maint'] = 1;
2439 2585
 
2440 2586
 	foreach ($_SERVER['argv'] as $i => $arg)
2441 2587
 	{
2442
-		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0)
2443
-			$_GET['lang'] = $match[1];
2444
-		elseif (preg_match('~^--path=(.+)$~', $arg) != 0)
2445
-			continue;
2446
-		elseif ($arg == '--no-maintenance')
2447
-			$_GET['maint'] = 0;
2448
-		elseif ($arg == '--debug')
2449
-			$is_debug = true;
2450
-		elseif ($arg == '--backup')
2451
-			$_POST['backup'] = 1;
2452
-		elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted')))
2453
-			$_GET['conv'] = 1;
2454
-		elseif ($i != 0)
2588
+		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) {
2589
+					$_GET['lang'] = $match[1];
2590
+		} elseif (preg_match('~^--path=(.+)$~', $arg) != 0) {
2591
+					continue;
2592
+		} elseif ($arg == '--no-maintenance') {
2593
+					$_GET['maint'] = 0;
2594
+		} elseif ($arg == '--debug') {
2595
+					$is_debug = true;
2596
+		} elseif ($arg == '--backup') {
2597
+					$_POST['backup'] = 1;
2598
+		} elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) {
2599
+					$_GET['conv'] = 1;
2600
+		} elseif ($i != 0)
2455 2601
 		{
2456 2602
 			echo 'SMF Command-line Upgrader
2457 2603
 Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]...
@@ -2465,10 +2611,12 @@  discard block
 block discarded – undo
2465 2611
 		}
2466 2612
 	}
2467 2613
 
2468
-	if (!php_version_check())
2469
-		print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2470
-	if (!db_version_check())
2471
-		print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2614
+	if (!php_version_check()) {
2615
+			print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
2616
+	}
2617
+	if (!db_version_check()) {
2618
+			print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
2619
+	}
2472 2620
 
2473 2621
 	// Do some checks to make sure they have proper privileges
2474 2622
 	db_extend('packages');
@@ -2483,34 +2631,39 @@  discard block
 block discarded – undo
2483 2631
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
2484 2632
 
2485 2633
 	// Sorry... we need CREATE, ALTER and DROP
2486
-	if (!$create || !$alter || !$drop)
2487
-		print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true);
2634
+	if (!$create || !$alter || !$drop) {
2635
+			print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true);
2636
+	}
2488 2637
 
2489 2638
 	$check = @file_exists($modSettings['theme_dir'] . '/index.template.php')
2490 2639
 		&& @file_exists($sourcedir . '/QueryString.php')
2491 2640
 		&& @file_exists($sourcedir . '/ManageBoards.php');
2492
-	if (!$check && !isset($modSettings['smfVersion']))
2493
-		print_error('Error: Some files are missing or out-of-date.', true);
2641
+	if (!$check && !isset($modSettings['smfVersion'])) {
2642
+			print_error('Error: Some files are missing or out-of-date.', true);
2643
+	}
2494 2644
 
2495 2645
 	// Do a quick version spot check.
2496 2646
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
2497 2647
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
2498
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
2499
-		print_error('Error: Some files have not yet been updated properly.');
2648
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
2649
+			print_error('Error: Some files have not yet been updated properly.');
2650
+	}
2500 2651
 
2501 2652
 	// Make sure Settings.php is writable.
2502 2653
 	quickFileWritable($boarddir . '/Settings.php');
2503
-	if (!is_writable($boarddir . '/Settings.php'))
2504
-		print_error('Error: Unable to obtain write access to "Settings.php".', true);
2654
+	if (!is_writable($boarddir . '/Settings.php')) {
2655
+			print_error('Error: Unable to obtain write access to "Settings.php".', true);
2656
+	}
2505 2657
 
2506 2658
 	// Make sure Settings_bak.php is writable.
2507 2659
 	quickFileWritable($boarddir . '/Settings_bak.php');
2508
-	if (!is_writable($boarddir . '/Settings_bak.php'))
2509
-		print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2660
+	if (!is_writable($boarddir . '/Settings_bak.php')) {
2661
+			print_error('Error: Unable to obtain write access to "Settings_bak.php".');
2662
+	}
2510 2663
 
2511
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
2512
-		print_error('Error: Unable to obtain write access to "agreement.txt".');
2513
-	elseif (isset($modSettings['agreement']))
2664
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
2665
+			print_error('Error: Unable to obtain write access to "agreement.txt".');
2666
+	} elseif (isset($modSettings['agreement']))
2514 2667
 	{
2515 2668
 		$fp = fopen($boarddir . '/agreement.txt', 'w');
2516 2669
 		fwrite($fp, $modSettings['agreement']);
@@ -2520,36 +2673,42 @@  discard block
 block discarded – undo
2520 2673
 	// Make sure Themes is writable.
2521 2674
 	quickFileWritable($modSettings['theme_dir']);
2522 2675
 
2523
-	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion']))
2524
-		print_error('Error: Unable to obtain write access to "Themes".');
2676
+	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) {
2677
+			print_error('Error: Unable to obtain write access to "Themes".');
2678
+	}
2525 2679
 
2526 2680
 	// Make sure cache directory exists and is writable!
2527 2681
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
2528
-	if (!file_exists($cachedir_temp))
2529
-		@mkdir($cachedir_temp);
2682
+	if (!file_exists($cachedir_temp)) {
2683
+			@mkdir($cachedir_temp);
2684
+	}
2530 2685
 
2531 2686
 	// Make sure the cache temp dir is writable.
2532 2687
 	quickFileWritable($cachedir_temp);
2533 2688
 
2534
-	if (!is_writable($cachedir_temp))
2535
-		print_error('Error: Unable to obtain write access to "cache".', true);
2689
+	if (!is_writable($cachedir_temp)) {
2690
+			print_error('Error: Unable to obtain write access to "cache".', true);
2691
+	}
2536 2692
 
2537 2693
 	// Make sure db_last_error.php is writable.
2538 2694
 	quickFileWritable($cachedir_temp . '/db_last_error.php');
2539
-	if (!is_writable($cachedir_temp . '/db_last_error.php'))
2540
-		print_error('Error: Unable to obtain write access to "db_last_error.php".');
2695
+	if (!is_writable($cachedir_temp . '/db_last_error.php')) {
2696
+			print_error('Error: Unable to obtain write access to "db_last_error.php".');
2697
+	}
2541 2698
 
2542
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
2543
-		print_error('Error: Unable to find language files!', true);
2544
-	else
2699
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
2700
+			print_error('Error: Unable to find language files!', true);
2701
+	} else
2545 2702
 	{
2546 2703
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
2547 2704
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
2548 2705
 
2549
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
2550
-			print_error('Error: Language files out of date.', true);
2551
-		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
2552
-			print_error('Error: Install language is missing for selected language.', true);
2706
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
2707
+					print_error('Error: Language files out of date.', true);
2708
+		}
2709
+		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
2710
+					print_error('Error: Install language is missing for selected language.', true);
2711
+		}
2553 2712
 
2554 2713
 		// Otherwise include it!
2555 2714
 		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
@@ -2569,8 +2728,9 @@  discard block
 block discarded – undo
2569 2728
 	global $db_prefix, $db_type, $command_line, $support_js, $txt;
2570 2729
 
2571 2730
 	// Done it already?
2572
-	if (!empty($_POST['utf8_done']))
2573
-		return true;
2731
+	if (!empty($_POST['utf8_done'])) {
2732
+			return true;
2733
+	}
2574 2734
 
2575 2735
 	// First make sure they aren't already on UTF-8 before we go anywhere...
2576 2736
 	if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8'))
@@ -2583,8 +2743,7 @@  discard block
 block discarded – undo
2583 2743
 		);
2584 2744
 
2585 2745
 		return true;
2586
-	}
2587
-	else
2746
+	} else
2588 2747
 	{
2589 2748
 		$upcontext['page_title'] = $txt['converting_utf8'];
2590 2749
 		$upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8';
@@ -2628,8 +2787,9 @@  discard block
 block discarded – undo
2628 2787
 			)
2629 2788
 		);
2630 2789
 		$db_charsets = array();
2631
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2632
-			$db_charsets[] = $row['Charset'];
2790
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2791
+					$db_charsets[] = $row['Charset'];
2792
+		}
2633 2793
 
2634 2794
 		$smcFunc['db_free_result']($request);
2635 2795
 
@@ -2665,13 +2825,15 @@  discard block
 block discarded – undo
2665 2825
 		// If there's a fulltext index, we need to drop it first...
2666 2826
 		if ($request !== false || $smcFunc['db_num_rows']($request) != 0)
2667 2827
 		{
2668
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2669
-				if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2828
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2829
+							if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
2670 2830
 					$upcontext['fulltext_index'][] = $row['Key_name'];
2831
+			}
2671 2832
 			$smcFunc['db_free_result']($request);
2672 2833
 
2673
-			if (isset($upcontext['fulltext_index']))
2674
-				$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2834
+			if (isset($upcontext['fulltext_index'])) {
2835
+							$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
2836
+			}
2675 2837
 		}
2676 2838
 
2677 2839
 		// Drop it and make a note...
@@ -2861,8 +3023,9 @@  discard block
 block discarded – undo
2861 3023
 			$replace = '%field%';
2862 3024
 
2863 3025
 			// Build a huge REPLACE statement...
2864
-			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to)
2865
-				$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
3026
+			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) {
3027
+							$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
3028
+			}
2866 3029
 		}
2867 3030
 
2868 3031
 		// Get a list of table names ahead of time... This makes it easier to set our substep and such
@@ -2872,9 +3035,10 @@  discard block
 block discarded – undo
2872 3035
 		$upcontext['table_count'] = count($queryTables);
2873 3036
 
2874 3037
 		// What ones have we already done?
2875
-		foreach ($queryTables as $id => $table)
2876
-			if ($id < $_GET['substep'])
3038
+		foreach ($queryTables as $id => $table) {
3039
+					if ($id < $_GET['substep'])
2877 3040
 				$upcontext['previous_tables'][] = $table;
3041
+		}
2878 3042
 
2879 3043
 		$upcontext['cur_table_num'] = $_GET['substep'];
2880 3044
 		$upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]);
@@ -2911,8 +3075,9 @@  discard block
 block discarded – undo
2911 3075
 			nextSubstep($substep);
2912 3076
 
2913 3077
 			// Just to make sure it doesn't time out.
2914
-			if (function_exists('apache_reset_timeout'))
2915
-				@apache_reset_timeout();
3078
+			if (function_exists('apache_reset_timeout')) {
3079
+							@apache_reset_timeout();
3080
+			}
2916 3081
 
2917 3082
 			$table_charsets = array();
2918 3083
 
@@ -2935,8 +3100,9 @@  discard block
 block discarded – undo
2935 3100
 
2936 3101
 						// Build structure of columns to operate on organized by charset; only operate on columns not yet utf8
2937 3102
 						if ($charset != 'utf8') {
2938
-							if (!isset($table_charsets[$charset]))
2939
-								$table_charsets[$charset] = array();
3103
+							if (!isset($table_charsets[$charset])) {
3104
+															$table_charsets[$charset] = array();
3105
+							}
2940 3106
 
2941 3107
 							$table_charsets[$charset][] = $column_info;
2942 3108
 						}
@@ -2977,10 +3143,11 @@  discard block
 block discarded – undo
2977 3143
 				if (isset($translation_tables[$upcontext['charset_detected']]))
2978 3144
 				{
2979 3145
 					$update = '';
2980
-					foreach ($table_charsets as $charset => $columns)
2981
-						foreach ($columns as $column)
3146
+					foreach ($table_charsets as $charset => $columns) {
3147
+											foreach ($columns as $column)
2982 3148
 							$update .= '
2983 3149
 								' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ',';
3150
+					}
2984 3151
 
2985 3152
 					$smcFunc['db_query']('', '
2986 3153
 						UPDATE {raw:table_name}
@@ -3005,8 +3172,9 @@  discard block
 block discarded – undo
3005 3172
 			// Now do the actual conversion (if still needed).
3006 3173
 			if ($charsets[$upcontext['charset_detected']] !== 'utf8')
3007 3174
 			{
3008
-				if ($command_line)
3009
-					echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3175
+				if ($command_line) {
3176
+									echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
3177
+				}
3010 3178
 
3011 3179
 				$smcFunc['db_query']('', '
3012 3180
 					ALTER TABLE {raw:table_name}
@@ -3016,12 +3184,14 @@  discard block
 block discarded – undo
3016 3184
 					)
3017 3185
 				);
3018 3186
 
3019
-				if ($command_line)
3020
-					echo " done.\n";
3187
+				if ($command_line) {
3188
+									echo " done.\n";
3189
+				}
3021 3190
 			}
3022 3191
 			// If this is XML to keep it nice for the user do one table at a time anyway!
3023
-			if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count'])
3024
-				return upgradeExit();
3192
+			if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) {
3193
+							return upgradeExit();
3194
+			}
3025 3195
 		}
3026 3196
 
3027 3197
 		$prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']];
@@ -3050,8 +3220,8 @@  discard block
 block discarded – undo
3050 3220
 		);
3051 3221
 		while ($row = $smcFunc['db_fetch_assoc']($request))
3052 3222
 		{
3053
-			if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1)
3054
-				$smcFunc['db_query']('', '
3223
+			if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) {
3224
+							$smcFunc['db_query']('', '
3055 3225
 					UPDATE {db_prefix}log_actions
3056 3226
 					SET extra = {string:extra}
3057 3227
 					WHERE id_action = {int:current_action}',
@@ -3060,6 +3230,7 @@  discard block
 block discarded – undo
3060 3230
 						'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4],
3061 3231
 					)
3062 3232
 				);
3233
+			}
3063 3234
 		}
3064 3235
 		$smcFunc['db_free_result']($request);
3065 3236
 
@@ -3081,15 +3252,17 @@  discard block
 block discarded – undo
3081 3252
 	// First thing's first - did we already do this?
3082 3253
 	if (!empty($modSettings['json_done']))
3083 3254
 	{
3084
-		if ($command_line)
3085
-			return DeleteUpgrade();
3086
-		else
3087
-			return true;
3255
+		if ($command_line) {
3256
+					return DeleteUpgrade();
3257
+		} else {
3258
+					return true;
3259
+		}
3088 3260
 	}
3089 3261
 
3090 3262
 	// Done it already - js wise?
3091
-	if (!empty($_POST['json_done']))
3092
-		return true;
3263
+	if (!empty($_POST['json_done'])) {
3264
+			return true;
3265
+	}
3093 3266
 
3094 3267
 	// List of tables affected by this function
3095 3268
 	// name => array('key', col1[,col2|true[,col3]])
@@ -3121,12 +3294,14 @@  discard block
 block discarded – undo
3121 3294
 	$upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0];
3122 3295
 	$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
3123 3296
 
3124
-	foreach ($keys as $id => $table)
3125
-		if ($id < $_GET['substep'])
3297
+	foreach ($keys as $id => $table) {
3298
+			if ($id < $_GET['substep'])
3126 3299
 			$upcontext['previous_tables'][] = $table;
3300
+	}
3127 3301
 
3128
-	if ($command_line)
3129
-		echo 'Converting data from serialize() to json_encode().';
3302
+	if ($command_line) {
3303
+			echo 'Converting data from serialize() to json_encode().';
3304
+	}
3130 3305
 
3131 3306
 	if (!$support_js || isset($_GET['xml']))
3132 3307
 	{
@@ -3166,8 +3341,9 @@  discard block
 block discarded – undo
3166 3341
 
3167 3342
 				// Loop through and fix these...
3168 3343
 				$new_settings = array();
3169
-				if ($command_line)
3170
-					echo "\n" . 'Fixing some settings...';
3344
+				if ($command_line) {
3345
+									echo "\n" . 'Fixing some settings...';
3346
+				}
3171 3347
 
3172 3348
 				foreach ($serialized_settings as $var)
3173 3349
 				{
@@ -3175,22 +3351,24 @@  discard block
 block discarded – undo
3175 3351
 					{
3176 3352
 						// Attempt to unserialize the setting
3177 3353
 						$temp = @safe_unserialize($modSettings[$var]);
3178
-						if (!$temp && $command_line)
3179
-							echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3180
-						elseif ($temp !== false)
3181
-							$new_settings[$var] = json_encode($temp);
3354
+						if (!$temp && $command_line) {
3355
+													echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
3356
+						} elseif ($temp !== false) {
3357
+													$new_settings[$var] = json_encode($temp);
3358
+						}
3182 3359
 					}
3183 3360
 				}
3184 3361
 
3185 3362
 				// Update everything at once
3186
-				if (!function_exists('cache_put_data'))
3187
-					require_once($sourcedir . '/Load.php');
3363
+				if (!function_exists('cache_put_data')) {
3364
+									require_once($sourcedir . '/Load.php');
3365
+				}
3188 3366
 				updateSettings($new_settings, true);
3189 3367
 
3190
-				if ($command_line)
3191
-					echo ' done.';
3192
-			}
3193
-			elseif ($table == 'themes')
3368
+				if ($command_line) {
3369
+									echo ' done.';
3370
+				}
3371
+			} elseif ($table == 'themes')
3194 3372
 			{
3195 3373
 				// Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point...
3196 3374
 				$query = $smcFunc['db_query']('', '
@@ -3209,10 +3387,11 @@  discard block
 block discarded – undo
3209 3387
 
3210 3388
 						if ($command_line)
3211 3389
 						{
3212
-							if ($temp === false)
3213
-								echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3214
-							else
3215
-								echo "\n" . 'Fixing admin preferences...';
3390
+							if ($temp === false) {
3391
+															echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
3392
+							} else {
3393
+															echo "\n" . 'Fixing admin preferences...';
3394
+							}
3216 3395
 						}
3217 3396
 
3218 3397
 						if ($temp !== false)
@@ -3234,15 +3413,15 @@  discard block
 block discarded – undo
3234 3413
 								)
3235 3414
 							);
3236 3415
 
3237
-							if ($command_line)
3238
-								echo ' done.';
3416
+							if ($command_line) {
3417
+															echo ' done.';
3418
+							}
3239 3419
 						}
3240 3420
 					}
3241 3421
 
3242 3422
 					$smcFunc['db_free_result']($query);
3243 3423
 				}
3244
-			}
3245
-			else
3424
+			} else
3246 3425
 			{
3247 3426
 				// First item is always the key...
3248 3427
 				$key = $info[0];
@@ -3253,8 +3432,7 @@  discard block
 block discarded – undo
3253 3432
 				{
3254 3433
 					$col_select = $info[1];
3255 3434
 					$where = ' WHERE ' . $info[1] . ' != {empty}';
3256
-				}
3257
-				else
3435
+				} else
3258 3436
 				{
3259 3437
 					$col_select = implode(', ', $info);
3260 3438
 				}
@@ -3287,8 +3465,7 @@  discard block
 block discarded – undo
3287 3465
 								if ($temp === false && $command_line)
3288 3466
 								{
3289 3467
 									echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n";
3290
-								}
3291
-								else
3468
+								} else
3292 3469
 								{
3293 3470
 									$row[$col] = json_encode($temp);
3294 3471
 
@@ -3313,16 +3490,18 @@  discard block
 block discarded – undo
3313 3490
 						}
3314 3491
 					}
3315 3492
 
3316
-					if ($command_line)
3317
-						echo ' done.';
3493
+					if ($command_line) {
3494
+											echo ' done.';
3495
+					}
3318 3496
 
3319 3497
 					// Free up some memory...
3320 3498
 					$smcFunc['db_free_result']($query);
3321 3499
 				}
3322 3500
 			}
3323 3501
 			// If this is XML to keep it nice for the user do one table at a time anyway!
3324
-			if (isset($_GET['xml']))
3325
-				return upgradeExit();
3502
+			if (isset($_GET['xml'])) {
3503
+							return upgradeExit();
3504
+			}
3326 3505
 		}
3327 3506
 
3328 3507
 		if ($command_line)
@@ -3337,8 +3516,9 @@  discard block
 block discarded – undo
3337 3516
 
3338 3517
 		$_GET['substep'] = 0;
3339 3518
 		// Make sure we move on!
3340
-		if ($command_line)
3341
-			return DeleteUpgrade();
3519
+		if ($command_line) {
3520
+					return DeleteUpgrade();
3521
+		}
3342 3522
 
3343 3523
 		return true;
3344 3524
 	}
@@ -3395,14 +3575,16 @@  discard block
 block discarded – undo
3395 3575
 	global $upcontext, $txt, $settings;
3396 3576
 
3397 3577
 	// Don't call me twice!
3398
-	if (!empty($upcontext['chmod_called']))
3399
-		return;
3578
+	if (!empty($upcontext['chmod_called'])) {
3579
+			return;
3580
+	}
3400 3581
 
3401 3582
 	$upcontext['chmod_called'] = true;
3402 3583
 
3403 3584
 	// Nothing?
3404
-	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error']))
3405
-		return;
3585
+	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) {
3586
+			return;
3587
+	}
3406 3588
 
3407 3589
 	// Was it a problem with Windows?
3408 3590
 	if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess')
@@ -3434,11 +3616,12 @@  discard block
 block discarded – undo
3434 3616
 					content.write(\'<div class="windowbg description">\n\t\t\t<h4>', $txt['upgrade_ftp_files'], '</h4>\n\t\t\t\');
3435 3617
 					content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');';
3436 3618
 
3437
-	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux')
3438
-		echo '
3619
+	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') {
3620
+			echo '
3439 3621
 					content.write(\'<hr>\n\t\t\t\');
3440 3622
 					content.write(\'<p>', $txt['upgrade_ftp_shell'], '</p>\n\t\t\t\');
3441 3623
 					content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');';
3624
+	}
3442 3625
 
3443 3626
 	echo '
3444 3627
 					content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\');
@@ -3446,17 +3629,19 @@  discard block
 block discarded – undo
3446 3629
 				}
3447 3630
 			</script>';
3448 3631
 
3449
-	if (!empty($upcontext['chmod']['ftp_error']))
3450
-		echo '
3632
+	if (!empty($upcontext['chmod']['ftp_error'])) {
3633
+			echo '
3451 3634
 			<div class="error_message red">
3452 3635
 				', $txt['upgrade_ftp_error'], '<br><br>
3453 3636
 				<code>', $upcontext['chmod']['ftp_error'], '</code>
3454 3637
 			</div>
3455 3638
 			<br>';
3639
+	}
3456 3640
 
3457
-	if (empty($upcontext['chmod_in_form']))
3458
-		echo '
3641
+	if (empty($upcontext['chmod_in_form'])) {
3642
+			echo '
3459 3643
 	<form action="', $upcontext['form_url'], '" method="post">';
3644
+	}
3460 3645
 
3461 3646
 	echo '
3462 3647
 		<table width="520" border="0" align="center" style="margin-bottom: 1ex;">
@@ -3493,10 +3678,11 @@  discard block
 block discarded – undo
3493 3678
 		<div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button"></div>
3494 3679
 	</div>';
3495 3680
 
3496
-	if (empty($upcontext['chmod_in_form']))
3497
-		echo '
3681
+	if (empty($upcontext['chmod_in_form'])) {
3682
+			echo '
3498 3683
 	</form>';
3499
-}
3684
+	}
3685
+	}
3500 3686
 
3501 3687
 function template_upgrade_above()
3502 3688
 {
@@ -3556,9 +3742,10 @@  discard block
 block discarded – undo
3556 3742
 					<h2>', $txt['upgrade_progress'], '</h2>
3557 3743
 					<ul>';
3558 3744
 
3559
-	foreach ($upcontext['steps'] as $num => $step)
3560
-		echo '
3745
+	foreach ($upcontext['steps'] as $num => $step) {
3746
+			echo '
3561 3747
 						<li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
3748
+	}
3562 3749
 
3563 3750
 	echo '
3564 3751
 					</ul>
@@ -3571,8 +3758,8 @@  discard block
 block discarded – undo
3571 3758
 					</div>
3572 3759
 				</div>';
3573 3760
 
3574
-	if (isset($upcontext['step_progress']))
3575
-		echo '
3761
+	if (isset($upcontext['step_progress'])) {
3762
+			echo '
3576 3763
 				<br>
3577 3764
 				<br>
3578 3765
 				<div id="progress_bar_step">
@@ -3581,6 +3768,7 @@  discard block
 block discarded – undo
3581 3768
 						<span>', $txt['upgrade_step_progress'], '</span>
3582 3769
 					</div>
3583 3770
 				</div>';
3771
+	}
3584 3772
 
3585 3773
 	echo '
3586 3774
 				<div id="substep_bar_div" class="smalltext" style="float: left;width: 50%;margin-top: 0.6em;display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', ':</div>
@@ -3611,32 +3799,36 @@  discard block
 block discarded – undo
3611 3799
 {
3612 3800
 	global $upcontext, $txt;
3613 3801
 
3614
-	if (!empty($upcontext['pause']))
3615
-		echo '
3802
+	if (!empty($upcontext['pause'])) {
3803
+			echo '
3616 3804
 						<em>', $txt['upgrade_incomplete'], '.</em><br>
3617 3805
 
3618 3806
 						<h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2>
3619 3807
 						<h3>
3620 3808
 							', $txt['upgrade_paused_overload'], '
3621 3809
 						</h3>';
3810
+	}
3622 3811
 
3623
-	if (!empty($upcontext['custom_warning']))
3624
-		echo '
3812
+	if (!empty($upcontext['custom_warning'])) {
3813
+			echo '
3625 3814
 						<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3626 3815
 							<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3627 3816
 							<strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br>
3628 3817
 							<div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div>
3629 3818
 						</div>';
3819
+	}
3630 3820
 
3631 3821
 	echo '
3632 3822
 						<div class="righttext" style="margin: 1ex;">';
3633 3823
 
3634
-	if (!empty($upcontext['continue']))
3635
-		echo '
3824
+	if (!empty($upcontext['continue'])) {
3825
+			echo '
3636 3826
 						<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">';
3637
-	if (!empty($upcontext['skip']))
3638
-		echo '
3827
+	}
3828
+	if (!empty($upcontext['skip'])) {
3829
+			echo '
3639 3830
 						<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">';
3831
+	}
3640 3832
 
3641 3833
 	echo '
3642 3834
 					</div>
@@ -3687,11 +3879,12 @@  discard block
 block discarded – undo
3687 3879
 	echo '<', '?xml version="1.0" encoding="UTF-8"?', '>
3688 3880
 	<smf>';
3689 3881
 
3690
-	if (!empty($upcontext['get_data']))
3691
-		foreach ($upcontext['get_data'] as $k => $v)
3882
+	if (!empty($upcontext['get_data'])) {
3883
+			foreach ($upcontext['get_data'] as $k => $v)
3692 3884
 			echo '
3693 3885
 		<get key="', $k, '">', $v, '</get>';
3694
-}
3886
+	}
3887
+	}
3695 3888
 
3696 3889
 function template_xml_below()
3697 3890
 {
@@ -3733,8 +3926,8 @@  discard block
 block discarded – undo
3733 3926
 	template_chmod();
3734 3927
 
3735 3928
 	// For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade!
3736
-	if ($upcontext['is_large_forum'])
3737
-		echo '
3929
+	if ($upcontext['is_large_forum']) {
3930
+			echo '
3738 3931
 					<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3739 3932
 						<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3740 3933
 						<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -3742,10 +3935,11 @@  discard block
 block discarded – undo
3742 3935
 							', $txt['upgrade_warning_lots_data'], '
3743 3936
 						</div>
3744 3937
 					</div>';
3938
+	}
3745 3939
 
3746 3940
 	// A warning message?
3747
-	if (!empty($upcontext['warning']))
3748
-		echo '
3941
+	if (!empty($upcontext['warning'])) {
3942
+			echo '
3749 3943
 					<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
3750 3944
 						<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3751 3945
 						<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -3753,6 +3947,7 @@  discard block
 block discarded – undo
3753 3947
 							', $upcontext['warning'], '
3754 3948
 						</div>
3755 3949
 					</div>';
3950
+	}
3756 3951
 
3757 3952
 	// Paths are incorrect?
3758 3953
 	echo '
@@ -3768,20 +3963,22 @@  discard block
 block discarded – undo
3768 3963
 	if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600))
3769 3964
 	{
3770 3965
 		$ago = time() - $upcontext['started'];
3771
-		if ($ago < 60)
3772
-			$ago = $ago . ' seconds';
3773
-		elseif ($ago < 3600)
3774
-			$ago = (int) ($ago / 60) . ' minutes';
3775
-		else
3776
-			$ago = (int) ($ago / 3600) . ' hours';
3966
+		if ($ago < 60) {
3967
+					$ago = $ago . ' seconds';
3968
+		} elseif ($ago < 3600) {
3969
+					$ago = (int) ($ago / 60) . ' minutes';
3970
+		} else {
3971
+					$ago = (int) ($ago / 3600) . ' hours';
3972
+		}
3777 3973
 
3778 3974
 		$active = time() - $upcontext['updated'];
3779
-		if ($active < 60)
3780
-			$updated = $active . ' seconds';
3781
-		elseif ($active < 3600)
3782
-			$updated = (int) ($active / 60) . ' minutes';
3783
-		else
3784
-			$updated = (int) ($active / 3600) . ' hours';
3975
+		if ($active < 60) {
3976
+					$updated = $active . ' seconds';
3977
+		} elseif ($active < 3600) {
3978
+					$updated = (int) ($active / 60) . ' minutes';
3979
+		} else {
3980
+					$updated = (int) ($active / 3600) . ' hours';
3981
+		}
3785 3982
 
3786 3983
 		echo '
3787 3984
 					<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
@@ -3790,16 +3987,18 @@  discard block
 block discarded – undo
3790 3987
 						<div style="padding-left: 6ex;">
3791 3988
 							&quot;', $upcontext['user']['name'], '&quot; has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.';
3792 3989
 
3793
-		if ($active < 600)
3794
-			echo '
3990
+		if ($active < 600) {
3991
+					echo '
3795 3992
 						', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], '';
3993
+		}
3796 3994
 
3797
-		if ($active > $upcontext['inactive_timeout'])
3798
-			echo '
3995
+		if ($active > $upcontext['inactive_timeout']) {
3996
+					echo '
3799 3997
 						<br><br>',$txt['upgrade_run'], '';
3800
-		else
3801
-			echo '
3998
+		} else {
3999
+					echo '
3802 4000
 						<br><br>', $txt['upgrade_script_timeout'], ' ', $upcontext['user']['name'], ' ', $txt['upgrade_script_timeout2'], ' ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!');
4001
+		}
3803 4002
 
3804 4003
 		echo '
3805 4004
 						</div>
@@ -3815,9 +4014,10 @@  discard block
 block discarded – undo
3815 4014
 							<td>
3816 4015
 								<input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>';
3817 4016
 
3818
-	if (!empty($upcontext['username_incorrect']))
3819
-		echo '
4017
+	if (!empty($upcontext['username_incorrect'])) {
4018
+			echo '
3820 4019
 								<div class="smalltext" style="color: red;">', $txt['upgrade_wrong_username'], '</div>';
4020
+	}
3821 4021
 
3822 4022
 	echo '
3823 4023
 							</td>
@@ -3828,9 +4028,10 @@  discard block
 block discarded – undo
3828 4028
 								<input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '>
3829 4029
 								<input type="hidden" name="hash_passwrd" value="">';
3830 4030
 
3831
-	if (!empty($upcontext['password_failed']))
3832
-		echo '
4031
+	if (!empty($upcontext['password_failed'])) {
4032
+			echo '
3833 4033
 								<div class="smalltext" style="color: red;">', $txt['upgrade_wrong_password'], '</div>';
4034
+	}
3834 4035
 
3835 4036
 	echo '
3836 4037
 							</td>
@@ -3902,8 +4103,8 @@  discard block
 block discarded – undo
3902 4103
 				<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">';
3903 4104
 
3904 4105
 	// Warning message?
3905
-	if (!empty($upcontext['upgrade_options_warning']))
3906
-		echo '
4106
+	if (!empty($upcontext['upgrade_options_warning'])) {
4107
+			echo '
3907 4108
 				<div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;">
3908 4109
 					<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
3909 4110
 					<strong style="text-decoration: underline;">Warning!</strong><br>
@@ -3911,6 +4112,7 @@  discard block
 block discarded – undo
3911 4112
 						', $upcontext['upgrade_options_warning'], '
3912 4113
 					</div>
3913 4114
 				</div>';
4115
+	}
3914 4116
 
3915 4117
 	echo '
3916 4118
 				<table>
@@ -3953,8 +4155,8 @@  discard block
 block discarded – undo
3953 4155
 						</td>
3954 4156
 					</tr>';
3955 4157
 
3956
-	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad']))
3957
-		echo '
4158
+	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) {
4159
+			echo '
3958 4160
 					<tr valign="top">
3959 4161
 						<td width="2%">
3960 4162
 							<input type="checkbox" name="delete_karma" id="delete_karma" value="1">
@@ -3963,6 +4165,7 @@  discard block
 block discarded – undo
3963 4165
 							<label for="delete_karma">', $txt['upgrade_delete_karma'], '</label>
3964 4166
 						</td>
3965 4167
 					</tr>';
4168
+	}
3966 4169
 
3967 4170
 	echo '
3968 4171
 					<tr valign="top">
@@ -4000,10 +4203,11 @@  discard block
 block discarded – undo
4000 4203
 					</div>';
4001 4204
 
4002 4205
 	// Dont any tables so far?
4003
-	if (!empty($upcontext['previous_tables']))
4004
-		foreach ($upcontext['previous_tables'] as $table)
4206
+	if (!empty($upcontext['previous_tables'])) {
4207
+			foreach ($upcontext['previous_tables'] as $table)
4005 4208
 			echo '
4006 4209
 					<br>', $txt['upgrade_completed_table'], ' &quot;', $table, '&quot;.';
4210
+	}
4007 4211
 
4008 4212
 	echo '
4009 4213
 					<h3 id="current_tab_div">', $txt['upgrade_current_table'], ' &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
@@ -4041,12 +4245,13 @@  discard block
 block discarded – undo
4041 4245
 							updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4042 4246
 
4043 4247
 		// If debug flood the screen.
4044
-		if ($is_debug)
4045
-			echo '
4248
+		if ($is_debug) {
4249
+					echo '
4046 4250
 							setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4047 4251
 
4048 4252
 							if (document.getElementById(\'debug_section\').scrollHeight)
4049 4253
 								document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4254
+		}
4050 4255
 
4051 4256
 		echo '
4052 4257
 							// Get the next update...
@@ -4079,8 +4284,9 @@  discard block
 block discarded – undo
4079 4284
 {
4080 4285
 	global $upcontext, $support_js, $is_debug, $timeLimitThreshold, $txt;
4081 4286
 
4082
-	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug']))
4083
-		$is_debug = true;
4287
+	if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) {
4288
+			$is_debug = true;
4289
+	}
4084 4290
 
4085 4291
 	echo '
4086 4292
 				<h3>', $txt['upgrade_db_changes'], '</h3>
@@ -4095,8 +4301,9 @@  discard block
 block discarded – undo
4095 4301
 	{
4096 4302
 		foreach ($upcontext['actioned_items'] as $num => $item)
4097 4303
 		{
4098
-			if ($num != 0)
4099
-				echo ' Successful!';
4304
+			if ($num != 0) {
4305
+							echo ' Successful!';
4306
+			}
4100 4307
 			echo '<br>' . $item;
4101 4308
 		}
4102 4309
 		if (!empty($upcontext['changes_complete']))
@@ -4109,29 +4316,33 @@  discard block
 block discarded – undo
4109 4316
 				$seconds = intval($active % 60);
4110 4317
 
4111 4318
 				$totalTime = '';
4112
-				if ($hours > 0)
4113
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4114
-				if ($minutes > 0)
4115
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4116
-				if ($seconds > 0)
4117
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4319
+				if ($hours > 0) {
4320
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4321
+				}
4322
+				if ($minutes > 0) {
4323
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4324
+				}
4325
+				if ($seconds > 0) {
4326
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4327
+				}
4118 4328
 			}
4119 4329
 
4120
-			if ($is_debug && !empty($totalTime))
4121
-				echo ' Successful! Completed in ', $totalTime, '<br><br>';
4122
-			else
4123
-				echo ' Successful!<br><br>';
4330
+			if ($is_debug && !empty($totalTime)) {
4331
+							echo ' Successful! Completed in ', $totalTime, '<br><br>';
4332
+			} else {
4333
+							echo ' Successful!<br><br>';
4334
+			}
4124 4335
 
4125 4336
 			echo '
4126 4337
 					<span id="commess" style="font-weight: bold;">', $txt['upgrade_db_complete'], '</span><br>';
4127 4338
 		}
4128
-	}
4129
-	else
4339
+	} else
4130 4340
 	{
4131 4341
 		// Tell them how many files we have in total.
4132
-		if ($upcontext['file_count'] > 1)
4133
-			echo '
4342
+		if ($upcontext['file_count'] > 1) {
4343
+					echo '
4134 4344
 					<strong id="info1">', $txt['upgrade_script'], ' <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>';
4345
+		}
4135 4346
 
4136 4347
 		echo '
4137 4348
 					<h3 id="info2"><strong>', $txt['upgrade_executing'], '</strong> &quot;<span id="cur_item_name">', $upcontext['current_item_name'], '</span>&quot; (<span id="item_num">', $upcontext['current_item_num'], '</span> ', $txt['upgrade_of'], ' <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3>
@@ -4148,20 +4359,24 @@  discard block
 block discarded – undo
4148 4359
 				$seconds = intval($active % 60);
4149 4360
 
4150 4361
 				$totalTime = '';
4151
-				if ($hours > 0)
4152
-					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4153
-				if ($minutes > 0)
4154
-					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4155
-				if ($seconds > 0)
4156
-					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4362
+				if ($hours > 0) {
4363
+									$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4364
+				}
4365
+				if ($minutes > 0) {
4366
+									$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4367
+				}
4368
+				if ($seconds > 0) {
4369
+									$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4370
+				}
4157 4371
 			}
4158 4372
 
4159 4373
 			echo '
4160 4374
 					<br>
4161 4375
 					<span id="upgradeCompleted">';
4162 4376
 
4163
-			if (!empty($totalTime))
4164
-				echo 'Completed in ', $totalTime, '<br>';
4377
+			if (!empty($totalTime)) {
4378
+							echo 'Completed in ', $totalTime, '<br>';
4379
+			}
4165 4380
 
4166 4381
 			echo '
4167 4382
 					</span>
@@ -4199,9 +4414,10 @@  discard block
 block discarded – undo
4199 4414
 						var getData = "";
4200 4415
 						var debugItems = ', $upcontext['debug_items'], ';';
4201 4416
 
4202
-		if ($is_debug)
4203
-			echo '
4417
+		if ($is_debug) {
4418
+					echo '
4204 4419
 						var upgradeStartTime = ' . $upcontext['started'] . ';';
4420
+		}
4205 4421
 
4206 4422
 		echo '
4207 4423
 						function getNextItem()
@@ -4241,9 +4457,10 @@  discard block
 block discarded – undo
4241 4457
 									document.getElementById("error_block").style.display = "";
4242 4458
 									setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));';
4243 4459
 
4244
-	if ($is_debug)
4245
-		echo '
4460
+	if ($is_debug) {
4461
+			echo '
4246 4462
 									setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4463
+	}
4247 4464
 
4248 4465
 	echo '
4249 4466
 								}
@@ -4264,9 +4481,10 @@  discard block
 block discarded – undo
4264 4481
 									document.getElementById("error_block").style.display = "";
4265 4482
 									setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);';
4266 4483
 
4267
-	if ($is_debug)
4268
-		echo '
4484
+	if ($is_debug) {
4485
+			echo '
4269 4486
 									setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
4487
+	}
4270 4488
 
4271 4489
 	echo '
4272 4490
 								}
@@ -4325,8 +4543,8 @@  discard block
 block discarded – undo
4325 4543
 							if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ')
4326 4544
 							{';
4327 4545
 
4328
-		if ($is_debug)
4329
-			echo '
4546
+		if ($is_debug) {
4547
+					echo '
4330 4548
 								document.getElementById(\'debug_section\').style.display = "none";
4331 4549
 
4332 4550
 								var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue);
@@ -4344,6 +4562,7 @@  discard block
 block discarded – undo
4344 4562
 									totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : "");
4345 4563
 
4346 4564
 								setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);';
4565
+		}
4347 4566
 
4348 4567
 		echo '
4349 4568
 
@@ -4351,9 +4570,10 @@  discard block
 block discarded – undo
4351 4570
 								document.getElementById(\'contbutt\').disabled = 0;
4352 4571
 								document.getElementById(\'database_done\').value = 1;';
4353 4572
 
4354
-		if ($upcontext['file_count'] > 1)
4355
-			echo '
4573
+		if ($upcontext['file_count'] > 1) {
4574
+					echo '
4356 4575
 								document.getElementById(\'info1\').style.display = "none";';
4576
+		}
4357 4577
 
4358 4578
 		echo '
4359 4579
 								document.getElementById(\'info2\').style.display = "none";
@@ -4366,9 +4586,10 @@  discard block
 block discarded – undo
4366 4586
 								lastItem = 0;
4367 4587
 								prevFile = curFile;';
4368 4588
 
4369
-		if ($is_debug)
4370
-			echo '
4589
+		if ($is_debug) {
4590
+					echo '
4371 4591
 								setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');';
4592
+		}
4372 4593
 
4373 4594
 		echo '
4374 4595
 								getNextItem();
@@ -4376,8 +4597,8 @@  discard block
 block discarded – undo
4376 4597
 							}';
4377 4598
 
4378 4599
 		// If debug scroll the screen.
4379
-		if ($is_debug)
4380
-			echo '
4600
+		if ($is_debug) {
4601
+					echo '
4381 4602
 							if (iLastSubStepProgress == -1)
4382 4603
 							{
4383 4604
 								// Give it consistent dots.
@@ -4396,6 +4617,7 @@  discard block
 block discarded – undo
4396 4617
 
4397 4618
 							if (document.getElementById(\'debug_section\').scrollHeight)
4398 4619
 								document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4620
+		}
4399 4621
 
4400 4622
 		echo '
4401 4623
 							// Update the page.
@@ -4456,9 +4678,10 @@  discard block
 block discarded – undo
4456 4678
 						}';
4457 4679
 
4458 4680
 		// Start things off assuming we've not errored.
4459
-		if (empty($upcontext['error_message']))
4460
-			echo '
4681
+		if (empty($upcontext['error_message'])) {
4682
+					echo '
4461 4683
 						getNextItem();';
4684
+		}
4462 4685
 
4463 4686
 		echo '
4464 4687
 					//# sourceURL=dynamicScript-dbch.js
@@ -4476,18 +4699,21 @@  discard block
 block discarded – undo
4476 4699
 	<item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item>
4477 4700
 	<debug num="', $upcontext['current_debug_item_num'], '" percent="', isset($upcontext['substep_progress']) ? $upcontext['substep_progress'] : '-1', '" complete="', empty($upcontext['completed_step']) ? 0 : 1, '">', $upcontext['current_debug_item_name'], '</debug>';
4478 4701
 
4479
-	if (!empty($upcontext['error_message']))
4480
-		echo '
4702
+	if (!empty($upcontext['error_message'])) {
4703
+			echo '
4481 4704
 	<error>', $upcontext['error_message'], '</error>';
4705
+	}
4482 4706
 
4483
-	if (!empty($upcontext['error_string']))
4484
-		echo '
4707
+	if (!empty($upcontext['error_string'])) {
4708
+			echo '
4485 4709
 	<sql>', $upcontext['error_string'], '</sql>';
4710
+	}
4486 4711
 
4487
-	if ($is_debug)
4488
-		echo '
4712
+	if ($is_debug) {
4713
+			echo '
4489 4714
 	<curtime>', time(), '</curtime>';
4490
-}
4715
+	}
4716
+	}
4491 4717
 
4492 4718
 // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications....
4493 4719
 function template_convert_utf8()
@@ -4504,18 +4730,20 @@  discard block
 block discarded – undo
4504 4730
 					</div>';
4505 4731
 
4506 4732
 	// Done any tables so far?
4507
-	if (!empty($upcontext['previous_tables']))
4508
-		foreach ($upcontext['previous_tables'] as $table)
4733
+	if (!empty($upcontext['previous_tables'])) {
4734
+			foreach ($upcontext['previous_tables'] as $table)
4509 4735
 			echo '
4510 4736
 					<br>', $txt['upgrade_completed_table'], ' &quot;', $table, '&quot;.';
4737
+	}
4511 4738
 
4512 4739
 	echo '
4513 4740
 					<h3 id="current_tab_div">', $txt['upgrade_current_table'], ' &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>';
4514 4741
 
4515 4742
 	// If we dropped their index, let's let them know
4516
-	if ($upcontext['dropping_index'])
4517
-		echo '
4743
+	if ($upcontext['dropping_index']) {
4744
+			echo '
4518 4745
 					<br><span id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_fulltext'], '</span>';
4746
+	}
4519 4747
 
4520 4748
 	// Completion notification
4521 4749
 	echo '
@@ -4552,12 +4780,13 @@  discard block
 block discarded – undo
4552 4780
 							updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4553 4781
 
4554 4782
 		// If debug flood the screen.
4555
-		if ($is_debug)
4556
-			echo '
4783
+		if ($is_debug) {
4784
+					echo '
4557 4785
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4558 4786
 
4559 4787
 						if (document.getElementById(\'debug_section\').scrollHeight)
4560 4788
 							document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4789
+		}
4561 4790
 
4562 4791
 		echo '
4563 4792
 						// Get the next update...
@@ -4603,19 +4832,21 @@  discard block
 block discarded – undo
4603 4832
 					</div>';
4604 4833
 
4605 4834
 	// Dont any tables so far?
4606
-	if (!empty($upcontext['previous_tables']))
4607
-		foreach ($upcontext['previous_tables'] as $table)
4835
+	if (!empty($upcontext['previous_tables'])) {
4836
+			foreach ($upcontext['previous_tables'] as $table)
4608 4837
 			echo '
4609 4838
 					<br>', $txt['upgrade_completed_table'], ' &quot;', $table, '&quot;.';
4839
+	}
4610 4840
 
4611 4841
 	echo '
4612 4842
 					<h3 id="current_tab_div">', $txt['upgrade_current_table'], ' &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
4613 4843
 					<br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_json_completed'], '</span>';
4614 4844
 
4615 4845
 	// Try to make sure substep was reset.
4616
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'])
4617
-		echo '
4846
+	if ($upcontext['cur_table_num'] == $upcontext['table_count']) {
4847
+			echo '
4618 4848
 					<input type="hidden" name="substep" id="substep" value="0">';
4849
+	}
4619 4850
 
4620 4851
 	// Continue please!
4621 4852
 	$upcontext['continue'] = $support_js ? 2 : 1;
@@ -4648,12 +4879,13 @@  discard block
 block discarded – undo
4648 4879
 							updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
4649 4880
 
4650 4881
 		// If debug flood the screen.
4651
-		if ($is_debug)
4652
-			echo '
4882
+		if ($is_debug) {
4883
+					echo '
4653 4884
 							setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>', $txt['upgrade_completed_table'], ' &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
4654 4885
 
4655 4886
 							if (document.getElementById(\'debug_section\').scrollHeight)
4656 4887
 								document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
4888
+		}
4657 4889
 
4658 4890
 		echo '
4659 4891
 							// Get the next update...
@@ -4689,8 +4921,8 @@  discard block
 block discarded – undo
4689 4921
 				<h3>', $txt['upgrade_done'], ' <a href="', $boardurl, '/index.php">', $txt['upgrade_done2'], '</a>.  ', $txt['upgrade_done3'], '</h3>
4690 4922
 				<form action="', $boardurl, '/index.php">';
4691 4923
 
4692
-	if (!empty($upcontext['can_delete_script']))
4693
-		echo '
4924
+	if (!empty($upcontext['can_delete_script'])) {
4925
+			echo '
4694 4926
 					<label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> ', $txt['upgrade_delete_now'], '</label> <em>', $txt['upgrade_delete_server'], '</em>
4695 4927
 					<script>
4696 4928
 						function doTheDelete(theCheck)
@@ -4701,6 +4933,7 @@  discard block
 block discarded – undo
4701 4933
 						}
4702 4934
 					</script>
4703 4935
 					<img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>';
4936
+	}
4704 4937
 
4705 4938
 	$active = time() - $upcontext['started'];
4706 4939
 	$hours = floor($active / 3600);
@@ -4710,17 +4943,21 @@  discard block
 block discarded – undo
4710 4943
 	if ($is_debug)
4711 4944
 	{
4712 4945
 		$totalTime = '';
4713
-		if ($hours > 0)
4714
-			$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4715
-		if ($minutes > 0)
4716
-			$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4717
-		if ($seconds > 0)
4718
-			$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4946
+		if ($hours > 0) {
4947
+					$totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ';
4948
+		}
4949
+		if ($minutes > 0) {
4950
+					$totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ';
4951
+		}
4952
+		if ($seconds > 0) {
4953
+					$totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' ';
4954
+		}
4719 4955
 	}
4720 4956
 
4721
-	if ($is_debug && !empty($totalTime))
4722
-		echo '
4957
+	if ($is_debug && !empty($totalTime)) {
4958
+			echo '
4723 4959
 					<br> ', $txt['upgrade_completed_time'], ' ', $totalTime, '<br><br>';
4960
+	}
4724 4961
 
4725 4962
 	echo '<br>
4726 4963
 					', sprintf($txt['upgrade_problems'], 'http://simplemachines.org'), '<br>
@@ -4747,8 +4984,9 @@  discard block
 block discarded – undo
4747 4984
 
4748 4985
 	$current_substep = $_GET['substep'];
4749 4986
 
4750
-	if (empty($_GET['a']))
4751
-		$_GET['a'] = 0;
4987
+	if (empty($_GET['a'])) {
4988
+			$_GET['a'] = 0;
4989
+	}
4752 4990
 	$step_progress['name'] = 'Converting ips';
4753 4991
 	$step_progress['current'] = $_GET['a'];
4754 4992
 
@@ -4791,16 +5029,19 @@  discard block
 block discarded – undo
4791 5029
 				'empty' => '',
4792 5030
 				'limit' => $limit,
4793 5031
 		));
4794
-		while ($row = $smcFunc['db_fetch_assoc']($request))
4795
-			$arIp[] = $row[$oldCol];
5032
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
5033
+					$arIp[] = $row[$oldCol];
5034
+		}
4796 5035
 		$smcFunc['db_free_result']($request);
4797 5036
 
4798 5037
 		// Special case, null ip could keep us in a loop.
4799
-		if (is_null($arIp[0]))
4800
-			unset($arIp[0]);
5038
+		if (is_null($arIp[0])) {
5039
+					unset($arIp[0]);
5040
+		}
4801 5041
 
4802
-		if (empty($arIp))
4803
-			$is_done = true;
5042
+		if (empty($arIp)) {
5043
+					$is_done = true;
5044
+		}
4804 5045
 
4805 5046
 		$updates = array();
4806 5047
 		$cases = array();
@@ -4809,16 +5050,18 @@  discard block
 block discarded – undo
4809 5050
 		{
4810 5051
 			$arIp[$i] = trim($arIp[$i]);
4811 5052
 
4812
-			if (empty($arIp[$i]))
4813
-				continue;
5053
+			if (empty($arIp[$i])) {
5054
+							continue;
5055
+			}
4814 5056
 
4815 5057
 			$updates['ip' . $i] = $arIp[$i];
4816 5058
 			$cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}';
4817 5059
 
4818 5060
 			if ($setSize > 0 && $i % $setSize === 0)
4819 5061
 			{
4820
-				if (count($updates) == 1)
4821
-					continue;
5062
+				if (count($updates) == 1) {
5063
+									continue;
5064
+				}
4822 5065
 
4823 5066
 				$updates['whereSet'] = array_values($updates);
4824 5067
 				$smcFunc['db_query']('', '
@@ -4852,8 +5095,7 @@  discard block
 block discarded – undo
4852 5095
 							'ip' => $ip
4853 5096
 					));
4854 5097
 				}
4855
-			}
4856
-			else
5098
+			} else
4857 5099
 			{
4858 5100
 				$updates['whereSet'] = array_values($updates);
4859 5101
 				$smcFunc['db_query']('', '
@@ -4867,9 +5109,9 @@  discard block
 block discarded – undo
4867 5109
 					$updates
4868 5110
 				);
4869 5111
 			}
5112
+		} else {
5113
+					$is_done = true;
4870 5114
 		}
4871
-		else
4872
-			$is_done = true;
4873 5115
 
4874 5116
 		$_GET['a'] += $limit;
4875 5117
 		$step_progress['current'] = $_GET['a'];
@@ -4895,10 +5137,11 @@  discard block
 block discarded – undo
4895 5137
 
4896 5138
 	$columns = $smcFunc['db_list_columns']($targetTable, true);
4897 5139
 
4898
-	if (isset($columns[$column]))
4899
-		return $columns[$column];
4900
-	else
4901
-		return null;
4902
-}
5140
+	if (isset($columns[$column])) {
5141
+			return $columns[$column];
5142
+	} else {
5143
+			return null;
5144
+	}
5145
+	}
4903 5146
 
4904 5147
 ?>
4905 5148
\ No newline at end of file
Please login to merge, or discard this patch.