MimeLib.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834
  1. <?php
  2. App::uses('CakeResponse', 'Network');
  3. /**
  4. * Wrapper to be able to read cake core's mime types as well as fix for missing ones
  5. *
  6. * @version 1.0
  7. * @license MIT
  8. * @author Mark Scherer
  9. */
  10. class MimeLib extends CakeResponse {
  11. protected $_mimeTypesExt = array(
  12. '3dm' => 'x-world/x-3dmf',
  13. '3dmf' => 'x-world/x-3dmf',
  14. 'a' => 'application/octet-stream',
  15. 'aab' => 'application/x-authorware-bin',
  16. 'aam' => 'application/x-authorware-map',
  17. 'aas' => 'application/x-authorware-seg',
  18. 'abc' => 'text/vnd.abc',
  19. 'acgi' => 'text/html',
  20. 'afl' => 'video/animaflex',
  21. 'ai' => 'application/postscript',
  22. 'aif' => 'audio/aiff',
  23. 'aif' => 'audio/x-aiff',
  24. 'aifc' => 'audio/aiff',
  25. 'aifc' => 'audio/x-aiff',
  26. 'aiff' => 'audio/aiff',
  27. 'aiff' => 'audio/x-aiff',
  28. 'aim' => 'application/x-aim',
  29. 'aip' => 'text/x-audiosoft-intra',
  30. 'ani' => 'application/x-navi-animation',
  31. 'aos' => 'application/x-nokia-9000-communicator-add-on-software',
  32. 'aps' => 'application/mime',
  33. 'arc' => 'application/octet-stream',
  34. 'arj' => 'application/arj',
  35. 'arj' => 'application/octet-stream',
  36. 'art' => 'image/x-jg',
  37. 'asf' => 'video/x-ms-asf',
  38. 'asm' => 'text/x-asm',
  39. 'asp' => 'text/asp',
  40. 'asx' => 'application/x-mplayer2',
  41. 'asx' => 'video/x-ms-asf',
  42. 'asx' => 'video/x-ms-asf-plugin',
  43. 'au' => 'audio/basic',
  44. 'au' => 'audio/x-au',
  45. 'avi' => 'application/x-troff-msvideo',
  46. 'avi' => 'video/avi',
  47. 'avi' => 'video/msvideo',
  48. 'avi' => 'video/x-msvideo',
  49. 'avs' => 'video/avs-video',
  50. 'bcpio' => 'application/x-bcpio',
  51. 'bin' => 'application/mac-binary',
  52. 'bin' => 'application/macbinary',
  53. 'bin' => 'application/octet-stream',
  54. 'bin' => 'application/x-binary',
  55. 'bin' => 'application/x-macbinary',
  56. 'bm' => 'image/bmp',
  57. 'bmp' => 'image/bmp',
  58. 'bmp' => 'image/x-windows-bmp',
  59. 'boo' => 'application/book',
  60. 'book' => 'application/book',
  61. 'boz' => 'application/x-bzip2',
  62. 'bsh' => 'application/x-bsh',
  63. 'bz' => 'application/x-bzip',
  64. 'bz2' => 'application/x-bzip2',
  65. 'c' => 'text/plain',
  66. 'c' => 'text/x-c',
  67. 'c++' => 'text/plain',
  68. 'cat' => 'application/vnd.ms-pki.seccat',
  69. 'cc' => 'text/plain',
  70. 'cc' => 'text/x-c',
  71. 'ccad' => 'application/clariscad',
  72. 'cco' => 'application/x-cocoa',
  73. 'cdf' => 'application/cdf',
  74. 'cdf' => 'application/x-cdf',
  75. 'cdf' => 'application/x-netcdf',
  76. 'cer' => 'application/pkix-cert',
  77. 'cer' => 'application/x-x509-ca-cert',
  78. 'cha' => 'application/x-chat',
  79. 'chat' => 'application/x-chat',
  80. 'class' => 'application/java',
  81. 'class' => 'application/java-byte-code',
  82. 'class' => 'application/x-java-class',
  83. 'com' => 'application/octet-stream',
  84. 'com' => 'text/plain',
  85. 'conf' => 'text/plain',
  86. 'cpio' => 'application/x-cpio',
  87. 'cpp' => 'text/x-c',
  88. 'cpt' => 'application/mac-compactpro',
  89. 'cpt' => 'application/x-compactpro',
  90. 'cpt' => 'application/x-cpt',
  91. 'crl' => 'application/pkcs-crl',
  92. 'crl' => 'application/pkix-crl',
  93. 'crt' => 'application/pkix-cert',
  94. 'crt' => 'application/x-x509-ca-cert',
  95. 'crt' => 'application/x-x509-user-cert',
  96. 'csh' => 'application/x-csh',
  97. 'csh' => 'text/x-script.csh',
  98. 'css' => 'application/x-pointplus',
  99. 'css' => 'text/css',
  100. 'cxx' => 'text/plain',
  101. 'dcr' => 'application/x-director',
  102. 'deepv' => 'application/x-deepv',
  103. 'def' => 'text/plain',
  104. 'der' => 'application/x-x509-ca-cert',
  105. 'dif' => 'video/x-dv',
  106. 'dir' => 'application/x-director',
  107. 'dl' => 'video/dl',
  108. 'dl' => 'video/x-dl',
  109. 'doc' => 'application/msword',
  110. 'dot' => 'application/msword',
  111. 'dp' => 'application/commonground',
  112. 'drw' => 'application/drafting',
  113. 'dump' => 'application/octet-stream',
  114. 'dv' => 'video/x-dv',
  115. 'dvi' => 'application/x-dvi',
  116. 'dwf' => 'model/vnd.dwf',
  117. 'dwg' => 'application/acad',
  118. 'dwg' => 'image/vnd.dwg',
  119. 'dwg' => 'image/x-dwg',
  120. 'dxf' => 'application/dxf',
  121. 'dxf' => 'image/vnd.dwg',
  122. 'dxf' => 'image/x-dwg',
  123. 'dxr' => 'application/x-director',
  124. 'el' => 'text/x-script.elisp',
  125. 'elc' => 'application/x-bytecode.elisp',
  126. 'elc' => 'application/x-elc',
  127. 'env' => 'application/x-envoy',
  128. 'eps' => 'application/postscript',
  129. 'es' => 'application/x-esrehber',
  130. 'etx' => 'text/x-setext',
  131. 'evy' => 'application/envoy',
  132. 'evy' => 'application/x-envoy',
  133. 'exe' => 'application/octet-stream',
  134. 'f' => 'text/plain',
  135. 'f' => 'text/x-fortran',
  136. 'f77' => 'text/x-fortran',
  137. 'f90' => 'text/plain',
  138. 'f90' => 'text/x-fortran',
  139. 'fdf' => 'application/vnd.fdf',
  140. 'fif' => 'application/fractals',
  141. 'fif' => 'image/fif',
  142. 'fli' => 'video/fli',
  143. 'fli' => 'video/x-fli',
  144. 'flo' => 'image/florian',
  145. 'flx' => 'text/vnd.fmi.flexstor',
  146. 'fmf' => 'video/x-atomic3d-feature',
  147. 'for' => 'text/plain',
  148. 'for' => 'text/x-fortran',
  149. 'fpx' => 'image/vnd.fpx',
  150. 'fpx' => 'image/vnd.net-fpx',
  151. 'frl' => 'application/freeloader',
  152. 'funk' => 'audio/make',
  153. 'g' => 'text/plain',
  154. 'g3' => 'image/g3fax',
  155. 'gif' => 'image/gif',
  156. 'gl' => 'video/gl',
  157. 'gl' => 'video/x-gl',
  158. 'gsd' => 'audio/x-gsm',
  159. 'gsm' => 'audio/x-gsm',
  160. 'gsp' => 'application/x-gsp',
  161. 'gss' => 'application/x-gss',
  162. 'gtar' => 'application/x-gtar',
  163. 'gz' => 'application/x-compressed',
  164. 'gz' => 'application/x-gzip',
  165. 'gzip' => 'application/x-gzip',
  166. 'gzip' => 'multipart/x-gzip',
  167. 'h' => 'text/plain',
  168. 'h' => 'text/x-h',
  169. 'hdf' => 'application/x-hdf',
  170. 'help' => 'application/x-helpfile',
  171. 'hgl' => 'application/vnd.hp-hpgl',
  172. 'hh' => 'text/plain',
  173. 'hh' => 'text/x-h',
  174. 'hlb' => 'text/x-script',
  175. 'hlp' => 'application/hlp',
  176. 'hlp' => 'application/x-helpfile',
  177. 'hlp' => 'application/x-winhelp',
  178. 'hpg' => 'application/vnd.hp-hpgl',
  179. 'hpgl' => 'application/vnd.hp-hpgl',
  180. 'hqx' => 'application/binhex',
  181. 'hqx' => 'application/binhex4',
  182. 'hqx' => 'application/mac-binhex',
  183. 'hqx' => 'application/mac-binhex40',
  184. 'hqx' => 'application/x-binhex40',
  185. 'hqx' => 'application/x-mac-binhex40',
  186. 'hta' => 'application/hta',
  187. 'htc' => 'text/x-component',
  188. 'htm' => 'text/html',
  189. 'html' => 'text/html',
  190. 'htmls' => 'text/html',
  191. 'htt' => 'text/webviewhtml',
  192. 'htx' => 'text/html',
  193. 'ice' => 'x-conference/x-cooltalk',
  194. 'ico' => 'image/x-icon',
  195. 'ics' => 'text/calendar',
  196. 'ical' => 'text/calendar',
  197. 'idc' => 'text/plain',
  198. 'ief' => 'image/ief',
  199. 'iefs' => 'image/ief',
  200. 'ifb' => 'text/calendar',
  201. 'iges' => 'application/iges',
  202. 'iges' => 'model/iges',
  203. 'igs' => 'application/iges',
  204. 'igs' => 'model/iges',
  205. 'ima' => 'application/x-ima',
  206. 'imap' => 'application/x-httpd-imap',
  207. 'inf' => 'application/inf',
  208. 'ins' => 'application/x-internett-signup',
  209. 'ip' => 'application/x-ip2',
  210. 'isu' => 'video/x-isvideo',
  211. 'it' => 'audio/it',
  212. 'iv' => 'application/x-inventor',
  213. 'ivr' => 'i-world/i-vrml',
  214. 'ivy' => 'application/x-livescreen',
  215. 'jam' => 'audio/x-jam',
  216. 'jav' => 'text/plain',
  217. 'jav' => 'text/x-java-source',
  218. 'java' => 'text/plain',
  219. 'java' => 'text/x-java-source',
  220. 'jcm' => 'application/x-java-commerce',
  221. 'jfif' => 'image/jpeg',
  222. 'jfif' => 'image/pjpeg',
  223. 'jfif-tbnl' => 'image/jpeg',
  224. 'jpe' => 'image/jpeg',
  225. 'jpe' => 'image/pjpeg',
  226. 'jpeg' => 'image/jpeg',
  227. 'jpeg' => 'image/pjpeg',
  228. 'jpg' => 'image/jpeg',
  229. 'jpg' => 'image/pjpeg',
  230. 'jps' => 'image/x-jps',
  231. 'js' => 'text/javascript',
  232. 'jut' => 'image/jutvision',
  233. 'kar' => 'audio/midi',
  234. 'kar' => 'music/x-karaoke',
  235. 'ksh' => 'application/x-ksh',
  236. 'ksh' => 'text/x-script.ksh',
  237. 'la' => 'audio/nspaudio',
  238. 'la' => 'audio/x-nspaudio',
  239. 'lam' => 'audio/x-liveaudio',
  240. 'latex' => 'application/x-latex',
  241. 'lha' => 'application/lha',
  242. 'lha' => 'application/octet-stream',
  243. 'lha' => 'application/x-lha',
  244. 'lhx' => 'application/octet-stream',
  245. 'list' => 'text/plain',
  246. 'lma' => 'audio/nspaudio',
  247. 'lma' => 'audio/x-nspaudio',
  248. 'log' => 'text/plain',
  249. 'lsp' => 'application/x-lisp',
  250. 'lsp' => 'text/x-script.lisp',
  251. 'lst' => 'text/plain',
  252. 'lsx' => 'text/x-la-asf',
  253. 'ltx' => 'application/x-latex',
  254. 'lzh' => 'application/octet-stream',
  255. 'lzh' => 'application/x-lzh',
  256. 'lzx' => 'application/lzx',
  257. 'lzx' => 'application/octet-stream',
  258. 'lzx' => 'application/x-lzx',
  259. 'm' => 'text/plain',
  260. 'm' => 'text/x-m',
  261. 'm1v' => 'video/mpeg',
  262. 'm2a' => 'audio/mpeg',
  263. 'm2v' => 'video/mpeg',
  264. 'm3u' => 'audio/x-mpequrl',
  265. 'man' => 'application/x-troff-man',
  266. 'map' => 'application/x-navimap',
  267. 'mar' => 'text/plain',
  268. 'mbd' => 'application/mbedlet',
  269. 'mc$' => 'application/x-magic-cap-package-1.0',
  270. 'mcd' => 'application/mcad',
  271. 'mcd' => 'application/x-mathcad',
  272. 'mcf' => 'image/vasa',
  273. 'mcf' => 'text/mcf',
  274. 'mcp' => 'application/netmc',
  275. 'me' => 'application/x-troff-me',
  276. 'mht' => 'message/rfc822',
  277. 'mhtml' => 'message/rfc822',
  278. 'mid' => 'application/x-midi',
  279. 'mid' => 'audio/midi',
  280. 'mid' => 'audio/x-mid',
  281. 'mid' => 'audio/x-midi',
  282. 'mid' => 'music/crescendo',
  283. 'mid' => 'x-music/x-midi',
  284. 'midi' => 'application/x-midi',
  285. 'midi' => 'audio/midi',
  286. 'midi' => 'audio/x-mid',
  287. 'midi' => 'audio/x-midi',
  288. 'midi' => 'music/crescendo',
  289. 'midi' => 'x-music/x-midi',
  290. 'mif' => 'application/x-frame',
  291. 'mif' => 'application/x-mif',
  292. 'mime' => 'message/rfc822',
  293. 'mime' => 'www/mime',
  294. 'mjf' => 'audio/x-vnd.audioexplosion.mjuicemediafile',
  295. 'mjpg' => 'video/x-motion-jpeg',
  296. 'mm' => 'application/base64',
  297. 'mm' => 'application/x-meme',
  298. 'mme' => 'application/base64',
  299. 'mod' => 'audio/mod',
  300. 'mod' => 'audio/x-mod',
  301. 'moov' => 'video/quicktime',
  302. 'mov' => 'video/quicktime',
  303. 'movie' => 'video/x-sgi-movie',
  304. 'mp2' => 'audio/mpeg',
  305. 'mp2' => 'audio/x-mpeg',
  306. 'mp2' => 'video/mpeg',
  307. 'mp2' => 'video/x-mpeg',
  308. 'mp2' => 'video/x-mpeq2a',
  309. 'mp3' => 'audio/mpeg3',
  310. 'mp3' => 'audio/x-mpeg-3',
  311. 'mp3' => 'video/mpeg',
  312. 'mp3' => 'video/x-mpeg',
  313. 'mpa' => 'audio/mpeg',
  314. 'mpa' => 'video/mpeg',
  315. 'mpc' => 'application/x-project',
  316. 'mpe' => 'video/mpeg',
  317. 'mpeg' => 'video/mpeg',
  318. 'mpg' => 'audio/mpeg',
  319. 'mpg' => 'video/mpeg',
  320. 'mpga' => 'audio/mpeg',
  321. 'mpp' => 'application/vnd.ms-project',
  322. 'mpt' => 'application/x-project',
  323. 'mpv' => 'application/x-project',
  324. 'mpx' => 'application/x-project',
  325. 'mrc' => 'application/marc',
  326. 'ms' => 'application/x-troff-ms',
  327. 'mv' => 'video/x-sgi-movie',
  328. 'my' => 'audio/make',
  329. 'mzz' => 'application/x-vnd.audioexplosion.mzz',
  330. 'nap' => 'image/naplps',
  331. 'naplps' => 'image/naplps',
  332. 'nc' => 'application/x-netcdf',
  333. 'ncm' => 'application/vnd.nokia.configuration-message',
  334. 'nif' => 'image/x-niff',
  335. 'niff' => 'image/x-niff',
  336. 'nix' => 'application/x-mix-transfer',
  337. 'nsc' => 'application/x-conference',
  338. 'nvd' => 'application/x-navidoc',
  339. 'o' => 'application/octet-stream',
  340. 'oda' => 'application/oda',
  341. 'omc' => 'application/x-omc',
  342. 'omcd' => 'application/x-omcdatamaker',
  343. 'omcr' => 'application/x-omcregerator',
  344. 'p' => 'text/x-pascal',
  345. 'p10' => 'application/pkcs10',
  346. 'p10' => 'application/x-pkcs10',
  347. 'p12' => 'application/pkcs-12',
  348. 'p12' => 'application/x-pkcs12',
  349. 'p7a' => 'application/x-pkcs7-signature',
  350. 'p7c' => 'application/pkcs7-mime',
  351. 'p7c' => 'application/x-pkcs7-mime',
  352. 'p7m' => 'application/pkcs7-mime',
  353. 'p7m' => 'application/x-pkcs7-mime',
  354. 'p7r' => 'application/x-pkcs7-certreqresp',
  355. 'p7s' => 'application/pkcs7-signature',
  356. 'part' => 'application/pro_eng',
  357. 'pas' => 'text/pascal',
  358. 'pbm' => 'image/x-portable-bitmap',
  359. 'pcl' => 'application/vnd.hp-pcl',
  360. 'pcl' => 'application/x-pcl',
  361. 'pct' => 'image/x-pict',
  362. 'pcx' => 'image/x-pcx',
  363. 'pdb' => 'chemical/x-pdb',
  364. 'pdf' => 'application/pdf',
  365. 'pfunk' => 'audio/make',
  366. 'pfunk' => 'audio/make.my.funk',
  367. 'pgm' => 'image/x-portable-graymap',
  368. 'pgm' => 'image/x-portable-greymap',
  369. 'pic' => 'image/pict',
  370. 'pict' => 'image/pict',
  371. 'pkg' => 'application/x-newton-compatible-pkg',
  372. 'pko' => 'application/vnd.ms-pki.pko',
  373. 'pl' => 'text/plain',
  374. 'pl' => 'text/x-script.perl',
  375. 'plx' => 'application/x-pixclscript',
  376. 'pm' => 'image/x-xpixmap',
  377. 'pm' => 'text/x-script.perl-module',
  378. 'pm4' => 'application/x-pagemaker',
  379. 'pm5' => 'application/x-pagemaker',
  380. 'png' => 'image/png',
  381. 'pnm' => 'application/x-portable-anymap',
  382. 'pnm' => 'image/x-portable-anymap',
  383. 'pot' => 'application/mspowerpoint',
  384. 'pot' => 'application/vnd.ms-powerpoint',
  385. 'pov' => 'model/x-pov',
  386. 'ppa' => 'application/vnd.ms-powerpoint',
  387. 'ppm' => 'image/x-portable-pixmap',
  388. 'pps' => 'application/mspowerpoint',
  389. 'pps' => 'application/vnd.ms-powerpoint',
  390. 'ppt' => 'application/mspowerpoint',
  391. 'ppt' => 'application/powerpoint',
  392. 'ppt' => 'application/vnd.ms-powerpoint',
  393. 'ppt' => 'application/x-mspowerpoint',
  394. 'ppz' => 'application/mspowerpoint',
  395. 'pre' => 'application/x-freelance',
  396. 'prt' => 'application/pro_eng',
  397. 'ps' => 'application/postscript',
  398. 'psd' => 'application/octet-stream',
  399. 'pvu' => 'paleovu/x-pv',
  400. 'pwz' => 'application/vnd.ms-powerpoint',
  401. 'py' => 'text/x-script.phyton',
  402. 'pyc' => 'applicaiton/x-bytecode.python',
  403. 'qcp' => 'audio/vnd.qcelp',
  404. 'qd3' => 'x-world/x-3dmf',
  405. 'qd3d' => 'x-world/x-3dmf',
  406. 'qif' => 'image/x-quicktime',
  407. 'qt' => 'video/quicktime',
  408. 'qtc' => 'video/x-qtc',
  409. 'qti' => 'image/x-quicktime',
  410. 'qtif' => 'image/x-quicktime',
  411. 'ra' => 'audio/x-pn-realaudio',
  412. 'ra' => 'audio/x-pn-realaudio-plugin',
  413. 'ra' => 'audio/x-realaudio',
  414. 'ram' => 'audio/x-pn-realaudio',
  415. 'ras' => 'application/x-cmu-raster',
  416. 'ras' => 'image/cmu-raster',
  417. 'ras' => 'image/x-cmu-raster',
  418. 'rast' => 'image/cmu-raster',
  419. 'rexx' => 'text/x-script.rexx',
  420. 'rf' => 'image/vnd.rn-realflash',
  421. 'rgb' => 'image/x-rgb',
  422. 'rm' => 'application/vnd.rn-realmedia',
  423. 'rm' => 'audio/x-pn-realaudio',
  424. 'rmi' => 'audio/mid',
  425. 'rmm' => 'audio/x-pn-realaudio',
  426. 'rmp' => 'audio/x-pn-realaudio',
  427. 'rmp' => 'audio/x-pn-realaudio-plugin',
  428. 'rng' => 'application/ringing-tones',
  429. 'rng' => 'application/vnd.nokia.ringing-tone',
  430. 'rnx' => 'application/vnd.rn-realplayer',
  431. 'roff' => 'application/x-troff',
  432. 'rp' => 'image/vnd.rn-realpix',
  433. 'rpm' => 'audio/x-pn-realaudio-plugin',
  434. 'rt' => 'text/richtext',
  435. 'rt' => 'text/vnd.rn-realtext',
  436. 'rtf' => 'application/rtf',
  437. 'rtf' => 'application/x-rtf',
  438. 'rtf' => 'text/richtext',
  439. 'rtx' => 'application/rtf',
  440. 'rtx' => 'text/richtext',
  441. 'rv' => 'video/vnd.rn-realvideo',
  442. 's' => 'text/x-asm',
  443. 's3m' => 'audio/s3m',
  444. 'saveme' => 'application/octet-stream',
  445. 'sbk' => 'application/x-tbook',
  446. 'scm' => 'application/x-lotusscreencam',
  447. 'scm' => 'text/x-script.guile',
  448. 'scm' => 'text/x-script.scheme',
  449. 'scm' => 'video/x-scm',
  450. 'sdml' => 'text/plain',
  451. 'sdp' => 'application/sdp',
  452. 'sdp' => 'application/x-sdp',
  453. 'sdr' => 'application/sounder',
  454. 'sea' => 'application/sea',
  455. 'sea' => 'application/x-sea',
  456. 'set' => 'application/set',
  457. 'sgm' => 'text/sgml',
  458. 'sgm' => 'text/x-sgml',
  459. 'sgml' => 'text/sgml',
  460. 'sgml' => 'text/x-sgml',
  461. 'sh' => 'application/x-bsh',
  462. 'sh' => 'application/x-sh',
  463. 'sh' => 'application/x-shar',
  464. 'sh' => 'text/x-script.sh',
  465. 'shar' => 'application/x-bsh',
  466. 'shar' => 'application/x-shar',
  467. 'shtml' => 'text/html',
  468. 'sid' => 'audio/x-psid',
  469. 'sit' => 'application/x-sit',
  470. 'sit' => 'application/x-stuffit',
  471. 'skd' => 'application/x-koan',
  472. 'skm' => 'application/x-koan',
  473. 'skp' => 'application/x-koan',
  474. 'skt' => 'application/x-koan',
  475. 'sl' => 'application/x-seelogo',
  476. 'smi' => 'application/smil',
  477. 'smil' => 'application/smil',
  478. 'snd' => 'audio/basic',
  479. 'snd' => 'audio/x-adpcm',
  480. 'sol' => 'application/solids',
  481. 'spc' => 'application/x-pkcs7-certificates',
  482. 'spc' => 'text/x-speech',
  483. 'spl' => 'application/futuresplash',
  484. 'spr' => 'application/x-sprite',
  485. 'sprite' => 'application/x-sprite',
  486. 'src' => 'application/x-wais-source',
  487. 'ssi' => 'text/x-server-parsed-html',
  488. 'ssm' => 'application/streamingmedia',
  489. 'sst' => 'application/vnd.ms-pki.certstore',
  490. 'step' => 'application/step',
  491. 'stl' => 'application/sla',
  492. 'stl' => 'application/vnd.ms-pki.stl',
  493. 'stl' => 'application/x-navistyle',
  494. 'stp' => 'application/step',
  495. 'sv4cpio'=> 'application/x-sv4cpio',
  496. 'sv4crc' => 'application/x-sv4crc',
  497. 'svf' => 'image/vnd.dwg',
  498. 'svf' => 'image/x-dwg',
  499. 'svr' => 'application/x-world',
  500. 'svr' => 'x-world/x-svr',
  501. 'swf' => 'application/x-shockwave-flash',
  502. 't' => 'application/x-troff',
  503. 'talk' => 'text/x-speech',
  504. 'tar' => 'application/x-tar',
  505. 'tbk' => 'application/toolbook',
  506. 'tbk' => 'application/x-tbook',
  507. 'tcl' => 'application/x-tcl',
  508. 'tcl' => 'text/x-script.tcl',
  509. 'tcsh' => 'text/x-script.tcsh',
  510. 'tex' => 'application/x-tex',
  511. 'texi' => 'application/x-texinfo',
  512. 'texinfo'=> 'application/x-texinfo',
  513. 'text' => 'application/plain',
  514. 'text' => 'text/plain',
  515. 'tgz' => 'application/gnutar',
  516. 'tgz' => 'application/x-compressed',
  517. 'tif' => 'image/tiff',
  518. 'tif' => 'image/x-tiff',
  519. 'tiff' => 'image/tiff',
  520. 'tiff' => 'image/x-tiff',
  521. 'tr' => 'application/x-troff',
  522. 'tsi' => 'audio/tsp-audio',
  523. 'tsp' => 'application/dsptype',
  524. 'tsp' => 'audio/tsplayer',
  525. 'tsv' => 'text/tab-separated-values',
  526. 'turbot' => 'image/florian',
  527. 'txt' => 'text/plain',
  528. 'uil' => 'text/x-uil',
  529. 'uni' => 'text/uri-list',
  530. 'unis' => 'text/uri-list',
  531. 'unv' => 'application/i-deas',
  532. 'uri' => 'text/uri-list',
  533. 'uris' => 'text/uri-list',
  534. 'ustar' => 'application/x-ustar',
  535. 'ustar' => 'multipart/x-ustar',
  536. 'uu' => 'application/octet-stream',
  537. 'uu' => 'text/x-uuencode',
  538. 'uue' => 'text/x-uuencode',
  539. 'vcd' => 'application/x-cdlink',
  540. 'vcs' => 'text/x-vcalendar',
  541. 'vda' => 'application/vda',
  542. 'vdo' => 'video/vdo',
  543. 'vew' => 'application/groupwise',
  544. 'viv' => 'video/vivo',
  545. 'viv' => 'video/vnd.vivo',
  546. 'vivo' => 'video/vivo',
  547. 'vivo' => 'video/vnd.vivo',
  548. 'vmd' => 'application/vocaltec-media-desc',
  549. 'vmf' => 'application/vocaltec-media-file',
  550. 'voc' => 'audio/voc',
  551. 'voc' => 'audio/x-voc',
  552. 'vos' => 'video/vosaic',
  553. 'vox' => 'audio/voxware',
  554. 'vqe' => 'audio/x-twinvq-plugin',
  555. 'vqf' => 'audio/x-twinvq',
  556. 'vql' => 'audio/x-twinvq-plugin',
  557. 'vrml' => 'application/x-vrml',
  558. 'vrml' => 'model/vrml',
  559. 'vrml' => 'x-world/x-vrml',
  560. 'vrt' => 'x-world/x-vrt',
  561. 'vsd' => 'application/x-visio',
  562. 'vst' => 'application/x-visio',
  563. 'vsw' => 'application/x-visio',
  564. 'w60' => 'application/wordperfect6.0',
  565. 'w61' => 'application/wordperfect6.1',
  566. 'w6w' => 'application/msword',
  567. 'wav' => 'audio/wav',
  568. 'wav' => 'audio/x-wav',
  569. 'wb1' => 'application/x-qpro',
  570. 'wbmp' => 'image/vnd.wap.wbmp',
  571. 'web' => 'application/vnd.xara',
  572. 'wiz' => 'application/msword',
  573. 'wk1' => 'application/x-123',
  574. 'wmf' => 'windows/metafile',
  575. 'wml' => 'text/vnd.wap.wml',
  576. 'wmlc' => 'application/vnd.wap.wmlc',
  577. 'wmls' => 'text/vnd.wap.wmlscript',
  578. 'wmlsc' => 'application/vnd.wap.wmlscriptc',
  579. 'word' => 'application/msword',
  580. 'wp' => 'application/wordperfect',
  581. 'wp5' => 'application/wordperfect',
  582. 'wp5' => 'application/wordperfect6.0',
  583. 'wp6' => 'application/wordperfect',
  584. 'wpd' => 'application/wordperfect',
  585. 'wpd' => 'application/x-wpwin',
  586. 'wq1' => 'application/x-lotus',
  587. 'wri' => 'application/mswrite',
  588. 'wri' => 'application/x-wri',
  589. 'wrl' => 'application/x-world',
  590. 'wrl' => 'model/vrml',
  591. 'wrl' => 'x-world/x-vrml',
  592. 'wrz' => 'model/vrml',
  593. 'wrz' => 'x-world/x-vrml',
  594. 'wsc' => 'text/scriplet',
  595. 'wsrc' => 'application/x-wais-source',
  596. 'wtk' => 'application/x-wintalk',
  597. 'xbm' => 'image/x-xbitmap',
  598. 'xbm' => 'image/x-xbm',
  599. 'xbm' => 'image/xbm',
  600. 'xdr' => 'video/x-amt-demorun',
  601. 'xgz' => 'xgl/drawing',
  602. 'xif' => 'image/vnd.xiff',
  603. 'xl' => 'application/excel',
  604. 'xla' => 'application/excel',
  605. 'xla' => 'application/x-excel',
  606. 'xla' => 'application/x-msexcel',
  607. 'xlb' => 'application/excel',
  608. 'xlb' => 'application/vnd.ms-excel',
  609. 'xlb' => 'application/x-excel',
  610. 'xlc' => 'application/excel',
  611. 'xlc' => 'application/vnd.ms-excel',
  612. 'xlc' => 'application/x-excel',
  613. 'xld' => 'application/excel',
  614. 'xld' => 'application/x-excel',
  615. 'xlk' => 'application/excel',
  616. 'xlk' => 'application/x-excel',
  617. 'xll' => 'application/excel',
  618. 'xll' => 'application/vnd.ms-excel',
  619. 'xll' => 'application/x-excel',
  620. 'xlm' => 'application/excel',
  621. 'xlm' => 'application/vnd.ms-excel',
  622. 'xlm' => 'application/x-excel',
  623. 'xls' => 'application/excel',
  624. 'xls' => 'application/vnd.ms-excel',
  625. 'xls' => 'application/x-excel',
  626. 'xls' => 'application/x-msexcel',
  627. 'xlt' => 'application/excel',
  628. 'xlt' => 'application/x-excel',
  629. 'xlv' => 'application/excel',
  630. 'xlv' => 'application/x-excel',
  631. 'xlw' => 'application/excel',
  632. 'xlw' => 'application/vnd.ms-excel',
  633. 'xlw' => 'application/x-excel',
  634. 'xlw' => 'application/x-msexcel',
  635. 'xm' => 'audio/xm',
  636. 'xml' => 'application/xml',
  637. 'xml' => 'text/xml',
  638. 'xmz' => 'xgl/movie',
  639. 'xpix' => 'application/x-vnd.ls-xpix',
  640. 'xpm' => 'image/x-xpixmap',
  641. 'xpm' => 'image/xpm',
  642. 'x-png' => 'image/png',
  643. 'xsr' => 'video/x-amt-showrun',
  644. 'xwd' => 'image/x-xwd',
  645. 'xwd' => 'image/x-xwindowdump',
  646. 'xyz' => 'chemical/x-pdb',
  647. 'z' => array('application/x-compress', 'application/x-compressed'),
  648. 'zip' => 'application/x-compressed',
  649. 'zip' => 'application/x-zip-compressed',
  650. 'zip' => 'application/zip',
  651. 'zip' => 'multipart/x-zip',
  652. 'zoo' => 'application/octet-stream',
  653. 'zsh' => 'text/x-script.zsh',
  654. 'txt' => 'text/plain',
  655. 'htm' => 'text/html',
  656. 'html' => 'text/html',
  657. 'php' => 'application/x-httpd-php',
  658. 'phps' => 'application/x-httpd-phps',
  659. 'css' => 'text/css',
  660. 'js' => 'application/javascript',
  661. 'json' => 'application/json',
  662. 'xml' => 'application/xml',
  663. 'swf' => 'application/x-shockwave-flash',
  664. 'flv' => 'video/x-flv',
  665. 'asc' => 'text/plain',
  666. 'atom' => 'application/atom+xml',
  667. 'bcpio' => 'application/x-bcpio',
  668. 'png' => 'image/png',
  669. 'jpe' => 'image/jpeg',
  670. 'jpeg' => 'image/jpeg',
  671. 'jpg' => 'image/jpeg',
  672. 'gif' => 'image/gif',
  673. 'bmp' => 'image/bmp',
  674. 'ico' => 'image/vnd.microsoft.icon',
  675. 'tiff' => 'image/tiff',
  676. 'tif' => 'image/tiff',
  677. 'svg' => 'image/svg+xml',
  678. 'svgz' => 'image/svg+xml',
  679. 'zip' => 'application/zip',
  680. 'rar' => 'application/x-rar-compressed',
  681. 'exe' => 'application/x-msdownload',
  682. 'msi' => 'application/x-msdownload',
  683. 'cab' => 'application/vnd.ms-cab-compressed',
  684. 'mp3' => 'audio/mpeg',
  685. 'qt' => 'video/quicktime',
  686. 'mov' => 'video/quicktime',
  687. 'au' => 'audio/basic',
  688. 'avi' => 'video/x-msvideo',
  689. 'pdf' => 'application/pdf',
  690. 'psd' => 'image/vnd.adobe.photoshop',
  691. 'ai' => 'application/postscript',
  692. 'eps' => 'application/postscript',
  693. 'ps' => 'application/postscript',
  694. 'aif' => 'audio/x-aiff',
  695. 'aifc' => 'audio/x-aiff',
  696. 'aiff' => 'audio/x-aiff',
  697. 'doc' => 'application/msword',
  698. 'rtf' => 'application/rtf',
  699. 'xls' => 'application/vnd.ms-excel',
  700. 'ppt' => 'application/vnd.ms-powerpoint',
  701. 'odt' => 'application/vnd.oasis.opendocument.text',
  702. 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
  703. 'swf' => array('application/x-shockwave-flash', 'application/x-shockwave-flash2-preview', 'application/futuresplash', 'image/vnd.rn-realflash')
  704. );
  705. /**
  706. * override constructor
  707. * 2012-02-12 ms
  708. */
  709. public function __construct() {
  710. }
  711. /**
  712. * get all mime types that are supported by cake php core right now
  713. * @return array
  714. * 2012-02-12 ms
  715. */
  716. public function getMimeTypes($coreOnly = false) {
  717. if ($coreOnly) {
  718. return $this->_mimeTypes;
  719. }
  720. return array_merge($this->_mimeTypesExt, $this->_mimeTypes);
  721. }
  722. /**
  723. * Returns the mime type definition for an alias
  724. *
  725. * e.g `getMimeType('pdf'); // returns 'application/pdf'`
  726. *
  727. * @param string $alias the content type alias to map
  728. * @return mixed string mapped mime type or false if $alias is not mapped
  729. */
  730. public function getMimeType($alias, $coreOnly = false) {
  731. $res = parent::getMimeType($alias);
  732. if ($res === false && !$coreOnly && isset($this->_mimeTypesExt[$alias])) {
  733. return $this->_mimeTypesExt[$alias];
  734. }
  735. return $res;
  736. }
  737. /**
  738. * Maps a content-type back to an alias
  739. *
  740. * e.g `mapType('application/pdf'); // returns 'pdf'`
  741. *
  742. * @param mixed $ctype Either a string content type to map, or an array of types.
  743. * @return mixed Aliases for the types provided.
  744. */
  745. public function mapType($ctype) {
  746. return parent::mapType($ctype);
  747. }
  748. /**
  749. * @desc Retrieve the corresponding MIME type, if one exists
  750. * @param String $file File Name (relative location such as "image_test.jpg" or full "http://site.com/path/to/image_test.jpg")
  751. * @return String $MIMEType - The type of the file passed in the argument
  752. */
  753. public function extractMimeType($file = NULL) {
  754. if (is_file($file)) {
  755. /**
  756. * Attempts to retrieve file info from FINFO
  757. * If FINFO functions are not available then try to retrieve MIME type from pre-defined MIMEs
  758. * If MIME type doesn't exist, then try (as a last resort) to use the (deprecated) mime_content_type function
  759. * If all else fails, just return application/octet-stream
  760. */
  761. if (!function_exists("finfo_open")) {
  762. if (function_exists("mime_content_type")) {
  763. $type = mime_content_type($file);
  764. if (!empty($type)) {
  765. return $type;
  766. }
  767. }
  768. $extension = $this->_getExtension($file);
  769. if ($mimeType = $this->getMimeType($extension)) {
  770. return $mimeType;
  771. } else {
  772. return "application/octet-stream";
  773. }
  774. } else {
  775. $finfo = finfo_open(FILEINFO_MIME_TYPE);
  776. $mimeType = finfo_file($finfo, $file);
  777. finfo_close($finfo);
  778. return $mimeType;
  779. }
  780. }
  781. return false;
  782. }
  783. /**
  784. * Write your Description here.
  785. *
  786. * Created: 22.10.10 23:37
  787. * Updated: 22.10.10 23:37
  788. * @return void
  789. * @param string $file
  790. * @param string $default
  791. * @access public
  792. * @author deltacahos
  793. */
  794. public function getEncoding($file = NULL, $default = 'utf-8') {
  795. if (!function_exists("finfo_open")) {
  796. return $default;
  797. }
  798. $finfo = finfo_open(FILEINFO_MIME_ENCODING);
  799. $encoding = finfo_file($finfo, $file);
  800. finfo_close($finfo);
  801. if ($encoding !== FALSE) {
  802. return $encoding;
  803. }
  804. return $default;
  805. }
  806. /**
  807. * @desc Gets the file extention from a string
  808. * @param String $file The full file name
  809. * @return String $ext The file extension
  810. */
  811. protected function _getExtension($file = NULL) {
  812. if (!is_null($file)) {
  813. $pieces = explode('.', $file);
  814. $ext = strtolower(array_pop($pieces));
  815. return $ext;
  816. }
  817. return false;
  818. }
  819. }