Completed
Push — release-2.1 ( c3ff7f...f1e1b9 )
by Mathias
11s
created
Sources/Subs.php 1 patch
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 			{
387 387
 				$val = 'CASE ';
388 388
 				foreach ($members as $k => $v)
389
-					$val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' ';
389
+					$val .= 'WHEN id_member = ' . $v . ' THEN ' . count(fetch_alerts($v, false, 0, array(), false)) . ' ';
390 390
 				$val = $val . ' END';
391 391
 				$type = 'raw';
392 392
 			}
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
 			$unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400);
818 818
 		if (empty($unsupportedFormats))
819 819
 		{
820
-			foreach($strftimeFormatSubstitutions as $format => $substitution)
820
+			foreach ($strftimeFormatSubstitutions as $format => $substitution)
821 821
 			{
822 822
 				$value = @strftime('%' . $format);
823 823
 
@@ -1182,7 +1182,7 @@  discard block
 block discarded – undo
1182 1182
 					'height' => array('optional' => true, 'match' => '(\d+)'),
1183 1183
 				),
1184 1184
 				'content' => '$1',
1185
-				'validate' => function (&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt)
1185
+				'validate' => function(&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt)
1186 1186
 				{
1187 1187
 					$returnContext = '';
1188 1188
 
@@ -1217,7 +1217,7 @@  discard block
 block discarded – undo
1217 1217
 						}
1218 1218
 
1219 1219
 						if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}']))
1220
-							$returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>';
1220
+							$returnContext .= '<a href="' . $currentAttachment['href'] . ';image" id="link_' . $currentAttachment['id'] . '" onclick="' . $currentAttachment['thumbnail']['javascript'] . '"><img src="' . $currentAttachment['thumbnail']['href'] . '"' . $alt . $title . ' id="thumb_' . $currentAttachment['id'] . '" class="atc_img"></a>';
1221 1221
 						else
1222 1222
 							$returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>';
1223 1223
 					}
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
 				'type' => 'unparsed_content',
1247 1247
 				'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',
1248 1248
 				// @todo Maybe this can be simplified?
