Code Duplication    Length = 18-18 lines in 2 locations

Sources/Display.php 1 location

@@ 1679-1696 (lines=18) @@
1676
	@set_time_limit(600);
1677
1678
	// Recode line endings for text files, if enabled.
1679
	if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file_ext, array('txt', 'css', 'htm', 'html', 'php', 'xml')))
1680
	{
1681
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false)
1682
			$callback = function ($buffer)
1683
			{
1684
				return preg_replace('~[\r]?\n~', "\r\n", $buffer);
1685
			};
1686
		elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false)
1687
			$callback = function ($buffer)
1688
			{
1689
				return preg_replace('~[\r]?\n~', "\r", $buffer);
1690
			};
1691
		else
1692
			$callback = function ($buffer)
1693
			{
1694
				return preg_replace('~[\r]?\n~', "\n", $buffer);
1695
			};
1696
	}
1697
1698
	// Since we don't do output compression for files this large...
1699
	if (filesize($filename) > 4194304)

Sources/ShowAttachments.php 1 location

@@ 289-306 (lines=18) @@
286
	@set_time_limit(600);
287
288
	// Recode line endings for text files, if enabled.
289
	if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file['fileext'], array('txt', 'css', 'htm', 'html', 'php', 'xml')))
290
	{
291
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false)
292
			$callback = function ($buffer)
293
			{
294
				return preg_replace('~[\r]?\n~', "\r\n", $buffer);
295
			};
296
		elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false)
297
			$callback = function ($buffer)
298
			{
299
				return preg_replace('~[\r]?\n~', "\r", $buffer);
300
			};
301
		else
302
			$callback = function ($buffer)
303
			{
304
				return preg_replace('~[\r]?\n~', "\n", $buffer);
305
			};
306
	}
307
308
	// Since we don't do output compression for files this large...
309
	if (filesize($file['filePath']) > 4194304)