Code Duplication    Length = 18-18 lines in 2 locations

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)

Sources/Display.php 1 location

@@ 1709-1726 (lines=18) @@
1706
	@set_time_limit(600);
1707
1708
	// Recode line endings for text files, if enabled.
1709
	if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file_ext, array('txt', 'css', 'htm', 'html', 'php', 'xml')))
1710
	{
1711
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false)
1712
			$callback = function ($buffer)
1713
			{
1714
				return preg_replace('~[\r]?\n~', "\r\n", $buffer);
1715
			};
1716
		elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false)
1717
			$callback = function ($buffer)
1718
			{
1719
				return preg_replace('~[\r]?\n~', "\r", $buffer);
1720
			};
1721
		else
1722
			$callback = function ($buffer)
1723
			{
1724
				return preg_replace('~[\r]?\n~', "\n", $buffer);
1725
			};
1726
	}
1727
1728
	// Since we don't do output compression for files this large...
1729
	if (filesize($filename) > 4194304)