1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-22 16:33:00 +00:00

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); return (substr($haystack, 0, $length) === $needle);
} }
function system_extension_mime_types() { function system_mime_type_extensions() {
global $settings; 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(); $out = array();
$file = fopen($settings->mime_extension_mappings_location, 'r'); $file = fopen($settings->mime_extension_mappings_location, 'r');
while(($line = fgets($file)) !== false) { while(($line = fgets($file)) !== false) {
@ -550,8 +551,8 @@ function system_extension_mime_types() {
if(count($parts) == 1) if(count($parts) == 1)
continue; continue;
$type = array_shift($parts); $type = array_shift($parts);
foreach($parts as $part) if(!isset($out[$type]))
$out[$part] = $type; $out[$type] = array_shift($parts);
} }
fclose($file); fclose($file);
return $out; return $out;
@ -1290,7 +1291,6 @@ register_module([
case "image": case "image":
$extra_data = []; $extra_data = [];
$imagesize = getimagesize($temp_filename, $extra_data); $imagesize = getimagesize($temp_filename, $extra_data);
var_dump($imagesize);
// Make sure that the image size is defined // Make sure that the image size is defined
if(!is_int($imagesize[0]) or !is_int($imagesize[1])) 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>")); 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); return (substr($haystack, 0, $length) === $needle);
} }
function system_extension_mime_types() { function system_mime_type_extensions() {
global $settings; 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(); $out = array();
$file = fopen($settings->mime_extension_mappings_location, 'r'); $file = fopen($settings->mime_extension_mappings_location, 'r');
while(($line = fgets($file)) !== false) { while(($line = fgets($file)) !== false) {
@ -266,8 +267,8 @@ function system_extension_mime_types() {
if(count($parts) == 1) if(count($parts) == 1)
continue; continue;
$type = array_shift($parts); $type = array_shift($parts);
foreach($parts as $part) if(!isset($out[$type]))
$out[$part] = $type; $out[$type] = array_shift($parts);
} }
fclose($file); fclose($file);
return $out; return $out;

View file

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

View file

@ -72,7 +72,6 @@ register_module([
case "image": case "image":
$extra_data = []; $extra_data = [];
$imagesize = getimagesize($temp_filename, $extra_data); $imagesize = getimagesize($temp_filename, $extra_data);
var_dump($imagesize);
// Make sure that the image size is defined // Make sure that the image size is defined
if(!is_int($imagesize[0]) or !is_int($imagesize[1])) 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>")); 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>"));