proxy.php

Simple redirection proxy
git clone git://git.finwo.net/misc/proxy.php
Log | Files | Refs | README

mime_content_type.php (2465B)


      1 <?php
      2 
      3 if(!function_exists('mime_content_type')) {
      4 
      5     function mime_content_type($filename) {
      6 
      7         $mime_types = array(
      8 
      9             'txt' => 'text/plain',
     10             'htm' => 'text/html',
     11             'html' => 'text/html',
     12             'php' => 'text/html',
     13             'css' => 'text/css',
     14             'js' => 'application/javascript',
     15             'json' => 'application/json',
     16             'xml' => 'application/xml',
     17             'swf' => 'application/x-shockwave-flash',
     18             'flv' => 'video/x-flv',
     19 
     20             // images
     21             'png' => 'image/png',
     22             'jpe' => 'image/jpeg',
     23             'jpeg' => 'image/jpeg',
     24             'jpg' => 'image/jpeg',
     25             'gif' => 'image/gif',
     26             'bmp' => 'image/bmp',
     27             'ico' => 'image/vnd.microsoft.icon',
     28             'tiff' => 'image/tiff',
     29             'tif' => 'image/tiff',
     30             'svg' => 'image/svg+xml',
     31             'svgz' => 'image/svg+xml',
     32 
     33             // archives
     34             'zip' => 'application/zip',
     35             'rar' => 'application/x-rar-compressed',
     36             'exe' => 'application/x-msdownload',
     37             'msi' => 'application/x-msdownload',
     38             'cab' => 'application/vnd.ms-cab-compressed',
     39 
     40             // audio/video
     41             'mp3' => 'audio/mpeg',
     42             'qt' => 'video/quicktime',
     43             'mov' => 'video/quicktime',
     44 
     45             // adobe
     46             'pdf' => 'application/pdf',
     47             'psd' => 'image/vnd.adobe.photoshop',
     48             'ai' => 'application/postscript',
     49             'eps' => 'application/postscript',
     50             'ps' => 'application/postscript',
     51 
     52             // ms office
     53             'doc' => 'application/msword',
     54             'rtf' => 'application/rtf',
     55             'xls' => 'application/vnd.ms-excel',
     56             'ppt' => 'application/vnd.ms-powerpoint',
     57 
     58             // open office
     59             'odt' => 'application/vnd.oasis.opendocument.text',
     60             'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
     61         );
     62 
     63         $ext = strtolower(@array_pop(explode('.',$filename)));
     64         if (array_key_exists($ext, $mime_types)) {
     65             return $mime_types[$ext];
     66         }
     67         elseif (function_exists('finfo_open')) {
     68             $finfo = finfo_open(FILEINFO_MIME);
     69             $mimetype = finfo_file($finfo, $filename);
     70             finfo_close($finfo);
     71             return $mimetype;
     72         }
     73         else {
     74             return 'application/octet-stream';
     75         }
     76     }
     77 }