From 6aea4db6c7adbcee4fffa7cbc39564481fa6e211 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Tue, 17 Jul 2012 17:36:09 +0100 Subject: [ticket/10944] Reverted changes in PHPBB3-10963 is_image now just checks the mimetype reported by the browser and get_mimetype goes back to being unused. PHPBB3-10944 --- phpBB/includes/functions_upload.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php index 33cb585b19..f70e20e616 100644 --- a/phpBB/includes/functions_upload.php +++ b/phpBB/includes/functions_upload.php @@ -151,8 +151,7 @@ class filespec */ function is_image() { - $mimetype = $this->get_mimetype($this->filename); - return (strpos($mimetype, 'image/') === 0); + return (strpos($this->mimetype, 'image/') !== false) ? true : false; } /** @@ -201,12 +200,17 @@ class filespec } /** - * Get mimetype. Utilises the finfo class. + * Get mimetype. Utilize mime_content_type if the function exist. + * Not used at the moment... */ function get_mimetype($filename) { - $finfo = new finfo(FILEINFO_MIME_TYPE); - $mimetype = $finfo->file($filename); + $mimetype = ''; + + if (function_exists('mime_content_type')) + { + $mimetype = mime_content_type($filename); + } // Some browsers choke on a mimetype of application/octet-stream if (!$mimetype || $mimetype == 'application/octet-stream') @@ -338,7 +342,6 @@ class filespec // Remove temporary filename @unlink($this->filename); - $this->filename = $this->destination_file; if (sizeof($this->error)) { -- cgit v1.2.1 From e71474abb5e90d0aeee61d7d9a2d4648aed61426 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Tue, 17 Jul 2012 17:39:19 +0100 Subject: [ticket/10944] strpos now stricter and removed superfluous ternary PHPBB3-10944 --- phpBB/includes/functions_upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php index f70e20e616..d4c6b42cf4 100644 --- a/phpBB/includes/functions_upload.php +++ b/phpBB/includes/functions_upload.php @@ -151,7 +151,7 @@ class filespec */ function is_image() { - return (strpos($this->mimetype, 'image/') !== false) ? true : false; + return (strpos($this->mimetype, 'image/') === 0); } /** -- cgit v1.2.1