1249
-				'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context)
1249
+				'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context)
1250 1250
 				{
1251 1251
 					if (!isset($disabled['code']))
1252 1252
 					{
@@ -1283,7 +1283,7 @@  discard block
 block discarded – undo
1283 1283
 				'type' => 'unparsed_equals_content',
1284 1284
 				'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> ($2) <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',
1285 1285
 				// @todo Maybe this can be simplified?
1286
-				'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context)
1286
+				'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context)
1287 1287
 				{
1288 1288
 					if (!isset($disabled['code']))
1289 1289
 					{
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
 				'type' => 'unparsed_content',
1328 1328
 				'content' => '<a href="mailto:$1" class="bbc_email">$1</a>',
1329 1329
 				// @todo Should this respect guest_hideContacts?
1330
-				'validate' => function (&$tag, &$data, $disabled)
1330
+				'validate' => function(&$tag, &$data, $disabled)
1331 1331
 				{
1332 1332
 					$data = strtr($data, array('<br>' => ''));
1333 1333
 				},
@@ -1346,7 +1346,7 @@  discard block
 block discarded – undo
1346 1346
 				'type' => 'unparsed_commas_content',
1347 1347
 				'test' => '\d+,\d+\]',
1348 1348
 				'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">',
1349
-				'validate' => function (&$tag, &$data, $disabled)
1349
+				'validate' => function(&$tag, &$data, $disabled)
1350 1350
 				{
1351 1351
 					if (isset($disabled['url']))
1352 1352
 						$tag['content'] = '$1';
@@ -1362,7 +1362,7 @@  discard block
 block discarded – undo
1362 1362
 				'test' => '(left|right)(\s+max=\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)?\]',
1363 1363
 				'before' => '<div $1>',
1364 1364
 				'after' => '</div>',
1365
-				'validate' => function (&$tag, &$data, $disabled)
1365
+				'validate' => function(&$tag, &$data, $disabled)
1366 1366
 				{
1367 1367
 					$class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"';
1368 1368
 
@@ -1411,7 +1411,7 @@  discard block
 block discarded – undo
1411 1411
 					'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
1412 1412
 				),
1413 1413
 				'content' => '<img src="$1" alt="{alt}" title="{title}"{width}{height} class="bbc_img resized">',
1414
-				'validate' => function (&$tag, &$data, $disabled)
1414
+				'validate' => function(&$tag, &$data, $disabled)
1415 1415
 				{
1416 1416
 					global $image_proxy_enabled, $user_info;
1417 1417
 
@@ -1437,7 +1437,7 @@  discard block
 block discarded – undo
1437 1437
 				'tag' => 'img',
1438 1438
 				'type' => 'unparsed_content',
1439 1439
 				'content' => '<img src="$1" alt="" class="bbc_img">',
1440
-				'validate' => function (&$tag, &$data, $disabled)
1440
+				'validate' => function(&$tag, &$data, $disabled)
1441 1441
 				{
1442 1442
 					global $image_proxy_enabled, $user_info;
1443 1443
 
@@ -1463,7 +1463,7 @@  discard block
 block discarded – undo
1463 1463
 				'tag' => 'iurl',
1464 1464
 				'type' => 'unparsed_content',
1465 1465
 				'content' => '<a href="$1" class="bbc_link">$1</a>',
1466
-				'validate' => function (&$tag, &$data, $disabled)
1466
+				'validate' => function(&$tag, &$data, $disabled)
1467 1467
 				{
1468 1468
 					$data = strtr($data, array('<br>' => ''));
1469 1469
 					$scheme = parse_url($data, PHP_URL_SCHEME);
@@ -1477,7 +1477,7 @@  discard block
 block discarded – undo
1477 1477
 				'quoted' => 'optional',
1478 1478
 				'before' => '<a href="$1" class="bbc_link">',
1479 1479
 				'after' => '</a>',
1480
-				'validate' => function (&$tag, &$data, $disabled)
1480
+				'validate' => function(&$tag, &$data, $disabled)
1481 1481
 				{
1482 1482
 					if (substr($data, 0, 1) == '#')
1483 1483
 						$data = '#post_' . substr($data, 1);
@@ -1563,7 +1563,7 @@  discard block
 block discarded – undo
1563 1563
 				'tag' => 'php',
1564 1564
 				'type' => 'unparsed_content',
1565 1565
 				'content' => '<span class="phpcode">$1</span>',
1566
-				'validate' => isset($disabled['php']) ? null : function (&$tag, &$data, $disabled)
1566
+				'validate' => isset($disabled['php']) ? null : function(&$tag, &$data, $disabled)
1567 1567
 				{
1568 1568
 					if (!isset($disabled['php']))
1569 1569
 					{
@@ -1661,7 +1661,7 @@  discard block
 block discarded – undo
1661 1661
 				'test' => '[1-7]\]',
1662 1662
 				'before' => '<span style="font-size: $1;" class="bbc_size">',
1663 1663
 				'after' => '</span>',
1664
-				'validate' => function (&$tag, &$data, $disabled)
1664
+				'validate' => function(&$tag, &$data, $disabled)
1665 1665
 				{
1666 1666
 					$sizes = array(1 => 0.7, 2 => 1.0, 3 => 1.35, 4 => 1.45, 5 => 2.0, 6 => 2.65, 7 => 3.95);
1667 1667
 					$data = $sizes[$data] . 'em';
@@ -1699,7 +1699,7 @@  discard block
 block discarded – undo
1699 1699
 				'tag' => 'time',
1700 1700
 				'type' => 'unparsed_content',
1701 1701
 				'content' => '$1',
1702
-				'validate' => function (&$tag, &$data, $disabled)
1702
+				'validate' => function(&$tag, &$data, $disabled)
1703 1703
 				{
1704 1704
 					if (is_numeric($data))
1705 1705
 						$data = timeformat($data);
@@ -1727,7 +1727,7 @@  discard block
 block discarded – undo
1727 1727
 				'tag' => 'url',
1728 1728
 				'type' => 'unparsed_content',
1729 1729
 				'content' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">$1</a>',
1730
-				'validate' => function (&$tag, &$data, $disabled)
1730
+				'validate' => function(&$tag, &$data, $disabled)
1731 1731
 				{
1732 1732
 					$data = strtr($data, array('<br>' => ''));
1733 1733
 					$scheme = parse_url($data, PHP_URL_SCHEME);
@@ -1741,7 +1741,7 @@  discard block
 block discarded – undo
1741 1741
 				'quoted' => 'optional',
1742 1742
 				'before' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">',
1743 1743
 				'after' => '</a>',
1744
-				'validate' => function (&$tag, &$data, $disabled)
1744
+				'validate' => function(&$tag, &$data, $disabled)
1745 1745
 				{
1746 1746
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1747 1747
 					if (empty($scheme))
@@ -1773,7 +1773,7 @@  discard block
 block discarded – undo
1773 1773
 		{
1774 1774
 			if (isset($temp_bbc))
1775 1775
 				$bbc_codes = $temp_bbc;
1776
-			usort($codes, function ($a, $b) {
1776
+			usort($codes, function($a, $b) {
1777 1777
 				return strcmp($a['tag'], $b['tag']);
1778 1778
 			});
1779 1779
 			return $codes;
@@ -1989,7 +1989,7 @@  discard block
 block discarded – undo
1989 1989
 										# a run of Unicode domain name characters and a dot
1990 1990
 										[\p{L}\p{M}\p{N}\-.:@]+\.
1991 1991
 										# and then a TLD valid in the DNS or the reserved "local" TLD
1992
-										(?:'. $modSettings['tld_regex'] .'|local)
1992
+										(?:'. $modSettings['tld_regex'] . '|local)
1993 1993
 									)
1994 1994
 									# followed by a non-domain character or end of line
1995 1995
 									(?=[^\p{L}\p{N}\-.]|$)
@@ -2057,7 +2057,7 @@  discard block
 block discarded – undo
2057 2057
 						)?
2058 2058
 						';
2059 2059
 
2060
-						$data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function ($matches) {
2060
+						$data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function($matches) {
2061 2061
 							$url = array_shift($matches);
2062 2062
 
2063 2063
 							// If this isn't a clean URL, bail out
@@ -2082,7 +2082,7 @@  discard block
 block discarded – undo
2082 2082
 								$fullUrl = $url;
2083 2083
 
2084 2084
 							// Make sure that $fullUrl really is valid
2085
-							if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '' ) . $fullUrl) === false)
2085
+							if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '') . $fullUrl) === false)
2086 2086
 								return $url;
2087 2087
 
2088 2088
 							return '[url=&quot;' . str_replace(array('[', ']'), array('&#91;', '&#93;'), $fullUrl) . '&quot;]' . $url . '[/url]';
@@ -2146,7 +2146,7 @@  discard block
 block discarded – undo
2146 2146
 			$look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2));
2147 2147
 
2148 2148
 			// A closing tag that doesn't match any open tags? Skip it.
2149
-			if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags)))
2149
+			if (!in_array($look_for, array_map(function($code) {return $code['tag']; }, $open_tags)))
2150 2150
 				continue;
2151 2151
 
2152 2152
 			$to_close = array();
@@ -2813,7 +2813,7 @@  discard block
 block discarded – undo
2813 2813
 		for ($i = 0, $n = count($smileysfrom); $i < $n; $i++)
2814 2814
 		{
2815 2815
 			$specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES);
2816
-			$smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')). '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" class="smiley">';
2816
+			$smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" class="smiley">';
2817 2817
 
2818 2818
 			$smileyPregReplacements[$smileysfrom[$i]] = $smileyCode;
2819 2819
 
@@ -2830,7 +2830,7 @@  discard block
 block discarded – undo
2830 2830
 
2831 2831
 	// Replace away!
2832 2832
 	$message = preg_replace_callback($smileyPregSearch,
2833
-		function ($matches) use ($smileyPregReplacements)
2833
+		function($matches) use ($smileyPregReplacements)
2834 2834
 		{
2835 2835
 			return $smileyPregReplacements[$matches[1]];
2836 2836
 		}, $message);
@@ -2927,13 +2927,13 @@  discard block
 block discarded – undo
2927 2927
 	{
2928 2928
 		if (defined('SID') && SID != '')
2929 2929
 			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
2930
-				function ($m) use ($scripturl)
2930
+				function($m) use ($scripturl)
2931 2931
 				{
2932
-					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : "");
2932
+					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : "");
2933 2933
 				}, $setLocation);
2934 2934
 		else
2935 2935
 			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
2936
-				function ($m) use ($scripturl)
2936
+				function($m) use ($scripturl)
2937 2937
 				{
2938 2938
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : "");
2939 2939
 				}, $setLocation);
@@ -3254,7 +3254,7 @@  discard block
 block discarded – undo
3254 3254
 
3255 3255
 	// Add a generic "Are you sure?" confirmation message.
3256 3256
 	addInlineJavaScript('
3257
-	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';');
3257
+	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) . ';');
3258 3258
 
3259 3259
 	// Now add the capping code for avatars.
3260 3260
 	if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize')
@@ -3721,7 +3721,7 @@  discard block
 block discarded – undo
3721 3721
 	if (!empty($normal))
3722 3722
 		foreach ($normal as $nf)
3723 3723
 			echo '
3724
-	<link rel="stylesheet" href="', $nf ,'">';
3724
+	<link rel="stylesheet" href="', $nf, '">';
3725 3725
 
3726 3726
 	if ($db_show_debug === true)
3727 3727
 	{
@@ -3737,7 +3737,7 @@  discard block
 block discarded – undo
3737 3737
 	<style>';
3738 3738
 
3739 3739
 		foreach ($context['css_header'] as $css)
3740
-			echo $css .'
3740
+			echo $css . '
3741 3741
 	';
3742 3742
 
3743 3743
 		echo'
@@ -3781,7 +3781,7 @@  discard block
 block discarded – undo
3781 3781
 
3782 3782
 
3783 3783
 	// No namespaces, sorry!
3784
-	$classType = 'MatthiasMullie\\Minify\\'. strtoupper($type);
3784
+	$classType = 'MatthiasMullie\\Minify\\' . strtoupper($type);
3785 3785
 
3786 3786
 	// Temp path.
3787 3787
 	$cTempPath = $settings['theme_dir'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/';
@@ -3961,7 +3961,7 @@  discard block
 block discarded – undo
3961 3961
 	else
3962 3962
 		$path = $modSettings['attachmentUploadDir'];
3963 3963
 
3964
-	return $path . '/' . $attachment_id . '_' . $file_hash .'.dat';
3964
+	return $path . '/' . $attachment_id . '_' . $file_hash . '.dat';
3965 3965
 }
3966 3966
 
3967 3967
 /**
@@ -4005,10 +4005,10 @@  discard block
 block discarded – undo
4005 4005
 		$valid_low = isValidIP($ip_parts[0]);
4006 4006
 		$valid_high = isValidIP($ip_parts[1]);
4007 4007
 		$count = 0;
4008
-		$mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.');
4008
+		$mode = (preg_match('/:/', $ip_parts[0]) > 0 ? ':' : '.');
4009 4009
 		$max = ($mode == ':' ? 'ffff' : '255');
4010 4010
 		$min = 0;
4011
-		if(!$valid_low)
4011
+		if (!$valid_low)
4012 4012
 		{
4013 4013
 			$ip_parts[0] = preg_replace('/\*/', '0', $ip_parts[0]);
4014 4014
 			$valid_low = isValidIP($ip_parts[0]);
@@ -4022,7 +4022,7 @@  discard block
 block discarded – undo
4022 4022
 		}
4023 4023
 
4024 4024
 		$count = 0;
4025
-		if(!$valid_high)
4025
+		if (!$valid_high)
4026 4026
 		{
4027 4027
 			$ip_parts[1] = preg_replace('/\*/', $max, $ip_parts[1]);
4028 4028
 			$valid_high = isValidIP($ip_parts[1]);
@@ -4035,7 +4035,7 @@  discard block
 block discarded – undo
4035 4035
 			}
4036 4036
 		}
