From 2fa99602c6f6431e99468ca13f4a58344a401c24 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 8 Feb 2015 20:46:14 +0100 Subject: [ticket/8672] Add class for retrieving imagesize without download getimagesize() always downloads the complete file before checking the actual image dimensions. This class will be able to do the same without having to download possibly large files. PHPBB3-8672 --- phpBB/phpbb/avatar/driver/remote.php | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'phpBB/phpbb/avatar/driver/remote.php') diff --git a/phpBB/phpbb/avatar/driver/remote.php b/phpBB/phpbb/avatar/driver/remote.php index 4b0ee3f06f..d04f95905d 100644 --- a/phpBB/phpbb/avatar/driver/remote.php +++ b/phpBB/phpbb/avatar/driver/remote.php @@ -92,25 +92,22 @@ class remote extends \phpbb\avatar\driver\driver return false; } - // Make sure getimagesize works... - if (function_exists('getimagesize')) + // Get image dimensions + if (($width <= 0 || $height <= 0) && (($image_data = $this->imagesize->get_imagesize($url)) === false)) { - if (($width <= 0 || $height <= 0) && (($image_data = @getimagesize($url)) === false)) - { - $error[] = 'UNABLE_GET_IMAGE_SIZE'; - return false; - } - - if (!empty($image_data) && ($image_data[0] <= 0 || $image_data[1] <= 0)) - { - $error[] = 'AVATAR_NO_SIZE'; - return false; - } + $error[] = 'UNABLE_GET_IMAGE_SIZE'; + return false; + } - $width = ($width && $height) ? $width : $image_data[0]; - $height = ($width && $height) ? $height : $image_data[1]; + if (!empty($image_data) && ($image_data['width'] <= 0 || $image_data['height'] <= 0)) + { + $error[] = 'AVATAR_NO_SIZE'; + return false; } + $width = ($width && $height) ? $width : $image_data['width']; + $height = ($width && $height) ? $height : $image_data['height']; + if ($width <= 0 || $height <= 0) { $error[] = 'AVATAR_NO_SIZE'; @@ -172,15 +169,15 @@ class remote extends \phpbb\avatar\driver\driver return false; } - if (!empty($image_data) && (!isset($types[$image_data[2]]) || !in_array($extension, $types[$image_data[2]]))) + if (!empty($image_data) && (!isset($types[$image_data['type']]) || !in_array($extension, $types[$image_data['type']]))) { - if (!isset($types[$image_data[2]])) + if (!isset($types[$image_data['type']])) { $error[] = 'UNABLE_GET_IMAGE_SIZE'; } else { - $error[] = array('IMAGE_FILETYPE_MISMATCH', $types[$image_data[2]][0], $extension); + $error[] = array('IMAGE_FILETYPE_MISMATCH', $types[$image_data['type']][0], $extension); } return false; -- cgit v1.2.1 From 39d6180c6814996dde84cfcd8c0150bba37354ac Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 7 Apr 2015 16:19:36 +0200 Subject: [ticket/8672] Use fastImageSize in classes PHPBB3-8672 --- phpBB/phpbb/avatar/driver/remote.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/avatar/driver/remote.php') diff --git a/phpBB/phpbb/avatar/driver/remote.php b/phpBB/phpbb/avatar/driver/remote.php index d04f95905d..90443c9b4e 100644 --- a/phpBB/phpbb/avatar/driver/remote.php +++ b/phpBB/phpbb/avatar/driver/remote.php @@ -93,7 +93,7 @@ class remote extends \phpbb\avatar\driver\driver } // Get image dimensions - if (($width <= 0 || $height <= 0) && (($image_data = $this->imagesize->get_imagesize($url)) === false)) + if (($width <= 0 || $height <= 0) && (($image_data = $this->imagesize->getImageSize($url)) === false)) { $error[] = 'UNABLE_GET_IMAGE_SIZE'; return false; -- cgit v1.2.1 From 1af6f052d80e693d289258d490c1187a064093b9 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 14 Aug 2015 09:03:55 +0200 Subject: [ticket/13904] Load upload class using factory PHPBB3-13904 --- phpBB/phpbb/avatar/driver/remote.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'phpBB/phpbb/avatar/driver/remote.php') diff --git a/phpBB/phpbb/avatar/driver/remote.php b/phpBB/phpbb/avatar/driver/remote.php index 90443c9b4e..0526b9184e 100644 --- a/phpBB/phpbb/avatar/driver/remote.php +++ b/phpBB/phpbb/avatar/driver/remote.php @@ -114,13 +114,8 @@ class remote extends \phpbb\avatar\driver\driver return false; } - if (!class_exists('fileupload')) - { - include($this->phpbb_root_path . 'includes/functions_upload.' . $this->php_ext); - } - - $types = \fileupload::image_types(); - $extension = strtolower(\filespec::get_extension($url)); + $types = \phpbb\files\upload::image_types(); + $extension = strtolower(\phpbb\files\filespec::get_extension($url)); // Check if this is actually an image if ($file_stream = @fopen($url, 'r')) -- cgit v1.2.1