Passed
Pull Request — release-2.1 (#6368)
by Mathias
04:06
created
Sources/Cache/APIs/MemcacheImplementation.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -181,15 +181,15 @@  discard block
 block discarded – undo
181 181
 		$class_name = $this->getImplementationClassKeyName();
182 182
 		$class_name_txt_key = strtolower($class_name);
183 183
 
184
-		$config_vars[] = $txt['cache_'. $class_name_txt_key .'_settings'];
184
+		$config_vars[] = $txt['cache_' . $class_name_txt_key . '_settings'];
185 185
 		$config_vars[] = array(
186 186
 			self::CLASS_KEY,
187
-			$txt['cache_'. $class_name_txt_key .'_servers'],
187
+			$txt['cache_' . $class_name_txt_key . '_servers'],
188 188
 			'file',
189 189
 			'text',
190 190
 			0,
191
-			'cache_'. $class_name_txt_key,
192
-			'subtext' => $txt['cache_'. $class_name_txt_key .'_servers_subtext']);
191
+			'cache_' . $class_name_txt_key,
192
+			'subtext' => $txt['cache_' . $class_name_txt_key . '_servers_subtext']);
193 193
 
194 194
 		if (!isset($context['settings_post_javascript']))
195 195
 			$context['settings_post_javascript'] = '';
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 		$context['settings_post_javascript'] .= '
198 198
 			$("#cache_accelerator").change(function (e) {
199 199
 				var cache_type = e.currentTarget.value;
200
-				$("#'. self::CLASS_KEY .'").prop("disabled", cache_type != "'. $class_name .'");
200
+				$("#'. self::CLASS_KEY . '").prop("disabled", cache_type != "' . $class_name . '");
201 201
 			});';
202 202
 	}
203 203
 
Please login to merge, or discard this patch.
Sources/Cache/APIs/Sqlite.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
 		$class_name = $this->getImplementationClassKeyName();
132 132
 		$class_name_txt_key = strtolower($class_name);
133 133
 
134
-		$config_vars[] = $txt['cache_'. $class_name_txt_key .'_settings'];
134
+		$config_vars[] = $txt['cache_' . $class_name_txt_key . '_settings'];
135 135
 		$config_vars[] = array(
136
-			'cachedir_'. $class_name_txt_key,
137
-			$txt['cachedir_'. $class_name_txt_key],
136
+			'cachedir_' . $class_name_txt_key,
137
+			$txt['cachedir_' . $class_name_txt_key],
138 138
 			'file',
139 139
 			'text',
140 140
 			36,
141
-			'cache_'. $class_name_txt_key .'_cachedir');
141
+			'cache_' . $class_name_txt_key . '_cachedir');
142 142
 
143 143
 		if (!isset($context['settings_post_javascript']))
144 144
 			$context['settings_post_javascript'] = '';
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 		$context['settings_post_javascript'] .= '
147 147
 			$("#cache_accelerator").change(function (e) {
148 148
 				var cache_type = e.currentTarget.value;
149
-				$("#cachedir_'. $class_name_txt_key .'").prop("disabled", cache_type != "'. $class_name .'");
149
+				$("#cachedir_'. $class_name_txt_key . '").prop("disabled", cache_type != "' . $class_name . '");
150 150
 			});';
151 151
 	}
152 152
 
Please login to merge, or discard this patch.
Sources/Help.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -163,7 +163,8 @@
 block discarded – undo
163 163
 	else
164 164
 		$context['help_text'] = $_GET['help'];
165 165
 
166
-	switch ($_GET['help']) {
166
+	switch ($_GET['help'])
167
+	{
167 168
 		case 'cal_short_months':
168 169
 			$context['help_text'] = sprintf($context['help_text'], $txt['months_short'][1], $txt['months_titles'][1]);
169 170
 			break;
Please login to merge, or discard this patch.
Sources/Subs.php 2 patches
Braces   +3 added lines, -8 removed lines patch added patch discarded remove patch
@@ -279,7 +279,6 @@  discard block
 block discarded – undo
279 279
 		$condition = 'id_member IN ({array_int:members})';
280 280
 		$parameters['members'] = $members;
281 281
 	}
282
-
283 282
 	elseif ($members === null)
284 283
 		$condition = '1=1';
285 284
 
@@ -382,11 +381,9 @@  discard block
 block discarded – undo
382 381
 				$val = $val . ' END';
383 382
 				$type = 'raw';
384 383
 			}
385
-
386 384
 			else
387 385
 				$val = alert_count($members, true);
388 386
 		}
389
-
390 387
 		elseif ($type == 'int' && ($val === '+' || $val === '-'))
