mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 04:40:44 +02:00
Mime fixes.
This commit is contained in:
@@ -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)
|
function imageTab($type,$options)
|
||||||
{
|
{
|
||||||
$tag = ($options['bbcode']) ? "" : $this->getQuery('tagid');
|
$tag = ($options['bbcode']) ? "" : $this->getQuery('tagid');
|
||||||
|
@@ -310,12 +310,78 @@ class e_file
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an extension for a specific mime-type.
|
||||||
|
* @param $mimeType
|
||||||
|
* @return mixed|null
|
||||||
|
*/
|
||||||
function getFileExtension($mimeType)
|
function getFileExtension($mimeType)
|
||||||
{
|
{
|
||||||
$extensions = array(
|
$extensions = array(
|
||||||
'image/jpeg'=>'.jpg',
|
'application/ecmascript' => '.es',
|
||||||
'image/png' => '.png',
|
'application/epub+zip' => '.epub',
|
||||||
'image/gif' => '.gif'
|
'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]))
|
if(isset($extensions[$mimeType]))
|
||||||
@@ -323,6 +389,7 @@ class e_file
|
|||||||
return $extensions[$mimeType];
|
return $extensions[$mimeType];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -413,6 +480,10 @@ class e_file
|
|||||||
{
|
{
|
||||||
switch($finfo['pathinfo']['extension'])
|
switch($finfo['pathinfo']['extension'])
|
||||||
{
|
{
|
||||||
|
case "svg":
|
||||||
|
$finfo['mime'] = 'image/svg+xml';
|
||||||
|
break;
|
||||||
|
|
||||||
case "mp3":
|
case "mp3":
|
||||||
$finfo['mime'] = 'audio/mpeg';
|
$finfo['mime'] = 'audio/mpeg';
|
||||||
break;
|
break;
|
||||||
|
@@ -348,7 +348,7 @@ class e_media
|
|||||||
{
|
{
|
||||||
if($owner == '')
|
if($owner == '')
|
||||||
{
|
{
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = e107::getDb();
|
$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)
|
public function mediaSelect($category='',$tagid=null,$att=null)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -1324,20 +1330,19 @@ class e_media
|
|||||||
* @param $mime
|
* @param $mime
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function checkFileExtension($path, $mime)
|
public function checkFileExtension($path, $mime)
|
||||||
{
|
{
|
||||||
if(empty($mime))
|
if(empty($mime))
|
||||||
{
|
{
|
||||||
return $path;
|
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
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user