From c307c5021a63335b43c7eec8b9f3cc593573447f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 7 Jun 2006 08:35:13 +0000 Subject: [PATCH] check if supported gd image type matches the uploaded image type - if not, thumbnails are not created. git-svn-id: file:///svn/phpbb/trunk@6016 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_posting.php | 30 ++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 53f11651a3..0c4e5c9afb 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -445,25 +445,29 @@ function get_supported_image_types($type = false) { switch ($type) { + // GIF case 1: - $new_type = ($format & IMG_GIF) ? IMG_GIF : 0; + $new_type = ($format & IMG_GIF) ? IMG_GIF : false; break; + // JPG, JPC, JP2 case 2: case 9: case 10: case 11: case 12: - $new_type = ($format & IMG_JPG) ? IMG_JPG : 0; + $new_type = ($format & IMG_JPG) ? IMG_JPG : false; break; + // PNG case 3: - $new_type = ($format & IMG_PNG) ? IMG_PNG : 0; + $new_type = ($format & IMG_PNG) ? IMG_PNG : false; break; + // BMP, WBMP case 6: case 15: - $new_type = ($format & IMG_WBMP) ? IMG_WBMP : 0; + $new_type = ($format & IMG_WBMP) ? IMG_WBMP : false; break; } } @@ -532,22 +536,28 @@ function create_thumbnail($source, $destination, $mimetype) if ($type['gd']) { + // If the type is not supported, we are not able to create a thumbnail + if ($type['format'] === false) + { + return false; + } + switch ($type['format']) { case IMG_GIF: - $image = imagecreatefromgif($source); + $image = @imagecreatefromgif($source); break; case IMG_JPG: - $image = imagecreatefromjpeg($source); + $image = @imagecreatefromjpeg($source); break; case IMG_PNG: - $image = imagecreatefrompng($source); + $image = @imagecreatefrompng($source); break; case IMG_WBMP: - $image = imagecreatefromwbmp($source); + $image = @imagecreatefromwbmp($source); break; } @@ -583,6 +593,10 @@ function create_thumbnail($source, $destination, $mimetype) imagedestroy($new_image); } + else + { + return false; + } } if (!file_exists($destination))