1 | <?php |
||
9 | class MIME |
||
10 | { |
||
11 | use \PHPDaemon\Traits\ClassWatchdog; |
||
12 | use \PHPDaemon\Traits\StaticObjectWatchdog; |
||
13 | |||
14 | /** |
||
15 | * @var array MIME types |
||
16 | */ |
||
17 | protected static $fileTypes = [ |
||
18 | 'txt' => 'text/plain', |
||
19 | 'htm' => 'text/html', |
||
20 | 'html' => 'text/html', |
||
21 | 'php' => 'text/html', |
||
22 | 'css' => 'text/css', |
||
23 | 'js' => 'application/javascript', |
||
24 | 'json' => 'application/json', |
||
25 | 'xml' => 'application/xml', |
||
26 | 'swf' => 'application/x-shockwave-flash', |
||
27 | 'flv' => 'video/x-flv', |
||
28 | |||
29 | // images |
||
30 | 'png' => 'image/png', |
||
31 | 'jpe' => 'image/jpeg', |
||
32 | 'jpeg' => 'image/jpeg', |
||
33 | 'jpg' => 'image/jpeg', |
||
34 | 'gif' => 'image/gif', |
||
35 | 'bmp' => 'image/bmp', |
||
36 | 'ico' => 'image/vnd.microsoft.icon', |
||
37 | 'tiff' => 'image/tiff', |
||
38 | 'tif' => 'image/tiff', |
||
39 | 'svg' => 'image/svg+xml', |
||
40 | 'svgz' => 'image/svg+xml', |
||
41 | |||
42 | // archives |
||
43 | 'zip' => 'application/zip', |
||
44 | 'rar' => 'application/x-rar-compressed', |
||
45 | 'exe' => 'application/x-msdownload', |
||
46 | 'msi' => 'application/x-msdownload', |
||
47 | 'cab' => 'application/vnd.ms-cab-compressed', |
||
48 | |||
49 | // audio/video |
||
50 | 'mp3' => 'audio/mpeg', |
||
51 | 'qt' => 'video/quicktime', |
||
52 | 'mov' => 'video/quicktime', |
||
53 | |||
54 | // adobe |
||
55 | 'pdf' => 'application/pdf', |
||
56 | 'psd' => 'image/vnd.adobe.photoshop', |
||
57 | 'ai' => 'application/postscript', |
||
58 | 'eps' => 'application/postscript', |
||
59 | 'ps' => 'application/postscript', |
||
60 | |||
61 | // ms office |
||
62 | 'doc' => 'application/msword', |
||
63 | 'rtf' => 'application/rtf', |
||
64 | 'xls' => 'application/vnd.ms-excel', |
||
65 | 'ppt' => 'application/vnd.ms-powerpoint', |
||
66 | |||
67 | // open office |
||
68 | 'odt' => 'application/vnd.oasis.opendocument.text', |
||
69 | 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', |
||
70 | ]; |
||
71 | |||
72 | /** |
||
73 | * Returns MIME type of the given file |
||
74 | * @param string $path Path |
||
75 | * @return string MIME type |
||
76 | */ |
||
77 | public static function get($path) |
||
85 | } |
||
86 |