1+ <?php
2+
3+ /**
4+ * FireFS - Easily manage your filesystem, through PHP
5+ *
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+ *
13+ * The above copyright notice and this permission notice shall be included in all
14+ * copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+ * SOFTWARE.
23+ *
24+ * @category Library
25+ * @package FireFS
26+ * @author Axel Nana <[email protected] > 27+ * @copyright 2018 Aliens Group, Inc.
28+ * @license MIT <https://github.com/ElementaryFramework/FireFS/blob/master/LICENSE>
29+ * @version GIT: 0.0.1
30+ * @link http://firefs.na2axl.tk
31+ */
32+
33+ namespace FireFS ;
34+
35+
36+ class MimeTypes
37+ {
38+ private static $ _mimes = array (
39+ '3g2 ' => 'video/3gpp2 ' ,
40+ '3gp ' => array ('video/3gp ' , 'video/3gpp ' ),
41+ '7zip ' => array ('application/x-compressed ' , 'application/x-zip-compressed ' , 'application/zip ' , 'multipart/x-zip ' ),
42+ 'aac ' => 'audio/x-acc ' ,
43+ 'ac3 ' => 'audio/ac3 ' ,
44+ 'ai ' => array ('application/pdf ' , 'application/postscript ' ),
45+ 'aif ' => array ('audio/x-aiff ' , 'audio/aiff ' ),
46+ 'aifc ' => 'audio/x-aiff ' ,
47+ 'aiff ' => array ('audio/x-aiff ' , 'audio/aiff ' ),
48+ 'au ' => 'audio/x-au ' ,
49+ 'avi ' => array ('video/x-msvideo ' , 'video/msvideo ' , 'video/avi ' , 'application/x-troff-msvideo ' ),
50+ 'bin ' => array ('application/macbinary ' , 'application/mac-binary ' , 'application/octet-stream ' , 'application/x-binary ' , 'application/x-macbinary ' ),
51+ 'bmp ' => array ('image/bmp ' , 'image/x-bmp ' , 'image/x-bitmap ' , 'image/x-xbitmap ' , 'image/x-win-bitmap ' , 'image/x-windows-bmp ' , 'image/ms-bmp ' , 'image/x-ms-bmp ' , 'application/bmp ' , 'application/x-bmp ' , 'application/x-win-bitmap ' ),
52+ 'cdr ' => array ('application/cdr ' , 'application/coreldraw ' , 'application/x-cdr ' , 'application/x-coreldraw ' , 'image/cdr ' , 'image/x-cdr ' , 'zz-application/zz-winassoc-cdr ' ),
53+ 'cer ' => array ('application/pkix-cert ' , 'application/x-x509-ca-cert ' ),
54+ 'class ' => 'application/octet-stream ' ,
55+ 'cpt ' => 'application/mac-compactpro ' ,
56+ 'crl ' => array ('application/pkix-crl ' , 'application/pkcs-crl ' ),
57+ 'crt ' => array ('application/x-x509-ca-cert ' , 'application/x-x509-user-cert ' , 'application/pkix-cert ' ),
58+ 'csr ' => 'application/octet-stream ' ,
59+ 'css ' => 'text/css ' ,
60+ 'csv ' => array ('text/x-comma-separated-values ' , 'text/comma-separated-values ' , 'application/octet-stream ' , 'application/vnd.ms-excel ' , 'application/x-csv ' , 'text/x-csv ' , 'text/csv ' , 'application/csv ' , 'application/excel ' , 'application/vnd.msexcel ' , 'text/plain ' ),
61+ 'dcr ' => 'application/x-director ' ,
62+ 'der ' => 'application/x-x509-ca-cert ' ,
63+ 'dir ' => 'application/x-director ' ,
64+ 'dll ' => 'application/octet-stream ' ,
65+ 'dms ' => 'application/octet-stream ' ,
66+ 'doc ' => array ('application/msword ' , 'application/vnd.ms-office ' ),
67+ 'docx ' => array ('application/vnd.openxmlformats-officedocument.wordprocessingml.document ' , 'application/zip ' , 'application/msword ' , 'application/x-zip ' ),
68+ 'dot ' => array ('application/msword ' , 'application/vnd.ms-office ' ),
69+ 'dotx ' => array ('application/vnd.openxmlformats-officedocument.wordprocessingml.document ' , 'application/zip ' , 'application/msword ' ),
70+ 'dvi ' => 'application/x-dvi ' ,
71+ 'dxr ' => 'application/x-director ' ,
72+ 'eml ' => 'message/rfc822 ' ,
73+ 'eps ' => 'application/postscript ' ,
74+ 'exe ' => array ('application/octet-stream ' , 'application/x-msdownload ' ),
75+ 'f4v ' => 'video/mp4 ' ,
76+ 'flac ' => 'audio/x-flac ' ,
77+ 'gif ' => 'image/gif ' ,
78+ 'gpg ' => 'application/gpg-keys ' ,
79+ 'gtar ' => 'application/x-gtar ' ,
80+ 'gz ' => 'application/x-gzip ' ,
81+ 'gzip ' => 'application/x-gzip ' ,
82+ 'hqx ' => array ('application/mac-binhex40 ' , 'application/mac-binhex ' , 'application/x-binhex40 ' , 'application/x-mac-binhex40 ' ),
83+ 'htm ' => 'text/html ' ,
84+ 'html ' => 'text/html ' ,
85+ 'ical ' => 'text/calendar ' ,
86+ 'ico ' => array ('image/x-icon ' , 'image/x-ico ' , 'image/vnd.microsoft.icon ' ),
87+ 'ics ' => 'text/calendar ' ,
88+ 'jar ' => array ('application/java-archive ' , 'application/x-java-application ' , 'application/x-jar ' , 'application/x-compressed ' ),
89+ 'jpe ' => array ('image/jpeg ' , 'image/pjpeg ' ),
90+ 'jpeg ' => array ('image/jpeg ' , 'image/pjpeg ' ),
91+ 'jpg ' => array ('image/jpeg ' , 'image/pjpeg ' ),
92+ 'js ' => 'text/javascript ' ,
93+ 'json ' => array ('application/json ' , 'text/json ' ),
94+ 'kdb ' => 'application/octet-stream ' ,
95+ 'kml ' => array ('application/vnd.google-earth.kml+xml ' , 'application/xml ' , 'text/xml ' ),
96+ 'kmz ' => array ('application/vnd.google-earth.kmz ' , 'application/zip ' , 'application/x-zip ' ),
97+ 'lha ' => 'application/octet-stream ' ,
98+ 'log ' => array ('text/plain ' , 'text/x-log ' ),
99+ 'lzh ' => 'application/octet-stream ' ,
100+ 'm3u ' => 'text/plain ' ,
101+ 'm4a ' => 'audio/x-m4a ' ,
102+ 'm4u ' => 'application/vnd.mpegurl ' ,
103+ 'mid ' => 'audio/midi ' ,
104+ 'midi ' => 'audio/midi ' ,
105+ 'mif ' => 'application/vnd.mif ' ,
106+ 'mov ' => 'video/quicktime ' ,
107+ 'movie ' => 'video/x-sgi-movie ' ,
108+ 'mp2 ' => 'audio/mpeg ' ,
109+ 'mp3 ' => array ('audio/mpeg ' , 'audio/mpg ' , 'audio/mpeg3 ' , 'audio/mp3 ' ),
110+ 'mp4 ' => 'video/mp4 ' ,
111+ 'mpe ' => 'video/mpeg ' ,
112+ 'mpeg ' => 'video/mpeg ' ,
113+ 'mpg ' => 'video/mpeg ' ,
114+ 'mpga ' => 'audio/mpeg ' ,
115+ 'oda ' => 'application/oda ' ,
116+ 'ogg ' => 'audio/ogg ' ,
117+ 'p10 ' => array ('application/x-pkcs10 ' , 'application/pkcs10 ' ),
118+ 'p12 ' => 'application/x-pkcs12 ' ,
119+ 'p7a ' => 'application/x-pkcs7-signature ' ,
120+ 'p7c ' => array ('application/pkcs7-mime ' , 'application/x-pkcs7-mime ' ),
121+ 'p7m ' => array ('application/pkcs7-mime ' , 'application/x-pkcs7-mime ' ),
122+ 'p7r ' => 'application/x-pkcs7-certreqresp ' ,
123+ 'p7s ' => 'application/pkcs7-signature ' ,
124+ 'pdf ' => array ('application/pdf ' , 'application/force-download ' , 'application/x-download ' , 'binary/octet-stream ' ),
125+ 'pem ' => array ('application/x-x509-user-cert ' , 'application/x-pem-file ' , 'application/octet-stream ' ),
126+ 'pgp ' => 'application/pgp ' ,
127+ 'php ' => array ('application/x-httpd-php ' , 'application/php ' , 'application/x-php ' , 'text/php ' , 'text/x-php ' , 'application/x-httpd-php-source ' ),
128+ 'php3 ' => 'application/x-httpd-php ' ,
129+ 'php4 ' => 'application/x-httpd-php ' ,
130+ 'phps ' => 'application/x-httpd-php-source ' ,
131+ 'phtml ' => 'application/x-httpd-php ' ,
132+ 'png ' => array ('image/png ' , 'image/x-png ' ),
133+ 'ppt ' => array ('application/powerpoint ' , 'application/vnd.ms-powerpoint ' , 'application/vnd.ms-office ' , 'application/msword ' ),
134+ 'pptx ' => array ('application/vnd.openxmlformats-officedocument.presentationml.presentation ' , 'application/x-zip ' , 'application/zip ' ),
135+ 'ps ' => 'application/postscript ' ,
136+ 'psd ' => array ('application/x-photoshop ' , 'image/vnd.adobe.photoshop ' ),
137+ 'qt ' => 'video/quicktime ' ,
138+ 'ra ' => 'audio/x-realaudio ' ,
139+ 'ram ' => 'audio/x-pn-realaudio ' ,
140+ 'rar ' => array ('application/x-rar ' , 'application/rar ' , 'application/x-rar-compressed ' ),
141+ 'rm ' => 'audio/x-pn-realaudio ' ,
142+ 'rpm ' => 'audio/x-pn-realaudio-plugin ' ,
143+ 'rsa ' => 'application/x-pkcs7 ' ,
144+ 'rtf ' => 'text/rtf ' ,
145+ 'rtx ' => 'text/richtext ' ,
146+ 'rv ' => 'video/vnd.rn-realvideo ' ,
147+ 'sea ' => 'application/octet-stream ' ,
148+ 'shtml ' => 'text/html ' ,
149+ 'sit ' => 'application/x-stuffit ' ,
150+ 'smi ' => 'application/smil ' ,
151+ 'smil ' => 'application/smil ' ,
152+ 'so ' => 'application/octet-stream ' ,
153+ 'srt ' => array ('text/srt ' , 'text/plain ' ),
154+ 'sst ' => 'application/octet-stream ' ,
155+ 'svg ' => array ('image/svg+xml ' , 'application/xml ' , 'text/xml ' ),
156+ 'swf ' => 'application/x-shockwave-flash ' ,
157+ 'tar ' => 'application/x-tar ' ,
158+ 'text ' => 'text/plain ' ,
159+ 'tgz ' => array ('application/x-tar ' , 'application/x-gzip-compressed ' ),
160+ 'tif ' => 'image/tiff ' ,
161+ 'tiff ' => 'image/tiff ' ,
162+ 'txt ' => 'text/plain ' ,
163+ 'vcf ' => 'text/x-vcard ' ,
164+ 'vlc ' => 'application/videolan ' ,
165+ 'vtt ' => array ('text/vtt ' , 'text/plain ' ),
166+ 'wav ' => array ('audio/x-wav ' , 'audio/wave ' , 'audio/wav ' ),
167+ 'wbxml ' => 'application/wbxml ' ,
168+ 'webm ' => 'video/webm ' ,
169+ 'wma ' => array ('audio/x-ms-wma ' , 'video/x-ms-asf ' ),
170+ 'wmlc ' => 'application/wmlc ' ,
171+ 'wmv ' => array ('video/x-ms-wmv ' , 'video/x-ms-asf ' ),
172+ 'word ' => array ('application/msword ' , 'application/octet-stream ' ),
173+ 'xht ' => 'application/xhtml+xml ' ,
174+ 'xhtml ' => 'application/xhtml+xml ' ,
175+ 'xl ' => 'application/excel ' ,
176+ 'xls ' => array ('application/vnd.ms-excel ' , 'application/msexcel ' , 'application/x-msexcel ' , 'application/x-ms-excel ' , 'application/x-excel ' , 'application/x-dos_ms_excel ' , 'application/xls ' , 'application/x-xls ' , 'application/excel ' , 'application/download ' , 'application/vnd.ms-office ' , 'application/msword ' ),
177+ 'xlsx ' => array ('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet ' , 'application/zip ' , 'application/vnd.ms-excel ' , 'application/msword ' , 'application/x-zip ' ),
178+ 'xml ' => array ('application/xml ' , 'text/xml ' , 'text/plain ' ),
179+ 'xsl ' => array ('application/xml ' , 'text/xsl ' , 'text/xml ' ),
180+ 'xspf ' => 'application/xspf+xml ' ,
181+ 'z ' => 'application/x-compress ' ,
182+ 'zip ' => array ('application/x-zip ' , 'application/zip ' , 'application/x-zip-compressed ' , 'application/s-compressed ' , 'multipart/x-zip ' ),
183+ 'zsh ' => 'text/x-scriptzsh '
184+ );
185+
186+ public static function exists (string $ extension ): bool
187+ {
188+ return array_key_exists ($ extension , self ::$ _mimes );
189+ }
190+
191+ public static function register (string $ extension , string $ mime )
192+ {
193+ if (self ::exists ($ extension ))
194+ {
195+ if (is_array (self ::$ _mimes [$ extension ]))
196+ array_push (self ::$ _mimes [$ extension ], $ mime );
197+ else
198+ self ::$ _mimes [$ extension ] = array (self ::$ _mimes [$ extension ], $ mime );
199+ }
200+ else
201+ {
202+ self ::$ _mimes [$ extension ] = $ mime ;
203+ }
204+ }
205+
206+ public static function remove (string $ extension )
207+ {
208+ if (self ::exists ($ extension ))
209+ unset(self ::$ _mimes [$ extension ]);
210+ }
211+
212+ public static function &get ()
213+ {
214+ return self ::$ _mimes ;
215+ }
216+ }
0 commit comments