pmpro_mimetype

Name: PHP MimeType Class.

Defined (1)

The class is defined in the following location(s).

/classes/class.mimetype.php  
  1. class pmpro_mimetype {  
  2. function getType($filename) {  
  3. // get base name of the filename provided by user  
  4. $filename = basename($filename);  
  5.  
  6. // break file into parts seperated by .  
  7. $filename = explode('.', $filename);  
  8.  
  9. // take the last part of the file to get the file extension  
  10. $filename = $filename[count($filename)-1];  
  11.  
  12. // find mime type  
  13. return $this->privFindType($filename);  
  14. }  
  15.  
  16. function privFindType($ext) {  
  17. // create mimetypes array  
  18. $mimetypes = $this->privBuildMimeArray();  
  19.  
  20. // return mime type for extension  
  21. if (isset($mimetypes[$ext])) {  
  22. return $mimetypes[$ext];  
  23. // if the extension wasn't found return octet-stream  
  24. } else {  
  25. return 'application/octet-stream';  
  26. }  
  27.  
  28. }  
  29.  
  30. function privBuildMimeArray() {  
  31. return array(  
  32. "ez" => "application/andrew-inset",  
  33. "hqx" => "application/mac-binhex40",  
  34. "cpt" => "application/mac-compactpro",  
  35. "doc" => "application/msword",  
  36. "bin" => "application/octet-stream",  
  37. "dms" => "application/octet-stream",  
  38. "lha" => "application/octet-stream",  
  39. "lzh" => "application/octet-stream",  
  40. "exe" => "application/octet-stream",  
  41. "class" => "application/octet-stream",  
  42. "so" => "application/octet-stream",  
  43. "dll" => "application/octet-stream",  
  44. "oda" => "application/oda",  
  45. "pdf" => "application/pdf",  
  46. "ai" => "application/postscript",  
  47. "eps" => "application/postscript",  
  48. "ps" => "application/postscript",  
  49. "smi" => "application/smil",  
  50. "smil" => "application/smil",  
  51. "wbxml" => "application/vnd.wap.wbxml",  
  52. "wmlc" => "application/vnd.wap.wmlc",  
  53. "wmlsc" => "application/vnd.wap.wmlscriptc",  
  54. "bcpio" => "application/x-bcpio",  
  55. "vcd" => "application/x-cdlink",  
  56. "pgn" => "application/x-chess-pgn",  
  57. "cpio" => "application/x-cpio",  
  58. "csh" => "application/x-csh",  
  59. "dcr" => "application/x-director",  
  60. "dir" => "application/x-director",  
  61. "dxr" => "application/x-director",  
  62. "dvi" => "application/x-dvi",  
  63. "spl" => "application/x-futuresplash",  
  64. "gtar" => "application/x-gtar",  
  65. "hdf" => "application/x-hdf",  
  66. "js" => "application/x-javascript",  
  67. "skp" => "application/x-koan",  
  68. "skd" => "application/x-koan",  
  69. "skt" => "application/x-koan",  
  70. "skm" => "application/x-koan",  
  71. "latex" => "application/x-latex",  
  72. "nc" => "application/x-netcdf",  
  73. "cdf" => "application/x-netcdf",  
  74. "sh" => "application/x-sh",  
  75. "shar" => "application/x-shar",  
  76. "swf" => "application/x-shockwave-flash",  
  77. "sit" => "application/x-stuffit",  
  78. "sv4cpio" => "application/x-sv4cpio",  
  79. "sv4crc" => "application/x-sv4crc",  
  80. "tar" => "application/x-tar",  
  81. "tcl" => "application/x-tcl",  
  82. "tex" => "application/x-tex",  
  83. "texinfo" => "application/x-texinfo",  
  84. "texi" => "application/x-texinfo",  
  85. "t" => "application/x-troff",  
  86. "tr" => "application/x-troff",  
  87. "roff" => "application/x-troff",  
  88. "man" => "application/x-troff-man",  
  89. "me" => "application/x-troff-me",  
  90. "ms" => "application/x-troff-ms",  
  91. "ustar" => "application/x-ustar",  
  92. "src" => "application/x-wais-source",  
  93. "xhtml" => "application/xhtml+xml",  
  94. "xht" => "application/xhtml+xml",  
  95. "zip" => "application/zip",  
  96. "au" => "audio/basic",  
  97. "snd" => "audio/basic",  
  98. "mid" => "audio/midi",  
  99. "midi" => "audio/midi",  
  100. "kar" => "audio/midi",  
  101. "mpga" => "audio/mpeg",  
  102. "mp2" => "audio/mpeg",  
  103. "mp3" => "audio/mpeg",  
  104. "aif" => "audio/x-aiff",  
  105. "aiff" => "audio/x-aiff",  
  106. "aifc" => "audio/x-aiff",  
  107. "m3u" => "audio/x-mpegurl",  
  108. "ram" => "audio/x-pn-realaudio",  
  109. "rm" => "audio/x-pn-realaudio",  
  110. "rpm" => "audio/x-pn-realaudio-plugin",  
  111. "ra" => "audio/x-realaudio",  
  112. "wav" => "audio/x-wav",  
  113. "pdb" => "chemical/x-pdb",  
  114. "xyz" => "chemical/x-xyz",  
  115. "bmp" => "image/bmp",  
  116. "gif" => "image/gif",  
  117. "ief" => "image/ief",  
  118. "jpeg" => "image/jpeg",  
  119. "jpg" => "image/jpeg",  
  120. "jpe" => "image/jpeg",  
  121. "png" => "image/png",  
  122. "tiff" => "image/tiff",  
  123. "tif" => "image/tif",  
  124. "djvu" => "image/vnd.djvu",  
  125. "djv" => "image/vnd.djvu",  
  126. "wbmp" => "image/vnd.wap.wbmp",  
  127. "ras" => "image/x-cmu-raster",  
  128. "pnm" => "image/x-portable-anymap",  
  129. "pbm" => "image/x-portable-bitmap",  
  130. "pgm" => "image/x-portable-graymap",  
  131. "ppm" => "image/x-portable-pixmap",  
  132. "rgb" => "image/x-rgb",  
  133. "xbm" => "image/x-xbitmap",  
  134. "xpm" => "image/x-xpixmap",  
  135. "xwd" => "image/x-windowdump",  
  136. "igs" => "model/iges",  
  137. "iges" => "model/iges",  
  138. "msh" => "model/mesh",  
  139. "mesh" => "model/mesh",  
  140. "silo" => "model/mesh",  
  141. "wrl" => "model/vrml",  
  142. "vrml" => "model/vrml",  
  143. "css" => "text/css",  
  144. "html" => "text/html",  
  145. "htm" => "text/html",  
  146. "asc" => "text/plain",  
  147. "txt" => "text/plain",  
  148. "rtx" => "text/richtext",  
  149. "rtf" => "text/rtf",  
  150. "sgml" => "text/sgml",  
  151. "sgm" => "text/sgml",  
  152. "tsv" => "text/tab-seperated-values",  
  153. "wml" => "text/vnd.wap.wml",  
  154. "wmls" => "text/vnd.wap.wmlscript",  
  155. "etx" => "text/x-setext",  
  156. "xml" => "text/xml",  
  157. "xsl" => "text/xml",  
  158. "mpeg" => "video/mpeg",  
  159. "mpg" => "video/mpeg",  
  160. "mpe" => "video/mpeg",  
  161. "qt" => "video/quicktime",  
  162. "mov" => "video/quicktime",  
  163. "mxu" => "video/vnd.mpegurl",  
  164. "avi" => "video/x-msvideo",  
  165. "movie" => "video/x-sgi-movie",  
  166. "ice" => "x-conference-xcooltalk"  
  167. );  
  168. }  
  169. }