Completed
Push — release-2.1 ( 2ca19b...643a63 )
by Mathias
08:07
created
Sources/CacheAPI-memcache.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
 			$server = trim($servers[array_rand($servers)]);
62 62
 
63 63
 			// Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0.
64
-			if (strpos($server,'/') !== false)
64
+			if (strpos($server, '/') !== false)
65 65
 				$host = $server;
66 66
 			else
67 67
 			{
Please login to merge, or discard this patch.
Braces   +19 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 3
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * Our Cache API class
@@ -34,8 +35,9 @@  discard block
 block discarded – undo
34 35
 
35 36
 		$supported = class_exists('memcache');
36 37
 
37
-		if ($test)
38
-			return $supported;
38
+		if ($test) {
39
+					return $supported;
40
+		}
39 41
 		return parent::isSupported() && $supported && !empty($cache_memcached);
40 42
 	}
41 43
 
@@ -61,9 +63,9 @@  discard block
 block discarded – undo
61 63
 			$server = trim($servers[array_rand($servers)]);
62 64
 
63 65
 			// Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0.
64
-			if (strpos($server,'/') !== false)
65
-				$host = $server;
66
-			else
66
+			if (strpos($server,'/') !== false) {
67
+							$host = $server;
68
+			} else
67 69
 			{
68 70
 				$server = explode(':', $server);
69 71
 				$host = $server[0];
@@ -71,10 +73,11 @@  discard block
 block discarded – undo
71 73
 			}
72 74
 
73 75
 			// Don't wait too long: yes, we want the server, but we might be able to run the query faster!
74
-			if (empty($db_persist))
75
-				$connected = $this->memcache->connect($host, $port);
76
-			else
77
-				$connected = $this->memcache->pconnect($host, $port);
76
+			if (empty($db_persist)) {
77
+							$connected = $this->memcache->connect($host, $port);
78
+			} else {
79
+							$connected = $this->memcache->pconnect($host, $port);
80
+			}
78 81
 		}
79 82
 
80 83
 		return $connected;
@@ -90,8 +93,9 @@  discard block
 block discarded – undo
90 93
 		$value = $this->memcache->get($key);
91 94
 
92 95
 		// $value should return either data or false (from failure, key not found or empty array).
93
-		if ($value === false)
94
-			return null;
96
+		if ($value === false) {
97
+					return null;
98
+		}
95 99
 		return $value;
96 100
 	}
97 101
 
@@ -132,8 +136,9 @@  discard block
 block discarded – undo
132 136
 		$config_vars[] = $txt['cache_memcache_settings'];
133 137
 		$config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br /><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>');
134 138
 
135
-		if (!isset($context['settings_post_javascript']))
136
-			$context['settings_post_javascript'] = '';
139
+		if (!isset($context['settings_post_javascript'])) {
140
+					$context['settings_post_javascript'] = '';
141
+		}
137 142
 
138 143
 		$context['settings_post_javascript'] .= '
139 144
 			$("#cache_accelerator").change(function (e) {
Please login to merge, or discard this patch.
Sources/PackageGet.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -181,14 +181,14 @@  discard block
 block discarded – undo
181 181
 		{
182 182
 			collapsedDiv.show(\'slow\');
183 183
 			icon.removeClass(\'toggle_down\').addClass(\'toggle_up\');
184
-			icon.prop(\'title\', '. JavaScriptEscape($txt['hide']) .');
184
+			icon.prop(\'title\', '. JavaScriptEscape($txt['hide']) . ');
185 185
 		}
186 186
 
187 187
 		else
188 188
 		{
189 189
 			collapsedDiv.hide(\'slow\');
190 190
 			icon.removeClass(\'toggle_up\').addClass(\'toggle_down\');
191
-			icon.prop(\'title\', '. JavaScriptEscape($txt['show']) .');
191
+			icon.prop(\'title\', '. JavaScriptEscape($txt['show']) . ');
192 192
 		}
193 193
 
194 194
 	});', true);
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 
642 642
 	// Setup the correct template, even though I'll admit we ain't downloading ;)
643 643
 	$context['sub_template'] = 'downloaded';
644
-	$allowext = array('.zip','.tgz','.gz');
644
+	$allowext = array('.zip', '.tgz', '.gz');
645 645
 	// @todo Use FTP if the Packages directory is not writable.
646 646
 
647 647
 	// Check the file was even sent!
@@ -653,13 +653,13 @@  discard block
 block discarded – undo
653 653
 	// Make sure it has a sane filename.
654 654
 	$_FILES['package']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['package']['name']);
655 655
 	$extension = substr(strrchr(strtolower($_FILES['package']['name']), '.'), 0);
656
-	if(!in_array($extension, $allowext))
656
+	if (!in_array($extension, $allowext))
657 657
 	{
658 658
 		fatal_lang_error('package_upload_error_supports', false, array('zip, tgz, tar.gz'));
659 659
 	}
660 660
 	
661 661
 	// We only need the filename...
662
-	$extension = ($extension == '.gz') ? '.tar.gz' : $extension ;
662
+	$extension = ($extension == '.gz') ? '.tar.gz' : $extension;
663 663
 	$packageName = time() . $extension;
664 664
 
665 665
 	// Setup the destination and throw an error if the file is already there!
Please login to merge, or discard this patch.
Braces   +197 added lines, -154 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
  * Browse the list of package servers, add servers...
@@ -43,13 +44,15 @@  discard block
 block discarded – undo
43 44
 	);
44 45
 
45 46
 	// Now let's decide where we are taking this...
46
-	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]))
47
-		$context['sub_action'] = $_REQUEST['sa'];
47
+	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
48
+			$context['sub_action'] = $_REQUEST['sa'];
49
+	}
48 50
 	// We need to support possible old javascript links...
49
-	elseif (isset($_GET['pgdownload']))
50
-		$context['sub_action'] = 'download';
51
-	else
52
-		$context['sub_action'] = 'servers';
51
+	elseif (isset($_GET['pgdownload'])) {
52
+			$context['sub_action'] = 'download';
53
+	} else {
54
+			$context['sub_action'] = 'servers';
55
+	}
53 56
 
54 57
 	// We need to force the "Download" tab as selected.
55 58
 	$context['menu_data_' . $context['admin_menu_id']]['current_subsection'] = 'packageget';
@@ -141,17 +144,19 @@  discard block
 block discarded – undo
141 144
 			{
142 145
 				require_once($sourcedir . '/Class-Package.php');
143 146
 				$ftp = new ftp_connection(null);
147
+			} elseif ($ftp->error !== false && !isset($ftp_error)) {
148
+							$ftp_error = $ftp->last_message === null ? '' : $ftp->last_message;
144 149
 			}
145
-			elseif ($ftp->error !== false && !isset($ftp_error))
146
-				$ftp_error = $ftp->last_message === null ? '' : $ftp->last_message;
147 150
 
148 151
 			list ($username, $detect_path, $found_path) = $ftp->detect_path($packagesdir);
149 152
 
150
-			if ($found_path || !isset($_POST['ftp_path']))
151
-				$_POST['ftp_path'] = $detect_path;
153
+			if ($found_path || !isset($_POST['ftp_path'])) {
154
+							$_POST['ftp_path'] = $detect_path;
155
+			}
152 156
 
153
-			if (!isset($_POST['ftp_username']))
154
-				$_POST['ftp_username'] = $username;
157
+			if (!isset($_POST['ftp_username'])) {
158
+							$_POST['ftp_username'] = $username;
159
+			}
155 160
 
156 161
 			$context['package_ftp'] = array(
157 162
 				'server' => isset($_POST['ftp_server']) ? $_POST['ftp_server'] : (isset($modSettings['package_server']) ? $modSettings['package_server'] : 'localhost'),
@@ -160,8 +165,7 @@  discard block
 block discarded – undo
160 165
 				'path' => $_POST['ftp_path'],
161 166
 				'error' => empty($ftp_error) ? null : $ftp_error,
162 167
 			);
163
-		}
164
-		else
168
+		} else
165 169
 		{
166 170
 			$context['package_download_broken'] = false;
167 171
 
@@ -203,8 +207,9 @@  discard block
 block discarded – undo
203 207
 
204 208
 	if (isset($_GET['server']))
205 209
 	{
206
-		if ($_GET['server'] == '')
207
-			redirectexit('action=admin;area=packages;get');
210
+		if ($_GET['server'] == '') {
211
+					redirectexit('action=admin;area=packages;get');
212
+		}
208 213
 
209 214
 		$server = (int) $_GET['server'];
210 215
 
@@ -222,17 +227,18 @@  discard block
 block discarded – undo
222 227
 		$smcFunc['db_free_result']($request);
223 228
 
224 229
 		// If the server does not exist, dump out.
225
-		if (empty($url))
226
-			fatal_lang_error('couldnt_connect', false);
230
+		if (empty($url)) {
231
+					fatal_lang_error('couldnt_connect', false);
232
+		}
227 233
 
228 234
 		// If there is a relative link, append to the stored server url.
229
-		if (isset($_GET['relative']))
230
-			$url = $url . (substr($url, -1) == '/' ? '' : '/') . $_GET['relative'];
235
+		if (isset($_GET['relative'])) {
236
+					$url = $url . (substr($url, -1) == '/' ? '' : '/') . $_GET['relative'];
237
+		}
231 238
 
232 239
 		// Clear any "absolute" URL.  Since "server" is present, "absolute" is garbage.
233 240
 		unset($_GET['absolute']);
234
-	}
235
-	elseif (isset($_GET['absolute']) && $_GET['absolute'] != '')
241
+	} elseif (isset($_GET['absolute']) && $_GET['absolute'] != '')
236 242
 	{
237 243
 		// Initialize the requried variables.
238 244
 		$server = '';
@@ -256,16 +262,19 @@  discard block
 block discarded – undo
256 262
 		}
257 263
 	}
258 264
 	// Minimum required parameter did not exist so dump out.
259
-	else
260
-		fatal_lang_error('couldnt_connect', false);
265
+	else {
266
+			fatal_lang_error('couldnt_connect', false);
267
+	}
261 268
 
262 269
 	// Attempt to connect.  If unsuccessful... try the URL.
263
-	if (!isset($_GET['package']) || file_exists($_GET['package']))
264
-		$_GET['package'] = $url . '/packages.xml?language=' . $context['user']['language'];
270
+	if (!isset($_GET['package']) || file_exists($_GET['package'])) {
271
+			$_GET['package'] = $url . '/packages.xml?language=' . $context['user']['language'];
272
+	}
265 273
 
266 274
 	// Check to be sure the packages.xml file actually exists where it is should be... or dump out.
267
-	if ((isset($_GET['absolute']) || isset($_GET['relative'])) && !url_exists($_GET['package']))
268
-		fatal_lang_error('packageget_unable', false, array($url . '/index.php'));
275
+	if ((isset($_GET['absolute']) || isset($_GET['relative'])) && !url_exists($_GET['package'])) {
276
+			fatal_lang_error('packageget_unable', false, array($url . '/index.php'));
277
+	}
269 278
 
270 279
 	// Might take some time.
271 280
 	@set_time_limit(600);
@@ -275,8 +284,9 @@  discard block
 block discarded – undo
275 284
 	$listing = new xmlArray(fetch_web_data($_GET['package']), true);
276 285
 
277 286
 	// Errm.... empty file?  Try the URL....
278
-	if (!$listing->exists('package-list'))
279
-		fatal_lang_error('packageget_unable', false, array($url . '/index.php'));
287
+	if (!$listing->exists('package-list')) {
288
+			fatal_lang_error('packageget_unable', false, array($url . '/index.php'));
289
+	}
280 290
 
281 291
 	// List out the packages...
282 292
 	$context['package_list'] = array();
@@ -284,8 +294,9 @@  discard block
 block discarded – undo
284 294
 	$listing = $listing->path('package-list[0]');
285 295
 
286 296
 	// Use the package list's name if it exists.
287
-	if ($listing->exists('list-title'))
288
-		$name = $smcFunc['htmlspecialchars']($listing->fetch('list-title'));
297
+	if ($listing->exists('list-title')) {
298
+			$name = $smcFunc['htmlspecialchars']($listing->fetch('list-title'));
299
+	}
289 300
 
290 301
 	// Pick the correct template.
291 302
 	$context['sub_template'] = 'package_list';
@@ -300,28 +311,32 @@  discard block
 block discarded – undo
300 311
 
301 312
 	$installed_mods = array();
302 313
 	// Look through the list of installed mods...
303
-	foreach ($instmods as $installed_mod)
304
-		$installed_mods[$installed_mod['package_id']] = $installed_mod['version'];
314
+	foreach ($instmods as $installed_mod) {
315
+			$installed_mods[$installed_mod['package_id']] = $installed_mod['version'];
316
+	}
305 317
 
306 318
 	// Get default author and email if they exist.
307 319
 	if ($listing->exists('default-author'))
308 320
 	{
309 321
 		$default_author = $smcFunc['htmlspecialchars']($listing->fetch('default-author'));
310
-		if ($listing->exists('default-author/@email') && filter_var($listing->fetch('default-author/@email'), FILTER_VALIDATE_EMAIL))
311
-			$default_email = $smcFunc['htmlspecialchars']($listing->fetch('default-author/@email'));
322
+		if ($listing->exists('default-author/@email') && filter_var($listing->fetch('default-author/@email'), FILTER_VALIDATE_EMAIL)) {
323
+					$default_email = $smcFunc['htmlspecialchars']($listing->fetch('default-author/@email'));
324
+		}
312 325
 	}
313 326
 
314 327
 	// Get default web site if it exists.
315 328
 	if ($listing->exists('default-website'))
316 329
 	{
317 330
 		$default_website = $smcFunc['htmlspecialchars']($listing->fetch('default-website'));
318
-		if ($listing->exists('default-website/@title'))
319
-			$default_title = $smcFunc['htmlspecialchars']($listing->fetch('default-website/@title'));
331
+		if ($listing->exists('default-website/@title')) {
332
+					$default_title = $smcFunc['htmlspecialchars']($listing->fetch('default-website/@title'));
333
+		}
320 334
 	}
321 335
 
322 336
 	$the_version = strtr($forum_version, array('SMF ' => ''));
323
-	if (!empty($_SESSION['version_emulate']))
324
-		$the_version = $_SESSION['version_emulate'];
337
+	if (!empty($_SESSION['version_emulate'])) {
338
+			$the_version = $_SESSION['version_emulate'];
339
+	}
325 340
 
326 341
 	$packageNum = 0;
327 342
 	$packageSection = 0;
@@ -342,11 +357,13 @@  discard block
 block discarded – undo
342 357
 				'type' => $thisPackage->name(),
343 358
 			);
344 359
 
345
-			if (in_array($package['type'], array('title', 'text')))
346
-				$context['package_list'][$packageSection][$package['type']] = $smcFunc['htmlspecialchars']($thisPackage->fetch('.'));
360
+			if (in_array($package['type'], array('title', 'text'))) {
361
+							$context['package_list'][$packageSection][$package['type']] = $smcFunc['htmlspecialchars']($thisPackage->fetch('.'));
362
+			}
347 363
 			// It's a Title, Heading, Rule or Text.
348
-			elseif (in_array($package['type'], array('heading', 'rule')))
349
-				$package['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('.'));
364
+			elseif (in_array($package['type'], array('heading', 'rule'))) {
365
+							$package['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('.'));
366
+			}
350 367
 			// It's a Remote link.
351 368
 			elseif ($package['type'] == 'remote')
352 369
 			{
@@ -354,20 +371,21 @@  discard block
 block discarded – undo
354 371
 
355 372
 				if ($remote_type == 'relative' && substr($thisPackage->fetch('@href'), 0, 7) != 'http://' && substr($thisPackage->fetch('@href'), 0, 8) != 'https://')
356 373
 				{
357
-					if (isset($_GET['absolute']))
358
-						$current_url = $_GET['absolute'] . '/';
359
-					elseif (isset($_GET['relative']))
360
-						$current_url = $_GET['relative'] . '/';
361
-					else
362
-						$current_url = '';
374
+					if (isset($_GET['absolute'])) {
375
+											$current_url = $_GET['absolute'] . '/';
376
+					} elseif (isset($_GET['relative'])) {
377
+											$current_url = $_GET['relative'] . '/';
378
+					} else {
379
+											$current_url = '';
380
+					}
363 381
 
364 382
 					$current_url .= $thisPackage->fetch('@href');
365
-					if (isset($_GET['absolute']))
366
-						$package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;absolute=' . $current_url;
367
-					else
368
-						$package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $context['package_server'] . ';relative=' . $current_url;
369
-				}
370
-				else
383
+					if (isset($_GET['absolute'])) {
384
+											$package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;absolute=' . $current_url;
385
+					} else {
386
+											$package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $context['package_server'] . ';relative=' . $current_url;
387
+					}
388
+				} else
371 389
 				{
372 390
 					$current_url = $thisPackage->fetch('@href');
373 391
 					$package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;absolute=' . $current_url;
@@ -379,25 +397,28 @@  discard block
 block discarded – undo
379 397
 			// It's a package...
380 398
 			else
381 399
 			{
382
-				if (isset($_GET['absolute']))
383
-					$current_url = $_GET['absolute'] . '/';
384
-				elseif (isset($_GET['relative']))
385
-					$current_url = $_GET['relative'] . '/';
386
-				else
387
-					$current_url = '';
400
+				if (isset($_GET['absolute'])) {
401
+									$current_url = $_GET['absolute'] . '/';
402
+				} elseif (isset($_GET['relative'])) {
403
+									$current_url = $_GET['relative'] . '/';
404
+				} else {
405
+									$current_url = '';
406
+				}
388 407
 
389 408
 				$server_att = $server != '' ? ';server=' . $server : '';
390 409
 
391 410
 				$package += $thisPackage->to_array();
392 411
 
393
-				if (isset($package['website']))
394
-					unset($package['website']);
412
+				if (isset($package['website'])) {
413
+									unset($package['website']);
414
+				}
395 415
 				$package['author'] = array();
396 416
 
397
-				if ($package['description'] == '')
398
-					$package['description'] = $txt['package_no_description'];
399
-				else
400
-					$package['description'] = parse_bbc(preg_replace('~\[[/]?html\]~i', '', $smcFunc['htmlspecialchars']($package['description'])));
417
+				if ($package['description'] == '') {
418
+									$package['description'] = $txt['package_no_description'];
419
+				} else {
420
+									$package['description'] = parse_bbc(preg_replace('~\[[/]?html\]~i', '', $smcFunc['htmlspecialchars']($package['description'])));
421
+				}
401 422
 
402 423
 				$package['is_installed'] = isset($installed_mods[$package['id']]);
403 424
 				$package['is_current'] = $package['is_installed'] && ($installed_mods[$package['id']] == $package['version']);
@@ -406,12 +427,14 @@  discard block
 block discarded – undo
406 427
 				// This package is either not installed, or installed but old.  Is it supported on this version of SMF?
407 428
 				if (!$package['is_installed'] || (!$package['is_current'] && !$package['is_newer']))
408 429
 				{
409
-					if ($thisPackage->exists('version/@for'))
410
-						$package['can_install'] = matchPackageVersion($the_version, $thisPackage->fetch('version/@for'));
430
+					if ($thisPackage->exists('version/@for')) {
431
+											$package['can_install'] = matchPackageVersion($the_version, $thisPackage->fetch('version/@for'));
432
+					}
411 433
 				}
412 434
 				// Okay, it's already installed AND up to date.
413
-				else
414
-					$package['can_install'] = false;
435
+				else {
436
+									$package['can_install'] = false;
437
+				}
415 438
 
416 439
 				$already_exists = getPackageInfo(basename($package['filename']));
417 440
 				$package['download_conflict'] = is_array($already_exists) && $already_exists['id'] == $package['id'] && $already_exists['version'] != $package['version'];
@@ -423,40 +446,44 @@  discard block
 block discarded – undo
423 446
 
424 447
 				if ($thisPackage->exists('author') || isset($default_author))
425 448
 				{
426
-					if ($thisPackage->exists('author/@email') && filter_var($thisPackage->fetch('author/@email'), FILTER_VALIDATE_EMAIL))
427
-						$package['author']['email'] = $thisPackage->fetch('author/@email');
428
-					elseif (isset($default_email))
429
-						$package['author']['email'] = $default_email;
430
-
431
-					if ($thisPackage->exists('author') && $thisPackage->fetch('author') != '')
432
-						$package['author']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('author'));
433
-					else
434
-						$package['author']['name'] = $default_author;
435
-
436
-					if (!empty($package['author']['email']))
437
-						$package['author']['link'] = '<a href="mailto:' . $package['author']['email'] . '">' . $package['author']['name'] . '</a>';
449
+					if ($thisPackage->exists('author/@email') && filter_var($thisPackage->fetch('author/@email'), FILTER_VALIDATE_EMAIL)) {
450
+											$package['author']['email'] = $thisPackage->fetch('author/@email');
451
+					} elseif (isset($default_email)) {
452
+											$package['author']['email'] = $default_email;
453
+					}
454
+
455
+					if ($thisPackage->exists('author') && $thisPackage->fetch('author') != '') {
456
+											$package['author']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('author'));
457
+					} else {
458
+											$package['author']['name'] = $default_author;
459
+					}
460
+
461
+					if (!empty($package['author']['email'])) {
462
+											$package['author']['link'] = '<a href="mailto:' . $package['author']['email'] . '">' . $package['author']['name'] . '</a>';
463
+					}
438 464
 				}
439 465
 
440 466
 				if ($thisPackage->exists('website') || isset($default_website))
441 467
 				{
442
-					if ($thisPackage->exists('website') && $thisPackage->exists('website/@title'))
443
-						$package['author']['website']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('website/@title'));
444
-					elseif (isset($default_title))
445
-						$package['author']['website']['name'] = $default_title;
446
-					elseif ($thisPackage->exists('website'))
447
-						$package['author']['website']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('website'));
448
-					else
449
-						$package['author']['website']['name'] = $default_website;
450
-
451
-					if ($thisPackage->exists('website') && $thisPackage->fetch('website') != '')
452
-						$authorhompage = $smcFunc['htmlspecialchars']($thisPackage->fetch('website'));
453
-					else
454
-						$authorhompage = $default_website;
468
+					if ($thisPackage->exists('website') && $thisPackage->exists('website/@title')) {
469
+											$package['author']['website']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('website/@title'));
470
+					} elseif (isset($default_title)) {
471
+											$package['author']['website']['name'] = $default_title;
472
+					} elseif ($thisPackage->exists('website')) {
473
+											$package['author']['website']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('website'));
474
+					} else {
475
+											$package['author']['website']['name'] = $default_website;
476
+					}
477
+
478
+					if ($thisPackage->exists('website') && $thisPackage->fetch('website') != '') {
479
+											$authorhompage = $smcFunc['htmlspecialchars']($thisPackage->fetch('website'));
480
+					} else {
481
+											$authorhompage = $default_website;
482
+					}
455 483
 
