Use Rhymix Framework to decide whether a file can be directly downloaded

xpressengine/xe-core#1997
This commit is contained in:
Kijin Sung 2017-02-06 15:58:10 +09:00
parent f17fa23598
commit e1ffe39a2e
4 changed files with 41 additions and 2 deletions

View file

@ -85,4 +85,22 @@ class FilenameFilter
// Trim trailing slashes.
return rtrim($path, '/');
}
/**
* Check if a file has an extension that would allow direct download.
*
* @param string $filename
* @return bool
*/
public static function isDirectDownload($filename)
{
if (preg_match('/\.(as[fx]|avi|flac|flv|gif|jpe?g|m4[av]|midi?|mkv|moov|mov|mp[1234]|mpe?g|ogg|png|qt|ram?|rmm?|swf|wav|web[mp]|wm[av])$/i', $filename))
{
return true;
}
else
{
return false;
}
}
}