Completed
Branch release-2.1 (4c82a0)
by Rick
15:44
created
other/install.php 3 patches
Doc Comments   +13 added lines patch added patch discarded remove patch
@@ -1732,6 +1732,9 @@  discard block
 block discarded – undo
1732 1732
 		return true;
1733 1733
 	}
1734 1734
 
1735
+	/**
1736
+	 * @param integer $chmod
1737
+	 */
1735 1738
 	function chmod($ftp_file, $chmod)
1736 1739
 	{
1737 1740
 		if (!is_resource($this->connection))
@@ -1748,6 +1751,9 @@  discard block
 block discarded – undo
1748 1751
 		return true;
1749 1752
 	}
1750 1753
 
1754
+	/**
1755
+	 * @param string $ftp_file
1756
+	 */
1751 1757
 	function unlink($ftp_file)
1752 1758
 	{
1753 1759
 		// We are actually connected, right?
@@ -1816,6 +1822,9 @@  discard block
 block discarded – undo
1816 1822
 		return true;
1817 1823
 	}
1818 1824
 
1825
+	/**
1826
+	 * @param string $ftp_file
1827
+	 */
1819 1828
 	function create_file($ftp_file)
1820 1829
 	{
1821 1830
 		// First, we have to be connected... very important.
@@ -1887,6 +1896,10 @@  discard block
 block discarded – undo
1887 1896
 		return $data;
1888 1897
 	}
1889 1898
 
1899
+	/**
1900
+	 * @param string $file
1901
+	 * @param false|string $listing
1902
+	 */
1890 1903
 	function locate($file, $listing = null)
1891 1904
 	{
1892 1905
 		if ($listing === null)
Please login to merge, or discard this patch.
Spacing   +7 added lines, -9 removed lines patch added patch discarded remove patch
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 	if (isset($_POST['db_user']))
733 733
 	{
734 734
 		$incontext['db']['user'] = $_POST['db_user'];
735
-		$incontext['db']['name'] =  $_POST['db_name'];
735
+		$incontext['db']['name'] = $_POST['db_name'];
736 736
 		$incontext['db']['server'] = $_POST['db_server'];
737 737
 		$incontext['db']['prefix'] = $_POST['db_prefix'];
738 738
 
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 			$smcFunc['db_free_result']($result);
1107 1107
 		}
1108 1108
 		
1109
-		if(isset($pg_version) && $pg_version >= 90100)
1109
+		if (isset($pg_version) && $pg_version >= 90100)
1110 1110
 			$replaces['{$unlogged}'] = 'UNLOGGED';
1111 1111
 		else
1112 1112
 			$replaces['{$unlogged}'] = '';
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 		if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false)
1153 1153
 		{
1154 1154
 			// Use the appropriate function based on the DB type
1155
-			if ($db_type == 'mysql' || $db_type =='mysqli')
1155
+			if ($db_type == 'mysql' || $db_type == 'mysqli')
1156 1156
 				$db_errorno = $db_type . '_errno';
1157 1157
 
1158 1158
 			// Error 1050: Table already exists!
@@ -1339,8 +1339,7 @@  discard block
 block discarded – undo
1339 1339
 	require_once($sourcedir . '/Subs-Auth.php');
1340 1340
 
1341 1341
 	// We need this to properly hash the password for Admin
1342
-	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1343
-		create_function('$string', '
1342
+	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : create_function('$string', '
1344 1343
 			global $sourcedir;
1345 1344
 			if (function_exists(\'mb_strtolower\'))
1346 1345
 				return mb_strtolower($string, \'UTF-8\');
@@ -1604,8 +1603,7 @@  discard block
 block discarded – undo
1604 1603
 	updateStats('topic');
1605 1604
 
1606 1605
 	// This function is needed to do the updateStats('subject') call.
1607
-	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1608
-		create_function('$string', '
1606
+	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : create_function('$string', '
1609 1607
 			global $sourcedir;
1610 1608
 			if (function_exists(\'mb_strtolower\'))
1611 1609
 				return mb_strtolower($string, \'UTF-8\');
@@ -1633,7 +1631,7 @@  discard block
 block discarded – undo
1633 1631
 	// Sanity check that they loaded earlier!
1634 1632
 	if (isset($modSettings['recycle_board']))
1635 1633
 	{
1636
-		$forum_version = $current_smf_version;  // The variable is usually defined in index.php so lets just use our variable to do it for us.
1634
+		$forum_version = $current_smf_version; // The variable is usually defined in index.php so lets just use our variable to do it for us.
1637 1635
 		scheduled_fetchSMfiles(); // Now go get those files!
1638 1636
 
1639 1637
 		// We've just installed!
@@ -2147,7 +2145,7 @@  discard block
 block discarded – undo
2147 2145
 		<title>', $txt['smf_installer'], '</title>
2148 2146
 		<link rel="stylesheet" href="Themes/default/css/index.css?alp21">
2149 2147
 		<link rel="stylesheet" href="Themes/default/css/install.css?alp21">
2150
-		', $txt['lang_rtl'] == true ? '<link rel="stylesheet" href="Themes/default/css/rtl.css?alp21">' : '' , '
2148
+		', $txt['lang_rtl'] == true ? '<link rel="stylesheet" href="Themes/default/css/rtl.css?alp21">' : '', '
2151 2149
 
2152 2150
 		<script src="Themes/default/scripts/jquery-2.1.3.min.js"></script>
2153 2151
 		<script src="Themes/default/scripts/script.js"></script>
Please login to merge, or discard this patch.
Braces   +509 added lines, -380 removed lines patch added patch discarded remove patch
@@ -128,10 +128,11 @@  discard block
 block discarded – undo
128 128
 		$incontext['skip'] = false;
129 129
 
130 130
 		// 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']++;
131
+		if (function_exists($step[2]) && $step[2]() === false) {
132
+					break;
133
+		} elseif (function_exists($step[2])) {
134
+					$incontext['current_step']++;
135
+		}
135 136
 
136 137
 		// No warnings pass on.
137 138
 		$incontext['warning'] = '';
@@ -147,12 +148,14 @@  discard block
 block discarded – undo
147 148
 	global $databases, $incontext;
148 149
 
149 150
 	// 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';
151
+	if (!isset($_SERVER['PHP_SELF'])) {
152
+			$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
153
+	}
152 154
 
153 155
 	// Turn off magic quotes runtime and enable error reporting.
154
-	if (function_exists('set_magic_quotes_runtime'))
155
-		@set_magic_quotes_runtime(0);
156
+	if (function_exists('set_magic_quotes_runtime')) {
157
+			@set_magic_quotes_runtime(0);
158
+	}
156 159
 	error_reporting(E_ALL);
157 160
 
158 161
 	// Fun.  Low PHP version...
@@ -166,21 +169,23 @@  discard block
 block discarded – undo
166 169
 	{
167 170
 		ob_start();
168 171
 
169
-		if (ini_get('session.save_handler') == 'user')
170
-			@ini_set('session.save_handler', 'files');
171
-		if (function_exists('session_start'))
172
-			@session_start();
173
-	}
174
-	else
172
+		if (ini_get('session.save_handler') == 'user') {
173
+					@ini_set('session.save_handler', 'files');
174
+		}
175
+		if (function_exists('session_start')) {
176
+					@session_start();
177
+		}
178
+	} else
175 179
 	{
176 180
 		ob_start('ob_gzhandler');
177 181
 
178
-		if (ini_get('session.save_handler') == 'user')
179
-			@ini_set('session.save_handler', 'files');
182
+		if (ini_get('session.save_handler') == 'user') {
183
+					@ini_set('session.save_handler', 'files');
184
+		}
180 185
 		session_start();
181 186
 
182
-		if (!headers_sent())
183
-			echo '<!DOCTYPE html>
187
+		if (!headers_sent()) {
188
+					echo '<!DOCTYPE html>
184 189
 <html>
185 190
 	<head>
186 191
 		<title>', htmlspecialchars($_GET['pass_string']), '</title>
@@ -189,6 +194,7 @@  discard block
 block discarded – undo
189 194
 		<strong>', htmlspecialchars($_GET['pass_string']), '</strong>
190 195
 	</body>
191 196
 </html>';
197
+		}
192 198
 		exit;
193 199
 	}
194 200
 
@@ -197,16 +203,18 @@  discard block
 block discarded – undo
197 203
 	{
198 204
 		$incontext['remote_files_available'] = false;
199 205
 		$test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1);
200
-		if ($test)
201
-			$incontext['remote_files_available'] = true;
206
+		if ($test) {
207
+					$incontext['remote_files_available'] = true;
208
+		}
202 209
 		@fclose($test);
203 210
 	}
204 211
 
205 212
 	// Add slashes, as long as they aren't already being added.
206
-	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0)
207
-		foreach ($_POST as $k => $v)
213
+	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) {
214
+			foreach ($_POST as $k => $v)
208 215
 			if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false)
209 216
 				$_POST[$k] = addslashes($v);
217
+	}
210 218
 
211 219
 	// This is really quite simple; if ?delete is on the URL, delete the installer...
212 220
 	if (isset($_GET['delete']))
@@ -227,8 +235,7 @@  discard block
 block discarded – undo
227 235
 			$ftp->close();
228 236
 
229 237
 			unset($_SESSION['installer_temp_ftp']);
230
-		}
231
-		else
238
+		} else
232 239
 		{
233 240
 			@unlink(__FILE__);
234 241
 
@@ -269,8 +276,9 @@  discard block
 block discarded – undo
269 276
 		$dir = dir(dirname(__FILE__) . '/Themes/default/languages');
270 277
 		while ($entry = $dir->read())
271 278
 		{
272
-			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php')
273
-				$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
279
+			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') {
280
+							$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
281
+			}
274 282
 		}
275 283
 		$dir->close();
276 284
 	}
@@ -305,10 +313,11 @@  discard block
 block discarded – undo
305 313
 	}
306 314
 
307 315
 	// Override the language file?
308
-	if (isset($_GET['lang_file']))
309
-		$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
310
-	elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file']))
311
-		$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_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'];
320
+	}
312 321
 
313 322
 	// Make sure it exists, if it doesn't reset it.
314 323
 	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']))
@@ -317,8 +326,9 @@  discard block
 block discarded – undo
317 326
 		list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
318 327
 
319 328
 		// If we have english and some other language, use the other language.  We Americans hate english :P.
320
-		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1)
321
-			list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
329
+		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) {
330
+					list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
331
+		}
322 332
 	}
323 333
 
324 334
 	// And now include the actual language file itself.
@@ -331,15 +341,18 @@  discard block
 block discarded – undo
331 341
 	global $db_prefix, $db_connection, $sourcedir;
332 342
 	global $smcFunc, $modSettings, $db_type, $db_name, $db_user, $db_persist;
333 343
 
334
-	if (empty($sourcedir))
335
-		$sourcedir = dirname(__FILE__) . '/Sources';
344
+	if (empty($sourcedir)) {
345
+			$sourcedir = dirname(__FILE__) . '/Sources';
346
+	}
336 347
 
337 348
 	// Need this to check whether we need the database password.
338 349
 	require(dirname(__FILE__) . '/Settings.php');
339
-	if (!defined('SMF'))
340
-		define('SMF', 1);
341
-	if (empty($smcFunc))
342
-		$smcFunc = array();
350
+	if (!defined('SMF')) {
351
+			define('SMF', 1);
352
+	}
353
+	if (empty($smcFunc)) {
354
+			$smcFunc = array();
355
+	}
343 356
 
344 357
 	$modSettings['disableQueryCheck'] = true;
345 358
 
@@ -347,8 +360,9 @@  discard block
 block discarded – undo
347 360
 	if (!$db_connection)
348 361
 	{
349 362
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
350
-		if (version_compare(PHP_VERSION, '5', '<'))
351
-			require_once($sourcedir . '/Subs-Compat.php');
363
+		if (version_compare(PHP_VERSION, '5', '<')) {
364
+					require_once($sourcedir . '/Subs-Compat.php');
365
+		}
352 366
 
353 367
 		$db_options = array('persist' => $db_persist);
354 368
 		$port = '';
@@ -359,19 +373,20 @@  discard block
 block discarded – undo
359 373
 			if ($db_type == 'mysql' || $db_type == 'mysqli')
360 374
 			{
361 375
 				$port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port'];
362
-			}
363
-			elseif ($db_type == 'postgresql')
376
+			} elseif ($db_type == 'postgresql')
364 377
 			{
365 378
 				// PostgreSQL doesn't have a default port setting in php.ini, so just check against the default
366 379
 				$port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port'];
367 380
 			}
368 381
 		}
369 382
 
370
-		if (!empty($port))
371
-			$db_options['port'] = $port;
383
+		if (!empty($port)) {
384
+					$db_options['port'] = $port;
385
+		}
372 386
 
373
-		if (!$db_connection)
374
-			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options);
387
+		if (!$db_connection) {
388
+					$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options);
389
+		}
375 390
 	}
376 391
 }
377 392
 
@@ -399,8 +414,9 @@  discard block
 block discarded – undo
399 414
 		// @todo REMOVE THIS!!
400 415
 		else
401 416
 		{
402
-			if (function_exists('doStep' . $_GET['step']))
403
-				call_user_func('doStep' . $_GET['step']);
417
+			if (function_exists('doStep' . $_GET['step'])) {
418
+							call_user_func('doStep' . $_GET['step']);
419
+			}
404 420
 		}
405 421
 		// Show the footer.
406 422
 		template_install_below();
@@ -418,8 +434,9 @@  discard block
 block discarded – undo
418 434
 	$incontext['sub_template'] = 'welcome_message';
419 435
 
420 436
 	// Done the submission?
421
-	if (isset($_POST['contbutt']))
422
-		return true;
437
+	if (isset($_POST['contbutt'])) {
438
+			return true;
439
+	}
423 440
 
424 441
 	// See if we think they have already installed it?
425 442
 	if (is_readable(dirname(__FILE__) . '/Settings.php'))
@@ -427,14 +444,17 @@  discard block
 block discarded – undo
427 444
 		$probably_installed = 0;
428 445
 		foreach (file(dirname(__FILE__) . '/Settings.php') as $line)
429 446
 		{
430
-			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line))
431
-				$probably_installed++;
432
-			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line))
433
-				$probably_installed++;
447
+			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) {
448
+							$probably_installed++;
449
+			}
450
+			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) {
451
+							$probably_installed++;
452
+			}
434 453
 		}
435 454
 
436
-		if ($probably_installed == 2)
437
-			$incontext['warning'] = $txt['error_already_installed'];
455
+		if ($probably_installed == 2) {
456
+					$incontext['warning'] = $txt['error_already_installed'];
457
+		}
438 458
 	}
439 459
 
440 460
 	// Is some database support even compiled in?
@@ -449,8 +469,7 @@  discard block
 block discarded – undo
449 469
 				$databases[$key]['supported'] = false;
450 470
 				$notFoundSQLFile = true;
451 471
 				$txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql');
452
-			}
453
-			else
472
+			} else
454 473
 			{
455 474
 				$db_type = $key;
456 475
 				$incontext['supported_databases'][] = $db;
@@ -459,29 +478,36 @@  discard block
 block discarded – undo
459 478
 	}
460 479
 
461 480
 	// Check the PHP version.
462
-	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>')))
463
-		$error = 'error_php_too_low';
481
+	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>'))) {
482
+			$error = 'error_php_too_low';
483
+	}
464 484
 	// Make sure we have a supported database
465
-	elseif (empty($incontext['supported_databases']))
466
-		$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
485
+	elseif (empty($incontext['supported_databases'])) {
486
+			$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
487
+	}
467 488
 	// How about session support?  Some crazy sysadmin remove it?
468
-	elseif (!function_exists('session_start'))
469
-		$error = 'error_session_missing';
489
+	elseif (!function_exists('session_start')) {
490
+			$error = 'error_session_missing';
491
+	}
470 492
 	// Make sure they uploaded all the files.
471
-	elseif (!file_exists(dirname(__FILE__) . '/index.php'))
472
-		$error = 'error_missing_files';
493
+	elseif (!file_exists(dirname(__FILE__) . '/index.php')) {
494
+			$error = 'error_missing_files';
495
+	}
473 496
 	// Very simple check on the session.save_path for Windows.
474 497
 	// @todo Move this down later if they don't use database-driven sessions?
475
-	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\')
476
-		$error = 'error_session_save_path';
498
+	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') {
499
+			$error = 'error_session_save_path';
500
+	}
477 501
 
478 502
 	// Since each of the three messages would look the same, anyway...
479
-	if (isset($error))
480
-		$incontext['error'] = $txt[$error];
503
+	if (isset($error)) {
504
+			$incontext['error'] = $txt[$error];
505
+	}
481 506
 
482 507
 	// Mod_security blocks everything that smells funny. Let SMF handle security.
483
-	if (!fixModSecurity() && !isset($_GET['overmodsecurity']))
484
-		$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
508
+	if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) {
509
+			$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
510
+	}
485 511
 
486 512
 	return false;
487 513
 }
@@ -505,12 +531,14 @@  discard block
 block discarded – undo
505 531
 		'Settings.php',
506 532
 		'Settings_bak.php'
507 533
 	);
508
-	foreach ($incontext['detected_languages'] as $lang => $temp)
509
-		$extra_files[] = 'Themes/default/languages/' . $lang;
534
+	foreach ($incontext['detected_languages'] as $lang => $temp) {
535
+			$extra_files[] = 'Themes/default/languages/' . $lang;
536
+	}
510 537
 
511 538
 	// With mod_security installed, we could attempt to fix it with .htaccess.
512
-	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules()))
513
-		$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
539
+	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) {
540
+			$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
541
+	}
514 542
 
515 543
 	$failed_files = array();
516 544
 
@@ -526,12 +554,14 @@  discard block
 block discarded – undo
526 554
 				@chmod(dirname(__FILE__) . '/' . $file, 0755);
527 555
 
528 556
 				// Well, 755 hopefully worked... if not, try 777.
529
-				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777))
530
-					$failed_files[] = $file;
557
+				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) {
558
+									$failed_files[] = $file;
559
+				}
531 560
 			}
532 561
 		}
533
-		foreach ($extra_files as $file)
534
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
562
+		foreach ($extra_files as $file) {
563
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
564
+		}
535 565
 	}
536 566
 	// Windows is trickier.  Let's try opening for r+...
537 567
 	else
@@ -541,30 +571,35 @@  discard block
 block discarded – undo
541 571
 		foreach ($writable_files as $file)
542 572
 		{
543 573
 			// Folders can't be opened for write... but the index.php in them can ;)
544
-			if (is_dir(dirname(__FILE__) . '/' . $file))
545
-				$file .= '/index.php';
574
+			if (is_dir(dirname(__FILE__) . '/' . $file)) {
575
+							$file .= '/index.php';
576
+			}
546 577
 
547 578
 			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
548 579
 			@chmod(dirname(__FILE__) . '/' . $file, 0777);
549 580
 			$fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+');
550 581
 
551 582
 			// Hmm, okay, try just for write in that case...
552
-			if (!is_resource($fp))
553
-				$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
583
+			if (!is_resource($fp)) {
584
+							$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
585
+			}
554 586
 
555
-			if (!is_resource($fp))
556
-				$failed_files[] = $file;
587
+			if (!is_resource($fp)) {
588
+							$failed_files[] = $file;
589
+			}
557 590
 
558 591
 			@fclose($fp);
559 592
 		}
560
-		foreach ($extra_files as $file)
561
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
593
+		foreach ($extra_files as $file) {
594
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
595
+		}
562 596
 	}
563 597
 
564 598
 	$failure = count($failed_files) >= 1;
565 599
 
566
-	if (!isset($_SERVER))
567
-		return !$failure;
600
+	if (!isset($_SERVER)) {
601
+			return !$failure;
602
+	}
568 603
 
569 604
 	// Put the list into context.
570 605
 	$incontext['failed_files'] = $failed_files;
@@ -612,19 +647,23 @@  discard block
 block discarded – undo
612 647
 
613 648
 		if (!isset($ftp) || $ftp->error !== false)
614 649
 		{
615
-			if (!isset($ftp))
616
-				$ftp = new ftp_connection(null);
650
+			if (!isset($ftp)) {
651
+							$ftp = new ftp_connection(null);
652
+			}
617 653
 			// Save the error so we can mess with listing...
618
-			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message))
619
-				$incontext['ftp_errors'][] = $ftp->last_message;
654
+			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) {
655
+							$incontext['ftp_errors'][] = $ftp->last_message;
656
+			}
620 657
 
621 658
 			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
622 659
 
623
-			if (empty($_POST['ftp_path']) && $found_path)
624
-				$_POST['ftp_path'] = $detect_path;
660
+			if (empty($_POST['ftp_path']) && $found_path) {
661
+							$_POST['ftp_path'] = $detect_path;
662
+			}
625 663
 
626
-			if (!isset($_POST['ftp_username']))
627
-				$_POST['ftp_username'] = $username;
664
+			if (!isset($_POST['ftp_username'])) {
665
+							$_POST['ftp_username'] = $username;
666
+			}
628 667
 
629 668
 			// Set the username etc, into context.
630 669
 			$incontext['ftp'] = array(
@@ -636,8 +675,7 @@  discard block
 block discarded – undo
636 675
 			);
637 676
 
638 677
 			return false;
639
-		}
640
-		else
678
+		} else
641 679
 		{
642 680
 			$_SESSION['installer_temp_ftp'] = array(
643 681
 				'server' => $_POST['ftp_server'],
@@ -651,10 +689,12 @@  discard block
 block discarded – undo
651 689
 
652 690
 			foreach ($failed_files as $file)
653 691
 			{
654
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
655
-					$ftp->chmod($file, 0755);
656
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
657
-					$ftp->chmod($file, 0777);
692
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
693
+									$ftp->chmod($file, 0755);
694
+				}
695
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
696
+									$ftp->chmod($file, 0777);
697
+				}
658 698
 				if (!is_writable(dirname(__FILE__) . '/' . $file))
659 699
 				{
660 700
 					$failed_files_updated[] = $file;
@@ -709,15 +749,17 @@  discard block
 block discarded – undo
709 749
 
710 750
 			if (!$foundOne)
711 751
 			{
712
-				if (isset($db['default_host']))
713
-					$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
752
+				if (isset($db['default_host'])) {
753
+									$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
754
+				}
714 755
 				if (isset($db['default_user']))
715 756
 				{
716 757
 					$incontext['db']['user'] = ini_get($db['default_user']);
717 758
 					$incontext['db']['name'] = ini_get($db['default_user']);
718 759
 				}
719
-				if (isset($db['default_password']))
720
-					$incontext['db']['pass'] = ini_get($db['default_password']);
760
+				if (isset($db['default_password'])) {
761
+									$incontext['db']['pass'] = ini_get($db['default_password']);
762
+				}
721 763
 
722 764
 				// For simplicity and less confusion, leave the port blank by default
723 765
 				$incontext['db']['port'] = '';
@@ -736,10 +778,10 @@  discard block
 block discarded – undo
736 778
 		$incontext['db']['server'] = $_POST['db_server'];
737 779
 		$incontext['db']['prefix'] = $_POST['db_prefix'];
738 780
 
739
-		if (!empty($_POST['db_port']))
740
-			$incontext['db']['port'] = $_POST['db_port'];
741
-	}
742
-	else
781
+		if (!empty($_POST['db_port'])) {
782
+					$incontext['db']['port'] = $_POST['db_port'];
783
+		}
784
+	} else
743 785
 	{
744 786
 		$incontext['db']['prefix'] = 'smf_';
745 787
 	}
@@ -775,10 +817,11 @@  discard block
 block discarded – undo
775 817
 		if (!empty($_POST['db_port']))
776 818
 		{
777 819
 			// For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though.
778
-			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port'))
779
-				$vars['db_port'] == (int) $_POST['db_port'];
780
-			elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432)
781
-				$vars['db_port'] == (int) $_POST['db_port'];
820
+			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) {
821
+							$vars['db_port'] == (int) $_POST['db_port'];
822
+			} elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) {
823
+							$vars['db_port'] == (int) $_POST['db_port'];
824
+			}
782 825
 		}
783 826
 
784 827
 		// God I hope it saved!
@@ -791,8 +834,9 @@  discard block
 block discarded – undo
791 834
 		// Make sure it works.
792 835
 		require(dirname(__FILE__) . '/Settings.php');
793 836
 
794
-		if (empty($sourcedir))
795
-			$sourcedir = dirname(__FILE__) . '/Sources';
837
+		if (empty($sourcedir)) {
838
+					$sourcedir = dirname(__FILE__) . '/Sources';
839
+		}
796 840
 
797 841
 		// Better find the database file!
798 842
 		if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
@@ -804,14 +848,16 @@  discard block
 block discarded – undo
804 848
 		// Now include it for database functions!
805 849
 		define('SMF', 1);
806 850
 		$modSettings['disableQueryCheck'] = true;
807
-		if (empty($smcFunc))
808
-			$smcFunc = array();
851
+		if (empty($smcFunc)) {
852
+					$smcFunc = array();
853
+		}
809 854
 
810 855
 			require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
811 856
 
812 857
 		// What - running PHP4? The shame!
813
-		if (version_compare(PHP_VERSION, '5', '<'))
814
-			require_once($sourcedir . '/Subs-Compat.php');
858
+		if (version_compare(PHP_VERSION, '5', '<')) {
859
+					require_once($sourcedir . '/Subs-Compat.php');
860
+		}
815 861
 
816 862
 		// Attempt a connection.
817 863
 		$needsDB = !empty($databases[$db_type]['always_has_db']);
@@ -899,12 +945,14 @@  discard block
 block discarded – undo
899 945
 	$incontext['page_title'] = $txt['install_settings'];
900 946
 
901 947
 	// Let's see if we got the database type correct.
902
-	if (isset($_POST['db_type'], $databases[$_POST['db_type']]))
903
-		$db_type = $_POST['db_type'];
948
+	if (isset($_POST['db_type'], $databases[$_POST['db_type']])) {
949
+			$db_type = $_POST['db_type'];
950
+	}
904 951
 
905 952
 	// Else we'd better be able to get the connection.
906
-	else
907
-		load_database();
953
+	else {
954
+			load_database();
955
+	}
908 956
 
909 957
 	$db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type;
910 958
 
@@ -924,12 +972,14 @@  discard block
 block discarded – undo
924 972
 	// Submitting?
925 973
 	if (isset($_POST['boardurl']))
926 974
 	{
927
-		if (substr($_POST['boardurl'], -10) == '/index.php')
928
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
929
-		elseif (substr($_POST['boardurl'], -1) == '/')
930
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
931
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
932
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
975
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
976
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
977
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
978
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
979
+		}
980
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
981
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
982
+		}
933 983
 
934 984
 		// Save these variables.
935 985
 		$vars = array(
@@ -960,10 +1010,10 @@  discard block
 block discarded – undo
960 1010
 			{
961 1011
 				$incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']);
962 1012
 				return false;
963
-			}
964
-			else
965
-				// Set the character set here.
1013
+			} else {
1014
+							// Set the character set here.
966 1015
 				updateSettingsFile(array('db_character_set' => 'utf8'));
1016
+			}
967 1017
 		}
968 1018
 
969 1019
 		// Good, skip on.
@@ -983,8 +1033,9 @@  discard block
 block discarded – undo
983 1033
 	$incontext['continue'] = 1;
984 1034
 
985 1035
 	// Already done?
986
-	if (isset($_POST['pop_done']))
987
-		return true;
1036
+	if (isset($_POST['pop_done'])) {
1037
+			return true;
1038
+	}
988 1039
 
989 1040
 	// Reload settings.
990 1041
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1002,8 +1053,9 @@  discard block
 block discarded – undo
1002 1053
 	$modSettings = array();
1003 1054
 	if ($result !== false)
1004 1055
 	{
1005
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1006
-			$modSettings[$row['variable']] = $row['value'];
1056
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1057
+					$modSettings[$row['variable']] = $row['value'];
1058
+		}
1007 1059
 		$smcFunc['db_free_result']($result);
1008 1060
 
1009 1061
 		// Do they match?  If so, this is just a refresh so charge on!
@@ -1016,20 +1068,22 @@  discard block
 block discarded – undo
1016 1068
 	$modSettings['disableQueryCheck'] = true;
1017 1069
 
1018 1070
 	// If doing UTF8, select it. PostgreSQL requires passing it as a string...
1019
-	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support']))
1020
-		$smcFunc['db_query']('', '
1071
+	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) {
1072
+			$smcFunc['db_query']('', '
1021 1073
 			SET NAMES {'. ($db_type == 'postgresql' ? 'string' : 'raw') . ':utf8}',
1022 1074
 			array(
1023 1075
 				'db_error_skip' => true,
1024 1076
 				'utf8' => 'utf8',
1025 1077
 			)
1026 1078
 		);
1079
+	}
1027 1080
 
1028 1081
 	// Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments...
1029
-	if (substr(__DIR__, -1) == '\\')
1030
-		$attachdir = __DIR__ . 'attachments';
1031
-	else
1032
-		$attachdir = __DIR__ . '/attachments';
1082
+	if (substr(__DIR__, -1) == '\\') {
1083
+			$attachdir = __DIR__ . 'attachments';
1084
+	} else {
1085
+			$attachdir = __DIR__ . '/attachments';
1086
+	}
1033 1087
 
1034 1088
 	$replaces = array(
1035 1089
 		'{$db_prefix}' => $db_prefix,
@@ -1046,8 +1100,9 @@  discard block
 block discarded – undo
1046 1100
 
1047 1101
 	foreach ($txt as $key => $value)
1048 1102
 	{
1049
-		if (substr($key, 0, 8) == 'default_')
1050
-			$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1103
+		if (substr($key, 0, 8) == 'default_') {
1104
+					$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1105
+		}
1051 1106
 	}
1052 1107
 	$replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n'));
1053 1108
 
@@ -1062,8 +1117,9 @@  discard block
 block discarded – undo
1062 1117
 
1063 1118
 		while ($row = $smcFunc['db_fetch_assoc']($get_engines))
1064 1119
 		{
1065
-			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT')
1066
-				$engines[] = $row['Engine'];
1120
+			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') {
1121
+							$engines[] = $row['Engine'];
1122
+			}
1067 1123
 		}
1068 1124
 
1069 1125
 		// Done with this now
@@ -1087,8 +1143,7 @@  discard block
 block discarded – undo
1087 1143
 			$replaces['START TRANSACTION;'] = '';
1088 1144
 			$replaces['COMMIT;'] = '';
1089 1145
 		}
1090
-	} 
1091
-	else 
1146
+	} else 
1092 1147
 	{
1093 1148
 		$has_innodb = false;
1094 1149
 	}
@@ -1101,15 +1156,17 @@  discard block
 block discarded – undo
1101 1156
 		);
1102 1157
 		if ($result !== false)
1103 1158
 		{
1104
-			while ($row = $smcFunc['db_fetch_assoc']($result))
1105
-				$pg_version = $row['server_version_num'];
1159
+			while ($row = $smcFunc['db_fetch_assoc']($result)) {
1160
+							$pg_version = $row['server_version_num'];
1161
+			}
1106 1162
 			$smcFunc['db_free_result']($result);
1107 1163
 		}
1108 1164
 		
1109
-		if(isset($pg_version) && $pg_version >= 90100)
1110
-			$replaces['{$unlogged}'] = 'UNLOGGED';
1111
-		else
1112
-			$replaces['{$unlogged}'] = '';
1165
+		if(isset($pg_version) && $pg_version >= 90100) {
1166
+					$replaces['{$unlogged}'] = 'UNLOGGED';
1167
+		} else {
1168
+					$replaces['{$unlogged}'] = '';
1169
+		}
1113 1170
 	}
1114 1171
 
1115 1172
 	// Read in the SQL.  Turn this on and that off... internationalize... etc.
@@ -1129,21 +1186,24 @@  discard block
 block discarded – undo
1129 1186
 	foreach ($sql_lines as $count => $line)
1130 1187
 	{
1131 1188
 		// No comments allowed!
1132
-		if (substr(trim($line), 0, 1) != '#')
1133
-			$current_statement .= "\n" . rtrim($line);
1189
+		if (substr(trim($line), 0, 1) != '#') {
1190
+					$current_statement .= "\n" . rtrim($line);
1191
+		}
1134 1192
 
1135 1193
 		// Is this the end of the query string?
1136
-		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines)))
1137
-			continue;
1194
+		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) {
1195
+					continue;
1196
+		}
1138 1197
 
1139 1198
 		// Does this table already exist?  If so, don't insert more data into it!
1140 1199
 		if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists))
1141 1200
 		{
1142 1201
 			preg_match_all('~\)[,;]~', $current_statement, $matches);
1143
-			if (!empty($matches[0]))
1144
-				$incontext['sql_results']['insert_dups'] += count($matches[0]);
1145
-			else
1146
-				$incontext['sql_results']['insert_dups']++;
1202
+			if (!empty($matches[0])) {
1203
+							$incontext['sql_results']['insert_dups'] += count($matches[0]);
1204
+			} else {
1205
+							$incontext['sql_results']['insert_dups']++;
1206
+			}
1147 1207
 
1148 1208
 			$current_statement = '';
1149 1209
 			continue;
@@ -1152,8 +1212,9 @@  discard block
 block discarded – undo
1152 1212
 		if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false)
1153 1213
 		{
1154 1214
 			// Use the appropriate function based on the DB type
1155
-			if ($db_type == 'mysql' || $db_type =='mysqli')
1156
-				$db_errorno = $db_type . '_errno';
1215
+			if ($db_type == 'mysql' || $db_type =='mysqli') {
1216
+							$db_errorno = $db_type . '_errno';
1217
+			}
1157 1218
 
1158 1219
 			// Error 1050: Table already exists!
1159 1220
 			// @todo Needs to be made better!
@@ -1168,18 +1229,18 @@  discard block
 block discarded – undo
1168 1229
 				// MySQLi requires a connection object. It's optional with MySQL and Postgres
1169 1230
 				$incontext['failures'][$count] = $smcFunc['db_error']($db_connection);
1170 1231
 			}
1171
-		}
1172
-		else
1232
+		} else
1173 1233
 		{
1174
-			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1175
-				$incontext['sql_results']['tables']++;
1176
-			elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1234
+			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) {
1235
+							$incontext['sql_results']['tables']++;
1236
+			} elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1177 1237
 			{
1178 1238
 				preg_match_all('~\)[,;]~', $current_statement, $matches);
1179
-				if (!empty($matches[0]))
1180
-					$incontext['sql_results']['inserts'] += count($matches[0]);
1181
-				else
1182
-					$incontext['sql_results']['inserts']++;
1239
+				if (!empty($matches[0])) {
1240
+									$incontext['sql_results']['inserts'] += count($matches[0]);
1241
+				} else {
1242
+									$incontext['sql_results']['inserts']++;
1243
+				}
1183 1244
 			}
1184 1245
 		}
1185 1246
 
@@ -1192,15 +1253,17 @@  discard block
 block discarded – undo
1192 1253
 	// Sort out the context for the SQL.
1193 1254
 	foreach ($incontext['sql_results'] as $key => $number)
1194 1255
 	{
1195
-		if ($number == 0)
1196
-			unset($incontext['sql_results'][$key]);
1197
-		else
1198
-			$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1256
+		if ($number == 0) {
1257
+					unset($incontext['sql_results'][$key]);
1258
+		} else {
1259
+					$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1260
+		}
1199 1261
 	}
1200 1262
 
1201 1263
 	// Make sure UTF will be used globally.
1202
-	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'])))
1203
-		$newSettings[] = array('global_character_set', 'UTF-8');
1264
+	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']))) {
1265
+			$newSettings[] = array('global_character_set', 'UTF-8');
1266
+	}
1204 1267
 
1205 1268
 	// Maybe we can auto-detect better cookie settings?
1206 1269
 	preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches);
@@ -1211,16 +1274,20 @@  discard block
 block discarded – undo
1211 1274
 		$globalCookies = false;
1212 1275
 
1213 1276
 		// Okay... let's see.  Using a subdomain other than www.? (not a perfect check.)
1214
-		if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www'))))
1215
-			$globalCookies = true;
1277
+		if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) {
1278
+					$globalCookies = true;
1279
+		}
1216 1280
 		// If there's a / in the middle of the path, or it starts with ~... we want local.
1217
-		if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false))
1218
-			$localCookies = true;
1281
+		if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) {
1282
+					$localCookies = true;
1283
+		}
1219 1284
 
1220
-		if ($globalCookies)
1221
-			$newSettings[] = array('globalCookies', '1');
1222
-		if ($localCookies)
1223
-			$newSettings[] = array('localCookies', '1');
1285
+		if ($globalCookies) {
1286
+					$newSettings[] = array('globalCookies', '1');
1287
+		}
1288
+		if ($localCookies) {
1289
+					$newSettings[] = array('localCookies', '1');
1290
+		}
1224 1291
 	}
1225 1292
 
1226 1293
 	// Are we allowing stat collection?
@@ -1236,30 +1303,34 @@  discard block
 block discarded – undo
1236 1303
 			fwrite($fp, $out);
1237 1304
 
1238 1305
 			$return_data = '';
1239
-			while (!feof($fp))
1240
-				$return_data .= fgets($fp, 128);
1306
+			while (!feof($fp)) {
1307
+							$return_data .= fgets($fp, 128);
1308
+			}
1241 1309
 
1242 1310
 			fclose($fp);
1243 1311
 
1244 1312
 			// Get the unique site ID.
1245 1313
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1246 1314
 
1247
-			if (!empty($ID[1]))
1248
-				$newSettings[] = array('allow_sm_stats', $ID[1]);
1315
+			if (!empty($ID[1])) {
1316
+							$newSettings[] = array('allow_sm_stats', $ID[1]);
1317
+			}
1249 1318
 		}
1250 1319
 	}
1251 1320
 
1252 1321
 	// Are we enabling SSL?
1253
-	if (!empty($_POST['force_ssl']))
1254
-		$newSettings[] = array('force_ssl', 2);
1322
+	if (!empty($_POST['force_ssl'])) {
1323
+			$newSettings[] = array('force_ssl', 2);
1324
+	}
1255 1325
 
1256 1326
 	// As of PHP 5.1, setting a timezone is required.
1257 1327
 	if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set'))
1258 1328
 	{
1259 1329
 		$server_offset = mktime(0, 0, 0, 1, 1, 1970);
1260 1330
 		$timezone_id = 'Etc/GMT' . ($server_offset > 0 ? '+' : '') . ($server_offset / 3600);
1261
-		if (date_default_timezone_set($timezone_id))
1262
-			$newSettings[] = array('default_timezone', $timezone_id);
1331
+		if (date_default_timezone_set($timezone_id)) {
1332
+					$newSettings[] = array('default_timezone', $timezone_id);
1333
+		}
1263 1334
 	}
1264 1335
 
1265 1336
 	if (!empty($newSettings))
@@ -1290,16 +1361,18 @@  discard block
 block discarded – undo
1290 1361
 	}
1291 1362
 	
1292 1363
 	// MySQL specific stuff 
1293
-	if (substr($db_type, 0, 5) != 'mysql')
1294
-		return false;
1364
+	if (substr($db_type, 0, 5) != 'mysql') {
1365
+			return false;
1366
+	}
1295 1367
 	
1296 1368
 	// Find database user privileges.
1297 1369
 	$privs = array();
1298 1370
 	$get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array());
1299 1371
 	while ($row = $smcFunc['db_fetch_assoc']($get_privs))
1300 1372
 	{
1301
-		if ($row['Privilege'] == 'Alter')
1302
-			$privs[] = $row['Privilege'];
1373
+		if ($row['Privilege'] == 'Alter') {
1374
+					$privs[] = $row['Privilege'];
1375
+		}
1303 1376
 	}
1304 1377
 	$smcFunc['db_free_result']($get_privs);
1305 1378
 
@@ -1329,8 +1402,9 @@  discard block
 block discarded – undo
1329 1402
 	$incontext['continue'] = 1;
1330 1403
 
1331 1404
 	// Skipping?
1332
-	if (!empty($_POST['skip']))
1333
-		return true;
1405
+	if (!empty($_POST['skip'])) {
1406
+			return true;
1407
+	}
1334 1408
 
1335 1409
 	// Need this to check whether we need the database password.
1336 1410
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1348,12 +1422,15 @@  discard block
 block discarded – undo
1348 1422
 			return utf8_strtolower($string);
1349 1423
 		');
1350 1424
 
1351
-	if (!isset($_POST['username']))
1352
-		$_POST['username'] = '';
1353
-	if (!isset($_POST['email']))
1354
-		$_POST['email'] = '';
1355
-	if (!isset($_POST['server_email']))
1356
-		$_POST['server_email'] = '';
1425
+	if (!isset($_POST['username'])) {
1426
+			$_POST['username'] = '';
1427
+	}
1428
+	if (!isset($_POST['email'])) {
1429
+			$_POST['email'] = '';
1430
+	}
1431
+	if (!isset($_POST['server_email'])) {
1432
+			$_POST['server_email'] = '';
1433
+	}
1357 1434
 
1358 1435
 	$incontext['username'] = htmlspecialchars(stripslashes($_POST['username']));
1359 1436
 	$incontext['email'] = htmlspecialchars(stripslashes($_POST['email']));
@@ -1372,8 +1449,9 @@  discard block
 block discarded – undo
1372 1449
 			'admin_group' => 1,
1373 1450
 		)
1374 1451
 	);
1375
-	if ($smcFunc['db_num_rows']($request) != 0)
1376
-		$incontext['skip'] = 1;
1452
+	if ($smcFunc['db_num_rows']($request) != 0) {
1453
+			$incontext['skip'] = 1;
1454
+	}
1377 1455
 	$smcFunc['db_free_result']($request);
1378 1456
 
1379 1457
 	// Trying to create an account?
@@ -1404,8 +1482,9 @@  discard block
 block discarded – undo
1404 1482
 		}
1405 1483
 
1406 1484
 		// Update the webmaster's email?
1407
-		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]'))
1408
-			updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1485
+		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) {
1486
+					updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1487
+		}
1409 1488
 
1410 1489
 		// Work out whether we're going to have dodgy characters and remove them.
1411 1490
 		$invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0;
@@ -1428,32 +1507,27 @@  discard block
 block discarded – undo
1428 1507
 			$smcFunc['db_free_result']($result);
1429 1508
 
1430 1509
 			$incontext['account_existed'] = $txt['error_user_settings_taken'];
1431
-		}
1432
-		elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1510
+		} elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1433 1511
 		{
1434 1512
 			// Try the previous step again.
1435 1513
 			$incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long'];
1436 1514
 			return false;
1437
-		}
1438
-		elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1515
+		} elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1439 1516
 		{
1440 1517
 			// Try the previous step again.
1441 1518
 			$incontext['error'] = $txt['error_invalid_characters_username'];
1442 1519
 			return false;
1443
-		}
1444
-		elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1520
+		} elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1445 1521
 		{
1446 1522
 			// One step back, this time fill out a proper admin email address.
1447 1523
 			$incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']);
1448 1524
 			return false;
1449
-		}
1450
-		elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1525
+		} elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1451 1526
 		{
1452 1527
 			// One step back, this time fill out a proper admin email address.
1453 1528
 			$incontext['error'] = $txt['error_valid_server_email_needed'];
1454 1529
 			return false;
1455
-		}
1456
-		elseif ($_POST['username'] != '')
1530
+		} elseif ($_POST['username'] != '')
1457 1531
 		{
1458 1532
 			$incontext['member_salt'] = substr(md5(mt_rand()), 0, 4);
1459 1533
 
@@ -1528,17 +1602,19 @@  discard block
 block discarded – undo
1528 1602
 	require_once($sourcedir . '/Subs-Auth.php');
1529 1603
 
1530 1604
 	// Bring a warning over.
1531
-	if (!empty($incontext['account_existed']))
1532
-		$incontext['warning'] = $incontext['account_existed'];
1605
+	if (!empty($incontext['account_existed'])) {
1606
+			$incontext['warning'] = $incontext['account_existed'];
1607
+	}
1533 1608
 
1534
-	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support']))
1535
-		$smcFunc['db_query']('', '
1609
+	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) {
1610
+			$smcFunc['db_query']('', '
1536 1611
 			SET NAMES {raw:db_character_set}',
1537 1612
 			array(
1538 1613
 				'db_character_set' => $db_character_set,
1539 1614
 				'db_error_skip' => true,
1540 1615
 			)
1541 1616
 		);
1617
+	}
1542 1618
 
1543 1619
 	// As track stats is by default enabled let's add some activity.
1544 1620
 	$smcFunc['db_insert']('ignore',
@@ -1559,14 +1635,16 @@  discard block
 block discarded – undo
1559 1635
 	// Only proceed if we can load the data.
1560 1636
 	if ($request)
1561 1637
 	{
1562
-		while ($row = $smcFunc['db_fetch_row']($request))
1563
-			$modSettings[$row[0]] = $row[1];
1638
+		while ($row = $smcFunc['db_fetch_row']($request)) {
1639
+					$modSettings[$row[0]] = $row[1];
1640
+		}
1564 1641
 		$smcFunc['db_free_result']($request);
1565 1642
 	}
1566 1643
 
1567 1644
 	// Automatically log them in ;)
1568
-	if (isset($incontext['member_id']) && isset($incontext['member_salt']))
1569
-		setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1645
+	if (isset($incontext['member_id']) && isset($incontext['member_salt'])) {
1646
+			setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1647
+	}
1570 1648
 
1571 1649
 	$result = $smcFunc['db_query']('', '
1572 1650
 		SELECT value
@@ -1577,13 +1655,14 @@  discard block
 block discarded – undo
1577 1655
 			'db_error_skip' => true,
1578 1656
 		)
1579 1657
 	);
1580
-	if ($smcFunc['db_num_rows']($result) != 0)
1581
-		list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1658
+	if ($smcFunc['db_num_rows']($result) != 0) {
1659
+			list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1660
+	}
1582 1661
 	$smcFunc['db_free_result']($result);
1583 1662
 
1584
-	if (empty($db_sessions))
1585
-		$_SESSION['admin_time'] = time();
1586
-	else
1663
+	if (empty($db_sessions)) {
1664
+			$_SESSION['admin_time'] = time();
1665
+	} else
1587 1666
 	{
1588 1667
 		$_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211);
1589 1668
 
@@ -1624,8 +1703,9 @@  discard block
 block discarded – undo
1624 1703
 		)
1625 1704
 	);
1626 1705
 	$context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8';
1627
-	if ($smcFunc['db_num_rows']($request) > 0)
1628
-		updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1706
+	if ($smcFunc['db_num_rows']($request) > 0) {
1707
+			updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1708
+	}
1629 1709
 	$smcFunc['db_free_result']($request);
1630 1710
 
1631 1711
 	// Now is the perfect time to fetch the SM files.
@@ -1644,8 +1724,9 @@  discard block
 block discarded – undo
1644 1724
 
1645 1725
 	// Check if we need some stupid MySQL fix.
1646 1726
 	$server_version = $smcFunc['db_server_info']();
1647
-	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1648
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1727
+	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1728
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1729
+	}
1649 1730
 
1650 1731
 	// Some final context for the template.
1651 1732
 	$incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\';
@@ -1667,18 +1748,21 @@  discard block
 block discarded – undo
1667 1748
 	// Create a new FTP connection...
1668 1749
 	function ftp_connection($ftp_server, $ftp_port = 21, $ftp_user = 'anonymous', $ftp_pass = '[email protected]')
1669 1750
 	{
1670
-		if ($ftp_server !== null)
1671
-			$this->connect($ftp_server, $ftp_port, $ftp_user, $ftp_pass);
1751
+		if ($ftp_server !== null) {
1752
+					$this->connect($ftp_server, $ftp_port, $ftp_user, $ftp_pass);
1753
+		}
1672 1754
 	}
1673 1755
 
1674 1756
 	function connect($ftp_server, $ftp_port = 21, $ftp_user = 'anonymous', $ftp_pass = '[email protected]')
1675 1757
 	{
1676
-		if (substr($ftp_server, 0, 6) == 'ftp://')
1677
-			$ftp_server = substr($ftp_server, 6);
1678
-		elseif (substr($ftp_server, 0, 7) == 'ftps://')
1679
-			$ftp_server = 'ssl://' . substr($ftp_server, 7);
1680
-		if (substr($ftp_server, 0, 7) == 'http://')
1681
-			$ftp_server = substr($ftp_server, 7);
1758
+		if (substr($ftp_server, 0, 6) == 'ftp://') {
1759
+					$ftp_server = substr($ftp_server, 6);
1760
+		} elseif (substr($ftp_server, 0, 7) == 'ftps://') {
1761
+					$ftp_server = 'ssl://' . substr($ftp_server, 7);
1762
+		}
1763
+		if (substr($ftp_server, 0, 7) == 'http://') {
1764
+					$ftp_server = substr($ftp_server, 7);
1765
+		}
1682 1766
 		$ftp_server = strtr($ftp_server, array('/' => '', ':' => '', '@' => ''));
1683 1767
 
1684 1768
 		// Connect to the FTP server.
@@ -1715,12 +1799,14 @@  discard block
 block discarded – undo
1715 1799
 
1716 1800
 	function chdir($ftp_path)
1717 1801
 	{
1718
-		if (!is_resource($this->connection))
1719
-			return false;
1802
+		if (!is_resource($this->connection)) {
1803
+					return false;
1804
+		}
1720 1805
 
1721 1806
 		// No slash on the end, please...
1722
-		if (substr($ftp_path, -1) == '/')
1723
-			$ftp_path = substr($ftp_path, 0, -1);
1807
+		if (substr($ftp_path, -1) == '/') {
1808
+					$ftp_path = substr($ftp_path, 0, -1);
1809
+		}
1724 1810
 
1725 1811
 		fwrite($this->connection, 'CWD ' . $ftp_path . "\r\n");
1726 1812
 		if (!$this->check_response(250))
@@ -1734,8 +1820,9 @@  discard block
 block discarded – undo
1734 1820
 
1735 1821
 	function chmod($ftp_file, $chmod)
1736 1822
 	{
1737
-		if (!is_resource($this->connection))
1738
-			return false;
1823
+		if (!is_resource($this->connection)) {
1824
+					return false;
1825
+		}
1739 1826
 
1740 1827
 		// Convert the chmod value from octal (0777) to text ("777")
1741 1828
 		fwrite($this->connection, 'SITE CHMOD ' . decoct($chmod) . ' ' . $ftp_file . "\r\n");
@@ -1751,8 +1838,9 @@  discard block
 block discarded – undo
1751 1838
 	function unlink($ftp_file)
1752 1839
 	{
1753 1840
 		// We are actually connected, right?
1754
-		if (!is_resource($this->connection))
1755
-			return false;
1841
+		if (!is_resource($this->connection)) {
1842
+					return false;
1843
+		}
1756 1844
 
1757 1845
 		// Delete file X.
1758 1846
 		fwrite($this->connection, 'DELE ' . $ftp_file . "\r\n");
@@ -1775,9 +1863,9 @@  discard block
 block discarded – undo
1775 1863
 	{
1776 1864
 		// Wait for a response that isn't continued with -, but don't wait too long.
1777 1865
 		$time = time();
1778
-		do
1779
-			$this->last_message = fgets($this->connection, 1024);
1780
-		while (substr($this->last_message, 3, 1) != ' ' && time() - $time < 5);
1866
+		do {
1867
+					$this->last_message = fgets($this->connection, 1024);
1868
+		} while (substr($this->last_message, 3, 1) != ' ' && time() - $time < 5);
1781 1869
 
1782 1870
 		// Was the desired response returned?
1783 1871
 		return is_array($desired) ? in_array(substr($this->last_message, 0, 3), $desired) : substr($this->last_message, 0, 3) == $desired;
@@ -1786,15 +1874,16 @@  discard block
 block discarded – undo
1786 1874
 	function passive()
1787 1875
 	{
1788 1876
 		// We can't create a passive data connection without a primary one first being there.
1789
-		if (!is_resource($this->connection))
1790
-			return false;
1877
+		if (!is_resource($this->connection)) {
1878
+					return false;
1879
+		}
1791 1880
 
1792 1881
 		// Request a passive connection - this means, we'll talk to you, you don't talk to us.
1793 1882
 		@fwrite($this->connection, "PASV\r\n");
1794 1883
 		$time = time();
1795
-		do
1796
-			$response = fgets($this->connection, 1024);
1797
-		while (substr($response, 3, 1) != ' ' && time() - $time < 5);
1884
+		do {
1885
+					$response = fgets($this->connection, 1024);
1886
+		} while (substr($response, 3, 1) != ' ' && time() - $time < 5);
1798 1887
 
1799 1888
 		// If it's not 227, we weren't given an IP and port, which means it failed.
1800 1889
 		if (substr($response, 0, 4) != '227 ')
@@ -1819,12 +1908,14 @@  discard block
 block discarded – undo
1819 1908
 	function create_file($ftp_file)
1820 1909
 	{
1821 1910
 		// First, we have to be connected... very important.
1822
-		if (!is_resource($this->connection))
1823
-			return false;
1911
+		if (!is_resource($this->connection)) {
1912
+					return false;
1913
+		}
1824 1914
 
1825 1915
 		// I'd like one passive mode, please!
1826
-		if (!$this->passive())
1827
-			return false;
1916
+		if (!$this->passive()) {
1917
+					return false;
1918
+		}
1828 1919
 
1829 1920
 		// Seems logical enough, so far...
1830 1921
 		fwrite($this->connection, 'STOR ' . $ftp_file . "\r\n");
@@ -1852,12 +1943,14 @@  discard block
 block discarded – undo
1852 1943
 	function list_dir($ftp_path = '', $search = false)
1853 1944
 	{
1854 1945
 		// Are we even connected...?
1855
-		if (!is_resource($this->connection))
1856
-			return false;
1946
+		if (!is_resource($this->connection)) {
1947
+					return false;
1948
+		}
1857 1949
 
1858 1950
 		// Passive... non-agressive...
1859
-		if (!$this->passive())
1860
-			return false;
1951
+		if (!$this->passive()) {
1952
+					return false;
1953
+		}
1861 1954
 
1862 1955
 		// Get the listing!
1863 1956
 		fwrite($this->connection, 'LIST -1' . ($search ? 'R' : '') . ($ftp_path == '' ? '' : ' ' . $ftp_path) . "\r\n");
@@ -1873,8 +1966,9 @@  discard block
 block discarded – undo
1873 1966
 
1874 1967
 		// Read in the file listing.
1875 1968
 		$data = '';
1876
-		while (!feof($fp))
1877
-			$data .= fread($fp, 4096);
1969
+		while (!feof($fp)) {
1970
+					$data .= fread($fp, 4096);
1971
+		}
1878 1972
 		fclose($fp);
1879 1973
 
1880 1974
 		// Everything go okay?
@@ -1889,21 +1983,23 @@  discard block
 block discarded – undo
1889 1983
 
1890 1984
 	function locate($file, $listing = null)
1891 1985
 	{
1892
-		if ($listing === null)
1893
-			$listing = $this->list_dir('', true);
1986
+		if ($listing === null) {
1987
+					$listing = $this->list_dir('', true);
1988
+		}
1894 1989
 		$listing = explode("\n", $listing);
1895 1990
 
1896 1991
 		@fwrite($this->connection, "PWD\r\n");
1897 1992
 		$time = time();
1898
-		do
1899
-			$response = fgets($this->connection, 1024);
1900
-		while (substr($response, 3, 1) != ' ' && time() - $time < 5);
1993
+		do {
1994
+					$response = fgets($this->connection, 1024);
1995
+		} while (substr($response, 3, 1) != ' ' && time() - $time < 5);
1901 1996
 
1902 1997
 		// Check for 257!
1903
-		if (preg_match('~^257 "(.+?)" ~', $response, $match) != 0)
1904
-			$current_dir = strtr($match[1], array('""' => '"'));
1905
-		else
1906
-			$current_dir = '';
1998
+		if (preg_match('~^257 "(.+?)" ~', $response, $match) != 0) {
1999
+					$current_dir = strtr($match[1], array('""' => '"'));
2000
+		} else {
2001
+					$current_dir = '';
2002
+		}
1907 2003
 
1908 2004
 		for ($i = 0, $n = count($listing); $i < $n; $i++)
1909 2005
 		{
@@ -1916,12 +2012,15 @@  discard block
 block discarded – undo
1916 2012
 			// Okay, this file's name is:
1917 2013
 			$listing[$i] = $current_dir . '/' . trim(strlen($listing[$i]) > 30 ? strrchr($listing[$i], ' ') : $listing[$i]);
1918 2014
 
1919
-			if (substr($file, 0, 1) == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1))
1920
-				return $listing[$i];
1921
-			if (substr($file, -1) == '*' && substr($listing[$i], 0, strlen($file) - 1) == substr($file, 0, -1))
1922
-				return $listing[$i];
1923
-			if (basename($listing[$i]) == $file || $listing[$i] == $file)
1924
-				return $listing[$i];
2015
+			if (substr($file, 0, 1) == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1)) {
2016
+							return $listing[$i];
2017
+			}
2018
+			if (substr($file, -1) == '*' && substr($listing[$i], 0, strlen($file) - 1) == substr($file, 0, -1)) {
2019
+							return $listing[$i];
2020
+			}
2021
+			if (basename($listing[$i]) == $file || $listing[$i] == $file) {
2022
+							return $listing[$i];
2023
+			}
1925 2024
 		}
1926 2025
 
1927 2026
 		return false;
@@ -1930,8 +2029,9 @@  discard block
 block discarded – undo
1930 2029
 	function create_dir($ftp_dir)
1931 2030
 	{
1932 2031
 		// We must be connected to the server to do something.
1933
-		if (!is_resource($this->connection))
1934
-			return false;
2032
+		if (!is_resource($this->connection)) {
2033
+					return false;
2034
+		}
1935 2035
 
1936 2036
 		// Make this new beautiful directory!
1937 2037
 		fwrite($this->connection, 'MKD ' . $ftp_dir . "\r\n");
@@ -1956,35 +2056,40 @@  discard block
 block discarded – undo
1956 2056
 
1957 2057
 				$path = strtr($_SERVER['DOCUMENT_ROOT'], array('/home/' . $match[1] . '/' => '', '/home2/' . $match[1] . '/' => ''));
1958 2058
 
1959
-				if (substr($path, -1) == '/')
1960
-					$path = substr($path, 0, -1);
2059
+				if (substr($path, -1) == '/') {
2060
+									$path = substr($path, 0, -1);
2061
+				}
1961 2062
 
1962
-				if (strlen(dirname($_SERVER['PHP_SELF'])) > 1)
1963
-					$path .= dirname($_SERVER['PHP_SELF']);
2063
+				if (strlen(dirname($_SERVER['PHP_SELF'])) > 1) {
2064
+									$path .= dirname($_SERVER['PHP_SELF']);
2065
+				}
2066
+			} elseif (substr($filesystem_path, 0, 9) == '/var/www/') {
2067
+							$path = substr($filesystem_path, 8);
2068
+			} else {
2069
+							$path = strtr(strtr($filesystem_path, array('\\' => '/')), array($_SERVER['DOCUMENT_ROOT'] => ''));
1964 2070
 			}
1965
-			elseif (substr($filesystem_path, 0, 9) == '/var/www/')
1966
-				$path = substr($filesystem_path, 8);
1967
-			else
1968
-				$path = strtr(strtr($filesystem_path, array('\\' => '/')), array($_SERVER['DOCUMENT_ROOT'] => ''));
2071
+		} else {
2072
+					$path = '';
1969 2073
 		}
1970
-		else
1971
-			$path = '';
1972 2074
 
1973 2075
 		if (is_resource($this->connection) && $this->list_dir($path) == '')
1974 2076
 		{
1975 2077
 			$data = $this->list_dir('', true);
1976 2078
 
1977
-			if ($lookup_file === null)
1978
-				$lookup_file = $_SERVER['PHP_SELF'];
2079
+			if ($lookup_file === null) {
2080
+							$lookup_file = $_SERVER['PHP_SELF'];
2081
+			}
1979 2082
 
1980 2083
 			$found_path = dirname($this->locate('*' . basename(dirname($lookup_file)) . '/' . basename($lookup_file), $data));
1981
-			if ($found_path == false)
1982
-				$found_path = dirname($this->locate(basename($lookup_file)));
1983
-			if ($found_path != false)
1984
-				$path = $found_path;
2084
+			if ($found_path == false) {
2085
+							$found_path = dirname($this->locate(basename($lookup_file)));
2086
+			}
2087
+			if ($found_path != false) {
2088
+							$path = $found_path;
2089
+			}
2090
+		} elseif (is_resource($this->connection)) {
2091
+					$found_path = true;
1985 2092
 		}
1986
-		elseif (is_resource($this->connection))
1987
-			$found_path = true;
1988 2093
 
1989 2094
 		return array($username, $path, isset($found_path));
1990 2095
 	}
@@ -2005,8 +2110,9 @@  discard block
 block discarded – undo
2005 2110
 	$settingsArray = file(dirname(__FILE__) . '/Settings.php');
2006 2111
 
2007 2112
 	// @todo Do we just want to read the file in clean, and split it this way always?
2008
-	if (count($settingsArray) == 1)
2009
-		$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
2113
+	if (count($settingsArray) == 1) {
2114
+			$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
2115
+	}
2010 2116
 
2011 2117
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
2012 2118
 	{
@@ -2021,19 +2127,22 @@  discard block
 block discarded – undo
2021 2127
 			continue;
2022 2128
 		}
2023 2129
 
2024
-		if (trim($settingsArray[$i]) == '?' . '>')
2025
-			$settingsArray[$i] = '';
2130
+		if (trim($settingsArray[$i]) == '?' . '>') {
2131
+					$settingsArray[$i] = '';
2132
+		}
2026 2133
 
2027 2134
 		// Don't trim or bother with it if it's not a variable.
2028
-		if (substr($settingsArray[$i], 0, 1) != '$')
2029
-			continue;
2135
+		if (substr($settingsArray[$i], 0, 1) != '$') {
2136
+					continue;
2137
+		}
2030 2138
 
2031 2139
 		$settingsArray[$i] = rtrim($settingsArray[$i]) . "\n";
2032 2140
 
2033
-		foreach ($vars as $var => $val)
2034
-			if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
2141
+		foreach ($vars as $var => $val) {
2142
+					if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
2035 2143
 			{
2036 2144
 				$comment = strstr($settingsArray[$i], '#');
2145
+		}
2037 2146
 				$settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n");
2038 2147
 				unset($vars[$var]);
2039 2148
 			}
@@ -2043,36 +2152,41 @@  discard block
 block discarded – undo
2043 2152
 	if (!empty($vars))
2044 2153
 	{
2045 2154
 		$settingsArray[$i++] = '';
2046
-		foreach ($vars as $var => $val)
2047
-			$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
2155
+		foreach ($vars as $var => $val) {
2156
+					$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
2157
+		}
2048 2158
 	}
2049 2159
 
2050 2160
 	// Blank out the file - done to fix a oddity with some servers.
2051 2161
 	$fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w');
2052
-	if (!$fp)
2053
-		return false;
2162
+	if (!$fp) {
2163
+			return false;
2164
+	}
2054 2165
 	fclose($fp);
2055 2166
 
2056 2167
 	$fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+');
2057 2168
 
2058 2169
 	// Gotta have one of these ;)
2059
-	if (trim($settingsArray[0]) != '<?php')
2060
-		fwrite($fp, "<?php\n");
2170
+	if (trim($settingsArray[0]) != '<?php') {
2171
+			fwrite($fp, "<?php\n");
2172
+	}
2061 2173
 
2062 2174
 	$lines = count($settingsArray);
2063 2175
 	for ($i = 0; $i < $lines - 1; $i++)
2064 2176
 	{
2065 2177
 		// Don't just write a bunch of blank lines.
2066
-		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '')
2067
-			fwrite($fp, strtr($settingsArray[$i], "\r", ''));
2178
+		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') {
2179
+					fwrite($fp, strtr($settingsArray[$i], "\r", ''));
2180
+		}
2068 2181
 	}
2069 2182
 	fwrite($fp, $settingsArray[$i] . '?' . '>');
2070 2183
 	fclose($fp);
2071 2184
 
2072 2185
 	// Even though on normal installations the filemtime should prevent this being used by the installer incorrectly
2073 2186
 	// it seems that there are times it might not. So let's MAKE it dump the cache.
2074
-	if (function_exists('opcache_invalidate'))
2075
-		opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
2187
+	if (function_exists('opcache_invalidate')) {
2188
+			opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
2189
+	}
2076 2190
 
2077 2191
 	return true;
2078 2192
 }
@@ -2097,9 +2211,9 @@  discard block
 block discarded – undo
2097 2211
 	SecFilterScanPOST Off
2098 2212
 </IfModule>';
2099 2213
 
2100
-	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules()))
2101
-		return true;
2102
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
2214
+	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) {
2215
+			return true;
2216
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
2103 2217
 	{
2104 2218
 		$current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess'));
2105 2219
 
@@ -2111,29 +2225,28 @@  discard block
 block discarded – undo
2111 2225
 				fwrite($ht_handle, $htaccess_addition);
2112 2226
 				fclose($ht_handle);
2113 2227
 				return true;
2228
+			} else {
2229
+							return false;
2114 2230
 			}
2115
-			else
2116
-				return false;
2231
+		} else {
2232
+					return true;
2117 2233
 		}
2118
-		else
2119
-			return true;
2120
-	}
2121
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess'))
2122
-		return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
2123
-	elseif (is_writable(dirname(__FILE__)))
2234
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess')) {
2235
+			return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
2236
+	} elseif (is_writable(dirname(__FILE__)))
2124 2237
 	{
2125 2238
 		if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w'))
2126 2239
 		{
2127 2240
 			fwrite($ht_handle, $htaccess_addition);
2128 2241
 			fclose($ht_handle);
2129 2242
 			return true;
2243
+		} else {
2244
+					return false;
2130 2245
 		}
2131
-		else
2246
+	} else {
2132 2247
 			return false;
2133 2248
 	}
2134
-	else
2135
-		return false;
2136
-}
2249
+	}
2137 2250
 
2138 2251
 function template_install_above()
2139 2252
 {
@@ -2171,9 +2284,10 @@  discard block
 block discarded – undo
2171 2284
 								<label for="installer_language">', $txt['installer_language'], ':</label>
2172 2285
 								<select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">';
2173 2286
 
2174
-		foreach ($incontext['detected_languages'] as $lang => $name)
2175
-			echo '
2287
+		foreach ($incontext['detected_languages'] as $lang => $name) {
2288
+					echo '
2176 2289
 									<option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>';
2290
+		}
2177 2291
 
2178 2292
 		echo '
2179 2293
 								</select>
@@ -2193,9 +2307,10 @@  discard block
 block discarded – undo
2193 2307
 						<h2>', $txt['upgrade_progress'], '</h2>
2194 2308
 						<ul>';
2195 2309
 
2196
-	foreach ($incontext['steps'] as $num => $step)
2197
-		echo '
2310
+	foreach ($incontext['steps'] as $num => $step) {
2311
+			echo '
2198 2312
 							<li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
2313
+	}
2199 2314
 
2200 2315
 	echo '
2201 2316
 						</ul>
@@ -2219,20 +2334,23 @@  discard block
 block discarded – undo
2219 2334
 		echo '
2220 2335
 								<div>';
2221 2336
 
2222
-		if (!empty($incontext['continue']))
2223
-			echo '
2337
+		if (!empty($incontext['continue'])) {
2338
+					echo '
2224 2339
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button_submit" />';
2225
-		if (!empty($incontext['skip']))
2226
-			echo '
2340
+		}
2341
+		if (!empty($incontext['skip'])) {
2342
+					echo '
2227 2343
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button_submit" />';
2344
+		}
2228 2345
 		echo '
2229 2346
 								</div>';
2230 2347
 	}
2231 2348
 
2232 2349
 	// Show the closing form tag and other data only if not in the last step
2233
-	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step'])
2234
-		echo '
2350
+	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) {
2351
+			echo '
2235 2352
 							</form>';
2353
+	}
2236 2354
 
2237 2355
 	echo '
2238 2356
 						</div>
@@ -2267,13 +2385,15 @@  discard block
 block discarded – undo
2267 2385
 		</div>';
2268 2386
 
2269 2387
 	// Show the warnings, or not.
2270
-	if (template_warning_divs())
2271
-		echo '
2388
+	if (template_warning_divs()) {
2389
+			echo '
2272 2390
 		<h3>', $txt['install_all_lovely'], '</h3>';
2391
+	}
2273 2392
 
2274 2393
 	// Say we want the continue button!
2275
-	if (empty($incontext['error']))
2276
-		$incontext['continue'] = 1;
2394
+	if (empty($incontext['error'])) {
2395
+			$incontext['continue'] = 1;
2396
+	}
2277 2397
 
2278 2398
 	// For the latest version stuff.
2279 2399
 	echo '
@@ -2307,8 +2427,8 @@  discard block
 block discarded – undo
2307 2427
 	global $txt, $incontext;
2308 2428
 
2309 2429
 	// Errors are very serious..
2310
-	if (!empty($incontext['error']))
2311
-		echo '
2430
+	if (!empty($incontext['error'])) {
2431
+			echo '
2312 2432
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
2313 2433
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
2314 2434
 			<strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br />
@@ -2316,9 +2436,10 @@  discard block
 block discarded – undo
2316 2436
 				', $incontext['error'], '
2317 2437
 			</div>
2318 2438
 		</div>';
2439
+	}
2319 2440
 	// A warning message?
2320
-	elseif (!empty($incontext['warning']))
2321
-		echo '
2441
+	elseif (!empty($incontext['warning'])) {
2442
+			echo '
2322 2443
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
2323 2444
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
2324 2445
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br />
@@ -2326,6 +2447,7 @@  discard block
 block discarded – undo
2326 2447
 				', $incontext['warning'], '
2327 2448
 			</div>
2328 2449
 		</div>';
2450
+	}
2329 2451
 
2330 2452
 	return empty($incontext['error']) && empty($incontext['warning']);
2331 2453
 }
@@ -2341,22 +2463,24 @@  discard block
 block discarded – undo
2341 2463
 			<li>', $incontext['failed_files']), '</li>
2342 2464
 		</ul>';
2343 2465
 
2344
-	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux')
2345
-		echo '
2466
+	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') {
2467
+			echo '
2346 2468
 		<hr />
2347 2469
 		<p>', $txt['chmod_linux_info'], '</p>
2348 2470
 		<tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>';
2471
+	}
2349 2472
 
2350 2473
 	// This is serious!
2351
-	if (!template_warning_divs())
2352
-		return;
2474
+	if (!template_warning_divs()) {
2475
+			return;
2476
+	}
2353 2477
 
2354 2478
 	echo '
2355 2479
 		<hr />
2356 2480
 		<p>', $txt['ftp_setup_info'], '</p>';
2357 2481
 
2358
-	if (!empty($incontext['ftp_errors']))
2359
-		echo '
2482
+	if (!empty($incontext['ftp_errors'])) {
2483
+			echo '
2360 2484
 		<div class="error_message">
2361 2485
 			<div style="color: red;">
2362 2486
 				', $txt['error_ftp_no_connect'], '<br />
@@ -2365,6 +2489,7 @@  discard block
 block discarded – undo
2365 2489
 			</div>
2366 2490
 		</div>
2367 2491
 		<br />';
2492
+	}
2368 2493
 
2369 2494
 	echo '
2370 2495
 		<form action="', $incontext['form_url'], '" method="post">
@@ -2424,17 +2549,17 @@  discard block
 block discarded – undo
2424 2549
 				<td>
2425 2550
 					<select name="db_type" id="db_type_input" onchange="toggleDBInput();">';
2426 2551
 
2427
-	foreach ($incontext['supported_databases'] as $key => $db)
2428
-			echo '
2552
+	foreach ($incontext['supported_databases'] as $key => $db) {
2553
+				echo '
2429 2554
 						<option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>';
2555
+	}
2430 2556
 
2431 2557
 	echo '
2432 2558
 					</select>
2433 2559
 					<div class="smalltext block">', $txt['db_settings_type_info'], '</div>
2434 2560
 				</td>
2435 2561
 			</tr>';
2436
-	}
2437
-	else
2562
+	} else
2438 2563
 	{
2439 2564
 		echo '
2440 2565
 			<tr style="display: none;">
@@ -2626,9 +2751,10 @@  discard block
 block discarded – undo
2626 2751
 				<div style="color: red;">', $txt['error_db_queries'], '</div>
2627 2752
 				<ul>';
2628 2753
 
2629
-		foreach ($incontext['failures'] as $line => $fail)
2630
-			echo '
2754
+		foreach ($incontext['failures'] as $line => $fail) {
2755
+					echo '
2631 2756
 						<li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>';
2757
+		}
2632 2758
 
2633 2759
 		echo '
2634 2760
 				</ul>';
@@ -2689,15 +2815,16 @@  discard block
 block discarded – undo
2689 2815
 			</tr>
2690 2816
 		</table>';
2691 2817
 
2692
-	if ($incontext['require_db_confirm'])
2693
-		echo '
2818
+	if ($incontext['require_db_confirm']) {
2819
+			echo '
2694 2820
 		<h2>', $txt['user_settings_database'], '</h2>
2695 2821
 		<p>', $txt['user_settings_database_info'], '</p>
2696 2822
 
2697 2823
 		<div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;">
2698 2824
 			<input type="password" name="password3" size="30" class="input_password" />
2699 2825
 		</div>';
2700
-}
2826
+	}
2827
+	}
2701 2828
 
2702 2829
 // Tell them it's done, and to delete.
2703 2830
 function template_delete_install()
@@ -2710,14 +2837,15 @@  discard block
 block discarded – undo
2710 2837
 	template_warning_divs();
2711 2838
 
2712 2839
 	// Install directory still writable?
2713
-	if ($incontext['dir_still_writable'])
2714
-		echo '
2840
+	if ($incontext['dir_still_writable']) {
2841
+			echo '
2715 2842
 		<em>', $txt['still_writable'], '</em><br />
2716 2843
 		<br />';
2844
+	}
2717 2845
 
2718 2846
 	// Don't show the box if it's like 99% sure it won't work :P.
2719
-	if ($incontext['probably_delete_install'])
2720
-		echo '
2847
+	if ($incontext['probably_delete_install']) {
2848
+			echo '
2721 2849
 		<div style="margin: 1ex; font-weight: bold;">
2722 2850
 			<label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" class="input_check" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label>
2723 2851
 		</div>
@@ -2733,6 +2861,7 @@  discard block
 block discarded – undo
2733 2861
 			}
2734 2862
 		</script>
2735 2863
 		<br />';
2864
+	}
2736 2865
 
2737 2866
 	echo '
2738 2867
 		', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br />
Please login to merge, or discard this patch.
other/upgrade.php 3 patches
Doc Comments   +31 added lines patch added patch discarded remove patch
@@ -205,6 +205,9 @@  discard block
 block discarded – undo
205 205
 // MD5 Encryption.
206 206
 if (!function_exists('md5_hmac'))
207 207
 {
208
+	/**
209
+	 * @param string $key
210
+	 */
208 211
 	function md5_hmac($data, $key)
209 212
 	{
210 213
 		if (strlen($key) > 64)
@@ -293,6 +296,9 @@  discard block
 block discarded – undo
293 296
 			return true;
294 297
 		}
295 298
 
299
+		/**
300
+		 * @param integer $chmod
301
+		 */
296 302
 		function chmod($ftp_file, $chmod)
297 303
 		{
298 304
 			if (!is_resource($this->connection))
@@ -309,6 +315,9 @@  discard block
 block discarded – undo
309 315
 			return true;
310 316
 		}
311 317
 
318
+		/**
319
+		 * @param string $ftp_file
320
+		 */
312 321
 		function unlink($ftp_file)
313 322
 		{
314 323
 			// We are actually connected, right?
@@ -377,6 +386,9 @@  discard block
 block discarded – undo
377 386
 			return true;
378 387
 		}
379 388
 
389
+		/**
390
+		 * @param string $ftp_file
391
+		 */
380 392
 		function create_file($ftp_file)
381 393
 		{
382 394
 			// First, we have to be connected... very important.
@@ -448,6 +460,10 @@  discard block
 block discarded – undo
448 460
 			return $data;
449 461
 		}
450 462
 
463
+		/**
464
+		 * @param string $file
465
+		 * @param false|string $listing
466
+		 */
451 467
 		function locate($file, $listing = null)
452 468
 		{
453 469
 			if ($listing === null)
@@ -756,6 +772,9 @@  discard block
 block discarded – undo
756 772
 }
757 773
 
758 774
 // Used to direct the user to another location.
775
+/**
776
+ * @param string $location
777
+ */
759 778
 function redirectLocation($location, $addForm = true)
760 779
 {
761 780
 	global $upgradeurl, $upcontext, $command_line;
@@ -2437,6 +2456,9 @@  discard block
 block discarded – undo
2437 2456
 	return addslashes(preg_replace(array('~^\.([/\\\]|$)~', '~[/]+~', '~[\\\]+~', '~[/\\\]$~'), array($install_path . '$1', '/', '\\', ''), $path));
2438 2457
 }
2439 2458
 
2459
+/**
2460
+ * @param string $filename
2461
+ */
2440 2462
 function parse_sql($filename)
2441 2463
 {
2442 2464
 	global $db_prefix, $db_collation, $boarddir, $boardurl, $command_line, $file_steps, $step_progress, $custom_warning;
@@ -2723,6 +2745,9 @@  discard block
 block discarded – undo
2723 2745
 	return true;
2724 2746
 }
2725 2747
 
2748
+/**
2749
+ * @param string $string
2750
+ */
2726 2751
 function upgrade_query($string, $unbuffered = false)
2727 2752
 {
2728 2753
 	global $db_connection, $db_server, $db_user, $db_passwd, $db_type, $command_line, $upcontext, $upgradeurl, $modSettings;
@@ -3349,6 +3374,9 @@  discard block
 block discarded – undo
3349 3374
 	$upcontext['current_step'] = 1;
3350 3375
 }
3351 3376
 
3377
+/**
3378
+ * @param string $message
3379
+ */
3352 3380
 function print_error($message, $fatal = false)
3353 3381
 {
3354 3382
 	static $fp = null;
@@ -3362,6 +3390,9 @@  discard block
 block discarded – undo
3362 3390
 		exit;
3363 3391
 }
3364 3392
 
3393
+/**
3394
+ * @param string $message
3395
+ */
3365 3396
 function throw_error($message)
3366 3397
 {
3367 3398
 	global $upcontext;
Please login to merge, or discard this patch.
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -1019,14 +1019,14 @@  discard block
 block discarded – undo
1019 1019
 	// Do we need to add this setting?
1020 1020
 	$need_settings_update = empty($modSettings['custom_avatar_dir']);
1021 1021
 
1022
-	$custom_av_dir = !empty($modSettings['custom_avatar_dir']) ? $modSettings['custom_avatar_dir'] : $GLOBALS['boarddir'] .'/custom_avatar';
1023
-	$custom_av_url = !empty($modSettings['custom_avatar_url']) ? $modSettings['custom_avatar_url'] : $boardurl .'/custom_avatar';
1022
+	$custom_av_dir = !empty($modSettings['custom_avatar_dir']) ? $modSettings['custom_avatar_dir'] : $GLOBALS['boarddir'] . '/custom_avatar';
1023
+	$custom_av_url = !empty($modSettings['custom_avatar_url']) ? $modSettings['custom_avatar_url'] : $boardurl . '/custom_avatar';
1024 1024
 
1025 1025
 	// This little fellow has to cooperate...
1026 1026
 	quickFileWritable($custom_av_dir);
1027 1027
 
1028 1028
 	// Are we good now?
1029
-	if(!is_writable($custom_av_dir))
1029
+	if (!is_writable($custom_av_dir))
1030 1030
 		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));
1031 1031
 	elseif ($need_settings_update)
1032 1032
 	{
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
 				$upcontext['user']['id'] = 1;
1223 1223
 				$upcontext['user']['name'] = 'Administrator';
1224 1224
 			}
1225
-			$upcontext['user']['pass'] = mt_rand(0,60000);
1225
+			$upcontext['user']['pass'] = mt_rand(0, 60000);
1226 1226
 			// This basically is used to match the GET variables to Settings.php.
1227 1227
 			$upcontext['upgrade_status']['pass'] = $upcontext['user']['pass'];
1228 1228
 
@@ -1433,7 +1433,7 @@  discard block
 block discarded – undo
1433 1433
 		if ($db_port != ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port'))
1434 1434
 			$changes['db_port'] = (int) $db_port;
1435 1435
 	}
1436
-	elseif(!empty($db_port))
1436
+	elseif (!empty($db_port))
1437 1437
 	{
1438 1438
 		// If db_port is set and is the same as the default, set it to ''
1439 1439
 		if ($db_type == 'mysql' || $db_type == 'mysqli')
@@ -2037,7 +2037,7 @@  discard block
 block discarded – undo
2037 2037
 		}
2038 2038
 
2039 2039
 		if (!empty($deletes))
2040
-			upgrade_query( '
2040
+			upgrade_query('
2041 2041
 				UPDATE ' . $db_prefix . 'log_packages
2042 2042
 				SET install_state = 0
2043 2043
 				WHERE id_install IN (' . implode(',', $deletes) . ')');
@@ -2116,7 +2116,7 @@  discard block
 block discarded – undo
2116 2116
 	else
2117 2117
 	{
2118 2118
 		require_once($sourcedir . '/ScheduledTasks.php');
2119
-		$forum_version = SMF_VERSION;  // The variable is usually defined in index.php so lets just use the constant to do it for us.
2119
+		$forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us.
2120 2120
 		scheduled_fetchSMfiles(); // Now go get those files!
2121 2121
 	}
2122 2122
 
@@ -2933,7 +2933,7 @@  discard block
 block discarded – undo
2933 2933
 	}
2934 2934
 	elseif ($change['type'] === 'index')
2935 2935
 	{
2936
-		$request = upgrade_query( '
2936
+		$request = upgrade_query('
2937 2937
 			SHOW INDEX
2938 2938
 			FROM ' . $db_prefix . $change['table']);
2939 2939
 		if ($request !== false)
@@ -3575,7 +3575,7 @@  discard block
 block discarded – undo
3575 3575
 	// Try 755 and 775 first since 777 doesn't always work and could be a risk...
3576 3576
 	$chmod_values = array(0755, 0775, 0777);
3577 3577
 
3578
-	foreach($chmod_values as $val)
3578
+	foreach ($chmod_values as $val)
3579 3579
 	{
3580 3580
 		// If it's writable, break out of the loop
3581 3581
 		if (is_writable($file))
@@ -3785,95 +3785,95 @@  discard block
 block discarded – undo
3785 3785
 		// Translation table for the character sets not native for MySQL.
3786 3786
 		$translation_tables = array(
3787 3787
 			'windows-1255' => array(
3788
-				'0x81' => '\'\'',		'0x8A' => '\'\'',		'0x8C' => '\'\'',
3789
-				'0x8D' => '\'\'',		'0x8E' => '\'\'',		'0x8F' => '\'\'',
3790
-				'0x90' => '\'\'',		'0x9A' => '\'\'',		'0x9C' => '\'\'',
3791
-				'0x9D' => '\'\'',		'0x9E' => '\'\'',		'0x9F' => '\'\'',
3792
-				'0xCA' => '\'\'',		'0xD9' => '\'\'',		'0xDA' => '\'\'',
3793
-				'0xDB' => '\'\'',		'0xDC' => '\'\'',		'0xDD' => '\'\'',
3794
-				'0xDE' => '\'\'',		'0xDF' => '\'\'',		'0xFB' => '\'\'',
3795
-				'0xFC' => '\'\'',		'0xFF' => '\'\'',		'0xC2' => '0xFF',
3796
-				'0x80' => '0xFC',		'0xE2' => '0xFB',		'0xA0' => '0xC2A0',
3797
-				'0xA1' => '0xC2A1',		'0xA2' => '0xC2A2',		'0xA3' => '0xC2A3',
3798
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
3799
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
3800
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
3801
-				'0xAF' => '0xC2AF',		'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',
3802
-				'0xB2' => '0xC2B2',		'0xB3' => '0xC2B3',		'0xB4' => '0xC2B4',
3803
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
3804
-				'0xB8' => '0xC2B8',		'0xB9' => '0xC2B9',		'0xBB' => '0xC2BB',
3805
-				'0xBC' => '0xC2BC',		'0xBD' => '0xC2BD',		'0xBE' => '0xC2BE',
3806
-				'0xBF' => '0xC2BF',		'0xD7' => '0xD7B3',		'0xD1' => '0xD781',
3807
-				'0xD4' => '0xD7B0',		'0xD5' => '0xD7B1',		'0xD6' => '0xD7B2',
3808
-				'0xE0' => '0xD790',		'0xEA' => '0xD79A',		'0xEC' => '0xD79C',
3809
-				'0xED' => '0xD79D',		'0xEE' => '0xD79E',		'0xEF' => '0xD79F',
3810
-				'0xF0' => '0xD7A0',		'0xF1' => '0xD7A1',		'0xF2' => '0xD7A2',
3811
-				'0xF3' => '0xD7A3',		'0xF5' => '0xD7A5',		'0xF6' => '0xD7A6',
3812
-				'0xF7' => '0xD7A7',		'0xF8' => '0xD7A8',		'0xF9' => '0xD7A9',
3813
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
3814
-				'0x86' => '0xE280A0',	'0x87' => '0xE280A1',	'0x89' => '0xE280B0',
3815
-				'0x8B' => '0xE280B9',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
3816
-				'0x95' => '0xE280A2',	'0x97' => '0xE28094',	'0x99' => '0xE284A2',
3817
-				'0xC0' => '0xD6B0',		'0xC1' => '0xD6B1',		'0xC3' => '0xD6B3',
3818
-				'0xC4' => '0xD6B4',		'0xC5' => '0xD6B5',		'0xC6' => '0xD6B6',
3819
-				'0xC7' => '0xD6B7',		'0xC8' => '0xD6B8',		'0xC9' => '0xD6B9',
3820
-				'0xCB' => '0xD6BB',		'0xCC' => '0xD6BC',		'0xCD' => '0xD6BD',
3821
-				'0xCE' => '0xD6BE',		'0xCF' => '0xD6BF',		'0xD0' => '0xD780',
3822
-				'0xD2' => '0xD782',		'0xE3' => '0xD793',		'0xE4' => '0xD794',
3823
-				'0xE5' => '0xD795',		'0xE7' => '0xD797',		'0xE9' => '0xD799',
3824
-				'0xFD' => '0xE2808E',	'0xFE' => '0xE2808F',	'0x92' => '0xE28099',
3825
-				'0x83' => '0xC692',		'0xD3' => '0xD783',		'0x88' => '0xCB86',
3826
-				'0x98' => '0xCB9C',		'0x91' => '0xE28098',	'0x96' => '0xE28093',
3827
-				'0xBA' => '0xC3B7',		'0x9B' => '0xE280BA',	'0xAA' => '0xC397',
3828
-				'0xA4' => '0xE282AA',	'0xE1' => '0xD791',		'0xE6' => '0xD796',
3829
-				'0xE8' => '0xD798',		'0xEB' => '0xD79B',		'0xF4' => '0xD7A4',
3830
-				'0xFA' => '0xD7AA',		'0xFF' => '0xD6B2',		'0xFC' => '0xE282AC',
3788
+				'0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'',
3789
+				'0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'',
3790
+				'0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'',
3791
+				'0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'',
3792
+				'0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'',
3793
+				'0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'',
3794
+				'0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '\'\'',
3795
+				'0xFC' => '\'\'', '0xFF' => '\'\'', '0xC2' => '0xFF',
3796
+				'0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0',
3797
+				'0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3',
3798
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
3799
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
3800
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
3801
+				'0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1',
3802
+				'0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4',
3803
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
3804
+				'0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB',
3805
+				'0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE',
3806
+				'0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781',
3807
+				'0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2',
3808
+				'0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C',
3809
+				'0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F',
3810
+				'0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2',
3811
+				'0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6',
3812
+				'0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9',
3813
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
3814
+				'0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0',
3815
+				'0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
3816
+				'0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2',
3817
+				'0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3',
3818
+				'0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6',
3819
+				'0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9',
3820
+				'0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD',
3821
+				'0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780',
3822
+				'0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794',
3823
+				'0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799',
3824
+				'0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099',
3825
+				'0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86',
3826
+				'0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093',
3827
+				'0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397',
3828
+				'0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796',
3829
+				'0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4',
3830
+				'0xFA' => '0xD7AA', '0xFF' => '0xD6B2', '0xFC' => '0xE282AC',
3831 3831
 				'0xFB' => '0xD792',
3832 3832
 			),
3833 3833
 			'windows-1253' => array(
3834
-				'0x81' => '\'\'',			'0x88' => '\'\'',			'0x8A' => '\'\'',
3835
-				'0x8C' => '\'\'',			'0x8D' => '\'\'',			'0x8E' => '\'\'',
3836
-				'0x8F' => '\'\'',			'0x90' => '\'\'',			'0x98' => '\'\'',
3837
-				'0x9A' => '\'\'',			'0x9C' => '\'\'',			'0x9D' => '\'\'',
3838
-				'0x9E' => '\'\'',			'0x9F' => '\'\'',			'0xAA' => '\'\'',
3839
-				'0xD2' => '\'\'',			'0xFF' => '\'\'',			'0xCE' => '0xCE9E',
3840
-				'0xB8' => '0xCE88',		'0xBA' => '0xCE8A',		'0xBC' => '0xCE8C',
3841
-				'0xBE' => '0xCE8E',		'0xBF' => '0xCE8F',		'0xC0' => '0xCE90',
3842
-				'0xC8' => '0xCE98',		'0xCA' => '0xCE9A',		'0xCC' => '0xCE9C',
3843
-				'0xCD' => '0xCE9D',		'0xCF' => '0xCE9F',		'0xDA' => '0xCEAA',
3844
-				'0xE8' => '0xCEB8',		'0xEA' => '0xCEBA',		'0xEC' => '0xCEBC',
3845
-				'0xEE' => '0xCEBE',		'0xEF' => '0xCEBF',		'0xC2' => '0xFF',
3846
-				'0xBD' => '0xC2BD',		'0xED' => '0xCEBD',		'0xB2' => '0xC2B2',
3847
-				'0xA0' => '0xC2A0',		'0xA3' => '0xC2A3',		'0xA4' => '0xC2A4',
3848
-				'0xA5' => '0xC2A5',		'0xA6' => '0xC2A6',		'0xA7' => '0xC2A7',
3849
-				'0xA8' => '0xC2A8',		'0xA9' => '0xC2A9',		'0xAB' => '0xC2AB',
3850
-				'0xAC' => '0xC2AC',		'0xAD' => '0xC2AD',		'0xAE' => '0xC2AE',
3851
-				'0xB0' => '0xC2B0',		'0xB1' => '0xC2B1',		'0xB3' => '0xC2B3',
3852
-				'0xB5' => '0xC2B5',		'0xB6' => '0xC2B6',		'0xB7' => '0xC2B7',
3853
-				'0xBB' => '0xC2BB',		'0xE2' => '0xCEB2',		'0x80' => '0xD2',
3854
-				'0x82' => '0xE2809A',	'0x84' => '0xE2809E',	'0x85' => '0xE280A6',
3855
-				'0x86' => '0xE280A0',	'0xA1' => '0xCE85',		'0xA2' => '0xCE86',
3856
-				'0x87' => '0xE280A1',	'0x89' => '0xE280B0',	'0xB9' => '0xCE89',
3857
-				'0x8B' => '0xE280B9',	'0x91' => '0xE28098',	'0x99' => '0xE284A2',
3858
-				'0x92' => '0xE28099',	'0x93' => '0xE2809C',	'0x94' => '0xE2809D',
3859
-				'0x95' => '0xE280A2',	'0x96' => '0xE28093',	'0x97' => '0xE28094',
3860
-				'0x9B' => '0xE280BA',	'0xAF' => '0xE28095',	'0xB4' => '0xCE84',
3861
-				'0xC1' => '0xCE91',		'0xC3' => '0xCE93',		'0xC4' => '0xCE94',
3862
-				'0xC5' => '0xCE95',		'0xC6' => '0xCE96',		'0x83' => '0xC692',
3863
-				'0xC7' => '0xCE97',		'0xC9' => '0xCE99',		'0xCB' => '0xCE9B',
3864
-				'0xD0' => '0xCEA0',		'0xD1' => '0xCEA1',		'0xD3' => '0xCEA3',
3865
-				'0xD4' => '0xCEA4',		'0xD5' => '0xCEA5',		'0xD6' => '0xCEA6',
3866
-				'0xD7' => '0xCEA7',		'0xD8' => '0xCEA8',		'0xD9' => '0xCEA9',
3867
-				'0xDB' => '0xCEAB',		'0xDC' => '0xCEAC',		'0xDD' => '0xCEAD',
3868
-				'0xDE' => '0xCEAE',		'0xDF' => '0xCEAF',		'0xE0' => '0xCEB0',
3869
-				'0xE1' => '0xCEB1',		'0xE3' => '0xCEB3',		'0xE4' => '0xCEB4',
3870
-				'0xE5' => '0xCEB5',		'0xE6' => '0xCEB6',		'0xE7' => '0xCEB7',
3871
-				'0xE9' => '0xCEB9',		'0xEB' => '0xCEBB',		'0xF0' => '0xCF80',
3872
-				'0xF1' => '0xCF81',		'0xF2' => '0xCF82',		'0xF3' => '0xCF83',
3873
-				'0xF4' => '0xCF84',		'0xF5' => '0xCF85',		'0xF6' => '0xCF86',
3874
-				'0xF7' => '0xCF87',		'0xF8' => '0xCF88',		'0xF9' => '0xCF89',
3875
-				'0xFA' => '0xCF8A',		'0xFB' => '0xCF8B',		'0xFC' => '0xCF8C',
3876
-				'0xFD' => '0xCF8D',		'0xFE' => '0xCF8E',		'0xFF' => '0xCE92',
3834
+				'0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'',
3835
+				'0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'',
3836
+				'0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'',
3837
+				'0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'',
3838
+				'0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'',
3839
+				'0xD2' => '\'\'', '0xFF' => '\'\'', '0xCE' => '0xCE9E',
3840
+				'0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C',
3841
+				'0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90',
3842
+				'0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C',
3843
+				'0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA',
3844
+				'0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC',
3845
+				'0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF',
3846
+				'0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2',
3847
+				'0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4',
3848
+				'0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7',
3849
+				'0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB',
3850
+				'0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE',
3851
+				'0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3',
3852
+				'0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7',
3853
+				'0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2',
3854
+				'0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6',
3855
+				'0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86',
3856
+				'0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89',
3857
+				'0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2',
3858
+				'0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D',
3859
+				'0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094',
3860
+				'0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84',
3861
+				'0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94',
3862
+				'0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692',
3863
+				'0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B',
3864
+				'0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3',
3865
+				'0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6',
3866
+				'0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9',
3867
+				'0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD',
3868
+				'0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0',
3869
+				'0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4',
3870
+				'0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7',
3871
+				'0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80',
3872
+				'0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83',
3873
+				'0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86',
3874
+				'0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89',
3875
+				'0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C',
3876
+				'0xFD' => '0xCF8D', '0xFE' => '0xCF8E', '0xFF' => '0xCE92',
3877 3877
 				'0xD2' => '0xE282AC',
3878 3878
 			),
3879 3879
 		);
@@ -3895,7 +3895,7 @@  discard block
 block discarded – undo
3895 3895
 		$upcontext['table_count'] = count($queryTables);
3896 3896
 		$file_steps = $upcontext['table_count'];
3897 3897
 
3898
-		for($substep = $_GET['substep']; $substep < $upcontext['table_count']; $substep++)
3898
+		for ($substep = $_GET['substep']; $substep < $upcontext['table_count']; $substep++)
3899 3899
 		{
3900 3900
 			$table = $queryTables[$_GET['substep']];
3901 3901
 
@@ -4123,7 +4123,7 @@  discard block
 block discarded – undo
4123 4123
 	$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
4124 4124
 	$file_steps = $upcontext['table_count'];
4125 4125
 
4126
-	foreach($keys as $id => $table)
4126
+	foreach ($keys as $id => $table)
4127 4127
 		if ($id < $_GET['substep'])
4128 4128
 			$upcontext['previous_tables'][] = $table;
4129 4129
 
@@ -4138,7 +4138,7 @@  discard block
 block discarded – undo
4138 4138
 			$upcontext['cur_table_name'] = isset($keys[$substep + 1]) ? $keys[$substep + 1] : $keys[$substep];
4139 4139
 			$upcontext['cur_table_num'] = $substep + 1;
4140 4140
 
4141
-			$upcontext['step_progress'] = (int)(($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
4141
+			$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
4142 4142
 
4143 4143
 			// Do we need to pause?
4144 4144
 			nextSubstep($substep);
@@ -4375,7 +4375,7 @@  discard block
 block discarded – undo
4375 4375
 				<div style="color: red;">The following files need to be writable to continue the upgrade. Please ensure the Windows permissions are correctly set to allow this:</div>
4376 4376
 				<ul style="margin: 2.5ex; font-family: monospace;">
4377 4377
 				<li>' . implode('</li>
4378
-				<li>', $upcontext['chmod']['files']). '</li>
4378
+				<li>', $upcontext['chmod']['files']) . '</li>
4379 4379
 			</ul>
4380 4380
 			</div>';
4381 4381
 
@@ -4474,7 +4474,7 @@  discard block
 block discarded – undo
4474 4474
 		<title>', $txt['upgrade_upgrade_utility'], '</title>
4475 4475
 		<link rel="stylesheet" href="', $settings['default_theme_url'], '/css/index.css?alp21">
4476 4476
 		<link rel="stylesheet" href="', $settings['default_theme_url'], '/css/install.css?alp21">
4477
-		', $txt['lang_rtl'] == true ? '<link rel="stylesheet" href="' . $settings['default_theme_url'] . '/css/rtl.css?alp21">' : '' , '
4477
+		', $txt['lang_rtl'] == true ? '<link rel="stylesheet" href="' . $settings['default_theme_url'] . '/css/rtl.css?alp21">' : '', '
4478 4478
 		<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
4479 4479
 		<script src="', $settings['default_theme_url'], '/scripts/script.js"></script>
4480 4480
 		<script>
Please login to merge, or discard this patch.
Braces   +1128 added lines, -832 removed lines patch added patch discarded remove patch
@@ -78,11 +78,14 @@  discard block
 block discarded – undo
78 78
 	ini_set('default_socket_timeout', 900);
79 79
 }
80 80
 // Clean the upgrade path if this is from the client.
81
-if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']))
82
-	for ($i = 1; $i < $_SERVER['argc']; $i++)
81
+if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
82
+	for ($i = 1;
83
+}
84
+$i < $_SERVER['argc']; $i++)
83 85
 	{
84
-		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0)
85
-			$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
86
+		if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) {
87
+					$upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1];
88
+		}
86 89
 	}
87 90
 
88 91
 // Are we from the client?
@@ -90,9 +93,9 @@  discard block
 block discarded – undo
90 93
 {
91 94
 	$command_line = true;
92 95
 	$disable_security = 1;
93
-}
94
-else
96
+} else {
95 97
 	$command_line = false;
98
+}
96 99
 
97 100
 // Load this now just because we can.
98 101
 require_once($upgrade_path . '/Settings.php');
@@ -103,10 +106,12 @@  discard block
 block discarded – undo
103 106
 	$upcontext['user'] = unserialize(base64_decode($upgradeData));
104 107
 
105 108
 	// Check for sensible values.
106
-	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400)
107
-		$upcontext['user']['started'] = time();
108
-	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400)
109
-		$upcontext['user']['updated'] = 0;
109
+	if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) {
110
+			$upcontext['user']['started'] = time();
111
+	}
112
+	if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) {
113
+			$upcontext['user']['updated'] = 0;
114
+	}
110 115
 
111 116
 	$upcontext['started'] = $upcontext['user']['started'];
112 117
 	$upcontext['updated'] = $upcontext['user']['updated'];
@@ -167,8 +172,9 @@  discard block
 block discarded – undo
167 172
 		{
168 173
 			$word = trim($word, '-_\'');
169 174
 
170
-			if ($word != '')
171
-				$returned_words[] = substr($word, 0, 20);
175
+			if ($word != '') {
176
+							$returned_words[] = substr($word, 0, 20);
177
+			}
172 178
 		}
173 179
 
174 180
 		return array_unique($returned_words);
@@ -183,15 +189,17 @@  discard block
 block discarded – undo
183 189
 		global $cachedir, $sourcedir;
184 190
 
185 191
 		// No directory = no game.
186
-		if (!is_dir($cachedir))
187
-			return;
192
+		if (!is_dir($cachedir)) {
193
+					return;
194
+		}
188 195
 
189 196
 		// Remove the files in SMF's own disk cache, if any
190 197
 		$dh = opendir($cachedir);
191 198
 		while ($file = readdir($dh))
192 199
 		{
193
-			if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type))
194
-				@unlink($cachedir . '/' . $file);
200
+			if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) {
201
+							@unlink($cachedir . '/' . $file);
202
+			}
195 203
 		}
196 204
 		closedir($dh);
197 205
 
@@ -207,8 +215,9 @@  discard block
 block discarded – undo
207 215
 {
208 216
 	function md5_hmac($data, $key)
209 217
 	{
210
-		if (strlen($key) > 64)
211
-			$key = pack('H*', md5($key));
218
+		if (strlen($key) > 64) {
219
+					$key = pack('H*', md5($key));
220
+		}
212 221
 		$key = str_pad($key, 64, chr(0x00));
213 222
 
214 223
 		$k_ipad = $key ^ str_repeat(chr(0x36), 64);
@@ -228,18 +237,21 @@  discard block
 block discarded – undo
228 237
 		// Create a new FTP connection...
229 238
 		function ftp_connection($ftp_server, $ftp_port = 21, $ftp_user = 'anonymous', $ftp_pass = '[email protected]')
230 239
 		{
231
-			if ($ftp_server !== null)
232
-				$this->connect($ftp_server, $ftp_port, $ftp_user, $ftp_pass);
240
+			if ($ftp_server !== null) {
241
+							$this->connect($ftp_server, $ftp_port, $ftp_user, $ftp_pass);
242
+			}
233 243
 		}
234 244
 
235 245
 		function connect($ftp_server, $ftp_port = 21, $ftp_user = 'anonymous', $ftp_pass = '[email protected]')
236 246
 		{
237
-			if (substr($ftp_server, 0, 6) == 'ftp://')
238
-				$ftp_server = substr($ftp_server, 6);
239
-			elseif (substr($ftp_server, 0, 7) == 'ftps://')
240
-				$ftp_server = 'ssl://' . substr($ftp_server, 7);
241
-			if (substr($ftp_server, 0, 7) == 'http://')
242
-				$ftp_server = substr($ftp_server, 7);
247
+			if (substr($ftp_server, 0, 6) == 'ftp://') {
248
+							$ftp_server = substr($ftp_server, 6);
249
+			} elseif (substr($ftp_server, 0, 7) == 'ftps://') {
250
+							$ftp_server = 'ssl://' . substr($ftp_server, 7);
251
+			}
252
+			if (substr($ftp_server, 0, 7) == 'http://') {
253
+							$ftp_server = substr($ftp_server, 7);
254
+			}
243 255
 			$ftp_server = strtr($ftp_server, array('/' => '', ':' => '', '@' => ''));
244 256
 
245 257
 			// Connect to the FTP server.
@@ -276,12 +288,14 @@  discard block
 block discarded – undo
276 288
 
277 289
 		function chdir($ftp_path)
278 290
 		{
279
-			if (!is_resource($this->connection))
280
-				return false;
291
+			if (!is_resource($this->connection)) {
292
+							return false;
293
+			}
281 294
 
282 295
 			// No slash on the end, please...
283
-			if (substr($ftp_path, -1) == '/' && $ftp_path !== '/')
284
-				$ftp_path = substr($ftp_path, 0, -1);
296
+			if (substr($ftp_path, -1) == '/' && $ftp_path !== '/') {
297
+							$ftp_path = substr($ftp_path, 0, -1);
298
+			}
285 299
 
286 300
 			fwrite($this->connection, 'CWD ' . $ftp_path . "\r\n");
287 301
 			if (!$this->check_response(250))
@@ -295,8 +309,9 @@  discard block
 block discarded – undo
295 309
 
296 310
 		function chmod($ftp_file, $chmod)
297 311
 		{
298
-			if (!is_resource($this->connection))
299
-				return false;
312
+			if (!is_resource($this->connection)) {
313
+							return false;
314
+			}
300 315
 
301 316
 			// Convert the chmod value from octal (0777) to text ("777").
302 317
 			fwrite($this->connection, 'SITE CHMOD ' . decoct($chmod) . ' ' . $ftp_file . "\r\n");
@@ -312,8 +327,9 @@  discard block
 block discarded – undo
312 327
 		function unlink($ftp_file)
313 328
 		{
314 329
 			// We are actually connected, right?
315
-			if (!is_resource($this->connection))
316
-				return false;
330
+			if (!is_resource($this->connection)) {
331
+							return false;
332
+			}
317 333
 
318 334
 			// Delete file X.
319 335
 			fwrite($this->connection, 'DELE ' . $ftp_file . "\r\n");
@@ -336,9 +352,9 @@  discard block
 block discarded – undo
336 352
 		{
337 353
 			// Wait for a response that isn't continued with -, but don't wait too long.
338 354
 			$time = time();
339
-			do
340
-				$this->last_message = fgets($this->connection, 1024);
341
-			while (substr($this->last_message, 3, 1) != ' ' && time() - $time < 5);
355
+			do {
356
+							$this->last_message = fgets($this->connection, 1024);
357
+			} while (substr($this->last_message, 3, 1) != ' ' && time() - $time < 5);
342 358
 
343 359
 			// Was the desired response returned?
344 360
 			return is_array($desired) ? in_array(substr($this->last_message, 0, 3), $desired) : substr($this->last_message, 0, 3) == $desired;
@@ -347,15 +363,16 @@  discard block
 block discarded – undo
347 363
 		function passive()
348 364
 		{
349 365
 			// We can't create a passive data connection without a primary one first being there.
350
-			if (!is_resource($this->connection))
351
-				return false;
366
+			if (!is_resource($this->connection)) {
367
+							return false;
368
+			}
352 369
 
353 370
 			// Request a passive connection - this means, we'll talk to you, you don't talk to us.
354 371
 			@fwrite($this->connection, 'PASV' . "\r\n");
355 372
 			$time = time();
356
-			do
357
-				$response = fgets($this->connection, 1024);
358
-			while (substr($response, 3, 1) != ' ' && time() - $time < 5);
373
+			do {
374
+							$response = fgets($this->connection, 1024);
375
+			} while (substr($response, 3, 1) != ' ' && time() - $time < 5);
359 376
 
360 377
 			// If it's not 227, we weren't given an IP and port, which means it failed.
361 378
 			if (substr($response, 0, 4) != '227 ')
@@ -380,12 +397,14 @@  discard block
 block discarded – undo
380 397
 		function create_file($ftp_file)
381 398
 		{
382 399
 			// First, we have to be connected... very important.
383
-			if (!is_resource($this->connection))
384
-				return false;
400
+			if (!is_resource($this->connection)) {
401
+							return false;
402
+			}
385 403
 
386 404
 			// I'd like one passive mode, please!
387
-			if (!$this->passive())
388
-				return false;
405
+			if (!$this->passive()) {
406
+							return false;
407
+			}
389 408
 
390 409
 			// Seems logical enough, so far...
391 410
 			fwrite($this->connection, 'STOR ' . $ftp_file . "\r\n");
@@ -413,12 +432,14 @@  discard block
 block discarded – undo
413 432
 		function list_dir($ftp_path = '', $search = false)
414 433
 		{
415 434
 			// Are we even connected...?
416
-			if (!is_resource($this->connection))
417
-				return false;
435
+			if (!is_resource($this->connection)) {
436
+							return false;
437
+			}
418 438
 
419 439
 			// Passive... non-agressive...
420
-			if (!$this->passive())
421
-				return false;
440
+			if (!$this->passive()) {
441
+							return false;
442
+			}
422 443
 
423 444
 			// Get the listing!
424 445
 			fwrite($this->connection, 'LIST -1' . ($search ? 'R' : '') . ($ftp_path == '' ? '' : ' ' . $ftp_path) . "\r\n");
@@ -434,8 +455,9 @@  discard block
 block discarded – undo
434 455
 
435 456
 			// Read in the file listing.
436 457
 			$data = '';
437
-			while (!feof($fp))
438
-				$data .= fread($fp, 4096);
458
+			while (!feof($fp)) {
459
+							$data .= fread($fp, 4096);
460
+			}
439 461
 			fclose($fp);
440 462
 
441 463
 			// Everything go okay?
@@ -450,21 +472,23 @@  discard block
 block discarded – undo
450 472
 
451 473
 		function locate($file, $listing = null)
452 474
 		{
453
-			if ($listing === null)
454
-				$listing = $this->list_dir('', true);
475
+			if ($listing === null) {
476
+							$listing = $this->list_dir('', true);
477
+			}
455 478
 			$listing = explode("\n", $listing);
456 479
 
457 480
 			@fwrite($this->connection, 'PWD' . "\r\n");
458 481
 			$time = time();
459
-			do
460
-				$response = fgets($this->connection, 1024);
461
-			while (substr($response, 3, 1) != ' ' && time() - $time < 5);
482
+			do {
483
+							$response = fgets($this->connection, 1024);
484
+			} while (substr($response, 3, 1) != ' ' && time() - $time < 5);
462 485
 
463 486
 			// Check for 257!
464
-			if (preg_match('~^257 "(.+?)" ~', $response, $match) != 0)
465
-				$current_dir = strtr($match[1], array('""' => '"'));
466
-			else
467
-				$current_dir = '';
487
+			if (preg_match('~^257 "(.+?)" ~', $response, $match) != 0) {
488
+							$current_dir = strtr($match[1], array('""' => '"'));
489
+			} else {
490
+							$current_dir = '';
491
+			}
468 492
 
469 493
 			for ($i = 0, $n = count($listing); $i < $n; $i++)
470 494
 			{
@@ -477,12 +501,15 @@  discard block
 block discarded – undo
477 501
 				// Okay, this file's name is:
478 502
 				$listing[$i] = $current_dir . '/' . trim(strlen($listing[$i]) > 30 ? strrchr($listing[$i], ' ') : $listing[$i]);
479 503
 
480
-				if (substr($file, 0, 1) == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1))
481
-					return $listing[$i];
482
-				if (substr($file, -1) == '*' && substr($listing[$i], 0, strlen($file) - 1) == substr($file, 0, -1))
483
-					return $listing[$i];
484
-				if (basename($listing[$i]) == $file || $listing[$i] == $file)
485
-					return $listing[$i];
504
+				if (substr($file, 0, 1) == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1)) {
505
+									return $listing[$i];
506
+				}
507
+				if (substr($file, -1) == '*' && substr($listing[$i], 0, strlen($file) - 1) == substr($file, 0, -1)) {
508
+									return $listing[$i];
509
+				}
510
+				if (basename($listing[$i]) == $file || $listing[$i] == $file) {
511
+									return $listing[$i];
512
+				}
486 513
 			}
487 514
 
488 515
 			return false;
@@ -491,8 +518,9 @@  discard block
 block discarded – undo
491 518
 		function create_dir($ftp_dir)
492 519
 		{
493 520
 			// We must be connected to the server to do something.
494
-			if (!is_resource($this->connection))
495
-				return false;
521
+			if (!is_resource($this->connection)) {
522
+							return false;
523
+			}
496 524
 
497 525
 			// Make this new beautiful directory!
498 526
 			fwrite($this->connection, 'MKD ' . $ftp_dir . "\r\n");
@@ -517,35 +545,40 @@  discard block
 block discarded – undo
517 545
 
518 546
 					$path = strtr($_SERVER['DOCUMENT_ROOT'], array('/home/' . $match[1] . '/' => '', '/home2/' . $match[1] . '/' => ''));
519 547
 
520
-					if (substr($path, -1) == '/')
521
-						$path = substr($path, 0, -1);
548
+					if (substr($path, -1) == '/') {
549
+											$path = substr($path, 0, -1);
550
+					}
522 551
 
523
-					if (strlen(dirname($_SERVER['PHP_SELF'])) > 1)
524
-						$path .= dirname($_SERVER['PHP_SELF']);
552
+					if (strlen(dirname($_SERVER['PHP_SELF'])) > 1) {
553
+											$path .= dirname($_SERVER['PHP_SELF']);
554
+					}
555
+				} elseif (substr($filesystem_path, 0, 9) == '/var/www/') {
556
+									$path = substr($filesystem_path, 8);
557
+				} else {
558
+									$path = strtr(strtr($filesystem_path, array('\\' => '/')), array($_SERVER['DOCUMENT_ROOT'] => ''));
525 559
 				}
526
-				elseif (substr($filesystem_path, 0, 9) == '/var/www/')
527
-					$path = substr($filesystem_path, 8);
528
-				else
529
-					$path = strtr(strtr($filesystem_path, array('\\' => '/')), array($_SERVER['DOCUMENT_ROOT'] => ''));
560
+			} else {
561
+							$path = '';
530 562
 			}
531
-			else
532
-				$path = '';
533 563
 
534 564
 			if (is_resource($this->connection) && $this->list_dir($path) == '')
535 565
 			{
536 566
 				$data = $this->list_dir('', true);
537 567
 
538
-				if ($lookup_file === null)
539
-					$lookup_file = $_SERVER['PHP_SELF'];
568
+				if ($lookup_file === null) {
569
+									$lookup_file = $_SERVER['PHP_SELF'];
570
+				}
540 571
 
541 572
 				$found_path = dirname($this->locate('*' . basename(dirname($lookup_file)) . '/' . basename($lookup_file), $data));
542
-				if ($found_path == false)
543
-					$found_path = dirname($this->locate(basename($lookup_file)));
544
-				if ($found_path != false)
545
-					$path = $found_path;
573
+				if ($found_path == false) {
574
+									$found_path = dirname($this->locate(basename($lookup_file)));
575
+				}
576
+				if ($found_path != false) {
577
+									$path = $found_path;
578
+				}
579
+			} elseif (is_resource($this->connection)) {
580
+							$found_path = true;
546 581
 			}
547
-			elseif (is_resource($this->connection))
548
-				$found_path = true;
549 582
 
550 583
 			return array($username, $path, isset($found_path));
551 584
 		}
@@ -562,8 +595,9 @@  discard block
 block discarded – undo
562 595
 }
563 596
 
564 597
 // Don't do security check if on Yabbse
565
-if (!isset($modSettings['smfVersion']))
598
+if (!isset($modSettings['smfVersion'])) {
566 599
 	$disable_security = true;
600
+}
567 601
 
568 602
 // This only exists if we're on SMF ;)
569 603
 if (isset($modSettings['smfVersion']))
@@ -581,8 +615,9 @@  discard block
 block discarded – undo
581 615
 			'db_error_skip' => true,
582 616
 		)
583 617
 	);
584
-	while ($row = $smcFunc['db_fetch_assoc']($request))
585
-		$modSettings[$row['variable']] = $row['value'];
618
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
619
+			$modSettings[$row['variable']] = $row['value'];
620
+	}
586 621
 	$smcFunc['db_free_result']($request);
587 622
 }
588 623
 
@@ -592,10 +627,12 @@  discard block
 block discarded – undo
592 627
 	$modSettings['theme_url'] = 'Themes/default';
593 628
 	$modSettings['images_url'] = 'Themes/default/images';
594 629
 }
595
-if (!isset($settings['default_theme_url']))
630
+if (!isset($settings['default_theme_url'])) {
596 631
 	$settings['default_theme_url'] = $modSettings['theme_url'];
597
-if (!isset($settings['default_theme_dir']))
632
+}
633
+if (!isset($settings['default_theme_dir'])) {
598 634
 	$settings['default_theme_dir'] = $modSettings['theme_dir'];
635
+}
599 636
 
600 637
 $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000;
601 638
 // Default title...
@@ -612,9 +649,10 @@  discard block
 block discarded – undo
612 649
 	$support_js = $upcontext['upgrade_status']['js'];
613 650
 
614 651
 	// Load the language.
615
-	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
616
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
617
-}
652
+	if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
653
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
654
+	}
655
+	}
618 656
 // Set the defaults.
619 657
 else
620 658
 {
@@ -632,15 +670,18 @@  discard block
 block discarded – undo
632 670
 }
633 671
 
634 672
 // If this isn't the first stage see whether they are logging in and resuming.
635
-if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step']))
673
+if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) {
636 674
 	checkLogin();
675
+}
637 676
 
638
-if ($command_line)
677
+if ($command_line) {
639 678
 	cmdStep0();
679
+}
640 680
 
641 681
 // Don't error if we're using xml.
642
-if (isset($_GET['xml']))
682
+if (isset($_GET['xml'])) {
643 683
 	$upcontext['return_error'] = true;
684
+}
644 685
 
645 686
 // Loop through all the steps doing each one as required.
646 687
 $upcontext['overall_percent'] = 0;
@@ -661,10 +702,11 @@  discard block
 block discarded – undo
661 702
 		}
662 703
 
663 704
 		// Call the step and if it returns false that means pause!
664
-		if (function_exists($step[2]) && $step[2]() === false)
665
-			break;
666
-		elseif (function_exists($step[2]))
667
-			$upcontext['current_step']++;
705
+		if (function_exists($step[2]) && $step[2]() === false) {
706
+					break;
707
+		} elseif (function_exists($step[2])) {
708
+					$upcontext['current_step']++;
709
+		}
668 710
 	}
669 711
 	$upcontext['overall_percent'] += $step[3];
670 712
 }
@@ -702,17 +744,18 @@  discard block
 block discarded – undo
702 744
 		// This should not happen my dear... HELP ME DEVELOPERS!!
703 745
 		if (!empty($command_line))
704 746
 		{
705
-			if (function_exists('debug_print_backtrace'))
706
-				debug_print_backtrace();
747
+			if (function_exists('debug_print_backtrace')) {
748
+							debug_print_backtrace();
749
+			}
707 750
 
708 751
 			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.';
709 752
 			flush();
710 753
 			die();
711 754
 		}
712 755
 
713
-		if (!isset($_GET['xml']))
714
-			template_upgrade_above();
715
-		else
756
+		if (!isset($_GET['xml'])) {
757
+					template_upgrade_above();
758
+		} else
716 759
 		{
717 760
 			header('Content-Type: text/xml; charset=UTF-8');
718 761
 			// Sadly we need to retain the $_GET data thanks to the old upgrade scripts.
@@ -734,21 +777,24 @@  discard block
 block discarded – undo
734 777
 			$upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&amp;substep=' . $_GET['substep'] . '&amp;data=' . base64_encode(safe_serialize($upcontext['upgrade_status']));
735 778
 
736 779
 			// Custom stuff to pass back?
737
-			if (!empty($upcontext['query_string']))
738
-				$upcontext['form_url'] .= $upcontext['query_string'];
780
+			if (!empty($upcontext['query_string'])) {
781
+							$upcontext['form_url'] .= $upcontext['query_string'];
782
+			}
739 783
 
740 784
 			call_user_func('template_' . $upcontext['sub_template']);
741 785
 		}
742 786
 
743 787
 		// Was there an error?
744
-		if (!empty($upcontext['forced_error_message']))
745
-			echo $upcontext['forced_error_message'];
788
+		if (!empty($upcontext['forced_error_message'])) {
789
+					echo $upcontext['forced_error_message'];
790
+		}
746 791
 
747 792
 		// Show the footer.
748
-		if (!isset($_GET['xml']))
749
-			template_upgrade_below();
750
-		else
751
-			template_xml_below();
793
+		if (!isset($_GET['xml'])) {
794
+					template_upgrade_below();
795
+		} else {
796
+					template_xml_below();
797
+		}
752 798
 	}
753 799
 
754 800
 	// Bang - gone!
@@ -761,8 +807,9 @@  discard block
 block discarded – undo
761 807
 	global $upgradeurl, $upcontext, $command_line;
762 808
 
763 809
 	// Command line users can't be redirected.
764
-	if ($command_line)
765
-		upgradeExit(true);
810
+	if ($command_line) {
811
+			upgradeExit(true);
812
+	}
766 813
 
767 814
 	// Are we providing the core info?
768 815
 	if ($addForm)
@@ -785,19 +832,22 @@  discard block
 block discarded – undo
785 832
 	global $modSettings, $sourcedir, $smcFunc;
786 833
 
787 834
 	// Do the non-SSI stuff...
788
-	if (function_exists('set_magic_quotes_runtime'))
789
-		@set_magic_quotes_runtime(0);
835
+	if (function_exists('set_magic_quotes_runtime')) {
836
+			@set_magic_quotes_runtime(0);
837
+	}
790 838
 
791 839
 	error_reporting(E_ALL);
792 840
 	define('SMF', 1);
793 841
 
794 842
 	// Start the session.
795
-	if (@ini_get('session.save_handler') == 'user')
796
-		@ini_set('session.save_handler', 'files');
843
+	if (@ini_get('session.save_handler') == 'user') {
844
+			@ini_set('session.save_handler', 'files');
845
+	}
797 846
 	@session_start();
798 847
 
799
-	if (empty($smcFunc))
800
-		$smcFunc = array();
848
+	if (empty($smcFunc)) {
849
+			$smcFunc = array();
850
+	}
801 851
 
802 852
 	// We need this for authentication and some upgrade code
803 853
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -809,8 +859,9 @@  discard block
 block discarded – undo
809 859
 	initialize_inputs();
810 860
 
811 861
 	// Get the database going!
812
-	if (empty($db_type))
813
-		$db_type = 'mysql';
862
+	if (empty($db_type)) {
863
+			$db_type = 'mysql';
864
+	}
814 865
 	if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
815 866
 	{
816 867
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
@@ -819,16 +870,18 @@  discard block
 block discarded – undo
819 870
 		$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
820 871
 
821 872
 		// Oh dear god!!
822
-		if ($db_connection === null)
823
-			die('Unable to connect to database - please check username and password are correct in Settings.php');
873
+		if ($db_connection === null) {
874
+					die('Unable to connect to database - please check username and password are correct in Settings.php');
875
+		}
824 876
 
825
-		if (($db_type == 'mysql' || $db_type == 'mysqli') && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1)
826
-			$smcFunc['db_query']('', '
877
+		if (($db_type == 'mysql' || $db_type == 'mysqli') && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) {
878
+					$smcFunc['db_query']('', '
827 879
 			SET NAMES ' . $db_character_set,
828 880
 			array(
829 881
 				'db_error_skip' => true,
830 882
 			)
831 883
 		);
884
+		}
832 885
 
833 886
 		// Load the modSettings data...
834 887
 		$request = $smcFunc['db_query']('', '
@@ -839,11 +892,11 @@  discard block
 block discarded – undo
839 892
 			)
840 893
 		);
841 894
 		$modSettings = array();
842
-		while ($row = $smcFunc['db_fetch_assoc']($request))
843
-			$modSettings[$row['variable']] = $row['value'];
895
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
896
+					$modSettings[$row['variable']] = $row['value'];
897
+		}
844 898
 		$smcFunc['db_free_result']($request);
845
-	}
846
-	else
899
+	} else
847 900
 	{
848 901
 		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.');
849 902
 	}
@@ -857,9 +910,10 @@  discard block
 block discarded – undo
857 910
 		cleanRequest();
858 911
 	}
859 912
 
860
-	if (!isset($_GET['substep']))
861
-		$_GET['substep'] = 0;
862
-}
913
+	if (!isset($_GET['substep'])) {
914
+			$_GET['substep'] = 0;
915
+	}
916
+	}
863 917
 
864 918
 function initialize_inputs()
865 919
 {
@@ -897,8 +951,9 @@  discard block
 block discarded – undo
897 951
 		$dh = opendir(dirname(__FILE__));
898 952
 		while ($file = readdir($dh))
899 953
 		{
900
-			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1]))
901
-				@unlink(dirname(__FILE__) . '/' . $file);
954
+			if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) {
955
+							@unlink(dirname(__FILE__) . '/' . $file);
956
+			}
902 957
 		}
903 958
 		closedir($dh);
904 959
 
@@ -928,8 +983,9 @@  discard block
 block discarded – undo
928 983
 	{
929 984
 		$upcontext['remote_files_available'] = false;
930 985
 		$test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1);
931
-		if ($test)
932
-			$upcontext['remote_files_available'] = true;
986
+		if ($test) {
987
+					$upcontext['remote_files_available'] = true;
988
+		}
933 989
 		@fclose($test);
934 990
 	}
935 991
 
@@ -937,8 +993,9 @@  discard block
 block discarded – undo
937 993
 	$temp = 'upgrade_php?step';
938 994
 	while (strlen($temp) > 4)
939 995
 	{
940
-		if (isset($_GET[$temp]))
941
-			unset($_GET[$temp]);
996
+		if (isset($_GET[$temp])) {
997
+					unset($_GET[$temp]);
998
+		}
942 999
 		$temp = substr($temp, 1);
943 1000
 	}
944 1001
 
@@ -964,29 +1021,36 @@  discard block
 block discarded – undo
964 1021
 		&& @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $type . '.sql');
965 1022
 
966 1023
 	// Need legacy scripts?
967
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1)
968
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $type . '.sql');
969
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0)
970
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
971
-	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1)
972
-		$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
1024
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) {
1025
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $type . '.sql');
1026
+	}
1027
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) {
1028
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql');
1029
+	}
1030
+	if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) {
1031
+			$check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql');
1032
+	}
973 1033
 
974 1034
 	// This needs to exist!
975
-	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
976
-		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>]');
977
-	else
978
-		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
1035
+	if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
1036
+			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>]');
1037
+	} else {
1038
+			require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
1039
+	}
979 1040
 
980
-	if (!$check)
981
-		// 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.
1041
+	if (!$check) {
1042
+			// 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.
982 1043
 		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.');
1044
+	}
983 1045
 
984 1046
 	// Do they meet the install requirements?
985
-	if (!php_version_check())
986
-		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.');
1047
+	if (!php_version_check()) {
1048
+			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.');
1049
+	}
987 1050
 
988
-	if (!db_version_check())
989
-		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.');
1051
+	if (!db_version_check()) {
1052
+			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.');
1053
+	}
990 1054
 
991 1055
 	// Do some checks to make sure they have proper privileges
992 1056
 	db_extend('packages');
@@ -1001,14 +1065,16 @@  discard block
 block discarded – undo
1001 1065
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
1002 1066
 
1003 1067
 	// Sorry... we need CREATE, ALTER and DROP
1004
-	if (!$create || !$alter || !$drop)
1005
-		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.');
1068
+	if (!$create || !$alter || !$drop) {
1069
+			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.');
1070
+	}
1006 1071
 
1007 1072
 	// Do a quick version spot check.
1008 1073
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
1009 1074
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
1010
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
1011
-		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.');
1075
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
1076
+			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.');
1077
+	}
1012 1078
 
1013 1079
 	// What absolutely needs to be writable?
1014 1080
 	$writable_files = array(
@@ -1026,12 +1092,13 @@  discard block
 block discarded – undo
1026 1092
 	quickFileWritable($custom_av_dir);
1027 1093
 
1028 1094
 	// Are we good now?
1029
-	if(!is_writable($custom_av_dir))
1030
-		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));
1031
-	elseif ($need_settings_update)
1095
+	if(!is_writable($custom_av_dir)) {
1096
+			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));
1097
+	} elseif ($need_settings_update)
1032 1098
 	{
1033
-		if (!function_exists('cache_put_data'))
1034
-			require_once($sourcedir . '/Load.php');
1099
+		if (!function_exists('cache_put_data')) {
1100
+					require_once($sourcedir . '/Load.php');
1101
+		}
1035 1102
 		updateSettings(array('custom_avatar_dir' => $custom_av_dir));
1036 1103
 		updateSettings(array('custom_avatar_url' => $custom_av_url));
1037 1104
 	}
@@ -1040,28 +1107,33 @@  discard block
 block discarded – undo
1040 1107
 
1041 1108
 	// Check the cache directory.
1042 1109
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
1043
-	if (!file_exists($cachedir_temp))
1044
-		@mkdir($cachedir_temp);
1045
-	if (!file_exists($cachedir_temp))
1046
-		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.');
1047
-
1048
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
1049
-		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>.');
1050
-	elseif (!isset($_GET['skiplang']))
1110
+	if (!file_exists($cachedir_temp)) {
1111
+			@mkdir($cachedir_temp);
1112
+	}
1113
+	if (!file_exists($cachedir_temp)) {
1114
+			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.');
1115
+	}
1116
+
1117
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
1118
+			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>.');
1119
+	} elseif (!isset($_GET['skiplang']))
1051 1120
 	{
1052 1121
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
1053 1122
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
1054 1123
 
1055
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
1056
-			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>]');
1124
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
1125
+					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>]');
1126
+		}
1057 1127
 	}
1058 1128
 
1059
-	if (!makeFilesWritable($writable_files))
1060
-		return false;
1129
+	if (!makeFilesWritable($writable_files)) {
1130
+			return false;
1131
+	}
1061 1132
 
1062 1133
 	// Check agreement.txt. (it may not exist, in which case $boarddir must be writable.)
1063
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
1064
-		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.');
1134
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
1135
+			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.');
1136
+	}
1065 1137
 
1066 1138
 	// Upgrade the agreement.
1067 1139
 	elseif (isset($modSettings['agreement']))
@@ -1072,8 +1144,8 @@  discard block
 block discarded – undo
1072 1144
 	}
1073 1145
 
1074 1146
 	// We're going to check that their board dir setting is right in case they've been moving stuff around.
1075
-	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => '')))
1076
-		$upcontext['warning'] = '
1147
+	if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) {
1148
+			$upcontext['warning'] = '
1077 1149
 			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>
1078 1150
 			<ul>
1079 1151
 				<li>Board Directory: ' . $boarddir . '</li>
@@ -1081,10 +1153,12 @@  discard block
 block discarded – undo
1081 1153
 				<li>Cache Directory: ' . $cachedir_temp . '</li>
1082 1154
 			</ul>
1083 1155
 			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="http://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.';
1156
+	}
1084 1157
 
1085 1158
 	// Either we're logged in or we're going to present the login.
1086
-	if (checkLogin())
1087
-		return true;
1159
+	if (checkLogin()) {
1160
+			return true;
1161
+	}
1088 1162
 
1089 1163
 	$upcontext += createToken('login');
1090 1164
 
@@ -1101,8 +1175,9 @@  discard block
 block discarded – undo
1101 1175
 	if (isset($_POST['contbutt']) && (!empty($_POST['user']) || $disable_security))
1102 1176
 	{
1103 1177
 		// If we've disabled security pick a suitable name!
1104
-		if (empty($_POST['user']))
1105
-			$_POST['user'] = 'Administrator';
1178
+		if (empty($_POST['user'])) {
1179
+					$_POST['user'] = 'Administrator';
1180
+		}
1106 1181
 
1107 1182
 		// Before 2.0 these column names were different!
1108 1183
 		$oldDB = false;
@@ -1117,16 +1192,17 @@  discard block
 block discarded – undo
1117 1192
 					'db_error_skip' => true,
1118 1193
 				)
1119 1194
 			);
1120
-			if ($smcFunc['db_num_rows']($request) != 0)
1121
-				$oldDB = true;
1195
+			if ($smcFunc['db_num_rows']($request) != 0) {
1196
+							$oldDB = true;
1197
+			}
1122 1198
 			$smcFunc['db_free_result']($request);
1123 1199
 		}
1124 1200
 
1125 1201
 		// Get what we believe to be their details.
1126 1202
 		if (!$disable_security)
1127 1203
 		{
1128
-			if ($oldDB)
1129
-				$request = $smcFunc['db_query']('', '
1204
+			if ($oldDB) {
1205
+							$request = $smcFunc['db_query']('', '
1130 1206
 					SELECT id_member, memberName AS member_name, passwd, id_group,
1131 1207
 					additionalGroups AS additional_groups, lngfile
1132 1208
 					FROM {db_prefix}members
@@ -1136,8 +1212,8 @@  discard block
 block discarded – undo
1136 1212
 						'db_error_skip' => true,
1137 1213
 					)
1138 1214
 				);
1139
-			else
1140
-				$request = $smcFunc['db_query']('', '
1215
+			} else {
1216
+							$request = $smcFunc['db_query']('', '
1141 1217
 					SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile
1142 1218
 					FROM {db_prefix}members
1143 1219
 					WHERE member_name = {string:member_name}',
@@ -1146,6 +1222,7 @@  discard block
 block discarded – undo
1146 1222
 						'db_error_skip' => true,
1147 1223
 					)
1148 1224
 				);
1225
+			}
1149 1226
 			if ($smcFunc['db_num_rows']($request) != 0)
1150 1227
 			{
1151 1228
 				list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request);
@@ -1153,13 +1230,14 @@  discard block
 block discarded – undo
1153 1230
 				$groups = explode(',', $addGroups);
1154 1231
 				$groups[] = $id_group;
1155 1232
 
1156
-				foreach ($groups as $k => $v)
1157
-					$groups[$k] = (int) $v;
1233
+				foreach ($groups as $k => $v) {
1234
+									$groups[$k] = (int) $v;
1235
+				}
1158 1236
 
1159 1237
 				$sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd']));
1238
+			} else {
1239
+							$upcontext['username_incorrect'] = true;
1160 1240
 			}
1161
-			else
1162
-				$upcontext['username_incorrect'] = true;
1163 1241
 			$smcFunc['db_free_result']($request);
1164 1242
 		}
1165 1243
 		$upcontext['username'] = $_POST['user'];
@@ -1169,13 +1247,14 @@  discard block
 block discarded – undo
1169 1247
 		{
1170 1248
 			$upcontext['upgrade_status']['js'] = 1;
1171 1249
 			$support_js = 1;
1250
+		} else {
1251
+					$support_js = 0;
1172 1252
 		}
1173
-		else
1174
-			$support_js = 0;
1175 1253
 
1176 1254
 		// Note down the version we are coming from.
1177
-		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version']))
1178
-			$upcontext['user']['version'] = $modSettings['smfVersion'];
1255
+		if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) {
1256
+					$upcontext['user']['version'] = $modSettings['smfVersion'];
1257
+		}
1179 1258
 
1180 1259
 		// Didn't get anywhere?
1181 1260
 		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']))
@@ -1209,15 +1288,15 @@  discard block
 block discarded – undo
1209 1288
 							'db_error_skip' => true,
1210 1289
 						)
1211 1290
 					);
1212
-					if ($smcFunc['db_num_rows']($request) == 0)
1213
-						return throw_error('You need to be an admin to perform an upgrade!');
1291
+					if ($smcFunc['db_num_rows']($request) == 0) {
1292
+											return throw_error('You need to be an admin to perform an upgrade!');
1293
+					}
1214 1294
 					$smcFunc['db_free_result']($request);
1215 1295
 				}
1216 1296
 
1217 1297
 				$upcontext['user']['id'] = $id_member;
1218 1298
 				$upcontext['user']['name'] = $name;
1219
-			}
1220
-			else
1299
+			} else
1221 1300
 			{
1222 1301
 				$upcontext['user']['id'] = 1;
1223 1302
 				$upcontext['user']['name'] = 'Administrator';
@@ -1233,11 +1312,11 @@  discard block
 block discarded – undo
1233 1312
 				$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096);
1234 1313
 				preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
1235 1314
 
1236
-				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
1237
-					$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'] . '.';
1238
-				elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php'))
1239
-					$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'] . '.';
1240
-				else
1315
+				if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
1316
+									$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'] . '.';
1317
+				} elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) {
1318
+									$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'] . '.';
1319
+				} else
1241 1320
 				{
1242 1321
 					// Set this as the new language.
1243 1322
 					$upcontext['language'] = $user_language;
@@ -1281,8 +1360,9 @@  discard block
 block discarded – undo
1281 1360
 	unset($member_columns);
1282 1361
 
1283 1362
 	// If we've not submitted then we're done.
1284
-	if (empty($_POST['upcont']))
1285
-		return false;
1363
+	if (empty($_POST['upcont'])) {
1364
+			return false;
1365
+	}
1286 1366
 
1287 1367
 	require_once($sourcedir . '/Subs-Admin.php');
1288 1368
 	updateSettingsFile(array('image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\''));
@@ -1300,25 +1380,26 @@  discard block
 block discarded – undo
1300 1380
 			fwrite($fp, $out);
1301 1381
 
1302 1382
 			$return_data = '';
1303
-			while (!feof($fp))
1304
-				$return_data .= fgets($fp, 128);
1383
+			while (!feof($fp)) {
1384
+							$return_data .= fgets($fp, 128);
1385
+			}
1305 1386
 
1306 1387
 			fclose($fp);
1307 1388
 
1308 1389
 			// Get the unique site ID.
1309 1390
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1310 1391
 
1311
-			if (!empty($ID[1]))
1312
-				$smcFunc['db_insert']('replace',
1392
+			if (!empty($ID[1])) {
1393
+							$smcFunc['db_insert']('replace',
1313 1394
 					$db_prefix . 'settings',
1314 1395
 					array('variable' => 'string', 'value' => 'string'),
1315 1396
 					array('allow_sm_stats', $ID[1]),
1316 1397
 					array('variable')
1317 1398
 				);
1399
+			}
1318 1400
 		}
1319
-	}
1320
-	else
1321
-		$smcFunc['db_query']('', '
1401
+	} else {
1402
+			$smcFunc['db_query']('', '
1322 1403
 			DELETE FROM {db_prefix}settings
1323 1404
 			WHERE variable = {string:allow_sm_stats}',
1324 1405
 			array(
@@ -1326,6 +1407,7 @@  discard block
 block discarded – undo
1326 1407
 				'db_error_skip' => true,
1327 1408
 			)
1328 1409
 		);
1410
+	}
1329 1411
 
1330 1412
 	// Deleting old karma stuff?
1331 1413
 	if (!empty($_POST['delete_karma']))
@@ -1340,20 +1422,22 @@  discard block
 block discarded – undo
1340 1422
 		);
1341 1423
 
1342 1424
 		// Cleaning up old karma member settings.
1343
-		if ($upcontext['karma_installed']['good'])
1344
-			$smcFunc['db_query']('', '
1425
+		if ($upcontext['karma_installed']['good']) {
1426
+					$smcFunc['db_query']('', '
1345 1427
 				ALTER TABLE {db_prefix}members
1346 1428
 				DROP karma_good',
1347 1429
 				array()
1348 1430
 			);
1431
+		}
1349 1432
 
1350 1433
 		// Does karma bad was enable?
1351
-		if ($upcontext['karma_installed']['bad'])
1352
-			$smcFunc['db_query']('', '
1434
+		if ($upcontext['karma_installed']['bad']) {
1435
+					$smcFunc['db_query']('', '
1353 1436
 				ALTER TABLE {db_prefix}members
1354 1437
 				DROP karma_bad',
1355 1438
 				array()
1356 1439
 			);
1440
+		}
1357 1441
 
1358 1442
 		// Cleaning up old karma permissions.
1359 1443
 		$smcFunc['db_query']('', '
@@ -1366,18 +1450,20 @@  discard block
 block discarded – undo
1366 1450
 	}
1367 1451
 
1368 1452
 	// Emptying the error log?
1369
-	if (!empty($_POST['empty_error']))
1370
-		$smcFunc['db_query']('truncate_table', '
1453
+	if (!empty($_POST['empty_error'])) {
1454
+			$smcFunc['db_query']('truncate_table', '
1371 1455
 			TRUNCATE {db_prefix}log_errors',
1372 1456
 			array(
1373 1457
 			)
1374 1458
 		);
1459
+	}
1375 1460
 
1376 1461
 	$changes = array();
1377 1462
 
1378 1463
 	// If we're overriding the language follow it through.
1379
-	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php'))
1380
-		$changes['language'] = '\'' . $_GET['lang'] . '\'';
1464
+	if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) {
1465
+			$changes['language'] = '\'' . $_GET['lang'] . '\'';
1466
+	}
1381 1467
 
1382 1468
 	if (!empty($_POST['maint']))
1383 1469
 	{
@@ -1389,37 +1475,42 @@  discard block
 block discarded – undo
1389 1475
 		{
1390 1476
 			$changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\'';
1391 1477
 			$changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\'';
1392
-		}
1393
-		else
1478
+		} else
1394 1479
 		{
1395 1480
 			$changes['mtitle'] = '\'Upgrading the forum...\'';
1396 1481
 			$changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum.  It will only be a minute ;).\'';
1397 1482
 		}
1398 1483
 	}
1399 1484
 
1400
-	if ($command_line)
1401
-		echo ' * Updating Settings.php...';
1485
+	if ($command_line) {
1486
+			echo ' * Updating Settings.php...';
1487
+	}
1402 1488
 
1403 1489
 	// Backup the current one first.
1404 1490
 	copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
1405 1491
 
1406 1492
 	// Fix some old paths.
1407
-	if (substr($boarddir, 0, 1) == '.')
1408
-		$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1493
+	if (substr($boarddir, 0, 1) == '.') {
1494
+			$changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\'';
1495
+	}
1409 1496
 
1410
-	if (substr($sourcedir, 0, 1) == '.')
1411
-		$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1497
+	if (substr($sourcedir, 0, 1) == '.') {
1498
+			$changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\'';
1499
+	}
1412 1500
 
1413
-	if (empty($cachedir) || substr($cachedir, 0, 1) == '.')
1414
-		$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1501
+	if (empty($cachedir) || substr($cachedir, 0, 1) == '.') {
1502
+			$changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\'';
1503
+	}
1415 1504
 
1416 1505
 	// Not had the database type added before?
1417
-	if (empty($db_type))
1418
-		$changes['db_type'] = 'mysql';
1506
+	if (empty($db_type)) {
1507
+			$changes['db_type'] = 'mysql';
1508
+	}
1419 1509
 
1420 1510
 	// For now we offer a option, this may change in future versions when mysql is completely removed.
1421
-	if (!empty($_POST['convertMysql']) && $db_type == 'mysql')
1422
-		$changes['db_type'] = '\'mysqli\'';
1511
+	if (!empty($_POST['convertMysql']) && $db_type == 'mysql') {
1512
+			$changes['db_type'] = '\'mysqli\'';
1513
+	}
1423 1514
 
1424 1515
 	// If they have a "host:port" setup for the host, split that into separate values
1425 1516
 	// You should never have a : in the hostname if you're not on MySQL, but better safe than sorry
@@ -1430,28 +1521,31 @@  discard block
 block discarded – undo
1430 1521
 		$changes['db_server'] = '\'' . $db_server . '\'';
1431 1522
 
1432 1523
 		// Only set this if we're not using the default port
1433
-		if ($db_port != ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port'))
1434
-			$changes['db_port'] = (int) $db_port;
1435
-	}
1436
-	elseif(!empty($db_port))
1524
+		if ($db_port != ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) {
1525
+					$changes['db_port'] = (int) $db_port;
1526
+		}
1527
+	} elseif(!empty($db_port))
1437 1528
 	{
1438 1529
 		// If db_port is set and is the same as the default, set it to ''
1439 1530
 		if ($db_type == 'mysql' || $db_type == 'mysqli')
1440 1531
 		{
1441
-			if ($db_port == ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port'))
1442
-				$changes['db_port'] = '\'\'';
1443
-			elseif ($db_type == 'postgresql' && $db_port == 5432)
1444
-				$changes['db_port'] = '\'\'';
1532
+			if ($db_port == ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) {
1533
+							$changes['db_port'] = '\'\'';
1534
+			} elseif ($db_type == 'postgresql' && $db_port == 5432) {
1535
+							$changes['db_port'] = '\'\'';
1536
+			}
1445 1537
 		}
1446 1538
 	}
1447 1539
 
1448 1540
 	// Maybe we haven't had this option yet?
1449
-	if (empty($packagesdir))
1450
-		$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1541
+	if (empty($packagesdir)) {
1542
+			$changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\'';
1543
+	}
1451 1544
 
1452 1545
 	// Add support for $tasksdir var.
1453
-	if (empty($tasksdir))
1454
-		$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1546
+	if (empty($tasksdir)) {
1547
+			$changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\'';
1548
+	}
1455 1549
 
1456 1550
 	// @todo Maybe change the cookie name if going to 1.1, too?
1457 1551
 
@@ -1496,8 +1590,7 @@  discard block
 block discarded – undo
1496 1590
 			$found_old = true;
1497 1591
 			// Replace the old line with the new code
1498 1592
 			$settings_file = str_replace('$db_last_error = ' . $db_last_error . ';', $error_catching_header . $error_catching, $settings_file);
1499
-		}
1500
-		else
1593
+		} else
1501 1594
 		{
1502 1595
 			$found_old = false;
1503 1596
 			// We want the comments as well as the code...
@@ -1528,8 +1621,9 @@  discard block
 block discarded – undo
1528 1621
 		fclose($file);
1529 1622
 	}
1530 1623
 
1531
-	if ($command_line)
1532
-		echo ' Successful.' . "\n";
1624
+	if ($command_line) {
1625
+			echo ' Successful.' . "\n";
1626
+	}
1533 1627
 
1534 1628
 	// Are we doing debug?
1535 1629
 	if (isset($_POST['debug']))
@@ -1539,8 +1633,9 @@  discard block
 block discarded – undo
1539 1633
 	}
1540 1634
 
1541 1635
 	// If we're not backing up then jump one.
1542
-	if (empty($_POST['backup']))
1543
-		$upcontext['current_step']++;
1636
+	if (empty($_POST['backup'])) {
1637
+			$upcontext['current_step']++;
1638
+	}
1544 1639
 
1545 1640
 	// If we've got here then let's proceed to the next step!
1546 1641
 	return true;
@@ -1555,8 +1650,9 @@  discard block
 block discarded – undo
1555 1650
 	$upcontext['page_title'] = 'Backup Database';
1556 1651
 
1557 1652
 	// Done it already - js wise?
1558
-	if (!empty($_POST['backup_done']))
1559
-		return true;
1653
+	if (!empty($_POST['backup_done'])) {
1654
+			return true;
1655
+	}
1560 1656
 
1561 1657
 	// Some useful stuff here.
1562 1658
 	db_extend();
@@ -1570,9 +1666,10 @@  discard block
 block discarded – undo
1570 1666
 	$tables = $smcFunc['db_list_tables']($db, $filter);
1571 1667
 
1572 1668
 	$table_names = array();
1573
-	foreach ($tables as $table)
1574
-		if (substr($table, 0, 7) !== 'backup_')
1669
+	foreach ($tables as $table) {
1670
+			if (substr($table, 0, 7) !== 'backup_')
1575 1671
 			$table_names[] = $table;
1672
+	}
1576 1673
 
1577 1674
 	$upcontext['table_count'] = count($table_names);
1578 1675
 	$upcontext['cur_table_num'] = $_GET['substep'];
@@ -1582,12 +1679,14 @@  discard block
 block discarded – undo
1582 1679
 	$file_steps = $upcontext['table_count'];
1583 1680
 
1584 1681
 	// What ones have we already done?
1585
-	foreach ($table_names as $id => $table)
1586
-		if ($id < $_GET['substep'])
1682
+	foreach ($table_names as $id => $table) {
1683
+			if ($id < $_GET['substep'])
1587 1684
 			$upcontext['previous_tables'][] = $table;
1685
+	}
1588 1686
 
1589
-	if ($command_line)
1590
-		echo 'Backing Up Tables.';
1687
+	if ($command_line) {
1688
+			echo 'Backing Up Tables.';
1689
+	}
1591 1690
 
1592 1691
 	// If we don't support javascript we backup here.
1593 1692
 	if (!$support_js || isset($_GET['xml']))
@@ -1606,8 +1705,9 @@  discard block
 block discarded – undo
1606 1705
 			backupTable($table_names[$substep]);
1607 1706
 
1608 1707
 			// If this is XML to keep it nice for the user do one table at a time anyway!
1609
-			if (isset($_GET['xml']))
1610
-				return upgradeExit();
1708
+			if (isset($_GET['xml'])) {
1709
+							return upgradeExit();
1710
+			}
1611 1711
 		}
1612 1712
 
1613 1713
 		if ($is_debug && $command_line)
@@ -1640,9 +1740,10 @@  discard block
 block discarded – undo
1640 1740
 
1641 1741
 	$smcFunc['db_backup_table']($table, 'backup_' . $table);
1642 1742
 
1643
-	if ($command_line)
1644
-		echo ' done.';
1645
-}
1743
+	if ($command_line) {
1744
+			echo ' done.';
1745
+	}
1746
+	}
1646 1747
 
1647 1748
 // Step 2: Everything.
1648 1749
 function DatabaseChanges()
@@ -1651,8 +1752,9 @@  discard block
 block discarded – undo
1651 1752
 	global $upcontext, $support_js, $db_type;
1652 1753
 
1653 1754
 	// Have we just completed this?
1654
-	if (!empty($_POST['database_done']))
1655
-		return true;
1755
+	if (!empty($_POST['database_done'])) {
1756
+			return true;
1757
+	}
1656 1758
 
1657 1759
 	$upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes';
1658 1760
 	$upcontext['page_title'] = 'Database Changes';
@@ -1669,15 +1771,16 @@  discard block
 block discarded – undo
1669 1771
 	);
1670 1772
 
1671 1773
 	// How many files are there in total?
1672
-	if (isset($_GET['filecount']))
1673
-		$upcontext['file_count'] = (int) $_GET['filecount'];
1674
-	else
1774
+	if (isset($_GET['filecount'])) {
1775
+			$upcontext['file_count'] = (int) $_GET['filecount'];
1776
+	} else
1675 1777
 	{
1676 1778
 		$upcontext['file_count'] = 0;
1677 1779
 		foreach ($files as $file)
1678 1780
 		{
1679
-			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1])
1680
-				$upcontext['file_count']++;
1781
+			if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) {
1782
+							$upcontext['file_count']++;
1783
+			}
1681 1784
 		}
1682 1785
 	}
1683 1786
 
@@ -1687,9 +1790,9 @@  discard block
 block discarded – undo
1687 1790
 	$upcontext['cur_file_num'] = 0;
1688 1791
 	foreach ($files as $file)
1689 1792
 	{
1690
-		if ($did_not_do)
1691
-			$did_not_do--;
1692
-		else
1793
+		if ($did_not_do) {
1794
+					$did_not_do--;
1795
+		} else
1693 1796
 		{
1694 1797
 			$upcontext['cur_file_num']++;
1695 1798
 			$upcontext['cur_file_name'] = $file[0];
@@ -1716,12 +1819,13 @@  discard block
 block discarded – undo
1716 1819
 					// Flag to move on to the next.
1717 1820
 					$upcontext['completed_step'] = true;
1718 1821
 					// Did we complete the whole file?
1719
-					if ($nextFile)
1720
-						$upcontext['current_debug_item_num'] = -1;
1822
+					if ($nextFile) {
1823
+											$upcontext['current_debug_item_num'] = -1;
1824
+					}
1721 1825
 					return upgradeExit();
1826
+				} elseif ($support_js) {
1827
+									break;
1722 1828
 				}
1723
-				elseif ($support_js)
1724
-					break;
1725 1829
 			}
1726 1830
 			// Set the progress bar to be right as if we had - even if we hadn't...
1727 1831
 			$upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100;
@@ -1745,8 +1849,9 @@  discard block
 block discarded – undo
1745 1849
 	global $db_prefix, $upcontext, $boarddir, $packagesdir, $settings, $smcFunc, $command_line;
1746 1850
 
1747 1851
 	// Sorry. Not supported for command line users.
1748
-	if ($command_line)
1749
-		return true;
1852
+	if ($command_line) {
1853
+			return true;
1854
+	}
1750 1855
 
1751 1856
 	// Skipping first?
1752 1857
 	if (!empty($_POST['skip']))
@@ -1756,8 +1861,9 @@  discard block
 block discarded – undo
1756 1861
 	}
1757 1862
 
1758 1863
 	// If we get here withOUT SSI we need to redirect to ensure we get it!
1759
-	if (!isset($_GET['ssi']) || !function_exists('mktree'))
1760
-		redirectLocation('&ssi=1');
1864
+	if (!isset($_GET['ssi']) || !function_exists('mktree')) {
1865
+			redirectLocation('&ssi=1');
1866
+	}
1761 1867
 
1762 1868
 	$upcontext['sub_template'] = 'clean_mods';
1763 1869
 	$upcontext['page_title'] = 'Cleanup Modifications';
@@ -1766,8 +1872,9 @@  discard block
 block discarded – undo
1766 1872
 	$upcontext['skip'] = true;
1767 1873
 
1768 1874
 	// If we're on the second redirect continue...
1769
-	if (isset($_POST['cleandone2']))
1770
-		return true;
1875
+	if (isset($_POST['cleandone2'])) {
1876
+			return true;
1877
+	}
1771 1878
 
1772 1879
 	// Do we already know about some writable files?
1773 1880
 	if (isset($_POST['writable_files']))
@@ -1782,8 +1889,9 @@  discard block
 block discarded – undo
1782 1889
 	}
1783 1890
 
1784 1891
 	// Make sure we have some sort of packages directory.
1785
-	if (!isset($packagesdir))
1786
-		$packagesdir = $boarddir . '/Packages';
1892
+	if (!isset($packagesdir)) {
1893
+			$packagesdir = $boarddir . '/Packages';
1894
+	}
1787 1895
 
1788 1896
 	// Load all theme paths....
1789 1897
 	$request = $smcFunc['db_query']('', '
@@ -1801,10 +1909,11 @@  discard block
 block discarded – undo
1801 1909
 	$theme_paths = array();
1802 1910
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1803 1911
 	{
1804
-		if ($row['id_theme'] == 1)
1805
-			$settings['default_' . $row['variable']] = $row['value'];
1806
-		elseif ($row['variable'] == 'theme_dir')
1807
-			$theme_paths[$row['id_theme']][$row['variable']] = $row['value'];
1912
+		if ($row['id_theme'] == 1) {
1913
+					$settings['default_' . $row['variable']] = $row['value'];
1914
+		} elseif ($row['variable'] == 'theme_dir') {
1915
+					$theme_paths[$row['id_theme']][$row['variable']] = $row['value'];
1916
+		}
1808 1917
 	}
1809 1918
 	$smcFunc['db_free_result']($request);
1810 1919
 
@@ -1828,8 +1937,7 @@  discard block
 block discarded – undo
1828 1937
 			$status = 'Missing';
1829 1938
 			$status_color = 'red';
1830 1939
 			$result = 'Removed';
1831
-		}
1832
-		else
1940
+		} else
1833 1941
 		{
1834 1942
 			$status = 'Installed';
1835 1943
 			$status_color = 'green';
@@ -1854,12 +1962,14 @@  discard block
 block discarded – undo
1854 1962
 	$smcFunc['db_free_result']($request);
1855 1963
 
1856 1964
 	// Don't carry on if there are none.
1857
-	if (empty($upcontext['packages']))
1858
-		return true;
1965
+	if (empty($upcontext['packages'])) {
1966
+			return true;
1967
+	}
1859 1968
 
1860 1969
 	// Setup some basics.
1861
-	if (!empty($upcontext['user']['version']))
1862
-		$_SESSION['version_emulate'] = $upcontext['user']['version'];
1970
+	if (!empty($upcontext['user']['version'])) {
1971
+			$_SESSION['version_emulate'] = $upcontext['user']['version'];
1972
+	}
1863 1973
 
1864 1974
 	// Before we get started, don't report notice errors.
1865 1975
 	$oldErrorReporting = error_reporting(E_ALL ^ E_NOTICE);
@@ -1882,34 +1992,40 @@  discard block
 block discarded – undo
1882 1992
 	foreach ($upcontext['packages'] as $id => $package)
1883 1993
 	{
1884 1994
 		// Can't do anything about this....
1885
-		if ($package['missing_file'])
1886
-			continue;
1995
+		if ($package['missing_file']) {
1996
+					continue;
1997
+		}
1887 1998
 
1888 1999
 		// Not testing *and* this wasn't checked?
1889
-		if (!$test && (!isset($_POST['remove']) || !isset($_POST['remove'][$id])))
1890
-			continue;
2000
+		if (!$test && (!isset($_POST['remove']) || !isset($_POST['remove'][$id]))) {
2001
+					continue;
2002
+		}
1891 2003
 
1892 2004
 		// What are the themes this was installed into?
1893 2005
 		$cur_theme_paths = array();
1894
-		foreach ($theme_paths as $tid => $data)
1895
-			if ($tid != 1 && in_array($tid, $package['themes']))
2006
+		foreach ($theme_paths as $tid => $data) {
2007
+					if ($tid != 1 && in_array($tid, $package['themes']))
1896 2008
 				$cur_theme_paths[$tid] = $data;
2009
+		}
1897 2010
 
1898 2011
 		// Get the modifications data if applicable.
1899 2012
 		$filename = $package['filename'];
1900 2013
 		$packageInfo = getPackageInfo($filename);
1901
-		if (!is_array($packageInfo))
1902
-			continue;
2014
+		if (!is_array($packageInfo)) {
2015
+					continue;
2016
+		}
1903 2017
 
1904 2018
 		$info = parsePackageInfo($packageInfo['xml'], $test, 'uninstall');
1905 2019
 		// Also get the reinstall details...
1906
-		if (isset($_POST['remove']))
1907
-			$infoInstall = parsePackageInfo($packageInfo['xml'], true);
2020
+		if (isset($_POST['remove'])) {
2021
+					$infoInstall = parsePackageInfo($packageInfo['xml'], true);
2022
+		}
1908 2023
 
1909
-		if (is_file($packagesdir . '/' . $filename))
1910
-			read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp');
1911
-		else
1912
-			copytree($packagesdir . '/' . $filename, $packagesdir . '/temp');
2024
+		if (is_file($packagesdir . '/' . $filename)) {
2025
+					read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp');
2026
+		} else {
2027
+					copytree($packagesdir . '/' . $filename, $packagesdir . '/temp');
2028
+		}
1913 2029
 
1914 2030
 		// Work out how we uninstall...
1915 2031
 		$files = array();
@@ -1921,16 +2037,18 @@  discard block
 block discarded – undo
1921 2037
 			if ($change['type'] == 'modification')
1922 2038
 			{
1923 2039
 				$contents = @file_get_contents($packagesdir . '/temp/' . $upcontext['base_path'] . $change['filename']);
1924
-				if ($change['boardmod'])
1925
-					$results = parseBoardMod($contents, $test, $change['reverse'], $cur_theme_paths);
1926
-				else
1927
-					$results = parseModification($contents, $test, $change['reverse'], $cur_theme_paths);
2040
+				if ($change['boardmod']) {
2041
+									$results = parseBoardMod($contents, $test, $change['reverse'], $cur_theme_paths);
2042
+				} else {
2043
+									$results = parseModification($contents, $test, $change['reverse'], $cur_theme_paths);
2044
+				}
1928 2045
 
1929 2046
 				foreach ($results as $action)
1930 2047
 				{
1931 2048
 					// Something we can remove? Probably means it existed!
1932
-					if (($action['type'] == 'replace' || $action['type'] == 'append' || (!empty($action['filename']) && $action['type'] == 'failure')) && !in_array($action['filename'], $files))
1933
-						$files[] = $action['filename'];
2049
+					if (($action['type'] == 'replace' || $action['type'] == 'append' || (!empty($action['filename']) && $action['type'] == 'failure')) && !in_array($action['filename'], $files)) {
2050
+											$files[] = $action['filename'];
2051
+					}
1934 2052
 					if ($action['type'] == 'failure')
1935 2053
 					{
1936 2054
 						$upcontext['packages'][$id]['needs_removing'] = true;
@@ -1946,17 +2064,19 @@  discard block
 block discarded – undo
1946 2064
 		$upcontext['packages'][$id]['file_count'] = count($files);
1947 2065
 
1948 2066
 		// If we've done something save the changes!
1949
-		if (!$test)
1950
-			package_flush_cache();
2067
+		if (!$test) {
2068
+					package_flush_cache();
2069
+		}
1951 2070
 
1952 2071
 		// Are we attempting to reinstall this thing?
1953 2072
 		if (isset($_POST['remove']) && !$test && isset($infoInstall))
1954 2073
 		{
1955 2074
 			// Need to extract again I'm afraid.
1956
-			if (is_file($packagesdir . '/' . $filename))
1957
-				read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp');
1958
-			else
1959
-				copytree($packagesdir . '/' . $filename, $packagesdir . '/temp');
2075
+			if (is_file($packagesdir . '/' . $filename)) {
2076
+							read_tgz_file($packagesdir . '/' . $filename, $packagesdir . '/temp');
2077
+			} else {
2078
+							copytree($packagesdir . '/' . $filename, $packagesdir . '/temp');
2079
+			}
1960 2080
 
1961 2081
 			$errors = false;
1962 2082
 			$upcontext['packages'][$id]['result'] = 'Removed';
@@ -1965,15 +2085,17 @@  discard block
 block discarded – undo
1965 2085
 				if ($change['type'] == 'modification')
1966 2086
 				{
1967 2087
 					$contents = @file_get_contents($packagesdir . '/temp/' . $upcontext['base_path'] . $change['filename']);
1968
-					if ($change['boardmod'])
1969
-						$results = parseBoardMod($contents, true, $change['reverse'], $cur_theme_paths);
1970
-					else
1971
-						$results = parseModification($contents, true, $change['reverse'], $cur_theme_paths);
2088
+					if ($change['boardmod']) {
2089
+											$results = parseBoardMod($contents, true, $change['reverse'], $cur_theme_paths);
2090
+					} else {
2091
+											$results = parseModification($contents, true, $change['reverse'], $cur_theme_paths);
2092
+					}
1972 2093
 
1973 2094
 					// Are there any errors?
1974
-					foreach ($results as $action)
1975
-						if ($action['type'] == 'failure')
2095
+					foreach ($results as $action) {
2096
+											if ($action['type'] == 'failure')
1976 2097
 							$errors = true;
2098
+					}
1977 2099
 				}
1978 2100
 			}
1979 2101
 			if (!$errors)
@@ -1986,10 +2108,11 @@  discard block
 block discarded – undo
1986 2108
 					if ($change['type'] == 'modification')
1987 2109
 					{
1988 2110
 						$contents = @file_get_contents($packagesdir . '/temp/' . $upcontext['base_path'] . $change['filename']);
1989
-						if ($change['boardmod'])
1990
-							$results = parseBoardMod($contents, false, $change['reverse'], $cur_theme_paths);
1991
-						else
1992
-							$results = parseModification($contents, false, $change['reverse'], $cur_theme_paths);
2111
+						if ($change['boardmod']) {
2112
+													$results = parseBoardMod($contents, false, $change['reverse'], $cur_theme_paths);
2113
+						} else {
2114
+													$results = parseModification($contents, false, $change['reverse'], $cur_theme_paths);
2115
+						}
1993 2116
 					}
1994 2117
 				}
1995 2118
 
@@ -2008,9 +2131,10 @@  discard block
 block discarded – undo
2008 2131
 		$writable_files = array();
2009 2132
 		foreach ($upcontext['packages'] as $package)
2010 2133
 		{
2011
-			if (!empty($package['files']))
2012
-				foreach ($package['files'] as $file)
2134
+			if (!empty($package['files'])) {
2135
+							foreach ($package['files'] as $file)
2013 2136
 					$writable_files[] = $file;
2137
+			}
2014 2138
 		}
2015 2139
 
2016 2140
 		if (!empty($writable_files))
@@ -2018,13 +2142,15 @@  discard block
 block discarded – undo
2018 2142
 			$writable_files = array_unique($writable_files);
2019 2143
 			$upcontext['writable_files'] = $writable_files;
2020 2144
 
2021
-			if (!makeFilesWritable($writable_files))
2022
-				return false;
2145
+			if (!makeFilesWritable($writable_files)) {
2146
+							return false;
2147
+			}
2023 2148
 		}
2024 2149
 	}
2025 2150
 
2026
-	if (file_exists($packagesdir . '/temp'))
2027
-		deltree($packagesdir . '/temp');
2151
+	if (file_exists($packagesdir . '/temp')) {
2152
+			deltree($packagesdir . '/temp');
2153
+	}
2028 2154
 
2029 2155
 	// Removing/Reinstalling any packages?
2030 2156
 	if (isset($_POST['remove']))
@@ -2032,32 +2158,35 @@  discard block
 block discarded – undo
2032 2158
 		$deletes = array();
2033 2159
 		foreach ($_POST['remove'] as $id => $dummy)
2034 2160
 		{
2035
-			if (!in_array((int) $id, $reinstall_worked))
2036
-				$deletes[] = (int) $id;
2161
+			if (!in_array((int) $id, $reinstall_worked)) {
2162
+							$deletes[] = (int) $id;
2163
+			}
2037 2164
 		}
2038 2165
 
2039
-		if (!empty($deletes))
2040
-			upgrade_query( '
2166
+		if (!empty($deletes)) {
2167
+					upgrade_query( '
2041 2168
 				UPDATE ' . $db_prefix . 'log_packages
2042 2169
 				SET install_state = 0
2043 2170
 				WHERE id_install IN (' . implode(',', $deletes) . ')');
2171
+		}
2044 2172
 
2045 2173
 		// Ensure we don't lose our changes!
2046 2174
 		package_put_contents($packagesdir . '/installed.list', time());
2047 2175
 
2048 2176
 		$upcontext['sub_template'] = 'cleanup_done';
2049 2177
 		return false;
2050
-	}
2051
-	else
2178
+	} else
2052 2179
 	{
2053 2180
 		$allgood = true;
2054 2181
 		// Is there actually anything that needs our attention?
2055
-		foreach ($upcontext['packages'] as $package)
2056
-			if ($package['color'] != 'green')
2182
+		foreach ($upcontext['packages'] as $package) {
2183
+					if ($package['color'] != 'green')
2057 2184
 				$allgood = false;
2185
+		}
2058 2186
 
2059
-		if ($allgood)
2060
-			return true;
2187
+		if ($allgood) {
2188
+					return true;
2189
+		}
2061 2190
 	}
2062 2191
 
2063 2192
 	$_GET['substep'] = 0;
@@ -2071,8 +2200,9 @@  discard block
 block discarded – undo
2071 2200
 	global $command_line, $language, $upcontext, $boarddir, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type;
2072 2201
 
2073 2202
 	// Now it's nice to have some of the basic SMF source files.
2074
-	if (!isset($_GET['ssi']) && !$command_line)
2075
-		redirectLocation('&ssi=1');
2203
+	if (!isset($_GET['ssi']) && !$command_line) {
2204
+			redirectLocation('&ssi=1');
2205
+	}
2076 2206
 
2077 2207
 	$upcontext['sub_template'] = 'upgrade_complete';
2078 2208
 	$upcontext['page_title'] = 'Upgrade Complete';
@@ -2088,14 +2218,16 @@  discard block
 block discarded – undo
2088 2218
 	// Are we in maintenance mode?
2089 2219
 	if (isset($upcontext['user']['main']))
2090 2220
 	{
2091
-		if ($command_line)
2092
-			echo ' * ';
2221
+		if ($command_line) {
2222
+					echo ' * ';
2223
+		}
2093 2224
 		$upcontext['removed_maintenance'] = true;
2094 2225
 		$changes['maintenance'] = $upcontext['user']['main'];
2095 2226
 	}
2096 2227
 	// Otherwise if somehow we are in 2 let's go to 1.
2097
-	elseif (!empty($maintenance) && $maintenance == 2)
2098
-		$changes['maintenance'] = 1;
2228
+	elseif (!empty($maintenance) && $maintenance == 2) {
2229
+			$changes['maintenance'] = 1;
2230
+	}
2099 2231
 
2100 2232
 	// Wipe this out...
2101 2233
 	$upcontext['user'] = array();
@@ -2111,9 +2243,9 @@  discard block
 block discarded – undo
2111 2243
 	$upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__);
2112 2244
 
2113 2245
 	// Now is the perfect time to fetch the SM files.
2114
-	if ($command_line)
2115
-		cli_scheduled_fetchSMfiles();
2116
-	else
2246
+	if ($command_line) {
2247
+			cli_scheduled_fetchSMfiles();
2248
+	} else
2117 2249
 	{
2118 2250
 		require_once($sourcedir . '/ScheduledTasks.php');
2119 2251
 		$forum_version = SMF_VERSION;  // The variable is usually defined in index.php so lets just use the constant to do it for us.
@@ -2121,8 +2253,9 @@  discard block
 block discarded – undo
2121 2253
 	}
2122 2254
 
2123 2255
 	// Log what we've done.
2124
-	if (empty($user_info['id']))
2125
-		$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
2256
+	if (empty($user_info['id'])) {
2257
+			$user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0;
2258
+	}
2126 2259
 
2127 2260
 	// Log the action manually, so CLI still works.
2128 2261
 	$smcFunc['db_insert']('',
@@ -2141,8 +2274,9 @@  discard block
 block discarded – undo
2141 2274
 
2142 2275
 	// Save the current database version.
2143 2276
 	$server_version = $smcFunc['db_server_info']();
2144
-	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
2145
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
2277
+	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
2278
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
2279
+	}
2146 2280
 
2147 2281
 	if ($command_line)
2148 2282
 	{
@@ -2154,8 +2288,9 @@  discard block
 block discarded – undo
2154 2288
 
2155 2289
 	// Make sure it says we're done.
2156 2290
 	$upcontext['overall_percent'] = 100;
2157
-	if (isset($upcontext['step_progress']))
2158
-		unset($upcontext['step_progress']);
2291
+	if (isset($upcontext['step_progress'])) {
2292
+			unset($upcontext['step_progress']);
2293
+	}
2159 2294
 
2160 2295
 	$_GET['substep'] = 0;
2161 2296
 	return false;
@@ -2166,8 +2301,9 @@  discard block
 block discarded – undo
2166 2301
 {
2167 2302
 	global $sourcedir, $language, $forum_version, $modSettings, $smcFunc;
2168 2303
 
2169
-	if (empty($modSettings['time_format']))
2170
-		$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
2304
+	if (empty($modSettings['time_format'])) {
2305
+			$modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p';
2306
+	}
2171 2307
 
2172 2308
 	// What files do we want to get
2173 2309
 	$request = $smcFunc['db_query']('', '
@@ -2201,8 +2337,9 @@  discard block
 block discarded – undo
2201 2337
 		$file_data = fetch_web_data($url);
2202 2338
 
2203 2339
 		// If we got an error - give up - the site might be down.
2204
-		if ($file_data === false)
2205
-			return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
2340
+		if ($file_data === false) {
2341
+					return throw_error(sprintf('Could not retrieve the file %1$s.', $url));
2342
+		}
2206 2343
 
2207 2344
 		// Save the file to the database.
2208 2345
 		$smcFunc['db_query']('substring', '
@@ -2244,8 +2381,9 @@  discard block
 block discarded – undo
2244 2381
 	$themeData = array();
2245 2382
 	foreach ($values as $variable => $value)
2246 2383
 	{
2247
-		if (!isset($value) || $value === null)
2248
-			$value = 0;
2384
+		if (!isset($value) || $value === null) {
2385
+					$value = 0;
2386
+		}
2249 2387
 
2250 2388
 		$themeData[] = array(0, 1, $variable, $value);
2251 2389
 	}
@@ -2274,8 +2412,9 @@  discard block
 block discarded – undo
2274 2412
 
2275 2413
 	foreach ($values as $variable => $value)
2276 2414
 	{
2277
-		if (empty($modSettings[$value[0]]))
2278
-			continue;
2415
+		if (empty($modSettings[$value[0]])) {
2416
+					continue;
2417
+		}
2279 2418
 
2280 2419
 		$smcFunc['db_query']('', '
2281 2420
 			INSERT IGNORE INTO {db_prefix}themes
@@ -2308,8 +2447,9 @@  discard block
 block discarded – undo
2308 2447
 
2309 2448
 	$settingsArray = file($boarddir . '/Settings_bak.php');
2310 2449
 
2311
-	if (count($settingsArray) == 1)
2312
-		$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
2450
+	if (count($settingsArray) == 1) {
2451
+			$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
2452
+	}
2313 2453
 
2314 2454
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
2315 2455
 	{
@@ -2322,9 +2462,9 @@  discard block
 block discarded – undo
2322 2462
 			{
2323 2463
 				if (isset($settingsArray[$i]) && strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
2324 2464
 				{
2325
-					if ($val == '#remove#')
2326
-						unset($settingsArray[$i]);
2327
-					else
2465
+					if ($val == '#remove#') {
2466
+											unset($settingsArray[$i]);
2467
+					} else
2328 2468
 					{
2329 2469
 						$comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#');
2330 2470
 						$settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment != '' ? "\t\t" . $comment : "\n");
@@ -2336,22 +2476,25 @@  discard block
 block discarded – undo
2336 2476
 		}
2337 2477
 		if (isset($settingsArray[$i]))
2338 2478
 		{
2339
-			if (trim(substr($settingsArray[$i], 0, 2)) == '?' . '>')
2340
-				$end = $i;
2479
+			if (trim(substr($settingsArray[$i], 0, 2)) == '?' . '>') {
2480
+							$end = $i;
2481
+			}
2341 2482
 		}
2342 2483
 	}
2343 2484
 
2344 2485
 	// Assume end-of-file if the end wasn't found.
2345
-	if (empty($end) || $end < 10)
2346
-		$end = count($settingsArray);
2486
+	if (empty($end) || $end < 10) {
2487
+			$end = count($settingsArray);
2488
+	}
2347 2489
 
2348 2490
 	if (!empty($config_vars))
2349 2491
 	{
2350 2492
 		$settingsArray[$end++] = '';
2351 2493
 		foreach ($config_vars as $var => $val)
2352 2494
 		{
2353
-			if ($val != '#remove#')
2354
-				$settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n";
2495
+			if ($val != '#remove#') {
2496
+							$settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n";
2497
+			}
2355 2498
 		}
2356 2499
 	}
2357 2500
 	// This should be the last line and even last bytes of the file.
@@ -2364,8 +2507,9 @@  discard block
 block discarded – undo
2364 2507
 	$fp = fopen($boarddir . '/Settings.php', 'r+');
2365 2508
 	for ($i = 0; $i < $end; $i++)
2366 2509
 	{
2367
-		if (isset($settingsArray[$i]))
2368
-			fwrite($fp, strtr($settingsArray[$i], "\r", ''));
2510
+		if (isset($settingsArray[$i])) {
2511
+					fwrite($fp, strtr($settingsArray[$i], "\r", ''));
2512
+		}
2369 2513
 	}
2370 2514
 	fwrite($fp, rtrim($settingsArray[$i]));
2371 2515
 	fclose($fp);
@@ -2396,8 +2540,9 @@  discard block
 block discarded – undo
2396 2540
 	global $smcFunc;
2397 2541
 	static $member_groups = array();
2398 2542
 
2399
-	if (!empty($member_groups))
2400
-		return $member_groups;
2543
+	if (!empty($member_groups)) {
2544
+			return $member_groups;
2545
+	}
2401 2546
 
2402 2547
 	$request = $smcFunc['db_query']('', '
2403 2548
 		SELECT group_name, id_group
@@ -2422,8 +2567,9 @@  discard block
 block discarded – undo
2422 2567
 			)
2423 2568
 		);
2424 2569
 	}
2425
-	while ($row = $smcFunc['db_fetch_row']($request))
2426
-		$member_groups[trim($row[0])] = $row[1];
2570
+	while ($row = $smcFunc['db_fetch_row']($request)) {
2571
+			$member_groups[trim($row[0])] = $row[1];
2572
+	}
2427 2573
 	$smcFunc['db_free_result']($request);
2428 2574
 
2429 2575
 	return $member_groups;
@@ -2476,10 +2622,11 @@  discard block
 block discarded – undo
2476 2622
 		{
2477 2623
 			global $support_js;
2478 2624
 
2479
-			if ($support_js)
2480
-				return true;
2481
-			else
2482
-				echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
2625
+			if ($support_js) {
2626
+							return true;
2627
+			} else {
2628
+							echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline;
2629
+			}
2483 2630
 		}
2484 2631
 	}
2485 2632
 
@@ -2497,8 +2644,9 @@  discard block
 block discarded – undo
2497 2644
 				'db_error_skip' => true,
2498 2645
 			)
2499 2646
 		);
2500
-		if ($smcFunc['db_num_rows']($request) === 0)
2501
-			die('Unable to find members table!');
2647
+		if ($smcFunc['db_num_rows']($request) === 0) {
2648
+					die('Unable to find members table!');
2649
+		}
2502 2650
 		$table_status = $smcFunc['db_fetch_assoc']($request);
2503 2651
 		$smcFunc['db_free_result']($request);
2504 2652
 
@@ -2513,17 +2661,20 @@  discard block
 block discarded – undo
2513 2661
 				)
2514 2662
 			);
2515 2663
 			// Got something?
2516
-			if ($smcFunc['db_num_rows']($request) !== 0)
2517
-				$collation_info = $smcFunc['db_fetch_assoc']($request);
2664
+			if ($smcFunc['db_num_rows']($request) !== 0) {
2665
+							$collation_info = $smcFunc['db_fetch_assoc']($request);
2666
+			}
2518 2667
 			$smcFunc['db_free_result']($request);
2519 2668
 
2520 2669
 			// Excellent!
2521
-			if (!empty($collation_info['Collation']) && !empty($collation_info['Charset']))
2522
-				$db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation'];
2670
+			if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) {
2671
+							$db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation'];
2672
+			}
2523 2673
 		}
2524 2674
 	}
2525
-	if (empty($db_collation))
2526
-		$db_collation = '';
2675
+	if (empty($db_collation)) {
2676
+			$db_collation = '';
2677
+	}
2527 2678
 
2528 2679
 	$endl = $command_line ? "\n" : '<br>' . "\n";
2529 2680
 
@@ -2535,8 +2686,9 @@  discard block
 block discarded – undo
2535 2686
 	$last_step = '';
2536 2687
 
2537 2688
 	// Make sure all newly created tables will have the proper characters set.
2538
-	if (isset($db_character_set) && $db_character_set === 'utf8')
2539
-		$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
2689
+	if (isset($db_character_set) && $db_character_set === 'utf8') {
2690
+			$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
2691
+	}
2540 2692
 
2541 2693
 	// Count the total number of steps within this file - for progress.
2542 2694
 	$file_steps = substr_count(implode('', $lines), '---#');
@@ -2556,15 +2708,18 @@  discard block
 block discarded – undo
2556 2708
 		$do_current = $substep >= $_GET['substep'];
2557 2709
 
2558 2710
 		// Get rid of any comments in the beginning of the line...
2559
-		if (substr(trim($line), 0, 2) === '/*')
2560
-			$line = preg_replace('~/\*.+?\*/~', '', $line);
2711
+		if (substr(trim($line), 0, 2) === '/*') {
2712
+					$line = preg_replace('~/\*.+?\*/~', '', $line);
2713
+		}
2561 2714
 
2562 2715
 		// Always flush.  Flush, flush, flush.  Flush, flush, flush, flush!  FLUSH!
2563
-		if ($is_debug && !$support_js && $command_line)
2564
-			flush();
2716
+		if ($is_debug && !$support_js && $command_line) {
2717
+					flush();
2718
+		}
2565 2719
 
2566
-		if (trim($line) === '')
2567
-			continue;
2720
+		if (trim($line) === '') {
2721
+					continue;
2722
+		}
2568 2723
 
2569 2724
 		if (trim(substr($line, 0, 3)) === '---')
2570 2725
 		{
@@ -2574,8 +2729,9 @@  discard block
 block discarded – undo
2574 2729
 			if (trim($current_data) != '' && $type !== '}')
2575 2730
 			{
2576 2731
 				$upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl;
2577
-				if ($command_line)
2578
-					echo $upcontext['error_message'];
2732
+				if ($command_line) {
2733
+									echo $upcontext['error_message'];
2734
+				}
2579 2735
 			}
2580 2736
 
2581 2737
 			if ($type == ' ')
@@ -2593,17 +2749,18 @@  discard block
 block discarded – undo
2593 2749
 				if ($do_current)
2594 2750
 				{
2595 2751
 					$upcontext['actioned_items'][] = $last_step;
2596
-					if ($command_line)
2597
-						echo ' * ';
2752
+					if ($command_line) {
2753
+											echo ' * ';
2754
+					}
2598 2755
 				}
2599
-			}
2600
-			elseif ($type == '#')
2756
+			} elseif ($type == '#')
2601 2757
 			{
2602 2758
 				$upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps;
2603 2759
 
2604 2760
 				$upcontext['current_debug_item_num']++;
2605
-				if (trim($line) != '---#')
2606
-					$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
2761
+				if (trim($line) != '---#') {
2762
+									$upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4)));
2763
+				}
2607 2764
 
2608 2765
 				// Have we already done something?
2609 2766
 				if (isset($_GET['xml']) && $done_something)
@@ -2614,34 +2771,36 @@  discard block
 block discarded – undo
2614 2771
 
2615 2772
 				if ($do_current)
2616 2773
 				{
2617
-					if (trim($line) == '---#' && $command_line)
2618
-						echo ' done.', $endl;
2619
-					elseif ($command_line)
2620
-						echo ' +++ ', rtrim(substr($line, 4));
2621
-					elseif (trim($line) != '---#')
2774
+					if (trim($line) == '---#' && $command_line) {
2775
+											echo ' done.', $endl;
2776
+					} elseif ($command_line) {
2777
+											echo ' +++ ', rtrim(substr($line, 4));
2778
+					} elseif (trim($line) != '---#')
2622 2779
 					{
2623
-						if ($is_debug)
2624
-							$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
2780
+						if ($is_debug) {
2781
+													$upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4)));
2782
+						}
2625 2783
 					}
2626 2784
 				}
2627 2785
 
2628 2786
 				if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep'])
2629 2787
 				{
2630
-					if ($command_line)
2631
-						echo ' * ';
2632
-					else
2633
-						$upcontext['actioned_items'][] = $last_step;
2788
+					if ($command_line) {
2789
+											echo ' * ';
2790
+					} else {
2791
+											$upcontext['actioned_items'][] = $last_step;
2792
+					}
2634 2793
 				}
2635 2794
 
2636 2795
 				// Small step - only if we're actually doing stuff.
2637
-				if ($do_current)
2638
-					nextSubstep(++$substep);
2639
-				else
2640
-					$substep++;
2641
-			}
2642
-			elseif ($type == '{')
2643
-				$current_type = 'code';
2644
-			elseif ($type == '}')
2796
+				if ($do_current) {
2797
+									nextSubstep(++$substep);
2798
+				} else {
2799
+									$substep++;
2800
+				}
2801
+			} elseif ($type == '{') {
2802
+							$current_type = 'code';
2803
+			} elseif ($type == '}')
2645 2804
 			{
2646 2805
 				$current_type = 'sql';
2647 2806
 
@@ -2654,8 +2813,9 @@  discard block
 block discarded – undo
2654 2813
 				if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false)
2655 2814
 				{
2656 2815
 					$upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl;
2657
-					if ($command_line)
2658
-						echo $upcontext['error_message'];
2816
+					if ($command_line) {
2817
+											echo $upcontext['error_message'];
2818
+					}
2659 2819
 				}
2660 2820
 
2661 2821
 				// Done with code!
@@ -2735,8 +2895,9 @@  discard block
 block discarded – undo
2735 2895
 	$db_unbuffered = false;
2736 2896
 
2737 2897
 	// Failure?!
2738
-	if ($result !== false)
2739
-		return $result;
2898
+	if ($result !== false) {
2899
+			return $result;
2900
+	}
2740 2901
 
2741 2902
 	$db_error_message = $smcFunc['db_error']($db_connection);
2742 2903
 	// If MySQL we do something more clever.
@@ -2766,17 +2927,16 @@  discard block
 block discarded – undo
2766 2927
 				{
2767 2928
 					mysql_query('REPAIR TABLE `' . $match[1] . '`');
2768 2929
 					$result = mysql_query($string);
2769
-				}
2770
-				else
2930
+				} else
2771 2931
 				{
2772 2932
 					mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`');
2773 2933
 					$result = mysqli_query($db_connection, $string);
2774 2934
 				}
2775
-				if ($result !== false)
2776
-					return $result;
2935
+				if ($result !== false) {
2936
+									return $result;
2937
+				}
2777 2938
 			}
2778
-		}
2779
-		elseif ($mysql_errno == 2013)
2939
+		} elseif ($mysql_errno == 2013)
2780 2940
 		{
2781 2941
 			$db_connection = mysql_connect($db_server, $db_user, $db_passwd);
2782 2942
 			if ($db_type == 'mysql')
@@ -2785,54 +2945,61 @@  discard block
 block discarded – undo
2785 2945
 				if ($db_connection)
2786 2946
 				{
2787 2947
 					$result = mysql_query($string);
2788
-					if ($result !== false)
2789
-						return $result;
2948
+					if ($result !== false) {
2949
+											return $result;
2950
+					}
2790 2951
 				}
2791
-			}
2792
-			else
2952
+			} else
2793 2953
 			{
2794 2954
 				mysqli_select_db($db_connection, $db_name);
2795 2955
 				if ($db_connection)
2796 2956
 				{
2797 2957
 					$result = mysqli_query($db_connection, $string);
2798
-					if ($result !== false)
2799
-						return $result;
2958
+					if ($result !== false) {
2959
+											return $result;
2960
+					}
2800 2961
 				}
2801 2962
 			}
2802 2963
 		}
2803 2964
 		// Duplicate column name... should be okay ;).
2804
-		elseif (in_array($mysql_errno, array(1060, 1061, 1068, 1091)))
2805
-			return false;
2965
+		elseif (in_array($mysql_errno, array(1060, 1061, 1068, 1091))) {
2966
+					return false;
2967
+		}
2806 2968
 		// Duplicate insert... make sure it's the proper type of query ;).
2807
-		elseif (in_array($mysql_errno, array(1054, 1062, 1146)) && $error_query)
2808
-			return false;
2969
+		elseif (in_array($mysql_errno, array(1054, 1062, 1146)) && $error_query) {
2970
+					return false;
2971
+		}
2809 2972
 		// Creating an index on a non-existent column.
2810
-		elseif ($mysql_errno == 1072)
2811
-			return false;
2812
-		elseif ($mysql_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE')
2813
-			return false;
2973
+		elseif ($mysql_errno == 1072) {
2974
+					return false;
2975
+		} elseif ($mysql_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') {
2976
+					return false;
2977
+		}
2814 2978
 	}
2815 2979
 	// If a table already exists don't go potty.
2816 2980
 	else
2817 2981
 	{
2818 2982
 		if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U')))
2819 2983
 		{
2820
-			if (strpos($db_error_message, 'exist') !== false)
2821
-				return true;
2822
-		}
2823
-		elseif (strpos(trim($string), 'INSERT ') !== false)
2984
+			if (strpos($db_error_message, 'exist') !== false) {
2985
+							return true;
2986
+			}
2987
+		} elseif (strpos(trim($string), 'INSERT ') !== false)
2824 2988
 		{
2825
-			if (strpos($db_error_message, 'duplicate') !== false)
2826
-				return true;
2989
+			if (strpos($db_error_message, 'duplicate') !== false) {
2990
+							return true;
2991
+			}
2827 2992
 		}
2828 2993
 	}
2829 2994
 
2830 2995
 	// Get the query string so we pass everything.
2831 2996
 	$query_string = '';
2832
-	foreach ($_GET as $k => $v)
2833
-		$query_string .= ';' . $k . '=' . $v;
2834
-	if (strlen($query_string) != 0)
2835
-		$query_string = '?' . substr($query_string, 1);
2997
+	foreach ($_GET as $k => $v) {
2998
+			$query_string .= ';' . $k . '=' . $v;
2999
+	}
3000
+	if (strlen($query_string) != 0) {
3001
+			$query_string = '?' . substr($query_string, 1);
3002
+	}
2836 3003
 
2837 3004
 	if ($command_line)
2838 3005
 	{
@@ -2922,16 +3089,18 @@  discard block
 block discarded – undo
2922 3089
 			{
2923 3090
 				$found |= 1;
2924 3091
 				// Do some checks on the data if we have it set.
2925
-				if (isset($change['col_type']))
2926
-					$found &= $change['col_type'] === $column['type'];
2927
-				if (isset($change['null_allowed']))
2928
-					$found &= $column['null'] == $change['null_allowed'];
2929
-				if (isset($change['default']))
2930
-					$found &= $change['default'] === $column['default'];
3092
+				if (isset($change['col_type'])) {
3093
+									$found &= $change['col_type'] === $column['type'];
3094
+				}
3095
+				if (isset($change['null_allowed'])) {
3096
+									$found &= $column['null'] == $change['null_allowed'];
3097
+				}
3098
+				if (isset($change['default'])) {
3099
+									$found &= $change['default'] === $column['default'];
3100
+				}
2931 3101
 			}
2932 3102
 		}
2933
-	}
2934
-	elseif ($change['type'] === 'index')
3103
+	} elseif ($change['type'] === 'index')
2935 3104
 	{
2936 3105
 		$request = upgrade_query( '
2937 3106
 			SHOW INDEX
@@ -2940,9 +3109,10 @@  discard block
 block discarded – undo
2940 3109
 		{
2941 3110
 			$cur_index = array();
2942 3111
 
2943
-			while ($row = $smcFunc['db_fetch_assoc']($request))
2944
-				if ($row['Key_name'] === $change['name'])
3112
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
3113
+							if ($row['Key_name'] === $change['name'])
2945 3114
 					$cur_index[(int) $row['Seq_in_index']] = $row['Column_name'];
3115
+			}
2946 3116
 
2947 3117
 			ksort($cur_index, SORT_NUMERIC);
2948 3118
 			$found = array_values($cur_index) === $change['target_columns'];
@@ -2952,14 +3122,17 @@  discard block
 block discarded – undo
2952 3122
 	}
2953 3123
 
2954 3124
 	// If we're trying to add and it's added, we're done.
2955
-	if ($found && in_array($change['method'], array('add', 'change')))
2956
-		return true;
3125
+	if ($found && in_array($change['method'], array('add', 'change'))) {
3126
+			return true;
3127
+	}
2957 3128
 	// Otherwise if we're removing and it wasn't found we're also done.
2958
-	elseif (!$found && in_array($change['method'], array('remove', 'change_remove')))
2959
-		return true;
3129
+	elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) {
3130
+			return true;
3131
+	}
2960 3132
 	// Otherwise is it just a test?
2961
-	elseif ($is_test)
2962
-		return false;
3133
+	elseif ($is_test) {
3134
+			return false;
3135
+	}
2963 3136
 
2964 3137
 	// Not found it yet? Bummer! How about we see if we're currently doing it?
2965 3138
 	$running = false;
@@ -2970,8 +3143,9 @@  discard block
 block discarded – undo
2970 3143
 			SHOW FULL PROCESSLIST');
2971 3144
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2972 3145
 		{
2973
-			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false)
2974
-				$found = true;
3146
+			if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) {
3147
+							$found = true;
3148
+			}
2975 3149
 		}
2976 3150
 
2977 3151
 		// Can't find it? Then we need to run it fools!
@@ -2983,8 +3157,9 @@  discard block
 block discarded – undo
2983 3157
 				ALTER TABLE ' . $db_prefix . $change['table'] . '
2984 3158
 				' . $change['text'], true) !== false;
2985 3159
 
2986
-			if (!$success)
2987
-				return false;
3160
+			if (!$success) {
3161
+							return false;
3162
+			}
2988 3163
 
2989 3164
 			// Return
2990 3165
 			$running = true;
@@ -3017,8 +3192,7 @@  discard block
 block discarded – undo
3017 3192
 	{
3018 3193
 		$column_fix = true;
3019 3194
 		$null_fix = !$change['null_allowed'];
3020
-	}
3021
-	else
3195
+	} else
3022 3196
 	{
3023 3197
 		$request = $smcFunc['db_query']('', '
3024 3198
 			SHOW FULL COLUMNS
@@ -3029,8 +3203,9 @@  discard block
 block discarded – undo
3029 3203
 				'db_error_skip' => true,
3030 3204
 			)
3031 3205
 		);
3032
-		if ($smcFunc['db_num_rows']($request) === 0)
3033
-			die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
3206
+		if ($smcFunc['db_num_rows']($request) === 0) {
3207
+					die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']);
3208
+		}
3034 3209
 		$table_row = $smcFunc['db_fetch_assoc']($request);
3035 3210
 		$smcFunc['db_free_result']($request);
3036 3211
 
@@ -3052,10 +3227,11 @@  discard block
 block discarded – undo
3052 3227
 				)
3053 3228
 			);
3054 3229
 			// No results? Just forget it all together.
3055
-			if ($smcFunc['db_num_rows']($request) === 0)
3056
-				unset($table_row['Collation']);
3057
-			else
3058
-				$collation_info = $smcFunc['db_fetch_assoc']($request);
3230
+			if ($smcFunc['db_num_rows']($request) === 0) {
3231
+							unset($table_row['Collation']);
3232
+			} else {
3233
+							$collation_info = $smcFunc['db_fetch_assoc']($request);
3234
+			}
3059 3235
 			$smcFunc['db_free_result']($request);
3060 3236
 		}
3061 3237
 	}
@@ -3063,8 +3239,8 @@  discard block
 block discarded – undo
3063 3239
 	if ($column_fix)
3064 3240
 	{
3065 3241
 		// Make sure there are no NULL's left.
3066
-		if ($null_fix)
3067
-			$smcFunc['db_query']('', '
3242
+		if ($null_fix) {
3243
+					$smcFunc['db_query']('', '
3068 3244
 				UPDATE {db_prefix}' . $change['table'] . '
3069 3245
 				SET ' . $change['column'] . ' = {string:default}
3070 3246
 				WHERE ' . $change['column'] . ' IS NULL',
@@ -3073,6 +3249,7 @@  discard block
 block discarded – undo
3073 3249
 					'db_error_skip' => true,
3074 3250
 				)
3075 3251
 			);
3252
+		}
3076 3253
 
3077 3254
 		// Do the actual alteration.
3078 3255
 		$smcFunc['db_query']('', '
@@ -3101,8 +3278,9 @@  discard block
 block discarded – undo
3101 3278
 	}
3102 3279
 
3103 3280
 	// Not a column we need to check on?
3104
-	if (!in_array($change['name'], array('memberGroups', 'passwordSalt')))
3105
-		return;
3281
+	if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) {
3282
+			return;
3283
+	}
3106 3284
 
3107 3285
 	// Break it up you (six|seven).
3108 3286
 	$temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text']));
@@ -3120,13 +3298,13 @@  discard block
 block discarded – undo
3120 3298
 				'old_name' => $temp[1],
3121 3299
 				'new_name' => $temp[2],
3122 3300
 		));
3123
-		if ($smcFunc['db_num_rows'] != 1)
3124
-			return;
3301
+		if ($smcFunc['db_num_rows'] != 1) {
3302
+					return;
3303
+		}
3125 3304
 
3126 3305
 		list (, $current_type) = $smcFunc['db_fetch_assoc']($request);
3127 3306
 		$smcFunc['db_free_result']($request);
3128
-	}
3129
-	else
3307
+	} else
3130 3308
 	{
3131 3309
 		// Do this the old fashion, sure method way.
3132 3310
 		$request = $smcFunc['db_query']('', '
@@ -3136,21 +3314,24 @@  discard block
 block discarded – undo
3136 3314
 				'table' => $change['table'],
3137 3315
 		));
3138 3316
 		// Mayday!
3139
-		if ($smcFunc['db_num_rows'] == 0)
3140
-			return;
3317
+		if ($smcFunc['db_num_rows'] == 0) {
3318
+					return;
3319
+		}
3141 3320
 
3142 3321
 		// Oh where, oh where has my little field gone. Oh where can it be...
3143
-		while ($row = $smcFunc['db_query']($request))
3144
-			if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
3322
+		while ($row = $smcFunc['db_query']($request)) {
3323
+					if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2])
3145 3324
 			{
3146 3325
 				$current_type = $row['Type'];
3326
+		}
3147 3327
 				break;
3148 3328
 			}
3149 3329
 	}
3150 3330
 
3151 3331
 	// If this doesn't match, the column may of been altered for a reason.
3152
-	if (trim($current_type) != trim($temp[3]))
3153
-		$temp[3] = $current_type;
3332
+	if (trim($current_type) != trim($temp[3])) {
3333
+			$temp[3] = $current_type;
3334
+	}
3154 3335
 
3155 3336
 	// Piece this back together.
3156 3337
 	$change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp));
@@ -3162,8 +3343,9 @@  discard block
 block discarded – undo
3162 3343
 	global $start_time, $timeLimitThreshold, $command_line, $custom_warning;
3163 3344
 	global $step_progress, $is_debug, $upcontext;
3164 3345
 
3165
-	if ($_GET['substep'] < $substep)
3166
-		$_GET['substep'] = $substep;
3346
+	if ($_GET['substep'] < $substep) {
3347
+			$_GET['substep'] = $substep;
3348
+	}
3167 3349
 
3168 3350
 	if ($command_line)
3169 3351
 	{
@@ -3176,29 +3358,33 @@  discard block
 block discarded – undo
3176 3358
 	}
3177 3359
 
3178 3360
 	@set_time_limit(300);
3179
-	if (function_exists('apache_reset_timeout'))
3180
-		@apache_reset_timeout();
3361
+	if (function_exists('apache_reset_timeout')) {
3362
+			@apache_reset_timeout();
3363
+	}
3181 3364
 
3182
-	if (time() - $start_time <= $timeLimitThreshold)
3183
-		return;
3365
+	if (time() - $start_time <= $timeLimitThreshold) {
3366
+			return;
3367
+	}
3184 3368
 
3185 3369
 	// Do we have some custom step progress stuff?
3186 3370
 	if (!empty($step_progress))
3187 3371
 	{
3188 3372
 		$upcontext['substep_progress'] = 0;
3189 3373
 		$upcontext['substep_progress_name'] = $step_progress['name'];
3190
-		if ($step_progress['current'] > $step_progress['total'])
3191
-			$upcontext['substep_progress'] = 99.9;
3192
-		else
3193
-			$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
3374
+		if ($step_progress['current'] > $step_progress['total']) {
3375
+					$upcontext['substep_progress'] = 99.9;
3376
+		} else {
3377
+					$upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100;
3378
+		}
3194 3379
 
3195 3380
 		// Make it nicely rounded.
3196 3381
 		$upcontext['substep_progress'] = round($upcontext['substep_progress'], 1);
3197 3382
 	}
3198 3383
 
3199 3384
 	// If this is XML we just exit right away!
3200
-	if (isset($_GET['xml']))
3201
-		return upgradeExit();
3385
+	if (isset($_GET['xml'])) {
3386
+			return upgradeExit();
3387
+	}
3202 3388
 
3203 3389
 	// We're going to pause after this!
3204 3390
 	$upcontext['pause'] = true;
@@ -3206,13 +3392,15 @@  discard block
 block discarded – undo
3206 3392
 	$upcontext['query_string'] = '';
3207 3393
 	foreach ($_GET as $k => $v)
3208 3394
 	{
3209
-		if ($k != 'data' && $k != 'substep' && $k != 'step')
3210
-			$upcontext['query_string'] .= ';' . $k . '=' . $v;
3395
+		if ($k != 'data' && $k != 'substep' && $k != 'step') {
3396
+					$upcontext['query_string'] .= ';' . $k . '=' . $v;
3397
+		}
3211 3398
 	}
3212 3399
 
3213 3400
 	// Custom warning?
3214
-	if (!empty($custom_warning))
3215
-		$upcontext['custom_warning'] = $custom_warning;
3401
+	if (!empty($custom_warning)) {
3402
+			$upcontext['custom_warning'] = $custom_warning;
3403
+	}
3216 3404
 
3217 3405
 	upgradeExit();
3218 3406
 }
@@ -3227,25 +3415,26 @@  discard block
 block discarded – undo
3227 3415
 	ob_implicit_flush(true);
3228 3416
 	@set_time_limit(600);
3229 3417
 
3230
-	if (!isset($_SERVER['argv']))
3231
-		$_SERVER['argv'] = array();
3418
+	if (!isset($_SERVER['argv'])) {
3419
+			$_SERVER['argv'] = array();
3420
+	}
3232 3421
 	$_GET['maint'] = 1;
3233 3422
 
3234 3423
 	foreach ($_SERVER['argv'] as $i => $arg)
3235 3424
 	{
3236
-		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0)
3237
-			$_GET['lang'] = $match[1];
3238
-		elseif (preg_match('~^--path=(.+)$~', $arg) != 0)
3239
-			continue;
3240
-		elseif ($arg == '--no-maintenance')
3241
-			$_GET['maint'] = 0;
3242
-		elseif ($arg == '--debug')
3243
-			$is_debug = true;
3244
-		elseif ($arg == '--backup')
3245
-			$_POST['backup'] = 1;
3246
-		elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted')))
3247
-			$_GET['conv'] = 1;
3248
-		elseif ($i != 0)
3425
+		if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) {
3426
+					$_GET['lang'] = $match[1];
3427
+		} elseif (preg_match('~^--path=(.+)$~', $arg) != 0) {
3428
+					continue;
3429
+		} elseif ($arg == '--no-maintenance') {
3430
+					$_GET['maint'] = 0;
3431
+		} elseif ($arg == '--debug') {
3432
+					$is_debug = true;
3433
+		} elseif ($arg == '--backup') {
3434
+					$_POST['backup'] = 1;
3435
+		} elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) {
3436
+					$_GET['conv'] = 1;
3437
+		} elseif ($i != 0)
3249 3438
 		{
3250 3439
 			echo 'SMF Command-line Upgrader
3251 3440
 Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]...
@@ -3259,10 +3448,12 @@  discard block
 block discarded – undo
3259 3448
 		}
3260 3449
 	}
3261 3450
 
3262
-	if (!php_version_check())
3263
-		print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
3264
-	if (!db_version_check())
3265
-		print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
3451
+	if (!php_version_check()) {
3452
+			print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true);
3453
+	}
3454
+	if (!db_version_check()) {
3455
+			print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true);
3456
+	}
3266 3457
 
3267 3458
 	// Do some checks to make sure they have proper privileges
3268 3459
 	db_extend('packages');
@@ -3277,34 +3468,39 @@  discard block
 block discarded – undo
3277 3468
 	$drop = $smcFunc['db_drop_table']('{db_prefix}priv_check');
3278 3469
 
3279 3470
 	// Sorry... we need CREATE, ALTER and DROP
3280
-	if (!$create || !$alter || !$drop)
3281
-		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);
3471
+	if (!$create || !$alter || !$drop) {
3472
+			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);
3473
+	}
3282 3474
 
3283 3475
 	$check = @file_exists($modSettings['theme_dir'] . '/index.template.php')
3284 3476
 		&& @file_exists($sourcedir . '/QueryString.php')
3285 3477
 		&& @file_exists($sourcedir . '/ManageBoards.php');
3286
-	if (!$check && !isset($modSettings['smfVersion']))
3287
-		print_error('Error: Some files are missing or out-of-date.', true);
3478
+	if (!$check && !isset($modSettings['smfVersion'])) {
3479
+			print_error('Error: Some files are missing or out-of-date.', true);
3480
+	}
3288 3481
 
3289 3482
 	// Do a quick version spot check.
3290 3483
 	$temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096);
3291 3484
 	preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match);
3292
-	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION))
3293
-		print_error('Error: Some files have not yet been updated properly.');
3485
+	if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) {
3486
+			print_error('Error: Some files have not yet been updated properly.');
3487
+	}
3294 3488
 
3295 3489
 	// Make sure Settings.php is writable.
3296 3490
 		quickFileWritable($boarddir . '/Settings.php');
3297
-	if (!is_writable($boarddir . '/Settings.php'))
3298
-		print_error('Error: Unable to obtain write access to "Settings.php".', true);
3491
+	if (!is_writable($boarddir . '/Settings.php')) {
3492
+			print_error('Error: Unable to obtain write access to "Settings.php".', true);
3493
+	}
3299 3494
 
3300 3495
 	// Make sure Settings_bak.php is writable.
3301 3496
 		quickFileWritable($boarddir . '/Settings_bak.php');
3302
-	if (!is_writable($boarddir . '/Settings_bak.php'))
3303
-		print_error('Error: Unable to obtain write access to "Settings_bak.php".');
3497
+	if (!is_writable($boarddir . '/Settings_bak.php')) {
3498
+			print_error('Error: Unable to obtain write access to "Settings_bak.php".');
3499
+	}
3304 3500
 
3305
-	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt'))
3306
-		print_error('Error: Unable to obtain write access to "agreement.txt".');
3307
-	elseif (isset($modSettings['agreement']))
3501
+	if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) {
3502
+			print_error('Error: Unable to obtain write access to "agreement.txt".');
3503
+	} elseif (isset($modSettings['agreement']))
3308 3504
 	{
3309 3505
 		$fp = fopen($boarddir . '/agreement.txt', 'w');
3310 3506
 		fwrite($fp, $modSettings['agreement']);
@@ -3314,31 +3510,36 @@  discard block
 block discarded – undo
3314 3510
 	// Make sure Themes is writable.
3315 3511
 	quickFileWritable($modSettings['theme_dir']);
3316 3512
 
3317
-	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion']))
3318
-		print_error('Error: Unable to obtain write access to "Themes".');
3513
+	if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) {
3514
+			print_error('Error: Unable to obtain write access to "Themes".');
3515
+	}
3319 3516
 
3320 3517
 	// Make sure cache directory exists and is writable!
3321 3518
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
3322
-	if (!file_exists($cachedir_temp))
3323
-		@mkdir($cachedir_temp);
3519
+	if (!file_exists($cachedir_temp)) {
3520
+			@mkdir($cachedir_temp);
3521
+	}
3324 3522
 
3325 3523
 	// Make sure the cache temp dir is writable.
3326 3524
 	quickFileWritable($cachedir_temp);
3327 3525
 
3328
-	if (!is_writable($cachedir_temp))
3329
-		print_error('Error: Unable to obtain write access to "cache".', true);
3526
+	if (!is_writable($cachedir_temp)) {
3527
+			print_error('Error: Unable to obtain write access to "cache".', true);
3528
+	}
3330 3529
 
3331
-	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang']))
3332
-		print_error('Error: Unable to find language files!', true);
3333
-	else
3530
+	if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) {
3531
+			print_error('Error: Unable to find language files!', true);
3532
+	} else
3334 3533
 	{
3335 3534
 		$temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096);
3336 3535
 		preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match);
3337 3536
 
3338
-		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION)
3339
-			print_error('Error: Language files out of date.', true);
3340
-		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'))
3341
-			print_error('Error: Install language is missing for selected language.', true);
3537
+		if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) {
3538
+					print_error('Error: Language files out of date.', true);
3539
+		}
3540
+		if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) {
3541
+					print_error('Error: Install language is missing for selected language.', true);
3542
+		}
3342 3543
 
3343 3544
 		// Otherwise include it!
3344 3545
 		require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php');
@@ -3353,14 +3554,16 @@  discard block
 block discarded – undo
3353 3554
 {
3354 3555
 	static $fp = null;
3355 3556
 
3356
-	if ($fp === null)
3357
-		$fp = fopen('php://stderr', 'wb');
3557
+	if ($fp === null) {
3558
+			$fp = fopen('php://stderr', 'wb');
3559
+	}
3358 3560
 
3359 3561
 	fwrite($fp, $message . "\n");
3360 3562
 
3361
-	if ($fatal)
3362
-		exit;
3363
-}
3563
+	if ($fatal) {
3564
+			exit;
3565
+	}
3566
+	}
3364 3567
 
3365 3568
 function throw_error($message)
3366 3569
 {
@@ -3377,8 +3580,9 @@  discard block
 block discarded – undo
3377 3580
 {
3378 3581
 	global $upcontext, $boarddir;
3379 3582
 
3380
-	if (empty($files))
3381
-		return true;
3583
+	if (empty($files)) {
3584
+			return true;
3585
+	}
3382 3586
 
3383 3587
 	$failure = false;
3384 3588
 	// On linux, it's easy - just use is_writable!
@@ -3393,14 +3597,16 @@  discard block
 block discarded – undo
3393 3597
 				@chmod($file, 0755);
3394 3598
 
3395 3599
 				// Well, 755 hopefully worked... if not, try 777.
3396
-				if (!is_writable($file) && !@chmod($file, 0777))
3397
-					$failure = true;
3600
+				if (!is_writable($file) && !@chmod($file, 0777)) {
3601
+									$failure = true;
3602
+				}
3398 3603
 				// Otherwise remove it as it's good!
3399
-				else
3400
-					unset($files[$k]);
3604
+				else {
3605
+									unset($files[$k]);
3606
+				}
3607
+			} else {
3608
+							unset($files[$k]);
3401 3609
 			}
3402
-			else
3403
-				unset($files[$k]);
3404 3610
 		}
3405 3611
 	}
3406 3612
 	// Windows is trickier.  Let's try opening for r+...
@@ -3411,30 +3617,35 @@  discard block
 block discarded – undo
3411 3617
 		foreach ($files as $k => $file)
3412 3618
 		{
3413 3619
 			// Folders can't be opened for write... but the index.php in them can ;).
3414
-			if (is_dir($file))
3415
-				$file .= '/index.php';
3620
+			if (is_dir($file)) {
3621
+							$file .= '/index.php';
3622
+			}
3416 3623
 
3417 3624
 			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
3418 3625
 			@chmod($file, 0777);
3419 3626
 			$fp = @fopen($file, 'r+');
3420 3627
 
3421 3628
 			// Hmm, okay, try just for write in that case...
3422
-			if (!$fp)
3423
-				$fp = @fopen($file, 'w');
3629
+			if (!$fp) {
3630
+							$fp = @fopen($file, 'w');
3631
+			}
3424 3632
 
3425
-			if (!$fp)
3426
-				$failure = true;
3427
-			else
3428
-				unset($files[$k]);
3633
+			if (!$fp) {
3634
+							$failure = true;
3635
+			} else {
3636
+							unset($files[$k]);
3637
+			}
3429 3638
 			@fclose($fp);
3430 3639
 		}
3431 3640
 	}
3432 3641
 
3433
-	if (empty($files))
3434
-		return true;
3642
+	if (empty($files)) {
3643
+			return true;
3644
+	}
3435 3645
 
3436
-	if (!isset($_SERVER))
3437
-		return !$failure;
3646
+	if (!isset($_SERVER)) {
3647
+			return !$failure;
3648
+	}
3438 3649
 
3439 3650
 	// What still needs to be done?
3440 3651
 	$upcontext['chmod']['files'] = $files;
@@ -3485,33 +3696,37 @@  discard block
 block discarded – undo
3485 3696
 
3486 3697
 		if (!isset($ftp) || $ftp->error !== false)
3487 3698
 		{
3488
-			if (!isset($ftp))
3489
-				$ftp = new ftp_connection(null);
3699
+			if (!isset($ftp)) {
3700
+							$ftp = new ftp_connection(null);
3701
+			}
3490 3702
 			// Save the error so we can mess with listing...
3491
-			elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error']))
3492
-				$upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message;
3703
+			elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) {
3704
+							$upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message;
3705
+			}
3493 3706
 
3494 3707
 			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
3495 3708
 
3496
-			if ($found_path || !isset($upcontext['chmod']['path']))
3497
-				$upcontext['chmod']['path'] = $detect_path;
3709
+			if ($found_path || !isset($upcontext['chmod']['path'])) {
3710
+							$upcontext['chmod']['path'] = $detect_path;
3711
+			}
3498 3712
 
3499
-			if (!isset($upcontext['chmod']['username']))
3500
-				$upcontext['chmod']['username'] = $username;
3713
+			if (!isset($upcontext['chmod']['username'])) {
3714
+							$upcontext['chmod']['username'] = $username;
3715
+			}
3501 3716
 
3502 3717
 			return false;
3503
-		}
3504
-		else
3718
+		} else
3505 3719
 		{
3506 3720
 			// We want to do a relative path for FTP.
3507 3721
 			if (!in_array($upcontext['chmod']['path'], array('', '/')))
3508 3722
 			{
3509 3723
 				$ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => ''));
3510
-				if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/'))
3511
-				$ftp_root = substr($ftp_root, 0, -1);
3724
+				if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) {
3725
+								$ftp_root = substr($ftp_root, 0, -1);
3726
+				}
3727
+			} else {
3728
+							$ftp_root = $boarddir;
3512 3729
 			}
3513
-			else
3514
-				$ftp_root = $boarddir;
3515 3730
 
3516 3731
 			// Save the info for next time!
3517 3732
 			$_SESSION['installer_temp_ftp'] = array(
@@ -3525,10 +3740,12 @@  discard block
 block discarded – undo
3525 3740
 
3526 3741
 			foreach ($files as $k => $file)
3527 3742
 			{
3528
-				if (!is_writable($file))
3529
-					$ftp->chmod($file, 0755);
3530
-				if (!is_writable($file))
3531
-					$ftp->chmod($file, 0777);
3743
+				if (!is_writable($file)) {
3744
+									$ftp->chmod($file, 0755);
3745
+				}
3746
+				if (!is_writable($file)) {
3747
+									$ftp->chmod($file, 0777);
3748
+				}
3532 3749
 
3533 3750
 				// Assuming that didn't work calculate the path without the boarddir.
3534 3751
 				if (!is_writable($file))
@@ -3537,19 +3754,23 @@  discard block
 block discarded – undo
3537 3754
 					{
3538 3755
 						$ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => ''));
3539 3756
 						$ftp->chmod($ftp_file, 0755);
3540
-						if (!is_writable($file))
3541
-							$ftp->chmod($ftp_file, 0777);
3757
+						if (!is_writable($file)) {
3758
+													$ftp->chmod($ftp_file, 0777);
3759
+						}
3542 3760
 						// Sometimes an extra slash can help...
3543 3761
 						$ftp_file = '/' . $ftp_file;
3544
-						if (!is_writable($file))
3545
-							$ftp->chmod($ftp_file, 0755);
3546
-						if (!is_writable($file))
3547
-							$ftp->chmod($ftp_file, 0777);
3762
+						if (!is_writable($file)) {
3763
+													$ftp->chmod($ftp_file, 0755);
3764
+						}
3765
+						if (!is_writable($file)) {
3766
+													$ftp->chmod($ftp_file, 0777);
3767
+						}
3548 3768
 					}
3549 3769
 				}
3550 3770
 
3551
-				if (is_writable($file))
3552
-					unset($files[$k]);
3771
+				if (is_writable($file)) {
3772
+									unset($files[$k]);
3773
+				}
3553 3774
 			}
3554 3775
 
3555 3776
 			$ftp->close();
@@ -3559,16 +3780,18 @@  discard block
 block discarded – undo
3559 3780
 	// What remains?
3560 3781
 	$upcontext['chmod']['files'] = $files;
3561 3782
 
3562
-	if (empty($files))
3563
-		return true;
3783
+	if (empty($files)) {
3784
+			return true;
3785
+	}
3564 3786
 
3565 3787
 	return false;
3566 3788
 }
3567 3789
 
3568 3790
 function quickFileWritable($file)
3569 3791
 {
3570
-	if (is_writable($file))
3571
-		return true;
3792
+	if (is_writable($file)) {
3793
+			return true;
3794
+	}
3572 3795
 
3573 3796
 	@chmod($file, 0755);
3574 3797
 
@@ -3578,17 +3801,19 @@  discard block
 block discarded – undo
3578 3801
 	foreach($chmod_values as $val)
3579 3802
 	{
3580 3803
 		// If it's writable, break out of the loop
3581
-		if (is_writable($file))
3582
-			break;
3583
-		else
3584
-			@chmod($file, $val);
3804
+		if (is_writable($file)) {
3805
+					break;
3806
+		} else {
3807
+					@chmod($file, $val);
3808
+		}
3585 3809
 	}
3586 3810
 }
3587 3811
 function smf_strtolower($string)
3588 3812
 {
3589 3813
 	global $sourcedir;
3590
-	if (function_exists('mb_strtolower'))
3591
-		return mb_strtolower($string, 'UTF-8');
3814
+	if (function_exists('mb_strtolower')) {
3815
+			return mb_strtolower($string, 'UTF-8');
3816
+	}
3592 3817
 	require_once($sourcedir . '/Subs-Charset.php');
3593 3818
 	return utf8_strtolower($string);
3594 3819
 }
@@ -3604,8 +3829,7 @@  discard block
 block discarded – undo
3604 3829
 	if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8'))
3605 3830
 	{
3606 3831
 		return true;
3607
-	}
3608
-	else
3832
+	} else
3609 3833
 	{
3610 3834
 		$upcontext['page_title'] = 'Converting to UTF8';
3611 3835
 		$upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8';
@@ -3649,8 +3873,9 @@  discard block
 block discarded – undo
3649 3873
 			)
3650 3874
 		);
3651 3875
 		$db_charsets = array();
3652
-		while ($row = $smcFunc['db_fetch_assoc']($request))
3653
-			$db_charsets[] = $row['Charset'];
3876
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
3877
+					$db_charsets[] = $row['Charset'];
3878
+		}
3654 3879
 
3655 3880
 		$smcFunc['db_free_result']($request);
3656 3881
 
@@ -3686,13 +3911,15 @@  discard block
 block discarded – undo
3686 3911
 		// If there's a fulltext index, we need to drop it first...
3687 3912
 		if ($request !== false || $smcFunc['db_num_rows']($request) != 0)
3688 3913
 		{
3689
-			while ($row = $smcFunc['db_fetch_assoc']($request))
3690
-				if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
3914
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
3915
+							if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT'))
3691 3916
 					$upcontext['fulltext_index'][] = $row['Key_name'];
3917
+			}
3692 3918
 			$smcFunc['db_free_result']($request);
3693 3919
 
3694
-			if (isset($upcontext['fulltext_index']))
3695
-				$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
3920
+			if (isset($upcontext['fulltext_index'])) {
3921
+							$upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']);
3922
+			}
3696 3923
 		}
3697 3924
 
3698 3925
 		// Drop it and make a note...
@@ -3884,8 +4111,9 @@  discard block
 block discarded – undo
3884 4111
 			$replace = '%field%';
3885 4112
 
3886 4113
 			// Build a huge REPLACE statement...
3887
-			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to)
3888
-				$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
4114
+			foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) {
4115
+							$replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
4116
+			}
3889 4117
 		}
3890 4118
 
3891 4119
 		// Get a list of table names ahead of time... This makes it easier to set our substep and such
@@ -3919,8 +4147,9 @@  discard block
 block discarded – undo
3919 4147
 			$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
3920 4148
 
3921 4149
 			// Just to make sure it doesn't time out.
3922
-			if (function_exists('apache_reset_timeout'))
3923
-				@apache_reset_timeout();
4150
+			if (function_exists('apache_reset_timeout')) {
4151
+							@apache_reset_timeout();
4152
+			}
3924 4153
 
3925 4154
 			$table_charsets = array();
3926 4155
 
@@ -3941,8 +4170,9 @@  discard block
 block discarded – undo
3941 4170
 					{
3942 4171
 						list($charset) = explode('_', $collation);
3943 4172
 
3944
-						if (!isset($table_charsets[$charset]))
3945
-							$table_charsets[$charset] = array();
4173
+						if (!isset($table_charsets[$charset])) {
4174
+													$table_charsets[$charset] = array();
4175
+						}
3946 4176
 
3947 4177
 						$table_charsets[$charset][] = $column_info;
3948 4178
 					}
@@ -3982,10 +4212,11 @@  discard block
 block discarded – undo
3982 4212
 				if (isset($translation_tables[$upcontext['charset_detected']]))
3983 4213
 				{
3984 4214
 					$update = '';
3985
-					foreach ($table_charsets as $charset => $columns)
3986
-						foreach ($columns as $column)
4215
+					foreach ($table_charsets as $charset => $columns) {
4216
+											foreach ($columns as $column)
3987 4217
 							$update .= '
3988 4218
 								' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ',';
4219
+					}
3989 4220
 
3990 4221
 					$smcFunc['db_query']('', '
3991 4222
 						UPDATE {raw:table_name}
@@ -4010,8 +4241,9 @@  discard block
 block discarded – undo
4010 4241
 			// Now do the actual conversion (if still needed).
4011 4242
 			if ($charsets[$upcontext['charset_detected']] !== 'utf8')
4012 4243
 			{
4013
-				if ($command_line)
4014
-					echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
4244
+				if ($command_line) {
4245
+									echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...';
4246
+				}
4015 4247
 
4016 4248
 				$smcFunc['db_query']('', '
4017 4249
 					ALTER TABLE {raw:table_name}
@@ -4021,8 +4253,9 @@  discard block
 block discarded – undo
4021 4253
 						)
4022 4254
 				);
4023 4255
 
4024
-				if ($command_line)
4025
-					echo " done.\n";
4256
+				if ($command_line) {
4257
+									echo " done.\n";
4258
+				}
4026 4259
 			}
4027 4260
 		}
4028 4261
 
@@ -4052,8 +4285,8 @@  discard block
 block discarded – undo
4052 4285
 		);
4053 4286
 		while ($row = $smcFunc['db_fetch_assoc']($request))
4054 4287
 		{
4055
-			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)
4056
-				$smcFunc['db_query']('', '
4288
+			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) {
4289
+							$smcFunc['db_query']('', '
4057 4290
 					UPDATE {db_prefix}log_actions
4058 4291
 					SET extra = {string:extra}
4059 4292
 					WHERE id_action = {int:current_action}',
@@ -4062,6 +4295,7 @@  discard block
 block discarded – undo
4062 4295
 						'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4],
4063 4296
 					)
4064 4297
 				);
4298
+			}
4065 4299
 		}
4066 4300
 		$smcFunc['db_free_result']($request);
4067 4301
 
@@ -4083,15 +4317,17 @@  discard block
 block discarded – undo
4083 4317
 	// First thing's first - did we already do this?
4084 4318
 	if (!empty($modSettings['json_done']))
4085 4319
 	{
4086
-		if ($command_line)
4087
-			return DeleteUpgrade();
4088
-		else
4089
-			return true;
4320
+		if ($command_line) {
4321
+					return DeleteUpgrade();
4322
+		} else {
4323
+					return true;
4324
+		}
4090 4325
 	}
4091 4326
 
4092 4327
 	// Done it already - js wise?
4093
-	if (!empty($_POST['json_done']))
4094
-		return true;
4328
+	if (!empty($_POST['json_done'])) {
4329
+			return true;
4330
+	}
4095 4331
 
4096 4332
 	// List of tables affected by this function
4097 4333
 	// name => array('key', col1[,col2|true[,col3]])
@@ -4123,12 +4359,14 @@  discard block
 block discarded – undo
4123 4359
 	$upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100);
4124 4360
 	$file_steps = $upcontext['table_count'];
4125 4361
 
4126
-	foreach($keys as $id => $table)
4127
-		if ($id < $_GET['substep'])
4362
+	foreach($keys as $id => $table) {
4363
+			if ($id < $_GET['substep'])
4128 4364
 			$upcontext['previous_tables'][] = $table;
4365
+	}
4129 4366
 
4130
-	if ($command_line)
4131
-		echo 'Converting data from serialize() to json_encode().';
4367
+	if ($command_line) {
4368
+			echo 'Converting data from serialize() to json_encode().';
4369
+	}
4132 4370
 
4133 4371
 	if (!$support_js || isset($_GET['xml']))
4134 4372
 	{
@@ -4168,8 +4406,9 @@  discard block
 block discarded – undo
4168 4406
 
4169 4407
 				// Loop through and fix these...
4170 4408
 				$new_settings = array();
4171
-				if ($command_line)
4172
-					echo "\n" . 'Fixing some settings...';
4409
+				if ($command_line) {
4410
+									echo "\n" . 'Fixing some settings...';
4411
+				}
4173 4412
 
4174 4413
 				foreach ($serialized_settings as $var)
4175 4414
 				{
@@ -4177,22 +4416,24 @@  discard block
 block discarded – undo
4177 4416
 					{
4178 4417
 						// Attempt to unserialize the setting
4179 4418
 						$temp = @safe_unserialize($modSettings[$var]);
4180
-						if (!$temp && $command_line)
4181
-							echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
4182
-						elseif ($temp !== false)
4183
-							$new_settings[$var] = json_encode($temp);
4419
+						if (!$temp && $command_line) {
4420
+													echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping.";
4421
+						} elseif ($temp !== false) {
4422
+													$new_settings[$var] = json_encode($temp);
4423
+						}
4184 4424
 					}
4185 4425
 				}
4186 4426
 
4187 4427
 				// Update everything at once
4188
-				if (!function_exists('cache_put_data'))
4189
-					require_once($sourcedir . '/Load.php');
4428
+				if (!function_exists('cache_put_data')) {
4429
+									require_once($sourcedir . '/Load.php');
4430
+				}
4190 4431
 				updateSettings($new_settings, true);
4191 4432
 
4192
-				if ($command_line)
4193
-					echo ' done.';
4194
-			}
4195
-			elseif ($table == 'themes')
4433
+				if ($command_line) {
4434
+									echo ' done.';
4435
+				}
4436
+			} elseif ($table == 'themes')
4196 4437
 			{
4197 4438
 				// Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point...
4198 4439
 				$query = $smcFunc['db_query']('', '
@@ -4211,10 +4452,11 @@  discard block
 block discarded – undo
4211 4452
 
4212 4453
 						if ($command_line)
4213 4454
 						{
4214
-							if ($temp === false)
4215
-								echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
4216
-							else
4217
-								echo "\n" . 'Fixing admin preferences...';
4455
+							if ($temp === false) {
4456
+															echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.';
4457
+							} else {
4458
+															echo "\n" . 'Fixing admin preferences...';
4459
+							}
4218 4460
 						}
4219 4461
 
4220 4462
 						if ($temp !== false)
@@ -4234,15 +4476,15 @@  discard block
 block discarded – undo
4234 4476
 								)
4235 4477
 							);
4236 4478
 
4237
-							if ($is_debug || $command_line)
4238
-								echo ' done.';
4479
+							if ($is_debug || $command_line) {
4480
+															echo ' done.';
4481
+							}
4239 4482
 						}
4240 4483
 					}
4241 4484
 
4242 4485
 					$smcFunc['db_free_result']($query);
4243 4486
 				}
4244
-			}
4245
-			else
4487
+			} else
4246 4488
 			{
4247 4489
 				// First item is always the key...
4248 4490
 				$key = $info[0];
@@ -4253,8 +4495,7 @@  discard block
 block discarded – undo
4253 4495
 				{
4254 4496
 					$col_select = $info[1];
4255 4497
 					$where = ' WHERE ' . $info[1] . ' != {empty}';
4256
-				}
4257
-				else
4498
+				} else
4258 4499
 				{
4259 4500
 					$col_select = implode(', ', $info);
4260 4501
 				}
@@ -4287,8 +4528,7 @@  discard block
 block discarded – undo
4287 4528
 								if ($temp === false && $command_line)
4288 4529
 								{
4289 4530
 									echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n";
4290
-								}
4291
-								else
4531
+								} else
4292 4532
 								{
4293 4533
 									$row[$col] = json_encode($temp);
4294 4534
 
@@ -4313,16 +4553,18 @@  discard block
 block discarded – undo
4313 4553
 						}
4314 4554
 					}
4315 4555
 
4316
-					if ($command_line)
4317
-						echo ' done.';
4556
+					if ($command_line) {
4557
+											echo ' done.';
4558
+					}
4318 4559
 
4319 4560
 					// Free up some memory...
4320 4561
 					$smcFunc['db_free_result']($query);
4321 4562
 				}
4322 4563
 			}
4323 4564
 			// If this is XML to keep it nice for the user do one table at a time anyway!
4324
-			if (isset($_GET['xml']))
4325
-				return upgradeExit();
4565
+			if (isset($_GET['xml'])) {
4566
+							return upgradeExit();
4567
+			}
4326 4568
 		}
4327 4569
 
4328 4570
 		if ($command_line)
@@ -4337,8 +4579,9 @@  discard block
 block discarded – undo
4337 4579
 
4338 4580
 		$_GET['substep'] = 0;
4339 4581
 		// Make sure we move on!
4340
-		if ($command_line)
4341
-			return DeleteUpgrade();
4582
+		if ($command_line) {
4583
+					return DeleteUpgrade();
4584
+		}
4342 4585
 
4343 4586
 		return true;
4344 4587
 	}
@@ -4358,14 +4601,16 @@  discard block
 block discarded – undo
4358 4601
 	global $upcontext, $txt, $settings;
4359 4602
 
4360 4603
 	// Don't call me twice!
4361
-	if (!empty($upcontext['chmod_called']))
4362
-		return;
4604
+	if (!empty($upcontext['chmod_called'])) {
4605
+			return;
4606
+	}
4363 4607
 
4364 4608
 	$upcontext['chmod_called'] = true;
4365 4609
 
4366 4610
 	// Nothing?
4367
-	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error']))
4368
-		return;
4611
+	if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) {
4612
+			return;
4613
+	}
4369 4614
 
4370 4615
 	// Was it a problem with Windows?
4371 4616
 	if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess')
@@ -4397,11 +4642,12 @@  discard block
 block discarded – undo
4397 4642
 					content.write(\'<div class="windowbg description">\n\t\t\t<h4>The following files needs to be made writable to continue:</h4>\n\t\t\t\');
4398 4643
 					content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');';
4399 4644
 
4400
-	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux')
4401
-		echo '
4645
+	if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') {
4646
+			echo '
4402 4647
 					content.write(\'<hr />\n\t\t\t\');
4403 4648
 					content.write(\'<p>If you have a shell account, the convenient below command can automatically correct permissions on these files</p>\n\t\t\t\');
4404 4649
 					content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');';
4650
+	}
4405 4651
 
4406 4652
 	echo '
4407 4653
 					content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\');
@@ -4409,8 +4655,8 @@  discard block
 block discarded – undo
4409 4655
 				}
4410 4656
 		</script>';
4411 4657
 
4412
-	if (!empty($upcontext['chmod']['ftp_error']))
4413
-		echo '
4658
+	if (!empty($upcontext['chmod']['ftp_error'])) {
4659
+			echo '
4414 4660
 			<div class="error_message">
4415 4661
 				<div style="color: red;">
4416 4662
 					The following error was encountered when trying to connect:<br>
@@ -4419,10 +4665,12 @@  discard block
 block discarded – undo
4419 4665
 				</div>
4420 4666
 			</div>
4421 4667
 			<br>';
4668
+	}
4422 4669
 
4423
-	if (empty($upcontext['chmod_in_form']))
4424
-		echo '
4670
+	if (empty($upcontext['chmod_in_form'])) {
4671
+			echo '
4425 4672
 	<form action="', $upcontext['form_url'], '" method="post">';
4673
+	}
4426 4674
 
4427 4675
 	echo '
4428 4676
 		<table width="520" border="0" align="center" style="margin-bottom: 1ex;">
@@ -4457,10 +4705,11 @@  discard block
 block discarded – undo
4457 4705
 		<div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div>
4458 4706
 	</div>';
4459 4707
 
4460
-	if (empty($upcontext['chmod_in_form']))
4461
-		echo '
4708
+	if (empty($upcontext['chmod_in_form'])) {
4709
+			echo '
4462 4710
 	</form>';
4463
-}
4711
+	}
4712
+	}
4464 4713
 
4465 4714
 function template_upgrade_above()
4466 4715
 {
@@ -4514,9 +4763,10 @@  discard block
 block discarded – undo
4514 4763
 				<h2>', $txt['upgrade_progress'], '</h2>
4515 4764
 				<ul>';
4516 4765
 
4517
-	foreach ($upcontext['steps'] as $num => $step)
4518
-		echo '
4766
+	foreach ($upcontext['steps'] as $num => $step) {
4767
+			echo '
4519 4768
 						<li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
4769
+	}
4520 4770
 
4521 4771
 	echo '
4522 4772
 					</ul>
@@ -4528,8 +4778,8 @@  discard block
 block discarded – undo
4528 4778
 				<div class="over_progress">', $txt['upgrade_overall_progress'], '</div>
4529 4779
 			</div>';
4530 4780
 
4531
-	if (isset($upcontext['step_progress']))
4532
-		echo '
4781
+	if (isset($upcontext['step_progress'])) {
4782
+			echo '
4533 4783
 				<br>
4534 4784
 				<br>
4535 4785
 				<div id="progress">
@@ -4537,6 +4787,7 @@  discard block
 block discarded – undo
4537 4787
 					<div id="step_progress_upgrade" style="width: ', $upcontext['step_progress'], '%;background-color: #ffd000;">&nbsp;</div>
4538 4788
 					<div class="over_progress">', $txt['upgrade_step_progress'], '</div>
4539 4789
 					</div>';
4790
+	}
4540 4791
 
4541 4792
 	echo '
4542 4793
 				<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>
@@ -4568,32 +4819,36 @@  discard block
 block discarded – undo
4568 4819
 {
4569 4820
 	global $upcontext, $txt;
4570 4821
 
4571
-	if (!empty($upcontext['pause']))
4572
-		echo '
4822
+	if (!empty($upcontext['pause'])) {
4823
+			echo '
4573 4824
 								<em>', $txt['upgrade_incomplete'], '.</em><br>
4574 4825
 
4575 4826
 								<h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2>
4576 4827
 								<h3>
4577 4828
 									', $txt['upgrade_paused_overload'], '
4578 4829
 								</h3>';
4830
+	}
4579 4831
 
4580
-	if (!empty($upcontext['custom_warning']))
4581
-		echo '
4832
+	if (!empty($upcontext['custom_warning'])) {
4833
+			echo '
4582 4834
 								<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
4583 4835
 									<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
4584 4836
 									<strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br>
4585 4837
 									<div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div>
4586 4838
 								</div>';
4839
+	}
4587 4840
 
4588 4841
 	echo '
4589 4842
 								<div class="righttext" style="margin: 1ex;">';
4590 4843
 
4591
-	if (!empty($upcontext['continue']))
4592
-		echo '
4844
+	if (!empty($upcontext['continue'])) {
4845
+			echo '
4593 4846
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">';
4594
-	if (!empty($upcontext['skip']))
4595
-		echo '
4847
+	}
4848
+	if (!empty($upcontext['skip'])) {
4849
+			echo '
4596 4850
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">';
4851
+	}
4597 4852
 
4598 4853
 	echo '
4599 4854
 								</div>
@@ -4644,11 +4899,12 @@  discard block
 block discarded – undo
4644 4899
 	echo '<', '?xml version="1.0" encoding="UTF-8"?', '>
4645 4900
 	<smf>';
4646 4901
 
4647
-	if (!empty($upcontext['get_data']))
4648
-		foreach ($upcontext['get_data'] as $k => $v)
4902
+	if (!empty($upcontext['get_data'])) {
4903
+			foreach ($upcontext['get_data'] as $k => $v)
4649 4904
 			echo '
4650 4905
 		<get key="', $k, '">', $v, '</get>';
4651
-}
4906
+	}
4907
+	}
4652 4908
 
4653 4909
 function template_xml_below()
4654 4910
 {
@@ -4691,8 +4947,8 @@  discard block
 block discarded – undo
4691 4947
 	template_chmod();
4692 4948
 
4693 4949
 	// For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade!
4694
-	if ($upcontext['is_large_forum'])
4695
-		echo '
4950
+	if ($upcontext['is_large_forum']) {
4951
+			echo '
4696 4952
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
4697 4953
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
4698 4954
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -4700,10 +4956,11 @@  discard block
 block discarded – undo
4700 4956
 				', $txt['upgrade_warning_lots_data'], '
4701 4957
 			</div>
4702 4958
 		</div>';
4959
+	}
4703 4960
 
4704 4961
 	// A warning message?
4705
-	if (!empty($upcontext['warning']))
4706
-		echo '
4962
+	if (!empty($upcontext['warning'])) {
4963
+			echo '
4707 4964
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
4708 4965
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
4709 4966
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -4711,6 +4968,7 @@  discard block
 block discarded – undo
4711 4968
 				', $upcontext['warning'], '
4712 4969
 			</div>
4713 4970
 		</div>';
4971
+	}
4714 4972
 
4715 4973
 	// Paths are incorrect?
4716 4974
 	echo '
@@ -4726,20 +4984,22 @@  discard block
 block discarded – undo
4726 4984
 	if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600))
4727 4985
 	{
4728 4986
 		$ago = time() - $upcontext['started'];
4729
-		if ($ago < 60)
4730
-			$ago = $ago . ' seconds';
4731
-		elseif ($ago < 3600)
4732
-			$ago = (int) ($ago / 60) . ' minutes';
4733
-		else
4734
-			$ago = (int) ($ago / 3600) . ' hours';
4987
+		if ($ago < 60) {
4988
+					$ago = $ago . ' seconds';
4989
+		} elseif ($ago < 3600) {
4990
+					$ago = (int) ($ago / 60) . ' minutes';
4991
+		} else {
4992
+					$ago = (int) ($ago / 3600) . ' hours';
4993
+		}
4735 4994
 
4736 4995
 		$active = time() - $upcontext['updated'];
4737
-		if ($active < 60)
4738
-			$updated = $active . ' seconds';
4739
-		elseif ($active < 3600)
4740
-			$updated = (int) ($active / 60) . ' minutes';
4741
-		else
4742
-			$updated = (int) ($active / 3600) . ' hours';
4996
+		if ($active < 60) {
4997
+					$updated = $active . ' seconds';
4998
+		} elseif ($active < 3600) {
4999
+					$updated = (int) ($active / 60) . ' minutes';
5000
+		} else {
5001
+					$updated = (int) ($active / 3600) . ' hours';
5002
+		}
4743 5003
 
4744 5004
 		echo '
4745 5005
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
@@ -4748,16 +5008,18 @@  discard block
 block discarded – undo
4748 5008
 			<div style="padding-left: 6ex;">
4749 5009
 				&quot;', $upcontext['user']['name'], '&quot; has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.';
4750 5010
 
4751
-		if ($active < 600)
4752
-			echo '
5011
+		if ($active < 600) {
5012
+					echo '
4753 5013
 				We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.';
5014
+		}
4754 5015
 
4755
-		if ($active > $upcontext['inactive_timeout'])
4756
-			echo '
5016
+		if ($active > $upcontext['inactive_timeout']) {
5017
+					echo '
4757 5018
 				<br><br>You can choose to either run the upgrade again from the beginning - or alternatively continue from the last step reached during the last upgrade.';
4758
-		else
4759
-			echo '
5019
+		} else {
5020
+					echo '
4760 5021
 				<br><br>This upgrade script cannot be run until ', $upcontext['user']['name'], ' has been inactive for at least ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!');
5022
+		}
4761 5023
 
4762 5024
 		echo '
4763 5025
 			</div>
@@ -4773,9 +5035,10 @@  discard block
 block discarded – undo
4773 5035
 					<td>
4774 5036
 						<input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">';
4775 5037
 
4776
-	if (!empty($upcontext['username_incorrect']))
4777
-		echo '
5038
+	if (!empty($upcontext['username_incorrect'])) {
5039
+			echo '
4778 5040
 						<div class="smalltext" style="color: red;">Username Incorrect</div>';
5041
+	}
4779 5042
 
4780 5043
 	echo '
4781 5044
 					</td>
@@ -4786,9 +5049,10 @@  discard block
 block discarded – undo
4786 5049
 						<input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password">
4787 5050
 						<input type="hidden" name="hash_passwrd" value="">';
4788 5051
 
4789
-	if (!empty($upcontext['password_failed']))
4790
-		echo '
5052
+	if (!empty($upcontext['password_failed'])) {
5053
+			echo '
4791 5054
 						<div class="smalltext" style="color: red;">Password Incorrect</div>';
5055
+	}
4792 5056
 
4793 5057
 	echo '
4794 5058
 					</td>
@@ -4859,8 +5123,8 @@  discard block
 block discarded – undo
4859 5123
 			<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">';
4860 5124
 
4861 5125
 	// Warning message?
4862
-	if (!empty($upcontext['upgrade_options_warning']))
4863
-		echo '
5126
+	if (!empty($upcontext['upgrade_options_warning'])) {
5127
+			echo '
4864 5128
 		<div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;">
4865 5129
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
4866 5130
 			<strong style="text-decoration: underline;">Warning!</strong><br>
@@ -4868,6 +5132,7 @@  discard block
 block discarded – undo
4868 5132
 				', $upcontext['upgrade_options_warning'], '
4869 5133
 			</div>
4870 5134
 		</div>';
5135
+	}
4871 5136
 
4872 5137
 	echo '
4873 5138
 				<table>
@@ -4895,8 +5160,8 @@  discard block
 block discarded – undo
4895 5160
 					</tr>';
4896 5161
 
4897 5162
 	// Offer mysql users to switch to mysqli
4898
-	if ($db_type == 'mysql' && function_exists('mysqli_query'))
4899
-		echo '
5163
+	if ($db_type == 'mysql' && function_exists('mysqli_query')) {
5164
+			echo '
4900 5165
 					<tr valign="top">
4901 5166
 						<td width="2%">
4902 5167
 							<input type="checkbox" name="convertMysql" id="convertMysql" value="1" checked class="input_check">
@@ -4906,6 +5171,7 @@  discard block
 block discarded – undo
4906 5171
 							<strong class="smalltext"><a href="http://wiki.simplemachines.org/smf/Upgrading-MySQLi-Functionality" target="_blank">More information about MySQLi</a></strong><br>
4907 5172
 						</td>
4908 5173
 					</tr>';
5174
+	}
4909 5175
 
4910 5176
 	echo '
4911 5177
 					<tr valign="top">
@@ -4925,8 +5191,8 @@  discard block
 block discarded – undo
4925 5191
 						</td>
4926 5192
 					</tr>';
4927 5193
 
4928
-	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad']))
4929
-		echo '
5194
+	if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) {
5195
+			echo '
4930 5196
 					<tr valign="top">
4931 5197
 						<td width="2%">
4932 5198
 							<input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check">
@@ -4935,6 +5201,7 @@  discard block
 block discarded – undo
4935 5201
 							<label for="delete_karma">Delete all karma settings and info from the DB</label>
4936 5202
 						</td>
4937 5203
 					</tr>';
5204
+	}
4938 5205
 
4939 5206
 	echo '
4940 5207
 					<tr valign="top">
@@ -4970,10 +5237,11 @@  discard block
 block discarded – undo
4970 5237
 			<span id="debuginfo"></span>';
4971 5238
 
4972 5239
 	// Dont any tables so far?
4973
-	if (!empty($upcontext['previous_tables']))
4974
-		foreach ($upcontext['previous_tables'] as $table)
5240
+	if (!empty($upcontext['previous_tables'])) {
5241
+			foreach ($upcontext['previous_tables'] as $table)
4975 5242
 			echo '
4976 5243
 			<br>Completed Table: &quot;', $table, '&quot;.';
5244
+	}
4977 5245
 
4978 5246
 	echo '
4979 5247
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
@@ -5010,12 +5278,13 @@  discard block
 block discarded – undo
5010 5278
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
5011 5279
 
5012 5280
 		// If debug flood the screen.
5013
-		if ($is_debug)
5014
-			echo '
5281
+		if ($is_debug) {
5282
+					echo '
5015 5283
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');
5016 5284
 
5017 5285
 				if (document.getElementById(\'debuginfo\').scrollHeight)
5018 5286
 					document.getElementById(\'debuginfo\').scrollTop = document.getElementById(\'debuginfo\').scrollHeight;';
5287
+		}
5019 5288
 
5020 5289
 		echo '
5021 5290
 				// Get the next update...
@@ -5060,19 +5329,21 @@  discard block
 block discarded – undo
5060 5329
 	{
5061 5330
 		foreach ($upcontext['actioned_items'] as $num => $item)
5062 5331
 		{
5063
-			if ($num != 0)
5064
-				echo ' Successful!';
5332
+			if ($num != 0) {
5333
+							echo ' Successful!';
5334
+			}
5065 5335
 			echo '<br>' . $item;
5066 5336
 		}
5067
-		if (!empty($upcontext['changes_complete']))
5068
-			echo ' Successful!<br><br><span id="commess" style="font-weight: bold;">Database Updates Complete! Click Continue to Proceed.</span><br>';
5069
-	}
5070
-	else
5337
+		if (!empty($upcontext['changes_complete'])) {
5338
+					echo ' Successful!<br><br><span id="commess" style="font-weight: bold;">Database Updates Complete! Click Continue to Proceed.</span><br>';
5339
+		}
5340
+	} else
5071 5341
 	{
5072 5342
 		// Tell them how many files we have in total.
5073
-		if ($upcontext['file_count'] > 1)
5074
-			echo '
5343
+		if ($upcontext['file_count'] > 1) {
5344
+					echo '
5075 5345
 		<strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>';
5346
+		}
5076 5347
 
5077 5348
 		echo '
5078 5349
 		<h3 id="info2"><strong>Executing:</strong> &quot;<span id="cur_item_name">', $upcontext['current_item_name'], '</span>&quot; (<span id="item_num">', $upcontext['current_item_num'], '</span> of <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3>
@@ -5151,9 +5422,10 @@  discard block
 block discarded – undo
5151 5422
 						document.getElementById("error_block").style.display = "";
5152 5423
 						setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));';
5153 5424
 
5154
-	if ($is_debug)
5155
-		echo '
5425
+	if ($is_debug) {
5426
+			echo '
5156 5427
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
5428
+	}
5157 5429
 
5158 5430
 	echo '
5159 5431
 					}
@@ -5174,9 +5446,10 @@  discard block
 block discarded – undo
5174 5446
 						document.getElementById("error_block").style.display = "";
5175 5447
 						setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);';
5176 5448
 
5177
-	if ($is_debug)
5178
-		echo '
5449
+	if ($is_debug) {
5450
+			echo '
5179 5451
 						setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');';
5452
+	}
5180 5453
 
5181 5454
 	echo '
5182 5455
 					}
@@ -5235,9 +5508,10 @@  discard block
 block discarded – undo
5235 5508
 				if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ')
5236 5509
 				{';
5237 5510
 
5238
-		if ($is_debug)
5239
-			echo '
5511
+		if ($is_debug) {
5512
+					echo '
5240 5513
 					document.getElementById(\'debug_section\').style.display = "none";';
5514
+		}
5241 5515
 
5242 5516
 		echo '
5243 5517
 
@@ -5245,9 +5519,10 @@  discard block
 block discarded – undo
5245 5519
 					document.getElementById(\'contbutt\').disabled = 0;
5246 5520
 					document.getElementById(\'database_done\').value = 1;';
5247 5521
 
5248
-		if ($upcontext['file_count'] > 1)
5249
-			echo '
5522
+		if ($upcontext['file_count'] > 1) {
5523
+					echo '
5250 5524
 					document.getElementById(\'info1\').style.display = "none";';
5525
+		}
5251 5526
 
5252 5527
 		echo '
5253 5528
 					document.getElementById(\'info2\').style.display = "none";
@@ -5260,9 +5535,10 @@  discard block
 block discarded – undo
5260 5535
 					lastItem = 0;
5261 5536
 					prevFile = curFile;';
5262 5537
 
5263
-		if ($is_debug)
5264
-			echo '
5538
+		if ($is_debug) {
5539
+					echo '
5265 5540
 					setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');';
5541
+		}
5266 5542
 
5267 5543
 		echo '
5268 5544
 					getNextItem();
@@ -5270,8 +5546,8 @@  discard block
 block discarded – undo
5270 5546
 				}';
5271 5547
 
5272 5548
 		// If debug scroll the screen.
5273
-		if ($is_debug)
5274
-			echo '
5549
+		if ($is_debug) {
5550
+					echo '
5275 5551
 				if (iLastSubStepProgress == -1)
5276 5552
 				{
5277 5553
 					// Give it consistent dots.
@@ -5290,6 +5566,7 @@  discard block
 block discarded – undo
5290 5566
 
5291 5567
 				if (document.getElementById(\'debug_section\').scrollHeight)
5292 5568
 					document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight';
5569
+		}
5293 5570
 
5294 5571
 		echo '
5295 5572
 				// Update the page.
@@ -5350,9 +5627,10 @@  discard block
 block discarded – undo
5350 5627
 			}';
5351 5628
 
5352 5629
 		// Start things off assuming we've not errored.
5353
-		if (empty($upcontext['error_message']))
5354
-			echo '
5630
+		if (empty($upcontext['error_message'])) {
5631
+					echo '
5355 5632
 			getNextItem();';
5633
+		}
5356 5634
 
5357 5635
 		echo '
5358 5636
 		</script>';
@@ -5369,10 +5647,11 @@  discard block
 block discarded – undo
5369 5647
 	<item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item>
5370 5648
 	<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>';
5371 5649
 
5372
-	if (!empty($upcontext['error_message']))
5373
-		echo '
5650
+	if (!empty($upcontext['error_message'])) {
5651
+			echo '
5374 5652
 	<error>', $upcontext['error_message'], '</error>';
5375
-}
5653
+	}
5654
+	}
5376 5655
 
5377 5656
 // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications....
5378 5657
 function template_convert_utf8()
@@ -5389,18 +5668,20 @@  discard block
 block discarded – undo
5389 5668
 			<span id="debuginfo"></span>';
5390 5669
 
5391 5670
 	// Done any tables so far?
5392
-	if (!empty($upcontext['previous_tables']))
5393
-		foreach ($upcontext['previous_tables'] as $table)
5671
+	if (!empty($upcontext['previous_tables'])) {
5672
+			foreach ($upcontext['previous_tables'] as $table)
5394 5673
 			echo '
5395 5674
 			<br>Completed Table: &quot;', $table, '&quot;.';
5675
+	}
5396 5676
 
5397 5677
 	echo '
5398 5678
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>';
5399 5679
 
5400 5680
 	// If we dropped their index, let's let them know
5401
-	if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index'])
5402
-		echo '
5681
+	if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) {
5682
+			echo '
5403 5683
 			<br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>';
5684
+	}
5404 5685
 
5405 5686
 	echo '
5406 5687
 			<br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Conversion Complete! Click Continue to Proceed.</span>';
@@ -5436,9 +5717,10 @@  discard block
 block discarded – undo
5436 5717
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
5437 5718
 
5438 5719
 		// If debug flood the screen.
5439
-		if ($is_debug)
5440
-			echo '
5720
+		if ($is_debug) {
5721
+					echo '
5441 5722
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');';
5723
+		}
5442 5724
 
5443 5725
 		echo '
5444 5726
 				// Get the next update...
@@ -5507,14 +5789,16 @@  discard block
 block discarded – undo
5507 5789
 		<input type="hidden" name="cleandone" value="1">';
5508 5790
 
5509 5791
 	// Files to make writable?
5510
-	if (!empty($upcontext['writable_files']))
5511
-		echo '
5792
+	if (!empty($upcontext['writable_files'])) {
5793
+			echo '
5512 5794
 		<input type="hidden" name="writable_files" value="', base64_encode(safe_serialize($upcontext['writable_files'])), '">';
5795
+	}
5513 5796
 
5514 5797
 	// We'll want a continue button...
5515
-	if (empty($upcontext['chmod']['files']))
5516
-		$upcontext['continue'] = 1;
5517
-}
5798
+	if (empty($upcontext['chmod']['files'])) {
5799
+			$upcontext['continue'] = 1;
5800
+	}
5801
+	}
5518 5802
 
5519 5803
 // Finished with the mods - let them know what we've done.
5520 5804
 function template_cleanup_done()
@@ -5576,8 +5860,9 @@  discard block
 block discarded – undo
5576 5860
 						&quot;', $language['name'], '&quot; Language Pack
5577 5861
 						<div class="smalltext">(';
5578 5862
 
5579
-			foreach ($language['files'] as $k => $file)
5580
-				echo $file['name'], $k + 1 != count($language['files']) ? ', ' : ')';
5863
+			foreach ($language['files'] as $k => $file) {
5864
+							echo $file['name'], $k + 1 != count($language['files']) ? ', ' : ')';
5865
+			}
5581 5866
 
5582 5867
 			echo '
5583 5868
 						</div>
@@ -5594,8 +5879,9 @@  discard block
 block discarded – undo
5594 5879
 						&quot;', $theme['name'], '&quot; Theme
5595 5880
 						<div class="smalltext">(';
5596 5881
 
5597
-			foreach ($theme['files'] as $k => $file)
5598
-				echo $file['name'], $k + 1 != count($theme['files']) ? ', ' : ')';
5882
+			foreach ($theme['files'] as $k => $file) {
5883
+							echo $file['name'], $k + 1 != count($theme['files']) ? ', ' : ')';
5884
+			}
5599 5885
 
5600 5886
 			echo '
5601 5887
 						</div>
@@ -5606,47 +5892,54 @@  discard block
 block discarded – undo
5606 5892
 
5607 5893
 		echo '
5608 5894
 		</table>';
5609
-	}
5610
-	else
5895
+	} else
5611 5896
 	{
5612 5897
 		$langFiles = 0;
5613 5898
 		$themeFiles = 0;
5614
-		if (!empty($upcontext['languages']))
5615
-			foreach ($upcontext['languages'] as $lang)
5899
+		if (!empty($upcontext['languages'])) {
5900
+					foreach ($upcontext['languages'] as $lang)
5616 5901
 				$langFiles += count($lang['files']);
5617
-		if (!empty($upcontext['themes']))
5618
-			foreach ($upcontext['themes'] as $theme)
5902
+		}
5903
+		if (!empty($upcontext['themes'])) {
5904
+					foreach ($upcontext['themes'] as $theme)
5619 5905
 				$themeFiles += count($theme['files']);
5906
+		}
5620 5907
 		echo sprintf('Found <strong>%d</strong> language files and <strong>%d</strong> templates requiring an update so far.', $langFiles, $themeFiles) . '<br>';
5621 5908
 
5622 5909
 		// What we're currently doing?
5623
-		if (!empty($upcontext['current_message']))
5624
-			echo '
5910
+		if (!empty($upcontext['current_message'])) {
5911
+					echo '
5625 5912
 				', $upcontext['current_message'];
5913
+		}
5626 5914
 	}
5627 5915
 
5628 5916
 	echo '
5629 5917
 		<input type="hidden" name="uptempdone" value="1">';
5630 5918
 
5631
-	if (!empty($upcontext['languages']))
5632
-		echo '
5919
+	if (!empty($upcontext['languages'])) {
5920
+			echo '
5633 5921
 		<input type="hidden" name="languages" value="', base64_encode(safe_serialize($upcontext['languages'])), '">';
5634
-	if (!empty($upcontext['themes']))
5635
-		echo '
5922
+	}
5923
+	if (!empty($upcontext['themes'])) {
5924
+			echo '
5636 5925
 		<input type="hidden" name="themes" value="', base64_encode(safe_serialize($upcontext['themes'])), '">';
5637
-	if (!empty($upcontext['writable_files']))
5638
-		echo '
5926
+	}
5927
+	if (!empty($upcontext['writable_files'])) {
5928
+			echo '
5639 5929
 		<input type="hidden" name="writable_files" value="', base64_encode(safe_serialize($upcontext['writable_files'])), '">';
5930
+	}
5640 5931
 
5641 5932
 	// Offer them the option to upgrade from YaBB SE?
5642
-	if (!empty($upcontext['can_upgrade_yabbse']))
5643
-		echo '
5933
+	if (!empty($upcontext['can_upgrade_yabbse'])) {
5934
+			echo '
5644 5935
 		<br><label for="conv"><input type="checkbox" name="conv" id="conv" value="1" class="input_check"> Convert the existing YaBB SE template and set it as default.</label><br>';
5936
+	}
5645 5937
 
5646 5938
 	// We'll want a continue button... assuming chmod is OK (Otherwise let them use connect!)
5647
-	if (empty($upcontext['chmod']['files']) || $upcontext['is_test'])
5648
-		$upcontext['continue'] = 1;
5649
-}
5939
+	if (empty($upcontext['chmod']['files']) || $upcontext['is_test']) {
5940
+			$upcontext['continue'] = 1;
5941
+	}
5942
+	}
5650 5943
 
5651 5944
 // Template for the database backup tool/
5652 5945
 function template_serialize_json()
@@ -5663,10 +5956,11 @@  discard block
 block discarded – undo
5663 5956
 			<span id="debuginfo"></span>';
5664 5957
 
5665 5958
 	// Dont any tables so far?
5666
-	if (!empty($upcontext['previous_tables']))
5667
-		foreach ($upcontext['previous_tables'] as $table)
5959
+	if (!empty($upcontext['previous_tables'])) {
5960
+			foreach ($upcontext['previous_tables'] as $table)
5668 5961
 			echo '
5669 5962
 			<br>Completed Table: &quot;', $table, '&quot;.';
5963
+	}
5670 5964
 
5671 5965
 	echo '
5672 5966
 			<h3 id="current_tab_div">Current Table: &quot;<span id="current_table">', $upcontext['cur_table_name'], '</span>&quot;</h3>
@@ -5703,9 +5997,10 @@  discard block
 block discarded – undo
5703 5997
 				updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');';
5704 5998
 
5705 5999
 		// If debug flood the screen.
5706
-		if ($is_debug)
5707
-			echo '
6000
+		if ($is_debug) {
6001
+					echo '
5708 6002
 				setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: &quot;\' + sCompletedTableName + \'&quot;.<span id="debuginfo"><\' + \'/span>\');';
6003
+		}
5709 6004
 
5710 6005
 		echo '
5711 6006
 				// Get the next update...
@@ -5740,8 +6035,8 @@  discard block
 block discarded – undo
5740 6035
 	<h3>That wasn\'t so hard, was it?  Now you are ready to use <a href="', $boardurl, '/index.php">your installation of SMF</a>.  Hope you like it!</h3>
5741 6036
 	<form action="', $boardurl, '/index.php">';
5742 6037
 
5743
-	if (!empty($upcontext['can_delete_script']))
5744
-		echo '
6038
+	if (!empty($upcontext['can_delete_script'])) {
6039
+			echo '
5745 6040
 			<label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);" class="input_check"> Delete upgrade.php and its data files now</label> <em>(doesn\'t work on all servers).</em>
5746 6041
 			<script>
5747 6042
 				function doTheDelete(theCheck)
@@ -5753,6 +6048,7 @@  discard block
 block discarded – undo
5753 6048
 				}
5754 6049
 			</script>
5755 6050
 			<img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>';
6051
+	}
5756 6052
 
5757 6053
 	echo '<br>
5758 6054
 			If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="http://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br>
Please login to merge, or discard this patch.
Sources/Class-CurlFetchWeb.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	* Start the curl object
63 63
 	* - allow for user override values
64 64
 	*
65
-	* @param array $options An array of cURL options
65
+	* @param integer[] $options An array of cURL options
66 66
 	* @param int $max_redirect Maximum number of redirects
67 67
 	* @return void
68 68
 	*/
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 	*  - calls set_options to set the curl opts array values based on the defaults and user input
82 82
 	*
83 83
 	* @param string $url the site we are going to fetch
84
-	* @param array $post_data any post data as form name => value
85
-	* @return object An instance of the curl_fetch_web_data class
84
+	* @param string $post_data any post data as form name => value
85
+	* @return curl_fetch_web_data An instance of the curl_fetch_web_data class
86 86
 	*/
87 87
 	public function get_url_data($url, $post_data = array())
88 88
 	{
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	*
107 107
 	* @param string $url The site to fetch
108 108
 	* @param bool $redirect Whether or not this was a redirect request
109
-	* @return void|bool Sets various properties of the class or returns false if the URL isn't specified
109
+	* @return false|null Sets various properties of the class or returns false if the URL isn't specified
110 110
 	*/
111 111
 	private function curl_request($url, $redirect = false)
112 112
 	{
Please login to merge, or discard this patch.
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
 	);
60 60
 
61 61
 	/**
62
-	* Start the curl object
63
-	* - allow for user override values
64
-	*
65
-	* @param array $options An array of cURL options
66
-	* @param int $max_redirect Maximum number of redirects
67
-	* @return void
68
-	*/
62
+	 * Start the curl object
63
+	 * - allow for user override values
64
+	 *
65
+	 * @param array $options An array of cURL options
66
+	 * @param int $max_redirect Maximum number of redirects
67
+	 * @return void
68
+	 */
69 69
 	public function __construct($options = array(), $max_redirect = 3)
70 70
 	{
71 71
 		// Initialize class variables
@@ -74,16 +74,16 @@  discard block
 block discarded – undo
74 74
 	}
75 75
 
76 76
 	/**
77
-	* Main calling function,
78
-	*  - will request the page data from a given $url
79
-	*  - optionally will post data to the page form if post data is supplied
80
-	*  - passed arrays will be converted to a post string joined with &'s
81
-	*  - calls set_options to set the curl opts array values based on the defaults and user input
82
-	*
83
-	* @param string $url the site we are going to fetch
84
-	* @param array $post_data any post data as form name => value
85
-	* @return object An instance of the curl_fetch_web_data class
86
-	*/
77
+	 * Main calling function,
78
+	 *  - will request the page data from a given $url
79
+	 *  - optionally will post data to the page form if post data is supplied
80
+	 *  - passed arrays will be converted to a post string joined with &'s
81
+	 *  - calls set_options to set the curl opts array values based on the defaults and user input
82
+	 *
83
+	 * @param string $url the site we are going to fetch
84
+	 * @param array $post_data any post data as form name => value
85
+	 * @return object An instance of the curl_fetch_web_data class
86
+	 */
87 87
 	public function get_url_data($url, $post_data = array())
88 88
 	{
89 89
 		// POSTing some data perhaps?
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 	}
101 101
 
102 102
 	/**
103
-	* Makes the actual cURL call
104
-	*  - stores responses (url, code, error, headers, body) in the response array
105
-	*  - detects 301, 302, 307 codes and will redirect to the given response header location
106
-	*
107
-	* @param string $url The site to fetch
108
-	* @param bool $redirect Whether or not this was a redirect request
109
-	* @return void|bool Sets various properties of the class or returns false if the URL isn't specified
110
-	*/
103
+	 * Makes the actual cURL call
104
+	 *  - stores responses (url, code, error, headers, body) in the response array
105
+	 *  - detects 301, 302, 307 codes and will redirect to the given response header location
106
+	 *
107
+	 * @param string $url The site to fetch
108
+	 * @param bool $redirect Whether or not this was a redirect request
109
+	 * @return void|bool Sets various properties of the class or returns false if the URL isn't specified
110
+	 */
111 111
 	private function curl_request($url, $redirect = false)
112 112
 	{
113 113
 		// we do have a url I hope
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
 	}
160 160
 
161 161
 	/**
162
-	* Used if being redirected to ensure we have a fully qualified address
163
-	*
164
-	* @param string $last_url The URL we went to
165
-	* @param string $new_url The URL we were redirected to
166
-	* @return string The new URL that was in the HTTP header
167
-	*/
162
+	 * Used if being redirected to ensure we have a fully qualified address
163
+	 *
164
+	 * @param string $last_url The URL we went to
165
+	 * @param string $new_url The URL we were redirected to
166
+	 * @return string The new URL that was in the HTTP header
167
+	 */
168 168
 	private function get_redirect_url($last_url = '', $new_url = '')
169 169
 	{
170 170
 		// Get the elements for these urls
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
 	}
183 183
 
184 184
 	/**
185
-	* Used to return the results to the calling program
186
-	*  - called as ->result() will return the full final array
187
-	*  - called as ->result('body') to just return the page source of the result
188
-	*
189
-	* @param string $area Used to return an area such as body, header, error
190
-	* @return string The response
191
-	*/
185
+	 * Used to return the results to the calling program
186
+	 *  - called as ->result() will return the full final array
187
+	 *  - called as ->result('body') to just return the page source of the result
188
+	 *
189
+	 * @param string $area Used to return an area such as body, header, error
190
+	 * @return string The response
191
+	 */
192 192
 	public function result($area = '')
193 193
 	{
194 194
 		$max_result = count($this->response) - 1;
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
 	}
202 202
 
203 203
 	/**
204
-	* Will return all results from all loops (redirects)
205
-	*  - Can be called as ->result_raw(x) where x is a specific loop results.
206
-	*  - Call as ->result_raw() for everything.
207
-	*
208
-	* @param string $response_number Which response we want to get
209
-	* @return array|string The entire response array or just the specified response
210
-	*/
204
+	 * Will return all results from all loops (redirects)
205
+	 *  - Can be called as ->result_raw(x) where x is a specific loop results.
206
+	 *  - Call as ->result_raw() for everything.
207
+	 *
208
+	 * @param string $response_number Which response we want to get
209
+	 * @return array|string The entire response array or just the specified response
210
+	 */
211 211
 	public function result_raw($response_number = '')
212 212
 	{
213 213
 		if (!is_numeric($response_number))
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
 	}
221 221
 
222 222
 	/**
223
-	* Takes supplied POST data and url encodes it
224
-	*  - forms the date (for post) in to a string var=xyz&var2=abc&var3=123
225
-	*  - drops vars with @ since we don't support sending files (uploading)
226
-	*
227
-	* @param array|string $post_data The raw POST data
228
-	* @return string A string of post data
229
-	*/
223
+	 * Takes supplied POST data and url encodes it
224
+	 *  - forms the date (for post) in to a string var=xyz&var2=abc&var3=123
225
+	 *  - drops vars with @ since we don't support sending files (uploading)
226
+	 *
227
+	 * @param array|string $post_data The raw POST data
228
+	 * @return string A string of post data
229
+	 */
230 230
 	private function build_post_data($post_data)
231 231
 	{
232 232
 		if (is_array($post_data))
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
 	}
246 246
 
247 247
 	/**
248
-	* Sets the final cURL options for the current call
249
-	*  - overwrites our default values with user supplied ones or appends new user ones to what we have
250
-	*  - sets the callback function now that $this is existing
251
-	* @return void
252
-	*/
248
+	 * Sets the final cURL options for the current call
249
+	 *  - overwrites our default values with user supplied ones or appends new user ones to what we have
250
+	 *  - sets the callback function now that $this is existing
251
+	 * @return void
252
+	 */
253 253
 	private function set_options()
254 254
 	{
255 255
 		// Callback to parse the returned headers, if any
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 	}
275 275
 
276 276
 	/**
277
-	* Called to initiate a redirect from a 301, 302 or 307 header
278
-	*  - resets the cURL options for the loop, sets the referrer flag
279
-	*
280
-	* @param string $target_url The URL we want to redirect to
281
-	* @param string $referer_url The URL that we're redirecting from
282
-	*/
277
+	 * Called to initiate a redirect from a 301, 302 or 307 header
278
+	 *  - resets the cURL options for the loop, sets the referrer flag
279
+	 *
280
+	 * @param string $target_url The URL we want to redirect to
281
+	 * @param string $referer_url The URL that we're redirecting from
282
+	 */
283 283
 	private function redirect($target_url, $referer_url)
284 284
 	{
285 285
 		// no no I last saw that over there ... really, 301, 302, 307
@@ -289,13 +289,13 @@  discard block
 block discarded – undo
289 289
 	}
290 290
 
291 291
 	/**
292
-	* Callback function to parse returned headers
293
-	*  - lowercases everything to make it consistent
294
-	*
295
-	* @param type $cr Not sure what this is used for?
296
-	* @param string $header The header
297
-	* @return int The length of the header
298
-	*/
292
+	 * Callback function to parse returned headers
293
+	 *  - lowercases everything to make it consistent
294
+	 *
295
+	 * @param type $cr Not sure what this is used for?
296
+	 * @param string $header The header
297
+	 * @return int The length of the header
298
+	 */
299 299
 	private function header_callback($cr, $header)
300 300
 	{
301 301
 		$_header = trim($header);
Please login to merge, or discard this patch.
Braces   +30 added lines, -24 removed lines patch added patch discarded remove patch
@@ -10,8 +10,9 @@  discard block
 block discarded – undo
10 10
  * @version 2.1 Beta 3
11 11
  */
12 12
 
13
-if (!defined('SMF'))
13
+if (!defined('SMF')) {
14 14
 	die('No direct access...');
15
+}
15 16
 
16 17
 /**
17 18
  * Class curl_fetch_web_data
@@ -87,10 +88,11 @@  discard block
 block discarded – undo
87 88
 	public function get_url_data($url, $post_data = array())
88 89
 	{
89 90
 		// POSTing some data perhaps?
90
-		if (!empty($post_data) && is_array($post_data))
91
-			$this->post_data = $this->build_post_data($post_data);
92
-		elseif (!empty($post_data))
93
-			$this->post_data = trim($post_data);
91
+		if (!empty($post_data) && is_array($post_data)) {
92
+					$this->post_data = $this->build_post_data($post_data);
93
+		} elseif (!empty($post_data)) {
94
+					$this->post_data = trim($post_data);
95
+		}
94 96
 
95 97
 		// set the options and get it
96 98
 		$this->set_options();
@@ -111,10 +113,11 @@  discard block
 block discarded – undo
111 113
 	private function curl_request($url, $redirect = false)
112 114
 	{
113 115
 		// we do have a url I hope
114
-		if ($url == '')
115
-			return false;
116
-		else
117
-			$this->options[CURLOPT_URL] = $url;
116
+		if ($url == '') {
117
+					return false;
118
+		} else {
119
+					$this->options[CURLOPT_URL] = $url;
120
+		}
118 121
 
119 122
 		// if we have not already been redirected, set it up so we can if needed
120 123
 		if (!$redirect)
@@ -194,10 +197,11 @@  discard block
 block discarded – undo
194 197
 		$max_result = count($this->response) - 1;
195 198
 
196 199
 		// just return a specifed area or the entire result?
197
-		if ($area == '')
198
-			return $this->response[$max_result];
199
-		else
200
-			return isset($this->response[$max_result][$area]) ? $this->response[$max_result][$area] : $this->response[$max_result];
200
+		if ($area == '') {
201
+					return $this->response[$max_result];
202
+		} else {
203
+					return isset($this->response[$max_result][$area]) ? $this->response[$max_result][$area] : $this->response[$max_result];
204
+		}
201 205
 	}
202 206
 
203 207
 	/**
@@ -210,9 +214,9 @@  discard block
 block discarded – undo
210 214
 	*/
211 215
 	public function result_raw($response_number = '')
212 216
 	{
213
-		if (!is_numeric($response_number))
214
-			return $this->response;
215
-		else
217
+		if (!is_numeric($response_number)) {
218
+					return $this->response;
219
+		} else
216 220
 		{
217 221
 			$response_number = min($response_number, count($this->response) - 1);
218 222
 			return $this->response[$response_number];
@@ -234,13 +238,14 @@  discard block
 block discarded – undo
234 238
 			$postvars = array();
235 239
 
236 240
 			// build the post data, drop ones with leading @'s since those can be used to send files, we don't support that.
237
-			foreach ($post_data as $name => $value)
238
-				$postvars[] = $name . '=' . urlencode($value[0] == '@' ? '' : $value);
241
+			foreach ($post_data as $name => $value) {
242
+							$postvars[] = $name . '=' . urlencode($value[0] == '@' ? '' : $value);
243
+			}
239 244
 
240 245
 			return implode('&', $postvars);
246
+		} else {
247
+					return $post_data;
241 248
 		}
242
-		else
243
-			return $post_data;
244 249
 
245 250
 	}
246 251
 
@@ -261,9 +266,9 @@  discard block
 block discarded – undo
261 266
 			$keys = array_merge(array_keys($this->default_options), array_keys($this->user_options));
262 267
 			$vals = array_merge($this->default_options, $this->user_options);
263 268
 			$this->options = array_combine($keys, $vals);
269
+		} else {
270
+					$this->options = $this->default_options;
264 271
 		}
265
-		else
266
-			$this->options = $this->default_options;
267 272
 
268 273
 		// POST data options, here we don't allow any overide
269 274
 		if (isset($this->post_data))
@@ -302,8 +307,9 @@  discard block
 block discarded – undo
302 307
 		$temp = explode(': ', $_header, 2);
303 308
 
304 309
 		// set proper headers only
305
-		if (isset($temp[0]) && isset($temp[1]))
306
-			$this->headers[strtolower($temp[0])] = strtolower(trim($temp[1]));
310
+		if (isset($temp[0]) && isset($temp[1])) {
311
+					$this->headers[strtolower($temp[0])] = strtolower(trim($temp[1]));
312
+		}
307 313
 
308 314
 		// return the length of what was passed unless you want a Failed writing header error ;)
309 315
 		return strlen($header);
Please login to merge, or discard this patch.
Sources/Class-Graphics.php 4 patches
Doc Comments   +28 added lines patch added patch discarded remove patch
@@ -44,6 +44,10 @@  discard block
 block discarded – undo
44 44
 		$this->Buf   = range(0, 279);
45 45
 	}
46 46
 
47
+	/**
48
+	 * @param string $data
49
+	 * @param integer $datLen
50
+	 */
47 51
 	public function decompress($data, &$datLen)
48 52
 	{
49 53
 		$stLen  = strlen($data);
@@ -63,6 +67,11 @@  discard block
 block discarded – undo
63 67
 		return $ret;
64 68
 	}
65 69
 
70
+	/**
71
+	 * @param boolean $bInit
72
+	 *
73
+	 * @return integer
74
+	 */
66 75
 	public function LZWCommand(&$data, $bInit)
67 76
 	{
68 77
 		if ($bInit)
@@ -253,6 +262,10 @@  discard block
 block discarded – undo
253 262
 		unset($this->m_nColors, $this->m_arColors);
254 263
 	}
255 264
 
265
+	/**
266
+	 * @param string $lpData
267
+	 * @param integer $num
268
+	 */
256 269
 	public function load($lpData, $num)
257 270
 	{
258 271
 		$this->m_nColors  = 0;
@@ -324,6 +337,9 @@  discard block
 block discarded – undo
324 337
 		unset($this->m_bSorted, $this->m_nTableSize, $this->m_nBgColor, $this->m_nPixelRatio, $this->m_colorTable);
325 338
 	}
326 339
 
340
+	/**
341
+	 * @param integer $hdrLen
342
+	 */
327 343
 	public function load($lpData, &$hdrLen)
328 344
 	{
329 345
 		$hdrLen = 0;
@@ -370,6 +386,10 @@  discard block
 block discarded – undo
370 386
 		unset($this->m_bInterlace, $this->m_bSorted, $this->m_nTableSize, $this->m_colorTable);
371 387
 	}
372 388
 
389
+	/**
390
+	 * @param string $lpData
391
+	 * @param integer $hdrLen
392
+	 */
373 393
 	public function load($lpData, &$hdrLen)
374 394
 	{
375 395
 		$hdrLen = 0;
@@ -412,6 +432,10 @@  discard block
 block discarded – undo
412 432
 		$this->m_lzw = new gif_lzw_compression();
413 433
 	}
414 434
 
435
+	/**
436
+	 * @param string $data
437
+	 * @param integer $datLen
438
+	 */
415 439
 	public function load($data, &$datLen)
416 440
 	{
417 441
 		$datLen = 0;
@@ -464,6 +488,10 @@  discard block
 block discarded – undo
464 488
 		return false;
465 489
 	}
466 490
 
491
+	/**
492
+	 * @param string $data
493
+	 * @param integer $extLen
494
+	 */
467 495
 	public function skipExt(&$data, &$extLen)
468 496
 	{
469 497
 		$extLen = 0;
Please login to merge, or discard this patch.
Switch Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -425,40 +425,40 @@  discard block
 block discarded – undo
425 425
 			switch ($b)
426 426
 			{
427 427
 			// Extension...
428
-			case 0x21:
429
-				$len = 0;
430
-				if (!$this->skipExt($data, $len))
431
-					return false;
428
+				case 0x21:
429
+					$len = 0;
430
+					if (!$this->skipExt($data, $len))
431
+						return false;
432 432
 
433
-				$datLen += $len;
434
-				break;
433
+					$datLen += $len;
434
+					break;
435 435
 
436
-			// Image...
437
-			case 0x2C:
438
-				// Load the header and color table.
439
-				$len = 0;
440
-				if (!$this->m_gih->load($data, $len))
441
-					return false;
436
+				// Image...
437
+				case 0x2C:
438
+					// Load the header and color table.
439
+					$len = 0;
440
+					if (!$this->m_gih->load($data, $len))
441
+						return false;
442 442
 
443
-				$data = substr($data, $len);
444
-				$datLen += $len;
443
+					$data = substr($data, $len);
444
+					$datLen += $len;
445 445
 
446
-				// Decompress the data, and ride on home ;).
447
-				$len = 0;
448
-				if (!($this->m_data = $this->m_lzw->decompress($data, $len)))
449
-					return false;
446
+					// Decompress the data, and ride on home ;).
447
+					$len = 0;
448
+					if (!($this->m_data = $this->m_lzw->decompress($data, $len)))
449
+						return false;
450 450
 
451
-				$data = substr($data, $len);
452
-				$datLen += $len;
451
+					$data = substr($data, $len);
452
+					$datLen += $len;
453 453
 
454
-				if ($this->m_gih->m_bInterlace)
455
-					$this->deInterlace();
454
+					if ($this->m_gih->m_bInterlace)
455
+						$this->deInterlace();
456 456
 
457
-				return true;
457
+					return true;
458 458
 
459
-			case 0x3B: // EOF
460
-			default:
461
-				return false;
459
+				case 0x3B: // EOF
460
+				default:
461
+					return false;
462 462
 			}
463 463
 		}
464 464
 		return false;
@@ -475,27 +475,27 @@  discard block
 block discarded – undo
475 475
 		switch ($b)
476 476
 		{
477 477
 		// Graphic Control...
478
-		case 0xF9:
479
-			$b = ord($data[1]);
480
-			$this->m_disp   = ($b & 0x1C) >> 2;
481
-			$this->m_bUser  = ($b & 0x02) ? true : false;
482
-			$this->m_bTrans = ($b & 0x01) ? true : false;
483
-			list ($this->m_nDelay) = array_values(unpack('v', substr($data, 2, 2)));
484
-			$this->m_nTrans = ord($data[4]);
485
-			break;
486
-
487
-		// Comment...
488
-		case 0xFE:
489
-			$this->m_lpComm = substr($data, 1, ord($data[0]));
490
-			break;
491
-
492
-		// Plain text...
493
-		case 0x01:
494
-			break;
495
-
496
-		// Application...
497
-		case 0xFF:
498
-			break;
478
+			case 0xF9:
479
+				$b = ord($data[1]);
480
+				$this->m_disp   = ($b & 0x1C) >> 2;
481
+				$this->m_bUser  = ($b & 0x02) ? true : false;
482
+				$this->m_bTrans = ($b & 0x01) ? true : false;
483
+				list ($this->m_nDelay) = array_values(unpack('v', substr($data, 2, 2)));
484
+				$this->m_nTrans = ord($data[4]);
485
+				break;
486
+
487
+			// Comment...
488
+			case 0xFE:
489
+				$this->m_lpComm = substr($data, 1, ord($data[0]));
490
+				break;
491
+
492
+			// Plain text...
493
+			case 0x01:
494
+				break;
495
+
496
+			// Application...
497
+			case 0xFF:
498
+				break;
499 499
 		}
500 500
 
501 501
 		// Skip default as defs may change.
@@ -521,25 +521,25 @@  discard block
 block discarded – undo
521 521
 		{
522 522
 			switch ($i)
523 523
 			{
524
-			case 0:
525
-				$s = 8;
526
-				$y = 0;
527
-				break;
528
-
529
-			case 1:
530
-				$s = 8;
531
-				$y = 4;
532
-				break;
533
-
534
-			case 2:
535
-				$s = 4;
536
-				$y = 2;
537
-				break;
538
-
539
-			case 3:
540
-				$s = 2;
541
-				$y = 1;
542
-				break;
524
+				case 0:
525
+					$s = 8;
526
+					$y = 0;
527
+					break;
528
+
529
+				case 1:
530
+					$s = 8;
531
+					$y = 4;
532
+					break;
533
+
534
+				case 2:
535
+					$s = 4;
536
+					$y = 2;
537
+					break;
538
+
539
+				case 3:
540
+					$s = 2;
541
+					$y = 1;
542
+					break;
543 543
 			}
544 544
 
545 545
 			for (; $y < $this->m_gih->m_nHeight; $y += $s)
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 		$this->MAX_LZW_BITS = 12;
39 39
 		unset($this->Next, $this->Vals, $this->Stack, $this->Buf);
40 40
 
41
-		$this->Next  = range(0, (1 << $this->MAX_LZW_BITS)       - 1);
42
-		$this->Vals  = range(0, (1 << $this->MAX_LZW_BITS)       - 1);
41
+		$this->Next  = range(0, (1 << $this->MAX_LZW_BITS) - 1);
42
+		$this->Vals  = range(0, (1 << $this->MAX_LZW_BITS) - 1);
43 43
 		$this->Stack = range(0, (1 << ($this->MAX_LZW_BITS + 1)) - 1);
44 44
 		$this->Buf   = range(0, 279);
45 45
 	}
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
 		for ($i = 0; $i < $this->m_nColors; $i++)
279 279
 		{
280 280
 			$ret .=
281
-				chr(($this->m_arColors[$i] & 0x000000FF))       . // R
282
-				chr(($this->m_arColors[$i] & 0x0000FF00) >>  8) . // G
283
-				chr(($this->m_arColors[$i] & 0x00FF0000) >> 16);  // B
281
+				chr(($this->m_arColors[$i] & 0x000000FF)) . // R
282
+				chr(($this->m_arColors[$i] & 0x0000FF00) >> 8) . // G
283
+				chr(($this->m_arColors[$i] & 0x00FF0000) >> 16); // B
284 284
 		}
285 285
 
286 286
 		return $ret;
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
 	{
291 291
 		$rgb  = intval($rgb) & 0xFFFFFF;
292 292
 		$r1   = ($rgb & 0x0000FF);
293
-		$g1   = ($rgb & 0x00FF00) >>  8;
293
+		$g1   = ($rgb & 0x00FF00) >> 8;
294 294
 		$b1   = ($rgb & 0xFF0000) >> 16;
295 295
 		$idx  = -1;
296 296
 
297 297
 		for ($i = 0; $i < $this->m_nColors; $i++)
298 298
 		{
299 299
 			$r2 = ($this->m_arColors[$i] & 0x000000FF);
300
-			$g2 = ($this->m_arColors[$i] & 0x0000FF00) >>  8;
300
+			$g2 = ($this->m_arColors[$i] & 0x0000FF00) >> 8;
301 301
 			$b2 = ($this->m_arColors[$i] & 0x00FF0000) >> 16;
302 302
 			$d  = abs($r2 - $r1) + abs($g2 - $g1) + abs($b2 - $b1);
303 303
 
Please login to merge, or discard this patch.
Braces   +90 added lines, -62 removed lines patch added patch discarded remove patch
@@ -19,8 +19,9 @@  discard block
 block discarded – undo
19 19
  * @version 2.1 Beta 3
20 20
  */
21 21
 
22
-if (!defined('SMF'))
22
+if (!defined('SMF')) {
23 23
 	die('No direct access...');
24
+}
24 25
 
25 26
 /**
26 27
  * Class gif_lzw_compression
@@ -52,13 +53,15 @@  discard block
 block discarded – undo
52 53
 
53 54
 		$this->LZWCommand($data, true);
54 55
 
55
-		while (($iIndex = $this->LZWCommand($data, false)) >= 0)
56
-			$ret .= chr($iIndex);
56
+		while (($iIndex = $this->LZWCommand($data, false)) >= 0) {
57
+					$ret .= chr($iIndex);
58
+		}
57 59
 
58 60
 		$datLen = $stLen - strlen($data);
59 61
 
60
-		if ($iIndex != -2)
61
-			return false;
62
+		if ($iIndex != -2) {
63
+					return false;
64
+		}
62 65
 
63 66
 		return $ret;
64 67
 	}
@@ -140,8 +143,9 @@  discard block
 block discarded – undo
140 143
 				return $this->FirstCode;
141 144
 			}
142 145
 
143
-			if ($Code == $this->EndCode)
144
-				return -2;
146
+			if ($Code == $this->EndCode) {
147
+							return -2;
148
+			}
145 149
 
146 150
 			$InCode = $Code;
147 151
 			if ($Code >= $this->MaxCode)
@@ -156,8 +160,10 @@  discard block
 block discarded – undo
156 160
 				$this->Stack[$this->sp] = $this->Vals[$Code];
157 161
 				$this->sp++;
158 162
 
159
-				if ($Code == $this->Next[$Code]) // Circular table entry, big GIF Error!
163
+				if ($Code == $this->Next[$Code]) {
164
+					// Circular table entry, big GIF Error!
160 165
 					return -1;
166
+				}
161 167
 
162 168
 				$Code = $this->Next[$Code];
163 169
 			}
@@ -207,8 +213,9 @@  discard block
 block discarded – undo
207 213
 			if ($this->Done)
208 214
 			{
209 215
 				// Ran off the end of my bits...
210
-				if ($this->CurBit >= $this->LastBit)
211
-					return 0;
216
+				if ($this->CurBit >= $this->LastBit) {
217
+									return 0;
218
+				}
212 219
 
213 220
 				return -1;
214 221
 			}
@@ -221,13 +228,14 @@  discard block
 block discarded – undo
221 228
 
222 229
 			if ($count)
223 230
 			{
224
-				for ($i = 0; $i < $count; $i++)
225
-					$this->Buf[2 + $i] = ord($data{$i});
231
+				for ($i = 0; $i < $count; $i++) {
232
+									$this->Buf[2 + $i] = ord($data{$i});
233
+				}
226 234
 
227 235
 				$data = substr($data, $count);
236
+			} else {
237
+							$this->Done = 1;
228 238
 			}
229
-			else
230
-				$this->Done = 1;
231 239
 
232 240
 			$this->LastByte = 2 + $count;
233 241
 			$this->CurBit = ($this->CurBit - $this->LastBit) + 16;
@@ -235,8 +243,9 @@  discard block
 block discarded – undo
235 243
 		}
236 244
 
237 245
 		$iRet = 0;
238
-		for ($i = $this->CurBit, $j = 0; $j < $this->CodeSize; $i++, $j++)
239
-			$iRet |= (($this->Buf[intval($i / 8)] & (1 << ($i % 8))) != 0) << $j;
246
+		for ($i = $this->CurBit, $j = 0; $j < $this->CodeSize; $i++, $j++) {
247
+					$iRet |= (($this->Buf[intval($i / 8)] & (1 << ($i % 8))) != 0) << $j;
248
+		}
240 249
 
241 250
 		$this->CurBit += $this->CodeSize;
242 251
 		return $iRet;
@@ -261,8 +270,9 @@  discard block
 block discarded – undo
261 270
 		for ($i = 0; $i < $num; $i++)
262 271
 		{
263 272
 			$rgb = substr($lpData, $i * 3, 3);
264
-			if (strlen($rgb) < 3)
265
-				return false;
273
+			if (strlen($rgb) < 3) {
274
+							return false;
275
+			}
266 276
 
267 277
 			$this->m_arColors[] = (ord($rgb[2]) << 16) + (ord($rgb[1]) << 8) + ord($rgb[0]);
268 278
 			$this->m_nColors++;
@@ -329,13 +339,15 @@  discard block
 block discarded – undo
329 339
 		$hdrLen = 0;
330 340
 
331 341
 		$this->m_lpVer = substr($lpData, 0, 6);
332
-		if (($this->m_lpVer != 'GIF87a') && ($this->m_lpVer != 'GIF89a'))
333
-			return false;
342
+		if (($this->m_lpVer != 'GIF87a') && ($this->m_lpVer != 'GIF89a')) {
343
+					return false;
344
+		}
334 345
 
335 346
 		list ($this->m_nWidth, $this->m_nHeight) = array_values(unpack('v2', substr($lpData, 6, 4)));
336 347
 
337
-		if (!$this->m_nWidth || !$this->m_nHeight)
338
-			return false;
348
+		if (!$this->m_nWidth || !$this->m_nHeight) {
349
+					return false;
350
+		}
339 351
 
340 352
 		$b = ord(substr($lpData, 10, 1));
341 353
 		$this->m_bGlobalClr  = ($b & 0x80) ? true : false;
@@ -349,8 +361,9 @@  discard block
 block discarded – undo
349 361
 		if ($this->m_bGlobalClr)
350 362
 		{
351 363
 			$this->m_colorTable = new gif_color_table();
352
-			if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize))
353
-				return false;
364
+			if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) {
365
+							return false;
366
+			}
354 367
 
355 368
 			$hdrLen += 3 * $this->m_nTableSize;
356 369
 		}
@@ -377,8 +390,9 @@  discard block
 block discarded – undo
377 390
 		// Get the width/height/etc. from the header.
378 391
 		list ($this->m_nLeft, $this->m_nTop, $this->m_nWidth, $this->m_nHeight) = array_values(unpack('v4', substr($lpData, 0, 8)));
379 392
 
380
-		if (!$this->m_nWidth || !$this->m_nHeight)
381
-			return false;
393
+		if (!$this->m_nWidth || !$this->m_nHeight) {
394
+					return false;
395
+		}
382 396
 
383 397
 		$b = ord($lpData[8]);
384 398
 		$this->m_bLocalClr  = ($b & 0x80) ? true : false;
@@ -390,8 +404,9 @@  discard block
 block discarded – undo
390 404
 		if ($this->m_bLocalClr)
391 405
 		{
392 406
 			$this->m_colorTable = new gif_color_table();
393
-			if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize))
394
-				return false;
407
+			if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) {
408
+							return false;
409
+			}
395 410
 
396 411
 			$hdrLen += 3 * $this->m_nTableSize;
397 412
 		}
@@ -427,8 +442,9 @@  discard block
 block discarded – undo
427 442
 			// Extension...
428 443
 			case 0x21:
429 444
 				$len = 0;
430
-				if (!$this->skipExt($data, $len))
431
-					return false;
445
+				if (!$this->skipExt($data, $len)) {
446
+									return false;
447
+				}
432 448
 
433 449
 				$datLen += $len;
434 450
 				break;
@@ -437,22 +453,25 @@  discard block
 block discarded – undo
437 453
 			case 0x2C:
438 454
 				// Load the header and color table.
439 455
 				$len = 0;
440
-				if (!$this->m_gih->load($data, $len))
441
-					return false;
456
+				if (!$this->m_gih->load($data, $len)) {
457
+									return false;
458
+				}
442 459
 
443 460
 				$data = substr($data, $len);
444 461
 				$datLen += $len;
445 462
 
446 463
 				// Decompress the data, and ride on home ;).
447 464
 				$len = 0;
448
-				if (!($this->m_data = $this->m_lzw->decompress($data, $len)))
449
-					return false;
465
+				if (!($this->m_data = $this->m_lzw->decompress($data, $len))) {
466
+									return false;
467
+				}
450 468
 
451 469
 				$data = substr($data, $len);
452 470
 				$datLen += $len;
453 471
 
454
-				if ($this->m_gih->m_bInterlace)
455
-					$this->deInterlace();
472
+				if ($this->m_gih->m_bInterlace) {
473
+									$this->deInterlace();
474
+				}
456 475
 
457 476
 				return true;
458 477
 
@@ -572,17 +591,20 @@  discard block
 block discarded – undo
572 591
 
573 592
 	public function loadFile($filename, $iIndex)
574 593
 	{
575
-		if ($iIndex < 0)
576
-			return false;
594
+		if ($iIndex < 0) {
595
+					return false;
596
+		}
577 597
 
578 598
 		$this->data = @file_get_contents($filename);
579
-		if ($this->data === false)
580
-			return false;
599
+		if ($this->data === false) {
600
+					return false;
601
+		}
581 602
 
582 603
 		// Tell the header to load up....
583 604
 		$len = 0;
584
-		if (!$this->header->load($this->data, $len))
585
-			return false;
605
+		if (!$this->header->load($this->data, $len)) {
606
+					return false;
607
+		}
586 608
 
587 609
 		$this->data = substr($this->data, $len);
588 610
 
@@ -590,8 +612,9 @@  discard block
 block discarded – undo
590 612
 		for ($j = 0; $j <= $iIndex; $j++)
591 613
 		{
592 614
 			$imgLen = 0;
593
-			if (!$this->image->load($this->data, $imgLen))
594
-				return false;
615
+			if (!$this->image->load($this->data, $imgLen)) {
616
+							return false;
617
+			}
595 618
 
596 619
 			$this->data = substr($this->data, $imgLen);
597 620
 		}
@@ -602,8 +625,9 @@  discard block
 block discarded – undo
602 625
 
603 626
 	public function get_png_data($background_color)
604 627
 	{
605
-		if (!$this->loaded)
606
-			return false;
628
+		if (!$this->loaded) {
629
+					return false;
630
+		}
607 631
 
608 632
 		// Prepare the color table.
609 633
 		if ($this->image->m_gih->m_bLocalClr)
@@ -611,25 +635,26 @@  discard block
 block discarded – undo
611 635
 			$colors = $this->image->m_gih->m_nTableSize;
612 636
 			$pal = $this->image->m_gih->m_colorTable->toString();
613 637
 
614
-			if ($background_color != -1)
615
-				$background_color = $this->image->m_gih->m_colorTable->colorIndex($background_color);
616
-		}
617
-		elseif ($this->header->m_bGlobalClr)
638
+			if ($background_color != -1) {
639
+							$background_color = $this->image->m_gih->m_colorTable->colorIndex($background_color);
640
+			}
641
+		} elseif ($this->header->m_bGlobalClr)
618 642
 		{
619 643
 			$colors = $this->header->m_nTableSize;
620 644
 			$pal = $this->header->m_colorTable->toString();
621 645
 
622
-			if ($background_color != -1)
623
-				$background_color = $this->header->m_colorTable->colorIndex($background_color);
624
-		}
625
-		else
646
+			if ($background_color != -1) {
647
+							$background_color = $this->header->m_colorTable->colorIndex($background_color);
648
+			}
649
+		} else
626 650
 		{
627 651
 			$colors = 0;
628 652
 			$background_color = -1;
629 653
 		}
630 654
 
631
-		if ($background_color == -1)
632
-			$background_color = $this->header->m_nBgColor;
655
+		if ($background_color == -1) {
656
+					$background_color = $this->header->m_nBgColor;
657
+		}
633 658
 
634 659
 		$data = &$this->image->m_data;
635 660
 		$header = &$this->image->m_gih;
@@ -645,11 +670,13 @@  discard block
 block discarded – undo
645 670
 			for ($x = 0; $x < $this->header->m_nWidth; $x++, $i++)
646 671
 			{
647 672
 				// Is this in the proper range?  If so, get the specific pixel data...
648
-				if ($x >= $header->m_nLeft && $y >= $header->m_nTop && $x < ($header->m_nLeft + $header->m_nWidth) && $y < ($header->m_nTop + $header->m_nHeight))
649
-					$bmp .= $data{$i};
673
+				if ($x >= $header->m_nLeft && $y >= $header->m_nTop && $x < ($header->m_nLeft + $header->m_nWidth) && $y < ($header->m_nTop + $header->m_nHeight)) {
674
+									$bmp .= $data{$i};
675
+				}
650 676
 				// Otherwise, this is background...
651
-				else
652
-					$bmp .= chr($background_color);
677
+				else {
678
+									$bmp .= chr($background_color);
679
+				}
653 680
 			}
654 681
 		}
655 682
 
@@ -678,8 +705,9 @@  discard block
 block discarded – undo
678 705
 			$tmp = 'tRNS';
679 706
 
680 707
 			// Stick each color on - full transparency or none.
681
-			for ($i = 0; $i < $colors; $i++)
682
-				$tmp .= $i == $this->image->m_nTrans ? "\x00" : "\xFF";
708
+			for ($i = 0; $i < $colors; $i++) {
709
+							$tmp .= $i == $this->image->m_nTrans ? "\x00" : "\xFF";
710
+			}
683 711
 
684 712
 			$out .= $tmp . pack('N', smf_crc32($tmp));
685 713
 		}
Please login to merge, or discard this patch.
Sources/Class-Package.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	 * of elements, an array of xmlArray's is returned for use with foreach.
258 258
 	 * Example use:
259 259
 	 *  foreach ($xml->set('html/body/p') as $p)
260
-	 * @param $path string The path to search for.
260
+	 * @param string $path string The path to search for.
261 261
 	 * @return array An array of xmlArray objects
262 262
 	 */
263 263
 	public function set($path)
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
 	 *
1020 1020
 	 * @param string $ftp_path The path to the directory
1021 1021
 	 * @param bool $search Whether or not to get a recursive directory listing
1022
-	 * @return string|boolean The results of the command or false if unsuccessful
1022
+	 * @return false|string The results of the command or false if unsuccessful
1023 1023
 	 */
1024 1024
 	public function list_dir($ftp_path = '', $search = false)
1025 1025
 	{
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
 	 *
1065 1065
 	 * @param string $file The name of a file
1066 1066
 	 * @param string $listing A directory listing or null to generate one
1067
-	 * @return string|boolean The name of the file or false if it wasn't found
1067
+	 * @return string|false The name of the file or false if it wasn't found
1068 1068
 	 */
1069 1069
 	public function locate($file, $listing = null)
1070 1070
 	{
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 			if ((!isset($match[3]) || trim($match[3]) != '/') && (!isset($match[2]) || trim($match[2]) != '/'))
425 425
 			{
426 426
 				// Because PHP 5.2.0+ seems to croak using regex, we'll have to do this the less fun way.
427
-				$last_tag_end = strpos($data, '</' . $match[1]. '>');
427
+				$last_tag_end = strpos($data, '</' . $match[1] . '>');
428 428
 				if ($last_tag_end === false)
429 429
 					continue;
430 430
 
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 						break;
439 439
 
440 440
 					// If not then find the next ending tag.
441
-					$next_tag_end = strpos($data, '</' . $match[1]. '>', $offset);
441
+					$next_tag_end = strpos($data, '</' . $match[1] . '>', $offset);
442 442
 
443 443
 					// Didn't find one? Then just use the last and sod it.
444 444
 					if ($next_tag_end === false)
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 				// Parse the insides.
453 453
 				$inner_match = substr($data, 0, $last_tag_end);
454 454
 				// Data now starts from where this section ends.
455
-				$data = substr($data, $last_tag_end + strlen('</' . $match[1]. '>'));
455
+				$data = substr($data, $last_tag_end + strlen('</' . $match[1] . '>'));
456 456
 
457 457
 				if (!empty($inner_match))
458 458
 				{
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 		$trans_tbl = array_flip(get_html_translation_table(HTML_ENTITIES, ENT_QUOTES));
619 619
 
620 620
 		// Translate all the entities out.
621
-		$data = strtr(preg_replace_callback('~&#(\d{1,4});~', function ($m)
621
+		$data = strtr(preg_replace_callback('~&#(\d{1,4});~', function($m)
622 622
 		{
623 623
 			return chr("$m[1]");
624 624
 		}, $data), $trans_tbl);
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
 		// Set different modes.
868 868
 		$chmod_values = $is_dir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666);
869 869
 
870
-		foreach($chmod_values as $val)
870
+		foreach ($chmod_values as $val)
871 871
 		{
872 872
 			// If it's writable, break out of the loop.
873 873
 			if (is_writable($ftp_file))
Please login to merge, or discard this patch.
Braces   +266 added lines, -199 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Class xmlArray
@@ -65,8 +66,9 @@  discard block
 block discarded – undo
65 66
 		}
66 67
 
67 68
 		// Is the input an array? (ie. passed from file()?)
68
-		if (is_array($data))
69
-			$data = implode('', $data);
69
+		if (is_array($data)) {
70
+					$data = implode('', $data);
71
+		}
70 72
 
71 73
 		// Remove any xml declaration or doctype, and parse out comments and CDATA.
72 74
 		$data = preg_replace('/<!--.*?-->/s', '', $this->_to_cdata(preg_replace(array('/^<\?xml.+?\?' . '>/is', '/<!DOCTYPE[^>]+?' . '>/s'), '', $data)));
@@ -101,8 +103,9 @@  discard block
 block discarded – undo
101 103
 		// Get the element, in array form.
102 104
 		$array = $this->path($path);
103 105
 
104
-		if ($array === false)
105
-			return false;
106
+		if ($array === false) {
107
+					return false;
108
+		}
106 109
 
107 110
 		// Getting elements into this is a bit complicated...
108 111
 		if ($get_elements && !is_string($array))
@@ -113,8 +116,9 @@  discard block
 block discarded – undo
113 116
 			foreach ($array->array as $val)
114 117
 			{
115 118
 				// Skip the name and any attributes.
116
-				if (is_array($val))
117
-					$temp .= $this->_xml($val, null);
119
+				if (is_array($val)) {
120
+									$temp .= $this->_xml($val, null);
121
+				}
118 122
 			}
119 123
 
120 124
 			// Just get the XML data and then take out the CDATAs.
@@ -156,32 +160,35 @@  discard block
 block discarded – undo
156 160
 			elseif (substr($el, 0, 1) == '@')
157 161
 			{
158 162
 				// It simplifies things if the attribute is already there ;).
159
-				if (isset($array[$el]))
160
-					return $array[$el];
161
-				else
163
+				if (isset($array[$el])) {
164
+									return $array[$el];
165
+				} else
162 166
 				{
163 167
 					$trace = debug_backtrace();
164 168
 					$i = 0;
165
-					while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this))
166
-						$i++;
169
+					while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this)) {
170
+											$i++;
171
+					}
167 172
 					$debug = ' (from ' . $trace[$i - 1]['file'] . ' on line ' . $trace[$i - 1]['line'] . ')';
168 173
 
169 174
 					// Cause an error.
170
-					if ($this->debug_level & E_NOTICE)
171
-						trigger_error('Undefined XML attribute: ' . substr($el, 1) . $debug, E_USER_NOTICE);
175
+					if ($this->debug_level & E_NOTICE) {
176
+											trigger_error('Undefined XML attribute: ' . substr($el, 1) . $debug, E_USER_NOTICE);
177
+					}
172 178
 					return false;
173 179
 				}
180
+			} else {
181
+							$lvl = null;
174 182
 			}
175
-			else
176
-				$lvl = null;
177 183
 
178 184
 			// Find this element.
179 185
 			$array = $this->_path($array, $el, $lvl);
180 186
 		}
181 187
 
182 188
 		// Clean up after $lvl, for $return_full.
183
-		if ($return_full && (!isset($array['name']) || substr($array['name'], -1) != ']'))
184
-			$array = array('name' => $el . '[]', $array);
189
+		if ($return_full && (!isset($array['name']) || substr($array['name'], -1) != ']')) {
190
+					$array = array('name' => $el . '[]', $array);
191
+		}
185 192
 
186 193
 		// Create the right type of class...
187 194
 		$newClass = get_class($this);
@@ -216,10 +223,11 @@  discard block
 block discarded – undo
216 223
 				$el = substr($el, 0, strpos($el, '['));
217 224
 			}
218 225
 			// Find an attribute.
219
-			elseif (substr($el, 0, 1) == '@')
220
-				return isset($array[$el]);
221
-			else
222
-				$lvl = null;
226
+			elseif (substr($el, 0, 1) == '@') {
227
+							return isset($array[$el]);
228
+			} else {
229
+							$lvl = null;
230
+			}
223 231
 
224 232
 			// Find this element.
225 233
 			$array = $this->_path($array, $el, $lvl, true);
@@ -244,8 +252,9 @@  discard block
 block discarded – undo
244 252
 		$i = 0;
245 253
 		foreach ($temp->array as $item)
246 254
 		{
247
-			if (is_array($item))
248
-				$i++;
255
+			if (is_array($item)) {
256
+							$i++;
257
+			}
249 258
 		}
250 259
 
251 260
 		return $i;
@@ -269,8 +278,9 @@  discard block
 block discarded – undo
269 278
 		foreach ($xml->array as $val)
270 279
 		{
271 280
 			// Skip these, they aren't elements.
272
-			if (!is_array($val) || $val['name'] == '!')
273
-				continue;
281
+			if (!is_array($val) || $val['name'] == '!') {
282
+							continue;
283
+			}
274 284
 
275 285
 			// Create the right type of class...
276 286
 			$newClass = get_class($this);
@@ -297,14 +307,16 @@  discard block
 block discarded – undo
297 307
 			$path = $this->path($path);
298 308
 
299 309
 			// The path was not found
300
-			if ($path === false)
301
-				return false;
310
+			if ($path === false) {
311
+							return false;
312
+			}
302 313
 
303 314
 			$path = $path->array;
304 315
 		}
305 316
 		// Just use the current array.
306
-		else
307
-			$path = $this->array;
317
+		else {
318
+					$path = $this->array;
319
+		}
308 320
 
309 321
 		// Add the xml declaration to the front.
310 322
 		return '<?xml version="1.0"?' . '>' . $this->_xml($path, 0);
@@ -326,14 +338,16 @@  discard block
 block discarded – undo
326 338
 			$path = $this->path($path);
327 339
 
328 340
 			// The path was not found
329
-			if ($path === false)
330
-				return false;
341
+			if ($path === false) {
342
+							return false;
343
+			}
331 344
 
332 345
 			$path = $path->array;
333 346
 		}
334 347
 		// No, so just use the current array.
335
-		else
336
-			$path = $this->array;
348
+		else {
349
+					$path = $this->array;
350
+		}
337 351
 
338 352
 		return $this->_array($path);
339 353
 	}
@@ -355,8 +369,9 @@  discard block
 block discarded – undo
355 369
 		{
356 370
 			// Find and remove the next tag.
357 371
 			preg_match('/\A<([\w\-:]+)((?:\s+.+?)?)([\s]?\/)?' . '>/', $data, $match);
358
-			if (isset($match[0]))
359
-				$data = preg_replace('/' . preg_quote($match[0], '/') . '/s', '', $data, 1);
372
+			if (isset($match[0])) {
373
+							$data = preg_replace('/' . preg_quote($match[0], '/') . '/s', '', $data, 1);
374
+			}
360 375
 
361 376
 			// Didn't find a tag?  Keep looping....
362 377
 			if (!isset($match[1]) || $match[1] == '')
@@ -367,11 +382,12 @@  discard block
 block discarded – undo
367 382
 					$text_value = $this->_from_cdata($data);
368 383
 					$data = '';
369 384
 
370
-					if ($text_value != '')
371
-						$current[] = array(
385
+					if ($text_value != '') {
386
+											$current[] = array(
372 387
 							'name' => '!',
373 388
 							'value' => $text_value
374 389
 						);
390
+					}
375 391
 				}
376 392
 				// If the < isn't immediately next to the current position... more data.
377 393
 				elseif (strpos($data, '<') > 0)
@@ -379,11 +395,12 @@  discard block
 block discarded – undo
379 395
 					$text_value = $this->_from_cdata(substr($data, 0, strpos($data, '<')));
380 396
 					$data = substr($data, strpos($data, '<'));
381 397
 
382
-					if ($text_value != '')
383
-						$current[] = array(
398
+					if ($text_value != '') {
399
+											$current[] = array(
384 400
 							'name' => '!',
385 401
 							'value' => $text_value
386 402
 						);
403
+					}
387 404
 				}
388 405
 				// If we're looking at a </something> with no start, kill it.
389 406
 				elseif (strpos($data, '<') !== false && strpos($data, '<') == 0)
@@ -393,22 +410,23 @@  discard block
 block discarded – undo
393 410
 						$text_value = $this->_from_cdata(substr($data, 0, strpos($data, '<', 1)));
394 411
 						$data = substr($data, strpos($data, '<', 1));
395 412
 
396
-						if ($text_value != '')
397
-							$current[] = array(
413
+						if ($text_value != '') {
414
+													$current[] = array(
398 415
 								'name' => '!',
399 416
 								'value' => $text_value
400 417
 							);
401
-					}
402
-					else
418
+						}
419
+					} else
403 420
 					{
404 421
 						$text_value = $this->_from_cdata($data);
405 422
 						$data = '';
406 423
 
407
-						if ($text_value != '')
408
-							$current[] = array(
424
+						if ($text_value != '') {
425
+													$current[] = array(
409 426
 								'name' => '!',
410 427
 								'value' => $text_value
411 428
 							);
429
+						}
412 430
 					}
413 431
 				}
414 432
 
@@ -425,8 +443,9 @@  discard block
 block discarded – undo
425 443
 			{
426 444
 				// Because PHP 5.2.0+ seems to croak using regex, we'll have to do this the less fun way.
427 445
 				$last_tag_end = strpos($data, '</' . $match[1]. '>');
428
-				if ($last_tag_end === false)
429
-					continue;
446
+				if ($last_tag_end === false) {
447
+									continue;
448
+				}
430 449
 
431 450
 				$offset = 0;
432 451
 				while (1 == 1)
@@ -434,16 +453,17 @@  discard block
 block discarded – undo
434 453
 					// Where is the next start tag?
435 454
 					$next_tag_start = strpos($data, '<' . $match[1], $offset);
436 455
 					// If the next start tag is after the last end tag then we've found the right close.
437
-					if ($next_tag_start === false || $next_tag_start > $last_tag_end)
438
-						break;
456
+					if ($next_tag_start === false || $next_tag_start > $last_tag_end) {
457
+											break;
458
+					}
439 459
 
440 460
 					// If not then find the next ending tag.
441 461
 					$next_tag_end = strpos($data, '</' . $match[1]. '>', $offset);
442 462
 
443 463
 					// Didn't find one? Then just use the last and sod it.
444
-					if ($next_tag_end === false)
445
-						break;
446
-					else
464
+					if ($next_tag_end === false) {
465
+											break;
466
+					} else
447 467
 					{
448 468
 						$last_tag_end = $next_tag_end;
449 469
 						$offset = $next_tag_start + 1;
@@ -457,16 +477,17 @@  discard block
 block discarded – undo
457 477
 				if (!empty($inner_match))
458 478
 				{
459 479
 					// Parse the inner data.
460
-					if (strpos($inner_match, '<') !== false)
461
-						$el += $this->_parse($inner_match);
462
-					elseif (trim($inner_match) != '')
480
+					if (strpos($inner_match, '<') !== false) {
481
+											$el += $this->_parse($inner_match);
482
+					} elseif (trim($inner_match) != '')
463 483
 					{
464 484
 						$text_value = $this->_from_cdata($inner_match);
465
-						if ($text_value != '')
466
-							$el[] = array(
485
+						if ($text_value != '') {
486
+													$el[] = array(
467 487
 								'name' => '!',
468 488
 								'value' => $text_value
469 489
 							);
490
+						}
470 491
 					}
471 492
 				}
472 493
 			}
@@ -478,8 +499,9 @@  discard block
 block discarded – undo
478 499
 				preg_match_all('/([\w:]+)="(.+?)"/', $match[2], $attr, PREG_SET_ORDER);
479 500
 
480 501
 				// Set them as @attribute-name.
481
-				foreach ($attr as $match_attr)
482
-					$el['@' . $match_attr[1]] = $match_attr[2];
502
+				foreach ($attr as $match_attr) {
503
+									$el['@' . $match_attr[1]] = $match_attr[2];
504
+				}
483 505
 			}
484 506
 		}
485 507
 
@@ -503,16 +525,18 @@  discard block
 block discarded – undo
503 525
 		if (is_array($array) && !isset($array['name']))
504 526
 		{
505 527
 			$temp = '';
506
-			foreach ($array as $val)
507
-				$temp .= $this->_xml($val, $indent);
528
+			foreach ($array as $val) {
529
+							$temp .= $this->_xml($val, $indent);
530
+			}
508 531
 			return $temp;
509 532
 		}
510 533
 
511 534
 		// This is just text!
512
-		if ($array['name'] == '!')
513
-			return $indentation . '<![CDATA[' . $array['value'] . ']]>';
514
-		elseif (substr($array['name'], -2) == '[]')
515
-			$array['name'] = substr($array['name'], 0, -2);
535
+		if ($array['name'] == '!') {
536
+					return $indentation . '<![CDATA[' . $array['value'] . ']]>';
537
+		} elseif (substr($array['name'], -2) == '[]') {
538
+					$array['name'] = substr($array['name'], 0, -2);
539
+		}
516 540
 
517 541
 		// Start the element.
518 542
 		$output = $indentation . '<' . $array['name'];
@@ -523,9 +547,9 @@  discard block
 block discarded – undo
523 547
 		// Run through and recursively output all the elements or attrbutes inside this.
524 548
 		foreach ($array as $k => $v)
525 549
 		{
526
-			if (substr($k, 0, 1) == '@')
527
-				$output .= ' ' . substr($k, 1) . '="' . $v . '"';
528
-			elseif (is_array($v))
550
+			if (substr($k, 0, 1) == '@') {
551
+							$output .= ' ' . substr($k, 1) . '="' . $v . '"';
552
+			} elseif (is_array($v))
529 553
 			{
530 554
 				$output_el .= $this->_xml($v, $indent === null ? null : $indent + 1);
531 555
 				$inside_elements = true;
@@ -533,10 +557,11 @@  discard block
 block discarded – undo
533 557
 		}
534 558
 
535 559
 		// Indent, if necessary.... then close the tag.
536
-		if ($inside_elements)
537
-			$output .= '>' . $output_el . $indentation . '</' . $array['name'] . '>';
538
-		else
539
-			$output .= ' />';
560
+		if ($inside_elements) {
561
+					$output .= '>' . $output_el . $indentation . '</' . $array['name'] . '>';
562
+		} else {
563
+					$output .= ' />';
564
+		}
540 565
 
541 566
 		return $output;
542 567
 	}
@@ -553,19 +578,22 @@  discard block
 block discarded – undo
553 578
 		$text = '';
554 579
 		foreach ($array as $value)
555 580
 		{
556
-			if (!is_array($value) || !isset($value['name']))
557
-				continue;
581
+			if (!is_array($value) || !isset($value['name'])) {
582
+							continue;
583
+			}
558 584
 
559
-			if ($value['name'] == '!')
560
-				$text .= $value['value'];
561
-			else
562
-				$return[$value['name']] = $this->_array($value);
585
+			if ($value['name'] == '!') {
586
+							$text .= $value['value'];
587
+			} else {
588
+							$return[$value['name']] = $this->_array($value);
589
+			}
563 590
 		}
564 591
 
565
-		if (empty($return))
566
-			return $text;
567
-		else
568
-			return $return;
592
+		if (empty($return)) {
593
+					return $text;
594
+		} else {
595
+					return $return;
596
+		}
569 597
 	}
570 598
 
571 599
 	/**
@@ -583,24 +611,28 @@  discard block
 block discarded – undo
583 611
 		foreach ($parts as $part)
584 612
 		{
585 613
 			// Handle XML comments.
586
-			if (!$inCdata && $part === '<!--')
587
-				$inComment = true;
588
-			if ($inComment && $part === '-->')
589
-				$inComment = false;
590
-			elseif ($inComment)
591
-				continue;
614
+			if (!$inCdata && $part === '<!--') {
615
+							$inComment = true;
616
+			}
617
+			if ($inComment && $part === '-->') {
618
+							$inComment = false;
619
+			} elseif ($inComment) {
620
+							continue;
621
+			}
592 622
 
593 623
 			// Handle Cdata blocks.
594
-			elseif (!$inComment && $part === '<![CDATA[')
595
-				$inCdata = true;
596
-			elseif ($inCdata && $part === ']]>')
597
-				$inCdata = false;
598
-			elseif ($inCdata)
599
-				$output .= htmlentities($part, ENT_QUOTES);
624
+			elseif (!$inComment && $part === '<![CDATA[') {
625
+							$inCdata = true;
626
+			} elseif ($inCdata && $part === ']]>') {
627
+							$inCdata = false;
628
+			} elseif ($inCdata) {
629
+							$output .= htmlentities($part, ENT_QUOTES);
630
+			}
600 631
 
601 632
 			// Everything else is kept as is.
602
-			else
603
-				$output .= $part;
633
+			else {
634
+							$output .= $part;
635
+			}
604 636
 		}
605 637
 
606 638
 		return $output;
@@ -635,22 +667,26 @@  discard block
 block discarded – undo
635 667
 	protected function _fetch($array)
636 668
 	{
637 669
 		// Don't return anything if this is just a string.
638
-		if (is_string($array))
639
-			return '';
670
+		if (is_string($array)) {
671
+					return '';
672
+		}
640 673
 
641 674
 		$temp = '';
642 675
 		foreach ($array as $text)
643 676
 		{
644 677
 			// This means it's most likely an attribute or the name itself.
645
-			if (!isset($text['name']))
646
-				continue;
678
+			if (!isset($text['name'])) {
679
+							continue;
680
+			}
647 681
 
648 682
 			// This is text!
649
-			if ($text['name'] == '!')
650
-				$temp .= $text['value'];
683
+			if ($text['name'] == '!') {
684
+							$temp .= $text['value'];
685
+			}
651 686
 			// Another element - dive in ;).
652
-			else
653
-				$temp .= $this->_fetch($text);
687
+			else {
688
+							$temp .= $this->_fetch($text);
689
+			}
654 690
 		}
655 691
 
656 692
 		// Return all the bits and pieces we've put together.
@@ -669,12 +705,14 @@  discard block
 block discarded – undo
669 705
 	protected function _path($array, $path, $level, $no_error = false)
670 706
 	{
671 707
 		// Is $array even an array?  It might be false!
672
-		if (!is_array($array))
673
-			return false;
708
+		if (!is_array($array)) {
709
+					return false;
710
+		}
674 711
 
675 712
 		// Asking for *no* path?
676
-		if ($path == '' || $path == '.')
677
-			return $array;
713
+		if ($path == '' || $path == '.') {
714
+					return $array;
715
+		}
678 716
 		$paths = explode('|', $path);
679 717
 
680 718
 		// A * means all elements of any name.
@@ -685,16 +723,18 @@  discard block
 block discarded – undo
685 723
 		// Check each element.
686 724
 		foreach ($array as $value)
687 725
 		{
688
-			if (!is_array($value) || $value['name'] === '!')
689
-				continue;
726
+			if (!is_array($value) || $value['name'] === '!') {
727
+							continue;
728
+			}
690 729
 
691 730
 			if ($show_all || in_array($value['name'], $paths))
692 731
 			{
693 732
 				// Skip elements before "the one".
694
-				if ($level !== null && $level > 0)
695
-					$level--;
696
-				else
697
-					$results[] = $value;
733
+				if ($level !== null && $level > 0) {
734
+									$level--;
735
+				} else {
736
+									$results[] = $value;
737
+				}
698 738
 			}
699 739
 		}
700 740
 
@@ -703,21 +743,25 @@  discard block
 block discarded – undo
703 743
 		{
704 744
 			$trace = debug_backtrace();
705 745
 			$i = 0;
706
-			while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this))
707
-				$i++;
746
+			while ($i < count($trace) && isset($trace[$i]['class']) && $trace[$i]['class'] == get_class($this)) {
747
+							$i++;
748
+			}
708 749
 			$debug = ' from ' . $trace[$i - 1]['file'] . ' on line ' . $trace[$i - 1]['line'];
709 750
 
710 751
 			// Cause an error.
711
-			if ($this->debug_level & E_NOTICE && !$no_error)
712
-				trigger_error('Undefined XML element: ' . $path . $debug, E_USER_NOTICE);
752
+			if ($this->debug_level & E_NOTICE && !$no_error) {
753
+							trigger_error('Undefined XML element: ' . $path . $debug, E_USER_NOTICE);
754
+			}
713 755
 			return false;
714 756
 		}
715 757
 		// Only one result.
716
-		elseif (count($results) == 1 || $level !== null)
717
-			return $results[0];
758
+		elseif (count($results) == 1 || $level !== null) {
759
+					return $results[0];
760
+		}
718 761
 		// Return the result set.
719
-		else
720
-			return $results + array('name' => $path . '[]');
762
+		else {
763
+					return $results + array('name' => $path . '[]');
764
+		}
721 765
 	}
722 766
 }
723 767
 
@@ -764,8 +808,9 @@  discard block
 block discarded – undo
764 808
 		$this->error = false;
765 809
 		$this->pasv = array();
766 810
 
767
-		if ($ftp_server !== null)
768
-			$this->connect($ftp_server, $ftp_port, $ftp_user, $ftp_pass);
811
+		if ($ftp_server !== null) {
812
+					$this->connect($ftp_server, $ftp_port, $ftp_user, $ftp_pass);
813
+		}
769 814
 	}
770 815
 
771 816
 	/**
@@ -778,14 +823,16 @@  discard block
 block discarded – undo
778 823
 	 */
779 824
 	public function connect($ftp_server, $ftp_port = 21, $ftp_user = 'anonymous', $ftp_pass = '[email protected]')
780 825
 	{
781
-		if (strpos($ftp_server, 'ftp://') === 0)
782
-			$ftp_server = substr($ftp_server, 6);
783
-		elseif (strpos($ftp_server, 'ftps://') === 0)
784
-			$ftp_server = 'ssl://' . substr($ftp_server, 7);
785
-		if (strpos($ftp_server, 'http://') === 0)
786
-			$ftp_server = substr($ftp_server, 7);
787
-		elseif (strpos($ftp_server, 'https://') === 0)
788
-			$ftp_server = substr($ftp_server, 8);
826
+		if (strpos($ftp_server, 'ftp://') === 0) {
827
+					$ftp_server = substr($ftp_server, 6);
828
+		} elseif (strpos($ftp_server, 'ftps://') === 0) {
829
+					$ftp_server = 'ssl://' . substr($ftp_server, 7);
830
+		}
831
+		if (strpos($ftp_server, 'http://') === 0) {
832
+					$ftp_server = substr($ftp_server, 7);
833
+		} elseif (strpos($ftp_server, 'https://') === 0) {
834
+					$ftp_server = substr($ftp_server, 8);
835
+		}
789 836
 		$ftp_server = strtr($ftp_server, array('/' => '', ':' => '', '@' => ''));
790 837
 
791 838
 		// Connect to the FTP server.
@@ -828,12 +875,14 @@  discard block
 block discarded – undo
828 875
 	 */
829 876
 	public function chdir($ftp_path)
830 877
 	{
831
-		if (!is_resource($this->connection))
832
-			return false;
878
+		if (!is_resource($this->connection)) {
879
+					return false;
880
+		}
833 881
 
834 882
 		// No slash on the end, please...
835
-		if ($ftp_path !== '/' && substr($ftp_path, -1) === '/')
836
-			$ftp_path = substr($ftp_path, 0, -1);
883
+		if ($ftp_path !== '/' && substr($ftp_path, -1) === '/') {
884
+					$ftp_path = substr($ftp_path, 0, -1);
885
+		}
837 886
 
838 887
 		fwrite($this->connection, 'CWD ' . $ftp_path . "\r\n");
839 888
 		if (!$this->check_response(250))
@@ -854,11 +903,13 @@  discard block
 block discarded – undo
854 903
 	 */
855 904
 	public function chmod($ftp_file, $chmod)
856 905
 	{
857
-		if (!is_resource($this->connection))
858
-			return false;
906
+		if (!is_resource($this->connection)) {
907
+					return false;
908
+		}
859 909
 
860
-		if ($ftp_file == '')
861
-			$ftp_file = '.';
910
+		if ($ftp_file == '') {
911
+					$ftp_file = '.';
912
+		}
862 913
 
863 914
 		// Do we have a file or a dir?
864 915
 		$is_dir = is_dir($ftp_file);
@@ -874,9 +925,7 @@  discard block
 block discarded – undo
874 925
 			{
875 926
 				$is_writable = true;
876 927
 				break;
877
-			}
878
-
879
-			else
928
+			} else
880 929
 			{
881 930
 				// Convert the chmod value from octal (0777) to text ("777").
882 931
 				fwrite($this->connection, 'SITE CHMOD ' . decoct($val) . ' ' . $ftp_file . "\r\n");
@@ -899,8 +948,9 @@  discard block
 block discarded – undo
899 948
 	public function unlink($ftp_file)
900 949
 	{
901 950
 		// We are actually connected, right?
902
-		if (!is_resource($this->connection))
903
-			return false;
951
+		if (!is_resource($this->connection)) {
952
+					return false;
953
+		}
904 954
 
905 955
 		// Delete file X.
906 956
 		fwrite($this->connection, 'DELE ' . $ftp_file . "\r\n");
@@ -929,9 +979,9 @@  discard block
 block discarded – undo
929 979
 	{
930 980
 		// Wait for a response that isn't continued with -, but don't wait too long.
931 981
 		$time = time();
932
-		do
933
-			$this->last_message = fgets($this->connection, 1024);
934
-		while ((strlen($this->last_message) < 4 || strpos($this->last_message, ' ') === 0 || strpos($this->last_message, ' ', 3) !== 3) && time() - $time < 5);
982
+		do {
983
+					$this->last_message = fgets($this->connection, 1024);
984
+		} while ((strlen($this->last_message) < 4 || strpos($this->last_message, ' ') === 0 || strpos($this->last_message, ' ', 3) !== 3) && time() - $time < 5);
935 985
 
936 986
 		// Was the desired response returned?
937 987
 		return is_array($desired) ? in_array(substr($this->last_message, 0, 3), $desired) : substr($this->last_message, 0, 3) == $desired;
@@ -945,15 +995,16 @@  discard block
 block discarded – undo
945 995
 	public function passive()
946 996
 	{
947 997
 		// We can't create a passive data connection without a primary one first being there.
948
-		if (!is_resource($this->connection))
949
-			return false;
998
+		if (!is_resource($this->connection)) {
999
+					return false;
1000
+		}
950 1001
 
951 1002
 		// Request a passive connection - this means, we'll talk to you, you don't talk to us.
952 1003
 		@fwrite($this->connection, 'PASV' . "\r\n");
953 1004
 		$time = time();
954
-		do
955
-			$response = fgets($this->connection, 1024);
956
-		while (strpos($response, ' ', 3) !== 3 && time() - $time < 5);
1005
+		do {
1006
+					$response = fgets($this->connection, 1024);
1007
+		} while (strpos($response, ' ', 3) !== 3 && time() - $time < 5);
957 1008
 
958 1009
 		// If it's not 227, we weren't given an IP and port, which means it failed.
959 1010
 		if (strpos($response, '227 ') !== 0)
@@ -984,12 +1035,14 @@  discard block
 block discarded – undo
984 1035
 	public function create_file($ftp_file)
985 1036
 	{
986 1037
 		// First, we have to be connected... very important.
987
-		if (!is_resource($this->connection))
988
-			return false;
1038
+		if (!is_resource($this->connection)) {
1039
+					return false;
1040
+		}
989 1041
 
990 1042
 		// I'd like one passive mode, please!
991
-		if (!$this->passive())
992
-			return false;
1043
+		if (!$this->passive()) {
1044
+					return false;
1045
+		}
993 1046
 
994 1047
 		// Seems logical enough, so far...
995 1048
 		fwrite($this->connection, 'STOR ' . $ftp_file . "\r\n");
@@ -1024,12 +1077,14 @@  discard block
 block discarded – undo
1024 1077
 	public function list_dir($ftp_path = '', $search = false)
1025 1078
 	{
1026 1079
 		// Are we even connected...?
1027
-		if (!is_resource($this->connection))
1028
-			return false;
1080
+		if (!is_resource($this->connection)) {
1081
+					return false;
1082
+		}
1029 1083
 
1030 1084
 		// Passive... non-agressive...
1031
-		if (!$this->passive())
1032
-			return false;
1085
+		if (!$this->passive()) {
1086
+					return false;
1087
+		}
1033 1088
 
1034 1089
 		// Get the listing!
1035 1090
 		fwrite($this->connection, 'LIST -1' . ($search ? 'R' : '') . ($ftp_path == '' ? '' : ' ' . $ftp_path) . "\r\n");
@@ -1045,8 +1100,9 @@  discard block
 block discarded – undo
1045 1100
 
1046 1101
 		// Read in the file listing.
1047 1102
 		$data = '';
1048
-		while (!feof($fp))
1049
-			$data .= fread($fp, 4096);
1103
+		while (!feof($fp)) {
1104
+					$data .= fread($fp, 4096);
1105
+		}
1050 1106
 		fclose($fp);
1051 1107
 
1052 1108
 		// Everything go okay?
@@ -1068,21 +1124,23 @@  discard block
 block discarded – undo
1068 1124
 	 */
1069 1125
 	public function locate($file, $listing = null)
1070 1126
 	{
1071
-		if ($listing === null)
1072
-			$listing = $this->list_dir('', true);
1127
+		if ($listing === null) {
1128
+					$listing = $this->list_dir('', true);
1129
+		}
1073 1130
 		$listing = explode("\n", $listing);
1074 1131
 
1075 1132
 		@fwrite($this->connection, 'PWD' . "\r\n");
1076 1133
 		$time = time();
1077
-		do
1078
-			$response = fgets($this->connection, 1024);
1079
-		while ($response[3] != ' ' && time() - $time < 5);
1134
+		do {
1135
+					$response = fgets($this->connection, 1024);
1136
+		} while ($response[3] != ' ' && time() - $time < 5);
1080 1137
 
1081 1138
 		// Check for 257!
1082
-		if (preg_match('~^257 "(.+?)" ~', $response, $match) != 0)
1083
-			$current_dir = strtr($match[1], array('""' => '"'));
1084
-		else
1085
-			$current_dir = '';
1139
+		if (preg_match('~^257 "(.+?)" ~', $response, $match) != 0) {
1140
+					$current_dir = strtr($match[1], array('""' => '"'));
1141
+		} else {
1142
+					$current_dir = '';
1143
+		}
1086 1144
 
1087 1145
 		for ($i = 0, $n = count($listing); $i < $n; $i++)
1088 1146
 		{
@@ -1095,12 +1153,15 @@  discard block
 block discarded – undo
1095 1153
 			// Okay, this file's name is:
1096 1154
 			$listing[$i] = $current_dir . '/' . trim(strlen($listing[$i]) > 30 ? strrchr($listing[$i], ' ') : $listing[$i]);
1097 1155
 
1098
-			if ($file[0] == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1))
1099
-				return $listing[$i];
1100
-			if (substr($file, -1) == '*' && substr($listing[$i], 0, strlen($file) - 1) == substr($file, 0, -1))
1101
-				return $listing[$i];
1102
-			if (basename($listing[$i]) == $file || $listing[$i] == $file)
1103
-				return $listing[$i];
1156
+			if ($file[0] == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1)) {
1157
+							return $listing[$i];
1158
+			}
1159
+			if (substr($file, -1) == '*' && substr($listing[$i], 0, strlen($file) - 1) == substr($file, 0, -1)) {
1160
+							return $listing[$i];
1161
+			}
1162
+			if (basename($listing[$i]) == $file || $listing[$i] == $file) {
1163
+							return $listing[$i];
1164
+			}
1104 1165
 		}
1105 1166
 
1106 1167
 		return false;
@@ -1115,8 +1176,9 @@  discard block
 block discarded – undo
1115 1176
 	public function create_dir($ftp_dir)
1116 1177
 	{
1117 1178
 		// We must be connected to the server to do something.
1118
-		if (!is_resource($this->connection))
1119
-			return false;
1179
+		if (!is_resource($this->connection)) {
1180
+					return false;
1181
+		}
1120 1182
 
1121 1183
 		// Make this new beautiful directory!
1122 1184
 		fwrite($this->connection, 'MKD ' . $ftp_dir . "\r\n");
@@ -1148,35 +1210,40 @@  discard block
 block discarded – undo
1148 1210
 
1149 1211
 				$path = strtr($_SERVER['DOCUMENT_ROOT'], array('/home/' . $match[1] . '/' => '', '/home2/' . $match[1] . '/' => ''));
1150 1212
 
1151
-				if (substr($path, -1) == '/')
1152
-					$path = substr($path, 0, -1);
1213
+				if (substr($path, -1) == '/') {
1214
+									$path = substr($path, 0, -1);
1215
+				}
1153 1216
 
1154
-				if (strlen(dirname($_SERVER['PHP_SELF'])) > 1)
1155
-					$path .= dirname($_SERVER['PHP_SELF']);
1217
+				if (strlen(dirname($_SERVER['PHP_SELF'])) > 1) {
1218
+									$path .= dirname($_SERVER['PHP_SELF']);
1219
+				}
1220
+			} elseif (strpos($filesystem_path, '/var/www/') === 0) {
1221
+							$path = substr($filesystem_path, 8);
1222
+			} else {
1223
+							$path = strtr(strtr($filesystem_path, array('\\' => '/')), array($_SERVER['DOCUMENT_ROOT'] => ''));
1156 1224
 			}
1157
-			elseif (strpos($filesystem_path, '/var/www/') === 0)
1158
-				$path = substr($filesystem_path, 8);
1159
-			else
1160
-				$path = strtr(strtr($filesystem_path, array('\\' => '/')), array($_SERVER['DOCUMENT_ROOT'] => ''));
1225
+		} else {
1226
+					$path = '';
1161 1227
 		}
1162
-		else
1163
-			$path = '';
1164 1228
 
1165 1229
 		if (is_resource($this->connection) && $this->list_dir($path) == '')
1166 1230
 		{
1167 1231
 			$data = $this->list_dir('', true);
1168 1232
 
1169
-			if ($lookup_file === null)
1170
-				$lookup_file = $_SERVER['PHP_SELF'];
1233
+			if ($lookup_file === null) {
1234
+							$lookup_file = $_SERVER['PHP_SELF'];
1235
+			}
1171 1236
 
1172 1237
 			$found_path = dirname($this->locate('*' . basename(dirname($lookup_file)) . '/' . basename($lookup_file), $data));
1173
-			if ($found_path == false)
1174
-				$found_path = dirname($this->locate(basename($lookup_file)));
1175
-			if ($found_path != false)
1176
-				$path = $found_path;
1238
+			if ($found_path == false) {
1239
+							$found_path = dirname($this->locate(basename($lookup_file)));
1240
+			}
1241
+			if ($found_path != false) {
1242
+							$path = $found_path;
1243
+			}
1244
+		} elseif (is_resource($this->connection)) {
1245
+					$found_path = true;
1177 1246
 		}
1178
-		elseif (is_resource($this->connection))
1179
-			$found_path = true;
1180 1247
 
1181 1248
 		return array($username, $path, isset($found_path));
1182 1249
 	}
Please login to merge, or discard this patch.
Sources/Class-SearchAPI.php 1 patch
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,6 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @param array $wordsSearch Search words
57 57
 	 * @param array $wordsExclude Words to exclude
58 58
 	 * @param bool $isExcluded Whether the specfied word should be excluded
59
+	 * @return void
59 60
 	 */
60 61
 	public function prepareIndexes($word, array &$wordsSearch, array &$wordsExclude, $isExcluded);
61 62
 
@@ -130,7 +131,7 @@  discard block
 block discarded – undo
130 131
 	 * @param array $excludedIndexWords Indexed words that should be excluded
131 132
 	 * @param array $participants
132 133
 	 * @param array $searchArray
133
-	 * @return mixed
134
+	 * @return integer
134 135
 	 */
135 136
 	public function searchQuery(array $query_params, array $searchWords, array $excludedIndexWords, array $participants, array $searchArray);
136 137
 }
Please login to merge, or discard this patch.
Sources/Class-TOTP.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	/**
280 280
 	 * Generate the timestamp for the calculation
281 281
 	 *
282
-	 * @return integer Timestamp
282
+	 * @return double Timestamp
283 283
 	 */
284 284
 	public function generateTimestamp()
285 285
 	{
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 * Truncate the given hash down to just what we need
291 291
 	 *
292 292
 	 * @param string $hash Hash to truncate
293
-	 * @return string Truncated hash value
293
+	 * @return integer Truncated hash value
294 294
 	 */
295 295
 	public function truncateHash($hash)
296 296
 	{
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	public function setInitKey($key)
116 116
 	{
117
-		if (preg_match('/^['.implode('', array_keys($this->getLookup())).']+$/', $key) == false) {
117
+		if (preg_match('/^[' . implode('', array_keys($this->getLookup())) . ']+$/', $key) == false) {
118 118
 			throw new \InvalidArgumentException('Invalid base32 hash!');
119 119
 		}
120 120
 		$this->initKey = $key;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 		$initKey = ($initKey == null) ? $this->getInitKey() : $initKey;
248 248
 		$timestamp = ($timestamp == null) ? $this->generateTimestamp() : $timestamp;
249 249
 
250
-		$hash = hash_hmac (
250
+		$hash = hash_hmac(
251 251
 			'sha1',
252 252
 			pack('N*', 0) . pack('N*', $timestamp),
253 253
 			$initKey,
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 		$code = '';
271 271
 
272 272
 		for ($i = 0; $i < $length; $i++) {
273
-			$code .= $lookup[mt_rand(0, strlen($lookup)-1)];
273
+			$code .= $lookup[mt_rand(0, strlen($lookup) - 1)];
274 274
 		}
275 275
 
276 276
 		return $code;
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	 */
284 284
 	public function generateTimestamp()
285 285
 	{
286
-		return floor(microtime(true)/$this->getRefresh());
286
+		return floor(microtime(true) / $this->getRefresh());
287 287
 	}
288 288
 
289 289
 	/**
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
 		$offset = ord($hash[19]) & 0xf;
298 298
 
299 299
 		return (
300
-			((ord($hash[$offset+0]) & 0x7f) << 24 ) |
301
-			((ord($hash[$offset+1]) & 0xff) << 16 ) |
302
-			((ord($hash[$offset+2]) & 0xff) << 8 ) |
303
-			(ord($hash[$offset+3]) & 0xff)
300
+			((ord($hash[$offset + 0]) & 0x7f) << 24) |
301
+			((ord($hash[$offset + 1]) & 0xff) << 16) |
302
+			((ord($hash[$offset + 2]) & 0xff) << 8) |
303
+			(ord($hash[$offset + 3]) & 0xff)
304 304
 		) % pow(10, $this->getCodeLength());
305 305
 	}
306 306
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	{
316 316
 		$lookup = $this->getLookup();
317 317
 
318
-		if (preg_match('/^['.implode('', array_keys($lookup)).']+$/', $hash) == false) {
318
+		if (preg_match('/^[' . implode('', array_keys($lookup)) . ']+$/', $hash) == false) {
319 319
 			throw new \InvalidArgumentException('Invalid base32 hash!');
320 320
 		}
321 321
 
Please login to merge, or discard this patch.
Sources/DbPackages-postgresql.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -518,7 +518,7 @@
 block discarded – undo
518 518
  * @param array $parameters Not used?
519 519
  * @param string $if_exists What to do if the index exists. If 'update', the definition will be updated.
520 520
  * @param string $error
521
- * @return boolean Whether or not the operation was successful
521
+ * @return false|null Whether or not the operation was successful
522 522
  */
523 523
 function smf_db_add_index($table_name, $index_info, $parameters = array(), $if_exists = 'update', $error = 'fatal')
524 524
 {
Please login to merge, or discard this patch.
Braces   +110 added lines, -86 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Add the file functions to the $smcFunc array.
@@ -52,8 +53,9 @@  discard block
 block discarded – undo
52 53
 		'messages', 'moderators', 'package_servers', 'permission_profiles', 'permissions', 'personal_messages',
53 54
 		'pm_recipients', 'poll_choices', 'polls', 'scheduled_tasks', 'sessions', 'settings', 'smileys',
54 55
 		'themes', 'topics');
55
-	foreach ($reservedTables as $k => $table_name)
56
-		$reservedTables[$k] = strtolower($db_prefix . $table_name);
56
+	foreach ($reservedTables as $k => $table_name) {
57
+			$reservedTables[$k] = strtolower($db_prefix . $table_name);
58
+	}
57 59
 
58 60
 	// We in turn may need the extra stuff.
59 61
 	db_extend('extra');
@@ -102,8 +104,9 @@  discard block
 block discarded – undo
102 104
 	$table_name = str_replace('{db_prefix}', $db_prefix, $table_name);
103 105
 
104 106
 	// First - no way do we touch SMF tables.
105
-	if (in_array(strtolower($table_name), $reservedTables))
106
-		return false;
107
+	if (in_array(strtolower($table_name), $reservedTables)) {
108
+			return false;
109
+	}
107 110
 
108 111
 	// Log that we'll want to remove this on uninstall.
109 112
 	$db_package_log[] = array('remove_table', $table_name);
@@ -113,10 +116,11 @@  discard block
 block discarded – undo
113 116
 	if (in_array($full_table_name, $tables))
114 117
 	{
115 118
 		// This is a sad day... drop the table? If not, return false (error) by default.
116
-		if ($if_exists == 'overwrite')
117
-			$smcFunc['db_drop_table']($table_name);
118
-		else
119
-			return $if_exists == 'ignore';
119
+		if ($if_exists == 'overwrite') {
120
+					$smcFunc['db_drop_table']($table_name);
121
+		} else {
122
+					return $if_exists == 'ignore';
123
+		}
120 124
 	}
121 125
 
122 126
 	// If we've got this far - good news - no table exists. We can build our own!
@@ -134,17 +138,18 @@  discard block
 block discarded – undo
134 138
 				)
135 139
 			);
136 140
 			$default = 'default nextval(\'' . $table_name . '_seq\')';
141
+		} elseif (isset($column['default']) && $column['default'] !== null) {
142
+					$default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\'';
143
+		} else {
144
+					$default = '';
137 145
 		}
138
-		elseif (isset($column['default']) && $column['default'] !== null)
139
-			$default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\'';
140
-		else
141
-			$default = '';
142 146
 
143 147
 		// Sort out the size...
144 148
 		$column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null;
145 149
 		list ($type, $size) = $smcFunc['db_calculate_type']($column['type'], $column['size']);
146
-		if ($size !== null)
147
-			$type = $type . '(' . $size . ')';
150
+		if ($size !== null) {
151
+					$type = $type . '(' . $size . ')';
152
+		}
148 153
 
149 154
 		// Now just put it together!
150 155
 		$table_query .= "\n\t\"" . $column['name'] . '" ' . $type . ' ' . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default . ',';
@@ -157,19 +162,21 @@  discard block
 block discarded – undo
157 162
 		$columns = implode(',', $index['columns']);
158 163
 
159 164
 		// Primary goes in the table...
160
-		if (isset($index['type']) && $index['type'] == 'primary')
161
-			$table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),';
162
-		else
165
+		if (isset($index['type']) && $index['type'] == 'primary') {
166
+					$table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),';
167
+		} else
163 168
 		{
164
-			if (empty($index['name']))
165
-				$index['name'] = implode('_', $index['columns']);
169
+			if (empty($index['name'])) {
170
+							$index['name'] = implode('_', $index['columns']);
171
+			}
166 172
 			$index_queries[] = 'CREATE ' . (isset($index['type']) && $index['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $table_name . '_' . $index['name'] . ' ON ' . $table_name . ' (' . $columns . ')';
167 173
 		}
168 174
 	}
169 175
 
170 176
 	// No trailing commas!
171
-	if (substr($table_query, -1) == ',')
172
-		$table_query = substr($table_query, 0, -1);
177
+	if (substr($table_query, -1) == ',') {
178
+			$table_query = substr($table_query, 0, -1);
179
+	}
173 180
 
174 181
 	$table_query .= ')';
175 182
 
@@ -180,12 +187,13 @@  discard block
 block discarded – undo
180 187
 		)
181 188
 	);
182 189
 	// And the indexes...
183
-	foreach ($index_queries as $query)
184
-		$smcFunc['db_query']('', $query,
190
+	foreach ($index_queries as $query) {
191
+			$smcFunc['db_query']('', $query,
185 192
 		array(
186 193
 			'security_override' => true,
187 194
 		)
188 195
 	);
196
+	}
189 197
 
190 198
 	// Go, go power rangers!
191 199
 	$smcFunc['db_transaction']('commit');
@@ -213,8 +221,9 @@  discard block
 block discarded – undo
213 221
 	$table_name = str_replace('{db_prefix}', $db_prefix, $table_name);
214 222
 
215 223
 	// God no - dropping one of these = bad.
216
-	if (in_array(strtolower($table_name), $reservedTables))
217
-		return false;
224
+	if (in_array(strtolower($table_name), $reservedTables)) {
225
+			return false;
226
+	}
218 227
 
219 228
 	// Does it exist?
220 229
 	if (in_array($full_table_name, $smcFunc['db_list_tables']()))
@@ -272,21 +281,24 @@  discard block
 block discarded – undo
272 281
 
273 282
 	// Does it exist - if so don't add it again!
274 283
 	$columns = $smcFunc['db_list_columns']($table_name, false);
275
-	foreach ($columns as $column)
276
-		if ($column == $column_info['name'])
284
+	foreach ($columns as $column) {
285
+			if ($column == $column_info['name'])
277 286
 		{
278 287
 			// If we're going to overwrite then use change column.
279 288
 			if ($if_exists == 'update')
280 289
 				return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info);
281
-			else
282
-				return false;
290
+	}
291
+			else {
292
+							return false;
293
+			}
283 294
 		}
284 295
 
285 296
 	// Get the specifics...
286 297
 	$column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null;
287 298
 	list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']);
288
-	if ($size !== null)
289
-		$type = $type . '(' . $size . ')';
299
+	if ($size !== null) {
300
+			$type = $type . '(' . $size . ')';
301
+	}
290 302
 
291 303
 	// Now add the thing!
292 304
 	$query = '
@@ -301,11 +313,12 @@  discard block
 block discarded – undo
301 313
 	// If there's more attributes they need to be done via a change on PostgreSQL.
302 314
 	unset($column_info['type'], $column_info['size']);
303 315
 
304
-	if (count($column_info) != 1)
305
-		return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info);
306
-	else
307
-		return true;
308
-}
316
+	if (count($column_info) != 1) {
317
+			return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info);
318
+	} else {
319
+			return true;
320
+	}
321
+	}
309 322
 
310 323
 /**
311 324
  * Removes a column.
@@ -324,8 +337,8 @@  discard block
 block discarded – undo
324 337
 
325 338
 	// Does it exist?
326 339
 	$columns = $smcFunc['db_list_columns']($table_name, true);
327
-	foreach ($columns as $column)
328
-		if ($column['name'] == $column_name)
340
+	foreach ($columns as $column) {
341
+			if ($column['name'] == $column_name)
329 342
 		{
330 343
 			// If there is an auto we need remove it!
331 344
 			if ($column['auto'])
@@ -335,6 +348,7 @@  discard block
 block discarded – undo
335 348
 						'security_override' => true,
336 349
 					)
337 350
 				);
351
+	}
338 352
 
339 353
 			$smcFunc['db_query']('', '
340 354
 				ALTER TABLE ' . $table_name . '
@@ -369,13 +383,15 @@  discard block
 block discarded – undo
369 383
 	// Check it does exist!
370 384
 	$columns = $smcFunc['db_list_columns']($table_name, true);
371 385
 	$old_info = null;
372
-	foreach ($columns as $column)
373
-		if ($column['name'] == $old_column)
386
+	foreach ($columns as $column) {
387
+			if ($column['name'] == $old_column)
374 388
 			$old_info = $column;
389
+	}
375 390
 
376 391
 	// Nothing?
377
-	if ($old_info == null)
378
-		return false;
392
+	if ($old_info == null) {
393
+			return false;
394
+	}
379 395
 
380 396
 	// Now we check each bit individually and ALTER as required.
381 397
 	if (isset($column_info['name']) && $column_info['name'] != $old_column)
@@ -432,8 +448,9 @@  discard block
 block discarded – undo
432 448
 	{
433 449
 		$column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null;
434 450
 		list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']);
435
-		if ($size !== null)
436
-			$type = $type . '(' . $size . ')';
451
+		if ($size !== null) {
452
+					$type = $type . '(' . $size . ')';
453
+		}
437 454
 
438 455
 		// The alter is a pain.
439 456
 		$smcFunc['db_transaction']('begin');
@@ -527,21 +544,23 @@  discard block
 block discarded – undo
527 544
 	$table_name = str_replace('{db_prefix}', $db_prefix, $table_name);
528 545
 
529 546
 	// No columns = no index.
530
-	if (empty($index_info['columns']))
531
-		return false;
547
+	if (empty($index_info['columns'])) {
548
+			return false;
549
+	}
532 550
 	$columns = implode(',', $index_info['columns']);
533 551
 
534 552
 	// No name - make it up!
535 553
 	if (empty($index_info['name']))
536 554
 	{
537 555
 		// No need for primary.
538
-		if (isset($index_info['type']) && $index_info['type'] == 'primary')
539
-			$index_info['name'] = '';
540
-		else
541
-			$index_info['name'] = $table_name . implode('_', $index_info['columns']);
556
+		if (isset($index_info['type']) && $index_info['type'] == 'primary') {
557
+					$index_info['name'] = '';
558
+		} else {
559
+					$index_info['name'] = $table_name . implode('_', $index_info['columns']);
560
+		}
561
+	} else {
562
+			$index_info['name'] = $table_name . $index_info['name'];
542 563
 	}
543
-	else
544
-		$index_info['name'] = $table_name . $index_info['name'];
545 564
 
546 565
 	// Log that we are going to want to remove this!
547 566
 	$db_package_log[] = array('remove_index', $table_name, $index_info['name']);
@@ -554,10 +573,11 @@  discard block
 block discarded – undo
554 573
 		if ($index['name'] == $index_info['name'] || ($index['type'] == 'primary' && isset($index_info['type']) && $index_info['type'] == 'primary'))
555 574
 		{
556 575
 			// If we want to overwrite simply remove the current one then continue.
557
-			if ($if_exists != 'update' || $index['type'] == 'primary')
558
-				return false;
559
-			else
560
-				$smcFunc['db_remove_index']($table_name, $index_info['name']);
576
+			if ($if_exists != 'update' || $index['type'] == 'primary') {
577
+							return false;
578
+			} else {
579
+							$smcFunc['db_remove_index']($table_name, $index_info['name']);
580
+			}
561 581
 		}
562 582
 	}
563 583
 
@@ -571,8 +591,7 @@  discard block
 block discarded – undo
571 591
 				'security_override' => true,
572 592
 			)
573 593
 		);
574
-	}
575
-	else
594
+	} else
576 595
 	{
577 596
 		$smcFunc['db_query']('', '
578 597
 			CREATE ' . (isset($index_info['type']) && $index_info['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $index_info['name'] . ' ON ' . $table_name . ' (' . $columns . ')',
@@ -600,8 +619,9 @@  discard block
 block discarded – undo
600 619
 
601 620
 	// Better exist!
602 621
 	$indexes = $smcFunc['db_list_indexes']($table_name, true);
603
-	if ($index_name != 'primary')
604
-		$index_name = $table_name . '_' . $index_name;
622
+	if ($index_name != 'primary') {
623
+			$index_name = $table_name . '_' . $index_name;
624
+	}
605 625
 
606 626
 	foreach ($indexes as $index)
607 627
 	{
@@ -661,8 +681,7 @@  discard block
 block discarded – undo
661 681
 			'mediumtext' => 'text',
662 682
 			'largetext' => 'text',
663 683
 		);
664
-	}
665
-	else
684
+	} else
666 685
 	{
667 686
 		$types = array(
668 687
 			'character varying' => 'varchar',
@@ -674,13 +693,15 @@  discard block
 block discarded – undo
674 693
 	// Got it? Change it!
675 694
 	if (isset($types[$type_name]))
676 695
 	{
677
-		if ($type_name == 'tinytext')
678
-			$type_size = 255;
696
+		if ($type_name == 'tinytext') {
697
+					$type_size = 255;
698
+		}
679 699
 		$type_name = $types[$type_name];
680 700
 	}
681 701
 	// Numbers don't have a size.
682
-	if (strpos($type_name, 'int') !== false)
683
-			$type_size = null;
702
+	if (strpos($type_name, 'int') !== false) {
703
+				$type_size = null;
704
+	}
684 705
 
685 706
 	return array($type_name, $type_size);
686 707
 }
@@ -734,8 +755,7 @@  discard block
 block discarded – undo
734 755
 		if (!$detail)
735 756
 		{
736 757
 			$columns[] = $row['column_name'];
737
-		}
738
-		else
758
+		} else
739 759
 		{
740 760
 			$auto = false;
741 761
 			// What is the default?
@@ -743,11 +763,11 @@  discard block
 block discarded – undo
743 763
 			{
744 764
 				$default = null;
745 765
 				$auto = true;
766
+			} elseif (trim($row['column_default']) != '') {
767
+							$default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::'));
768
+			} else {
769
+							$default = null;
746 770
 			}
747
-			elseif (trim($row['column_default']) != '')
748
-				$default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::'));
749
-			else
750
-				$default = null;
751 771
 
752 772
 			// Make the type generic.
753 773
 			list ($type, $size) = $smcFunc['db_calculate_type']($row['data_type'], $row['character_maximum_length'], true);
@@ -798,26 +818,30 @@  discard block
 block discarded – undo
798 818
 	while ($row = $smcFunc['db_fetch_assoc']($result))
799 819
 	{
800 820
 		// Try get the columns that make it up.
801
-		if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0)
802
-			continue;
821
+		if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) {
822
+					continue;
823
+		}
803 824
 
804 825
 		$columns = explode(',', $matches[1]);
805 826
 
806
-		if (empty($columns))
807
-			continue;
827
+		if (empty($columns)) {
828
+					continue;
829
+		}
808 830
 
809
-		foreach ($columns as $k => $v)
810
-			$columns[$k] = trim($v);
831
+		foreach ($columns as $k => $v) {
832
+					$columns[$k] = trim($v);
833
+		}
811 834
 
812 835
 		// Fix up the name to be consistent cross databases
813
-		if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1)
814
-			$row['name'] = 'PRIMARY';
815
-		else
816
-			$row['name'] = str_replace($table_name . '_', '', $row['name']);
836
+		if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1) {
837
+					$row['name'] = 'PRIMARY';
838
+		} else {
839
+					$row['name'] = str_replace($table_name . '_', '', $row['name']);
840
+		}
817 841
 
818
-		if (!$detail)
819
-			$indexes[] = $row['name'];
820
-		else
842
+		if (!$detail) {
843
+					$indexes[] = $row['name'];
844
+		} else
821 845
 		{
822 846
 			$indexes[$row['name']] = array(
823 847
 				'name' => $row['name'],
Please login to merge, or discard this patch.
Sources/Drafts.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @param string $post_errors A string of info about errors encountered trying to save this draft
177 177
  * @param array $recipientList An array of data about who this PM is being sent to
178
- * @return boolean false if you can't save the draft, true if we're doing this via XML more than 5 seconds after the last save, nothing otherwise
178
+ * @return boolean|null false if you can't save the draft, true if we're doing this via XML more than 5 seconds after the last save, nothing otherwise
179 179
  */
180 180
 function SavePMDraft(&$post_errors, $recipientList)
181 181
 {
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
  *
393 393
  * @param int $id_draft The ID of the draft to delete
394 394
  * @param boolean $check Whether or not to check that the draft belongs to the current user
395
- * @return boolean False if it couldn't be deleted (doesn't return anything otherwise)
395
+ * @return false|null False if it couldn't be deleted (doesn't return anything otherwise)
396 396
  */
397 397
 function DeleteDraft($id_draft, $check = true)
398 398
 {
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
  * @param int $member_id ID of the member to show drafts for
427 427
  * @param boolean|integer If $type is 1, this can be set to only load drafts for posts in the specific topic
428 428
  * @param int $draft_type The type of drafts to show - 0 for post drafts, 1 for PM drafts
429
- * @return boolean False if the drafts couldn't be loaded, nothing otherwise
429
+ * @return false|null False if the drafts couldn't be loaded, nothing otherwise
430 430
  */
431 431
 function ShowDrafts($member_id, $topic = false, $draft_type = 0)
432 432
 {
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
  * Allows for the deleting and loading/editing of drafts
511 511
  *
512 512
  * @param type $memID
513
- * @param type $draft_type
513
+ * @param integer $draft_type
514 514
  */
515 515
 function showProfileDrafts($memID, $draft_type = 0)
516 516
 {
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
  * Uses the showpmdraft template
664 664
  * Allows for the deleting and loading/editing of drafts
665 665
  *
666
- * @param type $memID
666
+ * @param integer $memID
667 667
  */
668 668
 function showPMDrafts($memID = -1)
669 669
 {
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 				locked = {int:locked},
86 86
 				is_sticky = {int:is_sticky}
87 87
 			WHERE id_draft = {int:id_draft}',
88
-			array (
88
+			array(
89 89
 				'id_topic' => $topic_id,
90 90
 				'id_board' => $board,
91 91
 				'poster_time' => time(),
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 		DELETE FROM {db_prefix}user_drafts
411 411
 		WHERE id_draft IN ({array_int:id_draft})' . ($check ? '
412 412
 			AND  id_member = {int:id_member}' : ''),
413
-		array (
413
+		array(
414 414
 			'id_draft' => $id_draft,
415 415
 			'id_member' => empty($user_info['id']) ? -1 : $user_info['id'],
416 416
 		)
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 			$context['drafts'][] = array(
472 472
 				'subject' => censorText(shorten_subject(stripslashes($row['subject']), 24)),
473 473
 				'poster_time' => timeformat($row['poster_time']),
474
-				'link' => '<a href="' . $scripturl . '?action=post;board=' . $row['id_board'] . ';' . (!empty($row['id_topic']) ? 'topic='. $row['id_topic'] .'.0;' : '') . 'id_draft=' . $row['id_draft'] . '">' . $row['subject'] . '</a>',
474
+				'link' => '<a href="' . $scripturl . '?action=post;board=' . $row['id_board'] . ';' . (!empty($row['id_topic']) ? 'topic=' . $row['id_topic'] . '.0;' : '') . 'id_draft=' . $row['id_draft'] . '">' . $row['subject'] . '</a>',
475 475
 			);
476 476
 		// PM drafts
477 477
 		elseif ($draft_type === 1)
Please login to merge, or discard this patch.
Braces   +81 added lines, -57 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 loadLanguage('Drafts');
21 22
 
@@ -33,8 +34,9 @@  discard block
 block discarded – undo
33 34
 	global $context, $user_info, $smcFunc, $modSettings, $board;
34 35
 
35 36
 	// can you be, should you be ... here?
36
-	if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft']))
37
-		return false;
37
+	if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) {
38
+			return false;
39
+	}
38 40
 
39 41
 	// read in what they sent us, if anything
40 42
 	$id_draft = (int) $_POST['id_draft'];
@@ -46,14 +48,16 @@  discard block
 block discarded – undo
46 48
 		$context['draft_saved_on'] = $draft_info['poster_time'];
47 49
 
48 50
 		// since we were called from the autosave function, send something back
49
-		if (!empty($id_draft))
50
-			XmlDraft($id_draft);
51
+		if (!empty($id_draft)) {
52
+					XmlDraft($id_draft);
53
+		}
51 54
 
52 55
 		return true;
53 56
 	}
54 57
 
55
-	if (!isset($_POST['message']))
56
-		$_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : '';
58
+	if (!isset($_POST['message'])) {
59
+			$_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : '';
60
+	}
57 61
 
58 62
 	// prepare any data from the form
59 63
 	$topic_id = empty($_REQUEST['topic']) ? 0 : (int) $_REQUEST['topic'];
@@ -66,8 +70,9 @@  discard block
 block discarded – undo
66 70
 
67 71
 	// message and subject still need a bit more work
68 72
 	preparsecode($draft['body']);
69
-	if ($smcFunc['strlen']($draft['subject']) > 100)
70
-		$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
73
+	if ($smcFunc['strlen']($draft['subject']) > 100) {
74
+			$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
75
+	}
71 76
 
72 77
 	// Modifying an existing draft, like hitting the save draft button or autosave enabled?
73 78
 	if (!empty($id_draft) && !empty($draft_info) && $draft_info['id_member'] == $user_info['id'])
@@ -150,9 +155,9 @@  discard block
 block discarded – undo
150 155
 		{
151 156
 			$context['draft_saved'] = true;
152 157
 			$context['id_draft'] = $id_draft;
158
+		} else {
159
+					$post_errors[] = 'draft_not_saved';
153 160
 		}
154
-		else
155
-			$post_errors[] = 'draft_not_saved';
156 161
 
157 162
 		// cleanup
158 163
 		unset($_POST['save_draft']);
@@ -182,8 +187,9 @@  discard block
 block discarded – undo
182 187
 	global $context, $user_info, $smcFunc, $modSettings;
183 188
 
184 189
 	// PM survey says ... can you stay or must you go
185
-	if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft']))
186
-		return false;
190
+	if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) {
191
+			return false;
192
+	}
187 193
 
188 194
 	// read in what you sent us
189 195
 	$id_pm_draft = (int) $_POST['id_pm_draft'];
@@ -195,8 +201,9 @@  discard block
 block discarded – undo
195 201
 		$context['draft_saved_on'] = $draft_info['poster_time'];
196 202
 
197 203
 		// Send something back to the javascript caller
198
-		if (!empty($id_draft))
199
-			XmlDraft($id_draft);
204
+		if (!empty($id_draft)) {
205
+					XmlDraft($id_draft);
206
+		}
200 207
 
201 208
 		return true;
202 209
 	}
@@ -206,9 +213,9 @@  discard block
 block discarded – undo
206 213
 	{
207 214
 		$recipientList['to'] = isset($_POST['recipient_to']) ? explode(',', $_POST['recipient_to']) : array();
208 215
 		$recipientList['bcc'] = isset($_POST['recipient_bcc']) ? explode(',', $_POST['recipient_bcc']) : array();
216
+	} elseif (!empty($draft_info['to_list']) && empty($recipientList)) {
217
+			$recipientList = json_decode($draft_info['to_list'], true);
209 218
 	}
210
-	elseif (!empty($draft_info['to_list']) && empty($recipientList))
211
-		$recipientList = json_decode($draft_info['to_list'], true);
212 219
 
213 220
 	// prepare the data we got from the form
214 221
 	$reply_id = empty($_POST['replied_to']) ? 0 : (int) $_POST['replied_to'];
@@ -217,8 +224,9 @@  discard block
 block discarded – undo
217 224
 
218 225
 	// message and subject always need a bit more work
219 226
 	preparsecode($draft['body']);
220
-	if ($smcFunc['strlen']($draft['subject']) > 100)
221
-		$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
227
+	if ($smcFunc['strlen']($draft['subject']) > 100) {
228
+			$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
229
+	}
222 230
 
223 231
 	// Modifying an existing PM draft?
224 232
 	if (!empty($id_pm_draft) && !empty($draft_info) && $draft_info['id_member'] == $user_info['id'])
@@ -284,9 +292,9 @@  discard block
 block discarded – undo
284 292
 		{
285 293
 			$context['draft_saved'] = true;
286 294
 			$context['id_pm_draft'] = $id_pm_draft;
295
+		} else {
296
+					$post_errors[] = 'draft_not_saved';
287 297
 		}
288
-		else
289
-			$post_errors[] = 'draft_not_saved';
290 298
 	}
291 299
 
292 300
 	// if we were called from the autosave function, send something back
@@ -319,8 +327,9 @@  discard block
 block discarded – undo
319 327
 	$type = (int) $type;
320 328
 
321 329
 	// nothing to read, nothing to do
322
-	if (empty($id_draft))
323
-		return false;
330
+	if (empty($id_draft)) {
331
+			return false;
332
+	}
324 333
 
325 334
 	// load in this draft from the DB
326 335
 	$request = $smcFunc['db_query']('', '
@@ -340,8 +349,9 @@  discard block
 block discarded – undo
340 349
 	);
341 350
 
342 351
 	// no results?
343
-	if (!$smcFunc['db_num_rows']($request))
344
-		return false;
352
+	if (!$smcFunc['db_num_rows']($request)) {
353
+			return false;
354
+	}
345 355
 
346 356
 	// load up the data
347 357
 	$draft_info = $smcFunc['db_fetch_assoc']($request);
@@ -362,8 +372,7 @@  discard block
 block discarded – undo
362 372
 			$context['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : '';
363 373
 			$context['board'] = !empty($draft_info['board_id']) ? $draft_info['id_board'] : '';
364 374
 			$context['id_draft'] = !empty($draft_info['id_draft']) ? $draft_info['id_draft'] : 0;
365
-		}
366
-		elseif ($type === 1)
375
+		} elseif ($type === 1)
367 376
 		{
368 377
 			// one of those pm drafts? then set it up like we have an error
369 378
 			$_REQUEST['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : '';
@@ -399,12 +408,14 @@  discard block
 block discarded – undo
399 408
 	global $user_info, $smcFunc;
400 409
 
401 410
 	// Only a single draft.
402
-	if (is_numeric($id_draft))
403
-		$id_draft = array($id_draft);
411
+	if (is_numeric($id_draft)) {
412
+			$id_draft = array($id_draft);
413
+	}
404 414
 
405 415
 	// can't delete nothing
406
-	if (empty($id_draft) || ($check && empty($user_info['id'])))
407
-		return false;
416
+	if (empty($id_draft) || ($check && empty($user_info['id']))) {
417
+			return false;
418
+	}
408 419
 
409 420
 	$smcFunc['db_query']('', '
410 421
 		DELETE FROM {db_prefix}user_drafts
@@ -433,14 +444,16 @@  discard block
 block discarded – undo
433 444
 	global $smcFunc, $scripturl, $context, $txt, $modSettings;
434 445
 
435 446
 	// Permissions
436
-	if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id))
437
-		return false;
447
+	if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) {
448
+			return false;
449
+	}
438 450
 
439 451
 	$context['drafts'] = array();
440 452
 
441 453
 	// has a specific draft has been selected?  Load it up if there is not a message already in the editor
442
-	if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message']))
443
-		ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true);
454
+	if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) {
455
+			ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true);
456
+	}
444 457
 
445 458
 	// load the drafts this user has available
446 459
 	$request = $smcFunc['db_query']('', '
@@ -463,23 +476,26 @@  discard block
 block discarded – undo
463 476
 	// add them to the draft array for display
464 477
 	while ($row = $smcFunc['db_fetch_assoc']($request))
465 478
 	{
466
-		if (empty($row['subject']))
467
-			$row['subject'] = $txt['no_subject'];
479
+		if (empty($row['subject'])) {
480
+					$row['subject'] = $txt['no_subject'];
481
+		}
468 482
 
469 483
 		// Post drafts
470
-		if ($draft_type === 0)
471
-			$context['drafts'][] = array(
484
+		if ($draft_type === 0) {
485
+					$context['drafts'][] = array(
472 486
 				'subject' => censorText(shorten_subject(stripslashes($row['subject']), 24)),
473 487
 				'poster_time' => timeformat($row['poster_time']),
474 488
 				'link' => '<a href="' . $scripturl . '?action=post;board=' . $row['id_board'] . ';' . (!empty($row['id_topic']) ? 'topic='. $row['id_topic'] .'.0;' : '') . 'id_draft=' . $row['id_draft'] . '">' . $row['subject'] . '</a>',
475 489
 			);
490
+		}
476 491
 		// PM drafts
477
-		elseif ($draft_type === 1)
478
-			$context['drafts'][] = array(
492
+		elseif ($draft_type === 1) {
493
+					$context['drafts'][] = array(
479 494
 				'subject' => censorText(shorten_subject(stripslashes($row['subject']), 24)),
480 495
 				'poster_time' => timeformat($row['poster_time']),
481 496
 				'link' => '<a href="' . $scripturl . '?action=pm;sa=send;id_draft=' . $row['id_draft'] . '">' . (!empty($row['subject']) ? $row['subject'] : $txt['drafts_none']) . '</a>',
482 497
 			);
498
+		}
483 499
 	}
484 500
 	$smcFunc['db_free_result']($request);
485 501
 }
@@ -543,8 +559,9 @@  discard block
 block discarded – undo
543 559
 	}
544 560
 
545 561
 	// Default to 10.
546
-	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
547
-		$_REQUEST['viewscount'] = 10;
562
+	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) {
563
+			$_REQUEST['viewscount'] = 10;
564
+	}
548 565
 
549 566
 	// Get the count of applicable drafts on the boards they can (still) see ...
550 567
 	// @todo .. should we just let them see their drafts even if they have lost board access ?
@@ -609,12 +626,14 @@  discard block
 block discarded – undo
609 626
 	while ($row = $smcFunc['db_fetch_assoc']($request))
610 627
 	{
611 628
 		// Censor....
612
-		if (empty($row['body']))
613
-			$row['body'] = '';
629
+		if (empty($row['body'])) {
630
+					$row['body'] = '';
631
+		}
614 632
 
615 633
 		$row['subject'] = $smcFunc['htmltrim']($row['subject']);
616
-		if (empty($row['subject']))
617
-			$row['subject'] = $txt['no_subject'];
634
+		if (empty($row['subject'])) {
635
+					$row['subject'] = $txt['no_subject'];
636
+		}
618 637
 
619 638
 		censorText($row['body']);
620 639
 		censorText($row['subject']);
@@ -646,8 +665,9 @@  discard block
 block discarded – undo
646 665
 	$smcFunc['db_free_result']($request);
647 666
 
648 667
 	// If the drafts were retrieved in reverse order, get them right again.
649
-	if ($reverse)
650
-		$context['drafts'] = array_reverse($context['drafts'], true);
668
+	if ($reverse) {
669
+			$context['drafts'] = array_reverse($context['drafts'], true);
670
+	}
651 671
 
652 672
 	// Menu tab
653 673
 	$context[$context['profile_menu_name']]['tab_data'] = array(
@@ -705,8 +725,9 @@  discard block
 block discarded – undo
705 725
 	}
706 726
 
707 727
 	// Default to 10.
708
-	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
709
-		$_REQUEST['viewscount'] = 10;
728
+	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) {
729
+			$_REQUEST['viewscount'] = 10;
730
+	}
710 731
 
711 732
 	// Get the count of applicable drafts
712 733
 	$request = $smcFunc['db_query']('', '
@@ -765,12 +786,14 @@  discard block
 block discarded – undo
765 786
 	while ($row = $smcFunc['db_fetch_assoc']($request))
766 787
 	{
767 788
 		// Censor....
768
-		if (empty($row['body']))
769
-			$row['body'] = '';
789
+		if (empty($row['body'])) {
790
+					$row['body'] = '';
791
+		}
770 792
 
771 793
 		$row['subject'] = $smcFunc['htmltrim']($row['subject']);
772
-		if (empty($row['subject']))
773
-			$row['subject'] = $txt['no_subject'];
794
+		if (empty($row['subject'])) {
795
+					$row['subject'] = $txt['no_subject'];
796
+		}
774 797
 
775 798
 		censorText($row['body']);
776 799
 		censorText($row['subject']);
@@ -825,8 +848,9 @@  discard block
 block discarded – undo
825 848
 	$smcFunc['db_free_result']($request);
826 849
 
827 850
 	// if the drafts were retrieved in reverse order, then put them in the right order again.
828
-	if ($reverse)
829
-		$context['drafts'] = array_reverse($context['drafts'], true);
851
+	if ($reverse) {
852
+			$context['drafts'] = array_reverse($context['drafts'], true);
853
+	}
830 854
 
831 855
 	// off to the template we go
832 856
 	$context['page_title'] = $txt['drafts'];
Please login to merge, or discard this patch.