Пример #1
0
 /**
  * Return file mimetype
  *
  * @param  string  $path  file path
  * @return string
  * @author Dmitry (dio) Levashov
  **/
 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;
 }