/usr/share/doc/php-horde-mime/mime_mapping/convert.php is in php-horde-mime 2.9.3-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | <?php
/**
* Create MIME mapping file from data sources.
*
* Copyright 2001-2016 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @author Anil Madhavapeddy <avsm@horde.org>
* @author Michael Slusarz <slusarz@horde.org>
* @category Horde
* @copyright 2001-2016 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Mime
*/
/* Files containing MIME extensions (Apache format).
* https://github.com/apache/httpd/blob/trunk/docs/conf/mime.types */
$files = array(
'mime.types',
'mime.types.horde'
);
/* Files contating MIME extensions (freedesktop.org format).
* http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec */
$od_files = array(
'mime.globs'
);
$exts = array();
$maxlength = strlen('__MAXPERIOD__');
$maxperiod = 0;
/* Map the mime extensions file(s) into the $exts hash. */
foreach ($files as $val) {
/* Read file and remove trailing whitespace. */
$data = array_filter(array_map('rtrim', file($val)));
foreach ($data as $line) {
/* Skip comments. */
if ($line[0] === '#') {
continue;
}
/* These are tab-delimited files. Skip the entry if there is no
* extension information. */
$fields = preg_split("/\s+/", $line, 2);
if (!empty($fields[1])) {
foreach (preg_split("/\s+/", $fields[1]) as $val2) {
$exts[$val2] = $fields[0];
$maxlength = max(strlen($val2), $maxlength);
}
}
}
}
foreach ($od_files as $val) {
/* Read file and remove trailing whitespace. */
$data = array_filter(array_map('rtrim', file($val)));
foreach ($data as $line) {
/* Skip comments. */
if ($line[0] === '#') {
continue;
}
/* These are ':' delimited files. Skip the entry if this is not
an extension matching glob. */
$fields = explode(':', $line, 2);
$pos = strpos($fields[1], '*.');
if ($pos !== false) {
$val2 = substr($fields[1], $pos + 2);
if ((strpos($val2, '*') !== false) ||
(strpos($val2, '[') !== false) ||
isset($exts[$val2])) {
continue;
}
$maxperiod = max(substr_count($val2, '.'), $maxperiod);
$maxlength = max(strlen($val2), $maxlength);
$exts[$val2] = $fields[0];
}
}
}
/* Assemble/sort the extensions into an output array. */
$output = array(
sprintf(
"'__MAXPERIOD__'%s => '%u'",
str_repeat(' ', $maxlength - strlen('__MAXPERIOD__')),
$maxperiod
)
);
ksort($exts);
/* Special case: move .jpg to the first image/jpeg entry. */
$first_jpeg = array_search('image/jpeg', $exts);
$keys = array_keys($exts);
$index1 = array_search($first_jpeg, $keys);
$index2 = array_search('jpg', $keys);
$keys[$index1] = 'jpg';
$keys[$index2] = $first_jpeg;
$exts = array_combine($keys, array_values($exts));
foreach ($exts as $key => $val) {
$output[] = sprintf(
"'%s'%s => '%s'",
$key,
str_repeat(' ', $maxlength - strlen($key)),
$val
);
}
/* Generate the PHP output file. */
$generated = sprintf(
'%s by %s on %s',
strftime('%D %T'),
$_SERVER['USER'],
$_SERVER['HOST']
);
$map = implode(",\n ", $output);
print <<<HEADER
<?php
/**
* This file contains a mapping of common file extensions to MIME types.
* It has been automatically generated.
* Any changes made directly to this file may/will be lost in the future.
*
* Any unknown file extensions will automatically be mapped to
* 'x-extension/<ext>' where <ext> is the unknown file extension.
*
* Generated: $generated
*
* @category Horde
* @package Mime
*/
\$mime_extension_map = array(
$map
);
HEADER;
|