Completed
Push — release-2.1 ( 4bdd41...11eb43 )
by Mathias
07:36
created
Sources/Class-TOTP.php 1 patch
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	/**
280 280
 	 * Generate the timestamp for the calculation
281 281
 	 *
282
-	 * @return integer Timestamp
282
+	 * @return double Timestamp
283 283
 	 */
284 284
 	public function generateTimestamp()
285 285
 	{
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 * Truncate the given hash down to just what we need
291 291
 	 *
292 292
 	 * @param string $hash Hash to truncate
293
-	 * @return string Truncated hash value
293
+	 * @return integer Truncated hash value
294 294
 	 */
295 295
 	public function truncateHash($hash)
296 296
 	{
Please login to merge, or discard this patch.
Sources/Errors.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -474,7 +474,7 @@
 block discarded – undo
474 474
  * Used by fatal_error(), fatal_lang_error()
475 475
  *
476 476
  * @param string $error The error
477
- * @param array $sprintf An array of data to be sprintf()'d into the specified message
477
+ * @param boolean $sprintf An array of data to be sprintf()'d into the specified message
478 478
  */
479 479
 function log_error_online($error, $sprintf = array())
480 480
 {
Please login to merge, or discard this patch.
Braces   +125 added lines, -89 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 4
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * Log an error, if the error logging is enabled.
@@ -41,17 +42,19 @@  discard block
 block discarded – undo
41 42
 	// are we in a loop?
42 43
 	if($error_call > 2)
43 44
 	{
44
-		if (!isset($db_show_debug) || $db_show_debug === false)
45
-			$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
46
-		else
47
-			$backtrace = debug_backtrace();
45
+		if (!isset($db_show_debug) || $db_show_debug === false) {
46
+					$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
47
+		} else {
48
+					$backtrace = debug_backtrace();
49
+		}
48 50
 		var_dump($backtrace);
49 51
 		die('Error loop.');
50 52
 	}
51 53
 
52 54
 	// Check if error logging is actually on.
53
-	if (empty($modSettings['enableErrorLogging']))
54
-		return $error_message;
55
+	if (empty($modSettings['enableErrorLogging'])) {
56
+			return $error_message;
57
+	}
55 58
 
56 59
 	// Basically, htmlspecialchars it minus &. (for entities!)
57 60
 	$error_message = strtr($error_message, array('<' => '&lt;', '>' => '&gt;', '"' => '&quot;'));
@@ -59,33 +62,39 @@  discard block
 block discarded – undo
59 62
 
60 63
 	// Add a file and line to the error message?
61 64
 	// Don't use the actual txt entries for file and line but instead use %1$s for file and %2$s for line
62
-	if ($file == null)
63
-		$file = '';
64
-	else
65
-		// Window style slashes don't play well, lets convert them to the unix style.
65
+	if ($file == null) {
66
+			$file = '';
67
+	} else {
68
+			// Window style slashes don't play well, lets convert them to the unix style.
66 69
 		$file = str_replace('\\', '/', $file);
70
+	}
67 71
 
68
-	if ($line == null)
69
-		$line = 0;
70
-	else
71
-		$line = (int) $line;
72
+	if ($line == null) {
73
+			$line = 0;
74
+	} else {
75
+			$line = (int) $line;
76
+	}
72 77
 
73 78
 	// Just in case there's no id_member or IP set yet.
74
-	if (empty($user_info['id']))
75
-		$user_info['id'] = 0;
76
-	if (empty($user_info['ip']))
77
-		$user_info['ip'] = '';
79
+	if (empty($user_info['id'])) {
80
+			$user_info['id'] = 0;
81
+	}
82
+	if (empty($user_info['ip'])) {
83
+			$user_info['ip'] = '';
84
+	}
78 85
 
79 86
 	// Find the best query string we can...
80 87
 	$query_string = empty($_SERVER['QUERY_STRING']) ? (empty($_SERVER['REQUEST_URL']) ? '' : str_replace($scripturl, '', $_SERVER['REQUEST_URL'])) : $_SERVER['QUERY_STRING'];
81 88
 
82 89
 	// Don't log the session hash in the url twice, it's a waste.
83
-	if (!empty($smcFunc['htmlspecialchars']))
84
-		$query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string));
90
+	if (!empty($smcFunc['htmlspecialchars'])) {
91
+			$query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string));
92
+	}
85 93
 
86 94
 	// Just so we know what board error messages are from.
87
-	if (isset($_POST['board']) && !isset($_GET['board']))
88
-		$query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board'];
95
+	if (isset($_POST['board']) && !isset($_GET['board'])) {
96
+			$query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board'];
97
+	}
89 98
 
90 99
 	// What types of categories do we have?
91 100
 	$known_error_types = array(
@@ -146,12 +155,14 @@  discard block
 block discarded – undo
146 155
 	global $txt;
147 156
 
148 157
 	// Send the appropriate HTTP status header - set this to 0 or false if you don't want to send one at all
149
-	if (!empty($status))
150
-		send_http_status($status);
158
+	if (!empty($status)) {
159
+			send_http_status($status);
160
+	}
151 161
 
152 162
 	// We don't have $txt yet, but that's okay...
153
-	if (empty($txt))
154
-		die($error);
163
+	if (empty($txt)) {
164
+			die($error);
165
+	}
155 166
 
156 167
 	log_error_online($error, false);
157 168
 	setup_fatal_error_context($log ? log_error($error, $log) : $error);
@@ -178,8 +189,9 @@  discard block
 block discarded – undo
178 189
 	static $fatal_error_called = false;
179 190
 
180 191
 	// Send the status header - set this to 0 or false if you don't want to send one at all
181
-	if (!empty($status))
182
-		send_http_status($status);
192
+	if (!empty($status)) {
193
+			send_http_status($status);
194
+	}
183 195
 
184 196
 	// Try to load a theme if we don't have one.
185 197
 	if (empty($context['theme_loaded']) && empty($fatal_error_called))
@@ -189,8 +201,9 @@  discard block
 block discarded – undo
189 201
 	}
190 202
 
191 203
 	// If we have no theme stuff we can't have the language file...
192
-	if (empty($context['theme_loaded']))
193
-		die($error);
204
+	if (empty($context['theme_loaded'])) {
205
+			die($error);
206
+	}
194 207
 
195 208
 	$reload_lang_file = true;
196 209
 	// Log the error in the forum's language, but don't waste the time if we aren't logging
@@ -226,8 +239,9 @@  discard block
 block discarded – undo
226 239
 	global $settings, $modSettings, $db_show_debug;
227 240
 
228 241
 	// Ignore errors if we're ignoring them or they are strict notices from PHP 5 (which cannot be solved without breaking PHP 4.)
229
-	if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging'])))
230
-		return;
242
+	if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging']))) {
243
+			return;
244
+	}
231 245
 
232 246
 	if (strpos($file, 'eval()') !== false && !empty($settings['current_include_filename']))
233 247
 	{
@@ -235,19 +249,22 @@  discard block
 block discarded – undo
235 249
 		$count = count($array);
236 250
 		for ($i = 0; $i < $count; $i++)
237 251
 		{
238
-			if ($array[$i]['function'] != 'loadSubTemplate')
239
-				continue;
252
+			if ($array[$i]['function'] != 'loadSubTemplate') {
253
+							continue;
254
+			}
240 255
 
241 256
 			// This is a bug in PHP, with eval, it seems!
242
-			if (empty($array[$i]['args']))
243
-				$i++;
257
+			if (empty($array[$i]['args'])) {
258
+							$i++;
259
+			}
244 260
 			break;
245 261
 		}
246 262
 
247
-		if (isset($array[$i]) && !empty($array[$i]['args']))
248
-			$file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)';
249
-		else
250
-			$file = realpath($settings['current_include_filename']) . ' (eval?)';
263
+		if (isset($array[$i]) && !empty($array[$i]['args'])) {
264
+					$file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)';
265
+		} else {
266
+					$file = realpath($settings['current_include_filename']) . ' (eval?)';
267
+		}
251 268
 	}
252 269
 
253 270
 	if (isset($db_show_debug) && $db_show_debug === true)
@@ -256,8 +273,9 @@  discard block
 block discarded – undo
256 273
 		if ($error_level % 255 != E_ERROR)
257 274
 		{
258 275
 			$temporary = ob_get_contents();
259
-			if (substr($temporary, -2) == '="')
260
-				echo '"';
276
+			if (substr($temporary, -2) == '="') {
277
+							echo '"';
278
+			}
261 279
 		}
262 280
 
263 281
 		// Debugging!  This should look like a PHP error message.
@@ -273,23 +291,27 @@  discard block
 block discarded – undo
273 291
 	call_integration_hook('integrate_output_error', array($message, $error_type, $error_level, $file, $line));
274 292
 
275 293
 	// Dying on these errors only causes MORE problems (blank pages!)
276
-	if ($file == 'Unknown')
277
-		return;
294
+	if ($file == 'Unknown') {
295
+			return;
296
+	}
278 297
 
279 298
 	// If this is an E_ERROR or E_USER_ERROR.... die.  Violently so.
280
-	if ($error_level % 255 == E_ERROR)
281
-		obExit(false);
282
-	else
283
-		return;
299
+	if ($error_level % 255 == E_ERROR) {
300
+			obExit(false);
301
+	} else {
302
+			return;
303
+	}
284 304
 
