You are here

webfm_mime_types.inc in Web File Manager 5

File

webfm_mime_types.inc
View source
<?php

function webfm_get_mime_type($ext) {
  static $webfm_mime_types = array();
  $ext = strtolower($ext);

  //detect capitalied file extensions, as per #261880
  if (empty($webfm_mime_types)) {
    $webfm_mime_types['ai'] = 'application/postscript';
    $webfm_mime_types['aif'] = 'audio/x-aiff';
    $webfm_mime_types['aifc'] = 'audio/x-aiff';
    $webfm_mime_types['aiff'] = 'audio/x-aiff';
    $webfm_mime_types['asc'] = 'text/plain';
    $webfm_mime_types['atom'] = 'application/atom+xml';
    $webfm_mime_types['au'] = 'audio/basic';
    $webfm_mime_types['avi'] = 'video/x-msvideo';
    $webfm_mime_types['bcpio'] = 'application/x-bcpio';
    $webfm_mime_types['bin'] = 'application/octet-stream';
    $webfm_mime_types['bmp'] = 'image/bmp';
    $webfm_mime_types['cdf'] = 'application/x-netcdf';
    $webfm_mime_types['cgm'] = 'image/cgm';
    $webfm_mime_types['class'] = 'application/octet-stream';
    $webfm_mime_types['cpio'] = 'application/x-cpio';
    $webfm_mime_types['cpt'] = 'application/mac-compactpro';
    $webfm_mime_types['csh'] = 'application/x-csh';
    $webfm_mime_types['css'] = 'text/css';
    $webfm_mime_types['dcr'] = 'application/x-director';
    $webfm_mime_types['dif'] = 'video/x-dv';
    $webfm_mime_types['dir'] = 'application/x-director';
    $webfm_mime_types['djv'] = 'image/vnd.djvu';
    $webfm_mime_types['djvu'] = 'image/vnd.djvu';
    $webfm_mime_types['dll'] = 'application/octet-stream';
    $webfm_mime_types['dmg'] = 'application/octet-stream';
    $webfm_mime_types['dms'] = 'application/octet-stream';
    $webfm_mime_types['doc'] = 'application/msword';
    $webfm_mime_types['dtd'] = 'application/xml-dtd';
    $webfm_mime_types['dv'] = 'video/x-dv';
    $webfm_mime_types['dvi'] = 'application/x-dvi';
    $webfm_mime_types['dxr'] = 'application/x-director';
    $webfm_mime_types['eps'] = 'application/postscript';
    $webfm_mime_types['etx'] = 'text/x-setext';
    $webfm_mime_types['exe'] = 'application/octet-stream';
    $webfm_mime_types['ez'] = 'application/andrew-inset';
    $webfm_mime_types['gif'] = 'image/gif';
    $webfm_mime_types['gram'] = 'application/srgs';
    $webfm_mime_types['grxml'] = 'application/srgs+xml';
    $webfm_mime_types['gtar'] = 'application/x-gtar';
    $webfm_mime_types['hdf'] = 'application/x-hdf';
    $webfm_mime_types['hqx'] = 'application/mac-binhex40';
    $webfm_mime_types['htm'] = 'text/html';
    $webfm_mime_types['html'] = 'text/html';
    $webfm_mime_types['ice'] = 'x-conference/x-cooltalk';
    $webfm_mime_types['ico'] = 'image/x-icon';
    $webfm_mime_types['ics'] = 'text/calendar';
    $webfm_mime_types['ief'] = 'image/ief';
    $webfm_mime_types['ifb'] = 'text/calendar';
    $webfm_mime_types['iges'] = 'model/iges';
    $webfm_mime_types['igs'] = 'model/iges';
    $webfm_mime_types['jnlp'] = 'application/x-java-jnlp-file';
    $webfm_mime_types['jp2'] = 'image/jp2';
    $webfm_mime_types['jpe'] = 'image/jpeg';
    $webfm_mime_types['jpeg'] = 'image/jpeg';
    $webfm_mime_types['jpg'] = 'image/jpeg';
    $webfm_mime_types['js'] = 'application/x-javascript';
    $webfm_mime_types['kar'] = 'audio/midi';
    $webfm_mime_types['latex'] = 'application/x-latex';
    $webfm_mime_types['lha'] = 'application/octet-stream';
    $webfm_mime_types['lzh'] = 'application/octet-stream';
    $webfm_mime_types['m3u'] = 'audio/x-mpegurl';
    $webfm_mime_types['m4a'] = 'audio/mp4a-latm';
    $webfm_mime_types['m4b'] = 'audio/mp4a-latm';
    $webfm_mime_types['m4p'] = 'audio/mp4a-latm';
    $webfm_mime_types['m4u'] = 'video/vnd.mpegurl';
    $webfm_mime_types['m4v'] = 'video/x-m4v';
    $webfm_mime_types['mac'] = 'image/x-macpaint';
    $webfm_mime_types['man'] = 'application/x-troff-man';
    $webfm_mime_types['mathml'] = 'application/mathml+xml';
    $webfm_mime_types['me'] = 'application/x-troff-me';
    $webfm_mime_types['mesh'] = 'model/mesh';
    $webfm_mime_types['mid'] = 'audio/midi';
    $webfm_mime_types['midi'] = 'audio/midi';
    $webfm_mime_types['mif'] = 'application/vnd.mif';
    $webfm_mime_types['mov'] = 'video/quicktime';
    $webfm_mime_types['movie'] = 'video/x-sgi-movie';
    $webfm_mime_types['mp2'] = 'audio/mpeg';
    $webfm_mime_types['mp3'] = 'audio/mpeg';
    $webfm_mime_types['mp4'] = 'video/mp4';
    $webfm_mime_types['mpe'] = 'video/mpeg';
    $webfm_mime_types['mpeg'] = 'video/mpeg';
    $webfm_mime_types['mpg'] = 'video/mpeg';
    $webfm_mime_types['mpga'] = 'audio/mpeg';
    $webfm_mime_types['ms'] = 'application/x-troff-ms';
    $webfm_mime_types['msh'] = 'model/mesh';
    $webfm_mime_types['mxu'] = 'video/vnd.mpegurl';
    $webfm_mime_types['nc'] = 'application/x-netcdf';
    $webfm_mime_types['oda'] = 'application/oda';
    $webfm_mime_types['ogg'] = 'application/ogg';
    $webfm_mime_types['pbm'] = 'image/x-portable-bitmap';
    $webfm_mime_types['pct'] = 'image/pict';
    $webfm_mime_types['pdb'] = 'chemical/x-pdb';
    $webfm_mime_types['pdf'] = 'application/pdf';
    $webfm_mime_types['pgm'] = 'image/x-portable-graymap';
    $webfm_mime_types['pgn'] = 'application/x-chess-pgn';
    $webfm_mime_types['pic'] = 'image/pict';
    $webfm_mime_types['pict'] = 'image/pict';
    $webfm_mime_types['png'] = 'image/png';
    $webfm_mime_types['pnm'] = 'image/x-portable-anymap';
    $webfm_mime_types['pnt'] = 'image/x-macpaint';
    $webfm_mime_types['pntg'] = 'image/x-macpaint';
    $webfm_mime_types['ppm'] = 'image/x-portable-pixmap';
    $webfm_mime_types['ppt'] = 'application/vnd.ms-powerpoint';
    $webfm_mime_types['ps'] = 'application/postscript';
    $webfm_mime_types['qt'] = 'video/quicktime';
    $webfm_mime_types['qti'] = 'image/x-quicktime';
    $webfm_mime_types['qtif'] = 'image/x-quicktime';
    $webfm_mime_types['ra'] = 'audio/x-pn-realaudio';
    $webfm_mime_types['ram'] = 'audio/x-pn-realaudio';
    $webfm_mime_types['ras'] = 'image/x-cmu-raster';
    $webfm_mime_types['rdf'] = 'application/rdf+xml';
    $webfm_mime_types['rgb'] = 'image/x-rgb';
    $webfm_mime_types['rm'] = 'application/vnd.rn-realmedia';
    $webfm_mime_types['roff'] = 'application/x-troff';
    $webfm_mime_types['rtf'] = 'text/rtf';
    $webfm_mime_types['rtx'] = 'text/richtext';
    $webfm_mime_types['sgm'] = 'text/sgml';
    $webfm_mime_types['sgml'] = 'text/sgml';
    $webfm_mime_types['sh'] = 'application/x-sh';
    $webfm_mime_types['shar'] = 'application/x-shar';
    $webfm_mime_types['silo'] = 'model/mesh';
    $webfm_mime_types['sit'] = 'application/x-stuffit';
    $webfm_mime_types['skd'] = 'application/x-koan';
    $webfm_mime_types['skm'] = 'application/x-koan';
    $webfm_mime_types['skp'] = 'application/x-koan';
    $webfm_mime_types['skt'] = 'application/x-koan';
    $webfm_mime_types['smi'] = 'application/smil';
    $webfm_mime_types['smil'] = 'application/smil';
    $webfm_mime_types['snd'] = 'audio/basic';
    $webfm_mime_types['so'] = 'application/octet-stream';
    $webfm_mime_types['spl'] = 'application/x-futuresplash';
    $webfm_mime_types['src'] = 'application/x-wais-source';
    $webfm_mime_types['sv4cpio'] = 'application/x-sv4cpio';
    $webfm_mime_types['sv4crc'] = 'application/x-sv4crc';
    $webfm_mime_types['svg'] = 'image/svg+xml';
    $webfm_mime_types['swf'] = 'application/x-shockwave-flash';
    $webfm_mime_types['t'] = 'application/x-troff';
    $webfm_mime_types['tar'] = 'application/x-tar';
    $webfm_mime_types['tcl'] = 'application/x-tcl';
    $webfm_mime_types['tex'] = 'application/x-tex';
    $webfm_mime_types['texi'] = 'application/x-texinfo';
    $webfm_mime_types['texinfo'] = 'application/x-texinfo';
    $webfm_mime_types['tif'] = 'image/tiff';
    $webfm_mime_types['tiff'] = 'image/tiff';
    $webfm_mime_types['tr'] = 'application/x-troff';
    $webfm_mime_types['tsv'] = 'text/tab-separated-values';
    $webfm_mime_types['txt'] = 'text/plain';
    $webfm_mime_types['ustar'] = 'application/x-ustar';
    $webfm_mime_types['vcd'] = 'application/x-cdlink';
    $webfm_mime_types['vrml'] = 'model/vrml';
    $webfm_mime_types['vxml'] = 'application/voicexml+xml';
    $webfm_mime_types['wav'] = 'audio/x-wav';
    $webfm_mime_types['wbmp'] = 'image/vnd.wap.wbmp';
    $webfm_mime_types['wbmxl'] = 'application/vnd.wap.wbxml';
    $webfm_mime_types['wml'] = 'text/vnd.wap.wml';
    $webfm_mime_types['wmlc'] = 'application/vnd.wap.wmlc';
    $webfm_mime_types['wmls'] = 'text/vnd.wap.wmlscript';
    $webfm_mime_types['wmlsc'] = 'application/vnd.wap.wmlscriptc';
    $webfm_mime_types['wrl'] = 'model/vrml';
    $webfm_mime_types['xbm'] = 'image/x-xbitmap';
    $webfm_mime_types['xht'] = 'application/xhtml+xml';
    $webfm_mime_types['xhtml'] = 'application/xhtml+xml';
    $webfm_mime_types['xls'] = 'application/vnd.ms-excel';
    $webfm_mime_types['xml'] = 'application/xml';
    $webfm_mime_types['xpm'] = 'image/x-xpixmap';
    $webfm_mime_types['xsl'] = 'application/xml';
    $webfm_mime_types['xslt'] = 'application/xslt+xml';
    $webfm_mime_types['xul'] = 'application/vnd.mozilla.xul+xml';
    $webfm_mime_types['xwd'] = 'image/x-xwindowdump';
    $webfm_mime_types['xyz'] = 'chemical/x-xyz';
    $webfm_mime_types['zip'] = 'application/zip';
  }
  if (array_key_exists($ext, $webfm_mime_types)) {
    return $webfm_mime_types[$ext];
  }
  else {
    return 'application/octet-stream';
  }
}
function webfm_mime_content_type($filename) {
  $ext = array_pop(explode('.', $filename));
  return webfm_get_mime_type($ext);
}