diff options
author | Craig Andrews <candrews@integralblue.com> | 2010-03-11 20:12:32 -0500 |
---|---|---|
committer | Craig Andrews <candrews@integralblue.com> | 2010-03-11 20:12:32 -0500 |
commit | d6e0640251b91928fc65324438000d91f12cecf0 (patch) | |
tree | 32e90eb253bcdb4ed2b40cb97697113563bd63d6 /lib | |
parent | 74fd75555669cfe0a53b6cbc50a425e6f9f093d1 (diff) |
move image type checking to constructor, so checking will be done in all cases
check if the relevant image handling function exists when deciding if the image type is supported
Diffstat (limited to 'lib')
-rw-r--r-- | lib/imagefile.php | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/imagefile.php b/lib/imagefile.php index 7b0479455..2134623b1 100644 --- a/lib/imagefile.php +++ b/lib/imagefile.php @@ -60,6 +60,21 @@ class ImageFile $this->filepath = $filepath; $info = @getimagesize($this->filepath); + + if (!( + ($info[2] == IMAGETYPE_GIF && function_exists('imagecreatefromgif')) || + ($info[2] == IMAGETYPE_JPEG && function_exists('imagecreatefromjpeg')) || + $info[2] == IMAGETYPE_BMP || + ($info[2] == IMAGETYPE_WBMP && function_exists('imagecreatefromwbmp')) || + ($info[2] == IMAGETYPE_XBM && function_exists('imagecreatefromxbm')) || + ($info[2] == IMAGETYPE_XPM && function_exists('imagecreatefromxpm')) || + ($info[2] == IMAGETYPE_PNG && function_exists('imagecreatefrompng')))) { + + @unlink($_FILES[$param]['tmp_name']); + throw new Exception(_('Unsupported image file format.')); + return; + } + $this->type = ($info) ? $info[2]:$type; $this->width = ($info) ? $info[0]:$width; $this->height = ($info) ? $info[1]:$height; @@ -97,19 +112,6 @@ class ImageFile return; } - if ($info[2] !== IMAGETYPE_GIF && - $info[2] !== IMAGETYPE_JPEG && - $info[2] !== IMAGETYPE_BMP && - $info[2] !== IMAGETYPE_WBMP && - $info[2] !== IMAGETYPE_XBM && - $info[2] !== IMAGETYPE_XPM && - $info[2] !== IMAGETYPE_PNG) { - - @unlink($_FILES[$param]['tmp_name']); - throw new Exception(_('Unsupported image file format.')); - return; - } - return new ImageFile(null, $_FILES[$param]['tmp_name']); } |