285 305
 	// If this is an E_ERROR, E_USER_ERROR, E_WARNING, or E_USER_WARNING.... die.  Violently so.
286
-	if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING)
287
-		fatal_error(allowedTo('admin_forum') ? $message : $error_string, false);
306
+	if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) {
307
+			fatal_error(allowedTo('admin_forum') ? $message : $error_string, false);
308
+	}
288 309
 
289 310
 	// We should NEVER get to this point.  Any fatal error MUST quit, or very bad things can happen.
290
-	if ($error_level % 255 == E_ERROR)
291
-		die('No direct access...');
292
-}
311
+	if ($error_level % 255 == E_ERROR) {
312
+			die('No direct access...');
313
+	}
314
+	}
293 315
 
294 316
 /**
295 317
  * It is called by {@link fatal_error()} and {@link fatal_lang_error()}.
@@ -305,24 +327,28 @@  discard block
 block discarded – undo
305 327
 
306 328
 	// Attempt to prevent a recursive loop.
307 329
 	++$level;
308
-	if ($level > 1)
309
-		return false;
330
+	if ($level > 1) {
331
+			return false;
332
+	}
310 333
 
311 334
 	// Maybe they came from dlattach or similar?
312
-	if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded']))
313
-		loadTheme();
335
+	if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) {
336
+			loadTheme();
337
+	}
314 338
 
315 339
 	// Don't bother indexing errors mate...
316 340
 	$context['robot_no_index'] = true;
317 341
 
318
-	if (!isset($context['error_title']))
319
-		$context['error_title'] = $txt['error_occured'];
342
+	if (!isset($context['error_title'])) {
343
+			$context['error_title'] = $txt['error_occured'];
344
+	}
320 345
 	$context['error_message'] = isset($context['error_message']) ? $context['error_message'] : $error_message;
321 346
 
322 347
 	$context['error_code'] = isset($error_code) ? 'id="' . $error_code . '" ' : '';
323 348
 
324
-	if (empty($context['page_title']))
325
-		$context['page_title'] = $context['error_title'];
349
+	if (empty($context['page_title'])) {
350
+			$context['page_title'] = $context['error_title'];
351
+	}
326 352
 
327 353
 	loadTemplate('Errors');
328 354
 	$context['sub_template'] = 'fatal_error';
@@ -330,23 +356,26 @@  discard block
 block discarded – undo
330 356
 	// If this is SSI, what do they want us to do?
331 357
 	if (SMF == 'SSI')
332 358
 	{
333
-		if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method))
334
-			$ssi_on_error_method();
335
-		elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true)
336
-			loadSubTemplate('fatal_error');
359
+		if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) {
360
+					$ssi_on_error_method();
361
+		} elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) {
362
+					loadSubTemplate('fatal_error');
363
+		}
337 364
 
338 365
 		// No layers?
339
-		if (empty($ssi_on_error_method) || $ssi_on_error_method !== true)
340
-			exit;
366
+		if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) {
367
+					exit;
368
+		}
341 369
 	}
342 370
 	// Alternatively from the cron call?
343 371
 	elseif (SMF == 'BACKGROUND')
344 372
 	{
345 373
 		// We can't rely on even having language files available.
346
-		if (defined('FROM_CLI') && FROM_CLI)
347
-			echo 'cron error: ', $context['error_message'];
348
-		else
349
-			echo 'An error occurred. More information may be available in your logs.';
374
+		if (defined('FROM_CLI') && FROM_CLI) {
375
+					echo 'cron error: ', $context['error_message'];
376
+		} else {
377
+					echo 'An error occurred. More information may be available in your logs.';
378
+		}
350 379
 		exit;
351 380
 	}
352 381
 
@@ -374,8 +403,8 @@  discard block
 block discarded – undo
374 403
 
375 404
 	set_fatal_error_headers();
376 405
 
377
-	if (!empty($maintenance))
378
-		echo '<!DOCTYPE html>
406
+	if (!empty($maintenance)) {
407
+			echo '<!DOCTYPE html>
379 408
 <html>
380 409
 	<head>
381 410
 		<meta name="robots" content="noindex">
@@ -386,6 +415,7 @@  discard block
 block discarded – undo
386 415
 		', $mmessage, '
387 416
 	</body>
388 417
 </html>';
418
+	}
389 419
 
390 420
 	die();
391 421
 }
@@ -407,15 +437,17 @@  discard block
 block discarded – undo
407 437
 	// For our purposes, we're gonna want this on if at all possible.
408 438
 	$modSettings['cache_enable'] = '1';
409 439
 
410
-	if (($temp = cache_get_data('db_last_error', 600)) !== null)
411
-		$db_last_error = max($db_last_error, $temp);
440
+	if (($temp = cache_get_data('db_last_error', 600)) !== null) {
441
+			$db_last_error = max($db_last_error, $temp);
442
+	}
412 443
 
413 444
 	if ($db_last_error < time() - 3600 * 24 * 3 && empty($maintenance) && !empty($db_error_send))
414 445
 	{
415 446
 		// Avoid writing to the Settings.php file if at all possible; use shared memory instead.
416 447
 		cache_put_data('db_last_error', time(), 600);
417
-		if (($temp = cache_get_data('db_last_error', 600)) === null)
418
-			logLastDatabaseError();
448
+		if (($temp = cache_get_data('db_last_error', 600)) === null) {
449
+					logLastDatabaseError();
450
+		}
419 451
 
420 452
 		// Language files aren't loaded yet :(.
421 453
 		$db_error = @$smcFunc['db_error']($db_connection);
@@ -496,12 +528,14 @@  discard block
 block discarded – undo
496 528
 	global $smcFunc, $user_info, $modSettings;
497 529
 
498 530
 	// Don't bother if Who's Online is disabled.
499
-	if (empty($modSettings['who_enabled']))
500
-		return;
531
+	if (empty($modSettings['who_enabled'])) {
532
+			return;
533
+	}
501 534
 
502 535
 	// Maybe they came from SSI or similar where sessions are not recorded?
503
-	if (SMF == 'SSI' || SMF == 'BACKGROUND')
504
-		return;
536
+	if (SMF == 'SSI' || SMF == 'BACKGROUND') {
537
+			return;
538
+	}
505 539
 
506 540
 	$session_id = !empty($user_info['is_guest']) ? 'ip' . $user_info['ip'] : session_id();
507 541
 
@@ -527,8 +561,9 @@  discard block
 block discarded – undo
527 561
 		$url = $smcFunc['json_decode']($url, true);
528 562
 		$url['error'] = $error;
529 563
 
530
-		if (!empty($sprintf))
531
-			$url['error_params'] = $sprintf;
564
+		if (!empty($sprintf)) {
565
+					$url['error_params'] = $sprintf;
566
+		}
532 567
 
533 568
 		$smcFunc['db_query']('', '
534 569
 			UPDATE {db_prefix}log_online
@@ -559,10 +594,11 @@  discard block
 block discarded – undo
559 594
 
560 595
 	$protocol = preg_match('~HTTP/1\.[01]~i', $_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0';
561 596
 
562
-	if (!isset($statuses[$code]))
563
-		header($protocol . ' 500 Internal Server Error');
564
-	else
565
-		header($protocol . ' ' . $code . ' ' . $statuses[$code]);
566
-}
597
+	if (!isset($statuses[$code])) {
598
+			header($protocol . ' 500 Internal Server Error');
599
+	} else {
600
+			header($protocol . ' ' . $code . ' ' . $statuses[$code]);
601
+	}
602
+	}
567 603
 
568 604
 ?>
569 605
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Subs-Admin.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 
19 19
 /**
20 20
  * Get a list of versions that are currently installed on the server.
21
- * @param array $checkFor An array of what to check versions for - can contain one or more of 'gd', 'imagemagick', 'db_server', 'phpa', 'memcache', 'xcache', 'apc', 'php' or 'server'
21
+ * @param string[] $checkFor An array of what to check versions for - can contain one or more of 'gd', 'imagemagick', 'db_server', 'phpa', 'memcache', 'xcache', 'apc', 'php' or 'server'
22 22
  * @return array An array of versions (keys are same as what was in $checkFor, values are the versions)
23 23
  */
24 24
 function getServerVersions($checkFor)
Please login to merge, or discard this patch.
Braces   +124 added lines, -89 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
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
  * Get a list of versions that are currently installed on the server.
@@ -45,8 +46,7 @@  discard block
 block discarded – undo
45 46
 			$temp2 = $temp->getVersion();
46 47
 			$im_version = $temp2['versionString'];
47 48
 			$extension_version = 'Imagick ' . phpversion('Imagick');
