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/message_parser.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/message_parser.php')
-rw-r--r-- | phpBB/includes/message_parser.php | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 8353ae6843..3d263748cb 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -339,22 +339,23 @@ class bbcode_firstpass extends bbcode if ($config['max_' . $this->mode . '_img_height'] || $config['max_' . $this->mode . '_img_width']) { - $stats = @getimagesize(htmlspecialchars_decode($in)); + $imagesize = new \phpbb\upload\imagesize(); + $size_info = $imagesize->get_imagesize(htmlspecialchars_decode($in)); - if ($stats === false) + if ($size_info === false) { $error = true; $this->warn_msg[] = $user->lang['UNABLE_GET_IMAGE_SIZE']; } else { - if ($config['max_' . $this->mode . '_img_height'] && $config['max_' . $this->mode . '_img_height'] < $stats[1]) + if ($config['max_' . $this->mode . '_img_height'] && $config['max_' . $this->mode . '_img_height'] < $size_info['height']) { $error = true; $this->warn_msg[] = $user->lang('MAX_IMG_HEIGHT_EXCEEDED', (int) $config['max_' . $this->mode . '_img_height']); } - if ($config['max_' . $this->mode . '_img_width'] && $config['max_' . $this->mode . '_img_width'] < $stats[0]) + if ($config['max_' . $this->mode . '_img_width'] && $config['max_' . $this->mode . '_img_width'] < $size_info['width']) { $error = true; $this->warn_msg[] = $user->lang('MAX_IMG_WIDTH_EXCEEDED', (int) $config['max_' . $this->mode . '_img_width']); |