Merge pull request #535 from kijin/pr/ua-improvement

User-Agent 감지 기능 개선
This commit is contained in:
Kijin Sung 2016-06-26 17:55:46 +09:00 committed by GitHub
commit 866b709f36
3 changed files with 345 additions and 40 deletions

View file

@ -342,25 +342,8 @@ class fileController extends file
exit();
}
// Filename encoding for browsers that support RFC 5987
if(preg_match('#(?:Chrome|Edge)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 11)
{
$filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"';
}
elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6)
{
$filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"';
}
// Filename encoding for browsers that do not support RFC 5987
elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
{
$filename = rawurlencode($filename);
$filename_param = 'filename="' . preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1) . '"';
}
else
{
$filename_param = 'filename="' . $filename . '"';
}
// Encode the filename.
$filename_param = Rhymix\Framework\UA::encodeFilenameForDownload($filename);
// Close context to prevent blocking the session
Context::close();