48
-		}
49
-		else
49
+		} else
50 50
 		{
51 51
 			$im_version = MagickGetVersionString();
52 52
 			$extension_version = 'MagickWand ' . phpversion('MagickWand');
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 	if (in_array('db_server', $checkFor))
62 62
 	{
63 63
 		db_extend();
64
-		if (!isset($db_connection) || $db_connection === false)
65
-			trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE);
66
-		else
64
+		if (!isset($db_connection) || $db_connection === false) {
65
+					trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE);
66
+		} else
67 67
 		{
68 68
 			$versions['db_engine'] = array('title' => sprintf($txt['support_versions_db_engine'], $smcFunc['db_title']), 'version' => '');
69 69
 			$versions['db_engine']['version'] = $smcFunc['db_get_engine']();
@@ -75,24 +75,31 @@  discard block
 block discarded – undo
75 75
 
76 76
 	// If we're using memcache we need the server info.
77 77
 	$memcache_version = '???';
78
-	if (!empty($cache_accelerator) && ($cache_accelerator == 'memcached' || $cache_accelerator == 'memcache') && !empty($cache_memcached) && !empty($cacheAPI))
79
-		$memcache_version = $cacheAPI->getVersion();
78
+	if (!empty($cache_accelerator) && ($cache_accelerator == 'memcached' || $cache_accelerator == 'memcache') && !empty($cache_memcached) && !empty($cacheAPI)) {
79
+			$memcache_version = $cacheAPI->getVersion();
80
+	}
80 81
 
81 82
 	// Check to see if we have any accelerators installed...
82
-	if (in_array('phpa', $checkFor) && isset($_PHPA))
83
-		$versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']);
84
-	if (in_array('apc', $checkFor) && extension_loaded('apc'))
85
-		$versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc'));
86
-	if (in_array('memcache', $checkFor) && function_exists('memcache_set'))
87
-		$versions['memcache'] = array('title' => 'Memcached', 'version' => $memcache_version);
88
-	if (in_array('xcache', $checkFor) && function_exists('xcache_set'))
89
-		$versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION);
83
+	if (in_array('phpa', $checkFor) && isset($_PHPA)) {
84
+			$versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']);
85
+	}
86
+	if (in_array('apc', $checkFor) && extension_loaded('apc')) {
87
+			$versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc'));
88
+	}
89
+	if (in_array('memcache', $checkFor) && function_exists('memcache_set')) {
90
+			$versions['memcache'] = array('title' => 'Memcached', 'version' => $memcache_version);
91
+	}
92
+	if (in_array('xcache', $checkFor) && function_exists('xcache_set')) {
93
+			$versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION);
94
+	}
90 95
 
91
-	if (in_array('php', $checkFor))
92
-		$versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo');
96
+	if (in_array('php', $checkFor)) {
97
+			$versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo');
98
+	}
93 99
 
94
-	if (in_array('server', $checkFor))
95
-		$versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']);
100
+	if (in_array('server', $checkFor)) {
101
+			$versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']);
102
+	}
96 103
 
97 104
 	return $versions;
98 105
 }
@@ -132,11 +139,13 @@  discard block
 block discarded – undo
132 139
 		fclose($fp);
133 140
 
134 141
 		// The comment looks rougly like... that.
135
-		if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1)
136
-			$version_info['file_versions']['SSI.php'] = $match[1];
142
+		if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) {
143
+					$version_info['file_versions']['SSI.php'] = $match[1];
144
+		}
137 145
 		// Not found!  This is bad.
138
-		else
139
-			$version_info['file_versions']['SSI.php'] = '??';
146
+		else {
147
+					$version_info['file_versions']['SSI.php'] = '??';
148
+		}
140 149
 	}
141 150
 
142 151
 	// Do the paid subscriptions handler?
@@ -147,11 +156,13 @@  discard block
 block discarded – undo
147 156
 		fclose($fp);
148 157
 
149 158
 		// Found it?
150
-		if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1)
151
-			$version_info['file_versions']['subscriptions.php'] = $match[1];
159
+		if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) {
160
+					$version_info['file_versions']['subscriptions.php'] = $match[1];
161
+		}
152 162
 		// If we haven't how do we all get paid?
153
-		else
154
-			$version_info['file_versions']['subscriptions.php'] = '??';
163
+		else {
164
+					$version_info['file_versions']['subscriptions.php'] = '??';
165
+		}
155 166
 	}
156 167
 
157 168
 	// Load all the files in the Sources directory, except this file and the redirect.
@@ -166,11 +177,13 @@  discard block
 block discarded – undo
166 177
 			fclose($fp);
167 178
 
168 179
 			// Look for the version comment in the file header.
169
-			if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1)
170
-				$version_info['file_versions'][$entry] = $match[1];
180
+			if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) {
181
+							$version_info['file_versions'][$entry] = $match[1];
182
+			}
171 183
 			// It wasn't found, but the file was... show a '??'.
172
-			else
173
-				$version_info['file_versions'][$entry] = '??';
184
+			else {
185
+							$version_info['file_versions'][$entry] = '??';
186
+			}
174 187
 		}
175 188
 	}
176 189
 	$sources_dir->close();
@@ -189,11 +202,13 @@  discard block
 block discarded – undo
189 202
 				fclose($fp);
190 203
 
191 204
 				// Look for the version comment in the file header.
192
-				if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1)
193
-					$version_info['tasks_versions'][$entry] = $match[1];
205
+				if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) {
206
+									$version_info['tasks_versions'][$entry] = $match[1];
207
+				}
194 208
 				// It wasn't found, but the file was... show a '??'.
195
-				else
196
-					$version_info['tasks_versions'][$entry] = '??';
209
+				else {
210
+									$version_info['tasks_versions'][$entry] = '??';
211
+				}
197 212
 			}
198 213
 		}
199 214
 		$tasks_dir->close();
@@ -201,8 +216,9 @@  discard block
 block discarded – undo
201 216
 
202 217
 	// Load all the files in the default template directory - and the current theme if applicable.
203 218
 	$directories = array('default_template_versions' => $settings['default_theme_dir']);
204
-	if ($settings['theme_id'] != 1)
205
-		$directories += array('template_versions' => $settings['theme_dir']);
219
+	if ($settings['theme_id'] != 1) {
220
+			$directories += array('template_versions' => $settings['theme_dir']);
221
+	}
206 222
 
207 223
 	foreach ($directories as $type => $dirname)
208 224
 	{
@@ -217,11 +233,13 @@  discard block
 block discarded – undo
217 233
 				fclose($fp);
218 234
 
219 235
 				// Look for the version comment in the file header.
220
-				if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1)
221
-					$version_info[$type][$entry] = $match[1];
236
+				if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) {
237
+									$version_info[$type][$entry] = $match[1];
238
+				}
222 239
 				// It wasn't found, but the file was... show a '??'.
223
-				else
224
-					$version_info[$type][$entry] = '??';
240
+				else {
241
+									$version_info[$type][$entry] = '??';
242
+				}
225 243
 			}
226 244
 		}
227 245
 		$this_dir->close();
@@ -242,11 +260,13 @@  discard block
 block discarded – undo
242 260
 			list ($name, $language) = explode('.', $entry);
243 261
 
244 262
 			// Look for the version comment in the file header.
245
-			if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1)
246
-				$version_info['default_language_versions'][$language][$name] = $match[1];
263
+			if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) {
264
+							$version_info['default_language_versions'][$language][$name] = $match[1];
265
+			}
247 266
 			// It wasn't found, but the file was... show a '??'.
248
-			else
249
-				$version_info['default_language_versions'][$language][$name] = '??';
267
+			else {
268
+							$version_info['default_language_versions'][$language][$name] = '??';
269
+			}
250 270
 		}
251 271
 	}
252 272
 	$this_dir->close();
@@ -261,8 +281,9 @@  discard block
 block discarded – undo
261 281
 		ksort($version_info['tasks_versions']);
262 282
 
263 283
 		// For languages sort each language too.
264
-		foreach ($version_info['default_language_versions'] as $language => $dummy)
265
-			ksort($version_info['default_language_versions'][$language]);
284
+		foreach ($version_info['default_language_versions'] as $language => $dummy) {
285
+					ksort($version_info['default_language_versions'][$language]);
286
+		}
266 287
 	}
267 288
 	return $version_info;
268 289
 }
@@ -304,27 +325,31 @@  discard block
 block discarded – undo
304 325
 	$settingsArray = trim(file_get_contents($boarddir . '/Settings.php'));
305 326
 
306 327
 	// Break it up based on \r or \n, and then clean out extra characters.
307
-	if (strpos($settingsArray, "\n") !== false)
308
-		$settingsArray = explode("\n", $settingsArray);
309
-	elseif (strpos($settingsArray, "\r") !== false)
310
-		$settingsArray = explode("\r", $settingsArray);
311
-	else
312
-		return;
328
+	if (strpos($settingsArray, "\n") !== false) {
329
+			$settingsArray = explode("\n", $settingsArray);
330
+	} elseif (strpos($settingsArray, "\r") !== false) {
331
+			$settingsArray = explode("\r", $settingsArray);
332
+	} else {
333
+			return;
334
+	}
313 335
 
314 336
 	// Presumably, the file has to have stuff in it for this function to be called :P.
315
-	if (count($settingsArray) < 10)
316
-		return;
337
+	if (count($settingsArray) < 10) {
338
+			return;
339
+	}
317 340
 
318 341
 	// remove any /r's that made there way in here
319
-	foreach ($settingsArray as $k => $dummy)
320
-		$settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n";
342
+	foreach ($settingsArray as $k => $dummy) {
343
+			$settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n";
344
+	}
321 345
 
322 346
 	// go line by line and see whats changing
