aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2012-07-05 02:00:31 +0200
committerAndreas Fischer <bantu@phpbb.com>2012-07-05 02:00:31 +0200
commitc54d74ec0ed24a9ee7c0d722eb185f1c8a58aab9 (patch)
tree1566727a30d776e760d1cc4364373fc5d890a477
parentd998ad4b15a8fb0204db7f05c7b71e7c2c6b85bf (diff)
parent4fbcf4eaadea0425c7f8bf0ff02a60bd2165136b (diff)
downloadforums-c54d74ec0ed24a9ee7c0d722eb185f1c8a58aab9.tar
forums-c54d74ec0ed24a9ee7c0d722eb185f1c8a58aab9.tar.gz
forums-c54d74ec0ed24a9ee7c0d722eb185f1c8a58aab9.tar.bz2
forums-c54d74ec0ed24a9ee7c0d722eb185f1c8a58aab9.tar.xz
forums-c54d74ec0ed24a9ee7c0d722eb185f1c8a58aab9.zip
Merge remote-tracking branch 'Fyorl/ticket/10963' into develop
* Fyorl/ticket/10963: [ticket/10963] filespec::get_mimetype now used [ticket/10963] Removed superfluous ternary statement and strpos now stricter [ticket/10963] Modified filespec::is_image() to check actual mimetype
-rw-r--r--phpBB/includes/functions_upload.php15
1 files changed, 6 insertions, 9 deletions
diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php
index f70e20e616..33cb585b19 100644
--- a/phpBB/includes/functions_upload.php
+++ b/phpBB/includes/functions_upload.php
@@ -151,7 +151,8 @@ class filespec
*/
function is_image()
{
- return (strpos($this->mimetype, 'image/') !== false) ? true : false;
+ $mimetype = $this->get_mimetype($this->filename);
+ return (strpos($mimetype, 'image/') === 0);
}
/**
@@ -200,17 +201,12 @@ class filespec
}
/**
- * Get mimetype. Utilize mime_content_type if the function exist.
- * Not used at the moment...
+ * Get mimetype. Utilises the finfo class.
*/
function get_mimetype($filename)
{
- $mimetype = '';
-
- if (function_exists('mime_content_type'))
- {
- $mimetype = mime_content_type($filename);
- }
+ $finfo = new finfo(FILEINFO_MIME_TYPE);
+ $mimetype = $finfo->file($filename);
// Some browsers choke on a mimetype of application/octet-stream
if (!$mimetype || $mimetype == 'application/octet-stream')
@@ -342,6 +338,7 @@ class filespec
// Remove temporary filename
@unlink($this->filename);
+ $this->filename = $this->destination_file;
if (sizeof($this->error))
{