mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-06 17:13:03 +01:00
Enhance mime detection
This commit is contained in:
@@ -172,28 +172,28 @@ function dol_mimetype($file,$default='application/octet-stream',$shortmime=0)
|
||||
|
||||
// Text files
|
||||
if (preg_match('/\.txt$/i',$file)) $mime='text/plain';
|
||||
if (preg_match('/\.rtx$/i',$file)) $mime='text/richtext';
|
||||
if (preg_match('/\.rtx$/i',$file)) $mime='text/richtext';
|
||||
if (preg_match('/\.csv$/i',$file)) $mime='text/csv';
|
||||
if (preg_match('/\.tsv$/i',$file)) $mime='text/tab-separated-values';
|
||||
if (preg_match('/\.(cf|conf|ini|log)$/i',$file)) $mime='text/plain';
|
||||
if (preg_match('/\.css$/i',$file)) $mime='text/css';
|
||||
// Certificate files
|
||||
if (preg_match('/\.(crt|cer|key|pub)$/i',$file)) $mime='text/plain';
|
||||
// HTML
|
||||
if (preg_match('/\.(html|htm|shtml)$/i',$file)) $mime='text/html';
|
||||
// Languages
|
||||
if (preg_match('/\.bas$/i',$file)) $mime='text/plain';
|
||||
if (preg_match('/\.(c|cpp|h)$/i',$file)) $mime='text/plain';
|
||||
if (preg_match('/\.(java|jsp)$/i',$file)) $mime='text/plain';
|
||||
if (preg_match('/\.php$/i',$file)) $mime='text/plain';
|
||||
if (preg_match('/\.(pl|pm)$/i',$file)) $mime='text/plain';
|
||||
if (preg_match('/\.sql$/i',$file)) $mime='text/plain';
|
||||
if (preg_match('/\.js$/i',$file)) $mime='text/x-javascript';
|
||||
// Open office
|
||||
if (preg_match('/\.odp$/i',$file)) $mime='application/vnd.oasis.opendocument.presentation';
|
||||
if (preg_match('/\.ods$/i',$file)) $mime='application/vnd.oasis.opendocument.spreadsheet';
|
||||
if (preg_match('/\.odt$/i',$file)) $mime='application/vnd.oasis.opendocument.text';
|
||||
// MS Office
|
||||
if (preg_match('/\.(cf|conf|ini|log)$/i',$file)) $mime='text/plain';
|
||||
if (preg_match('/\.css$/i',$file)) $mime='text/css';
|
||||
// Certificate files
|
||||
if (preg_match('/\.(crt|cer|key|pub)$/i',$file)) $mime='text/plain';
|
||||
// HTML
|
||||
if (preg_match('/\.(html|htm|shtml)$/i',$file)) $mime='text/html';
|
||||
// Languages
|
||||
if (preg_match('/\.bas$/i',$file)) $mime='text/plain';
|
||||
if (preg_match('/\.(c|cpp|h)$/i',$file)) $mime='text/plain';
|
||||
if (preg_match('/\.(java|jsp)$/i',$file)) $mime='text/plain';
|
||||
if (preg_match('/\.php$/i',$file)) $mime='text/plain';
|
||||
if (preg_match('/\.(pl|pm)$/i',$file)) $mime='text/plain';
|
||||
if (preg_match('/\.sql$/i',$file)) $mime='text/plain';
|
||||
if (preg_match('/\.js$/i',$file)) $mime='text/x-javascript';
|
||||
// Open office
|
||||
if (preg_match('/\.odp$/i',$file)) $mime='application/vnd.oasis.opendocument.presentation';
|
||||
if (preg_match('/\.ods$/i',$file)) $mime='application/vnd.oasis.opendocument.spreadsheet';
|
||||
if (preg_match('/\.odt$/i',$file)) $mime='application/vnd.oasis.opendocument.text';
|
||||
// MS Office
|
||||
if (preg_match('/\.mdb$/i',$file)) $mime='application/msaccess';
|
||||
if (preg_match('/\.doc(x|m)?$/i',$file)) $mime='application/msword';
|
||||
if (preg_match('/\.dot(x|m)?$/i',$file)) $mime='application/msword';
|
||||
@@ -202,15 +202,15 @@ function dol_mimetype($file,$default='application/octet-stream',$shortmime=0)
|
||||
if (preg_match('/\.xla(m)?$/i',$file)) $mime='application/vnd.ms-excel';
|
||||
if (preg_match('/\.pps(m|x)?$/i',$file)) $mime='application/vnd.ms-powerpoint';
|
||||
if (preg_match('/\.ppt(m|x)?$/i',$file)) $mime='application/x-mspowerpoint';
|
||||
// Other
|
||||
if (preg_match('/\.pdf$/i',$file)) $mime='application/pdf';
|
||||
// Other
|
||||
if (preg_match('/\.pdf$/i',$file)) $mime='application/pdf';
|
||||
// Scripts
|
||||
if (preg_match('/\.bat$/i',$file)) $mime='text/x-bat';
|
||||
if (preg_match('/\.sh$/i',$file)) $mime='text/x-sh';
|
||||
if (preg_match('/\.ksh$/i',$file)) $mime='text/x-ksh';
|
||||
if (preg_match('/\.bash$/i',$file)) $mime='text/x-bash';
|
||||
if (preg_match('/\.bat$/i',$file)) $mime='text/x-bat';
|
||||
if (preg_match('/\.sh$/i',$file)) $mime='text/x-sh';
|
||||
if (preg_match('/\.ksh$/i',$file)) $mime='text/x-ksh';
|
||||
if (preg_match('/\.bash$/i',$file)) $mime='text/x-bash';
|
||||
// Images
|
||||
if (preg_match('/\.ico$/i',$file)) $mime='image/x-icon';
|
||||
if (preg_match('/\.ico$/i',$file)) $mime='image/x-icon';
|
||||
if (preg_match('/\.(jpg|jpeg)$/i',$file)) $mime='image/jpeg';
|
||||
if (preg_match('/\.png$/i',$file)) $mime='image/png';
|
||||
if (preg_match('/\.gif$/i',$file)) $mime='image/gif';
|
||||
@@ -228,9 +228,9 @@ function dol_mimetype($file,$default='application/octet-stream',$shortmime=0)
|
||||
// Archive
|
||||
if (preg_match('/\.(zip|rar|gz|tgz|z|cab|bz2|7z|tar|lzh)$/i',$file)) $mime='archive'; // application/xxx where zzz is zip, ...
|
||||
// Exe
|
||||
if (preg_match('/\.(exe|com)$/i',$file)) $mime='application';
|
||||
if (preg_match('/\.(exe|com)$/i',$file)) $mime='application/octet-stream';
|
||||
// Exe
|
||||
if (preg_match('/\.(dll|lib|o|so|a)$/i',$file)) $mime='library';
|
||||
if (preg_match('/\.(dll|lib|o|so|a)$/i',$file)) $mime='library';
|
||||
|
||||
if ($shortmime)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user