323 347
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
324 348
 	{
325 349
 		// Don't trim or bother with it if it's not a variable.
326
-		if (substr($settingsArray[$i], 0, 1) != '$')
327
-			continue;
350
+		if (substr($settingsArray[$i], 0, 1) != '$') {
351
+					continue;
352
+		}
328 353
 
329 354
 		$settingsArray[$i] = trim($settingsArray[$i]) . "\n";
330 355
 
@@ -336,8 +361,7 @@  discard block
 block discarded – undo
336 361
 			{
337 362
 				updateDbLastError($val);
338 363
 				unset($config_vars[$var]);
339
-			}
340
-			elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
364
+			} elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
341 365
 			{
342 366
 				$comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#');
343 367
 				$settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment == '' ? '' : "\t\t" . rtrim($comment)) . "\n";
@@ -348,34 +372,39 @@  discard block
 block discarded – undo
348 372
 		}
349 373
 
350 374
 		// End of the file ... maybe
351
-		if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>')
352
-			$end = $i;
375
+		if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') {
376
+					$end = $i;
377
+		}
353 378
 	}
354 379
 
355 380
 	// This should never happen, but apparently it is happening.
356
-	if (empty($end) || $end < 10)
357
-		$end = count($settingsArray) - 1;
381
+	if (empty($end) || $end < 10) {
382
+			$end = count($settingsArray) - 1;
383
+	}
358 384
 
359 385
 	// Still more variables to go?  Then lets add them at the end.
360 386
 	if (!empty($config_vars))
361 387
 	{
362
-		if (trim($settingsArray[$end]) == '?' . '>')
363
-			$settingsArray[$end++] = '';
364
-		else
365
-			$end++;
388
+		if (trim($settingsArray[$end]) == '?' . '>') {
389
+					$settingsArray[$end++] = '';
390
+		} else {
391
+					$end++;
392
+		}
366 393
 
367 394
 		// Add in any newly defined vars that were passed
368
-		foreach ($config_vars as $var => $val)
369
-			$settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n";
395
+		foreach ($config_vars as $var => $val) {
396
+					$settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n";
397
+		}
370 398
 
371 399
 		$settingsArray[$end] = '?' . '>';
400
+	} else {
401
+			$settingsArray[$end] = trim($settingsArray[$end]);
372 402
 	}
373
-	else
374
-		$settingsArray[$end] = trim($settingsArray[$end]);
375 403
 
376 404
 	// Sanity error checking: the file needs to be at least 12 lines.
377
-	if (count($settingsArray) < 12)
378
-		return;
405
+	if (count($settingsArray) < 12) {
406
+			return;
407
+	}
379 408
 
380 409
 	// Try to avoid a few pitfalls:
381 410
 	//  - like a possible race condition,
@@ -383,8 +412,9 @@  discard block
 block discarded – undo
383 412
 	//
384 413
 	// Check before you act: if cache is enabled, we can do a simple write test
385 414
 	// to validate that we even write things on this filesystem.
386
-	if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache'))
387
-		$cachedir = $boarddir . '/cache';
415
+	if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) {
416
+			$cachedir = $boarddir . '/cache';
417
+	}
388 418
 
389 419
 	$test_fp = @fopen($cachedir . '/settings_update.tmp', "w+");
390 420
 	if ($test_fp)
@@ -419,16 +449,18 @@  discard block
 block discarded – undo
419 449
 			// Well this is not good at all, lets see if we can save this
420 450
 			$context['settings_message'] = 'settings_error';
421 451
 
422
-			if (file_exists($boarddir . '/Settings_bak.php'))
423
-				@copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php');
452
+			if (file_exists($boarddir . '/Settings_bak.php')) {
453
+							@copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php');
454
+			}
424 455
 		}
425 456
 	}
426 457
 
427 458
 	// Even though on normal installations the filemtime should prevent this being used by the installer incorrectly
428 459
 	// it seems that there are times it might not. So let's MAKE it dump the cache.
429
-	if (function_exists('opcache_invalidate'))
430
-		opcache_invalidate($boarddir . '/Settings.php', true);
431
-}
460
+	if (function_exists('opcache_invalidate')) {
461
+			opcache_invalidate($boarddir . '/Settings.php', true);
462
+	}
463
+	}
432 464
 
433 465
 /**
434 466
  * Saves the time of the last db error for the error log
@@ -454,8 +486,9 @@  discard block
 block discarded – undo
454 486
 	global $options, $context, $smcFunc, $settings, $user_info;
455 487
 
456 488
 	// This must exist!
457
-	if (!isset($context['admin_preferences']))
458
-		return false;
489
+	if (!isset($context['admin_preferences'])) {
490
+			return false;
491
+	}
459 492
 
460 493
 	// This is what we'll be saving.
461 494
 	$options['admin_preferences'] = $smcFunc['json_encode']($context['admin_preferences']);
@@ -519,8 +552,9 @@  discard block
 block discarded – undo
519 552
 	$emails_sent = array();
520 553
 	while ($row = $smcFunc['db_fetch_assoc']($request))
521 554
 	{
522
-		if (empty($prefs[$row['id_member']]['announcements']))
523
-			continue;
555
+		if (empty($prefs[$row['id_member']]['announcements'])) {
556
+					continue;
557
+		}
524 558
 
525 559
 		// Stick their particulars in the replacement data.
526 560
 		$replacements['IDMEMBER'] = $row['id_member'];
@@ -539,11 +573,12 @@  discard block
 block discarded – undo
539 573
 	$smcFunc['db_free_result']($request);
540 574
 
541 575
 	// Any additional users we must email this to?
542
-	if (!empty($additional_recipients))
543
-		foreach ($additional_recipients as $recipient)
576
+	if (!empty($additional_recipients)) {
577
+			foreach ($additional_recipients as $recipient)
544 578
 		{
545 579
 			if (in_array($recipient['email'], $emails_sent))
546 580
 				continue;
581
+	}
547 582
 
548 583
 			$replacements['IDMEMBER'] = $recipient['id'];
549 584
 			$replacements['REALNAME'] = $recipient['name'];
Please login to merge, or discard this patch.
Sources/Subs-Auth.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@
 block discarded – undo
150 150
  *
151 151
  * @param bool $local Whether we want local cookies
152 152
  * @param bool $global Whether we want global cookies
153
- * @return array An array to set the cookie on with domain and path in it, in that order
153
+ * @return string An array to set the cookie on with domain and path in it, in that order
154 154
  */
155 155
 function url_parts($local, $global)
156 156
 {
Please login to merge, or discard this patch.
Braces   +163 added lines, -117 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
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
  * Sets the SMF-style login cookie and session based on the id_member and password passed.
@@ -43,15 +44,17 @@  discard block
 block discarded – undo
43 44
 		$array = $smcFunc['json_decode']($_COOKIE[$cookiename], true);
44 45
 
45 46
 		// Legacy format
46
-		if (is_null($array))
47
-			$array = safe_unserialize($_COOKIE[$cookiename]);
47
+		if (is_null($array)) {
48
+					$array = safe_unserialize($_COOKIE[$cookiename]);
49
+		}
48 50
 
49 51
 		// Out with the old, in with the new!
50 52
 		if (isset($array[3]) && $array[3] != $cookie_state)
51 53
 		{
52 54
 			$cookie_url = url_parts($array[3] & 1 > 0, $array[3] & 2 > 0);
53
-			if (isset($_COOKIE[$cookiename]['path']))
54
-				$cookie_url[1] = $_COOKIE[$cookiename]['path'];
55
+			if (isset($_COOKIE[$cookiename]['path'])) {
56
+							$cookie_url[1] = $_COOKIE[$cookiename]['path'];
57
+			}
55 58
 			smf_setcookie($cookiename, $smcFunc['json_encode'](array(0, '', 0, 'path' => $cookie_url[1])), 1, $cookie_url[1], $cookie_url[0]);
56 59
 		}
57 60
 	}
@@ -65,8 +68,9 @@  discard block
 block discarded – undo
65 68
 	smf_setcookie($cookiename, $data, time() + $cookie_length, $cookie_url[1], $cookie_url[0]);
66 69
 
67 70
 	// If subdomain-independent cookies are on, unset the subdomain-dependent cookie too.
68
-	if (empty($id) && !empty($modSettings['globalCookies']))
69
-		smf_setcookie($cookiename, $data, time() + $cookie_length, $cookie_url[1], '');
71
+	if (empty($id) && !empty($modSettings['globalCookies'])) {
72
+			smf_setcookie($cookiename, $data, time() + $cookie_length, $cookie_url[1], '');
73
+	}
70 74
 
71 75
 	// Any alias URLs?  This is mainly for use with frames, etc.
72 76
 	if (!empty($modSettings['forum_alias_urls']))
@@ -82,8 +86,9 @@  discard block
 block discarded – undo
82 86
 
83 87
 			$cookie_url = url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']));
84 88
 
85
-			if ($cookie_url[0] == '')
86
-				$cookie_url[0] = strtok($alias, '/');
89
+			if ($cookie_url[0] == '') {
90
+							$cookie_url[0] = strtok($alias, '/');
91
+			}
87 92
 			
88 93
 			$dataAr['path'] = $cookie_url[1];
