diff options
author | Marc Alexander <admin@m-a-styles.de> | 2015-02-08 20:46:14 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2015-04-24 13:31:36 +0200 |
commit | 2fa99602c6f6431e99468ca13f4a58344a401c24 (patch) | |
tree | 0be2c3641e6f9b60d69130793484c8dfff5f932b /phpBB/includes/functions_upload.php | |
parent | 746a33b57bf9bba645c826b596fbc54ee13d1954 (diff) | |
download | forums-2fa99602c6f6431e99468ca13f4a58344a401c24.tar forums-2fa99602c6f6431e99468ca13f4a58344a401c24.tar.gz forums-2fa99602c6f6431e99468ca13f4a58344a401c24.tar.bz2 forums-2fa99602c6f6431e99468ca13f4a58344a401c24.tar.xz forums-2fa99602c6f6431e99468ca13f4a58344a401c24.zip |
[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
Diffstat (limited to 'phpBB/includes/functions_upload.php')
-rw-r--r-- | phpBB/includes/functions_upload.php | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php index 21a6de7a41..f605f89d4d 100644 --- a/phpBB/includes/functions_upload.php +++ b/phpBB/includes/functions_upload.php @@ -400,28 +400,28 @@ class filespec { $this->width = $this->height = 0; - if (($this->image_info = @getimagesize($this->destination_file)) !== false) - { - $this->width = $this->image_info[0]; - $this->height = $this->image_info[1]; + // Get imagesize class + $imagesize = new \phpbb\upload\imagesize(); - if (!empty($this->image_info['mime'])) - { - $this->mimetype = $this->image_info['mime']; - } + $this->image_info = $imagesize->get_imagesize($this->destination_file, $this->mimetype); + + if ($this->image_info !== false) + { + $this->width = $this->image_info['width']; + $this->height = $this->image_info['height']; // Check image type $types = fileupload::image_types(); - if (!isset($types[$this->image_info[2]]) || !in_array($this->extension, $types[$this->image_info[2]])) + if (!isset($types[$this->image_info['type']]) || !in_array($this->extension, $types[$this->image_info['type']])) { - if (!isset($types[$this->image_info[2]])) + if (!isset($types[$this->image_info['type']])) { - $this->error[] = sprintf($user->lang['IMAGE_FILETYPE_INVALID'], $this->image_info[2], $this->mimetype); + $this->error[] = sprintf($user->lang['IMAGE_FILETYPE_INVALID'], $this->image_info['type'], $this->mimetype); } else { - $this->error[] = sprintf($user->lang['IMAGE_FILETYPE_MISMATCH'], $types[$this->image_info[2]][0], $this->extension); + $this->error[] = sprintf($user->lang['IMAGE_FILETYPE_MISMATCH'], $types[$this->image_info['type']][0], $this->extension); } } |