456 484
 					$package['author']['website']['href'] = $authorhompage;
457 485
 					$package['author']['website']['link'] = '<a href="' . $authorhompage . '">' . $package['author']['website']['name'] . '</a>';
458
-				}
459
-				else
486
+				} else
460 487
 				{
461 488
 					$package['author']['website']['href'] = '';
462 489
 					$package['author']['website']['link'] = '';
@@ -472,11 +499,13 @@  discard block
 block discarded – undo
472 499
 			$packageNum = in_array($package['type'], array('title', 'heading', 'text', 'remote', 'rule')) ? 0 : $packageNum + 1;
473 500
 			$package['count'] = $packageNum;
474 501
 
475
-			if (!in_array($package['type'], array('title', 'text')))
476
-				$context['package_list'][$packageSection]['items'][] = $package;
502
+			if (!in_array($package['type'], array('title', 'text'))) {
503
+							$context['package_list'][$packageSection]['items'][] = $package;
504
+			}
477 505
 
478
-			if ($package['count'] > 1)
479
-				$context['list_type'] = 'ol';
506
+			if ($package['count'] > 1) {
507
+							$context['list_type'] = 'ol';
508
+			}
480 509
 		}
481 510
 
482 511
 		$packageSection++;
@@ -489,8 +518,9 @@  discard block
 block discarded – undo