89 94
 			$data = $smcFunc['json_encode']($dataAr);
@@ -132,8 +137,9 @@  discard block
 block discarded – undo
132 137
 	$identifier = $cookiename . '_tfa';
133 138
 	$cookie_state = (empty($modSettings['localCookies']) ? 0 : 1) | (empty($modSettings['globalCookies']) ? 0 : 2);
134 139
 
135
-	if ($preserve)
136
-		$cookie_length = 81600 * 30;
140
+	if ($preserve) {
141
+			$cookie_length = 81600 * 30;
142
+	}
137 143
 
138 144
 	// Get the data and path to set it on.
139 145
 	$cookie_url = url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']));
@@ -143,8 +149,9 @@  discard block
 block discarded – undo
143 149
 	smf_setcookie($identifier, $data, time() + $cookie_length, $cookie_url[1], $cookie_url[0]);
144 150
 
145 151
 	// If subdomain-independent cookies are on, unset the subdomain-dependent cookie too.
146
-	if (empty($id) && !empty($modSettings['globalCookies']))
147
-		smf_setcookie($identifier, $data, time() + $cookie_length, $cookie_url[1], '');
152
+	if (empty($id) && !empty($modSettings['globalCookies'])) {
153
+			smf_setcookie($identifier, $data, time() + $cookie_length, $cookie_url[1], '');
154
+	}
148 155
 
149 156
 	$_COOKIE[$identifier] = $data;
150 157
 }
@@ -166,23 +173,28 @@  discard block
 block discarded – undo
166 173
 	$parsed_url = parse_url($boardurl);
167 174
 
168 175
 	// Is local cookies off?
169
-	if (empty($parsed_url['path']) || !$local)
170
-		$parsed_url['path'] = '';
176
+	if (empty($parsed_url['path']) || !$local) {
177
+			$parsed_url['path'] = '';
178
+	}
171 179
 
172
-	if (!empty($modSettings['globalCookiesDomain']) && strpos($boardurl, $modSettings['globalCookiesDomain']) !== false)
173
-		$parsed_url['host'] = $modSettings['globalCookiesDomain'];
180
+	if (!empty($modSettings['globalCookiesDomain']) && strpos($boardurl, $modSettings['globalCookiesDomain']) !== false) {
181
+			$parsed_url['host'] = $modSettings['globalCookiesDomain'];
182
+	}
174 183
 
175 184
 	// Globalize cookies across domains (filter out IP-addresses)?
176
-	elseif ($global && preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1)
177
-		$parsed_url['host'] = '.' . $parts[1];
185
+	elseif ($global && preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) {
186
+			$parsed_url['host'] = '.' . $parts[1];
187
+	}
178 188
 
179 189
 	// We shouldn't use a host at all if both options are off.
180
-	elseif (!$local && !$global)
181
-		$parsed_url['host'] = '';
190
+	elseif (!$local && !$global) {
191
+			$parsed_url['host'] = '';
192
+	}
182 193
 
183 194
 	// The host also shouldn't be set if there aren't any dots in it.
184
-	elseif (!isset($parsed_url['host']) || strpos($parsed_url['host'], '.') === false)
185
-		$parsed_url['host'] = '';
195
+	elseif (!isset($parsed_url['host']) || strpos($parsed_url['host'], '.') === false) {
196
+			$parsed_url['host'] = '';
197
+	}
186 198
 
187 199
 	return array($parsed_url['host'], $parsed_url['path'] . '/');
188 200
 }
@@ -201,8 +213,9 @@  discard block
 block discarded – undo
201 213
 	createToken('login');
202 214
 
203 215
 	// Never redirect to an attachment
204
-	if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false)
205
-		$_SESSION['login_url'] = $_SERVER['REQUEST_URL'];
216
+	if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) {
217
+			$_SESSION['login_url'] = $_SERVER['REQUEST_URL'];
218
+	}
206 219
 
207 220
 	$context['sub_template'] = 'kick_guest';
208 221
 	$context['page_title'] = $txt['login'];
@@ -257,10 +270,12 @@  discard block
 block discarded – undo
257 270
 		$txt['security_wrong'] = sprintf($txt['security_wrong'], isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $txt['unknown'], $_SERVER['HTTP_USER_AGENT'], $user_info['ip']);
258 271
 		log_error($txt['security_wrong'], 'critical');
259 272
 
260
-		if (isset($_POST[$type . '_hash_pass']))
261
-			unset($_POST[$type . '_hash_pass']);
262
-		if (isset($_POST[$type . '_pass']))
263
-			unset($_POST[$type . '_pass']);
273
+		if (isset($_POST[$type . '_hash_pass'])) {
274
+					unset($_POST[$type . '_hash_pass']);
275
+		}
276
+		if (isset($_POST[$type . '_pass'])) {
277
+					unset($_POST[$type . '_pass']);
278
+		}
264 279
 
265 280
 		$context['incorrect_password'] = true;
266 281
 	}
@@ -273,15 +288,17 @@  discard block
 block discarded – undo
273 288
 
274 289
 	// Now go through $_POST.  Make sure the session hash is sent.
275 290
 	$_POST[$context['session_var']] = $context['session_id'];
276
-	foreach ($_POST as $k => $v)
277
-		$context['post_data'] .= adminLogin_outputPostVars($k, $v);
291
+	foreach ($_POST as $k => $v) {
292
+			$context['post_data'] .= adminLogin_outputPostVars($k, $v);
293
+	}
278 294
 
279 295
 	// Now we'll use the admin_login sub template of the Login template.
280 296
 	$context['sub_template'] = 'admin_login';
281 297
 
282 298
 	// And title the page something like "Login".
283
-	if (!isset($context['page_title']))
284
-		$context['page_title'] = $txt['login'];
299
+	if (!isset($context['page_title'])) {
300
+			$context['page_title'] = $txt['login'];
301
+	}
285 302
 
286 303
 	// The type of action.
287 304
 	$context['sessionCheckType'] = $type;
@@ -304,14 +321,15 @@  discard block
 block discarded – undo
304 321
 {
305 322
 	global $smcFunc;
306 323
 
307
-	if (!is_array($v))
308
-		return '
324
+	if (!is_array($v)) {
325
+			return '
309 326
 <input type="hidden" name="' . $smcFunc['htmlspecialchars']($k) . '" value="' . strtr($v, array('"' => '&quot;', '<' => '&lt;', '>' => '&gt;')) . '">';
310
-	else
327
+	} else
311 328
 	{
312 329
 		$ret = '';
313
-		foreach ($v as $k2 => $v2)
314
-			$ret .= adminLogin_outputPostVars($k . '[' . $k2 . ']', $v2);
330
+		foreach ($v as $k2 => $v2) {
331
+					$ret .= adminLogin_outputPostVars($k . '[' . $k2 . ']', $v2);
332
+		}
315 333
 
316 334
 		return $ret;
317 335
 	}
@@ -338,18 +356,20 @@  discard block
 block discarded – undo
338 356
 		foreach ($get as $k => $v)
339 357
 		{
340 358
 			// Only if it's not already in the $scripturl!
341
-			if (!isset($temp[$k]))
342
-				$query_string .= urlencode($k) . '=' . urlencode($v) . ';';
359
+			if (!isset($temp[$k])) {
360
+							$query_string .= urlencode($k) . '=' . urlencode($v) . ';';
361
+			}
343 362
 			// If it changed, put it out there, but with an ampersand.
344
-			elseif ($temp[$k] != $get[$k])
345
-				$query_string .= urlencode($k) . '=' . urlencode($v) . '&amp;';
363
+			elseif ($temp[$k] != $get[$k]) {
364
+							$query_string .= urlencode($k) . '=' . urlencode($v) . '&amp;';
365
+			}
346 366
 		}
347
-	}
348
-	else
367
+	} else
349 368
 	{
350 369
 		// Add up all the data from $_GET into get_data.
351
-		foreach ($get as $k => $v)
352
-			$query_string .= urlencode($k) . '=' . urlencode($v) . ';';
370
+		foreach ($get as $k => $v) {
371
+					$query_string .= urlencode($k) . '=' . urlencode($v) . ';';
372
+		}
353 373
 	}
354 374
 
355 375
 	$query_string = substr($query_string, 0, -1);
@@ -372,8 +392,9 @@  discard block
 block discarded – undo
372 392
 	global $scripturl, $user_info, $smcFunc;
373 393
 
374 394
 	// If it's not already an array, make it one.
375
-	if (!is_array($names))
376
-		$names = explode(',', $names);
395
+	if (!is_array($names)) {
396
+			$names = explode(',', $names);
397
+	}
377 398
 
378 399
 	$maybe_email = false;
379 400
 	foreach ($names as $i => $name)
@@ -384,10 +405,11 @@  discard block
 block discarded – undo
384 405
 		$maybe_email |= strpos($name, '@') !== false;
385 406
 
386 407
 		// Make it so standard wildcards will work. (* and ?)
387
-		if ($use_wildcards)
388
-			$names[$i] = strtr($names[$i], array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_', '\'' => '&#039;'));
389
-		else
390
-			$names[$i] = strtr($names[$i], array('\'' => '&#039;'));
408
+		if ($use_wildcards) {
409
+					$names[$i] = strtr($names[$i], array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_', '\'' => '&#039;'));
410
+		} else {
411
+					$names[$i] = strtr($names[$i], array('\'' => '&#039;'));
412
+		}
391 413
 	}
