src build elFinder-2.1-f9aafbe

This commit is contained in:
nao-pon
2017-09-28 00:08:04 +09:00
parent 2d55b224a9
commit d6d9c80044
5 changed files with 21 additions and 31 deletions
+15 -25
View File
@@ -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])) {