1: <?php
2: /**
3: * Contain a lot of MimeTypes
4: *
5: * @package Email
6: * @filesource MimeType.php
7: *
8: * @author Cyril Nicodème
9: * @version 0.1
10: *
11: * @since 15/07/2008
12: *
13: * @license GNU/GPL v3
14: */
15: class MimeType
16: {
17: /**
18: * @var Array $_aType
19: * Contain a lot of Mime type !
20: */
21: private static $_aType = array ( '323' => 'text/h323',
22: 'acx' => 'application/internet-property-stream',
23: 'ai' => 'application/postscript',
24: 'aif' => 'audio/x-aiff',
25: 'aifc' => 'audio/x-aiff',
26: 'aiff' => 'audio/x-aiff',
27: 'asf' => 'video/x-ms-asf',
28: 'asr' => 'video/x-ms-asf',
29: 'asx' => 'video/x-ms-asf',
30: 'au' => 'audio/basic',
31: 'avi' => 'video/x-msvideo',
32: 'axs' => 'application/olescript',
33: 'bas' => 'text/plain',
34: 'bcpio' => 'application/x-bcpio',
35: 'bin' => 'application/octet-stream',
36: 'bmp' => 'image/bmp',
37: 'c' => 'text/plain',
38: 'cat' => 'application/vnd.ms-pkiseccat',
39: 'cdf' => 'application/x-cdf',
40: 'cer' => 'application/x-x509-ca-cert',
41: 'class' => 'application/octet-stream',
42: 'clp' => 'application/x-msclip',
43: 'cmx' => 'image/x-cmx',
44: 'cod' => 'image/cis-cod',
45: 'cpio' => 'application/x-cpio',
46: 'crd' => 'application/x-mscardfile',
47: 'crl' => 'application/pkix-crl',
48: 'crt' => 'application/x-x509-ca-cert',
49: 'csh' => 'application/x-csh',
50: 'css' => 'text/css',
51: 'dcr' => 'application/x-director',
52: 'der' => 'application/x-x509-ca-cert',
53: 'dir' => 'application/x-director',
54: 'dll' => 'application/x-msdownload',
55: 'dms' => 'application/octet-stream',
56: 'doc' => 'application/msword',
57: 'dot' => 'application/msword',
58: 'dvi' => 'application/x-dvi',
59: 'dxr' => 'application/x-director',
60: 'eps' => 'application/postscript',
61: 'etx' => 'text/x-setext',
62: 'evy' => 'application/envoy',
63: 'exe' => 'application/octet-stream',
64: 'fif' => 'application/fractals',
65: 'flr' => 'x-world/x-vrml',
66: 'gif' => 'image/gif',
67: 'gtar' => 'application/x-gtar',
68: 'gz' => 'application/x-gzip',
69: 'h' => 'text/plain',
70: 'hdf' => 'application/x-hdf',
71: 'hlp' => 'application/winhlp',
72: 'hqx' => 'application/mac-binhex40',
73: 'hta' => 'application/hta',
74: 'htc' => 'text/x-component',
75: 'htm' => 'text/html',
76: 'html' => 'text/html',
77: 'htt' => 'text/webviewhtml',
78: 'ico' => 'image/x-icon',
79: 'ief' => 'image/ief',
80: 'iii' => 'application/x-iphone',
81: 'ins' => 'application/x-internet-signup',
82: 'isp' => 'application/x-internet-signup',
83: 'jfif' => 'image/pipeg',
84: 'jpe' => 'image/jpeg',
85: 'jpeg' => 'image/jpeg',
86: 'jpg' => 'image/jpeg',
87: 'js' => 'application/x-javascript',
88: 'latex' => 'application/x-latex',
89: 'lha' => 'application/octet-stream',
90: 'lsf' => 'video/x-la-asf',
91: 'lsx' => 'video/x-la-asf',
92: 'lzh' => 'application/octet-stream',
93: 'm13' => 'application/x-msmediaview',
94: 'm14' => 'application/x-msmediaview',
95: 'm3u' => 'audio/x-mpegurl',
96: 'man' => 'application/x-troff-man',
97: 'mdb' => 'application/x-msaccess',
98: 'me' => 'application/x-troff-me',
99: 'mht' => 'message/rfc822',
100: 'mhtml' => 'message/rfc822',
101: 'mid' => 'audio/mid',
102: 'mny' => 'application/x-msmoney',
103: 'mov' => 'video/quicktime',
104: 'movie' => 'video/x-sgi-movie',
105: 'mp2' => 'video/mpeg',
106: 'mp3' => 'audio/mpeg',
107: 'mpa' => 'video/mpeg',
108: 'mpe' => 'video/mpeg',
109: 'mpeg' => 'video/mpeg',
110: 'mpg' => 'video/mpeg',
111: 'mpp' => 'application/vnd.ms-project',
112: 'mpv2' => 'video/mpeg',
113: 'ms' => 'application/x-troff-ms',
114: 'mvb' => 'application/x-msmediaview',
115: 'nws' => 'message/rfc822',
116: 'oda' => 'application/oda',
117: 'p10' => 'application/pkcs10',
118: 'p12' => 'application/x-pkcs12',
119: 'p7b' => 'application/x-pkcs7-certificates',
120: 'p7c' => 'application/x-pkcs7-mime',
121: 'p7m' => 'application/x-pkcs7-mime',
122: 'p7r' => 'application/x-pkcs7-certreqresp',
123: 'p7s' => 'application/x-pkcs7-signature',
124: 'pbm' => 'image/x-portable-bitmap',
125: 'pdf' => 'application/pdf',
126: 'pfx' => 'application/x-pkcs12',
127: 'pgm' => 'image/x-portable-graymap',
128: 'pko' => 'application/ynd.ms-pkipko',
129: 'pma' => 'application/x-perfmon',
130: 'pmc' => 'application/x-perfmon',
131: 'pml' => 'application/x-perfmon',
132: 'pmr' => 'application/x-perfmon',
133: 'pmw' => 'application/x-perfmon',
134: 'png' => 'image/png',
135: 'pnm' => 'image/x-portable-anymap',
136: 'pot' => 'application/vnd.ms-powerpoint',
137: 'ppm' => 'image/x-portable-pixmap',
138: 'pps' => 'application/vnd.ms-powerpoint',
139: 'ppt' => 'application/vnd.ms-powerpoint',
140: 'prf' => 'application/pics-rules',
141: 'ps' => 'application/postscript',
142: 'pub' => 'application/x-mspublisher',
143: 'qt' => 'video/quicktime',
144: 'ra' => 'audio/x-pn-realaudio',
145: 'ram' => 'audio/x-pn-realaudio',
146: 'ras' => 'image/x-cmu-raster',
147: 'rgb' => 'image/x-rgb',
148: 'rmi' => 'audio/mid',
149: 'roff' => 'application/x-troff',
150: 'rtf' => 'application/rtf',
151: 'rtx' => 'text/richtext',
152: 'scd' => 'application/x-msschedule',
153: 'sct' => 'text/scriptlet',
154: 'setpay' => 'application/set-payment-initiation',
155: 'setreg' => 'application/set-registration-initiation',
156: 'sh' => 'application/x-sh',
157: 'shar' => 'application/x-shar',
158: 'sit' => 'application/x-stuffit',
159: 'snd' => 'audio/basic',
160: 'spc' => 'application/x-pkcs7-certificates',
161: 'spl' => 'application/futuresplash',
162: 'src' => 'application/x-wais-source',
163: 'sst' => 'application/vnd.ms-pkicertstore',
164: 'stl' => 'application/vnd.ms-pkistl',
165: 'stm' => 'text/html',
166: 'svg' => 'image/svg+xml',
167: 'sv4cpio' => 'application/x-sv4cpio',
168: 'sv4crc' => 'application/x-sv4crc',
169: 't' => 'application/x-troff',
170: 'tar' => 'application/x-tar',
171: 'tcl' => 'application/x-tcl',
172: 'tex' => 'application/x-tex',
173: 'texi' => 'application/x-texinfo',
174: 'texinfo' => 'application/x-texinfo',
175: 'tgz' => 'application/x-compressed',
176: 'tif' => 'image/tiff',
177: 'tiff' => 'image/tiff',
178: 'tr' => 'application/x-troff',
179: 'trm' => 'application/x-msterminal',
180: 'tsv' => 'text/tab-separated-values',
181: 'txt' => 'text/plain',
182: 'uls' => 'text/iuls',
183: 'ustar' => 'application/x-ustar',
184: 'vcf' => 'text/x-vcard',
185: 'vrml' => 'x-world/x-vrml',
186: 'wav' => 'audio/x-wav',
187: 'wcm' => 'application/vnd.ms-works',
188: 'wdb' => 'application/vnd.ms-works',
189: 'wks' => 'application/vnd.ms-works',
190: 'wmf' => 'application/x-msmetafile',
191: 'wps' => 'application/vnd.ms-works',
192: 'wri' => 'application/x-mswrite',
193: 'wrl' => 'x-world/x-vrml',
194: 'wrz' => 'x-world/x-vrml',
195: 'xaf' => 'x-world/x-vrml',
196: 'xbm' => 'image/x-xbitmap',
197: 'xla' => 'application/vnd.ms-excel',
198: 'xlc' => 'application/vnd.ms-excel',
199: 'xlm' => 'application/vnd.ms-excel',
200: 'xls' => 'application/vnd.ms-excel',
201: 'xlt' => 'application/vnd.ms-excel',
202: 'xlw' => 'application/vnd.ms-excel',
203: 'xof' => 'x-world/x-vrml',
204: 'xpm' => 'image/x-xpixmap',
205: 'xwd' => 'image/x-xwindowdump',
206: 'z' => 'application/x-compress',
207: 'zip' => 'application/zip');
208:
209: /**
210: * Return the Mime type for the given extension
211: *
212: * @param String $sKey
213: *
214: * @return String
215: *
216: * @throws Exception
217: */
218: public static function get ($sKey)
219: {
220: $sExtension = $sKey;
221:
222: if (strpos ($sKey, '.') !== false)
223: $sExtension = substr ($sKey, strrpos ($sKey, '.') + 1);
224:
225: if (!isset (self::$_aType[$sExtension]))
226: throw new Exception ('Invalid Key given');
227:
228: return self::$_aType[$sExtension];
229: }
230: }
231: