mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
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
This commit is contained in:
parent
dd9ad539fd
commit
c307c5021a
1 changed files with 22 additions and 8 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Reference in a new issue