|
|
@ -301,21 +301,23 @@ class MimeClass { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private function system_mime_type_extensions() { |
|
|
|
private function system_mime_type_extensions() { |
|
|
|
$out = array(); |
|
|
|
$out = array(); |
|
|
|
$file = fopen($this->etc_mime_types, 'r'); |
|
|
|
if (file_exists($this->etc_mime_types)) { |
|
|
|
while (($line = fgets($file)) !== FALSE) { |
|
|
|
$file = fopen($this->etc_mime_types, 'r'); |
|
|
|
$line = trim(preg_replace('/#.*/', '', $line)); |
|
|
|
while (($line = fgets($file)) !== FALSE) { |
|
|
|
if (!$line) |
|
|
|
$line = trim(preg_replace('/#.*/', '', $line)); |
|
|
|
continue; |
|
|
|
if (!$line) |
|
|
|
$parts = preg_split('/\s+/', $line); |
|
|
|
continue; |
|
|
|
if (count($parts) == 1) |
|
|
|
$parts = preg_split('/\s+/', $line); |
|
|
|
continue; |
|
|
|
if (count($parts) == 1) |
|
|
|
// A single part means a mimetype without extensions, which we ignore. |
|
|
|
continue; |
|
|
|
$type = array_shift($parts); |
|
|
|
// A single part means a mimetype without extensions, which we ignore. |
|
|
|
if (!isset($out[$type])) |
|
|
|
$type = array_shift($parts); |
|
|
|
$out[$type] = array_shift($parts); |
|
|
|
if (!isset($out[$type])) |
|
|
|
// We take the first ext from the line if many are present. |
|
|
|
$out[$type] = array_shift($parts); |
|
|
|
|
|
|
|
// We take the first ext from the line if many are present. |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
fclose($file); |
|
|
|
} |
|
|
|
} |
|
|
|
fclose($file); |
|
|
|
|
|
|
|
return $out; |
|
|
|
return $out; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -328,20 +330,22 @@ class MimeClass { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private function system_extension_mime_types() { |
|
|
|
private function system_extension_mime_types() { |
|
|
|
$out = array(); |
|
|
|
$out = array(); |
|
|
|
$file = fopen($this->etc_mime_types, 'r'); |
|
|
|
if (file_exists($this->etc_mime_types)) { |
|
|
|
while (($line = fgets($file)) !== FALSE) { |
|
|
|
$file = fopen($this->etc_mime_types, 'r'); |
|
|
|
$line = trim(preg_replace('/#.*/', '', $line)); |
|
|
|
while (($line = fgets($file)) !== FALSE) { |
|
|
|
if (!$line) |
|
|
|
$line = trim(preg_replace('/#.*/', '', $line)); |
|
|
|
continue; |
|
|
|
if (!$line) |
|
|
|
$parts = preg_split('/\s+/', $line); |
|
|
|
continue; |
|
|
|
if (count($parts) == 1) |
|
|
|
$parts = preg_split('/\s+/', $line); |
|
|
|
continue; |
|
|
|
if (count($parts) == 1) |
|
|
|
// A single part means a mimetype without extensions, which we ignore. |
|
|
|
continue; |
|
|
|
$type = array_shift($parts); |
|
|
|
// A single part means a mimetype without extensions, which we ignore. |
|
|
|
foreach ($parts as $part) |
|
|
|
$type = array_shift($parts); |
|
|
|
$out[$part] = $type; |
|
|
|
foreach ($parts as $part) |
|
|
|
|
|
|
|
$out[$part] = $type; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
fclose($file); |
|
|
|
} |
|
|
|
} |
|
|
|
fclose($file); |
|
|
|
|
|
|
|
return $out; |
|
|
|
return $out; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|