489 518
 	{
490 519
 		foreach ($packageSection['items'] as $i => $package)
491 520
 		{
492
-			if ($package['count'] == 0 || isset($package['can_install']))
493
-				continue;
521
+			if ($package['count'] == 0 || isset($package['can_install'])) {
522
+							continue;
523
+			}
494 524
 
495 525
 			$context['package_list'][$ps_id]['items'][$i]['can_install'] = false;
496 526
 
@@ -539,8 +569,9 @@  discard block
 block discarded – undo
539 569
 	checkSession('get');
540 570
 
541 571
 	// To download something, we need a valid server or url.
542
-	if (empty($_GET['server']) && (!empty($_GET['get']) && !empty($_REQUEST['package'])))
543
-		fatal_lang_error('package_get_error_is_zero', false);
572
+	if (empty($_GET['server']) && (!empty($_GET['get']) && !empty($_REQUEST['package']))) {
573
+			fatal_lang_error('package_get_error_is_zero', false);
574
+	}
544 575
 
545 576
 	if (isset($_GET['server']))
546 577
 	{
@@ -560,22 +591,23 @@  discard block
 block discarded – undo
560 591
 		$smcFunc['db_free_result']($request);
561 592
 
562 593
 		// If server does not exist then dump out.
563
-		if (empty($url))
564
-			fatal_lang_error('couldnt_connect', false);
594
+		if (empty($url)) {
595
+					fatal_lang_error('couldnt_connect', false);
596
+		}
565 597
 
566 598
 		$url = $url . '/';
567
-	}
568
-	else
599
+	} else
569 600
 	{
570 601
 		// Initialize the requried variables.
571 602
 		$server = '';
572 603
 		$url = '';
573 604
 	}
574 605
 
575
-	if (isset($_REQUEST['byurl']) && !empty($_POST['filename']))
576
-		$package_name = basename($_REQUEST['filename']);
577
-	else
578
-		$package_name = basename($_REQUEST['package']);
606
+	if (isset($_REQUEST['byurl']) && !empty($_POST['filename'])) {
607
+			$package_name = basename($_REQUEST['filename']);
608
+	} else {
609
+			$package_name = basename($_REQUEST['package']);
610
+	}
579 611
 
580 612
 	if (isset($_REQUEST['conflict']) || (isset($_REQUEST['auto']) && file_exists($packagesdir . '/' . $package_name)))
581 613
 	{
@@ -584,14 +616,15 @@  discard block
 block discarded – undo
584 616
 		{
585 617
 			$ext = substr($package_name, strrpos(substr($package_name, 0, -3), '.'));
586 618
 			$package_name = substr($package_name, 0, strrpos(substr($package_name, 0, -3), '.')) . '_';
619
+		} else {
620
+					$ext = '';
587 621
 		}
588
-		else
589
-			$ext = '';
590 622
 
591 623
 		// Find the first available.
592 624
 		$i = 1;
593
-		while (file_exists($packagesdir . '/' . $package_name . $i . $ext))
594
-			$i++;
625
+		while (file_exists($packagesdir . '/' . $package_name . $i . $ext)) {
626
+					$i++;
627
+		}
595 628
 
596 629
 		$package_name = $package_name . $i . $ext;
597 630
 	}
@@ -601,25 +634,28 @@  discard block
 block discarded – undo
601 634
 	package_put_contents($packagesdir . '/' . $package_name, fetch_web_data($url . $_REQUEST['package']));
602 635
 
603 636
 	// Done!  Did we get this package automatically?
604
-	if (preg_match('~^http://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['package']) == 1 && strpos($_REQUEST['package'], 'dlattach') === false && isset($_REQUEST['auto']))
605
-		redirectexit('action=admin;area=packages;sa=install;package=' . $package_name);
637
+	if (preg_match('~^http://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['package']) == 1 && strpos($_REQUEST['package'], 'dlattach') === false && isset($_REQUEST['auto'])) {
638
+			redirectexit('action=admin;area=packages;sa=install;package=' . $package_name);
639
+	}
606 640
 
607 641
 	// You just downloaded a mod from SERVER_NAME_GOES_HERE.
608 642
 	$context['package_server'] = $server;
609 643
 
610 644
 	$context['package'] = getPackageInfo($package_name);
611 645
 
612
-	if (!is_array($context['package']))
613
-		fatal_lang_error('package_cant_download', false);
646
+	if (!is_array($context['package'])) {
647
+			fatal_lang_error('package_cant_download', false);
648
+	}
614 649
 
615
-	if ($context['package']['type'] == 'modification')
616
-		$context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['install_mod'] . ' ]</a>';
617
-	elseif ($context['package']['type'] == 'avatar')
618
-		$context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['use_avatars'] . ' ]</a>';
619
-	elseif ($context['package']['type'] == 'language')
620
-		$context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['add_languages'] . ' ]</a>';
621
-	else
622
-		$context['package']['install']['link'] = '';
650
+	if ($context['package']['type'] == 'modification') {
651
+			$context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['install_mod'] . ' ]</a>';
652
+	} elseif ($context['package']['type'] == 'avatar') {
653
+			$context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['use_avatars'] . ' ]</a>';
654
+	} elseif ($context['package']['type'] == 'language') {
655
+			$context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['add_languages'] . ' ]</a>';
656
+	} else {
657
+			$context['package']['install']['link'] = '';
658
+	}
623 659
 
624 660
 	// Does a 3rd party hook want to do some additional changes?
625 661
 	call_integration_hook('integrate_package_download');
@@ -645,10 +681,11 @@  discard block
 block discarded – undo
645 681
 	// @todo Use FTP if the Packages directory is not writable.
646 682
 
647 683
 	// Check the file was even sent!
648
-	if (!isset($_FILES['package']['name']) || $_FILES['package']['name'] == '')
649
-		fatal_lang_error('package_upload_error_nofile');
650
-	elseif (!is_uploaded_file($_FILES['package']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['package']['tmp_name'])))
651
-		fatal_lang_error('package_upload_error_failed');
684
+	if (!isset($_FILES['package']['name']) || $_FILES['package']['name'] == '') {
685
+			fatal_lang_error('package_upload_error_nofile');
686
+	} elseif (!is_uploaded_file($_FILES['package']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['package']['tmp_name']))) {
687
+			fatal_lang_error('package_upload_error_failed');
688
+	}
652 689
 
653 690
 	// Make sure it has a sane filename.
654 691
 	$_FILES['package']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['package']['name']);
@@ -665,8 +702,9 @@  discard block
 block discarded – undo
665 702
 	// Setup the destination and throw an error if the file is already there!
666 703
 	$destination = $packagesdir . '/' . $packageName;
667 704
 	// @todo Maybe just roll it like we do for downloads?
668
-	if (file_exists($destination))
669
-		fatal_lang_error('package_upload_error_exists');
705
+	if (file_exists($destination)) {
706
+			fatal_lang_error('package_upload_error_exists');
707
+	}
670 708
 
671 709
 	// Now move the file.
672 710
 	move_uploaded_file($_FILES['package']['tmp_name'], $destination);
@@ -689,12 +727,14 @@  discard block
 block discarded – undo
689 727
 	{
690 728
 		while ($package = readdir($dir))
691 729
 		{
692
-			if ($package == '.' || $package == '..' || $package == 'temp' || $package == $packageName || (!(is_dir($packagesdir . '/' . $package) && file_exists($packagesdir . '/' . $package . '/package-info.xml')) && substr(strtolower($package), -7) != '.tar.gz' && substr(strtolower($package), -4) != '.tgz' && substr(strtolower($package), -4) != '.zip'))
693
-				continue;
730
+			if ($package == '.' || $package == '..' || $package == 'temp' || $package == $packageName || (!(is_dir($packagesdir . '/' . $package) && file_exists($packagesdir . '/' . $package . '/package-info.xml')) && substr(strtolower($package), -7) != '.tar.gz' && substr(strtolower($package), -4) != '.tgz' && substr(strtolower($package), -4) != '.zip')) {
731
+							continue;
732
+			}
694 733
 
695 734
 			$packageInfo = getPackageInfo($package);
696
-			if (!is_array($packageInfo))
697
-				continue;
735
+			if (!is_array($packageInfo)) {
736
+							continue;
737
+			}
698 738
 
699 739
 			if ($packageInfo['id'] == $context['package']['id'] && $packageInfo['version'] == $context['package']['version'])
700 740
 			{
@@ -706,14 +746,15 @@  discard block
 block discarded – undo
706 746
 		closedir($dir);
707 747
 	}
708 748
 
709
-	if ($context['package']['type'] == 'modification')
710
-		$context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['install_mod'] . ' ]</a>';
711
-	elseif ($context['package']['type'] == 'avatar')
712
-		$context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['use_avatars'] . ' ]</a>';
713
-	elseif ($context['package']['type'] == 'language')
714
-		$context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['add_languages'] . ' ]</a>';
715
-	else
716
-		$context['package']['install']['link'] = '';
749
+	if ($context['package']['type'] == 'modification') {
750
+			$context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['install_mod'] . ' ]</a>';
751
+	} elseif ($context['package']['type'] == 'avatar') {
752
+			$context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['use_avatars'] . ' ]</a>';
753
+	} elseif ($context['package']['type'] == 'language') {
754
+			$context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['add_languages'] . ' ]</a>';
755
+	} else {
756
+			$context['package']['install']['link'] = '';
757
+	}
717 758
 
718 759
 	// Does a 3rd party hook want to do some additional changes?
719 760
 	call_integration_hook('integrate_package_upload');
@@ -736,16 +777,18 @@  discard block
 block discarded – undo
736 777
 	checkSession();
737 778
 
738 779
 	// If they put a slash on the end, get rid of it.
739
-	if (substr($_POST['serverurl'], -1) == '/')
740
-		$_POST['serverurl'] = substr($_POST['serverurl'], 0, -1);
780
+	if (substr($_POST['serverurl'], -1) == '/') {
781
+			$_POST['serverurl'] = substr($_POST['serverurl'], 0, -1);
782
+	}
741 783
 
742 784
 	// Are they both nice and clean?
743 785
 	$servername = trim($smcFunc['htmlspecialchars']($_POST['servername']));
744 786
 	$serverurl = trim($smcFunc['htmlspecialchars']($_POST['serverurl']));
745 787
 
746 788
 	// Make sure the URL has the correct prefix.
747
-	if (strpos($serverurl, 'http://') !== 0 && strpos($serverurl, 'https://') !== 0)
748
-		$serverurl = 'http://' . $serverurl;
789
+	if (strpos($serverurl, 'http://') !== 0 && strpos($serverurl, 'https://') !== 0) {
790
+			$serverurl = 'http://' . $serverurl;
791
+	}
749 792
 
750 793
 	$smcFunc['db_insert']('',
751 794
 		'{db_prefix}package_servers',
Please login to merge, or discard this patch.
Sources/Class-CacheAPI.php 1 patch
Braces   +13 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 3
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * Interface cache_api_interface
@@ -186,8 +187,9 @@  discard block
 block discarded – undo
186 187
 	{
187 188
 		global $cache_enable;
188 189
 
189
-		if ($test)
190
-			return true;
190
+		if ($test) {
191
+					return true;
192
+		}
191 193
 		return !empty($cache_enable);
192 194
 	}
193 195
 
@@ -206,10 +208,11 @@  discard block
 block discarded – undo
206 208
 		global $boardurl, $cachedir;
207 209
 
208 210
 		// Set the default if no prefix was specified.
209
-		if (empty($prefix))
210
-			$this->prefix = md5($boardurl . filemtime($cachedir . '/' . 'index.php')) . '-SMF-';
211
-		else
212
-			$this->prefix = $prefix;
211
+		if (empty($prefix)) {
212
+					$this->prefix = md5($boardurl . filemtime($cachedir . '/' . 'index.php')) . '-SMF-';
213
+		} else {
214
+					$this->prefix = $prefix;
215
+		}
213 216
 
214 217
 		return true;
215 218
 	}
@@ -272,8 +275,9 @@  discard block
 block discarded – undo
272 275
 
273 276
 		// Invalidate cache, to be sure!
274 277
 		// ... as long as index.php can be modified, anyway.
275
-		if (is_writable($cachedir . '/' . 'index.php'))
276
-			@touch($cachedir . '/' . 'index.php');
278
+		if (is_writable($cachedir . '/' . 'index.php')) {
279
+					@touch($cachedir . '/' . 'index.php');
280
+		}
277 281
 
278 282
 		return true;
279 283
 	}
Please login to merge, or discard this patch.
Sources/ManageServer.php 1 patch
Braces   +253 added lines, -196 removed lines patch added patch discarded remove patch
@@ -59,8 +59,9 @@  discard block
 block discarded – undo
59 59
  * @version 2.1 Beta 3
60 60
  */
61 61
 
62
-if (!defined('SMF'))
62
+if (!defined('SMF')) {
63 63
 	die('No direct access...');
64
+}
64 65
 
65 66
 /**
66 67
  * This is the main dispatcher. Sets up all the available sub-actions, all the tabs and selects
@@ -111,10 +112,11 @@  discard block
 block discarded – undo
111 112
 	$settings_not_writable = !is_writable($boarddir . '/Settings.php');
112 113
 	$settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
113 114
 
114
-	if ($settings_not_writable)
115
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
116
-	elseif ($settings_backup_fail)
117
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
115
+	if ($settings_not_writable) {
116
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
117
+	} elseif ($settings_backup_fail) {
118
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
119
+	}
118 120
 
119 121
 	$context['settings_not_writable'] = $settings_not_writable;
120 122
 
@@ -166,8 +168,9 @@  discard block
 block discarded – undo
166 168
 
167 169
 	call_integration_hook('integrate_general_settings', array(&$config_vars));
168 170
 
169
-	if ($return_config)
170
-		return $config_vars;
171
+	if ($return_config) {
172
+			return $config_vars;
173
+	}
171 174
 
172 175
 	// Setup the template stuff.
173 176
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=general;save';
@@ -232,8 +235,9 @@  discard block
 block discarded – undo
232 235
 
233 236
 	call_integration_hook('integrate_database_settings', array(&$config_vars));
234 237
 
235
-	if ($return_config)
236
-		return $config_vars;
238
+	if ($return_config) {
239
+			return $config_vars;
240
+	}
237 241
 
238 242
 	// Setup the template stuff.
239 243
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=database;save';
@@ -308,13 +312,15 @@  discard block
 block discarded – undo
308 312
 		hideGlobalCookies();
309 313
 	});', true);
310 314
 
311
-	if (empty($user_settings['tfa_secret']))
312
-		addInlineJavaScript('');
315
+	if (empty($user_settings['tfa_secret'])) {
316
+			addInlineJavaScript('');
317
+	}
313 318
 
314 319
 	call_integration_hook('integrate_cookie_settings', array(&$config_vars));
315 320
 
316
-	if ($return_config)
317
-		return $config_vars;
321
+	if ($return_config) {
322
+			return $config_vars;
323
+	}
318 324
 
319 325
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cookie;save';
320 326
 	$context['settings_title'] = $txt['cookies_sessions_settings'];
@@ -325,11 +331,13 @@  discard block
 block discarded – undo
325 331
 		call_integration_hook('integrate_save_cookie_settings');
326 332
 
327 333
 		// Local and global do not play nicely together.
328
-		if (!empty($_POST['localCookies']) && empty($_POST['globalCookies']))
329
-			unset ($_POST['globalCookies']);
334
+		if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) {
335
+					unset ($_POST['globalCookies']);
336
+		}
330 337
 
331
-		if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false)
332
-			fatal_lang_error('invalid_cookie_domain', false);
338
+		if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) {
339
+					fatal_lang_error('invalid_cookie_domain', false);
340
+		}
333 341
 
334 342
 		saveSettings($config_vars);
335 343
 
@@ -412,8 +420,9 @@  discard block
 block discarded – undo
412 420
 
413 421
 	call_integration_hook('integrate_general_security_settings', array(&$config_vars));
414 422
 
415
-	if ($return_config)
416
-		return $config_vars;
423
+	if ($return_config) {
424
+			return $config_vars;
425
+	}
417 426
 
418 427
 	// Saving?
419 428
 	if (isset($_GET['save']))
@@ -452,8 +461,7 @@  discard block
 block discarded – undo
452 461
 		$txt['cache_settings_message'] = $txt['detected_no_caching'];
453 462
 		$cache_level = array($txt['cache_off']);
454 463
 		$detected['none'] = $txt['cache_off'];
455
-	}
456
-	else
464
+	} else
457 465
 	{
458 466
 		$txt['cache_settings_message'] = sprintf($txt['detected_accelerators'], implode(', ', $detected));
459 467
 		$cache_level = array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']);
@@ -490,8 +498,9 @@  discard block
 block discarded – undo
490 498
 			}
491 499
 		}
492 500
 	}
493
-	if ($return_config)
494
-		return $config_vars;
501
+	if ($return_config) {
502
+			return $config_vars;
503
+	}
495 504
 
496 505
 	// Saving again?
497 506
 	if (isset($_GET['save']))
@@ -519,8 +528,9 @@  discard block
 block discarded – undo
519 528
 	$context['save_disabled'] = $context['settings_not_writable'];
520 529
 
521 530
 	// Decide what message to show.
522
-	if (!$context['save_disabled'])
523
-		$context['settings_message'] = $txt['caching_information'];
531
+	if (!$context['save_disabled']) {
532
+			$context['settings_message'] = $txt['caching_information'];
533
+	}
524 534
 
525 535
 	// Prepare the template.
526 536
 	prepareServerSettingsContext($config_vars);
@@ -543,24 +553,25 @@  discard block
 block discarded – undo
543 553
 	if (stripos(PHP_OS, 'win') === 0)
544 554
 	{
545 555
 		$context['settings_message'] = $txt['loadavg_disabled_windows'];
546
-		if (isset($_GET['save']))
547
-			$_SESSION['adm-save'] = $txt['loadavg_disabled_windows'];
548
-	}
549
-	elseif (stripos(PHP_OS, 'darwin') === 0)
556
+		if (isset($_GET['save'])) {
557
+					$_SESSION['adm-save'] = $txt['loadavg_disabled_windows'];
558
+		}
559
+	} elseif (stripos(PHP_OS, 'darwin') === 0)
550 560
 	{
551 561
 		$context['settings_message'] = $txt['loadavg_disabled_osx'];
552
-		if (isset($_GET['save']))
553
-			$_SESSION['adm-save'] = $txt['loadavg_disabled_osx'];
554
-	}
555
-	else
562
+		if (isset($_GET['save'])) {
563
+					$_SESSION['adm-save'] = $txt['loadavg_disabled_osx'];
564
+		}
565
+	} else
556 566
 	{
557 567
 		$modSettings['load_average'] = @file_get_contents('/proc/loadavg');
558
-		if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0)
559
-			$modSettings['load_average'] = (float) $matches[1];
560
-		elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0)
561
-			$modSettings['load_average'] = (float) $matches[1];
562
-		else
563
-			unset($modSettings['load_average']);
568
+		if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) {
569
+					$modSettings['load_average'] = (float) $matches[1];
570
+		} elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) {
571
+					$modSettings['load_average'] = (float) $matches[1];
572
+		} else {
573
+					unset($modSettings['load_average']);
574
+		}
564 575
 
565 576
 		if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0)
566 577
 		{
@@ -596,8 +607,9 @@  discard block
 block discarded – undo
596 607
 
597 608
 	call_integration_hook('integrate_loadavg_settings', array(&$config_vars));
598 609
 
599
-	if ($return_config)
600
-		return $config_vars;
610
+	if ($return_config) {
611
+			return $config_vars;
612
+	}
601 613
 
602 614
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=loads;save';
603 615
 	$context['settings_title'] = $txt['load_balancing_settings'];
@@ -608,24 +620,27 @@  discard block
 block discarded – undo
608 620
 		// Stupidity is not allowed.
609 621
 		foreach ($_POST as $key => $value)
610 622
 		{
611
-			if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values)))
612
-				continue;
613
-			else
614
-				$_POST[$key] = (float) $value;
615
-
616
-			if ($key == 'loadavg_auto_opt' && $value <= 1)
617
-				$_POST['loadavg_auto_opt'] = 1.0;
618
-			elseif ($key == 'loadavg_forum' && $value < 10)
619
-				$_POST['loadavg_forum'] = 10.0;
620
-			elseif ($value < 2)
621
-				$_POST[$key] = 2.0;
623
+			if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) {
624
+							continue;
625
+			} else {
626
+							$_POST[$key] = (float) $value;
627
+			}
628
+
629
+			if ($key == 'loadavg_auto_opt' && $value <= 1) {
630
+							$_POST['loadavg_auto_opt'] = 1.0;
631
+			} elseif ($key == 'loadavg_forum' && $value < 10) {
632
+							$_POST['loadavg_forum'] = 10.0;
633
+			} elseif ($value < 2) {
634
+							$_POST[$key] = 2.0;
635
+			}
622 636
 		}
623 637
 
624 638
 		call_integration_hook('integrate_save_loadavg_settings');
625 639
 
626 640
 		saveDBSettings($config_vars);
627
-		if (!isset($_SESSION['adm-save']))
628
-			$_SESSION['adm-save'] = true;
641
+		if (!isset($_SESSION['adm-save'])) {
642
+					$_SESSION['adm-save'] = true;
643
+		}
629 644
 		redirectexit('action=admin;area=serversettings;sa=loads;' . $context['session_var'] . '=' . $context['session_id']);
630 645
 	}
631 646
 
@@ -661,10 +676,11 @@  discard block
 block discarded – undo
661 676
 
662 677
 	if (isset($_SESSION['adm-save']))
663 678
 	{
664
-		if ($_SESSION['adm-save'] === true)
665
-			$context['saved_successful'] = true;
666
-		else
667
-			$context['saved_failed'] = $_SESSION['adm-save'];
679
+		if ($_SESSION['adm-save'] === true) {
680
+					$context['saved_successful'] = true;
681
+		} else {
682
+					$context['saved_failed'] = $_SESSION['adm-save'];
683
+		}
668 684
 
669 685
 		unset($_SESSION['adm-save']);
670 686
 	}
@@ -672,9 +688,9 @@  discard block
 block discarded – undo
672 688
 	$context['config_vars'] = array();
673 689
 	foreach ($config_vars as $identifier => $config_var)
674 690
 	{
675
-		if (!is_array($config_var) || !isset($config_var[1]))
676
-			$context['config_vars'][] = $config_var;
677
-		else
691
+		if (!is_array($config_var) || !isset($config_var[1])) {
692
+					$context['config_vars'][] = $config_var;
693
+		} else
678 694
 		{
679 695
 			$varname = $config_var[0];
680 696
 			global $$varname;
@@ -709,16 +725,19 @@  discard block
 block discarded – undo
709 725
 			if ($config_var[3] == 'int' || $config_var[3] == 'float')
710 726
 			{
711 727
 				// Default to a min of 0 if one isn't set
712
-				if (isset($config_var['min']))
713
-					$context['config_vars'][$config_var[0]]['min'] = $config_var['min'];
714
-				else
715
-					$context['config_vars'][$config_var[0]]['min'] = 0;
728
+				if (isset($config_var['min'])) {
729
+									$context['config_vars'][$config_var[0]]['min'] = $config_var['min'];
730
+				} else {
731
+									$context['config_vars'][$config_var[0]]['min'] = 0;
732
+				}
716 733
 
717
-				if (isset($config_var['max']))
718
-					$context['config_vars'][$config_var[0]]['max'] = $config_var['max'];
734
+				if (isset($config_var['max'])) {
735
+									$context['config_vars'][$config_var[0]]['max'] = $config_var['max'];
736
+				}
719 737
 
720
-				if (isset($config_var['step']))
721
-					$context['config_vars'][$config_var[0]]['step'] = $config_var['step'];
738
+				if (isset($config_var['step'])) {
739
+									$context['config_vars'][$config_var[0]]['step'] = $config_var['step'];
740
+				}
722 741
 			}
723 742
 
724 743
 			// If this is a select box handle any data.
@@ -726,12 +745,13 @@  discard block
 block discarded – undo
726 745
 			{
727 746
 				// If it's associative
728 747
 				$config_values = array_values($config_var[4]);
729
-				if (isset($config_values[0]) && is_array($config_values[0]))
730
-					$context['config_vars'][$config_var[0]]['data'] = $config_var[4];
731
-				else
748
+				if (isset($config_values[0]) && is_array($config_values[0])) {
749
+									$context['config_vars'][$config_var[0]]['data'] = $config_var[4];
750
+				} else
732 751
 				{
733
-					foreach ($config_var[4] as $key => $item)
734
-						$context['config_vars'][$config_var[0]]['data'][] = array($key, $item);
752
+					foreach ($config_var[4] as $key => $item) {
753
+											$context['config_vars'][$config_var[0]]['data'][] = array($key, $item);
754
+					}
735 755
 				}
736 756
 			}
737 757
 		}
@@ -756,10 +776,11 @@  discard block
 block discarded – undo
756 776
 
757 777
 	if (isset($_SESSION['adm-save']))
758 778
 	{
759
-		if ($_SESSION['adm-save'] === true)
760
-			$context['saved_successful'] = true;
761
-		else
762
-			$context['saved_failed'] = $_SESSION['adm-save'];
779
+		if ($_SESSION['adm-save'] === true) {
780
+					$context['saved_successful'] = true;
781
+		} else {
782
+					$context['saved_failed'] = $_SESSION['adm-save'];
783
+		}
763 784
 
764 785
 		unset($_SESSION['adm-save']);
765 786
 	}
@@ -771,26 +792,30 @@  discard block
 block discarded – undo
771 792
 	foreach ($config_vars as $config_var)
772 793
 	{
773 794
 		// HR?
774
-		if (!is_array($config_var))
775
-			$context['config_vars'][] = $config_var;
776
-		else
795
+		if (!is_array($config_var)) {
796
+					$context['config_vars'][] = $config_var;
797
+		} else
777 798
 		{
778 799
 			// If it has no name it doesn't have any purpose!
779
-			if (empty($config_var[1]))
780
-				continue;
800
+			if (empty($config_var[1])) {
801
+							continue;
802
+			}
781 803
 
782 804
 			// Special case for inline permissions
783
-			if ($config_var[0] == 'permissions' && allowedTo('manage_permissions'))
784
-				$inlinePermissions[] = $config_var[1];
785
-			elseif ($config_var[0] == 'permissions')
786
-				continue;
805
+			if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) {
806
+							$inlinePermissions[] = $config_var[1];
807
+			} elseif ($config_var[0] == 'permissions') {
808
+							continue;
809
+			}
787 810
 
788
-			if ($config_var[0] == 'boards')
789
-				$board_list = true;
811
+			if ($config_var[0] == 'boards') {
812
+							$board_list = true;
813
+			}
790 814
 
791 815
 			// Are we showing the BBC selection box?
792
-			if ($config_var[0] == 'bbc')
793
-				$bbcChoice[] = $config_var[1];
816
+			if ($config_var[0] == 'bbc') {
817
+							$bbcChoice[] = $config_var[1];
818
+			}
794 819
 
795 820
 			// We need to do some parsing of the value before we pass it in.
796 821
 			if (isset($modSettings[$config_var[1]]))
@@ -809,8 +834,7 @@  discard block
 block discarded – undo
809 834
 					default:
810 835
 						$value = $smcFunc['htmlspecialchars']($modSettings[$config_var[1]]);
811 836
 				}
812
-			}
813
-			else
837
+			} else
814 838
 			{
815 839
 				// Darn, it's empty. What type is expected?
816 840
 				switch ($config_var[0])
@@ -850,16 +874,19 @@  discard block
 block discarded – undo
850 874
 			if ($config_var[0] == 'int' || $config_var[0] == 'float')
851 875
 			{
852 876
 				// Default to a min of 0 if one isn't set
853
-				if (isset($config_var['min']))
854
-					$context['config_vars'][$config_var[1]]['min'] = $config_var['min'];
855
-				else
856
-					$context['config_vars'][$config_var[1]]['min'] = 0;
877
+				if (isset($config_var['min'])) {
878
+									$context['config_vars'][$config_var[1]]['min'] = $config_var['min'];
879
+				} else {
880
+									$context['config_vars'][$config_var[1]]['min'] = 0;
881
+				}
857 882
 
858
-				if (isset($config_var['max']))
859
-					$context['config_vars'][$config_var[1]]['max'] = $config_var['max'];
883
+				if (isset($config_var['max'])) {
884
+									$context['config_vars'][$config_var[1]]['max'] = $config_var['max'];
885
+				}
860 886
 
861
-				if (isset($config_var['step']))
862
-					$context['config_vars'][$config_var[1]]['step'] = $config_var['step'];
887
+				if (isset($config_var['step'])) {
888
+									$context['config_vars'][$config_var[1]]['step'] = $config_var['step'];
889
+				}
863 890
 			}
864 891
 
865 892
 			// If this is a select box handle any data.
@@ -873,12 +900,13 @@  discard block
 block discarded – undo
873 900
 				}
874 901
 
875 902
 				// If it's associative
876
-				if (isset($config_var[2][0]) && is_array($config_var[2][0]))
877
-					$context['config_vars'][$config_var[1]]['data'] = $config_var[2];
878
-				else
903
+				if (isset($config_var[2][0]) && is_array($config_var[2][0])) {
904
+									$context['config_vars'][$config_var[1]]['data'] = $config_var[2];
905
+				} else
879 906
 				{
880
-					foreach ($config_var[2] as $key => $item)
881
-						$context['config_vars'][$config_var[1]]['data'][] = array($key, $item);
907
+					foreach ($config_var[2] as $key => $item) {
908
+											$context['config_vars'][$config_var[1]]['data'][] = array($key, $item);
909
+					}
882 910
 				}
883 911
 			}
884 912
 
@@ -887,17 +915,19 @@  discard block
 block discarded – undo
887 915
 			{
888 916
 				if (!is_numeric($k))
889 917
 				{
890
-					if (substr($k, 0, 2) == 'on')
891
-						$context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"';
892
-					else
893
-						$context['config_vars'][$config_var[1]][$k] = $v;
918
+					if (substr($k, 0, 2) == 'on') {
919
+											$context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"';
920
+					} else {
921
+											$context['config_vars'][$config_var[1]][$k] = $v;
922
+					}
894 923
 				}
895 924
 
896 925
 				// See if there are any other labels that might fit?
897
-				if (isset($txt['setting_' . $config_var[1]]))
898
-					$context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]];
899
-				elseif (isset($txt['groups_' . $config_var[1]]))
900
-					$context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]];
926
+				if (isset($txt['setting_' . $config_var[1]])) {
927
+									$context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]];
928
+				} elseif (isset($txt['groups_' . $config_var[1]])) {
929
+									$context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]];
930
+				}
901 931
 			}
902 932
 
903 933
 			// Set the subtext in case it's part of the label.
@@ -930,8 +960,9 @@  discard block
 block discarded – undo
930 960
 		// What are the options, eh?
931 961
 		$temp = parse_bbc(false);
932 962
 		$bbcTags = array();
933
-		foreach ($temp as $tag)
934
-			$bbcTags[] = $tag['tag'];
963
+		foreach ($temp as $tag) {
964
+					$bbcTags[] = $tag['tag'];
965
+		}
935 966
 
936 967
 		$bbcTags = array_unique($bbcTags);
937 968
 		$totalTags = count($bbcTags);
@@ -946,8 +977,9 @@  discard block
 block discarded – undo
946 977
 		$col = 0; $i = 0;
947 978
 		foreach ($bbcTags as $tag)
948 979
 		{
949
-			if ($i % $tagsPerColumn == 0 && $i != 0)
950
-				$col++;
980
+			if ($i % $tagsPerColumn == 0 && $i != 0) {
981
+							$col++;
982
+			}
951 983
 
952 984
 			$context['bbc_columns'][$col][] = array(
953 985
 				'tag' => $tag,
@@ -990,18 +1022,21 @@  discard block
 block discarded – undo
990 1022
 	validateToken('admin-ssc');
991 1023
 
992 1024
 	// Fix the darn stupid cookiename! (more may not be allowed, but these for sure!)
993
-	if (isset($_POST['cookiename']))
994
-		$_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']);
1025
+	if (isset($_POST['cookiename'])) {
1026
+			$_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']);
1027
+	}
995 1028
 
996 1029
 	// Fix the forum's URL if necessary.
997 1030
 	if (isset($_POST['boardurl']))
998 1031
 	{
999
-		if (substr($_POST['boardurl'], -10) == '/index.php')
1000
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1001
-		elseif (substr($_POST['boardurl'], -1) == '/')
1002
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1003
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
1004
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1032
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
1033
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1034
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
1035
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1036
+		}
1037
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
1038
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1039
+		}
1005 1040
 	}
1006 1041
 
1007 1042
 	// Any passwords?
@@ -1036,21 +1071,21 @@  discard block
 block discarded – undo
1036 1071
 	// Figure out which config vars we're saving here...
1037 1072
 	foreach ($config_vars as $var)
1038 1073
 	{
1039
-		if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]])))
1040
-			continue;
1074
+		if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) {
1075
+					continue;
1076
+		}
1041 1077
 
1042 1078
 		$config_var = $var[0];
1043 1079
 
1044 1080
 		if (in_array($config_var, $config_passwords))
1045 1081
 		{
1046
-			if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1])
1047
-				$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\'';
1048
-		}
1049
-		elseif (in_array($config_var, $config_strs))
1082
+			if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) {
1083
+							$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\'';
1084
+			}
1085
+		} elseif (in_array($config_var, $config_strs))
1050 1086
 		{
1051 1087
 			$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var], '\'\\') . '\'';
1052
-		}
1053
-		elseif (in_array($config_var, $config_ints))
1088
+		} elseif (in_array($config_var, $config_ints))
1054 1089
 		{
1055 1090
 			$new_settings[$config_var] = (int) $_POST[$config_var];
1056 1091
 
@@ -1059,17 +1094,17 @@  discard block
 block discarded – undo
1059 1094
 			$new_settings[$config_var] = max($min, $new_settings[$config_var]);
1060 1095
 
1061 1096
 			// Is there a max value for this as well?
1062
-			if (isset($var['max']))
1063
-				$new_settings[$config_var] = min($var['max'], $new_settings[$config_var]);
1064
-		}
1065
-		elseif (in_array($config_var, $config_bools))
1097
+			if (isset($var['max'])) {
1098
+							$new_settings[$config_var] = min($var['max'], $new_settings[$config_var]);
1099
+			}
1100
+		} elseif (in_array($config_var, $config_bools))
1066 1101
 		{
1067
-			if (!empty($_POST[$config_var]))
1068
-				$new_settings[$config_var] = '1';
1069
-			else
1070
-				$new_settings[$config_var] = '0';
1071
-		}
1072
-		else
1102
+			if (!empty($_POST[$config_var])) {
1103
+							$new_settings[$config_var] = '1';
1104
+			} else {
1105
+							$new_settings[$config_var] = '0';
1106
+			}
1107
+		} else
1073 1108
 		{
1074 1109
 			// This shouldn't happen, but it might...
1075 1110
 			fatal_error('Unknown config_var \'' . $config_var . '\'');
@@ -1085,30 +1120,35 @@  discard block
 block discarded – undo
1085 1120
 	foreach ($config_vars as $config_var)
1086 1121
 	{
1087 1122
 		// We just saved the file-based settings, so skip their definitions.
1088
-		if (!is_array($config_var) || $config_var[2] == 'file')
1089
-			continue;
1123
+		if (!is_array($config_var) || $config_var[2] == 'file') {
1124
+					continue;
1125
+		}
1090 1126
 
1091 1127
 		$new_setting = array($config_var[3], $config_var[0]);
1092 1128
 
1093 1129
 		// Select options need carried over, too.
1094
-		if (isset($config_var[4]))
1095
-			$new_setting[] = $config_var[4];
1130
+		if (isset($config_var[4])) {
1131
+					$new_setting[] = $config_var[4];
1132
+		}
1096 1133
 
1097 1134
 		// Include min and max if necessary
1098
-		if (isset($config_var['min']))
1099
-			$new_setting['min'] = $config_var['min'];
1135
+		if (isset($config_var['min'])) {
1136
+					$new_setting['min'] = $config_var['min'];
1137
+		}
1100 1138
 
1101
-		if (isset($config_var['max']))
1102
-			$new_setting['max'] = $config_var['max'];
1139
+		if (isset($config_var['max'])) {
1140
+					$new_setting['max'] = $config_var['max'];
1141
+		}
1103 1142
 
1104 1143
 		// Rewrite the definition a bit.
1105 1144
 		$new_settings[] = $new_setting;
1106 1145
 	}
1107 1146
 
1108 1147
 	// Save the new database-based settings, if any.
1109
-	if (!empty($new_settings))
1110
-		saveDBSettings($new_settings);
1111
-}
1148
+	if (!empty($new_settings)) {
1149
+			saveDBSettings($new_settings);
1150
+	}
1151
+	}
1112 1152
 
1113 1153
 /**
1114 1154
  * Helper function for saving database settings.
@@ -1126,22 +1166,25 @@  discard block
 block discarded – undo
1126 1166
 	$inlinePermissions = array();
1127 1167
 	foreach ($config_vars as $var)
1128 1168
 	{
1129
-		if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags']))))
1130
-			continue;
1169
+		if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) {
1170
+					continue;
1171
+		}
1131 1172
 
1132 1173
 		// Checkboxes!
1133
-		elseif ($var[0] == 'check')
1134
-			$setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0';
1174
+		elseif ($var[0] == 'check') {
1175
+					$setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0';
1176
+		}
1135 1177
 		// Select boxes!
1136
-		elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2])))
1137
-			$setArray[$var[1]] = $_POST[$var[1]];
1138
-		elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array())
1178
+		elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) {
1179
+					$setArray[$var[1]] = $_POST[$var[1]];
1180
+		} elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array())
1139 1181
 		{
1140 1182
 			// For security purposes we validate this line by line.
1141 1183
 			$lOptions = array();
1142
-			foreach ($_POST[$var[1]] as $invar)
1143
-				if (in_array($invar, array_keys($var[2])))
1184
+			foreach ($_POST[$var[1]] as $invar) {
1185
+							if (in_array($invar, array_keys($var[2])))
1144 1186
 					$lOptions[] = $invar;
1187
+			}
1145 1188
 
1146 1189
 			$setArray[$var[1]] = json_encode($lOptions);
1147 1190
 		}
@@ -1155,18 +1198,20 @@  discard block
 block discarded – undo
1155 1198
 				$request = $smcFunc['db_query']('', '
1156 1199
 					SELECT id_board
1157 1200
 					FROM {db_prefix}boards');
1158
-				while ($row = $smcFunc['db_fetch_row']($request))
1159
-					$board_list[$row[0]] = true;
1201
+				while ($row = $smcFunc['db_fetch_row']($request)) {
1202
+									$board_list[$row[0]] = true;
1203
+				}
1160 1204
 
1161 1205
 				$smcFunc['db_free_result']($request);
1162 1206
 			}
1163 1207
 
1164 1208
 			$lOptions = array();
1165 1209
 
1166
-			if (!empty($_POST[$var[1]]))
1167
-				foreach ($_POST[$var[1]] as $invar => $dummy)
1210
+			if (!empty($_POST[$var[1]])) {
1211
+							foreach ($_POST[$var[1]] as $invar => $dummy)
1168 1212
 					if (isset($board_list[$invar]))
1169 1213
 						$lOptions[] = $invar;
1214
+			}
1170 1215
 
1171 1216
 			$setArray[$var[1]] = !empty($lOptions) ? implode(',', $lOptions) : '';
1172 1217
 		}
@@ -1180,8 +1225,9 @@  discard block
 block discarded – undo
1180 1225
 			$setArray[$var[1]] = max($min, $setArray[$var[1]]);
1181 1226
 
1182 1227
 			// Do we have a max value for this as well?
1183
-			if (isset($var['max']))
1184
-				$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1228
+			if (isset($var['max'])) {
1229
+							$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1230
+			}
1185 1231
 		}
1186 1232
 		// Floating point!
1187 1233
 		elseif ($var[0] == 'float')
@@ -1193,40 +1239,47 @@  discard block
 block discarded – undo
1193 1239
 			$setArray[$var[1]] = max($min, $setArray[$var[1]]);
1194 1240
 
1195 1241
 			// Do we have a max value for this as well?
1196
-			if (isset($var['max']))
1197
-				$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1242
+			if (isset($var['max'])) {
1243
+							$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1244
+			}
1198 1245
 		}
1199 1246
 		// Text!
1200
-		elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time')))
1201
-			$setArray[$var[1]] = $_POST[$var[1]];
1247
+		elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) {
1248
+					$setArray[$var[1]] = $_POST[$var[1]];
1249
+		}
1202 1250
 		// Passwords!
1203 1251
 		elseif ($var[0] == 'password')
1204 1252
 		{
1205
-			if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1])
1206
-				$setArray[$var[1]] = $_POST[$var[1]][0];
1253
+			if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) {
1254
+							$setArray[$var[1]] = $_POST[$var[1]][0];
1255
+			}
1207 1256
 		}
1208 1257
 		// BBC.
1209 1258
 		elseif ($var[0] == 'bbc')
1210 1259
 		{
1211 1260
 
1212 1261
 			$bbcTags = array();
1213
-			foreach (parse_bbc(false) as $tag)
1214
-				$bbcTags[] = $tag['tag'];
1262
+			foreach (parse_bbc(false) as $tag) {
1263
+							$bbcTags[] = $tag['tag'];
1264
+			}
1215 1265
 
1216
-			if (!isset($_POST[$var[1] . '_enabledTags']))
1217
-				$_POST[$var[1] . '_enabledTags'] = array();
1218
-			elseif (!is_array($_POST[$var[1] . '_enabledTags']))
1219
-				$_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']);
1266
+			if (!isset($_POST[$var[1] . '_enabledTags'])) {
1267
+							$_POST[$var[1] . '_enabledTags'] = array();
1268
+			} elseif (!is_array($_POST[$var[1] . '_enabledTags'])) {
1269
+							$_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']);
1270
+			}
1220 1271
 
1221 1272
 			$setArray[$var[1]] = implode(',', array_diff($bbcTags, $_POST[$var[1] . '_enabledTags']));
1222 1273
 		}
1223 1274
 		// Permissions?
1224
-		elseif ($var[0] == 'permissions')
1225
-			$inlinePermissions[] = $var[1];
1275
+		elseif ($var[0] == 'permissions') {
1276
+					$inlinePermissions[] = $var[1];
1277
+		}
1226 1278
 	}
1227 1279
 
1228
-	if (!empty($setArray))
1229
-		updateSettings($setArray);
1280
+	if (!empty($setArray)) {
1281
+			updateSettings($setArray);
1282
+	}
1230 1283
 
1231 1284
 	// If we have inline permissions we need to save them.
1232 1285
 	if (!empty($inlinePermissions) && allowedTo('manage_permissions'))
@@ -1264,18 +1317,21 @@  discard block
 block discarded – undo
1264 1317
 	// put all of it into an array
1265 1318
 	foreach ($info_lines as $line)
1266 1319
 	{
1267
-		if (preg_match('~(' . $remove . ')~', $line))
1268
-			continue;
1320
+		if (preg_match('~(' . $remove . ')~', $line)) {
1321
+					continue;
1322
+		}
1269 1323
 
1270 1324
 		// new category?
1271
-		if (strpos($line, '<h2>') !== false)
1272
-			$category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category;
1325
+		if (strpos($line, '<h2>') !== false) {
1326
+					$category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category;
1327
+		}
1273 1328
 
1274 1329
 		// load it as setting => value or the old setting local master
1275
-		if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val))
1276
-			$pinfo[$category][$val[1]] = $val[2];
1277
-		elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val))
1278
-			$pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]);
1330
+		if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) {
1331
+					$pinfo[$category][$val[1]] = $val[2];
1332
+		} elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) {
1333
+					$pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]);
1334
+		}
1279 1335
 	}
1280 1336
 
1281 1337
 	// load it in to context and display it
@@ -1310,8 +1366,9 @@  discard block
 block discarded – undo
1310 1366
 				$testAPI = new $cache_class_name();
1311 1367
 
1312 1368
 				// No Support?  NEXT!
1313
-				if (!$testAPI->isSupported(true))
1314
-					continue;
1369
+				if (!$testAPI->isSupported(true)) {
1370
+									continue;
1371
+				}
1315 1372
 
1316 1373
 				$apis[$tryCache] = isset($txt[$tryCache . '_cache']) ? $txt[$tryCache . '_cache'] : $tryCache;
1317 1374
 			}
Please login to merge, or discard this patch.
Sources/CacheAPI-apc.php 1 patch
Braces   +12 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 3
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * Our Cache API class
@@ -29,8 +30,9 @@  discard block
 block discarded – undo
29 30
 
30 31
 		$supported = function_exists('apc_fetch') && function_exists('apc_store');
31 32
 
32
-		if ($test)
33
-			return $supported;
33
+		if ($test) {
34
+					return $supported;
35
+		}
34 36
 		return parent::isSupported() && $supported;
35 37
 	}
36 38
 
@@ -52,10 +54,11 @@  discard block
 block discarded – undo
52 54
 		$key = $this->prefix . strtr($key, ':/', '-_');
53 55
 
54 56
 		// An extended key is needed to counteract a bug in APC.
55
-		if ($value === null)
56
-			return apc_delete($key . 'smf');
57
-		else
58
-			return apc_store($key . 'smf', $value, $ttl);
57
+		if ($value === null) {
58
+					return apc_delete($key . 'smf');
59
+		} else {
60
+					return apc_store($key . 'smf', $value, $ttl);
61
+		}
59 62
 	}
60 63
 
61 64
 	/**
@@ -69,9 +72,9 @@  discard block
 block discarded – undo
69 72
 			// Always returns true.
70 73
 			apc_clear_cache('user');
71 74
 			apc_clear_cache('system');
75
+		} elseif ($type === 'user') {
76
+					apc_clear_cache('user');
72 77
 		}
73
-		elseif ($type === 'user')
74
-			apc_clear_cache('user');
75 78
 
76 79
 		$this->invalidateCache();
77 80
 		return true;
Please login to merge, or discard this patch.
Sources/CacheAPI-apcu.php 1 patch
Braces   +10 added lines, -7 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 3
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * Our Cache API class
@@ -29,8 +30,9 @@  discard block
 block discarded – undo
29 30
 
30 31
 		$supported = function_exists('apcu_fetch') && function_exists('apcu_store');
31 32
 
32
-		if ($test)
33
-			return $supported;
33
+		if ($test) {
34
+					return $supported;
35
+		}
34 36
 		return parent::isSupported() && $supported;
35 37
 	}
36 38
 
@@ -52,10 +54,11 @@  discard block
 block discarded – undo
52 54
 		$key = $this->prefix . strtr($key, ':/', '-_');
53 55
 
54 56
 		// An extended key is needed to counteract a bug in APC.
55
-		if ($value === null)
56
-			return apcu_delete($key . 'smf');
57
-		else
58
-			return apcu_store($key . 'smf', $value, $ttl);
57
+		if ($value === null) {
58
+					return apcu_delete($key . 'smf');
59
+		} else {
60
+					return apcu_store($key . 'smf', $value, $ttl);
61
+		}
59 62
 	}
60 63
 
61 64
 	/**
Please login to merge, or discard this patch.
Sources/CacheAPI-memcached.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
 		$currentServers = $this->memcached->getServerList();
55 55
 		foreach ($servers as $server)
56 56
 		{
57
-			if (strpos($server,'/') !== false)
57
+			if (strpos($server, '/') !== false)
58 58
 				$tempServer = array($server, 0);
59 59
 			else
60 60
 			{
Please login to merge, or discard this patch.
Braces   +17 added lines, -12 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 3
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * Our Cache API class
@@ -34,8 +35,9 @@  discard block
 block discarded – undo
34 35
 
35 36
 		$supported = class_exists('memcached');
36 37
 
37
-		if ($test)
38
-			return $supported;
38
+		if ($test) {
39
+					return $supported;
40
+		}
39 41
 		return parent::isSupported() && $supported && !empty($cache_memcached);
40 42
 	}
41 43
 
@@ -54,9 +56,9 @@  discard block
 block discarded – undo
54 56
 		$currentServers = $this->memcached->getServerList();
55 57
 		foreach ($servers as $server)
56 58
 		{
57
-			if (strpos($server,'/') !== false)
58
-				$tempServer = array($server, 0);
59
-			else
59
+			if (strpos($server,'/') !== false) {
60
+							$tempServer = array($server, 0);
61
+			} else
60 62
 			{
61 63
 				$server = explode(':', $server);
62 64
 				$tempServer = array($server[0], isset($server[1]) ? $server[1] : 11211);
@@ -74,8 +76,9 @@  discard block
 block discarded – undo
74 76
 			}
75 77
 
76 78
 			// Found it?
77
-			if (empty($foundServer))
78
-				$this->memcached->addServer($tempServer[0], $tempServer[1]);
79
+			if (empty($foundServer)) {
80
+							$this->memcached->addServer($tempServer[0], $tempServer[1]);
81
+			}
79 82
 		}
80 83
 
81 84
 		// Best guess is this worked.
@@ -92,8 +95,9 @@  discard block
 block discarded – undo
92 95
 		$value = $this->memcached->get($key);
93 96
 
94 97
 		// $value should return either data or false (from failure, key not found or empty array).
95
-		if ($value === false)
96
-			return null;
98
+		if ($value === false) {
99
+					return null;
100
+		}
97 101
 		return $value;
98 102
 	}
99 103
 
@@ -136,8 +140,9 @@  discard block
 block discarded – undo
136 140
 		$config_vars[] = $txt['cache_memcache_settings'];
137 141
 		$config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br /><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>');
138 142
 
139
-		if (!isset($context['settings_post_javascript']))
140
-			$context['settings_post_javascript'] = '';
143
+		if (!isset($context['settings_post_javascript'])) {
144
+					$context['settings_post_javascript'] = '';
145
+		}
141 146
 
142 147
 		$context['settings_post_javascript'] .= '
143 148
 			$("#cache_accelerator").change(function (e) {
Please login to merge, or discard this patch.
Sources/Calendar.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -240,8 +240,8 @@
 block discarded – undo
240 240
 		$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
241 241
 
242 242
 	$js_time_string = str_replace(
243
-		array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r',      '%R',  '%S', '%T',    '%X'),
244
-		array('H',  'G',  'h',  'g',  'i',  'A',  'a',  'h:i:s A', 'H:i', 's',  'H:i:s', 'H:i:s'),
243
+		array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'),
244
+		array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'),
245 245
 		$time_string
246 246
 	);
247 247
 
Please login to merge, or discard this patch.
Braces   +125 added lines, -99 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Show the calendar.
@@ -47,12 +48,14 @@  discard block
 block discarded – undo
47 48
 		'post' => 'CalendarPost',
48 49
 	);
49 50
 
50
-	if (isset($_GET['sa']) && isset($subActions[$_GET['sa']]))
51
-		return call_helper($subActions[$_GET['sa']]);
51
+	if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) {
52
+			return call_helper($subActions[$_GET['sa']]);
53
+	}
52 54
 
53 55
 	// You can't do anything if the calendar is off.
54
-	if (empty($modSettings['cal_enabled']))
55
-		fatal_lang_error('calendar_off', false);
56
+	if (empty($modSettings['cal_enabled'])) {
57
+			fatal_lang_error('calendar_off', false);
58
+	}
56 59
 
57 60
 	// This is gonna be needed...
58 61
 	loadTemplate('Calendar');
@@ -80,8 +83,9 @@  discard block
 block discarded – undo
80 83
 				$_REQUEST['month'] = (int) $_REQUEST['month'];
81 84
 
82 85
 				// We want month view.
83
-				if (empty($_GET['viewmonth']))
84
-					$_GET['viewmonth'] = true;
86
+				if (empty($_GET['viewmonth'])) {
87
+									$_GET['viewmonth'] = true;
88
+				}
85 89
 
86 90
 				// And we definitely don't want weekly view.
87 91
 				unset ($_GET['viewweek']);
@@ -98,22 +102,25 @@  discard block
 block discarded – undo
98 102
 	$context['page_title'] = $txt['calendar'];
99 103
 
100 104
 	// Ensure a default view is defined
101
-	if (empty($modSettings['calendar_default_view']))
102
-		$modSettings['calendar_default_view'] = 'view_list';
105
+	if (empty($modSettings['calendar_default_view'])) {
106
+			$modSettings['calendar_default_view'] = 'view_list';
107
+	}
103 108
 
104 109
 	// What view do we want?
105
-	if (isset($_GET['viewweek']))
106
-		$context['calendar_view'] = 'view_week';
107
-	elseif (isset($_GET['viewmonth']))
108
-		$context['calendar_view'] = 'view_month';
109
-	elseif (isset($_GET['viewlist']))
110
-		$context['calendar_view'] = 'view_list';
111
-	else
112
-		$context['calendar_view'] = $modSettings['calendar_default_view'];
110
+	if (isset($_GET['viewweek'])) {
111
+			$context['calendar_view'] = 'view_week';
112
+	} elseif (isset($_GET['viewmonth'])) {
113
+			$context['calendar_view'] = 'view_month';
114
+	} elseif (isset($_GET['viewlist'])) {
115
+			$context['calendar_view'] = 'view_list';
116
+	} else {
117
+			$context['calendar_view'] = $modSettings['calendar_default_view'];
118
+	}
113 119
 
114 120
 	// Don't let search engines index the non-default calendar pages
115
-	if ($context['calendar_view'] !== $modSettings['calendar_default_view'])
116
-		$context['robot_no_index'] = true;
121
+	if ($context['calendar_view'] !== $modSettings['calendar_default_view']) {
122
+			$context['robot_no_index'] = true;
123
+	}
117 124
 
118 125
 	// Get the current day of month...
119 126
 	require_once($sourcedir . '/Subs-Calendar.php');
@@ -174,16 +181,19 @@  discard block
 block discarded – undo
174 181
 	);
175 182
 
176 183
 	// Make sure the year and month are in valid ranges.
177
-	if ($curPage['month'] < 1 || $curPage['month'] > 12)
178
-		fatal_lang_error('invalid_month', false);
179
-	if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear'])
180
-		fatal_lang_error('invalid_year', false);
184
+	if ($curPage['month'] < 1 || $curPage['month'] > 12) {
185
+			fatal_lang_error('invalid_month', false);
186
+	}
187
+	if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) {
188
+			fatal_lang_error('invalid_year', false);
189
+	}
181 190
 	// If we have a day clean that too.
182 191
 	if ($context['calendar_view'] != 'view_month')
183 192
 	{
184 193
 		$isValid = checkdate($curPage['month'], $curPage['day'], $curPage['year']);
185
-		if (!$isValid)
186
-			fatal_lang_error('invalid_day', false);
194
+		if (!$isValid) {
195
+					fatal_lang_error('invalid_day', false);
196
+		}
187 197
 	}
188 198
 
189 199
 	// Load all the context information needed to show the calendar grid.
@@ -205,23 +215,26 @@  discard block
 block discarded – undo
205 215
 	);
206 216
 
207 217
 	// Load up the main view.
208
-	if ($context['calendar_view'] == 'view_list')
209
-		$context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions);
210
-	elseif ($context['calendar_view'] == 'view_week')
211
-		$context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions);
212
-	else
213
-		$context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions);
218
+	if ($context['calendar_view'] == 'view_list') {
219
+			$context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions);
220
+	} elseif ($context['calendar_view'] == 'view_week') {
221
+			$context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions);
222
+	} else {
223
+			$context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions);
224
+	}
214 225
 
215 226
 	// Load up the previous and next months.
216 227
 	$context['calendar_grid_current'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions);
217 228
 
218 229
 	// Only show previous month if it isn't pre-January of the min-year
219
-	if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1)
220
-		$context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true);
230
+	if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) {
231
+			$context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true);
232
+	}
221 233
 
222 234
 	// Only show next month if it isn't post-December of the max-year
223
-	if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12)
224
-		$context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions);
235
+	if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) {
236
+			$context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions);
237
+	}
225 238
 
226 239
 	// Basic template stuff.
227 240
 	$context['allow_calendar_event'] = allowedTo('calendar_post');
@@ -241,8 +254,9 @@  discard block
 block discarded – undo
241 254
 	$context['blocks_disabled'] = !empty($modSettings['cal_disable_prev_next']) ? 1 : 0;
242 255
 
243 256
 	// Set the page title to mention the month or week, too
244
-	if ($context['calendar_view'] != 'view_list')
245
-		$context['page_title'] .= ' - ' . ($context['calendar_view'] == 'view_week' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']);
257
+	if ($context['calendar_view'] != 'view_list') {
258
+			$context['page_title'] .= ' - ' . ($context['calendar_view'] == 'view_week' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']);
259
+	}
246 260
 
247 261
 	// Load up the linktree!
248 262
 	$context['linktree'][] = array(
@@ -255,17 +269,19 @@  discard block
 block discarded – undo
255 269
 		'name' => $txt['months'][$context['current_month']] . ' ' . $context['current_year']
256 270
 	);
257 271
 	// If applicable, add the current week to the linktree.
258
-	if ($context['calendar_view'] == 'view_week')
259
-		$context['linktree'][] = array(
272
+	if ($context['calendar_view'] == 'view_week') {
273
+			$context['linktree'][] = array(
260 274
 			'url' => $scripturl . '?action=calendar;viewweek;year=' . $context['current_year'] . ';month=' . $context['current_month'] . ';day=' . $context['current_day'],
261 275
 			'name' => $context['calendar_grid_main']['week_title'],
262 276
 		);
277
+	}
263 278
 
264 279
 	// Build the calendar button array.
265 280
 	$context['calendar_buttons'] = array();
266 281
 
267
-	if ($context['can_post'])
268
-		$context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']);
282
+	if ($context['can_post']) {
283
+			$context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']);
284
+	}
269 285
 
270 286
 	// Allow mods to add additional buttons here
271 287
 	call_integration_hook('integrate_calendar_buttons');
@@ -294,14 +310,16 @@  discard block
 block discarded – undo
294 310
 	require_once($sourcedir . '/Subs.php');
295 311
 
296 312
 	// Cast this for safety...
297
-	if (isset($_REQUEST['eventid']))
298
-		$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
313
+	if (isset($_REQUEST['eventid'])) {
314
+			$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
315
+	}
299 316
 
300 317
 	// We want a fairly compact version of the time, but as close as possible to the user's settings.
301
-	if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
302
-		$time_string = '%k:%M';
303
-	else
304
-		$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
318
+	if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
319
+			$time_string = '%k:%M';
320
+	} else {
321
+			$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
322
+	}
305 323
 
306 324
 	$js_time_string = str_replace(
307 325
 		array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r',      '%R',  '%S', '%T',    '%X'),
@@ -315,12 +333,14 @@  discard block
 block discarded – undo
315 333
 		checkSession();
316 334
 
317 335
 		// Validate the post...
318
-		if (!isset($_POST['link_to_board']))
319
-			validateEventPost();
336
+		if (!isset($_POST['link_to_board'])) {
337
+					validateEventPost();
338
+		}
320 339
 
321 340
 		// If you're not allowed to edit any events, you have to be the poster.
322
-		if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any'))
323
-			isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any'));
341
+		if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) {
342
+					isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any'));
343
+		}
324 344
 
325 345
 		// New - and directing?
326 346
 		if (isset($_POST['link_to_board']) || empty($modSettings['cal_allow_unlinked']))
@@ -343,8 +363,9 @@  discard block
 block discarded – undo
343 363
 		}
344 364
 
345 365
 		// Deleting...
346
-		elseif (isset($_REQUEST['deleteevent']))
347
-			removeEvent($_REQUEST['eventid']);
366
+		elseif (isset($_REQUEST['deleteevent'])) {
367
+					removeEvent($_REQUEST['eventid']);
368
+		}
348 369
 
349 370
 		// ... or just update it?
350 371
 		else
@@ -366,14 +387,12 @@  discard block
 block discarded – undo
366 387
 			$d = date_parse($_POST['start_date']);
367 388
 			$year = $d['year'];
368 389
 			$month = $d['month'];
369
-		}
370
-		elseif (isset($_POST['start_datetime']))
390
+		} elseif (isset($_POST['start_datetime']))
371 391
 		{
372 392
 			$d = date_parse($_POST['start_datetime']);
373 393
 			$year = $d['year'];
374 394
 			$month = $d['month'];
375
-		}
376
-		else
395
+		} else
377 396
 		{
378 397
 			$today = getdate();
379 398
 			$year = isset($_POST['year']) ? $_POST['year'] : $today['year'];
@@ -406,13 +425,13 @@  discard block
 block discarded – undo
406 425
 		$context['event'] = array_merge($context['event'], $eventDatetimes);
407 426
 
408 427
 		$context['event']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['event']['month'] == 12 ? 1 : $context['event']['month'] + 1, 0, $context['event']['month'] == 12 ? $context['event']['year'] + 1 : $context['event']['year']));
409
-	}
410
-	else
428
+	} else
411 429
 	{
412 430
 		$context['event'] = getEventProperties($_REQUEST['eventid']);
413 431
 
414
-		if ($context['event'] === false)
415
-			fatal_lang_error('no_access', false);
432
+		if ($context['event'] === false) {
433
+					fatal_lang_error('no_access', false);
434
+		}
416 435
 
417 436
 		// If it has a board, then they should be editing it within the topic.
418 437
 		if (!empty($context['event']['topic']['id']) && !empty($context['event']['topic']['first_msg']))
@@ -423,10 +442,11 @@  discard block
 block discarded – undo
423 442
 		}
424 443
 
425 444
 		// Make sure the user is allowed to edit this event.
426
-		if ($context['event']['member'] != $user_info['id'])
427
-			isAllowedTo('calendar_edit_any');
428
-		elseif (!allowedTo('calendar_edit_any'))
429
-			isAllowedTo('calendar_edit_own');
445
+		if ($context['event']['member'] != $user_info['id']) {
446
+					isAllowedTo('calendar_edit_any');
447
+		} elseif (!allowedTo('calendar_edit_any')) {
448
+					isAllowedTo('calendar_edit_own');
449
+		}
430 450
 	}
431 451
 
432 452
 	// An all day event? Set up some nice defaults in case the user wants to change that
@@ -460,8 +480,7 @@  discard block
 block discarded – undo
460 480
 	{
461 481
 		// You can post new events but can't link them to anything...
462 482
 		$context['event']['categories'] = array();
463
-	}
464
-	else
483
+	} else
465 484
 	{
466 485
 		// Load the list of boards and categories in the context.
467 486
 		require_once($sourcedir . '/Subs-MessageIndex.php');
@@ -548,12 +567,14 @@  discard block
 block discarded – undo
548 567
 	global $smcFunc, $sourcedir, $forum_version, $modSettings, $webmaster_email, $mbname;
549 568
 
550 569
 	// You can't export if the calendar export feature is off.
551
-	if (empty($modSettings['cal_export']))
552
-		fatal_lang_error('calendar_export_off', false);
570
+	if (empty($modSettings['cal_export'])) {
571
+			fatal_lang_error('calendar_export_off', false);
572
+	}
553 573
 
554 574
 	// Goes without saying that this is required.
555
-	if (!isset($_REQUEST['eventid']))
556
-		fatal_lang_error('no_access', false);
575
+	if (!isset($_REQUEST['eventid'])) {
576
+			fatal_lang_error('no_access', false);
577
+	}
557 578
 
558 579
 	// This is kinda wanted.
559 580
 	require_once($sourcedir . '/Subs-Calendar.php');
@@ -561,15 +582,17 @@  discard block
 block discarded – undo
561 582
 	// Load up the event in question and check it exists.
562 583
 	$event = getEventProperties($_REQUEST['eventid']);
563 584
 
564
-	if ($event === false)
565
-		fatal_lang_error('no_access', false);
585
+	if ($event === false) {
586
+			fatal_lang_error('no_access', false);
587
+	}
566 588
 
567 589
 	// Check the title isn't too long - iCal requires some formatting if so.
568 590
 	$title = str_split($event['title'], 30);
569 591
 	foreach ($title as $id => $line)
570 592
 	{
571
-		if ($id != 0)
572
-			$title[$id] = ' ' . $title[$id];
593
+		if ($id != 0) {
594
+					$title[$id] = ' ' . $title[$id];
595
+		}
573 596
 		$title[$id] .= "\n";
574 597
 	}
575 598
 
@@ -582,8 +605,7 @@  discard block
 block discarded – undo
582 605
 	{
583 606
 		$datestart = date_format($start_date, 'Ymd\THis');
584 607
 		$dateend = date_format($end_date, 'Ymd\THis');
585
-	}
586
-	else
608
+	} else
587 609
 	{
588 610
 		$datestart = date_format($start_date, 'Ymd');
589 611
 
@@ -604,15 +626,18 @@  discard block
 block discarded – undo
604 626
 	$filecontents .= 'DTSTART' . (!empty($event['start_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $datestart . "\n";
605 627
 
606 628
 	// event has a duration
607
-	if ($event['start_iso_gmdate'] != $event['end_iso_gmdate'])
608
-		$filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n";
629
+	if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) {
630
+			$filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n";
631
+	}
609 632
 
610 633
 	// event has changed? advance the sequence for this UID
611
-	if ($event['sequence'] > 0)
612
-		$filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n";
634
+	if ($event['sequence'] > 0) {
635
+			$filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n";
636
+	}
613 637
 
614
-	if (!empty($event['location']))
615
-		$filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n";
638
+	if (!empty($event['location'])) {
639
+			$filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n";
640
+	}
616 641
 
617 642
 	$filecontents .= 'SUMMARY:' . implode('', $title);
618 643
 	$filecontents .= 'UID:' . $event['eventid'] . '@' . str_replace(' ', '-', $mbname) . "\n";
@@ -621,23 +646,26 @@  discard block
 block discarded – undo
621 646
 
622 647
 	// Send some standard headers.
623 648
 	ob_end_clean();
624
-	if (!empty($modSettings['enableCompressedOutput']))
625
-		@ob_start('ob_gzhandler');
626
-	else
627
-		ob_start();
649
+	if (!empty($modSettings['enableCompressedOutput'])) {
650
+			@ob_start('ob_gzhandler');
651
+	} else {
652
+			ob_start();
653
+	}
628 654
 
629 655
 	// Send the file headers
630 656
 	header('Pragma: ');
631 657
 	header('Cache-Control: no-cache');
632
-	if (!isBrowser('gecko'))
633
-		header('Content-Transfer-Encoding: binary');
658
+	if (!isBrowser('gecko')) {
659
+			header('Content-Transfer-Encoding: binary');
660
+	}
634 661
 	header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT');
635 662
 	header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . 'GMT');
636 663
 	header('Accept-Ranges: bytes');
637 664
 	header('Connection: close');
638 665
 	header('Content-Disposition: attachment; filename="' . $event['title'] . '.ics"');
639
-	if (empty($modSettings['enableCompressedOutput']))
640
-		header('Content-Length: ' . $smcFunc['strlen']($filecontents));
666
+	if (empty($modSettings['enableCompressedOutput'])) {
667
+			header('Content-Length: ' . $smcFunc['strlen']($filecontents));
668
+	}
641 669
 
642 670
 	// This is a calendar item!
643 671
 	header('Content-Type: text/calendar');
@@ -676,20 +704,17 @@  discard block
 block discarded – undo
676 704
 		$context['sub_template'] = 'bcd';
677 705
 		$context['linktree'][] = array('url' => $scripturl . '?action=clock;bcd', 'name' => 'BCD');
678 706
 		$context['clockicons'] = safe_unserialize(base64_decode('YTo2OntzOjI6ImgxIjthOjI6e2k6MDtpOjI7aToxO2k6MTt9czoyOiJoMiI7YTo0OntpOjA7aTo4O2k6MTtpOjQ7aToyO2k6MjtpOjM7aToxO31zOjI6Im0xIjthOjM6e2k6MDtpOjQ7aToxO2k6MjtpOjI7aToxO31zOjI6Im0yIjthOjQ6e2k6MDtpOjg7aToxO2k6NDtpOjI7aToyO2k6MztpOjE7fXM6MjoiczEiO2E6Mzp7aTowO2k6NDtpOjE7aToyO2k6MjtpOjE7fXM6MjoiczIiO2E6NDp7aTowO2k6ODtpOjE7aTo0O2k6MjtpOjI7aTozO2k6MTt9fQ=='));
679
-	}
680
-	elseif (!$omfg && !isset($_REQUEST['time']))
707
+	} elseif (!$omfg && !isset($_REQUEST['time']))
681 708
 	{
682 709
 		$context['sub_template'] = 'hms';
683 710
 		$context['linktree'][] = array('url' => $scripturl . '?action=clock', 'name' => 'Binary');
684 711
 		$context['clockicons'] = safe_unserialize(base64_decode('YTozOntzOjE6ImgiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czoxOiJtIjthOjY6e2k6MDtpOjMyO2k6MTtpOjE2O2k6MjtpOjg7aTozO2k6NDtpOjQ7aToyO2k6NTtpOjE7fXM6MToicyI7YTo2OntpOjA7aTozMjtpOjE7aToxNjtpOjI7aTo4O2k6MztpOjQ7aTo0O2k6MjtpOjU7aToxO319'));
685
-	}
686
-	elseif ($omfg)
712
+	} elseif ($omfg)
687 713
 	{
688 714
 		$context['sub_template'] = 'omfg';
689 715
 		$context['linktree'][] = array('url' => $scripturl . '?action=clock;omfg', 'name' => 'OMFG');
690 716
 		$context['clockicons'] = safe_unserialize(base64_decode('YTo2OntzOjQ6InllYXIiO2E6Nzp7aTowO2k6NjQ7aToxO2k6MzI7aToyO2k6MTY7aTozO2k6ODtpOjQ7aTo0O2k6NTtpOjI7aTo2O2k6MTt9czo1OiJtb250aCI7YTo0OntpOjA7aTo4O2k6MTtpOjQ7aToyO2k6MjtpOjM7aToxO31zOjM6ImRheSI7YTo1OntpOjA7aToxNjtpOjE7aTo4O2k6MjtpOjQ7aTozO2k6MjtpOjQ7aToxO31zOjQ6ImhvdXIiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czozOiJtaW4iO2E6Njp7aTowO2k6MzI7aToxO2k6MTY7aToyO2k6ODtpOjM7aTo0O2k6NDtpOjI7aTo1O2k6MTt9czozOiJzZWMiO2E6Njp7aTowO2k6MzI7aToxO2k6MTY7aToyO2k6ODtpOjM7aTo0O2k6NDtpOjI7aTo1O2k6MTt9fQ=='));
691
-	}
692
-	elseif (isset($_REQUEST['time']))
717
+	} elseif (isset($_REQUEST['time']))
693 718
 	{
694 719
 		$context['sub_template'] = 'thetime';
695 720
 		$time = getdate($_REQUEST['time'] == 'now' ? time() : (int) $_REQUEST['time']);
@@ -749,12 +774,13 @@  discard block
 block discarded – undo
749 774
 			),
750 775
 		);
751 776
 
752
-		foreach ($context['clockicons'] as $t => $vs)
753
-			foreach ($vs as $v => $dumb)
777
+		foreach ($context['clockicons'] as $t => $vs) {
778
+					foreach ($vs as $v => $dumb)
754 779
 			{
755 780
 				if ($$t >= $v)
756 781
 				{
757 782
 					$$t -= $v;
783
+		}
758 784
 					$context['clockicons'][$t][$v] = true;
759 785
 				}
760 786
 			}
Please login to merge, or discard this patch.
other/install.php 2 patches
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1619,8 +1619,7 @@
 block discarded – undo
1619 1619
 	updateStats('topic');
1620 1620
 
1621 1621
 	// This function is needed to do the updateStats('subject') call.
1622
-	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1623
-		function($string){
1622
+	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) {
1624 1623
 			global $sourcedir;
1625 1624
 			if (function_exists('mb_strtolower'))
1626 1625
 				return mb_strtolower($string, 'UTF-8');
Please login to merge, or discard this patch.
Braces   +441 added lines, -328 removed lines patch added patch discarded remove patch
@@ -20,8 +20,9 @@  discard block
 block discarded – undo
20 20
 // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;">
21 21
 
22 22
 // Let's pull in useful classes
23
-if (!defined('SMF'))
23
+if (!defined('SMF')) {
24 24
 	define('SMF', 1);
25
+}
25 26
 
26 27
 require_once('Sources/Class-Package.php');
27 28
 
@@ -63,10 +64,11 @@  discard block
 block discarded – undo
63 64
 			
64 65
 			list ($charcode) = pg_fetch_row($request);
65 66
 			
66
-			if ($charcode == 'UTF8')			
67
-				return true;
68
-			else
69
-				return false;
67
+			if ($charcode == 'UTF8') {
68
+							return true;
69
+			} else {
70
+							return false;
71
+			}
70 72
 		},
71 73
 		'utf8_version' => '8.0',
72 74
 		'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;',
@@ -74,12 +76,14 @@  discard block
 block discarded – undo
74 76
 			$value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value);
75 77
 
76 78
 			// Is it reserved?
77
-			if ($value == 'pg_')
78
-				return $txt['error_db_prefix_reserved'];
79
+			if ($value == 'pg_') {
80
+							return $txt['error_db_prefix_reserved'];
81
+			}
79 82
 
80 83
 			// Is the prefix numeric?
81
-			if (preg_match('~^\d~', $value))
82
-				return $txt['error_db_prefix_numeric'];
84
+			if (preg_match('~^\d~', $value)) {
85
+							return $txt['error_db_prefix_numeric'];
86
+			}
83 87
 
84 88
 			return true;
85 89
 		},
@@ -126,10 +130,11 @@  discard block
 block discarded – undo
126 130
 		$incontext['skip'] = false;
127 131
 
128 132
 		// Call the step and if it returns false that means pause!
129
-		if (function_exists($step[2]) && $step[2]() === false)
130
-			break;
131
-		elseif (function_exists($step[2]))
132
-			$incontext['current_step']++;
133
+		if (function_exists($step[2]) && $step[2]() === false) {
134
+					break;
135
+		} elseif (function_exists($step[2])) {
136
+					$incontext['current_step']++;
137
+		}
133 138
 
134 139
 		// No warnings pass on.
135 140
 		$incontext['warning'] = '';
@@ -145,12 +150,14 @@  discard block
 block discarded – undo
145 150
 	global $databases, $incontext;
146 151
 
147 152
 	// Just so people using older versions of PHP aren't left in the cold.
148
-	if (!isset($_SERVER['PHP_SELF']))
149
-		$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
153
+	if (!isset($_SERVER['PHP_SELF'])) {
154
+			$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
155
+	}
150 156
 
151 157
 	// Turn off magic quotes runtime and enable error reporting.
152
-	if (function_exists('set_magic_quotes_runtime'))
153
-		@set_magic_quotes_runtime(0);
158
+	if (function_exists('set_magic_quotes_runtime')) {
159
+			@set_magic_quotes_runtime(0);
160
+	}
154 161
 	error_reporting(E_ALL);
155 162
 
156 163
 	// Fun.  Low PHP version...
@@ -164,21 +171,23 @@  discard block
 block discarded – undo
164 171
 	{
165 172
 		ob_start();
166 173
 
167
-		if (ini_get('session.save_handler') == 'user')
168
-			@ini_set('session.save_handler', 'files');
169
-		if (function_exists('session_start'))
170
-			@session_start();
171
-	}
172
-	else
174
+		if (ini_get('session.save_handler') == 'user') {
175
+					@ini_set('session.save_handler', 'files');
176
+		}
177
+		if (function_exists('session_start')) {
178
+					@session_start();
179
+		}
180
+	} else
173 181
 	{
174 182
 		ob_start('ob_gzhandler');
175 183
 
176
-		if (ini_get('session.save_handler') == 'user')
177
-			@ini_set('session.save_handler', 'files');
184
+		if (ini_get('session.save_handler') == 'user') {
185
+					@ini_set('session.save_handler', 'files');
186
+		}
178 187
 		session_start();
179 188
 
180
-		if (!headers_sent())
181
-			echo '<!DOCTYPE html>
189
+		if (!headers_sent()) {
190
+					echo '<!DOCTYPE html>
182 191
 <html>
183 192
 	<head>
184 193
 		<title>', htmlspecialchars($_GET['pass_string']), '</title>
@@ -187,6 +196,7 @@  discard block
 block discarded – undo
187 196
 		<strong>', htmlspecialchars($_GET['pass_string']), '</strong>
188 197
 	</body>
189 198
 </html>';
199
+		}
190 200
 		exit;
191 201
 	}
192 202
 
@@ -195,16 +205,18 @@  discard block
 block discarded – undo
195 205
 	{
196 206
 		$incontext['remote_files_available'] = false;
197 207
 		$test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1);
198
-		if ($test)
199
-			$incontext['remote_files_available'] = true;
208
+		if ($test) {
209
+					$incontext['remote_files_available'] = true;
210
+		}
200 211
 		@fclose($test);
201 212
 	}
202 213
 
203 214
 	// Add slashes, as long as they aren't already being added.
204
-	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0)
205
-		foreach ($_POST as $k => $v)
215
+	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) {
216
+			foreach ($_POST as $k => $v)
206 217
 			if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false)
207 218
 				$_POST[$k] = addslashes($v);
219
+	}
208 220
 
209 221
 	// This is really quite simple; if ?delete is on the URL, delete the installer...
210 222
 	if (isset($_GET['delete']))
@@ -225,8 +237,7 @@  discard block
 block discarded – undo
225 237
 			$ftp->close();
226 238
 
227 239
 			unset($_SESSION['installer_temp_ftp']);
228
-		}
229
-		else
240
+		} else
230 241
 		{
231 242
 			@unlink(__FILE__);
232 243
 
@@ -247,10 +258,11 @@  discard block
 block discarded – undo
247 258
 	{
248 259
 		// Get PHP's default timezone, if set
249 260
 		$ini_tz = ini_get('date.timezone');
250
-		if (!empty($ini_tz))
251
-			$timezone_id = $ini_tz;
252
-		else
253
-			$timezone_id = '';
261
+		if (!empty($ini_tz)) {
262
+					$timezone_id = $ini_tz;
263
+		} else {
264
+					$timezone_id = '';
265
+		}
254 266
 
255 267
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
256 268
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -280,8 +292,9 @@  discard block
 block discarded – undo
280 292
 		$dir = dir(dirname(__FILE__) . '/Themes/default/languages');
281 293
 		while ($entry = $dir->read())
282 294
 		{
283
-			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php')
284
-				$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
295
+			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') {
296
+							$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
297
+			}
285 298
 		}
286 299
 		$dir->close();
287 300
 	}
@@ -316,10 +329,11 @@  discard block
 block discarded – undo
316 329
 	}
317 330
 
318 331
 	// Override the language file?
319
-	if (isset($_GET['lang_file']))
320
-		$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
321
-	elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file']))
322
-		$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
332
+	if (isset($_GET['lang_file'])) {
333
+			$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
334
+	} elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) {
335
+			$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
336
+	}
323 337
 
324 338
 	// Make sure it exists, if it doesn't reset it.
325 339
 	if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang']))
@@ -328,8 +342,9 @@  discard block
 block discarded – undo
328 342
 		list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
329 343
 
330 344
 		// If we have english and some other language, use the other language.  We Americans hate english :P.
331
-		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1)
332
-			list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
345
+		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) {
346
+					list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
347
+		}
333 348
 	}
334 349
 
335 350
 	// And now include the actual language file itself.
@@ -342,15 +357,18 @@  discard block
 block discarded – undo
342 357
 	global $db_prefix, $db_connection, $sourcedir;
343 358
 	global $smcFunc, $modSettings, $db_type, $db_name, $db_user, $db_persist;
344 359
 
345
-	if (empty($sourcedir))
346
-		$sourcedir = dirname(__FILE__) . '/Sources';
360
+	if (empty($sourcedir)) {
361
+			$sourcedir = dirname(__FILE__) . '/Sources';
362
+	}
347 363
 
348 364
 	// Need this to check whether we need the database password.
349 365
 	require(dirname(__FILE__) . '/Settings.php');
350
-	if (!defined('SMF'))
351
-		define('SMF', 1);
352
-	if (empty($smcFunc))
353
-		$smcFunc = array();
366
+	if (!defined('SMF')) {
367
+			define('SMF', 1);
368
+	}
369
+	if (empty($smcFunc)) {
370
+			$smcFunc = array();
371
+	}
354 372
 
355 373
 	$modSettings['disableQueryCheck'] = true;
356 374
 
@@ -358,8 +376,9 @@  discard block
 block discarded – undo
358 376
 	if (!$db_connection)
359 377
 	{
360 378
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
361
-		if (version_compare(PHP_VERSION, '5', '<'))
362
-			require_once($sourcedir . '/Subs-Compat.php');
379
+		if (version_compare(PHP_VERSION, '5', '<')) {
380
+					require_once($sourcedir . '/Subs-Compat.php');
381
+		}
363 382
 
364 383
 		$db_options = array('persist' => $db_persist);
365 384
 		$port = '';
@@ -370,19 +389,20 @@  discard block
 block discarded – undo
370 389
 			if ($db_type == 'mysql')
371 390
 			{
372 391
 				$port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port'];
373
-			}
374
-			elseif ($db_type == 'postgresql')
392
+			} elseif ($db_type == 'postgresql')
375 393
 			{
376 394
 				// PostgreSQL doesn't have a default port setting in php.ini, so just check against the default
377 395
 				$port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port'];
378 396
 			}
379 397
 		}
380 398
 
381
-		if (!empty($port))
382
-			$db_options['port'] = $port;
399
+		if (!empty($port)) {
400
+					$db_options['port'] = $port;
401
+		}
383 402
 
384
-		if (!$db_connection)
385
-			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options);
403
+		if (!$db_connection) {
404
+					$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options);
405
+		}
386 406
 	}
387 407
 }
388 408
 
@@ -410,8 +430,9 @@  discard block
 block discarded – undo
410 430
 		// @todo REMOVE THIS!!
411 431
 		else
412 432
 		{
413
-			if (function_exists('doStep' . $_GET['step']))
414
-				call_user_func('doStep' . $_GET['step']);
433
+			if (function_exists('doStep' . $_GET['step'])) {
434
+							call_user_func('doStep' . $_GET['step']);
435
+			}
415 436
 		}
416 437
 		// Show the footer.
417 438
 		template_install_below();
@@ -429,8 +450,9 @@  discard block
 block discarded – undo
429 450
 	$incontext['sub_template'] = 'welcome_message';
430 451
 
431 452
 	// Done the submission?
432
-	if (isset($_POST['contbutt']))
433
-		return true;
453
+	if (isset($_POST['contbutt'])) {
454
+			return true;
455
+	}
434 456
 
435 457
 	// See if we think they have already installed it?
436 458
 	if (is_readable(dirname(__FILE__) . '/Settings.php'))
@@ -438,14 +460,17 @@  discard block
 block discarded – undo
438 460
 		$probably_installed = 0;
439 461
 		foreach (file(dirname(__FILE__) . '/Settings.php') as $line)
440 462
 		{
441
-			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line))
442
-				$probably_installed++;
443
-			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line))
444
-				$probably_installed++;
463
+			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) {
464
+							$probably_installed++;
465
+			}
466
+			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) {
467
+							$probably_installed++;
468
+			}
445 469
 		}
446 470
 
447
-		if ($probably_installed == 2)
448
-			$incontext['warning'] = $txt['error_already_installed'];
471
+		if ($probably_installed == 2) {
472
+					$incontext['warning'] = $txt['error_already_installed'];
473
+		}
449 474
 	}
450 475
 
451 476
 	// Is some database support even compiled in?
@@ -460,36 +485,43 @@  discard block
 block discarded – undo
460 485
 				$databases[$key]['supported'] = false;
461 486
 				$notFoundSQLFile = true;
462 487
 				$txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql');
488
+			} else {
489
+							$incontext['supported_databases'][] = $db;
463 490
 			}
464
-			else
465
-				$incontext['supported_databases'][] = $db;
466 491
 		}
467 492
 	}
468 493
 
469 494
 	// Check the PHP version.
470
-	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>')))
471
-		$error = 'error_php_too_low';
495
+	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>'))) {
496
+			$error = 'error_php_too_low';
497
+	}
472 498
 	// Make sure we have a supported database
473
-	elseif (empty($incontext['supported_databases']))
474
-		$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
499
+	elseif (empty($incontext['supported_databases'])) {
500
+			$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
501
+	}
475 502
 	// How about session support?  Some crazy sysadmin remove it?
476
-	elseif (!function_exists('session_start'))
477
-		$error = 'error_session_missing';
503
+	elseif (!function_exists('session_start')) {
504
+			$error = 'error_session_missing';
505
+	}
478 506
 	// Make sure they uploaded all the files.
479
-	elseif (!file_exists(dirname(__FILE__) . '/index.php'))
480
-		$error = 'error_missing_files';
507
+	elseif (!file_exists(dirname(__FILE__) . '/index.php')) {
508
+			$error = 'error_missing_files';
509
+	}
481 510
 	// Very simple check on the session.save_path for Windows.
482 511
 	// @todo Move this down later if they don't use database-driven sessions?
483
-	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\')
484
-		$error = 'error_session_save_path';
512
+	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') {
513
+			$error = 'error_session_save_path';
514
+	}
485 515
 
486 516
 	// Since each of the three messages would look the same, anyway...
487
-	if (isset($error))
488
-		$incontext['error'] = $txt[$error];
517
+	if (isset($error)) {
518
+			$incontext['error'] = $txt[$error];
519
+	}
489 520
 
490 521
 	// Mod_security blocks everything that smells funny. Let SMF handle security.
491
-	if (!fixModSecurity() && !isset($_GET['overmodsecurity']))
492
-		$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
522
+	if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) {
523
+			$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
524
+	}
493 525
 
494 526
 	return false;
495 527
 }
@@ -515,12 +547,14 @@  discard block
 block discarded – undo
515 547
 		'db_last_error.php',
516 548
 	);
517 549
 
518
-	foreach ($incontext['detected_languages'] as $lang => $temp)
519
-		$extra_files[] = 'Themes/default/languages/' . $lang;
550
+	foreach ($incontext['detected_languages'] as $lang => $temp) {
551
+			$extra_files[] = 'Themes/default/languages/' . $lang;
552
+	}
520 553
 
521 554
 	// With mod_security installed, we could attempt to fix it with .htaccess.
522
-	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules()))
523
-		$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
555
+	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) {
556
+			$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
557
+	}
524 558
 
525 559
 	$failed_files = array();
526 560
 
@@ -536,12 +570,14 @@  discard block
 block discarded – undo
536 570
 				@chmod(dirname(__FILE__) . '/' . $file, 0755);
537 571
 
538 572
 				// Well, 755 hopefully worked... if not, try 777.
539
-				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777))
540
-					$failed_files[] = $file;
573
+				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) {
574
+									$failed_files[] = $file;
575
+				}
541 576
 			}
542 577
 		}
543
-		foreach ($extra_files as $file)
544
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
578
+		foreach ($extra_files as $file) {
579
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
580
+		}
545 581
 	}
546 582
 	// Windows is trickier.  Let's try opening for r+...
547 583
 	else
@@ -551,30 +587,35 @@  discard block
 block discarded – undo
551 587
 		foreach ($writable_files as $file)
552 588
 		{
553 589
 			// Folders can't be opened for write... but the index.php in them can ;)
554
-			if (is_dir(dirname(__FILE__) . '/' . $file))
555
-				$file .= '/index.php';
590
+			if (is_dir(dirname(__FILE__) . '/' . $file)) {
591
+							$file .= '/index.php';
592
+			}
556 593
 
557 594
 			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
558 595
 			@chmod(dirname(__FILE__) . '/' . $file, 0777);
559 596
 			$fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+');
560 597
 
561 598
 			// Hmm, okay, try just for write in that case...
562
-			if (!is_resource($fp))
563
-				$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
599
+			if (!is_resource($fp)) {
600
+							$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
601
+			}
564 602
 
565
-			if (!is_resource($fp))
566
-				$failed_files[] = $file;
603
+			if (!is_resource($fp)) {
604
+							$failed_files[] = $file;
605
+			}
567 606
 
568 607
 			@fclose($fp);
569 608
 		}
570
-		foreach ($extra_files as $file)
571
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
609
+		foreach ($extra_files as $file) {
610
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
611
+		}
572 612
 	}
573 613
 
574 614
 	$failure = count($failed_files) >= 1;
575 615
 
576
-	if (!isset($_SERVER))
577
-		return !$failure;
616
+	if (!isset($_SERVER)) {
617
+			return !$failure;
618
+	}
578 619
 
579 620
 	// Put the list into context.
580 621
 	$incontext['failed_files'] = $failed_files;
@@ -622,19 +663,23 @@  discard block
 block discarded – undo
622 663
 
623 664
 		if (!isset($ftp) || $ftp->error !== false)
624 665
 		{
625
-			if (!isset($ftp))
626
-				$ftp = new ftp_connection(null);
666
+			if (!isset($ftp)) {
667
+							$ftp = new ftp_connection(null);
668
+			}
627 669
 			// Save the error so we can mess with listing...
628
-			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message))
629
-				$incontext['ftp_errors'][] = $ftp->last_message;
670
+			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) {
671
+							$incontext['ftp_errors'][] = $ftp->last_message;
672
+			}
630 673
 
631 674
 			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
632 675
 
633
-			if (empty($_POST['ftp_path']) && $found_path)
634
-				$_POST['ftp_path'] = $detect_path;
676
+			if (empty($_POST['ftp_path']) && $found_path) {
677
+							$_POST['ftp_path'] = $detect_path;
678
+			}
635 679
 
636
-			if (!isset($_POST['ftp_username']))
637
-				$_POST['ftp_username'] = $username;
680
+			if (!isset($_POST['ftp_username'])) {
681
+							$_POST['ftp_username'] = $username;
682
+			}
638 683
 
639 684
 			// Set the username etc, into context.
640 685
 			$incontext['ftp'] = array(
@@ -646,8 +691,7 @@  discard block
 block discarded – undo
646 691
 			);
647 692
 
648 693
 			return false;
649
-		}
650
-		else
694
+		} else
651 695
 		{
652 696
 			$_SESSION['installer_temp_ftp'] = array(
653 697
 				'server' => $_POST['ftp_server'],
@@ -661,10 +705,12 @@  discard block
 block discarded – undo
661 705
 
662 706
 			foreach ($failed_files as $file)
663 707
 			{
664
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
665
-					$ftp->chmod($file, 0755);
666
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
667
-					$ftp->chmod($file, 0777);
708
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
709
+									$ftp->chmod($file, 0755);
710
+				}
711
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
712
+									$ftp->chmod($file, 0777);
713
+				}
668 714
 				if (!is_writable(dirname(__FILE__) . '/' . $file))
669 715
 				{
670 716
 					$failed_files_updated[] = $file;
@@ -719,15 +765,17 @@  discard block
 block discarded – undo
719 765
 
720 766
 			if (!$foundOne)
721 767
 			{
722
-				if (isset($db['default_host']))
723
-					$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
768
+				if (isset($db['default_host'])) {
769
+									$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
770
+				}
724 771
 				if (isset($db['default_user']))
725 772
 				{
726 773
 					$incontext['db']['user'] = ini_get($db['default_user']);
727 774
 					$incontext['db']['name'] = ini_get($db['default_user']);
728 775
 				}
729
-				if (isset($db['default_password']))
730
-					$incontext['db']['pass'] = ini_get($db['default_password']);
776
+				if (isset($db['default_password'])) {
777
+									$incontext['db']['pass'] = ini_get($db['default_password']);
778
+				}
731 779
 
732 780
 				// For simplicity and less confusion, leave the port blank by default
733 781
 				$incontext['db']['port'] = '';
@@ -746,10 +794,10 @@  discard block
 block discarded – undo
746 794
 		$incontext['db']['server'] = $_POST['db_server'];
747 795
 		$incontext['db']['prefix'] = $_POST['db_prefix'];
748 796
 
749
-		if (!empty($_POST['db_port']))
750
-			$incontext['db']['port'] = $_POST['db_port'];
751
-	}
752
-	else
797
+		if (!empty($_POST['db_port'])) {
798
+					$incontext['db']['port'] = $_POST['db_port'];
799
+		}
800
+	} else
753 801
 	{
754 802
 		$incontext['db']['prefix'] = 'smf_';
755 803
 	}
@@ -785,10 +833,11 @@  discard block
 block discarded – undo
785 833
 		if (!empty($_POST['db_port']))
786 834
 		{
787 835
 			// For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though.
788
-			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port'))
789
-				$vars['db_port'] = (int) $_POST['db_port'];
790
-			elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432)
791
-				$vars['db_port'] = (int) $_POST['db_port'];
836
+			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) {
837
+							$vars['db_port'] = (int) $_POST['db_port'];
838
+			} elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) {
839
+							$vars['db_port'] = (int) $_POST['db_port'];
840
+			}
792 841
 		}
793 842
 
794 843
 		// God I hope it saved!
@@ -801,8 +850,9 @@  discard block
 block discarded – undo
801 850
 		// Make sure it works.
802 851
 		require(dirname(__FILE__) . '/Settings.php');
803 852
 
804
-		if (empty($sourcedir))
805
-			$sourcedir = dirname(__FILE__) . '/Sources';
853
+		if (empty($sourcedir)) {
854
+					$sourcedir = dirname(__FILE__) . '/Sources';
855
+		}
806 856
 
807 857
 		// Better find the database file!
808 858
 		if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
@@ -812,18 +862,21 @@  discard block
 block discarded – undo
812 862
 		}
813 863
 
814 864
 		// Now include it for database functions!
815
-		if (!defined('SMF'))
816
-			define('SMF', 1);
865
+		if (!defined('SMF')) {
866
+					define('SMF', 1);
867
+		}
817 868
 
818 869
 		$modSettings['disableQueryCheck'] = true;
819
-		if (empty($smcFunc))
820
-			$smcFunc = array();
870
+		if (empty($smcFunc)) {
871
+					$smcFunc = array();
872
+		}
821 873
 
822 874
 			require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
823 875
 
824 876
 		// What - running PHP4? The shame!
825
-		if (version_compare(PHP_VERSION, '5', '<'))
826
-			require_once($sourcedir . '/Subs-Compat.php');
877
+		if (version_compare(PHP_VERSION, '5', '<')) {
878
+					require_once($sourcedir . '/Subs-Compat.php');
879
+		}
827 880
 
828 881
 		// Attempt a connection.
829 882
 		$needsDB = !empty($databases[$db_type]['always_has_db']);
@@ -911,12 +964,14 @@  discard block
 block discarded – undo
911 964
 	$incontext['page_title'] = $txt['install_settings'];
912 965
 
913 966
 	// Let's see if we got the database type correct.
914
-	if (isset($_POST['db_type'], $databases[$_POST['db_type']]))
915
-		$db_type = $_POST['db_type'];
967
+	if (isset($_POST['db_type'], $databases[$_POST['db_type']])) {
968
+			$db_type = $_POST['db_type'];
969
+	}
916 970
 
917 971
 	// Else we'd better be able to get the connection.
918
-	else
919
-		load_database();
972
+	else {
973
+			load_database();
974
+	}
920 975
 
921 976
 	$db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type;
922 977
 
@@ -936,12 +991,14 @@  discard block
 block discarded – undo
936 991
 	// Submitting?
937 992
 	if (isset($_POST['boardurl']))
938 993
 	{
939
-		if (substr($_POST['boardurl'], -10) == '/index.php')
940
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
941
-		elseif (substr($_POST['boardurl'], -1) == '/')
942
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
943
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
944
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
994
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
995
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
996
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
997
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
998
+		}
999
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
1000
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1001
+		}
945 1002
 
946 1003
 		// Save these variables.
947 1004
 		$vars = array(
@@ -978,10 +1035,10 @@  discard block
 block discarded – undo
978 1035
 			{
979 1036
 				$incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']);
980 1037
 				return false;
981
-			}
982
-			else
983
-				// Set the character set here.
1038
+			} else {
1039
+							// Set the character set here.
984 1040
 				updateSettingsFile(array('db_character_set' => 'utf8'));
1041
+			}
985 1042
 		}
986 1043
 
987 1044
 		// Good, skip on.
@@ -1001,8 +1058,9 @@  discard block
 block discarded – undo
1001 1058
 	$incontext['continue'] = 1;
1002 1059
 
1003 1060
 	// Already done?
1004
-	if (isset($_POST['pop_done']))
1005
-		return true;
1061
+	if (isset($_POST['pop_done'])) {
1062
+			return true;
1063
+	}
1006 1064
 
1007 1065
 	// Reload settings.
1008 1066
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1020,8 +1078,9 @@  discard block
 block discarded – undo
1020 1078
 	$modSettings = array();
1021 1079
 	if ($result !== false)
1022 1080
 	{
1023
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1024
-			$modSettings[$row['variable']] = $row['value'];
1081
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1082
+					$modSettings[$row['variable']] = $row['value'];
1083
+		}
1025 1084
 		$smcFunc['db_free_result']($result);
1026 1085
 
1027 1086
 		// Do they match?  If so, this is just a refresh so charge on!
@@ -1034,20 +1093,22 @@  discard block
 block discarded – undo
1034 1093
 	$modSettings['disableQueryCheck'] = true;
1035 1094
 
1036 1095
 	// If doing UTF8, select it. PostgreSQL requires passing it as a string...
1037
-	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support']))
1038
-		$smcFunc['db_query']('', '
1096
+	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) {
1097
+			$smcFunc['db_query']('', '
1039 1098
 			SET NAMES {string:utf8}',
1040 1099
 			array(
1041 1100
 				'db_error_skip' => true,
1042 1101
 				'utf8' => 'utf8',
1043 1102
 			)
1044 1103
 		);
1104
+	}
1045 1105
 
1046 1106
 	// Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments...
1047
-	if (substr(__DIR__, -1) == '\\')
1048
-		$attachdir = __DIR__ . 'attachments';
1049
-	else
1050
-		$attachdir = __DIR__ . '/attachments';
1107
+	if (substr(__DIR__, -1) == '\\') {
1108
+			$attachdir = __DIR__ . 'attachments';
1109
+	} else {
1110
+			$attachdir = __DIR__ . '/attachments';
1111
+	}
1051 1112
 
1052 1113
 	$replaces = array(
1053 1114
 		'{$db_prefix}' => $db_prefix,
@@ -1064,8 +1125,9 @@  discard block
 block discarded – undo
1064 1125
 
1065 1126
 	foreach ($txt as $key => $value)
1066 1127
 	{
1067
-		if (substr($key, 0, 8) == 'default_')
1068
-			$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1128
+		if (substr($key, 0, 8) == 'default_') {
1129
+					$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1130
+		}
1069 1131
 	}
1070 1132
 	$replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n'));
1071 1133
 
@@ -1080,8 +1142,9 @@  discard block
 block discarded – undo
1080 1142
 
1081 1143
 		while ($row = $smcFunc['db_fetch_assoc']($get_engines))
1082 1144
 		{
1083
-			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT')
1084
-				$engines[] = $row['Engine'];
1145
+			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') {
1146
+							$engines[] = $row['Engine'];
1147
+			}
1085 1148
 		}
1086 1149
 
1087 1150
 		// Done with this now
@@ -1105,8 +1168,7 @@  discard block
 block discarded – undo
1105 1168
 			$replaces['START TRANSACTION;'] = '';
1106 1169
 			$replaces['COMMIT;'] = '';
1107 1170
 		}
1108
-	}
1109
-	else
1171
+	} else
1110 1172
 	{
1111 1173
 		$has_innodb = false;
1112 1174
 	}
@@ -1128,21 +1190,24 @@  discard block
 block discarded – undo
1128 1190
 	foreach ($sql_lines as $count => $line)
1129 1191
 	{
1130 1192
 		// No comments allowed!
1131
-		if (substr(trim($line), 0, 1) != '#')
1132
-			$current_statement .= "\n" . rtrim($line);
1193
+		if (substr(trim($line), 0, 1) != '#') {
1194
+					$current_statement .= "\n" . rtrim($line);
1195
+		}
1133 1196
 
1134 1197
 		// Is this the end of the query string?
1135
-		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines)))
1136
-			continue;
1198
+		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) {
1199
+					continue;
1200
+		}
1137 1201
 
1138 1202
 		// Does this table already exist?  If so, don't insert more data into it!
1139 1203
 		if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists))
1140 1204
 		{
1141 1205
 			preg_match_all('~\)[,;]~', $current_statement, $matches);
1142
-			if (!empty($matches[0]))
1143
-				$incontext['sql_results']['insert_dups'] += count($matches[0]);
1144
-			else
1145
-				$incontext['sql_results']['insert_dups']++;
1206
+			if (!empty($matches[0])) {
1207
+							$incontext['sql_results']['insert_dups'] += count($matches[0]);
1208
+			} else {
1209
+							$incontext['sql_results']['insert_dups']++;
1210
+			}
1146 1211
 
1147 1212
 			$current_statement = '';
1148 1213
 			continue;
@@ -1151,8 +1216,9 @@  discard block
 block discarded – undo
1151 1216
 		if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false)
1152 1217
 		{
1153 1218
 			// Use the appropriate function based on the DB type
1154
-			if ($db_type == 'mysql' || $db_type == 'mysqli')
1155
-				$db_errorno = $db_type . '_errno';
1219
+			if ($db_type == 'mysql' || $db_type == 'mysqli') {
1220
+							$db_errorno = $db_type . '_errno';
1221
+			}
1156 1222
 
1157 1223
 			// Error 1050: Table already exists!
1158 1224
 			// @todo Needs to be made better!
@@ -1167,18 +1233,18 @@  discard block
 block discarded – undo
1167 1233
 				// MySQLi requires a connection object. It's optional with MySQL and Postgres
1168 1234
 				$incontext['failures'][$count] = $smcFunc['db_error']($db_connection);
1169 1235
 			}
1170
-		}
1171
-		else
1236
+		} else
1172 1237
 		{
1173
-			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1174
-				$incontext['sql_results']['tables']++;
1175
-			elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1238
+			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) {
1239
+							$incontext['sql_results']['tables']++;
1240
+			} elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1176 1241
 			{
1177 1242
 				preg_match_all('~\)[,;]~', $current_statement, $matches);
1178
-				if (!empty($matches[0]))
1179
-					$incontext['sql_results']['inserts'] += count($matches[0]);
1180
-				else
1181
-					$incontext['sql_results']['inserts']++;
1243
+				if (!empty($matches[0])) {
1244
+									$incontext['sql_results']['inserts'] += count($matches[0]);
1245
+				} else {
1246
+									$incontext['sql_results']['inserts']++;
1247
+				}
1182 1248
 			}
1183 1249
 		}
1184 1250
 
@@ -1191,15 +1257,17 @@  discard block
 block discarded – undo
1191 1257
 	// Sort out the context for the SQL.
1192 1258
 	foreach ($incontext['sql_results'] as $key => $number)
1193 1259
 	{
1194
-		if ($number == 0)
1195
-			unset($incontext['sql_results'][$key]);
1196
-		else
1197
-			$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1260
+		if ($number == 0) {
1261
+					unset($incontext['sql_results'][$key]);
1262
+		} else {
1263
+					$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1264
+		}
1198 1265
 	}
1199 1266
 
1200 1267
 	// Make sure UTF will be used globally.
1201
-	if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8'])))
1202
-		$newSettings[] = array('global_character_set', 'UTF-8');
1268
+	if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) {
1269
+			$newSettings[] = array('global_character_set', 'UTF-8');
1270
+	}
1203 1271
 
1204 1272
 	// Maybe we can auto-detect better cookie settings?
1205 1273
 	preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches);
@@ -1210,16 +1278,20 @@  discard block
 block discarded – undo
1210 1278
 		$globalCookies = false;
1211 1279
 
1212 1280
 		// Okay... let's see.  Using a subdomain other than www.? (not a perfect check.)
1213
-		if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www'))))
1214
-			$globalCookies = true;
1281
+		if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) {
1282
+					$globalCookies = true;
1283
+		}
1215 1284
 		// If there's a / in the middle of the path, or it starts with ~... we want local.
1216
-		if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false))
1217
-			$localCookies = true;
1285
+		if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) {
1286
+					$localCookies = true;
1287
+		}
1218 1288
 
1219
-		if ($globalCookies)
1220
-			$newSettings[] = array('globalCookies', '1');
1221
-		if ($localCookies)
1222
-			$newSettings[] = array('localCookies', '1');
1289
+		if ($globalCookies) {
1290
+					$newSettings[] = array('globalCookies', '1');
1291
+		}
1292
+		if ($localCookies) {
1293
+					$newSettings[] = array('localCookies', '1');
1294
+		}
1223 1295
 	}
1224 1296
 
1225 1297
 	// Are we allowing stat collection?
@@ -1235,32 +1307,36 @@  discard block
 block discarded – undo
1235 1307
 			fwrite($fp, $out);
1236 1308
 
1237 1309
 			$return_data = '';
1238
-			while (!feof($fp))
1239
-				$return_data .= fgets($fp, 128);
1310
+			while (!feof($fp)) {
1311
+							$return_data .= fgets($fp, 128);
1312
+			}
1240 1313
 
1241 1314
 			fclose($fp);
1242 1315
 
1243 1316
 			// Get the unique site ID.
1244 1317
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1245 1318
 
1246
-			if (!empty($ID[1]))
1247
-				$newSettings[] = array('allow_sm_stats', $ID[1]);
1319
+			if (!empty($ID[1])) {
1320
+							$newSettings[] = array('allow_sm_stats', $ID[1]);
1321
+			}
1248 1322
 		}
1249 1323
 	}
1250 1324
 
1251 1325
 	// Are we enabling SSL?
1252
-	if (!empty($_POST['force_ssl']))
1253
-		$newSettings[] = array('force_ssl', 2);
1326
+	if (!empty($_POST['force_ssl'])) {
1327
+			$newSettings[] = array('force_ssl', 2);
1328
+	}
1254 1329
 
1255 1330
 	// Setting a timezone is required.
1256 1331
 	if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set'))
1257 1332
 	{
1258 1333
 		// Get PHP's default timezone, if set
1259 1334
 		$ini_tz = ini_get('date.timezone');
1260
-		if (!empty($ini_tz))
1261
-			$timezone_id = $ini_tz;
1262
-		else
1263
-			$timezone_id = '';
1335
+		if (!empty($ini_tz)) {
1336
+					$timezone_id = $ini_tz;
1337
+		} else {
1338
+					$timezone_id = '';
1339
+		}
1264 1340
 
1265 1341
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
1266 1342
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -1269,8 +1345,9 @@  discard block
 block discarded – undo
1269 1345
 			$timezone_id = timezone_name_from_abbr('', $server_offset, 0);
1270 1346
 		}
1271 1347
 
1272
-		if (date_default_timezone_set($timezone_id))
1273
-			$newSettings[] = array('default_timezone', $timezone_id);
1348
+		if (date_default_timezone_set($timezone_id)) {
1349
+					$newSettings[] = array('default_timezone', $timezone_id);
1350
+		}
1274 1351
 	}
1275 1352
 
1276 1353
 	if (!empty($newSettings))
@@ -1301,16 +1378,18 @@  discard block
 block discarded – undo
1301 1378
 	}
1302 1379
 
1303 1380
 	// MySQL specific stuff
1304
-	if (substr($db_type, 0, 5) != 'mysql')
1305
-		return false;
1381
+	if (substr($db_type, 0, 5) != 'mysql') {
1382
+			return false;
1383
+	}
1306 1384
 
1307 1385
 	// Find database user privileges.
1308 1386
 	$privs = array();
1309 1387
 	$get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array());
1310 1388
 	while ($row = $smcFunc['db_fetch_assoc']($get_privs))
1311 1389
 	{
1312
-		if ($row['Privilege'] == 'Alter')
1313
-			$privs[] = $row['Privilege'];
1390
+		if ($row['Privilege'] == 'Alter') {
1391
+					$privs[] = $row['Privilege'];
1392
+		}
1314 1393
 	}
1315 1394
 	$smcFunc['db_free_result']($get_privs);
1316 1395
 
@@ -1340,8 +1419,9 @@  discard block
 block discarded – undo
1340 1419
 	$incontext['continue'] = 1;
1341 1420
 
1342 1421
 	// Skipping?
1343
-	if (!empty($_POST['skip']))
1344
-		return true;
1422
+	if (!empty($_POST['skip'])) {
1423
+			return true;
1424
+	}
1345 1425
 
1346 1426
 	// Need this to check whether we need the database password.
1347 1427
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1354,18 +1434,22 @@  discard block
 block discarded – undo
1354 1434
 	// We need this to properly hash the password for Admin
1355 1435
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) {
1356 1436
 			global $sourcedir;
1357
-			if (function_exists('mb_strtolower'))
1358
-				return mb_strtolower($string, 'UTF-8');
1437
+			if (function_exists('mb_strtolower')) {
1438
+							return mb_strtolower($string, 'UTF-8');
1439
+			}
1359 1440
 			require_once($sourcedir . '/Subs-Charset.php');
1360 1441
 			return utf8_strtolower($string);
1361 1442
 		};
1362 1443
 
1363
-	if (!isset($_POST['username']))
1364
-		$_POST['username'] = '';
1365
-	if (!isset($_POST['email']))
1366
-		$_POST['email'] = '';
1367
-	if (!isset($_POST['server_email']))
1368
-		$_POST['server_email'] = '';
1444
+	if (!isset($_POST['username'])) {
1445
+			$_POST['username'] = '';
1446
+	}
1447
+	if (!isset($_POST['email'])) {
1448
+			$_POST['email'] = '';
1449
+	}
1450
+	if (!isset($_POST['server_email'])) {
1451
+			$_POST['server_email'] = '';
1452
+	}
1369 1453
 
1370 1454
 	$incontext['username'] = htmlspecialchars(stripslashes($_POST['username']));
1371 1455
 	$incontext['email'] = htmlspecialchars(stripslashes($_POST['email']));
@@ -1384,8 +1468,9 @@  discard block
 block discarded – undo
1384 1468
 			'admin_group' => 1,
1385 1469
 		)
1386 1470
 	);
1387
-	if ($smcFunc['db_num_rows']($request) != 0)
1388
-		$incontext['skip'] = 1;
1471
+	if ($smcFunc['db_num_rows']($request) != 0) {
1472
+			$incontext['skip'] = 1;
1473
+	}
1389 1474
 	$smcFunc['db_free_result']($request);
1390 1475
 
1391 1476
 	// Trying to create an account?
@@ -1416,8 +1501,9 @@  discard block
 block discarded – undo
1416 1501
 		}
1417 1502
 
1418 1503
 		// Update the webmaster's email?
1419
-		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]'))
1420
-			updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1504
+		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) {
1505
+					updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1506
+		}
1421 1507
 
1422 1508
 		// Work out whether we're going to have dodgy characters and remove them.
1423 1509
 		$invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0;
@@ -1440,32 +1526,27 @@  discard block
 block discarded – undo
1440 1526
 			$smcFunc['db_free_result']($result);
1441 1527
 
1442 1528
 			$incontext['account_existed'] = $txt['error_user_settings_taken'];
1443
-		}
1444
-		elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1529
+		} elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1445 1530
 		{
1446 1531
 			// Try the previous step again.
1447 1532
 			$incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long'];
1448 1533
 			return false;
1449
-		}
1450
-		elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1534
+		} elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1451 1535
 		{
1452 1536
 			// Try the previous step again.
1453 1537
 			$incontext['error'] = $txt['error_invalid_characters_username'];
1454 1538
 			return false;
1455
-		}
1456
-		elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1539
+		} elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1457 1540
 		{
1458 1541
 			// One step back, this time fill out a proper admin email address.
1459 1542
 			$incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']);
1460 1543
 			return false;
1461
-		}
1462
-		elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1544
+		} elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1463 1545
 		{
1464 1546
 			// One step back, this time fill out a proper admin email address.
1465 1547
 			$incontext['error'] = $txt['error_valid_server_email_needed'];
1466 1548
 			return false;
1467
-		}
1468
-		elseif ($_POST['username'] != '')
1549
+		} elseif ($_POST['username'] != '')
1469 1550
 		{
1470 1551
 			$incontext['member_salt'] = substr(md5(mt_rand()), 0, 4);
1471 1552
 
@@ -1531,17 +1612,19 @@  discard block
 block discarded – undo
1531 1612
 	require_once($sourcedir . '/Subs-Auth.php');
1532 1613
 
1533 1614
 	// Bring a warning over.
1534
-	if (!empty($incontext['account_existed']))
1535
-		$incontext['warning'] = $incontext['account_existed'];
1615
+	if (!empty($incontext['account_existed'])) {
1616
+			$incontext['warning'] = $incontext['account_existed'];
1617
+	}
1536 1618
 
1537
-	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support']))
1538
-		$smcFunc['db_query']('', '
1619
+	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) {
1620
+			$smcFunc['db_query']('', '
1539 1621
 			SET NAMES {string:db_character_set}',
1540 1622
 			array(
1541 1623
 				'db_character_set' => $db_character_set,
1542 1624
 				'db_error_skip' => true,
1543 1625
 			)
1544 1626
 		);
1627
+	}
1545 1628
 
1546 1629
 	// As track stats is by default enabled let's add some activity.
1547 1630
 	$smcFunc['db_insert']('ignore',
@@ -1562,14 +1645,16 @@  discard block
 block discarded – undo
1562 1645
 	// Only proceed if we can load the data.
1563 1646
 	if ($request)
1564 1647
 	{
1565
-		while ($row = $smcFunc['db_fetch_row']($request))
1566
-			$modSettings[$row[0]] = $row[1];
1648
+		while ($row = $smcFunc['db_fetch_row']($request)) {
1649
+					$modSettings[$row[0]] = $row[1];
1650
+		}
1567 1651
 		$smcFunc['db_free_result']($request);
1568 1652
 	}
1569 1653
 
1570 1654
 	// Automatically log them in ;)
1571
-	if (isset($incontext['member_id']) && isset($incontext['member_salt']))
1572
-		setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1655
+	if (isset($incontext['member_id']) && isset($incontext['member_salt'])) {
1656
+			setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1657
+	}
1573 1658
 
1574 1659
 	$result = $smcFunc['db_query']('', '
1575 1660
 		SELECT value
@@ -1580,13 +1665,14 @@  discard block
 block discarded – undo
1580 1665
 			'db_error_skip' => true,
1581 1666
 		)
1582 1667
 	);
1583
-	if ($smcFunc['db_num_rows']($result) != 0)
1584
-		list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1668
+	if ($smcFunc['db_num_rows']($result) != 0) {
1669
+			list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1670
+	}
1585 1671
 	$smcFunc['db_free_result']($result);
1586 1672
 
1587
-	if (empty($db_sessions))
1588
-		$_SESSION['admin_time'] = time();
1589
-	else
1673
+	if (empty($db_sessions)) {
1674
+			$_SESSION['admin_time'] = time();
1675
+	} else
1590 1676
 	{
1591 1677
 		$_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211);
1592 1678
 
@@ -1610,8 +1696,9 @@  discard block
 block discarded – undo
1610 1696
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1611 1697
 		function($string){
1612 1698
 			global $sourcedir;
1613
-			if (function_exists('mb_strtolower'))
1614
-				return mb_strtolower($string, 'UTF-8');
1699
+			if (function_exists('mb_strtolower')) {
1700
+							return mb_strtolower($string, 'UTF-8');
1701
+			}
1615 1702
 			require_once($sourcedir . '/Subs-Charset.php');
1616 1703
 			return utf8_strtolower($string);
1617 1704
 		};
@@ -1627,8 +1714,9 @@  discard block
 block discarded – undo
1627 1714
 		)
1628 1715
 	);
1629 1716
 	$context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8';
1630
-	if ($smcFunc['db_num_rows']($request) > 0)
1631
-		updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1717
+	if ($smcFunc['db_num_rows']($request) > 0) {
1718
+			updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1719
+	}
1632 1720
 	$smcFunc['db_free_result']($request);
1633 1721
 
1634 1722
 	// Now is the perfect time to fetch the SM files.
@@ -1647,8 +1735,9 @@  discard block
 block discarded – undo
1647 1735
 
1648 1736
 	// Check if we need some stupid MySQL fix.
1649 1737
 	$server_version = $smcFunc['db_server_info']();
1650
-	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1651
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1738
+	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1739
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1740
+	}
1652 1741
 
1653 1742
 	// Some final context for the template.
1654 1743
 	$incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\';
@@ -1668,8 +1757,9 @@  discard block
 block discarded – undo
1668 1757
 	$settingsArray = file(dirname(__FILE__) . '/Settings.php');
1669 1758
 
1670 1759
 	// @todo Do we just want to read the file in clean, and split it this way always?
1671
-	if (count($settingsArray) == 1)
1672
-		$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1760
+	if (count($settingsArray) == 1) {
1761
+			$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1762
+	}
1673 1763
 
1674 1764
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
1675 1765
 	{
@@ -1684,19 +1774,22 @@  discard block
 block discarded – undo
1684 1774
 			continue;
1685 1775
 		}
1686 1776
 
1687
-		if (trim($settingsArray[$i]) == '?' . '>')
1688
-			$settingsArray[$i] = '';
1777
+		if (trim($settingsArray[$i]) == '?' . '>') {
1778
+					$settingsArray[$i] = '';
1779
+		}
1689 1780
 
1690 1781
 		// Don't trim or bother with it if it's not a variable.
1691
-		if (substr($settingsArray[$i], 0, 1) != '$')
1692
-			continue;
1782
+		if (substr($settingsArray[$i], 0, 1) != '$') {
1783
+					continue;
1784
+		}
1693 1785
 
1694 1786
 		$settingsArray[$i] = rtrim($settingsArray[$i]) . "\n";
1695 1787
 
1696
-		foreach ($vars as $var => $val)
1697
-			if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1788
+		foreach ($vars as $var => $val) {
1789
+					if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1698 1790
 			{
1699 1791
 				$comment = strstr($settingsArray[$i], '#');
1792
+		}
1700 1793
 				$settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n");
1701 1794
 				unset($vars[$var]);
1702 1795
 			}
@@ -1706,36 +1799,41 @@  discard block
 block discarded – undo
1706 1799
 	if (!empty($vars))
1707 1800
 	{
1708 1801
 		$settingsArray[$i++] = '';
1709
-		foreach ($vars as $var => $val)
1710
-			$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1802
+		foreach ($vars as $var => $val) {
1803
+					$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1804
+		}
1711 1805
 	}
1712 1806
 
1713 1807
 	// Blank out the file - done to fix a oddity with some servers.
1714 1808
 	$fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w');
1715
-	if (!$fp)
1716
-		return false;
1809
+	if (!$fp) {
1810
+			return false;
1811
+	}
1717 1812
 	fclose($fp);
1718 1813
 
1719 1814
 	$fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+');
1720 1815
 
1721 1816
 	// Gotta have one of these ;)
1722
-	if (trim($settingsArray[0]) != '<?php')
1723
-		fwrite($fp, "<?php\n");
1817
+	if (trim($settingsArray[0]) != '<?php') {
1818
+			fwrite($fp, "<?php\n");
1819
+	}
1724 1820
 
1725 1821
 	$lines = count($settingsArray);
1726 1822
 	for ($i = 0; $i < $lines - 1; $i++)
1727 1823
 	{
1728 1824
 		// Don't just write a bunch of blank lines.
1729
-		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '')
1730
-			fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1825
+		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') {
1826
+					fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1827
+		}
1731 1828
 	}
1732 1829
 	fwrite($fp, $settingsArray[$i] . '?' . '>');
1733 1830
 	fclose($fp);
1734 1831
 
1735 1832
 	// Even though on normal installations the filemtime should prevent this being used by the installer incorrectly
1736 1833
 	// it seems that there are times it might not. So let's MAKE it dump the cache.
1737
-	if (function_exists('opcache_invalidate'))
1738
-		opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1834
+	if (function_exists('opcache_invalidate')) {
1835
+			opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1836
+	}
1739 1837
 
1740 1838
 	return true;
1741 1839
 }
@@ -1760,9 +1858,9 @@  discard block
 block discarded – undo
1760 1858
 	SecFilterScanPOST Off
1761 1859
 </IfModule>';
1762 1860
 
1763
-	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules()))
1764
-		return true;
1765
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1861
+	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) {
1862
+			return true;
1863
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1766 1864
 	{
1767 1865
 		$current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess'));
1768 1866
 
@@ -1774,29 +1872,28 @@  discard block
 block discarded – undo
1774 1872
 				fwrite($ht_handle, $htaccess_addition);
1775 1873
 				fclose($ht_handle);
1776 1874
 				return true;
1875
+			} else {
1876
+							return false;
1777 1877
 			}
1778
-			else
1779
-				return false;
1878
+		} else {
1879
+					return true;
1780 1880
 		}
1781
-		else
1782
-			return true;
1783
-	}
1784
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess'))
1785
-		return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1786
-	elseif (is_writable(dirname(__FILE__)))
1881
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess')) {
1882
+			return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1883
+	} elseif (is_writable(dirname(__FILE__)))
1787 1884
 	{
1788 1885
 		if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w'))
1789 1886
 		{
1790 1887
 			fwrite($ht_handle, $htaccess_addition);
1791 1888
 			fclose($ht_handle);
1792 1889
 			return true;
1890
+		} else {
1891
+					return false;
1793 1892
 		}
1794
-		else
1893
+	} else {
1795 1894
 			return false;
1796 1895
 	}
1797
-	else
1798
-		return false;
1799
-}
1896
+	}
1800 1897
 
1801 1898
 function template_install_above()
1802 1899
 {
@@ -1834,9 +1931,10 @@  discard block
 block discarded – undo
1834 1931
 								<label for="installer_language">', $txt['installer_language'], ':</label>
1835 1932
 								<select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">';
1836 1933
 
1837
-		foreach ($incontext['detected_languages'] as $lang => $name)
1838
-			echo '
1934
+		foreach ($incontext['detected_languages'] as $lang => $name) {
1935
+					echo '
1839 1936
 									<option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>';
1937
+		}
1840 1938
 
1841 1939
 		echo '
1842 1940
 								</select>
@@ -1856,9 +1954,10 @@  discard block
 block discarded – undo
1856 1954
 						<h2>', $txt['upgrade_progress'], '</h2>
1857 1955
 						<ul>';
1858 1956
 
1859
-	foreach ($incontext['steps'] as $num => $step)
1860
-		echo '
1957
+	foreach ($incontext['steps'] as $num => $step) {
1958
+			echo '
1861 1959
 							<li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
1960
+	}
1862 1961
 
1863 1962
 	echo '
1864 1963
 						</ul>
@@ -1883,20 +1982,23 @@  discard block
 block discarded – undo
1883 1982
 		echo '
1884 1983
 								<div>';
1885 1984
 
1886
-		if (!empty($incontext['continue']))
1887
-			echo '
1985
+		if (!empty($incontext['continue'])) {
1986
+					echo '
1888 1987
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button_submit" />';
1889
-		if (!empty($incontext['skip']))
1890
-			echo '
1988
+		}
1989
+		if (!empty($incontext['skip'])) {
1990
+					echo '
1891 1991
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button_submit" />';
1992
+		}
1892 1993
 		echo '
1893 1994
 								</div>';
1894 1995
 	}
1895 1996
 
1896 1997
 	// Show the closing form tag and other data only if not in the last step
1897
-	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step'])
1898
-		echo '
1998
+	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) {
1999
+			echo '
1899 2000
 							</form>';
2001
+	}
1900 2002
 
1901 2003
 	echo '
1902 2004
 						</div>
@@ -1931,13 +2033,15 @@  discard block
 block discarded – undo
1931 2033
 		</div>';
1932 2034
 
1933 2035
 	// Show the warnings, or not.
1934
-	if (template_warning_divs())
1935
-		echo '
2036
+	if (template_warning_divs()) {
2037
+			echo '
1936 2038
 		<h3>', $txt['install_all_lovely'], '</h3>';
2039
+	}
1937 2040
 
1938 2041
 	// Say we want the continue button!
1939
-	if (empty($incontext['error']))
1940
-		$incontext['continue'] = 1;
2042
+	if (empty($incontext['error'])) {
2043
+			$incontext['continue'] = 1;
2044
+	}
1941 2045
 
1942 2046
 	// For the latest version stuff.
1943 2047
 	echo '
@@ -1971,8 +2075,8 @@  discard block
 block discarded – undo
1971 2075
 	global $txt, $incontext;
1972 2076
 
1973 2077
 	// Errors are very serious..
1974
-	if (!empty($incontext['error']))
1975
-		echo '
2078
+	if (!empty($incontext['error'])) {
2079
+			echo '
1976 2080
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
1977 2081
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
1978 2082
 			<strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br>
@@ -1980,9 +2084,10 @@  discard block
 block discarded – undo
1980 2084
 				', $incontext['error'], '
1981 2085
 			</div>
1982 2086
 		</div>';
2087
+	}
1983 2088
 	// A warning message?
1984
-	elseif (!empty($incontext['warning']))
1985
-		echo '
2089
+	elseif (!empty($incontext['warning'])) {
2090
+			echo '
1986 2091
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
1987 2092
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
1988 2093
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -1990,6 +2095,7 @@  discard block
 block discarded – undo
1990 2095
 				', $incontext['warning'], '
1991 2096
 			</div>
1992 2097
 		</div>';
2098
+	}
1993 2099
 
1994 2100
 	return empty($incontext['error']) && empty($incontext['warning']);
1995 2101
 }
@@ -2005,27 +2111,30 @@  discard block
 block discarded – undo
2005 2111
 			<li>', $incontext['failed_files']), '</li>
2006 2112
 		</ul>';
2007 2113
 
2008
-	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux')
2009
-		echo '
2114
+	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') {
2115
+			echo '
2010 2116
 		<hr>
2011 2117
 		<p>', $txt['chmod_linux_info'], '</p>
2012 2118
 		<tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>';
2119
+	}
2013 2120
 
2014 2121
 	// This is serious!
2015
-	if (!template_warning_divs())
2016
-		return;
2122
+	if (!template_warning_divs()) {
2123
+			return;
2124
+	}
2017 2125
 
2018 2126
 	echo '
2019 2127
 		<hr>
2020 2128
 		<p>', $txt['ftp_setup_info'], '</p>';
2021 2129
 
2022
-	if (!empty($incontext['ftp_errors']))
2023
-		echo '
2130
+	if (!empty($incontext['ftp_errors'])) {
2131
+			echo '
2024 2132
 		<div class="error_message">
2025 2133
 			', $txt['error_ftp_no_connect'], '<br><br>
2026 2134
 			<code>', implode('<br>', $incontext['ftp_errors']), '</code>
2027 2135
 		</div>
2028 2136
 		<br>';
2137
+	}
2029 2138
 
2030 2139
 	echo '
2031 2140
 		<form action="', $incontext['form_url'], '" method="post">
@@ -2085,17 +2194,17 @@  discard block
 block discarded – undo
2085 2194
 				<td>
2086 2195
 					<select name="db_type" id="db_type_input" onchange="toggleDBInput();">';
2087 2196
 
2088
-	foreach ($incontext['supported_databases'] as $key => $db)
2089
-			echo '
2197
+	foreach ($incontext['supported_databases'] as $key => $db) {
2198
+				echo '
2090 2199
 						<option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>';
2200
+	}
2091 2201
 
2092 2202
 	echo '
2093 2203
 					</select>
2094 2204
 					<div class="smalltext block">', $txt['db_settings_type_info'], '</div>
2095 2205
 				</td>
2096 2206
 			</tr>';
2097
-	}
2098
-	else
2207
+	} else
2099 2208
 	{
2100 2209
 		echo '
2101 2210
 			<tr style="display: none;">
@@ -2287,9 +2396,10 @@  discard block
 block discarded – undo
2287 2396
 				<div style="color: red;">', $txt['error_db_queries'], '</div>
2288 2397
 				<ul>';
2289 2398
 
2290
-		foreach ($incontext['failures'] as $line => $fail)
2291
-			echo '
2399
+		foreach ($incontext['failures'] as $line => $fail) {
2400
+					echo '
2292 2401
 						<li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>';
2402
+		}
2293 2403
 
2294 2404
 		echo '
2295 2405
 				</ul>';
@@ -2350,15 +2460,16 @@  discard block
 block discarded – undo
2350 2460
 			</tr>
2351 2461
 		</table>';
2352 2462
 
2353
-	if ($incontext['require_db_confirm'])
2354
-		echo '
2463
+	if ($incontext['require_db_confirm']) {
2464
+			echo '
2355 2465
 		<h2>', $txt['user_settings_database'], '</h2>
2356 2466
 		<p>', $txt['user_settings_database_info'], '</p>
2357 2467
 
2358 2468
 		<div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;">
2359 2469
 			<input type="password" name="password3" size="30" class="input_password" />
2360 2470
 		</div>';
2361
-}
2471
+	}
2472
+	}
2362 2473
 
2363 2474
 // Tell them it's done, and to delete.
2364 2475
 function template_delete_install()
@@ -2371,14 +2482,15 @@  discard block
 block discarded – undo
2371 2482
 	template_warning_divs();
2372 2483
 
2373 2484
 	// Install directory still writable?
2374
-	if ($incontext['dir_still_writable'])
2375
-		echo '
2485
+	if ($incontext['dir_still_writable']) {
2486
+			echo '
2376 2487
 		<em>', $txt['still_writable'], '</em><br>
2377 2488
 		<br>';
2489
+	}
2378 2490
 
2379 2491
 	// Don't show the box if it's like 99% sure it won't work :P.
2380
-	if ($incontext['probably_delete_install'])
2381
-		echo '
2492
+	if ($incontext['probably_delete_install']) {
2493
+			echo '
2382 2494
 		<div style="margin: 1ex; font-weight: bold;">
2383 2495
 			<label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" class="input_check" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label>
2384 2496
 		</div>
@@ -2394,6 +2506,7 @@  discard block
 block discarded – undo
2394 2506
 			}
2395 2507
 		</script>
2396 2508
 		<br>';
2509
+	}
2397 2510
 
2398 2511
 	echo '
2399 2512
 		', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br>
Please login to merge, or discard this patch.