392 414
 
393 415
 	// What are we using to compare?
@@ -397,11 +419,12 @@  discard block
 block discarded – undo
397 419
 	$results = array();
398 420
 
399 421
 	// This ensures you can't search someones email address if you can't see it.
400
-	if (($use_wildcards || $maybe_email) && allowedTo('moderate_forum'))
401
-		$email_condition = '
422
+	if (($use_wildcards || $maybe_email) && allowedTo('moderate_forum')) {
423
+			$email_condition = '
402 424
 			OR (email_address ' . $comparison . ' \'' . implode('\') OR (email_address ' . $comparison . ' \'', $names) . '\')';
403
-	else
404
-		$email_condition = '';
425
+	} else {
426
+			$email_condition = '';
427
+	}
405 428
 
406 429
 	// Get the case of the columns right - but only if we need to as things like MySQL will go slow needlessly otherwise.
407 430
 	$member_name = $smcFunc['db_case_sensitive'] ? 'LOWER(member_name)' : 'member_name';
@@ -459,10 +482,11 @@  discard block
 block discarded – undo
459 482
 	$context['template_layers'] = array();
460 483
 	$context['sub_template'] = 'find_members';
461 484
 
462
-	if (isset($_REQUEST['search']))
463
-		$context['last_search'] = $smcFunc['htmlspecialchars']($_REQUEST['search'], ENT_QUOTES);
464
-	else
465
-		$_REQUEST['start'] = 0;
485
+	if (isset($_REQUEST['search'])) {
486
+			$context['last_search'] = $smcFunc['htmlspecialchars']($_REQUEST['search'], ENT_QUOTES);
487
+	} else {
488
+			$_REQUEST['start'] = 0;
489
+	}
466 490
 
467 491
 	// Allow the user to pass the input to be added to to the box.
468 492
 	$context['input_box_name'] = isset($_REQUEST['input']) && preg_match('~^[\w-]+$~', $_REQUEST['input']) === 1 ? $_REQUEST['input'] : 'to';
@@ -503,10 +527,10 @@  discard block
 block discarded – undo
503 527
 		);
504 528
 
505 529
 		$context['results'] = array_slice($context['results'], $_REQUEST['start'], 7);
530
+	} else {
531
+			$context['links']['up'] = $scripturl . '?action=pm;sa=send' . (empty($_REQUEST['u']) ? '' : ';u=' . $_REQUEST['u']);
532
+	}
506 533
 	}
507
-	else
508
-		$context['links']['up'] = $scripturl . '?action=pm;sa=send' . (empty($_REQUEST['u']) ? '' : ';u=' . $_REQUEST['u']);
509
-}
510 534
 
511 535
 /**
512 536
  * Outputs each member name on its own line.
@@ -522,8 +546,9 @@  discard block
 block discarded – undo
522 546
 	$_REQUEST['search'] = trim($smcFunc['strtolower']($_REQUEST['search']));
523 547
 	$_REQUEST['search'] = strtr($_REQUEST['search'], array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_', '&#038;' => '&amp;'));
524 548
 
525
-	if (function_exists('iconv'))
526
-		header('Content-Type: text/plain; charset=UTF-8');
549
+	if (function_exists('iconv')) {
550
+			header('Content-Type: text/plain; charset=UTF-8');
551
+	}
527 552
 
528 553
 	$request = $smcFunc['db_query']('', '
529 554
 		SELECT real_name
@@ -543,14 +568,16 @@  discard block
 block discarded – undo
543 568
 		if (function_exists('iconv'))
544 569
 		{
545 570
 			$utf8 = iconv($txt['lang_character_set'], 'UTF-8', $row['real_name']);
546
-			if ($utf8)
547
-				$row['real_name'] = $utf8;
571
+			if ($utf8) {
572
+							$row['real_name'] = $utf8;
573
+			}
548 574
 		}
549 575
 
550 576
 		$row['real_name'] = strtr($row['real_name'], array('&amp;' => '&#038;', '&lt;' => '&#060;', '&gt;' => '&#062;', '&quot;' => '&#034;'));
551 577
 
552
-		if (preg_match('~&#\d+;~', $row['real_name']) != 0)
553
-			$row['real_name'] = preg_replace_callback('~&#(\d+);~', 'fixchar__callback', $row['real_name']);
578
+		if (preg_match('~&#\d+;~', $row['real_name']) != 0) {
579
+					$row['real_name'] = preg_replace_callback('~&#(\d+);~', 'fixchar__callback', $row['real_name']);
580
+		}
554 581
 
555 582
 		echo $row['real_name'], "\n";
556 583
 	}
@@ -607,9 +634,9 @@  discard block
 block discarded – undo
607 634
 
608 635
 		// Update the database...
609 636
 		updateMemberData($memID, array('member_name' => $user, 'passwd' => $newPassword_sha1));
637
+	} else {
638
+			updateMemberData($memID, array('passwd' => $newPassword_sha1));
610 639
 	}
611
-	else
612
-		updateMemberData($memID, array('passwd' => $newPassword_sha1));
613 640
 
614 641
 	call_integration_hook('integrate_reset_pass', array($old_user, $user, $newPassword));
615 642
 
@@ -640,31 +667,37 @@  discard block
 block discarded – undo
640 667
 	$errors = array();
641 668
 
642 669
 	// Don't use too long a name.
643
-	if ($smcFunc['strlen']($username) > 25)
644
-		$errors[] = array('lang', 'error_long_name');
670
+	if ($smcFunc['strlen']($username) > 25) {
671
+			$errors[] = array('lang', 'error_long_name');
672
+	}
645 673
 
646 674
 	// No name?!  How can you register with no name?
647
-	if ($username == '')
648
-		$errors[] = array('lang', 'need_username');
675
+	if ($username == '') {
676
+			$errors[] = array('lang', 'need_username');
677
+	}
649 678
 
650 679
 	// Only these characters are permitted.
651
-	if (in_array($username, array('_', '|')) || preg_match('~[<>&"\'=\\\\]~', preg_replace('~&#(?:\\d{1,7}|x[0-9a-fA-F]{1,6});~', '', $username)) != 0 || strpos($username, '[code') !== false || strpos($username, '[/code') !== false)
652
-		$errors[] = array('lang', 'error_invalid_characters_username');
680
+	if (in_array($username, array('_', '|')) || preg_match('~[<>&"\'=\\\\]~', preg_replace('~&#(?:\\d{1,7}|x[0-9a-fA-F]{1,6});~', '', $username)) != 0 || strpos($username, '[code') !== false || strpos($username, '[/code') !== false) {
681
+			$errors[] = array('lang', 'error_invalid_characters_username');
682
+	}
653 683
 
654
-	if (stristr($username, $txt['guest_title']) !== false)
655
-		$errors[] = array('lang', 'username_reserved', 'general', array($txt['guest_title']));
684
+	if (stristr($username, $txt['guest_title']) !== false) {
685
+			$errors[] = array('lang', 'username_reserved', 'general', array($txt['guest_title']));
686
+	}
656 687
 
657 688
 	if ($check_reserved_name)
658 689
 	{
659 690
 		require_once($sourcedir . '/Subs-Members.php');
660
-		if (isReservedName($username, $memID, false))
661
-			$errors[] = array('done', '(' . $smcFunc['htmlspecialchars']($username) . ') ' . $txt['name_in_use']);
691
+		if (isReservedName($username, $memID, false)) {
692
+					$errors[] = array('done', '(' . $smcFunc['htmlspecialchars']($username) . ') ' . $txt['name_in_use']);
693
+		}
662 694
 	}
663 695
 
664
-	if ($return_error)
665
-		return $errors;
666
-	elseif (empty($errors))
667
-		return null;
696
+	if ($return_error) {
697
+			return $errors;
698
+	} elseif (empty($errors)) {
699
+			return null;
700
+	}
668 701
 
669 702
 	loadLanguage('Errors');
670 703
 	$error = $errors[0];
@@ -690,22 +723,26 @@  discard block
 block discarded – undo
690 723
 	global $modSettings, $smcFunc;
691 724
 
692 725
 	// Perform basic requirements first.
693
-	if ($smcFunc['strlen']($password) < (empty($modSettings['password_strength']) ? 4 : 8))
694
-		return 'short';
726
+	if ($smcFunc['strlen']($password) < (empty($modSettings['password_strength']) ? 4 : 8)) {
727
+			return 'short';
728
+	}
695 729
 
696 730
 	// Is this enough?
697
-	if (empty($modSettings['password_strength']))
698
-		return null;
731
+	if (empty($modSettings['password_strength'])) {
732
+			return null;
733
+	}
699 734
 
700 735
 	// Otherwise, perform the medium strength test - checking if password appears in the restricted string.
701
-	if (preg_match('~\b' . preg_quote($password, '~') . '\b~', implode(' ', $restrict_in)) != 0)
702
-		return 'restricted_words';
703
-	elseif ($smcFunc['strpos']($password, $username) !== false)
704
-		return 'restricted_words';
736
+	if (preg_match('~\b' . preg_quote($password, '~') . '\b~', implode(' ', $restrict_in)) != 0) {
737
+			return 'restricted_words';
738
+	} elseif ($smcFunc['strpos']($password, $username) !== false) {
739
+			return 'restricted_words';
740
+	}
705 741
 
706 742
 	// If just medium, we're done.
707
-	if ($modSettings['password_strength'] == 1)
708
-		return null;
743
+	if ($modSettings['password_strength'] == 1) {
744
+			return null;
745
+	}
709 746
 
710 747
 	// Otherwise, hard test next, check for numbers and letters, uppercase too.
711 748
 	$good = preg_match('~(\D\d|\d\D)~', $password) != 0;
@@ -737,14 +774,16 @@  discard block
 block discarded – undo
737 774
 			)
738 775
 		);
739 776
 		$groups = array();
740
-		while ($row = $smcFunc['db_fetch_assoc']($request))
741
-			$groups[] = $row['id_group'];
777
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
778
+					$groups[] = $row['id_group'];
779
+		}
742 780
 		$smcFunc['db_free_result']($request);
743 781
 
744
-		if (empty($groups))
745
-			$group_query = '0=1';
746
-		else
747
-			$group_query = 'id_group IN (' . implode(',', $groups) . ')';
782
+		if (empty($groups)) {
783
+					$group_query = '0=1';
784
+		} else {
785
+					$group_query = 'id_group IN (' . implode(',', $groups) . ')';
786
+		}
748 787
 	}
749 788
 
750 789
 	// Then, same again, just the boards this time!
@@ -754,10 +793,11 @@  discard block
 block discarded – undo
754 793
 	{
755 794
 		$boards = boardsAllowedTo('moderate_board', true);
756 795
 
757
-		if (empty($boards))
758
-			$board_query = '0=1';
759
-		else
760
-			$board_query = 'id_board IN (' . implode(',', $boards) . ')';
796
+		if (empty($boards)) {
797
+					$board_query = '0=1';
798
+		} else {
799
+					$board_query = 'id_board IN (' . implode(',', $boards) . ')';
800
+		}
761 801
 	}
762 802
 
763 803
 	// What boards are they the moderator of?
@@ -772,8 +812,9 @@  discard block
 block discarded – undo
772 812
 				'current_member' => $user_info['id'],
773 813
 			)
774 814
 		);
775
-		while ($row = $smcFunc['db_fetch_assoc']($request))
776
-			$boards_mod[] = $row['id_board'];
815
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
816
+					$boards_mod[] = $row['id_board'];
817
+		}
777 818
 		$smcFunc['db_free_result']($request);
778 819
 
779 820
 		// Can any of the groups they're in moderate any of the boards?
@@ -785,8 +826,9 @@  discard block
 block discarded – undo
785 826
 				'groups' => $user_info['groups'],
786 827
 			)
787 828
 		);
788
-		while ($row = $smcFunc['db_fetch_assoc']($request))
789
-			$boards_mod[] = $row['id_board'];
829
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
830
+					$boards_mod[] = $row['id_board'];
831
+		}
790 832
 		$smcFunc['db_free_result']($request);
791 833
 
792 834
 		// Just in case we've got duplicates here...
@@ -831,10 +873,12 @@  discard block
 block discarded – undo
831 873
 	global $modSettings;
832 874
 
833 875
 	// In case a customization wants to override the default settings
834
-	if ($httponly === null)
835
-		$httponly = !empty($modSettings['httponlyCookies']);
836
-	if ($secure === null)
837
-		$secure = !empty($modSettings['secureCookies']);
876
+	if ($httponly === null) {
877
+			$httponly = !empty($modSettings['httponlyCookies']);
878
+	}
879
+	if ($secure === null) {
880
+			$secure = !empty($modSettings['secureCookies']);
881
+	}
838 882
 
839 883
 	// Intercept cookie?
840 884
 	call_integration_hook('integrate_cookie', array($name, $value, $expire, $path, $domain, $secure, $httponly));
@@ -854,8 +898,9 @@  discard block
 block discarded – undo
854 898
 function hash_password($username, $password, $cost = null)
855 899
 {
856 900
 	global $sourcedir, $smcFunc, $modSettings;
857
-	if (!function_exists('password_hash'))
858
-		require_once($sourcedir . '/Subs-Password.php');
901
+	if (!function_exists('password_hash')) {
902
+			require_once($sourcedir . '/Subs-Password.php');
903
+	}
859 904
 
860 905
 	$cost = empty($cost) ? (empty($modSettings['bcrypt_hash_cost']) ? 10 : $modSettings['bcrypt_hash_cost']) : $cost;
861 906
 
@@ -887,8 +932,9 @@  discard block
 block discarded – undo
887 932
 function hash_verify_password($username, $password, $hash)
888 933
 {
889 934
 	global $sourcedir, $smcFunc;
890
-	if (!function_exists('password_verify'))
891
-		require_once($sourcedir . '/Subs-Password.php');
935
+	if (!function_exists('password_verify')) {
936
+			require_once($sourcedir . '/Subs-Password.php');
937
+	}
892 938
 
893 939
 	return password_verify($smcFunc['strtolower']($username) . $password, $hash);
894 940
 }
Please login to merge, or discard this patch.
Themes/default/ReportToMod.template.php 1 patch
Braces   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -62,16 +62,17 @@
 block discarded – undo
62 62
 					<div id="error_box" class="errorbox">
63 63
 						<ul id="error_list">';
64 64
 
65
-		foreach ($context['post_errors'] as $key => $error)
66
-			echo '
65
+		foreach ($context['post_errors'] as $key => $error) {
66
+					echo '
67 67
 							<li id="error_', $key, '" class="error">', $error, '</li>';
68
+		}
68 69
 
69 70
 		echo '
70 71
 						</ul>';
71
-	}
72
-	else
73
-		echo '
72
+	} else {
73
+			echo '
74 74
 						<div style="display:none" id="error_box" class="errorbox">';
75
+	}
75 76
 
76 77
 	echo '
77 78
 					</div>';
Please login to merge, or discard this patch.
Sources/CacheAPI-smf.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -180,7 +180,7 @@
 block discarded – undo
180 180
 	 *
181 181
 	 * @access public
182 182
 	 * @param string $dir A valid path
183
-	 * @return boolean If this was successful or not.
183
+	 * @return boolean|null If this was successful or not.
184 184
 	 */
