mirror of
https://github.com/Studio-42/elFinder
synced 2026-06-08 12:37:09 +00:00
src build elFinder-2.1-f9aafbe
This commit is contained in:
@@ -4202,41 +4202,31 @@ abstract class elFinderVolumeDriver {
|
||||
$nameCheck = true;
|
||||
}
|
||||
$ext = (false === $pos = strrpos($name, '.')) ? '' : substr($name, $pos + 1);
|
||||
if (! $nameCheck && is_readable($path)) {
|
||||
if (filesize($path) > 0) {
|
||||
if ($this->mimeDetect == 'finfo') {
|
||||
if ($type = finfo_file($this->finfo, $path)) {
|
||||
if ($ext && preg_match('~^application/(?:octet-stream|(?:x-)?zip)~', $type)) {
|
||||
if (isset(elFinderVolumeDriver::$mimetypes[$ext])) $type = elFinderVolumeDriver::$mimetypes[$ext];
|
||||
} else if ($ext === 'js' && preg_match('~^text/~', $type)) {
|
||||
$type = 'text/javascript';
|
||||
}
|
||||
} else {
|
||||
$type = 'unknown';
|
||||
if (! $nameCheck && is_readable($path) && filesize($path) > 0) {
|
||||
// detecting by contents
|
||||
if ($this->mimeDetect === 'finfo') {
|
||||
$type = finfo_file($this->finfo, $path);
|
||||
} else if ($this->mimeDetect === 'mime_content_type') {
|
||||
$type = mime_content_type($path);
|
||||
}
|
||||
if ($type) {
|
||||
if ($ext && preg_match('~^application/(?:octet-stream|(?:x-)?zip)~', $type)) {
|
||||
if (isset(elFinderVolumeDriver::$mimetypes[$ext])) {
|
||||
$type = elFinderVolumeDriver::$mimetypes[$ext];
|
||||
}
|
||||
} else if ($this->mimeDetect == 'mime_content_type') {
|
||||
$type = mime_content_type($path);
|
||||
} else if ($ext === 'js' && preg_match('~^text/~', $type)) {
|
||||
$type = 'text/javascript';
|
||||
}
|
||||
} else {
|
||||
$type = 'text/plain';
|
||||
}
|
||||
}
|
||||
if (! $type) {
|
||||
$type = elFinderVolumeDriver::mimetypeInternalDetect($path);
|
||||
}
|
||||
|
||||
if ($type === 'unknown' && $this->mimeDetect != 'internal') {
|
||||
$type = elFinderVolumeDriver::mimetypeInternalDetect($path);
|
||||
// detecting by filename
|
||||
$type = elFinderVolumeDriver::mimetypeInternalDetect($name);
|
||||
}
|
||||
|
||||
$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';
|
||||
}
|
||||
|
||||
// mime type normalization
|
||||
$_checkKey = strtolower($ext.':'.$type);
|
||||
if (isset($this->options['mimeMap'][$_checkKey])) {
|
||||
|
||||
Reference in New Issue
Block a user