Subversion Repositories fileformats

Rev

Rev 5 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5 Rev 8
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
 * File Type Detection for PHP
4
 * File Type Detection for PHP
5
 * Copyright 2020 Daniel Marschall, ViaThinkSoft
5
 * Copyright 2020 - 2021 Daniel Marschall, ViaThinkSoft
6
 *
6
 *
7
 *    Revision 2020-05-17
7
 *    Revision 2021-05-21
8
 *
8
 *
9
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
11
 * You may obtain a copy of the License at
12
 *
12
 *
Line 24... Line 24...
24
        public static function getMimeType($filename) {
24
        public static function getMimeType($filename) {
25
            $mime_types = array();
25
                $mime_types = array();
26
           
26
 
27
                include __DIR__ . '/mimetype_lookup.inc.php';
27
                include __DIR__ . '/mimetype_lookup.inc.php';
28
 
28
 
-
 
29
                /** @phpstan-ignore-next-line */
29
                foreach ($mime_types as $ext => $mime) {
30
                foreach ($mime_types as $ext => $mime) {
30
                        if (strtoupper(substr($filename, -strlen($ext)-1)) == strtoupper('.'.$ext)) {
31
                        if (strtoupper(substr($filename, -strlen($ext)-1)) == strtoupper('.'.$ext)) {
31
                                return $mime;
32
                                return $mime;
32
                        }
33
                        }
33
                }
34
                }
Line 81... Line 82...
81
                        foreach ($inis as $ini) {
82
                        foreach ($inis as $ini) {
82
                                if (isset($ini['MimeType'][$mime]))  return $ini['MimeType'][$mime];
83
                                if (isset($ini['MimeType'][$mime]))  return $ini['MimeType'][$mime];
83
                        }
84
                        }
84
                }
85
                }
85
 
86
 
-
 
87
                foreach ($inis as $ini) {
-
 
88
                        if (isset($ini['Static']['LngUnknown'])) {
86
                return $ini['Static']['LngUnknown'];
89
                                return $ini['Static']['LngUnknown'];
87
        }
90
                        }
-
 
91
                }
-
 
92
                return 'Unknown';
-
 
93
        }
88
 
94
 
89
}
95
}