X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FMimeMagic.php;h=aedfd8fecebf968c73d021c558816d03ea196d80;hb=b06ba4991ec72069c4fa1a0bd73e916b0fac42fb;hp=2b240c3b02b45e19002450442450ca1b6d116337;hpb=497b94a02f41e161bba485d17a4fe6803440bb0f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/MimeMagic.php b/includes/MimeMagic.php index 2b240c3b02..aedfd8fece 100644 --- a/includes/MimeMagic.php +++ b/includes/MimeMagic.php @@ -59,7 +59,7 @@ application/vnd.oasis.opendocument.text odt application/vnd.oasis.opendocument.text-master otm application/vnd.oasis.opendocument.text-template ott application/vnd.oasis.opendocument.text-web oth -application/x-javascript js +application/javascript js application/x-shockwave-flash swf audio/midi mid midi kar audio/mpeg mpga mpa mp2 mp3 @@ -110,7 +110,7 @@ application/vnd.oasis.opendocument.text [OFFICE] application/vnd.oasis.opendocument.text-template [OFFICE] application/vnd.oasis.opendocument.text-master [OFFICE] application/vnd.oasis.opendocument.text-web [OFFICE] -text/javascript application/x-javascript [EXECUTABLE] +application/javascript text/javascript application/x-javascript [EXECUTABLE] application/x-shockwave-flash [MULTIMEDIA] audio/midi [AUDIO] audio/x-aiff [AUDIO] @@ -200,7 +200,7 @@ class MimeMagic { global $IP; # Allow media handling extensions adding MIME-types and MIME-info - Hooks::run( 'MimeMagicInit', array( $this ) ); + Hooks::run( 'MimeMagicInit', [ $this ] ); $types = MM_WELL_KNOWN_MIME_TYPES; @@ -223,11 +223,11 @@ class MimeMagic { $types .= "\n" . $this->mExtraTypes; - $types = str_replace( array( "\r\n", "\n\r", "\n\n", "\r\r", "\r" ), "\n", $types ); + $types = str_replace( [ "\r\n", "\n\r", "\n\n", "\r\r", "\r" ], "\n", $types ); $types = str_replace( "\t", " ", $types ); - $this->mMimeToExt = array(); - $this->mExtToMime = array(); + $this->mMimeToExt = []; + $this->mExtToMime = []; $lines = explode( "\n", $types ); foreach ( $lines as $s ) { @@ -300,11 +300,11 @@ class MimeMagic { $info .= "\n" . $this->mExtraInfo; - $info = str_replace( array( "\r\n", "\n\r", "\n\n", "\r\r", "\r" ), "\n", $info ); + $info = str_replace( [ "\r\n", "\n\r", "\n\n", "\r\r", "\r" ], "\n", $info ); $info = str_replace( "\t", " ", $info ); - $this->mMimeTypeAliases = array(); - $this->mMediaTypes = array(); + $this->mMimeTypeAliases = []; + $this->mMediaTypes = []; $lines = explode( "\n", $info ); foreach ( $lines as $s ) { @@ -323,9 +323,9 @@ class MimeMagic { continue; } - #print "processing MIME INFO line $s
"; + # print "processing MIME INFO line $s
"; - $match = array(); + $match = []; if ( preg_match( '!\[\s*(\w+)\s*\]!', $s, $match ) ) { $s = preg_replace( '!\[\s*(\w+)\s*\]!', '', $s ); $mtype = trim( strtoupper( $match[1] ) ); @@ -336,7 +336,7 @@ class MimeMagic { $m = explode( ' ', $s ); if ( !isset( $this->mMediaTypes[$mtype] ) ) { - $this->mMediaTypes[$mtype] = array(); + $this->mMediaTypes[$mtype] = []; } foreach ( $m as $mime ) { @@ -485,7 +485,7 @@ class MimeMagic { */ public function isPHPImageType( $mime ) { // As defined by imagegetsize and image_type_to_mime - static $types = array( + static $types = [ 'image/gif', 'image/jpeg', 'image/png', 'image/x-bmp', 'image/xbm', 'image/tiff', 'image/jp2', 'image/jpeg2000', 'image/iff', @@ -493,7 +493,7 @@ class MimeMagic { 'image/vnd.wap.wbmp', 'image/vnd.xiff', 'image/x-photoshop', 'application/x-shockwave-flash', - ); + ]; return in_array( $mime, $types ); } @@ -511,7 +511,7 @@ class MimeMagic { * @return bool */ function isRecognizableExtension( $extension ) { - static $types = array( + static $types = [ // Types recognized by getimagesize() 'gif', 'jpeg', 'jpg', 'png', 'swf', 'psd', 'bmp', 'tiff', 'tif', 'jpc', 'jp2', @@ -525,7 +525,7 @@ class MimeMagic { // XML formats we sure hope we recognize reliably 'svg', - ); + ]; return in_array( strtolower( $extension ), $types ); } @@ -569,7 +569,7 @@ class MimeMagic { } # Media handling extensions can improve the MIME detected - Hooks::run( 'MimeMagicImproveFromExtension', array( $this, $ext, &$mime ) ); + Hooks::run( 'MimeMagicImproveFromExtension', [ $this, $ext, &$mime ] ); if ( isset( $this->mMimeTypeAliases[$mime] ) ) { $mime = $this->mMimeTypeAliases[$mime]; @@ -651,7 +651,7 @@ class MimeMagic { wfDebug( __METHOD__ . ": analyzing head and tail of $file for magic numbers.\n" ); // Hardcode a few magic number checks... - $headers = array( + $headers = [ // Multimedia... 'MThd' => 'audio/midi', 'OggS' => 'application/ogg', @@ -667,7 +667,7 @@ class MimeMagic { 'MZ' => 'application/octet-stream', // DOS/Windows executable "\xca\xfe\xba\xbe" => 'application/octet-stream', // Mach-O binary "\x7fELF" => 'application/octet-stream', // ELF binary - ); + ]; foreach ( $headers as $magic => $candidate ) { if ( strncmp( $head, $magic, strlen( $magic ) ) == 0 ) { @@ -755,7 +755,7 @@ class MimeMagic { if ( $script_type ) { if ( $script_type !== "UTF-8" && $script_type !== "ASCII" ) { // Quick and dirty fold down to ASCII! - $pack = array( 'UTF-16BE' => 'n*', 'UTF-16LE' => 'v*' ); + $pack = [ 'UTF-16BE' => 'n*', 'UTF-16LE' => 'v*' ]; $chars = unpack( $pack[$script_type], substr( $head, 2 ) ); $head = ''; foreach ( $chars as $codepoint ) { @@ -767,7 +767,7 @@ class MimeMagic { } } - $match = array(); + $match = []; if ( preg_match( '%/?([^\s]+/)(\w+)%', $head, $match ) ) { $mime = "application/x-{$match[2]}"; @@ -806,7 +806,7 @@ class MimeMagic { # Some strings by reference for performance - assuming well-behaved hooks Hooks::run( 'MimeMagicGuessFromContent', - array( $this, &$head, &$tail, $file, &$mime ) + [ $this, &$head, &$tail, $file, &$mime ] ); return $mime; @@ -832,7 +832,7 @@ class MimeMagic { } $mime = 'application/zip'; - $opendocTypes = array( + $opendocTypes = [ 'chart-template', 'chart', 'formula-template', @@ -848,7 +848,7 @@ class MimeMagic { 'text-template', 'text-master', 'text-web', - 'text' ); + 'text' ]; // http://lists.oasis-open.org/archives/office/200505/msg00006.html $types = '(?:' . implode( '|', $opendocTypes ) . ')'; @@ -957,7 +957,7 @@ class MimeMagic { if ( $m ) { # normalize - $m = preg_replace( '![;, ].*$!', '', $m ); #strip charset, etc + $m = preg_replace( '![;, ].*$!', '', $m ); # strip charset, etc $m = trim( $m ); $m = strtolower( $m ); @@ -1110,7 +1110,7 @@ class MimeMagic { $extMime = $this->mMimeTypeAliases[$extMime]; } - $m = array( $extMime ); + $m = [ $extMime ]; } foreach ( $m as $mime ) {