Completed
Push — release-2.1 ( ab13ea...2ca19b )
by Mathias
10:09
created
Sources/CacheAPI-zend.php 1 patch
Braces   +15 added lines, -11 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('zend_shm_cache_fetch') || function_exists('output_cache_get');
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
 
@@ -42,10 +44,11 @@  discard block
 block discarded – undo
42 44
 		$key = $this->prefix . strtr($key, ':/', '-_');
43 45
 
44 46
 		// Zend's pricey stuff.
45
-		if (function_exists('zend_shm_cache_fetch'))
46
-			return zend_shm_cache_fetch('SMF::' . $key);
47
-		elseif (function_exists('output_cache_get'))
48
-			return output_cache_get($key, $ttl);
47
+		if (function_exists('zend_shm_cache_fetch')) {
48
+					return zend_shm_cache_fetch('SMF::' . $key);
49
+		} elseif (function_exists('output_cache_get')) {
50
+					return output_cache_get($key, $ttl);
51
+		}
49 52
 	}
50 53
 
51 54
 	/**
@@ -55,10 +58,11 @@  discard block
 block discarded – undo
55 58
 	{
56 59
 		$key = $this->prefix . strtr($key, ':/', '-_');
57 60
 
58
-		if (function_exists('zend_shm_cache_store'))
59
-			return zend_shm_cache_store('SMF::' . $key, $value, $ttl);
60
-		elseif (function_exists('output_cache_put'))
61
-			return output_cache_put($key, $value);
61
+		if (function_exists('zend_shm_cache_store')) {
62
+					return zend_shm_cache_store('SMF::' . $key, $value, $ttl);
63
+		} elseif (function_exists('output_cache_put')) {
64
+					return output_cache_put($key, $value);
65
+		}
62 66
 	}
63 67
 
64 68
 	/**
Please login to merge, or discard this patch.
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.