X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Flibs%2Fmime%2FMimeAnalyzer.php;h=0083e4b32a7ce6fc688ec1167d5858ce5cde4ec8;hp=4cd8e4e81584a240eee045d05196c443b362cace;hb=f7e1770fb832aa77bf4e16ce8cc815f2b24dd10d;hpb=a2f5d05ae842d26847d924ed5f57776108101363 diff --git a/includes/libs/mime/MimeAnalyzer.php b/includes/libs/mime/MimeAnalyzer.php index 4cd8e4e815..0083e4b32a 100644 --- a/includes/libs/mime/MimeAnalyzer.php +++ b/includes/libs/mime/MimeAnalyzer.php @@ -529,7 +529,7 @@ EOT; // Formats we recognize magic numbers for 'djvu', 'ogx', 'ogg', 'ogv', 'oga', 'spx', 'opus', 'mid', 'pdf', 'wmf', 'xcf', 'webm', 'mkv', 'mka', - 'webp', + 'webp', 'mp3', // XML formats we sure hope we recognize reliably 'svg', @@ -673,6 +673,10 @@ EOT; // Multimedia... 'MThd' => 'audio/midi', 'OggS' => 'application/ogg', + 'ID3' => 'audio/mpeg', + "\xff\xfb" => 'audio/mpeg', // MPEG-1 layer 3 + "\xff\xf3" => 'audio/mpeg', // MPEG-2 layer 3 (lower sample rates) + "\xff\xe3" => 'audio/mpeg', // MPEG-2.5 layer 3 (very low sample rates) // Image formats... // Note that WMF may have a bare header, no magic number. @@ -738,8 +742,8 @@ EOT; ( strpos( $head, "<\x00?\x00 " ) !== false ) || ( strpos( $head, "<\x00?\x00\n" ) !== false ) || ( strpos( $head, "<\x00?\x00\t" ) !== false ) || - ( strpos( $head, "<\x00?\x00=" ) !== false ) ) { - + ( strpos( $head, "<\x00?\x00=" ) !== false ) + ) { $this->logger->info( __METHOD__ . ": recognized $file as application/x-php\n" ); return 'application/x-php'; } @@ -1055,7 +1059,6 @@ EOT; // Special code for ogg - detect if it's video (theora), // else label it as sound. if ( $mime == 'application/ogg' && file_exists( $path ) ) { - // Read a chunk of the file $f = fopen( $path, "rt" ); if ( !$f ) { @@ -1161,6 +1164,15 @@ EOT; return MEDIATYPE_UNKNOWN; } + /** + * Returns an array of media types (MEDIATYPE_xxx constants) + * + * @return array + */ + public function getMediaTypes() { + return array_keys( $this->mediaTypes ); + } + /** * Get the MIME types that various versions of Internet Explorer would * detect from a chunk of the content.