protected function mimetype($path, $name = '')
{
$type = '';
if ($this->mimeDetect == 'finfo') {
if ($type = @finfo_file($this->finfo, $path)) {
if ($name === '') {
$name = $path;
}
$ext = false === ($pos = strrpos($name, '.')) ? '' : substr($name, $pos + 1);
if ($ext && preg_match('~^application/(?:octet-stream|(?:x-)?zip)~', $type)) {
if (isset(elFinderVolumeDriver::$mimetypes[$ext])) {
$type = elFinderVolumeDriver::$mimetypes[$ext];
}
}
}
} elseif ($type == 'mime_content_type') {
$type = mime_content_type($path);
} else {
$type = elFinderVolumeDriver::mimetypeInternalDetect($path);
}
$type = explode(';', $type);
$type = trim($type[0]);
if (in_array($type, array('application/x-empty', 'inode/x-empty'))) {
// finfo return this mime for empty files
$type = 'text/plain';
} elseif ($type == 'application/x-zip') {
// http://elrte.org/redmine/issues/163
$type = 'application/zip';
}
return $type == 'unknown' && $this->mimeDetect != 'internal' ? elFinderVolumeDriver::mimetypeInternalDetect($path) : $type;
}