|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Koded package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Mihail Binev <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* Please view the LICENSE distributed with this source code |
|
9
|
|
|
* for the full copyright and license information. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Koded\Stdlib; |
|
13
|
|
|
|
|
14
|
|
|
use function array_key_exists; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Helper class Mime. |
|
18
|
|
|
* |
|
19
|
|
|
*/ |
|
20
|
|
|
final class Mime |
|
21
|
|
|
{ |
|
22
|
|
|
private static array $extensionsToTypes = [ |
|
23
|
|
|
'323' => ['text/h323'], |
|
24
|
|
|
'7z' => ['application/x-7z-compressed'], |
|
25
|
|
|
'abw' => ['application/x-abiword'], |
|
26
|
|
|
'acx' => ['application/internet-property-stream'], |
|
27
|
|
|
'ai' => ['application/postscript'], |
|
28
|
|
|
'aif' => ['audio/x-aiff'], |
|
29
|
|
|
'aifc' => ['audio/x-aiff'], |
|
30
|
|
|
'aiff' => ['audio/x-aiff'], |
|
31
|
|
|
'asf' => ['video/x-ms-asf'], |
|
32
|
|
|
'asr' => ['video/x-ms-asf'], |
|
33
|
|
|
'asx' => ['video/x-ms-asf'], |
|
34
|
|
|
'atom' => ['application/atom+xml'], |
|
35
|
|
|
'avi' => ['video/avi', 'video/msvideo', 'video/x-msvideo'], |
|
36
|
|
|
'bin' => ['application/octet-stream', 'application/macbinary'], |
|
37
|
|
|
'bmp' => ['image/bmp'], |
|
38
|
|
|
'c' => ['text/x-csrc'], |
|
39
|
|
|
'c++' => ['text/x-c++src'], |
|
40
|
|
|
'cab' => ['application/x-cab'], |
|
41
|
|
|
'cc' => ['text/x-c++src'], |
|
42
|
|
|
'cda' => ['application/x-cdf'], |
|
43
|
|
|
'class' => ['application/octet-stream'], |
|
44
|
|
|
'cpp' => ['text/x-c++src'], |
|
45
|
|
|
'cpt' => ['application/mac-compactpro'], |
|
46
|
|
|
'csh' => ['text/x-csh'], |
|
47
|
|
|
'css' => ['text/css'], |
|
48
|
|
|
'csv' => [ |
|
49
|
|
|
'text/x-comma-separated-values', |
|
50
|
|
|
'application/vnd.ms-excel', |
|
51
|
|
|
'text/comma-separated-values', |
|
52
|
|
|
'text/csv' |
|
53
|
|
|
], |
|
54
|
|
|
'dbk' => ['application/docbook+xml'], |
|
55
|
|
|
'dcr' => ['application/x-director'], |
|
56
|
|
|
'deb' => ['application/x-debian-package'], |
|
57
|
|
|
'diff' => ['text/x-diff'], |
|
58
|
|
|
'dir' => ['application/x-director'], |
|
59
|
|
|
'divx' => ['video/divx'], |
|
60
|
|
|
'dll' => ['application/octet-stream', 'application/x-msdos-program'], |
|
61
|
|
|
'dmg' => ['application/x-apple-diskimage'], |
|
62
|
|
|
'dms' => ['application/octet-stream'], |
|
63
|
|
|
'doc' => ['application/msword'], |
|
64
|
|
|
'dvi' => ['application/x-dvi'], |
|
65
|
|
|
'dxr' => ['application/x-director'], |
|
66
|
|
|
'eml' => ['message/rfc822'], |
|
67
|
|
|
'eps' => ['application/postscript'], |
|
68
|
|
|
'evy' => ['application/envoy'], |
|
69
|
|
|
'exe' => ['application/x-msdos-program', 'application/octet-stream'], |
|
70
|
|
|
'fla' => ['application/octet-stream'], |
|
71
|
|
|
'flac' => ['application/x-flac'], |
|
72
|
|
|
'flc' => ['video/flc'], |
|
73
|
|
|
'fli' => ['video/fli'], |
|
74
|
|
|
'flv' => ['video/x-flv'], |
|
75
|
|
|
'gif' => ['image/gif'], |
|
76
|
|
|
'gtar' => ['application/x-gtar'], |
|
77
|
|
|
'gz' => ['application/x-gzip'], |
|
78
|
|
|
'h' => ['text/x-chdr'], |
|
79
|
|
|
'h++' => ['text/x-c++hdr'], |
|
80
|
|
|
'hh' => ['text/x-c++hdr'], |
|
81
|
|
|
'hpp' => ['text/x-c++hdr'], |
|
82
|
|
|
'hqx' => ['application/mac-binhex40'], |
|
83
|
|
|
'hs' => ['text/x-haskell'], |
|
84
|
|
|
'htm' => ['text/html'], |
|
85
|
|
|
'html' => ['text/html'], |
|
86
|
|
|
'ico' => ['image/x-icon'], |
|
87
|
|
|
'ics' => ['text/calendar'], |
|
88
|
|
|
'iii' => ['application/x-iphone'], |
|
89
|
|
|
'ins' => ['application/x-internet-signup'], |
|
90
|
|
|
'iso' => ['application/x-iso9660-image'], |
|
91
|
|
|
'isp' => ['application/x-internet-signup'], |
|
92
|
|
|
'jar' => ['application/java-archive'], |
|
93
|
|
|
'java' => ['application/x-java-applet'], |
|
94
|
|
|
'javascript' => ['application/javascript'], |
|
95
|
|
|
'jpe' => ['image/jpeg', 'image/pjpeg'], |
|
96
|
|
|
'jpeg' => ['image/jpeg', 'image/pjpeg'], |
|
97
|
|
|
'jpg' => ['image/jpeg', 'image/pjpeg'], |
|
98
|
|
|
'js' => ['application/x-javascript'], |
|
99
|
|
|
'json' => ['application/json'], |
|
100
|
|
|
'latex' => ['application/x-latex'], |
|
101
|
|
|
'lha' => ['application/octet-stream'], |
|
102
|
|
|
'log' => ['text/plain', 'text/x-log'], |
|
103
|
|
|
'lzh' => ['application/octet-stream'], |
|
104
|
|
|
'm4a' => ['audio/mpeg'], |
|
105
|
|
|
'm4p' => ['video/mp4v-es'], |
|
106
|
|
|
'm4v' => ['video/mp4'], |
|
107
|
|
|
'man' => ['application/x-troff-man'], |
|
108
|
|
|
'mdb' => ['application/x-msaccess'], |
|
109
|
|
|
'midi' => ['audio/midi'], |
|
110
|
|
|
'mid' => ['audio/midi'], |
|
111
|
|
|
'mif' => ['application/vnd.mif'], |
|
112
|
|
|
'mka' => ['audio/x-matroska'], |
|
113
|
|
|
'mkv' => ['video/x-matroska'], |
|
114
|
|
|
'mov' => ['video/quicktime'], |
|
115
|
|
|
'movie' => ['video/x-sgi-movie'], |
|
116
|
|
|
'mp2' => ['audio/mpeg'], |
|
117
|
|
|
'mp3' => ['audio/mpeg'], |
|
118
|
|
|
'mp4' => ['application/mp4', 'audio/mp4', 'video/mp4'], |
|
119
|
|
|
'mpa' => ['video/mpeg'], |
|
120
|
|
|
'mpe' => ['video/mpeg'], |
|
121
|
|
|
'mpeg' => ['video/mpeg'], |
|
122
|
|
|
'mpg' => ['video/mpeg'], |
|
123
|
|
|
'mpg4' => ['video/mp4'], |
|
124
|
|
|
'mpga' => ['audio/mpeg'], |
|
125
|
|
|
'mpp' => ['application/vnd.ms-project'], |
|
126
|
|
|
'mpv' => ['video/x-matroska'], |
|
127
|
|
|
'mpv2' => ['video/mpeg'], |
|
128
|
|
|
'ms' => ['application/x-troff-ms'], |
|
129
|
|
|
'msg' => ['application/msoutlook', 'application/x-msg'], |
|
130
|
|
|
'msi' => ['application/x-msi'], |
|
131
|
|
|
'nws' => ['message/rfc822'], |
|
132
|
|
|
'oda' => ['application/oda'], |
|
133
|
|
|
'odb' => ['application/vnd.oasis.opendocument.database'], |
|
134
|
|
|
'odc' => ['application/vnd.oasis.opendocument.chart'], |
|
135
|
|
|
'odf' => ['application/vnd.oasis.opendocument.forumla'], |
|
136
|
|
|
'odg' => ['application/vnd.oasis.opendocument.graphics'], |
|
137
|
|
|
'odi' => ['application/vnd.oasis.opendocument.image'], |
|
138
|
|
|
'odm' => ['application/vnd.oasis.opendocument.text-master'], |
|
139
|
|
|
'odp' => ['application/vnd.oasis.opendocument.presentation'], |
|
140
|
|
|
'ods' => ['application/vnd.oasis.opendocument.spreadsheet'], |
|
141
|
|
|
'odt' => ['application/vnd.oasis.opendocument.text'], |
|
142
|
|
|
'oga' => ['audio/ogg'], |
|
143
|
|
|
'ogg' => ['application/ogg'], |
|
144
|
|
|
'ogv' => ['video/ogg'], |
|
145
|
|
|
'otg' => ['application/vnd.oasis.opendocument.graphics-template'], |
|
146
|
|
|
'oth' => ['application/vnd.oasis.opendocument.web'], |
|
147
|
|
|
'otp' => ['application/vnd.oasis.opendocument.presentation-template'], |
|
148
|
|
|
'ots' => ['application/vnd.oasis.opendocument.spreadsheet-template'], |
|
149
|
|
|
'ott' => ['application/vnd.oasis.opendocument.template'], |
|
150
|
|
|
'p' => ['text/x-pascal'], |
|
151
|
|
|
'pas' => ['text/x-pascal'], |
|
152
|
|
|
'patch' => ['text/x-diff'], |
|
153
|
|
|
'pbm' => ['image/x-portable-bitmap'], |
|
154
|
|
|
'pdf' => ['application/pdf', 'application/x-download'], |
|
155
|
|
|
'php' => ['application/x-httpd-php'], |
|
156
|
|
|
'php3' => ['application/x-httpd-php'], |
|
157
|
|
|
'php4' => ['application/x-httpd-php'], |
|
158
|
|
|
'php5' => ['application/x-httpd-php'], |
|
159
|
|
|
'phps' => ['application/x-httpd-php-source'], |
|
160
|
|
|
'phtml' => ['application/x-httpd-php'], |
|
161
|
|
|
'pl' => ['text/x-perl'], |
|
162
|
|
|
'pm' => ['text/x-perl'], |
|
163
|
|
|
'png' => ['image/png', 'image/x-png'], |
|
164
|
|
|
'po' => ['text/x-gettext-translation'], |
|
165
|
|
|
'pot' => ['application/vnd.ms-powerpoint'], |
|
166
|
|
|
'pps' => ['application/vnd.ms-powerpoint'], |
|
167
|
|
|
'ppt' => ['application/powerpoint'], |
|
168
|
|
|
'ps' => ['application/postscript'], |
|
169
|
|
|
'psd' => ['application/x-photoshop', 'image/x-photoshop'], |
|
170
|
|
|
'pub' => ['application/x-mspublisher'], |
|
171
|
|
|
'py' => ['text/x-python'], |
|
172
|
|
|
'qt' => ['video/quicktime'], |
|
173
|
|
|
'ra' => ['audio/x-realaudio'], |
|
174
|
|
|
'ram' => ['audio/x-realaudio', 'audio/x-pn-realaudio'], |
|
175
|
|
|
'rar' => ['application/rar'], |
|
176
|
|
|
'rgb' => ['image/x-rgb'], |
|
177
|
|
|
'rm' => ['audio/x-pn-realaudio'], |
|
178
|
|
|
'rpm' => ['audio/x-pn-realaudio-plugin', 'application/x-redhat-package-manager'], |
|
179
|
|
|
'rss' => ['application/rss+xml'], |
|
180
|
|
|
'rtf' => ['text/rtf'], |
|
181
|
|
|
'rtx' => ['text/richtext'], |
|
182
|
|
|
'rv' => ['video/vnd.rn-realvideo'], |
|
183
|
|
|
'sea' => ['application/octet-stream'], |
|
184
|
|
|
'sh' => ['text/x-sh'], |
|
185
|
|
|
'shtml' => ['text/html'], |
|
186
|
|
|
'sit' => ['application/x-stuffit'], |
|
187
|
|
|
'smi' => ['application/smil'], |
|
188
|
|
|
'smil' => ['application/smil'], |
|
189
|
|
|
'so' => ['application/octet-stream'], |
|
190
|
|
|
'src' => ['application/x-wais-source'], |
|
191
|
|
|
'svg' => ['image/svg+xml'], |
|
192
|
|
|
'swf' => ['application/x-shockwave-flash'], |
|
193
|
|
|
't' => ['application/x-troff'], |
|
194
|
|
|
'tar' => ['application/x-tar'], |
|
195
|
|
|
'tcl' => ['text/x-tcl'], |
|
196
|
|
|
'tex' => ['application/x-tex'], |
|
197
|
|
|
'text' => ['text/plain'], |
|
198
|
|
|
'texti' => ['application/x-texinfo'], |
|
199
|
|
|
'textinfo' => ['application/x-texinfo'], |
|
200
|
|
|
'tgz' => ['application/x-tar'], |
|
201
|
|
|
'tif' => ['image/tiff'], |
|
202
|
|
|
'tiff' => ['image/tiff'], |
|
203
|
|
|
'torrent' => ['application/x-bittorrent'], |
|
204
|
|
|
'tr' => ['application/x-troff'], |
|
205
|
|
|
'tsv' => ['text/tab-separated-values'], |
|
206
|
|
|
'txt' => ['text/plain'], |
|
207
|
|
|
'wav' => ['audio/x-wav'], |
|
208
|
|
|
'wax' => ['audio/x-ms-wax'], |
|
209
|
|
|
'wbxml' => ['application/wbxml'], |
|
210
|
|
|
'wm' => ['video/x-ms-wm'], |
|
211
|
|
|
'wma' => ['audio/x-ms-wma'], |
|
212
|
|
|
'wmd' => ['application/x-ms-wmd'], |
|
213
|
|
|
'wmlc' => ['application/wmlc'], |
|
214
|
|
|
'wmv' => ['video/x-ms-wmv', 'application/octet-stream'], |
|
215
|
|
|
'wmx' => ['video/x-ms-wmx'], |
|
216
|
|
|
'wmz' => ['application/x-ms-wmz'], |
|
217
|
|
|
'word' => ['application/msword', 'application/octet-stream'], |
|
218
|
|
|
'wp5' => ['application/wordperfect5.1'], |
|
219
|
|
|
'wpd' => ['application/vnd.wordperfect'], |
|
220
|
|
|
'wvx' => ['video/x-ms-wvx'], |
|
221
|
|
|
'xbm' => ['image/x-xbitmap'], |
|
222
|
|
|
'xcf' => ['image/xcf'], |
|
223
|
|
|
'xhtml' => ['application/xhtml+xml'], |
|
224
|
|
|
'xht' => ['application/xhtml+xml'], |
|
225
|
|
|
'xl' => ['application/excel', 'application/vnd.ms-excel'], |
|
226
|
|
|
'xla' => ['application/excel', 'application/vnd.ms-excel'], |
|
227
|
|
|
'xlc' => ['application/excel', 'application/vnd.ms-excel'], |
|
228
|
|
|
'xlm' => ['application/excel', 'application/vnd.ms-excel'], |
|
229
|
|
|
'xls' => ['application/excel', 'application/vnd.ms-excel'], |
|
230
|
|
|
'xlt' => ['application/excel', 'application/vnd.ms-excel'], |
|
231
|
|
|
'xml' => ['text/xml', 'application/xml'], |
|
232
|
|
|
'xof' => ['x-world/x-vrml'], |
|
233
|
|
|
'xpm' => ['image/x-xpixmap'], |
|
234
|
|
|
'xsl' => ['text/xml'], |
|
235
|
|
|
'xvid' => ['video/x-xvid'], |
|
236
|
|
|
'xwd' => ['image/x-xwindowdump'], |
|
237
|
|
|
'z' => ['application/x-compress'], |
|
238
|
|
|
'zip' => ['application/x-zip', 'application/zip', 'application/x-zip-compressed'], |
|
239
|
|
|
]; |
|
240
|
|
|
|
|
241
|
|
|
/** |
|
242
|
|
|
* @var array |
|
243
|
|
|
*/ |
|
244
|
|
|
private static array $typesToExtensions = [ |
|
245
|
|
|
'application/json' => ['json'], |
|
246
|
|
|
'text/xml' => ['xml', 'xsl'], |
|
247
|
|
|
'application/xml' => ['xml'], |
|
248
|
|
|
'text/html' => ['htm', 'html', 'shtml'], |
|
249
|
|
|
'text/plain' => ['log', 'text', 'txt'], |
|
250
|
|
|
'application/xhtml+xml' => ['xhtml', 'xht'], |
|
251
|
|
|
'image/png' => ['png'], |
|
252
|
|
|
'image/x-png' => ['png'], |
|
253
|
|
|
'image/gif' => ['gif'], |
|
254
|
|
|
'application/javascript' => ['javascript'], |
|
255
|
|
|
'image/jpeg' => ['jpe', 'jpeg', 'jpg'], |
|
256
|
|
|
'image/pjpeg' => ['jpe', 'jpeg', 'jpg'], |
|
257
|
|
|
'application/x-javascript' => ['js'], |
|
258
|
|
|
'image/svg+xml' => ['svg'], |
|
259
|
|
|
'application/x-latex' => ['latex'], |
|
260
|
|
|
'text/x-log' => ['log'], |
|
261
|
|
|
'application/x-7z-compressed' => ['7z'], |
|
262
|
|
|
'application/x-abiword' => ['abw'], |
|
263
|
|
|
'application/internet-property-stream' => ['acx'], |
|
264
|
|
|
'application/postscript' => ['ai', 'eps', 'ps'], |
|
265
|
|
|
'audio/x-aiff' => ['aif', 'aifc', 'aiff'], |
|
266
|
|
|
'video/x-ms-asf' => ['asf', 'asr', 'asx'], |
|
267
|
|
|
'application/atom+xml' => ['atom'], |
|
268
|
|
|
'video/avi' => ['avi'], |
|
269
|
|
|
'video/msvideo' => ['avi'], |
|
270
|
|
|
'video/x-msvideo' => ['avi'], |
|
271
|
|
|
'application/octet-stream' => [ |
|
272
|
|
|
'bin', |
|
273
|
|
|
'class', |
|
274
|
|
|
'dll', |
|
275
|
|
|
'dms', |
|
276
|
|
|
'exe', |
|
277
|
|
|
'fla', |
|
278
|
|
|
'lha', |
|
279
|
|
|
'lzh', |
|
280
|
|
|
'sea', |
|
281
|
|
|
'so', |
|
282
|
|
|
'wmv', |
|
283
|
|
|
'word' |
|
284
|
|
|
], |
|
285
|
|
|
'application/macbinary' => ['bin'], |
|
286
|
|
|
'image/bmp' => ['bmp'], |
|
287
|
|
|
'text/x-csrc' => ['c'], |
|
288
|
|
|
'text/x-c++src' => ['c++', 'cc', 'cpp'], |
|
289
|
|
|
'application/x-cab' => ['cab'], |
|
290
|
|
|
'application/x-cdf' => ['cda'], |
|
291
|
|
|
'application/mac-compactpro' => ['cpt'], |
|
292
|
|
|
'text/x-csh' => ['csh'], |
|
293
|
|
|
'text/css' => ['css'], |
|
294
|
|
|
'text/x-comma-separated-values' => ['csv'], |
|
295
|
|
|
'application/vnd.ms-excel' => ['csv', 'xl', 'xla', 'xlc', 'xlm', 'xls', 'xlt'], |
|
296
|
|
|
'text/comma-separated-values' => ['csv'], |
|
297
|
|
|
'text/csv' => ['csv'], |
|
298
|
|
|
'application/docbook+xml' => ['dbk'], |
|
299
|
|
|
'application/x-director' => ['dcr', 'dir', 'dxr'], |
|
300
|
|
|
'application/x-debian-package' => ['deb'], |
|
301
|
|
|
'text/x-diff' => ['diff', 'patch'], |
|
302
|
|
|
'video/divx' => ['divx'], |
|
303
|
|
|
'application/x-msdos-program' => ['dll', 'exe'], |
|
304
|
|
|
'application/x-apple-diskimage' => ['dmg'], |
|
305
|
|
|
'application/msword' => ['doc', 'word'], |
|
306
|
|
|
'application/x-dvi' => ['dvi'], |
|
307
|
|
|
'message/rfc822' => ['eml', 'nws'], |
|
308
|
|
|
'application/envoy' => ['evy'], |
|
309
|
|
|
'application/x-flac' => ['flac'], |
|
310
|
|
|
'video/flc' => ['flc'], |
|
311
|
|
|
'video/fli' => ['fli'], |
|
312
|
|
|
'video/x-flv' => ['flv'], |
|
313
|
|
|
'application/x-gtar' => ['gtar'], |
|
314
|
|
|
'application/x-gzip' => ['gz'], |
|
315
|
|
|
'text/x-chdr' => ['h'], |
|
316
|
|
|
'text/x-c++hdr' => ['h++', 'hh', 'hpp'], |
|
317
|
|
|
'application/mac-binhex40' => ['hqx'], |
|
318
|
|
|
'text/x-haskell' => ['hs'], |
|
319
|
|
|
'image/x-icon' => ['ico'], |
|
320
|
|
|
'text/calendar' => ['ics'], |
|
321
|
|
|
'application/x-iphone' => ['iii'], |
|
322
|
|
|
'application/x-internet-signup' => ['ins', 'isp'], |
|
323
|
|
|
'application/x-iso9660-image' => ['iso'], |
|
324
|
|
|
'application/java-archive' => ['jar'], |
|
325
|
|
|
'application/x-java-applet' => ['java'], |
|
326
|
|
|
'audio/mpeg' => ['m4a', 'mp2', 'mp3', 'mpga'], |
|
327
|
|
|
'video/mp4v-es' => ['m4p'], |
|
328
|
|
|
'video/mp4' => ['m4v', 'mp4', 'mpg4'], |
|
329
|
|
|
'application/x-troff-man' => ['man'], |
|
330
|
|
|
'application/x-msaccess' => ['mdb'], |
|
331
|
|
|
'audio/midi' => ['midi', 'mid'], |
|
332
|
|
|
'application/vnd.mif' => ['mif'], |
|
333
|
|
|
'audio/x-matroska' => ['mka'], |
|
334
|
|
|
'video/x-matroska' => ['mkv', 'mpv'], |
|
335
|
|
|
'video/quicktime' => ['mov', 'qt'], |
|
336
|
|
|
'video/x-sgi-movie' => ['movie'], |
|
337
|
|
|
'application/mp4' => ['mp4'], |
|
338
|
|
|
'audio/mp4' => ['mp4'], |
|
339
|
|
|
'video/mpeg' => ['mpa', 'mpe', 'mpeg', 'mpg', 'mpv2'], |
|
340
|
|
|
'application/vnd.ms-project' => ['mpp'], |
|
341
|
|
|
'application/x-troff-ms' => ['ms'], |
|
342
|
|
|
'application/msoutlook' => ['msg'], |
|
343
|
|
|
'application/x-msg' => ['msg'], |
|
344
|
|
|
'application/x-msi' => ['msi'], |
|
345
|
|
|
'application/oda' => ['oda'], |
|
346
|
|
|
'application/vnd.oasis.opendocument.database' => ['odb'], |
|
347
|
|
|
'application/vnd.oasis.opendocument.chart' => ['odc'], |
|
348
|
|
|
'application/vnd.oasis.opendocument.forumla' => ['odf'], |
|
349
|
|
|
'application/vnd.oasis.opendocument.graphics' => ['odg'], |
|
350
|
|
|
'application/vnd.oasis.opendocument.image' => ['odi'], |
|
351
|
|
|
'application/vnd.oasis.opendocument.text-master' => ['odm'], |
|
352
|
|
|
'application/vnd.oasis.opendocument.presentation' => ['odp'], |
|
353
|
|
|
'application/vnd.oasis.opendocument.spreadsheet' => ['ods'], |
|
354
|
|
|
'application/vnd.oasis.opendocument.text' => ['odt'], |
|
355
|
|
|
'audio/ogg' => ['oga'], |
|
356
|
|
|
'application/ogg' => ['ogg'], |
|
357
|
|
|
'video/ogg' => ['ogv'], |
|
358
|
|
|
'application/vnd.oasis.opendocument.graphics-template' => ['otg'], |
|
359
|
|
|
'application/vnd.oasis.opendocument.web' => ['oth'], |
|
360
|
|
|
'application/vnd.oasis.opendocument.presentation-template' => ['otp'], |
|
361
|
|
|
'application/vnd.oasis.opendocument.spreadsheet-template' => ['ots'], |
|
362
|
|
|
'application/vnd.oasis.opendocument.template' => ['ott'], |
|
363
|
|
|
'text/x-pascal' => ['p', 'pas'], |
|
364
|
|
|
'image/x-portable-bitmap' => ['pbm'], |
|
365
|
|
|
'application/pdf' => ['pdf'], |
|
366
|
|
|
'application/x-download' => ['pdf'], |
|
367
|
|
|
'application/x-httpd-php' => ['php', 'php3', 'php4', 'php5', 'phtml'], |
|
368
|
|
|
'application/x-httpd-php-source' => ['phps'], |
|
369
|
|
|
'text/x-perl' => ['pl', 'pm'], |
|
370
|
|
|
'text/x-gettext-translation' => ['po'], |
|
371
|
|
|
'application/vnd.ms-powerpoint' => ['pot', 'pps'], |
|
372
|
|
|
'application/powerpoint' => ['ppt'], |
|
373
|
|
|
'application/x-photoshop' => ['psd'], |
|
374
|
|
|
'image/x-photoshop' => ['psd'], |
|
375
|
|
|
'application/x-mspublisher' => ['pub'], |
|
376
|
|
|
'text/x-python' => ['py'], |
|
377
|
|
|
'audio/x-realaudio' => ['ra', 'ram'], |
|
378
|
|
|
'audio/x-pn-realaudio' => ['ram', 'rm'], |
|
379
|
|
|
'application/rar' => ['rar'], |
|
380
|
|
|
'image/x-rgb' => ['rgb'], |
|
381
|
|
|
'audio/x-pn-realaudio-plugin' => ['rpm'], |
|
382
|
|
|
'application/x-redhat-package-manager' => ['rpm'], |
|
383
|
|
|
'application/rss+xml' => ['rss'], |
|
384
|
|
|
'text/rtf' => ['rtf'], |
|
385
|
|
|
'text/richtext' => ['rtx'], |
|
386
|
|
|
'video/vnd.rn-realvideo' => ['rv'], |
|
387
|
|
|
'text/x-sh' => ['sh'], |
|
388
|
|
|
'application/x-stuffit' => ['sit'], |
|
389
|
|
|
'application/smil' => ['smi', 'smil'], |
|
390
|
|
|
'application/x-wais-source' => ['src'], |
|
391
|
|
|
'application/x-shockwave-flash' => ['swf'], |
|
392
|
|
|
'application/x-troff' => ['t', 'tr'], |
|
393
|
|
|
'application/x-tar' => ['tar', 'tgz'], |
|
394
|
|
|
'text/x-tcl' => ['tcl'], |
|
395
|
|
|
'application/x-tex' => ['tex'], |
|
396
|
|
|
'application/x-texinfo' => ['texti', 'textinfo'], |
|
397
|
|
|
'image/tiff' => ['tif', 'tiff'], |
|
398
|
|
|
'application/x-bittorrent' => ['torrent'], |
|
399
|
|
|
'text/tab-separated-values' => ['tsv'], |
|
400
|
|
|
'audio/x-wav' => ['wav'], |
|
401
|
|
|
'audio/x-ms-wax' => ['wax'], |
|
402
|
|
|
'application/wbxml' => ['wbxml'], |
|
403
|
|
|
'video/x-ms-wm' => ['wm'], |
|
404
|
|
|
'audio/x-ms-wma' => ['wma'], |
|
405
|
|
|
'application/x-ms-wmd' => ['wmd'], |
|
406
|
|
|
'application/wmlc' => ['wmlc'], |
|
407
|
|
|
'video/x-ms-wmv' => ['wmv'], |
|
408
|
|
|
'video/x-ms-wmx' => ['wmx'], |
|
409
|
|
|
'application/x-ms-wmz' => ['wmz'], |
|
410
|
|
|
'application/wordperfect5.1' => ['wp5'], |
|
411
|
|
|
'application/vnd.wordperfect' => ['wpd'], |
|
412
|
|
|
'video/x-ms-wvx' => ['wvx'], |
|
413
|
|
|
'image/x-xbitmap' => ['xbm'], |
|
414
|
|
|
'image/xcf' => ['xcf'], |
|
415
|
|
|
'application/excel' => ['xl', 'xla', 'xlc', 'xlm', 'xls', 'xlt'], |
|
416
|
|
|
'x-world/x-vrml' => ['xof'], |
|
417
|
|
|
'image/x-xpixmap' => ['xpm'], |
|
418
|
|
|
'video/x-xvid' => ['xvid'], |
|
419
|
|
|
'image/x-xwindowdump' => ['xwd'], |
|
420
|
|
|
'application/x-compress' => ['z'], |
|
421
|
|
|
'application/x-zip' => ['zip'], |
|
422
|
|
|
'application/zip' => ['zip'], |
|
423
|
|
|
'application/x-zip-compressed' => ['zip'], |
|
424
|
|
|
'text/h323' => ['323'], |
|
425
|
|
|
]; |
|
426
|
|
|
|
|
427
|
|
|
/** |
|
428
|
|
|
* Returns the mime type by file extension name. |
|
429
|
|
|
* |
|
430
|
|
|
* @param string $extension The short mime type name |
|
431
|
|
|
* @param int $index [optional] The index of the full-name mime from the array list |
|
432
|
|
|
* |
|
433
|
|
|
* @return string The media type, or |
|
434
|
|
|
* empty string if type was not found (by type and index) |
|
435
|
|
|
*/ |
|
436
|
3 |
|
public static function type(string $extension, int $index = 0): string |
|
437
|
|
|
{ |
|
438
|
3 |
|
return self::$extensionsToTypes[$extension][$index] |
|
439
|
3 |
|
?? self::$extensionsToTypes[$extension][0] |
|
440
|
3 |
|
?? ''; |
|
441
|
|
|
} |
|
442
|
|
|
|
|
443
|
|
|
/** |
|
444
|
|
|
* Returns the list of mime types associated by the file extension name. |
|
445
|
|
|
* |
|
446
|
|
|
* @param string $extension Extension name |
|
447
|
|
|
* |
|
448
|
|
|
* @return array The mime types list |
|
449
|
|
|
*/ |
|
450
|
2 |
|
public static function types(string $extension): array |
|
451
|
|
|
{ |
|
452
|
2 |
|
return self::$extensionsToTypes[$extension] ?? []; |
|
453
|
|
|
} |
|
454
|
|
|
|
|
455
|
|
|
/** |
|
456
|
|
|
* Checks if mime type is in the supported type list. |
|
457
|
|
|
* |
|
458
|
|
|
* @param string $type |
|
459
|
|
|
* |
|
460
|
|
|
* @return bool |
|
461
|
|
|
*/ |
|
462
|
1 |
|
public static function supports(string $type): bool |
|
463
|
|
|
{ |
|
464
|
1 |
|
return array_key_exists($type, self::$typesToExtensions); |
|
465
|
|
|
} |
|
466
|
|
|
|
|
467
|
|
|
/** |
|
468
|
|
|
* Returns the list of file extensions associated by the mime type. |
|
469
|
|
|
* |
|
470
|
|
|
* @param string $type Mime type |
|
471
|
|
|
* |
|
472
|
|
|
* @return array List of corresponding file extensions |
|
473
|
|
|
*/ |
|
474
|
1 |
|
public static function extensions(string $type): array |
|
475
|
|
|
{ |
|
476
|
1 |
|
return self::$typesToExtensions[$type] ?? []; |
|
477
|
|
|
} |
|
478
|
|
|
} |
|
479
|
|
|
|