391 388
 		{
392 389
 			$val = $var . ' ' . $val . ' 1';
@@ -2176,12 +2173,12 @@  discard block
 block discarded – undo
2176 2173
 			'tag' => 'cowsay',
2177 2174
 			'parameters' => array(
2178 2175
 				'e' => array('optional' => true, 'quoted' => true, 'match' => '(.*?)', 'default' => 'oo', 'validate' => function ($eyes) use ($smcFunc)
2179
-					{
2176
+				{
2180 2177
 						return $smcFunc['substr']($eyes . 'oo', 0, 2);
2181 2178
 					},
2182 2179
 				),
2183 2180
 				't' => array('optional' => true, 'quoted' => true, 'match' => '(.*?)', 'default' => '  ', 'validate' => function ($tongue) use ($smcFunc)
2184
-					{
2181
+				{
2185 2182
 						return $smcFunc['substr']($tongue . '  ', 0, 2);
2186 2183
 					},
2187 2184
 				),
@@ -3279,7 +3276,7 @@  discard block
 block discarded – undo
3279 3276
 
3280 3277
 	// Replace away!
3281 3278
 	$message = preg_replace_callback($smileyPregSearch, function($matches) use ($smileyPregReplacements)
3282
-		{
3279
+	{
3283 3280
 			return $smileyPregReplacements[$matches[1]];
3284 3281
 		}, $message);
3285 3282
 }
@@ -4077,7 +4074,6 @@  discard block
 block discarded – undo
4077 4074
 				if (!isset($minSeed) && isset($js_file['options']['seed']))
4078 4075
 					$minSeed = $js_file['options']['seed'];
4079 4076
 			}
4080
-
4081 4077
 			else
4082 4078
 			{
4083 4079
 				echo '
@@ -6360,7 +6356,6 @@  discard block
 block discarded – undo
6360 6356
 			$isWritable = true;
6361 6357
 			break;
6362 6358
 		}
6363
-
6364 6359
 		else
6365 6360
 			@chmod($file, $val);
6366 6361
 	}
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 			{
378 378
 				$val = 'CASE ';
379 379
 				foreach ($members as $k => $v)
380
-					$val .= 'WHEN id_member = ' . $v . ' THEN '. alert_count($v, true) . ' ';
380
+					$val .= 'WHEN id_member = ' . $v . ' THEN ' . alert_count($v, true) . ' ';
381 381
 
382 382
 				$val = $val . ' END';
383 383
 				$type = 'raw';
@@ -1039,11 +1039,11 @@  discard block
 block discarded – undo
1039 1039
 			// Anything that isn't a specification, punctuation mark, or whitespace.
1040 1040
 			'~(?<!%)\p{L}|[^\p{L}\p{P}\s]~u',
1041 1041
 			// A series of punctuation marks (except %), possibly separated by whitespace.
1042
-			'~([^%\P{P}])(\s*)(?'.'>(\1|[^%\P{Po}])\s*(?!$))*~u',
1042
+			'~([^%\P{P}])(\s*)(?' . '>(\1|[^%\P{Po}])\s*(?!$))*~u',
1043 1043
 			// Unwanted trailing punctuation and whitespace.
1044
-			'~(?'.'>([\p{Pd}\p{Ps}\p{Pi}\p{Pc}]|[^%\P{Po}])\s*)*$~u',
1044
+			'~(?' . '>([\p{Pd}\p{Ps}\p{Pi}\p{Pc}]|[^%\P{Po}])\s*)*$~u',
1045 1045
 			// Unwanted opening punctuation and whitespace.
1046
-			'~^\s*(?'.'>([\p{Pd}\p{Pe}\p{Pf}\p{Pc}]|[^%\P{Po}])\s*)*~u',
1046
+			'~^\s*(?' . '>([\p{Pd}\p{Pe}\p{Pf}\p{Pc}]|[^%\P{Po}])\s*)*~u',
1047 1047
 		),
1048 1048
 		array(
1049 1049
 			'',
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 				$dt_user = new DateTime('@' . $timestamp);
1156 1156
 				$temp_offset = $dtz_user->getOffset($dt_user);
1157 1157
 				if ($temp_offset !== false)
1158
-					$user_offset = $temp_offset/3600;
1158
+					$user_offset = $temp_offset / 3600;
1159 1159
 			}
1160 1160
 		}
1161 1161
 	}
@@ -1486,7 +1486,7 @@  discard block
 block discarded – undo
1486 1486
 							$width = !empty($width) ? ' width="' . $width . '"' : '';
1487 1487
 							$height = !empty($height) ? ' height="' . $height . '"' : '';
1488 1488
 
1489
-							$returnContext .= '<div class="videocontainer"><video controls preload="metadata" src="'. $currentAttachment['href'] . '" playsinline' . $width . $height . '><a href="' . $currentAttachment['href'] . '" class="bbc_link">' . $smcFunc['htmlspecialchars'](!empty($data) ? $data : $currentAttachment['name']) . '</a></video></div>' . (!empty($data) && $data != $currentAttachment['name'] ? '<div class="smalltext">' . $data . '</div>' : '');
1489
+							$returnContext .= '<div class="videocontainer"><video controls preload="metadata" src="' . $currentAttachment['href'] . '" playsinline' . $width . $height . '><a href="' . $currentAttachment['href'] . '" class="bbc_link">' . $smcFunc['htmlspecialchars'](!empty($data) ? $data : $currentAttachment['name']) . '</a></video></div>' . (!empty($data) && $data != $currentAttachment['name'] ? '<div class="smalltext">' . $data . '</div>' : '');
1490 1490
 						}
1491 1491
 						// Audio.
1492 1492
 						elseif (strpos($currentAttachment['mime_type'], 'audio/') === 0)
@@ -1494,7 +1494,7 @@  discard block
 block discarded – undo
1494 1494
 							$width = 'max-width:100%; width: ' . (!empty($width) ? $width : '400') . 'px;';
1495 1495
 							$height = !empty($height) ? 'height: ' . $height . 'px;' : '';
1496 1496
 
1497
-							$returnContext .= (!empty($data) && $data != $currentAttachment['name'] ? $data . ' ' : '') . '<audio controls preload="none" src="'. $currentAttachment['href'] . '" class="bbc_audio" style="vertical-align:middle;' . $width . $height . '"><a href="' . $currentAttachment['href'] . '" class="bbc_link">' . $smcFunc['htmlspecialchars'](!empty($data) ? $data : $currentAttachment['name']) . '</a></audio>';
1497
+							$returnContext .= (!empty($data) && $data != $currentAttachment['name'] ? $data . ' ' : '') . '<audio controls preload="none" src="' . $currentAttachment['href'] . '" class="bbc_audio" style="vertical-align:middle;' . $width . $height . '"><a href="' . $currentAttachment['href'] . '" class="bbc_link">' . $smcFunc['htmlspecialchars'](!empty($data) ? $data : $currentAttachment['name']) . '</a></audio>';
1498 1498
 						}
1499 1499
 						// Anything else.
1500 1500
 						else
@@ -1663,7 +1663,7 @@  discard block
 block discarded – undo
1663 1663
 				'type' => 'unparsed_commas_content',
1664 1664
 				'test' => '\d+,\d+\]',