185 185
 	public function setCachedir($dir = null)
186 186
 	{
Please login to merge, or discard this patch.
Braces   +36 added lines, -26 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 4
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
@@ -43,8 +44,9 @@  discard block
 block discarded – undo
43 44
 	{
44 45
 		$supported = is_writable($this->cachedir);
45 46
 
46
-		if ($test)
47
-			return $supported;
47
+		if ($test) {
48
+					return $supported;
49
+		}
48 50
 		return parent::isSupported() && $supported;
49 51
 	}
50 52
 
@@ -61,11 +63,13 @@  discard block
 block discarded – undo
61 63
 		{
62 64
 			// Work around Zend's opcode caching (PHP 5.5+), they would cache older files for a couple of seconds
63 65
 			// causing newer files to take effect a while later.
64
-			if (function_exists('opcache_invalidate'))
65
-				opcache_invalidate($cachedir . '/data_' . $key . '.php', true);
66
+			if (function_exists('opcache_invalidate')) {
67
+							opcache_invalidate($cachedir . '/data_' . $key . '.php', true);
68
+			}
66 69
 
67
-			if (function_exists('apc_delete_file'))
68
-				@apc_delete_file($cachedir . '/data_' . $key . '.php');
70
+			if (function_exists('apc_delete_file')) {
71
+							@apc_delete_file($cachedir . '/data_' . $key . '.php');
72
+			}
69 73
 
70 74
 			// php will cache file_exists et all, we can't 100% depend on its results so proceed with caution
71 75
 			@include($cachedir . '/data_' . $key . '.php');
@@ -89,16 +93,18 @@  discard block
 block discarded – undo
89 93
 
90 94
 		// Work around Zend's opcode caching (PHP 5.5+), they would cache older files for a couple of seconds
91 95
 		// causing newer files to take effect a while later.
92
-		if (function_exists('opcache_invalidate'))
93
-			opcache_invalidate($cachedir . '/data_' . $key . '.php', true);
96
+		if (function_exists('opcache_invalidate')) {
97
+					opcache_invalidate($cachedir . '/data_' . $key . '.php', true);
98
+		}
94 99
 
95
-		if (function_exists('apc_delete_file'))
96
-			@apc_delete_file($cachedir . '/data_' . $key . '.php');
100
+		if (function_exists('apc_delete_file')) {
101
+					@apc_delete_file($cachedir . '/data_' . $key . '.php');
102
+		}
97 103
 
98 104
 		// Otherwise custom cache?
99
-		if ($value === null)
100
-			@unlink($cachedir . '/data_' . $key . '.php');
101
-		else
105
+		if ($value === null) {
106
+					@unlink($cachedir . '/data_' . $key . '.php');
107
+		} else
102 108
 		{
103 109
 			$cache_data = '<' . '?' . 'php if (!defined(\'SMF\')) die; if (' . (time() + $ttl) . ' < time()) $expired = true; else{$expired = false; $value = \'' . addcslashes($value, '\\\'') . '\';}' . '?' . '>';
104 110
 
@@ -109,9 +115,9 @@  discard block
 block discarded – undo
109 115
 			{
110 116
 				@unlink($cachedir . '/data_' . $key . '.php');
111 117
 				return false;
118
+			} else {
119
+							return true;
112 120
 			}
113
-			else
114
-				return true;
115 121
 		}
116 122
 	}
117 123
 
@@ -123,15 +129,17 @@  discard block
 block discarded – undo
123 129
 		$cachedir = $this->cachedir;
124 130
 
125 131
 		// No directory = no game.
126
-		if (!is_dir($cachedir))
127
-			return;
132
+		if (!is_dir($cachedir)) {
133
+					return;
134
+		}
128 135
 
129 136
 		// Remove the files in SMF's own disk cache, if any
130 137
 		$dh = opendir($cachedir);
131 138
 		while ($file = readdir($dh))
132 139
 		{
133
-			if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type))
134
-				@unlink($cachedir . '/' . $file);
140
+			if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) {
141
+							@unlink($cachedir . '/' . $file);
142
+			}
135 143
 		}
