mirror of
https://github.com/e107inc/e107.git
synced 2025-04-20 20:51:53 +02:00
Mime fixes.
This commit is contained in:
parent
0f5396fed8
commit
ae08e50413
@ -1629,7 +1629,12 @@ class media_admin_ui extends e_admin_ui
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated to be replaced by imageTab2
|
||||
* @param $type
|
||||
* @param $options
|
||||
* @return string
|
||||
*/
|
||||
function imageTab($type,$options)
|
||||
{
|
||||
$tag = ($options['bbcode']) ? "" : $this->getQuery('tagid');
|
||||
|
@ -310,19 +310,86 @@ class e_file
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an extension for a specific mime-type.
|
||||
* @param $mimeType
|
||||
* @return mixed|null
|
||||
*/
|
||||
function getFileExtension($mimeType)
|
||||
{
|
||||
$extensions = array(
|
||||
'image/jpeg'=>'.jpg',
|
||||
'image/png' => '.png',
|
||||
'image/gif' => '.gif'
|
||||
);
|
||||
|
||||
'application/ecmascript' => '.es',
|
||||
'application/epub+zip' => '.epub',
|
||||
'application/java-archive' => '.jar',
|
||||
'application/javascript' => '.js',
|
||||
'application/json' => '.json',
|
||||
'application/msword' => '.doc',
|
||||
'application/octet-stream' => '.bin',
|
||||
'application/ogg' => '.ogx',
|
||||
'application/pdf' => '.pdf',
|
||||
'application/rtf' => '.rtf',
|
||||
'application/typescript' => '.ts',
|
||||
'application/vnd.amazon.ebook' => '.azw',
|
||||
'application/vnd.apple.installer+xml' => '.mpkg',
|
||||
'application/vnd.mozilla.xul+xml' => '.xul',
|
||||
'application/vnd.ms-excel' => '.xls',
|
||||
'application/vnd.ms-fontobject' => '.eot',
|
||||
'application/vnd.ms-powerpoint' => '.ppt',
|
||||
'application/vnd.oasis.opendocument.presentation' => '.odp',
|
||||
'application/vnd.oasis.opendocument.spreadsheet' => '.ods',
|
||||
'application/vnd.oasis.opendocument.text' => '.odt',
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.presentation' => '.pptx',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => '.xlsx',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => '.docx',
|
||||
'application/vnd.visio' => '.vsd',
|
||||
'application/x-7z-compressed' => '.7z',
|
||||
'application/x-abiword' => '.abw',
|
||||
'application/x-bzip' => '.bz',
|
||||
'application/x-bzip2' => '.bz2',
|
||||
'application/x-csh' => '.csh',
|
||||
'application/x-rar-compressed' => '.rar',
|
||||
'application/x-sh' => '.sh',
|
||||
'application/x-shockwave-flash' => '.swf',
|
||||
'application/x-tar' => '.tar',
|
||||
'application/xhtml+xml' => '.xhtml',
|
||||
'application/xml' => '.xml',
|
||||
'application/zip' => '.zip',
|
||||
'audio/aac' => '.aac',
|
||||
'audio/midi' => '.midi',
|
||||
'audio/mpeg' => '.mp3',
|
||||
'audio/ogg' => '.oga',
|
||||
'audio/wav' => '.wav',
|
||||
'audio/webm' => '.weba',
|
||||
'font/otf' => '.otf',
|
||||
'font/ttf' => '.ttf',
|
||||
'font/woff' => '.woff',
|
||||
'font/woff2' => '.woff2',
|
||||
'image/bmp' => '.bmp',
|
||||
'image/gif' => '.gif',
|
||||
'image/jpeg' => '.jpg',
|
||||
'image/png' => '.png',
|
||||
'image/svg+xml' => '.svg',
|
||||
'image/tiff' => '.tiff',
|
||||
'image/webp' => '.webp',
|
||||
'image/x-icon' => '.ico',
|
||||
'text/calendar' => '.ics',
|
||||
'text/css' => '.css',
|
||||
'text/csv' => '.csv',
|
||||
'text/html' => '.html',
|
||||
'text/plain' => '.txt',
|
||||
'video/mp4' => '.mp4',
|
||||
'video/mpeg' => '.mpeg',
|
||||
'video/ogg' => '.ogv',
|
||||
'video/webm' => '.webm',
|
||||
'video/x-msvideo' => '.avi',
|
||||
);
|
||||
|
||||
if(isset($extensions[$mimeType]))
|
||||
{
|
||||
return $extensions[$mimeType];
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -413,6 +480,10 @@ class e_file
|
||||
{
|
||||
switch($finfo['pathinfo']['extension'])
|
||||
{
|
||||
case "svg":
|
||||
$finfo['mime'] = 'image/svg+xml';
|
||||
break;
|
||||
|
||||
case "mp3":
|
||||
$finfo['mime'] = 'audio/mpeg';
|
||||
break;
|
||||
|
@ -348,7 +348,7 @@ class e_media
|
||||
{
|
||||
if($owner == '')
|
||||
{
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$sql = e107::getDb();
|
||||
@ -653,7 +653,13 @@ class e_media
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated by browserCarousel
|
||||
* @param string $category
|
||||
* @param null $tagid
|
||||
* @param null $att
|
||||
* @return string
|
||||
*/
|
||||
public function mediaSelect($category='',$tagid=null,$att=null)
|
||||
{
|
||||
|
||||
@ -1324,20 +1330,19 @@ class e_media
|
||||
* @param $mime
|
||||
* @return string
|
||||
*/
|
||||
private function checkFileExtension($path, $mime)
|
||||
public function checkFileExtension($path, $mime)
|
||||
{
|
||||
if(empty($mime))
|
||||
{
|
||||
return $path;
|
||||
}
|
||||
|
||||
list($type,$ext) = explode("/",$mime);
|
||||
|
||||
$ext = str_replace("jpeg",'jpg',$ext);
|
||||
$ext = e107::getFile()->getFileExtension($mime);
|
||||
|
||||
if($type == 'image' && (substr($path,-3) != $ext))
|
||||
if($ext && (substr($path,-4) != $ext))
|
||||
{
|
||||
return $path.".".$ext;
|
||||
return $path.$ext;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user