1665 1665
 				'content' => '<a href="$1" target="_blank" rel="noopener">$1</a>',
1666
-				'validate' => function (&$tag, &$data, $disabled)
1666
+				'validate' => function(&$tag, &$data, $disabled)
1667 1667
 				{
1668 1668
 					$scheme = parse_url($data[0], PHP_URL_SCHEME);
1669 1669
 					if (empty($scheme))
@@ -2201,12 +2201,12 @@  discard block
 block discarded – undo
2201 2201
 		$codes[] = array(
2202 2202
 			'tag' => 'cowsay',
2203 2203
 			'parameters' => array(
2204
-				'e' => array('optional' => true, 'quoted' => true, 'match' => '(.*?)', 'default' => 'oo', 'validate' => function ($eyes) use ($smcFunc)
2204
+				'e' => array('optional' => true, 'quoted' => true, 'match' => '(.*?)', 'default' => 'oo', 'validate' => function($eyes) use ($smcFunc)
2205 2205
 					{
2206 2206
 						return $smcFunc['substr']($eyes . 'oo', 0, 2);
2207 2207
 					},
2208 2208
 				),
2209
-				't' => array('optional' => true, 'quoted' => true, 'match' => '(.*?)', 'default' => '  ', 'validate' => function ($tongue) use ($smcFunc)
2209
+				't' => array('optional' => true, 'quoted' => true, 'match' => '(.*?)', 'default' => '  ', 'validate' => function($tongue) use ($smcFunc)
2210 2210
 					{
2211 2211
 						return $smcFunc['substr']($tongue . '  ', 0, 2);
2212 2212
 					},
@@ -3578,7 +3578,7 @@  discard block
 block discarded – undo
3578 3578
 		if ($fp != false)
3579 3579
 		{
3580 3580
 			// Send the HEAD request (since we don't have to worry about chunked, HTTP/1.1 is fine here.)
3581
-			fwrite($fp, 'HEAD /' . $match[2] . ' HTTP/1.1' . "\r\n" . 'Host: ' . $match[1] . "\r\n" . 'user-agent: '. SMF_USER_AGENT . "\r\n" . 'Connection: close' . "\r\n\r\n");
3581
+			fwrite($fp, 'HEAD /' . $match[2] . ' HTTP/1.1' . "\r\n" . 'Host: ' . $match[1] . "\r\n" . 'user-agent: ' . SMF_USER_AGENT . "\r\n" . 'Connection: close' . "\r\n\r\n");
3582 3582
 
3583 3583
 			// Read in the HTTP/1.1 or whatever.
3584 3584
 			$test = substr(fgets($fp, 11), -1);
@@ -4182,7 +4182,7 @@  discard block
 block discarded – undo
4182 4182
 	$toMinify = array();
4183 4183
 	$normal = array();
4184 4184
 
4185
-	uasort($context['css_files'], function ($a, $b)
4185
+	uasort($context['css_files'], function($a, $b)
4186 4186
 	{
4187 4187
 		return $a['options']['order_pos'] < $b['options']['order_pos'] ? -1 : ($a['options']['order_pos'] > $b['options']['order_pos'] ? 1 : 0);
4188 4188
 	});
@@ -5478,7 +5478,7 @@  discard block
 block discarded – undo
5478 5478
 			{
5479 5479
 				fwrite($fp, 'GET ' . ($match[6] !== '/' ? str_replace(' ', '%20', $match[6]) : '') . ' HTTP/1.0' . "\r\n");
5480 5480
 				fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n");
5481
-				fwrite($fp, 'user-agent: '. SMF_USER_AGENT . "\r\n");
5481
+				fwrite($fp, 'user-agent: ' . SMF_USER_AGENT . "\r\n");
5482 5482
 				if ($keep_alive)
5483 5483
 					fwrite($fp, 'connection: Keep-Alive' . "\r\n\r\n");
5484 5484
 				else
@@ -5488,7 +5488,7 @@  discard block
 block discarded – undo
5488 5488
 			{
5489 5489
 				fwrite($fp, 'POST ' . ($match[6] !== '/' ? $match[6] : '') . ' HTTP/1.0' . "\r\n");
5490 5490
 				fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n");
5491
-				fwrite($fp, 'user-agent: '. SMF_USER_AGENT . "\r\n");
5491
+				fwrite($fp, 'user-agent: ' . SMF_USER_AGENT . "\r\n");
5492 5492
 				if ($keep_alive)
5493 5493
 					fwrite($fp, 'connection: Keep-Alive' . "\r\n");
5494 5494
 				else
@@ -5736,13 +5736,13 @@  discard block
 block discarded – undo
5736 5736
 
5737 5737
 	// UTF-8 occurences of MS special characters
5738 5738
 	$findchars_utf8 = array(
5739
-		"\xe2\x80\x9a",	// single low-9 quotation mark
5740
-		"\xe2\x80\x9e",	// double low-9 quotation mark
5741
-		"\xe2\x80\xa6",	// horizontal ellipsis
5742
-		"\xe2\x80\x98",	// left single curly quote
5743
-		"\xe2\x80\x99",	// right single curly quote
5744
-		"\xe2\x80\x9c",	// left double curly quote
5745
-		"\xe2\x80\x9d",	// right double curly quote
5739
+		"\xe2\x80\x9a", // single low-9 quotation mark
5740
+		"\xe2\x80\x9e", // double low-9 quotation mark
5741
+		"\xe2\x80\xa6", // horizontal ellipsis
5742
+		"\xe2\x80\x98", // left single curly quote
5743
+		"\xe2\x80\x99", // right single curly quote
5744
+		"\xe2\x80\x9c", // left double curly quote
5745
+		"\xe2\x80\x9d", // right double curly quote
5746 5746
 	);
5747 5747
 
5748 5748
 	// windows 1252 / iso equivalents
@@ -5758,13 +5758,13 @@  discard block
 block discarded – undo
5758 5758
 
5759 5759
 	// safe replacements
5760 5760
 	$replacechars = array(
5761
-		',',	// &sbquo;
5762
-		',,',	// &bdquo;
5763
-		'...',	// &hellip;
5764
-		"'",	// &lsquo;
5765
-		"'",	// &rsquo;
5766
-		'"',	// &ldquo;
5767
-		'"',	// &rdquo;
5761
+		',', // &sbquo;
5762
+		',,', // &bdquo;
5763
+		'...', // &hellip;
5764
+		"'", // &lsquo;
5765
+		"'", // &rsquo;
5766
+		'"', // &ldquo;
5767
+		'"', // &rdquo;
5768 5768
 	);
5769 5769
 
5770 5770
 	if ($context['utf8'])
@@ -6949,7 +6949,7 @@  discard block
 block discarded – undo
6949 6949
 			EXISTS (
6950 6950
 				SELECT bpv.id_board
6951 6951
 				FROM ' . $db_prefix . 'board_permissions_view AS bpv
6952
-				WHERE bpv.id_group IN ('. implode(',', $groups) .')
6952
+				WHERE bpv.id_group IN ('. implode(',', $groups) . ')
6953 6953
 					AND bpv.deny = 0
6954 6954
 					AND bpv.id_board = b.id_board
6955 6955
 			)';
@@ -6959,7 +6959,7 @@  discard block
 block discarded – undo
6959 6959
 			AND NOT EXISTS (
6960 6960
 				SELECT bpv.id_board
6961 6961
 				FROM ' . $db_prefix . 'board_permissions_view AS bpv
6962
-				WHERE bpv.id_group IN ( '. implode(',', $groups) .')
6962
+				WHERE bpv.id_group IN ( '. implode(',', $groups) . ')
6963 6963
 					AND bpv.deny = 1
6964 6964
 					AND bpv.id_board = b.id_board
6965 6965
 			)';
@@ -7230,8 +7230,8 @@  discard block
 block discarded – undo
7230 7230
 	$i = 0;
7231 7231
 	while (empty($done))
7232 7232
 	{
7233
-		if (strpos($format, '{'. --$i . '}') !== false)
7234
-			$replacements['{'. $i . '}'] = array_pop($list);
7233
+		if (strpos($format, '{' . --$i . '}') !== false)
7234
+			$replacements['{' . $i . '}'] = array_pop($list);
7235 7235
 		else
7236 7236
 			$done = true;
7237 7237
 	}
@@ -7241,8 +7241,8 @@  discard block
 block discarded – undo
7241 7241
 	$i = 0;
7242 7242
 	while (empty($done))
7243 7243
 	{
7244
-		if (strpos($format, '{'. ++$i . '}') !== false)
7245
-			$replacements['{'. $i . '}'] = array_shift($list);
7244
+		if (strpos($format, '{' . ++$i . '}') !== false)
7245
+			$replacements['{' . $i . '}'] = array_shift($list);
7246 7246
 		else
7247 7247
 			$done = true;
7248 7248
 	}
Please login to merge, or discard this patch.
Themes/default/Profile.template.php 1 patch
Spacing   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1721,7 +1721,7 @@  discard block
 block discarded – undo
1721 1721
 		{
1722 1722
 			// Avoid double separators and empty titled sections
1723 1723
 			$empty_section = true;
1724
-			for ($j=$i+1; $j < count($context['theme_options']); $j++)
1724
+			for ($j = $i + 1; $j < count($context['theme_options']); $j++)
1725 1725
 			{
1726 1726
 				// Found another separator, so we're done
1727 1727
 				if (!is_array($context['theme_options'][$j]))
@@ -2700,8 +2700,7 @@  discard block
 block discarded – undo
2700 2700
 		foreach ($context['post_errors'] as $error)
2701 2701
 		{
2702 2702
 			$text_key_error = $error == 'password_short' ?
2703
-				sprintf($txt['profile_error_' . $error], (empty($modSettings['password_strength']) ? 4 : 8)) :
2704
-				$txt['profile_error_' . $error];
2703
+				sprintf($txt['profile_error_' . $error], (empty($modSettings['password_strength']) ? 4 : 8)) : $txt['profile_error_' . $error];
2705 2704
 
2706 2705
 			echo '
2707 2706
 				<li>', isset($txt['profile_error_' . $error]) ? $text_key_error : $error, '</li>';
Please login to merge, or discard this patch.
Sources/random_compat/random_bytes_dev_urandom.php 2 patches
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -27,164 +27,164 @@
 block discarded – undo
27 27
  */
28 28
 
29 29
 if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
30
-    define('RANDOM_COMPAT_READ_BUFFER', 8);
30
+	define('RANDOM_COMPAT_READ_BUFFER', 8);
31 31
 }
32 32
 
33 33
 if (!is_callable('random_bytes')) {
34
-    /**
35
-     * Unless open_basedir is enabled, use /dev/urandom for
36
-     * random numbers in accordance with best practices
37
-     *
38
-     * Why we use /dev/urandom and not /dev/random
39
-     * @ref https://www.2uo.de/myths-about-urandom
40
-     * @ref http://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers
41
-     *
42
-     * @param int $bytes
43
-     *
44
-     * @throws Exception
45
-     *
46
-     * @return string
47
-     */
48
-    function random_bytes($bytes)
49
-    {
50
-        /** @var resource $fp */
51
-        static $fp = null;
34
+	/**
35
+	 * Unless open_basedir is enabled, use /dev/urandom for
36
+	 * random numbers in accordance with best practices
37
+	 *
38
+	 * Why we use /dev/urandom and not /dev/random
39
+	 * @ref https://www.2uo.de/myths-about-urandom
40
+	 * @ref http://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers
41
+	 *
42
+	 * @param int $bytes
43
+	 *
44
+	 * @throws Exception
45
+	 *
46
+	 * @return string
47
+	 */
48
+	function random_bytes($bytes)
49
+	{
50
+		/** @var resource $fp */
51
+		static $fp = null;
52 52
 
53
-        /**
54
-         * This block should only be run once
55
-         */
56
-        if (empty($fp)) {
57
-            /**
58
-             * We don't want to ever read C:\dev\random, only /dev/urandom on
59
-             * Unix-like operating systems. While we guard against this
60
-             * condition in random.php, it doesn't hurt to be defensive in depth
61
-             * here.
62
-             *
63
-             * To that end, we only try to open /dev/urandom if we're on a Unix-
64
-             * like operating system (which means the directory separator is set
65
-             * to "/" not "\".
66
-             */
67
-            if (DIRECTORY_SEPARATOR === '/') {
68
-                if (!is_readable('/dev/urandom')) {
69
-                    throw new Exception(
70
-                        'Environment misconfiguration: ' .
71
-                        '/dev/urandom cannot be read.'
72
-                    );
73
-                }
74
-                /**
75
-                 * We use /dev/urandom if it is a char device.
76
-                 * We never fall back to /dev/random
77
-                 */
78
-                /** @var resource|bool $fp */
79
-                $fp = fopen('/dev/urandom', 'rb');
80
-                if (is_resource($fp)) {
81
-                    /** @var array<string, int> $st */
82
-                    $st = fstat($fp);
83
-                    if (($st['mode'] & 0170000) !== 020000) {
84
-                        fclose($fp);
85
-                        $fp = false;
86
-                    }
87
-                }
88
-            }
53
+		/**
54
+		 * This block should only be run once
55
+		 */
56
+		if (empty($fp)) {
57
+			/**
58
+			 * We don't want to ever read C:\dev\random, only /dev/urandom on
59
+			 * Unix-like operating systems. While we guard against this
60
+			 * condition in random.php, it doesn't hurt to be defensive in depth
61
+			 * here.
62
+			 *
63
+			 * To that end, we only try to open /dev/urandom if we're on a Unix-
64
+			 * like operating system (which means the directory separator is set
65
+			 * to "/" not "\".
66
+			 */
67
+			if (DIRECTORY_SEPARATOR === '/') {
68
+				if (!is_readable('/dev/urandom')) {
69
+					throw new Exception(
70
+						'Environment misconfiguration: ' .
71
+						'/dev/urandom cannot be read.'
72
+					);
73
+				}
74
+				/**
75
+				 * We use /dev/urandom if it is a char device.
76
+				 * We never fall back to /dev/random
77
+				 */
78
+				/** @var resource|bool $fp */
79
+				$fp = fopen('/dev/urandom', 'rb');
80
+				if (is_resource($fp)) {
81
+					/** @var array<string, int> $st */
82
+					$st = fstat($fp);
83
+					if (($st['mode'] & 0170000) !== 020000) {
84
+						fclose($fp);
85
+						$fp = false;
86
+					}
87
+				}
88
+			}
89 89
 
90
-            if (is_resource($fp)) {
91
-                /**
92
-                 * stream_set_read_buffer() does not exist in HHVM
93
-                 *
94
-                 * If we don't set the stream's read buffer to 0, PHP will
95
-                 * internally buffer 8192 bytes, which can waste entropy
96
-                 *
97
-                 * stream_set_read_buffer returns 0 on success
98
-                 */
99
-                if (is_callable('stream_set_read_buffer')) {
100
-                    stream_set_read_buffer($fp, RANDOM_COMPAT_READ_BUFFER);
101
-                }
102
-                if (is_callable('stream_set_chunk_size')) {
103
-                    stream_set_chunk_size($fp, RANDOM_COMPAT_READ_BUFFER);
104
-                }
105
-            }
106
-        }
90
+			if (is_resource($fp)) {
91
+				/**
92
+				 * stream_set_read_buffer() does not exist in HHVM
93
+				 *
94
+				 * If we don't set the stream's read buffer to 0, PHP will
95
+				 * internally buffer 8192 bytes, which can waste entropy
96
+				 *
97
+				 * stream_set_read_buffer returns 0 on success
98
+				 */
99
+				if (is_callable('stream_set_read_buffer')) {
100
+					stream_set_read_buffer($fp, RANDOM_COMPAT_READ_BUFFER);
101
+				}
102
+				if (is_callable('stream_set_chunk_size')) {
103
+					stream_set_chunk_size($fp, RANDOM_COMPAT_READ_BUFFER);
104
+				}
105
+			}
106
+		}
107 107
 
108
-        try {
109
-            /** @var int $bytes */
110
-            $bytes = RandomCompat_intval($bytes);
111
-        } catch (TypeError $ex) {
112
-            throw new TypeError(
113
-                'random_bytes(): $bytes must be an integer'
114
-            );
115
-        }
108
+		try {
109
+			/** @var int $bytes */
110
+			$bytes = RandomCompat_intval($bytes);
111
+		} catch (TypeError $ex) {
112
+			throw new TypeError(
113
+				'random_bytes(): $bytes must be an integer'
114
+			);
115
+		}
116 116
 
117
-        if ($bytes < 1) {
118
-            throw new Error(
119
-                'Length must be greater than 0'
120
-            );
121
-        }
117
+		if ($bytes < 1) {
118
+			throw new Error(
119
+				'Length must be greater than 0'
120
+			);
121
+		}
122 122
 
123
-        /**
124
-         * This if() block only runs if we managed to open a file handle
125
-         *
126
-         * It does not belong in an else {} block, because the above
127
-         * if (empty($fp)) line is logic that should only be run once per
128
-         * page load.
129
-         */
130
-        if (is_resource($fp)) {
131
-            /**
132
-             * @var int
133
-             */
134
-            $remaining = $bytes;
123
+		/**
124
+		 * This if() block only runs if we managed to open a file handle
125
+		 *
126
+		 * It does not belong in an else {} block, because the above
127
+		 * if (empty($fp)) line is logic that should only be run once per
128
+		 * page load.
129
+		 */
130
+		if (is_resource($fp)) {
131
+			/**
132
+			 * @var int
133
+			 */
134
+			$remaining = $bytes;
135 135
 
136
-            /**
137
-             * @var string|bool
138
-             */
139
-            $buf = '';
136
+			/**
137
+			 * @var string|bool
138
+			 */
139
+			$buf = '';
140 140
 
141
-            /**
142
-             * We use fread() in a loop to protect against partial reads
143
-             */
144
-            do {
145
-                /**
146
-                 * @var string|bool
147
-                 */
148
-                $read = fread($fp, $remaining);
149
-                if (!is_string($read)) {
150
-                    /**
151
-                     * We cannot safely read from the file. Exit the
152
-                     * do-while loop and trigger the exception condition
153
-                     *
154
-                     * @var string|bool
155
-                     */
156
-                    $buf = false;
157
-                    break;
158
-                }
159
-                /**
160
-                 * Decrease the number of bytes returned from remaining
161
-                 */
162
-                $remaining -= RandomCompat_strlen($read);
163
-                /**
164
-                 * @var string $buf
165
-                 */
166
-                $buf .= $read;
167
-            } while ($remaining > 0);
141
+			/**
142
+			 * We use fread() in a loop to protect against partial reads
143
+			 */
144
+			do {
145
+				/**
146
+				 * @var string|bool
147
+				 */
148
+				$read = fread($fp, $remaining);
149
+				if (!is_string($read)) {
150
+					/**
151
+					 * We cannot safely read from the file. Exit the
152
+					 * do-while loop and trigger the exception condition
153
+					 *
154
+					 * @var string|bool
155
+					 */
156
+					$buf = false;
157
+					break;
158
+				}
159
+				/**
160
+				 * Decrease the number of bytes returned from remaining
161
+				 */
162
+				$remaining -= RandomCompat_strlen($read);
163
+				/**
164
+				 * @var string $buf
165
+				 */
166
+				$buf .= $read;
167
+			} while ($remaining > 0);
168 168
 
169
-            /**
170
-             * Is our result valid?
171
-             * @var string|bool $buf
172
-             */
173
-            if (is_string($buf)) {
174
-                if (RandomCompat_strlen($buf) === $bytes) {
175
-                    /**
176
-                     * Return our random entropy buffer here:
177
-                     */
178
-                    return $buf;
179
-                }
180
-            }
181
-        }
169
+			/**
170
+			 * Is our result valid?
171
+			 * @var string|bool $buf
172
+			 */
173
+			if (is_string($buf)) {
174
+				if (RandomCompat_strlen($buf) === $bytes) {
175
+					/**
176
+					 * Return our random entropy buffer here:
177
+					 */
178
+					return $buf;
179
+				}
180
+			}
181
+		}
182 182
 
183
-        /**
184
-         * If we reach here, PHP has failed us.
185
-         */
186
-        throw new Exception(
187
-            'Error reading from source device'
188
-        );
189
-    }
183
+		/**
184
+		 * If we reach here, PHP has failed us.
185
+		 */
186
+		throw new Exception(
187
+			'Error reading from source device'
188
+		);
189
+	}
190 190
 }
Please login to merge, or discard this patch.
Braces   +35 added lines, -17 removed lines patch added patch discarded remove patch
@@ -26,11 +26,13 @@  discard block
 block discarded – undo
26 26
  * SOFTWARE.
27 27
  */
28 28
 
29
-if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
29
+if (!defined('RANDOM_COMPAT_READ_BUFFER'))
30
+{
30 31
     define('RANDOM_COMPAT_READ_BUFFER', 8);
31 32
 }
32 33
 
33
-if (!is_callable('random_bytes')) {
34
+if (!is_callable('random_bytes'))
35
+{
34 36
     /**
35 37
      * Unless open_basedir is enabled, use /dev/urandom for
36 38
      * random numbers in accordance with best practices
@@ -53,7 +55,8 @@  discard block
 block discarded – undo
53 55
         /**
54 56
          * This block should only be run once
55 57
          */
56
-        if (empty($fp)) {
58
+        if (empty($fp))
59
+        {
57 60
             /**
58 61
              * We don't want to ever read C:\dev\random, only /dev/urandom on
59 62
              * Unix-like operating systems. While we guard against this
@@ -64,8 +67,10 @@  discard block
 block discarded – undo
64 67
              * like operating system (which means the directory separator is set
65 68
              * to "/" not "\".
66 69
              */
67
-            if (DIRECTORY_SEPARATOR === '/') {
68
-                if (!is_readable('/dev/urandom')) {
70
+            if (DIRECTORY_SEPARATOR === '/')
71
+            {
72
+                if (!is_readable('/dev/urandom'))
73
+                {
69 74
                     throw new Exception(
70 75
                         'Environment misconfiguration: ' .
71 76
                         '/dev/urandom cannot be read.'
@@ -77,17 +82,20 @@  discard block
 block discarded – undo
77 82
                  */
78 83
                 /** @var resource|bool $fp */
79 84
                 $fp = fopen('/dev/urandom', 'rb');
80
-                if (is_resource($fp)) {
85
+                if (is_resource($fp))
86
+                {
81 87
                     /** @var array<string, int> $st */
82 88
                     $st = fstat($fp);
83
-                    if (($st['mode'] & 0170000) !== 020000) {
89
+                    if (($st['mode'] & 0170000) !== 020000)
90
+                    {
84 91
                         fclose($fp);
85 92
                         $fp = false;
86 93
                     }
87 94
                 }
88 95
             }
89 96
 
90
-            if (is_resource($fp)) {
97
+            if (is_resource($fp))
98
+            {
91 99
                 /**
92 100
                  * stream_set_read_buffer() does not exist in HHVM
93 101
                  *
@@ -96,25 +104,31 @@  discard block
 block discarded – undo
96 104
                  *
97 105
                  * stream_set_read_buffer returns 0 on success
98 106
                  */
99
-                if (is_callable('stream_set_read_buffer')) {
107
+                if (is_callable('stream_set_read_buffer'))
108
+                {
100 109
                     stream_set_read_buffer($fp, RANDOM_COMPAT_READ_BUFFER);
101 110
                 }
102
-                if (is_callable('stream_set_chunk_size')) {
111
+                if (is_callable('stream_set_chunk_size'))
112
+                {
103 113
                     stream_set_chunk_size($fp, RANDOM_COMPAT_READ_BUFFER);
104 114
                 }
105 115
             }
106 116
         }
107 117
 
108
-        try {
118
+        try
119
+        {
109 120
             /** @var int $bytes */
110 121
             $bytes = RandomCompat_intval($bytes);
111
-        } catch (TypeError $ex) {
122
+        }
123
+        catch (TypeError $ex)
124
+        {
112 125
             throw new TypeError(
113 126
                 'random_bytes(): $bytes must be an integer'
114 127
             );
115 128
         }
116 129
 
117
-        if ($bytes < 1) {
130
+        if ($bytes < 1)
131
+        {
118 132
             throw new Error(
119 133
                 'Length must be greater than 0'
120 134
             );
@@ -127,7 +141,8 @@  discard block
 block discarded – undo
127 141
          * if (empty($fp)) line is logic that should only be run once per
128 142
          * page load.
129 143
          */
130
-        if (is_resource($fp)) {
144
+        if (is_resource($fp))
145
+        {
131 146
             /**
132 147
              * @var int
133 148
              */
@@ -146,7 +161,8 @@  discard block
 block discarded – undo
146 161
                  * @var string|bool
147 162
                  */
148 163
                 $read = fread($fp, $remaining);
149
-                if (!is_string($read)) {
164
+                if (!is_string($read))
165
+                {
150 166
                     /**
151 167
                      * We cannot safely read from the file. Exit the
152 168
                      * do-while loop and trigger the exception condition
@@ -170,8 +186,10 @@  discard block
 block discarded – undo
170 186
              * Is our result valid?
171 187
              * @var string|bool $buf
172 188
              */
173
-            if (is_string($buf)) {
174
-                if (RandomCompat_strlen($buf) === $bytes) {
189
+            if (is_string($buf))
190
+            {
191
+                if (RandomCompat_strlen($buf) === $bytes)
192
+                {
175 193
                     /**
176 194
                      * Return our random entropy buffer here:
177 195
                      */
Please login to merge, or discard this patch.
Sources/Load.php 2 patches
Spacing   +6 added lines, -9 removed lines patch added patch discarded remove patch
@@ -2717,8 +2717,7 @@  discard block
 block discarded – undo
2717 2717
 		$context['css_files_order'] = array();
2718 2718
 
2719 2719
 	$params['seed'] = (!array_key_exists('seed', $params) || (array_key_exists('seed', $params) && $params['seed'] === true)) ?
2720
-		(array_key_exists('browser_cache', $context) ? $context['browser_cache'] : '') :
2721
-		(is_string($params['seed']) ? '?' . ltrim($params['seed'], '?') : '');
2720
+		(array_key_exists('browser_cache', $context) ? $context['browser_cache'] : '') : (is_string($params['seed']) ? '?' . ltrim($params['seed'], '?') : '');
2722 2721
 	$params['force_current'] = isset($params['force_current']) ? $params['force_current'] : false;
2723 2722
 	$themeRef = !empty($params['default_theme']) ? 'default_theme' : 'theme';
2724 2723
 	$params['minimize'] = isset($params['minimize']) ? $params['minimize'] : true;
@@ -2832,8 +2831,7 @@  discard block
 block discarded – undo
2832 2831
 	global $settings, $context, $modSettings;
2833 2832
 
2834 2833
 	$params['seed'] = (!array_key_exists('seed', $params) || (array_key_exists('seed', $params) && $params['seed'] === true)) ?
2835
-		(array_key_exists('browser_cache', $context) ? $context['browser_cache'] : '') :
2836
-		(is_string($params['seed']) ? '?' . ltrim($params['seed'], '?') : '');
2834
+		(array_key_exists('browser_cache', $context) ? $context['browser_cache'] : '') : (is_string($params['seed']) ? '?' . ltrim($params['seed'], '?') : '');
2837 2835
 	$params['force_current'] = isset($params['force_current']) ? $params['force_current'] : false;
2838 2836
 	$themeRef = !empty($params['default_theme']) ? 'default_theme' : 'theme';
2839 2837
 	$params['async'] = isset($params['async']) ? $params['async'] : false;
@@ -3573,10 +3571,10 @@  discard block
 block discarded – undo
3573 3571
 		$cacheAPI = false;
3574 3572
 
3575 3573
 	// Autoload hasn't been called yet :/
3576
-	require_once($cacheAPIdir .'/CacheApi.php');
3577
-	require_once($cacheAPIdir .'/CacheApiInterface.php');
3574
+	require_once($cacheAPIdir . '/CacheApi.php');
3575
+	require_once($cacheAPIdir . '/CacheApiInterface.php');
3578 3576
 
3579
-	$apis_dir = $cacheAPIdir .'/'. CacheApi::APIS_FOLDER;
3577
+	$apis_dir = $cacheAPIdir . '/' . CacheApi::APIS_FOLDER;
3580 3578
 
3581 3579
 	// What accelerator we are going to try.
3582 3580
 	$cache_class_name = !empty($cache_accelerator) ? $cache_accelerator : CacheApi::APIS_DEFAULT;
@@ -3588,8 +3586,7 @@  discard block
 block discarded – undo
3588 3586
 	{
3589 3587
 		require_once($file_to_load);
3590 3588
 
3591
-		$fully_qualified_class_name = !empty($overrideCache) ? $overrideCache :
3592
-			CacheApi::APIS_NAMESPACE . $cache_class_name;
3589
+		$fully_qualified_class_name = !empty($overrideCache) ? $overrideCache : CacheApi::APIS_NAMESPACE . $cache_class_name;
3593 3590
 
3594 3591
 		/* @var CacheApiInterface $cache_api */
3595 3592
 		$cache_api = new $fully_qualified_class_name();
Please login to merge, or discard this patch.
Braces   +1 added lines, -5 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	// Set a list of common functions.
108 108
 	$ent_list = '&(?:#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . '|quot|amp|lt|gt|nbsp);';
109 109
 	$ent_check = empty($modSettings['disableEntityCheck']) ? function($string)
110
-		{
110
+	{
111 111
 			$string = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $string);
112 112
 			return $string;
113 113
 		} : function($string)
@@ -941,7 +941,6 @@  discard block
 block discarded – undo
941 941
 			$user_info_min[$row['id_member']]['time_offset'] = ($tz_user->getOffset($time_user) -
942 942
 					$tz_system->getOffset($time_system)) / 3600;
943 943
 		}
944
-
945 944
 		else
946 945
 			$user_info_min[$row['id_member']]['time_offset'] = empty($row['time_offset']) ? 0 : $row['time_offset'];
947 946
 	}
@@ -1669,7 +1668,6 @@  discard block
 block discarded – undo
1669 1668
 			$time_user = new DateTime('now', $tz_user);
1670 1669
 			$profile['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600;
1671 1670
 		}
1672
-
1673 1671
 		else
1674 1672
 		{
1675 1673
 			// !!! Compatibility.
@@ -2363,7 +2361,6 @@  discard block
 block discarded – undo
2363 2361
 		loadLanguage('index+Modifications');
2364 2362
 		$context['template_layers'] = array();
2365 2363
 	}
2366
-
2367 2364
 	else
2368 2365
 	{
2369 2366
 		// Custom templates to load, or just default?
@@ -3619,7 +3616,6 @@  discard block
 block discarded – undo
3619 3616
 
3620 3617
 			return $cacheAPI;
3621 3618
 		}
3622
-
3623 3619
 		else
3624 3620
 			return $cache_api;
3625 3621
 	}
Please login to merge, or discard this patch.
Sources/Subs-BoardIndex.php 2 patches
Braces   +1 added lines, -4 removed lines patch added patch discarded remove patch
@@ -280,7 +280,6 @@  discard block
 block discarded – undo
280 280
 					$this_category[$row_board['id_board']]['board_class'] = 'on';
281 281
 					$this_category[$row_board['id_board']]['board_tooltip'] = $txt['new_posts'];
282 282
 				}
283
-
284 283
 				else
285 284
 				{
286 285
 					$this_category[$row_board['id_board']]['board_tooltip'] = $txt['old_posts'];
@@ -415,7 +414,6 @@  discard block
 block discarded – undo
415 414
 			$this_last_post['href'] = $scripturl . '?topic=' . $row_board['id_topic'] . '.msg' . ($user_info['is_guest'] ? $row_board['id_msg'] : $row_board['new_from']) . (empty($row_board['is_read']) ? ';boardseen' : '') . '#new';
416 415
 			$this_last_post['link'] = '<a href="' . $this_last_post['href'] . '" title="' . $row_board['subject'] . '">' . $row_board['short_subject'] . '</a>';
417 416
 		}
418
-
419 417
 		else
420 418
 		{
421 419
 			$this_last_post['href'] = '';
@@ -510,8 +508,7 @@  discard block
 block discarded – undo
510 508
 					$board['last_post']['last_post_message'] = sprintf($txt['last_post_message'], $board['last_post']['member']['link'], $board['last_post']['link'], $board['last_post']['time'] > 0 ? timeformat($board['last_post']['time']) : $txt['not_applicable']);
511 509
 			}
512 510
 		}
513
-
514
-	else
511
+		else
515 512
 		foreach ($this_category as &$board)
516 513
 		{
517 514
 			if (isset($boards_parsed_data_by_cat_id[$board['id_cat']][$board['id']]))
Please login to merge, or discard this patch.
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -195,8 +195,7 @@
 block discarded – undo
195 195
 				);
196 196
 
197 197
 				$categories[$row_board['id_cat']]['link'] = '<a id="c' . $row_board['id_cat'] . '"></a>' . (!$context['user']['is_guest'] ?
198
-						'<a href="' . $scripturl . '?action=unread;c=' . $row_board['id_cat'] . '" title="' . sprintf($txt['new_posts_in_category'], $row_board['cat_name']) . '">' . $row_board['cat_name'] . '</a>' :
199
-						$row_board['cat_name']);
198
+						'<a href="' . $scripturl . '?action=unread;c=' . $row_board['id_cat'] . '" title="' . sprintf($txt['new_posts_in_category'], $row_board['cat_name']) . '">' . $row_board['cat_name'] . '</a>' : $row_board['cat_name']);
200 199
 
201 200
 			}
202 201
 
Please login to merge, or discard this patch.
Sources/Subs-Boards.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
 
852 852
 	clean_cache('data');
853 853
 
854
-	cache_put_data('parsed_boards_descriptions_'. $parsed_boards_cat_id, $already_parsed_boards, 864000);
854
+	cache_put_data('parsed_boards_descriptions_' . $parsed_boards_cat_id, $already_parsed_boards, 864000);
855 855
 
856 856
 	if (empty($boardOptions['dont_log']))
857 857
 		logAction('edit_board', array('board' => $board_id), 'admin');
@@ -1579,7 +1579,7 @@  discard block
 block discarded – undo
1579 1579
 			$context['description_allowed_tags']
1580 1580
 		);
1581 1581
 
1582
-	cache_put_data('parsed_boards_descriptions_'. $category_id, $already_parsed_boards, 864000);
1582
+	cache_put_data('parsed_boards_descriptions_' . $category_id, $already_parsed_boards, 864000);
1583 1583
 
1584 1584
 	return $already_parsed_boards;
1585 1585
 }
Please login to merge, or discard this patch.