136 144
 		closedir($dh);
137 145
 
@@ -165,8 +173,9 @@  discard block
 block discarded – undo
165 173
 		$config_vars[] = $txt['cache_smf_settings'];
166 174
 		$config_vars[] = array('cachedir', $txt['cachedir'], 'file', 'text', 36, 'cache_cachedir');
167 175
 
168
-		if (!isset($context['settings_post_javascript']))
169
-			$context['settings_post_javascript'] = '';
176
+		if (!isset($context['settings_post_javascript'])) {
177
+					$context['settings_post_javascript'] = '';
178
+		}
170 179
 
171 180
 		$context['settings_post_javascript'] .= '
172 181
 			$("#cache_accelerator").change(function (e) {
@@ -187,10 +196,11 @@  discard block
 block discarded – undo
187 196
 		global $cachedir;
188 197
 
189 198
 		// If its invalid, use SMF's.
190
-		if (is_null($dir) || !is_writable($dir))
191
-			$this->cachedir = $cachedir;
192
-		else
193
-			$this->cachedir = $dir;
199
+		if (is_null($dir) || !is_writable($dir)) {
200
+					$this->cachedir = $cachedir;
201
+		} else {
202
+					$this->cachedir = $dir;
203
+		}
194 204
 	}
195 205
 
196 206
 	/**
Please login to merge, or discard this patch.
Sources/CacheAPI-sqlite.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@
 block discarded – undo
143 143
 	 *
144 144
 	 * @param string $dir A valid path
145 145
 	 *
146
-	 * @return boolean If this was successful or not.
146
+	 * @return boolean|null If this was successful or not.
147 147
 	 */
148 148
 	public function setCachedir($dir = null)
149 149
 	{
Please login to merge, or discard this patch.
Braces   +16 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 4
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * SQLite Cache API class
@@ -68,8 +69,9 @@  discard block
 block discarded – undo
68 69
 	{
69 70
 		$supported = class_exists("SQLite3") && is_writable($this->cachedir);
70 71
 
71
-		if ($test)
72
-			return $supported;
72
+		if ($test) {
73
+					return $supported;
74
+		}
73 75
 
74 76
 		return parent::isSupported() && $supported;
75 77
 	}
@@ -84,8 +86,9 @@  discard block
 block discarded – undo
84 86
 		$result = $this->cacheDB->query($query);
85 87
 
86 88
 		$value = null;
87
-		while ($res = $result->fetchArray(SQLITE3_ASSOC))
88
-			$value = $res['value'];
89
+		while ($res = $result->fetchArray(SQLITE3_ASSOC)) {
90
+					$value = $res['value'];
91
+		}
89 92
 
90 93
 		return !empty($value) ? $value : null;
91 94
 	}
@@ -125,8 +128,9 @@  discard block
 block discarded – undo
125 128
 		$config_vars[] = $txt['cache_sqlite_settings'];
126 129
 		$config_vars[] = array('cachedir_sqlite', $txt['cachedir_sqlite'], 'file', 'text', 36, 'cache_sqlite_cachedir');
127 130
 
128
-		if (!isset($context['settings_post_javascript']))
129
-			$context['settings_post_javascript'] = '';
131
+		if (!isset($context['settings_post_javascript'])) {
132
+					$context['settings_post_javascript'] = '';
133
+		}
130 134
 
131 135
 		$context['settings_post_javascript'] .= '
132 136
 			$("#cache_accelerator").change(function (e) {
@@ -149,10 +153,11 @@  discard block
 block discarded – undo
149 153
 		global $cachedir_sqlite;
150 154
 
151 155
 		// If its invalid, use SMF's.
152
-		if (is_null($dir) || !is_writable($dir))
153
-			$this->cachedir = $cachedir_sqlite;
154
-		else
155
-			$this->cachedir = $dir;
156
+		if (is_null($dir) || !is_writable($dir)) {
157
+					$this->cachedir = $cachedir_sqlite;
158
+		} else {
159
+					$this->cachedir = $dir;
160
+		}
156 161
 	}
157 162
 
158 163
 	/**
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 4
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
@@ -27,8 +28,9 @@  discard block
 block discarded – undo
27 28
 	{
28 29
 		$supported = function_exists('apc_fetch') && function_exists('apc_store');
29 30
 
30
-		if ($test)
31
-			return $supported;
31
+		if ($test) {
32
+					return $supported;
33
+		}
32 34
 		return parent::isSupported() && $supported;
33 35
 	}
34 36
 
@@ -50,10 +52,11 @@  discard block
 block discarded – undo
50 52
 		$key = $this->prefix . strtr($key, ':/', '-_');
51 53
 
52 54
 		// An extended key is needed to counteract a bug in APC.
53
-		if ($value === null)
54
-			return apc_delete($key . 'smf');
55
-		else
56
-			return apc_store($key . 'smf', $value, $ttl);
55
+		if ($value === null) {
56
+					return apc_delete($key . 'smf');
57
+		} else {
58
+					return apc_store($key . 'smf', $value, $ttl);
59
+		}
57 60
 	}
58 61
 
59 62
 	/**
@@ -67,9 +70,9 @@  discard block
 block discarded – undo
67 70
 			// Always returns true.
68 71
 			apc_clear_cache('user');
69 72
 			apc_clear_cache('system');
73
+		} elseif ($type === 'user') {
74
+					apc_clear_cache('user');
70 75
 		}
71
-		elseif ($type === 'user')
72
-			apc_clear_cache('user');
73 76
 
74 77
 		$this->invalidateCache();
75 78
 		return true;
Please login to merge, or discard this patch.
Sources/CacheAPI-xcache.php 1 patch
Braces   +19 added lines, -13 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 4
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
@@ -44,8 +45,9 @@  discard block
 block discarded – undo
44 45
 	{
45 46
 		$supported = function_exists('xcache_get') && function_exists('xcache_set') && ini_get('xcache.var_size') > 0;
46 47
 
47
-		if ($test)
48
-			return $supported;
48
+		if ($test) {
49
+					return $supported;
50
+		}
49 51
 		return parent::isSupported() && $supported;
50 52
 	}
51 53
 
@@ -66,10 +68,11 @@  discard block
 block discarded – undo
66 68
 	{
67 69
 		$key = $this->prefix . strtr($key, ':/', '-_');
68 70
 
69
-		if ($value === null)
70
-			return xcache_unset($key);
71
-		else
72
-			return xcache_set($key, $value, $ttl);
71
+		if ($value === null) {
72
+					return xcache_unset($key);
73
+		} else {
74
+					return xcache_set($key, $value, $ttl);
75
+		}
73 76
 	}
74 77
 
75 78
 	/**
@@ -88,10 +91,12 @@  discard block
 block discarded – undo
88 91
 		}
89 92
 
90 93
 		// if passed a type, clear that type out
91
-		if ($type === '' || $type === 'user')
92
-			xcache_clear_cache(XC_TYPE_VAR, 0);
93
-		if ($type === '' || $type === 'data')
94
-			xcache_clear_cache(XC_TYPE_PHP, 0);
94
+		if ($type === '' || $type === 'user') {
95
+					xcache_clear_cache(XC_TYPE_VAR, 0);
96
+		}
97
+		if ($type === '' || $type === 'data') {
98
+					xcache_clear_cache(XC_TYPE_PHP, 0);
99
+		}
95 100
 
96 101
 		$this->invalidateCache();
97 102
 		return true;
@@ -110,8 +115,9 @@  discard block
 block discarded – undo
110 115
 		// While we could md5 this when saving, this could be tricky to be sure it doesn't get corrupted on additional saves.
111 116
 		$config_vars[] = array('xcache_adminpass', $txt['cache_xcache_adminpass'], 'db', 'text', 0);
112 117
 
113
-		if (!isset($context['settings_post_javascript']))
114
-			$context['settings_post_javascript'] = '';
118
+		if (!isset($context['settings_post_javascript'])) {
119
+					$context['settings_post_javascript'] = '';
120
+		}
115 121
 
116 122
 		$context['settings_post_javascript'] .= '
117 123
 			$("#cache_accelerator").change(function (e) {
Please login to merge, or discard this patch.