Bugfix: Include system_mime_type_extensions not system_extension_mime_types

This commit is contained in:
Starbeamrainbowlabs 2015-10-22 08:51:43 +01:00
parent 15885200eb
commit 35a1161be4
4 changed files with 11 additions and 11 deletions

View File

@ -537,9 +537,10 @@ function starts_with($haystack, $needle)
return (substr($haystack, 0, $length) === $needle);
}
function system_extension_mime_types() {
function system_mime_type_extensions() {
global $settings;
# Returns the system MIME type mapping of extensions to MIME types, as defined in /etc/mime.types.
# Returns the system MIME type mapping of MIME types to extensions, as defined in /etc/mime.types (considering the first
# extension listed to be canonical).
$out = array();
$file = fopen($settings->mime_extension_mappings_location, 'r');
while(($line = fgets($file)) !== false) {
@ -550,8 +551,8 @@ function system_extension_mime_types() {
if(count($parts) == 1)
continue;
$type = array_shift($parts);
foreach($parts as $part)
$out[$part] = $type;
if(!isset($out[$type]))
$out[$type] = array_shift($parts);
}
fclose($file);
return $out;
@ -1290,7 +1291,6 @@ register_module([
case "image":
$extra_data = [];
$imagesize = getimagesize($temp_filename, $extra_data);
var_dump($imagesize);
// Make sure that the image size is defined
if(!is_int($imagesize[0]) or !is_int($imagesize[1]))
exit(page_renderer::render("Upload Error - $settings->sitename", "<p>The file that you uploaded doesn't appear to be an image. $settings->sitename currently only supports uploading images (videos coming soon). <a href='?action=upload'>Go back to try again</a>.</p>"));

View File

@ -253,9 +253,10 @@ function starts_with($haystack, $needle)
return (substr($haystack, 0, $length) === $needle);
}
function system_extension_mime_types() {
function system_mime_type_extensions() {
global $settings;
# Returns the system MIME type mapping of extensions to MIME types, as defined in /etc/mime.types.
# Returns the system MIME type mapping of MIME types to extensions, as defined in /etc/mime.types (considering the first
# extension listed to be canonical).
$out = array();
$file = fopen($settings->mime_extension_mappings_location, 'r');
while(($line = fgets($file)) !== false) {
@ -266,8 +267,8 @@ function system_extension_mime_types() {
if(count($parts) == 1)
continue;
$type = array_shift($parts);
foreach($parts as $part)
$out[$part] = $type;
if(!isset($out[$type]))
$out[$type] = array_shift($parts);
}
fclose($file);
return $out;

View File

@ -50,7 +50,7 @@
"author": "Starbeamrainbowlabs",
"description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File:' prefix.",
"id": "feature-upload",
"lastupdate": 1445500026,
"lastupdate": 1445500053,
"optional": false
},
{

View File

@ -72,7 +72,6 @@ register_module([
case "image":
$extra_data = [];
$imagesize = getimagesize($temp_filename, $extra_data);
var_dump($imagesize);
// Make sure that the image size is defined
if(!is_int($imagesize[0]) or !is_int($imagesize[1]))
exit(page_renderer::render("Upload Error - $settings->sitename", "<p>The file that you uploaded doesn't appear to be an image. $settings->sitename currently only supports uploading images (videos coming soon). <a href='?action=upload'>Go back to try again</a>.</p>"));