1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
16:
17: 18: 19: 20: 21: 22:
23: class Pinoco_MIMEType
24: {
25: private static $EXT2TYPE = array (
26: 'ez' => 'application/andrew-inset',
27: 'atom' => 'application/atom+xml',
28: 'jar' => 'application/java-archive',
29: 'hqx' => 'application/mac-binhex40',
30: 'cpt' => 'application/mac-compactpro',
31: 'mathml' => 'application/mathml+xml',
32: 'doc' => 'application/msword',
33: 'dat' => 'application/octet-stream',
34: 'oda' => 'application/oda',
35: 'ogg' => 'application/ogg',
36: 'pdf' => 'application/pdf',
37: 'ai' => 'application/postscript',
38: 'eps' => 'application/postscript',
39: 'ps' => 'application/postscript',
40: 'rdf' => 'application/rdf+xml',
41: 'rss' => 'application/rss+xml',
42: 'smi' => 'application/smil',
43: 'smil' => 'application/smil',
44: 'gram' => 'application/srgs',
45: 'grxml' => 'application/srgs+xml',
46: 'kml' => 'application/vnd.google-earth.kml+xml',
47: 'kmz' => 'application/vnd.google-earth.kmz',
48: 'mif' => 'application/vnd.mif',
49: 'xul' => 'application/vnd.mozilla.xul+xml',
50: 'xls' => 'application/vnd.ms-excel',
51: 'xlb' => 'application/vnd.ms-excel',
52: 'xlt' => 'application/vnd.ms-excel',
53: 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12',
54: 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
55: 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12',
56: 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12',
57: 'docm' => 'application/vnd.ms-word.document.macroEnabled.12',
58: 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12',
59: 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12',
60: 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
61: 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
62: 'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12',
63: 'ppt' => 'application/vnd.ms-powerpoint',
64: 'pps' => 'application/vnd.ms-powerpoint',
65: 'odc' => 'application/vnd.oasis.opendocument.chart',
66: 'odb' => 'application/vnd.oasis.opendocument.database',
67: 'odf' => 'application/vnd.oasis.opendocument.formula',
68: 'odg' => 'application/vnd.oasis.opendocument.graphics',
69: 'otg' => 'application/vnd.oasis.opendocument.graphics-template',
70: 'odi' => 'application/vnd.oasis.opendocument.image',
71: 'odp' => 'application/vnd.oasis.opendocument.presentation',
72: 'otp' => 'application/vnd.oasis.opendocument.presentation-template',
73: 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
74: 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
75: 'odt' => 'application/vnd.oasis.opendocument.text',
76: 'odm' => 'application/vnd.oasis.opendocument.text-master',
77: 'ott' => 'application/vnd.oasis.opendocument.text-template',
78: 'oth' => 'application/vnd.oasis.opendocument.text-web',
79: 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
80: 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
81: 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
82: 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
83: 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
84: 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
85: 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
86: 'vsd' => 'application/vnd.visio',
87: 'wbxml' => 'application/vnd.wap.wbxml',
88: 'wmlc' => 'application/vnd.wap.wmlc',
89: 'wmlsc' => 'application/vnd.wap.wmlscriptc',
90: 'vxml' => 'application/voicexml+xml',
91: 'bcpio' => 'application/x-bcpio',
92: 'vcd' => 'application/x-cdlink',
93: 'pgn' => 'application/x-chess-pgn',
94: 'cpio' => 'application/x-cpio',
95: 'csh' => 'application/x-csh',
96: 'dcr' => 'application/x-director',
97: 'dir' => 'application/x-director',
98: 'dxr' => 'application/x-director',
99: 'dvi' => 'application/x-dvi',
100: 'spl' => 'application/x-futuresplash',
101: 'tgz' => 'application/x-gtar',
102: 'gtar' => 'application/x-gtar',
103: 'hdf' => 'application/x-hdf',
104: 'js' => 'application/x-javascript',
105: 'skp' => 'application/x-koan',
106: 'skd' => 'application/x-koan',
107: 'skt' => 'application/x-koan',
108: 'skm' => 'application/x-koan',
109: 'latex' => 'application/x-latex',
110: 'nc' => 'application/x-netcdf',
111: 'cdf' => 'application/x-netcdf',
112: 'sh' => 'application/x-sh',
113: 'shar' => 'application/x-shar',
114: 'swf' => 'application/x-shockwave-flash',
115: 'sit' => 'application/x-stuffit',
116: 'sv4cpio' => 'application/x-sv4cpio',
117: 'sv4crc' => 'application/x-sv4crc',
118: 'tar' => 'application/x-tar',
119: 'tcl' => 'application/x-tcl',
120: 'tex' => 'application/x-tex',
121: 'texinfo' => 'application/x-texinfo',
122: 'texi' => 'application/x-texinfo',
123: 't' => 'application/x-troff',
124: 'tr' => 'application/x-troff',
125: 'roff' => 'application/x-troff',
126: 'man' => 'application/x-troff-man',
127: 'me' => 'application/x-troff-me',
128: 'ms' => 'application/x-troff-ms',
129: 'ustar' => 'application/x-ustar',
130: 'src' => 'application/x-wais-source',
131: 'xhtml' => 'application/xhtml+xml',
132: 'xht' => 'application/xhtml+xml',
133: 'xslt' => 'application/xslt+xml',
134: 'xml' => 'application/xml',
135: 'xsl' => 'application/xml',
136: 'dtd' => 'application/xml-dtd',
137: 'zip' => 'application/zip',
138: 'au' => 'audio/basic',
139: 'snd' => 'audio/basic',
140: 'mid' => 'audio/midi',
141: 'midi' => 'audio/midi',
142: 'kar' => 'audio/midi',
143: 'mpga' => 'audio/mpeg',
144: 'mp2' => 'audio/mpeg',
145: 'mp3' => 'audio/mpeg',
146: 'aif' => 'audio/x-aiff',
147: 'aiff' => 'audio/x-aiff',
148: 'aifc' => 'audio/x-aiff',
149: 'm3u' => 'audio/x-mpegurl',
150: 'wma' => 'audio/x-ms-wma',
151: 'wax' => 'audio/x-ms-wax',
152: 'ram' => 'audio/x-pn-realaudio',
153: 'ra' => 'audio/x-pn-realaudio',
154: 'rm' => 'application/vnd.rn-realmedia',
155: 'wav' => 'audio/x-wav',
156: 'pdb' => 'chemical/x-pdb',
157: 'xyz' => 'chemical/x-xyz',
158: 'bmp' => 'image/bmp',
159: 'cgm' => 'image/cgm',
160: 'gif' => 'image/gif',
161: 'ief' => 'image/ief',
162: 'jpeg' => 'image/jpeg',
163: 'jpg' => 'image/jpeg',
164: 'jpe' => 'image/jpeg',
165: 'png' => 'image/png',
166: 'svg' => 'image/svg+xml',
167: 'tiff' => 'image/tiff',
168: 'tif' => 'image/tiff',
169: 'djvu' => 'image/vnd.djvu',
170: 'djv' => 'image/vnd.djvu',
171: 'wbmp' => 'image/vnd.wap.wbmp',
172: 'ras' => 'image/x-cmu-raster',
173: 'ico' => 'image/x-icon',
174: 'pnm' => 'image/x-portable-anymap',
175: 'pbm' => 'image/x-portable-bitmap',
176: 'pgm' => 'image/x-portable-graymap',
177: 'ppm' => 'image/x-portable-pixmap',
178: 'rgb' => 'image/x-rgb',
179: 'xbm' => 'image/x-xbitmap',
180: 'psd' => 'image/x-photoshop',
181: 'xpm' => 'image/x-xpixmap',
182: 'xwd' => 'image/x-xwindowdump',
183: 'eml' => 'message/rfc822',
184: 'igs' => 'model/iges',
185: 'iges' => 'model/iges',
186: 'msh' => 'model/mesh',
187: 'mesh' => 'model/mesh',
188: 'silo' => 'model/mesh',
189: 'wrl' => 'model/vrml',
190: 'vrml' => 'model/vrml',
191: 'ics' => 'text/calendar',
192: 'ifb' => 'text/calendar',
193: 'css' => 'text/css',
194: 'csv' => 'text/csv',
195: 'html' => 'text/html',
196: 'htm' => 'text/html',
197: 'txt' => 'text/plain',
198: 'asc' => 'text/plain',
199: 'rtx' => 'text/richtext',
200: 'rtf' => 'text/rtf',
201: 'sgml' => 'text/sgml',
202: 'sgm' => 'text/sgml',
203: 'tsv' => 'text/tab-separated-values',
204: 'wml' => 'text/vnd.wap.wml',
205: 'wmls' => 'text/vnd.wap.wmlscript',
206: 'etx' => 'text/x-setext',
207: 'mpeg' => 'video/mpeg',
208: 'mpg' => 'video/mpeg',
209: 'mpe' => 'video/mpeg',
210: 'qt' => 'video/quicktime',
211: 'mov' => 'video/quicktime',
212: 'mxu' => 'video/vnd.mpegurl',
213: 'm4u' => 'video/vnd.mpegurl',
214: 'flv' => 'video/x-flv',
215: 'asf' => 'video/x-ms-asf',
216: 'asx' => 'video/x-ms-asf',
217: 'wmv' => 'video/x-ms-wmv',
218: 'wm' => 'video/x-ms-wm',
219: 'wmx' => 'video/x-ms-wmx',
220: 'avi' => 'video/x-msvideo',
221: 'ogv' => 'video/ogg',
222: 'movie' => 'video/x-sgi-movie',
223: 'ice' => 'x-conference/x-cooltalk',
224: );
225:
226: 227: 228: 229: 230: 231:
232: public static function fromFileName($filename)
233: {
234: $ext = pathinfo($filename, PATHINFO_EXTENSION);
235: if ($ext && isset(self::$EXT2TYPE[$ext])) {
236: return self::$EXT2TYPE[$ext];
237: }
238: else {
239: return 'application/octet-stream';
240: }
241: }
242: }