summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2008-07-25 15:13:15 +0000
committerthomascube <thomas@roundcube.net>2008-07-25 15:13:15 +0000
commit6d5dbae53cd4b4b97da0b0c558292a7f1062a524 (patch)
tree244697d83b4d9fa572883a8dfe2ad0a9911a329f /program/include
parent94e38bbc1e497192c0b4e7345b2ceb307473dfff (diff)
Prefer File_Info over mime_content_type + detect mime type when uploading + some code style
Diffstat (limited to 'program/include')
-rw-r--r--program/include/rcube_shared.inc31
1 files changed, 13 insertions, 18 deletions
diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc
index 4cab27096..000483ef8 100644
--- a/program/include/rcube_shared.inc
+++ b/program/include/rcube_shared.inc
@@ -556,31 +556,26 @@ function get_offset_time($offset_str, $factor=1)
*/
function rc_mime_content_type($path, $failover = 'unknown/unknown')
{
- global $CONFIG;
+ $mime_type = null;
+ $mime_magic = rcmail::get_instance()->config->get('mime_magic');
- $mime_magic = $CONFIG['mime_magic'];
-
- if (function_exists('mime_content_type')) {
- $finfo = mime_content_type($path);
- if ($finfo)
- return $finfo;
+ if (!extension_loaded('fileinfo')) {
+ @dl('fileinfo.' . PHP_SHLIB_SUFFIX);
}
-
- if (!extension_loaded('fileinfo')) {
- if (!dl('fileinfo.' . PHP_SHLIB_SUFFIX)) {
- return $failover;
+
+ if (function_exists('finfo_open')) {
+ if ($finfo = finfo_open(FILEINFO_MIME, $mime_magic)) {
+ $mime_type = finfo_file($finfo, $path);
+ finfo_close($finfo);
}
}
-
- $finfo = finfo_open(FILEINFO_MIME, $mime_magic);
- if (!$finfo) {
- return $failover;
+ else if (function_exists('mime_content_type')) {
+ $mime_type = mime_content_type($path);
}
- $mime_type = finfo_file($finfo,$path);
+
if (!$mime_type) {
- return $failover;
+ $mime_type = $failover;
}
- finfo_close($finfo);
return $mime_type;
}