4037 4037
 
4038
-		if($valid_high && $valid_low)
4038
+		if ($valid_high && $valid_low)
4039 4039
 		{
4040 4040
 			$ip_array['low'] = $ip_parts[0];
4041 4041
 			$ip_array['high'] = $ip_parts[1];
@@ -4217,7 +4217,7 @@  discard block
 block discarded – undo
4217 4217
 		addInlineJavaScript('
4218 4218
 	var user_menus = new smc_PopupMenu();
4219 4219
 	user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup");
4220
-	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true);
4220
+	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u=' . $context['user']['id'] . '");', true);
4221 4221
 		if ($context['allow_pm'])
4222 4222
 			addInlineJavaScript('
4223 4223
 	user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true);
@@ -4853,7 +4853,7 @@  discard block
 block discarded – undo
4853 4853
 		// No? try a fallback to $sourcedir
4854 4854
 		else
4855 4855
 		{
4856
-			$absPath = $sourcedir .'/'. $file;
4856
+			$absPath = $sourcedir . '/' . $file;
4857 4857
 
4858 4858
 			if (file_exists($absPath))
4859 4859
 				require_once($absPath);
@@ -5120,15 +5120,15 @@  discard block
 block discarded – undo
5120 5120
 
5121 5121
 	// UTF-8 occurences of MS special characters
5122 5122
 	$findchars_utf8 = array(
5123
-		"\xe2\x80\x9a",	// single low-9 quotation mark
5124
-		"\xe2\x80\x9e",	// double low-9 quotation mark
5125
-		"\xe2\x80\xa6",	// horizontal ellipsis
5126
-		"\xe2\x80\x98",	// left single curly quote
5127
-		"\xe2\x80\x99",	// right single curly quote
5128
-		"\xe2\x80\x9c",	// left double curly quote
5129
-		"\xe2\x80\x9d",	// right double curly quote
5130
-		"\xe2\x80\x93",	// en dash
5131
-		"\xe2\x80\x94",	// em dash
5123
+		"\xe2\x80\x9a", // single low-9 quotation mark
5124
+		"\xe2\x80\x9e", // double low-9 quotation mark
5125
+		"\xe2\x80\xa6", // horizontal ellipsis
5126
+		"\xe2\x80\x98", // left single curly quote
5127
+		"\xe2\x80\x99", // right single curly quote
5128
+		"\xe2\x80\x9c", // left double curly quote
5129
+		"\xe2\x80\x9d", // right double curly quote
5130
+		"\xe2\x80\x93", // en dash
5131
+		"\xe2\x80\x94", // em dash
5132 5132
 	);
5133 5133
 
5134 5134
 	// windows 1252 / iso equivalents
@@ -5146,15 +5146,15 @@  discard block
 block discarded – undo
5146 5146
 
5147 5147
 	// safe replacements
5148 5148
 	$replacechars = array(
5149
-		',',	// &sbquo;
5150
-		',,',	// &bdquo;
5151
-		'...',	// &hellip;
5152
-		"'",	// &lsquo;
5153
-		"'",	// &rsquo;
5154
-		'"',	// &ldquo;
5155
-		'"',	// &rdquo;
5156
-		'-',	// &ndash;
5157
-		'--',	// &mdash;
5149
+		',', // &sbquo;
5150
+		',,', // &bdquo;
5151
+		'...', // &hellip;
5152
+		"'", // &lsquo;
5153
+		"'", // &rsquo;
5154
+		'"', // &ldquo;
5155
+		'"', // &rdquo;
5156
+		'-', // &ndash;
5157
+		'--', // &mdash;
5158 5158
 	);
5159 5159
 
5160 5160
 	if ($context['utf8'])
@@ -5572,7 +5572,7 @@  discard block
 block discarded – undo
5572 5572
  */
5573 5573
 function inet_dtop($bin)
5574 5574
 {
5575
-	if(empty($bin))
5575
+	if (empty($bin))
5576 5576
 		return '';
5577 5577
 
5578 5578
 	global $db_type;
@@ -5603,28 +5603,28 @@  discard block
 block discarded – undo
5603 5603
  */
5604 5604
 function _safe_serialize($value)
5605 5605
 {
5606
-	if(is_null($value))
5606
+	if (is_null($value))
5607 5607
 		return 'N;';
5608 5608
 
5609
-	if(is_bool($value))
5610
-		return 'b:'. (int) $value .';';
5609
+	if (is_bool($value))
5610
+		return 'b:' . (int) $value . ';';
5611 5611
 
5612
-	if(is_int($value))
5613
-		return 'i:'. $value .';';
5612
+	if (is_int($value))
5613
+		return 'i:' . $value . ';';
5614 5614
 
5615
-	if(is_float($value))
5616
-		return 'd:'. str_replace(',', '.', $value) .';';
5615
+	if (is_float($value))
5616
+		return 'd:' . str_replace(',', '.', $value) . ';';
5617 5617
 
5618
-	if(is_string($value))
5619
-		return 's:'. strlen($value) .':"'. $value .'";';
5618
+	if (is_string($value))
5619
+		return 's:' . strlen($value) . ':"' . $value . '";';
5620 5620
 
5621
-	if(is_array($value))
5621
+	if (is_array($value))
5622 5622
 	{
5623 5623
 		$out = '';
5624
-		foreach($value as $k => $v)
5624
+		foreach ($value as $k => $v)
5625 5625
 			$out .= _safe_serialize($k) . _safe_serialize($v);
5626 5626
 
5627
-		return 'a:'. count($value) .':{'. $out .'}';
5627
+		return 'a:' . count($value) . ':{' . $out . '}';
5628 5628
 	}
5629 5629
 
5630 5630
 	// safe_serialize cannot serialize resources or objects.
@@ -5666,7 +5666,7 @@  discard block
 block discarded – undo
5666 5666
 function _safe_unserialize($str)
5667 5667
 {
5668 5668
 	// Input  is not a string.
5669
-	if(empty($str) || !is_string($str))
5669
+	if (empty($str) || !is_string($str))
5670 5670
 		return false;
5671 5671
 
5672 5672
 	$stack = array();
@@ -5680,40 +5680,40 @@  discard block
 block discarded – undo
5680 5680
 	 *   3 - in array, expecting value or another array
5681 5681
 	 */
5682 5682
 	$state = 0;
5683
-	while($state != 1)
5683
+	while ($state != 1)
5684 5684
 	{
5685 5685
 		$type = isset($str[0]) ? $str[0] : '';
5686
-		if($type == '}')
5686
+		if ($type == '}')
5687 5687
 			$str = substr($str, 1);
5688 5688
 
5689
-		else if($type == 'N' && $str[1] == ';')
5689
+		else if ($type == 'N' && $str[1] == ';')
5690 5690
 		{
5691 5691
 			$value = null;
5692 5692
 			$str = substr($str, 2);
5693 5693
 		}
5694
-		else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5694
+		else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5695 5695
 		{
5696 5696
 			$value = $matches[1] == '1' ? true : false;
5697 5697
 			$str = substr($str, 4);
5698 5698
 		}
5699
-		else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5699
+		else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5700 5700
 		{
5701
-			$value = (int)$matches[1];
5701
+			$value = (int) $matches[1];
5702 5702
 			$str = $matches[2];
5703 5703
 		}
5704
-		else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5704
+		else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5705 5705
 		{
5706
-			$value = (float)$matches[1];
5706
+			$value = (float) $matches[1];
5707 5707
 			$str = $matches[3];
5708 5708
 		}
5709
-		else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
5709
+		else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";')
5710 5710
 		{
5711
-			$value = substr($matches[2], 0, (int)$matches[1]);
5712
-			$str = substr($matches[2], (int)$matches[1] + 2);
5711
+			$value = substr($matches[2], 0, (int) $matches[1]);
5712
+			$str = substr($matches[2], (int) $matches[1] + 2);
5713 5713
 		}
5714
-		else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5714
+		else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5715 5715
 		{
5716
-			$expectedLength = (int)$matches[1];
5716
+			$expectedLength = (int) $matches[1];
5717 5717
 			$str = $matches[2];
5718 5718
 		}
5719 5719
 
@@ -5721,10 +5721,10 @@  discard block
 block discarded – undo
5721 5721
 		else
5722 5722
 			return false;
5723 5723
 
5724
-		switch($state)
5724
+		switch ($state)
5725 5725
 		{
5726 5726
 			case 3: // In array, expecting value or another array.
5727
-				if($type == 'a')
5727
+				if ($type == 'a')
5728 5728
 				{
5729 5729
 					$stack[] = &$list;
5730 5730
 					$list[$key] = array();
@@ -5733,7 +5733,7 @@  discard block
 block discarded – undo
5733 5733
 					$state = 2;
5734 5734
 					break;
5735 5735
 				}
5736
-				if($type != '}')
5736
+				if ($type != '}')
5737 5737
 				{
5738 5738
 					$list[$key] = $value;
5739 5739
 					$state = 2;
@@ -5744,29 +5744,29 @@  discard block
 block discarded – undo
5744 5744
 				return false;
5745 5745
 
5746 5746
 			case 2: // in array, expecting end of array or a key
5747
-				if($type == '}')
5747
+				if ($type == '}')
5748 5748
 				{
5749 5749
 					// Array size is less than expected.
5750
-					if(count($list) < end($expected))
5750
+					if (count($list) < end($expected))
5751 5751
 						return false;
5752 5752
 
5753 5753
 					unset($list);
5754
-					$list = &$stack[count($stack)-1];
5754
+					$list = &$stack[count($stack) - 1];
5755 5755
 					array_pop($stack);
5756 5756
 
5757 5757
 					// Go to terminal state if we're at the end of the root array.
5758 5758
 					array_pop($expected);
5759 5759
 
5760
-					if(count($expected) == 0)
5760
+					if (count($expected) == 0)
5761 5761
 						$state = 1;
5762 5762
 
5763 5763
 					break;
5764 5764
 				}
5765 5765
 
5766
-				if($type == 'i' || $type == 's')
5766
+				if ($type == 'i' || $type == 's')
5767 5767
 				{
5768 5768
 					// Array size exceeds expected length.
5769
-					if(count($list) >= end($expected))
5769
+					if (count($list) >= end($expected))
5770 5770
 						return false;
5771 5771
 
5772 5772
 					$key = $value;
@@ -5779,7 +5779,7 @@  discard block
 block discarded – undo
5779 5779
 
5780 5780
 			// Expecting array or value.
5781 5781
 			case 0:
5782
-				if($type == 'a')
5782
+				if ($type == 'a')
5783 5783
 				{
5784 5784
 					$data = array();
5785 5785
 					$list = &$data;
@@ -5788,7 +5788,7 @@  discard block
 block discarded – undo
5788 5788
 					break;
5789 5789
 				}
5790 5790
 
5791
-				if($type != '}')
5791
+				if ($type != '}')
5792 5792
 				{
5793 5793
 					$data = $value;
5794 5794
 					$state = 1;
@@ -5801,7 +5801,7 @@  discard block
 block discarded – undo
5801 5801
 	}
5802 5802
 
5803 5803
 	// Trailing data in input.
5804
-	if(!empty($str))
5804
+	if (!empty($str))
5805 5805
 		return false;
5806 5806
 
5807 5807
 	return $data;
@@ -5855,7 +5855,7 @@  discard block
 block discarded – undo
5855 5855
 	// Set different modes.
5856 5856
 	$chmodValues = $isDir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666);
5857 5857
 
5858
-	foreach($chmodValues as $val)
5858
+	foreach ($chmodValues as $val)
5859 5859
 	{
5860 5860
 		// If it's writable, break out of the loop.
5861 5861
 		if (is_writable($file))
@@ -5890,13 +5890,13 @@  discard block
 block discarded – undo
5890 5890
 	$returnArray = @json_decode($json, $returnAsArray);
5891 5891
 
5892 5892
 	// PHP 5.3 so no json_last_error_msg()
5893
-	switch(json_last_error())
5893
+	switch (json_last_error())
5894 5894
 	{
5895 5895
 		case JSON_ERROR_NONE:
5896 5896
 			$jsonError = false;
5897 5897
 			break;
5898 5898
 		case JSON_ERROR_DEPTH:
5899
-			$jsonError =  'JSON_ERROR_DEPTH';
5899
+			$jsonError = 'JSON_ERROR_DEPTH';
5900 5900
 			break;
5901 5901
 		case JSON_ERROR_STATE_MISMATCH:
5902 5902
 			$jsonError = 'JSON_ERROR_STATE_MISMATCH';
@@ -5924,10 +5924,10 @@  discard block
 block discarded – undo
5924 5924
 		loadLanguage('Errors');
5925 5925
 
5926 5926
 		if (!empty($jsonDebug))
5927
-			log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5927
+			log_error($txt['json_' . $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5928 5928
 
5929 5929
 		else
5930
-			log_error($txt['json_'. $jsonError], 'critical');
5930
+			log_error($txt['json_' . $jsonError], 'critical');
5931 5931
 
5932 5932
 		// Everyone expects an array.
5933 5933
 		return array();
@@ -6044,7 +6044,7 @@  discard block
 block discarded – undo
6044 6044
 		// Convert Punycode to Unicode
6045 6045
 		require_once($sourcedir . '/punycode/Punycode.php');
6046 6046
 		$Punycode = new TrueBV\Punycode();
6047
-		$tlds = array_map(function ($input) use ($Punycode) { return $Punycode->decode($input); }, $tlds);
6047
+		$tlds = array_map(function($input) use ($Punycode) { return $Punycode->decode($input); }, $tlds);
6048 6048
 	}
6049 6049
 	// Otherwise, use the 2012 list of gTLDs and ccTLDs for now and schedule a background update
6050 6050
 	else
@@ -6138,7 +6138,7 @@  discard block
 block discarded – undo
6138 6138
 	}
6139 6139
 
6140 6140
 	// This recursive function creates the index array from the strings
6141
-	$add_string_to_index = function ($string, $index) use (&$strlen, &$substr, &$add_string_to_index)
6141
+	$add_string_to_index = function($string, $index) use (&$strlen, &$substr, &$add_string_to_index)
6142 6142
 	{
6143 6143
 		static $depth = 0;
6144 6144
 		$depth++;
@@ -6165,7 +6165,7 @@  discard block
 block discarded – undo
6165 6165
 	};
6166 6166
 
6167 6167
 	// This recursive function turns the index array into a regular expression
6168
-	$index_to_regex = function (&$index, $delim) use (&$strlen, &$index_to_regex)
6168
+	$index_to_regex = function(&$index, $delim) use (&$strlen, &$index_to_regex)
6169 6169
 	{
6170 6170
 		static $depth = 0;
6171 6171
 		$depth++;
@@ -6189,11 +6189,11 @@  discard block
 block discarded – undo
6189 6189
 
6190 6190
 				if (count(array_keys($value)) == 1)
6191 6191
 				{
6192
-					$new_key_array = explode('(?'.'>', $sub_regex);
6192
+					$new_key_array = explode('(?' . '>', $sub_regex);
6193 6193
 					$new_key .= $new_key_array[0];
6194 6194
 				}
6195 6195
 				else
6196
-					$sub_regex = '(?'.'>' . $sub_regex . ')';
6196
+					$sub_regex = '(?' . '>' . $sub_regex . ')';
6197 6197
 			}
6198 6198
 
6199 6199
 			if ($depth > 1)
@@ -6236,10 +6236,10 @@  discard block
 block discarded – undo
6236 6236
 	{
6237 6237
 		$regex = array();
6238 6238
 		while (!empty($index))
6239
-			$regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6239
+			$regex[] = '(?' . '>' . $index_to_regex($index, $delim) . ')';
6240 6240
 	}
6241 6241
 	else
6242
-		$regex = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6242
+		$regex = '(?' . '>' . $index_to_regex($index, $delim) . ')';
6243 6243
 
6244 6244
 	// Restore PHP's internal character encoding to whatever it was originally
6245 6245
 	if (!empty($current_encoding))
@@ -6461,7 +6461,7 @@  discard block
 block discarded – undo
6461 6461
 function sanitize_iri($iri)
6462 6462
 {
6463 6463
 	// Encode any non-ASCII characters (but not space or control characters of any sort)
6464
-	$iri = preg_replace_callback('~[^\x00-\x7F\pZ\pC]~u', function ($matches) {
6464
+	$iri = preg_replace_callback('~[^\x00-\x7F\pZ\pC]~u', function($matches) {
6465 6465
 		return rawurlencode($matches[0]);
6466 6466
 	}, $iri);
6467 6467
 
@@ -6503,7 +6503,7 @@  discard block
 block discarded – undo
6503 6503
 	$unescaped = array(
6504 6504
 		'%21'=>'!', '%23'=>'#', '%24'=>'$', '%26'=>'&',
6505 6505
 		'%27'=>"'", '%28'=>'(', '%29'=>')', '%2A'=>'*',
6506
-		'%2B'=>'+', '%2C'=>',',	'%2F'=>'/', '%3A'=>':',
6506
+		'%2B'=>'+', '%2C'=>',', '%2F'=>'/', '%3A'=>':',
6507 6507
 		'%3B'=>';', '%3D'=>'=', '%3F'=>'?', '%40'=>'@',
6508 6508
 	);
6509 6509
 	$iri = strtr(rawurlencode($iri), $unescaped);
Please login to merge, or discard this patch.