mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08: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)
|
switch ($type)
|
||||||
{
|
{
|
||||||
|
// GIF
|
||||||
case 1:
|
case 1:
|
||||||
$new_type = ($format & IMG_GIF) ? IMG_GIF : 0;
|
$new_type = ($format & IMG_GIF) ? IMG_GIF : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// JPG, JPC, JP2
|
||||||
case 2:
|
case 2:
|
||||||
case 9:
|
case 9:
|
||||||
case 10:
|
case 10:
|
||||||
case 11:
|
case 11:
|
||||||
case 12:
|
case 12:
|
||||||
$new_type = ($format & IMG_JPG) ? IMG_JPG : 0;
|
$new_type = ($format & IMG_JPG) ? IMG_JPG : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// PNG
|
||||||
case 3:
|
case 3:
|
||||||
$new_type = ($format & IMG_PNG) ? IMG_PNG : 0;
|
$new_type = ($format & IMG_PNG) ? IMG_PNG : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// BMP, WBMP
|
||||||
case 6:
|
case 6:
|
||||||
case 15:
|
case 15:
|
||||||
$new_type = ($format & IMG_WBMP) ? IMG_WBMP : 0;
|
$new_type = ($format & IMG_WBMP) ? IMG_WBMP : false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -532,22 +536,28 @@ function create_thumbnail($source, $destination, $mimetype)
|
||||||
|
|
||||||
if ($type['gd'])
|
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'])
|
switch ($type['format'])
|
||||||
{
|
{
|
||||||
case IMG_GIF:
|
case IMG_GIF:
|
||||||
$image = imagecreatefromgif($source);
|
$image = @imagecreatefromgif($source);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IMG_JPG:
|
case IMG_JPG:
|
||||||
$image = imagecreatefromjpeg($source);
|
$image = @imagecreatefromjpeg($source);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IMG_PNG:
|
case IMG_PNG:
|
||||||
$image = imagecreatefrompng($source);
|
$image = @imagecreatefrompng($source);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IMG_WBMP:
|
case IMG_WBMP:
|
||||||
$image = imagecreatefromwbmp($source);
|
$image = @imagecreatefromwbmp($source);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,6 +593,10 @@ function create_thumbnail($source, $destination, $mimetype)
|
||||||
|
|
||||||
imagedestroy($new_image);
|
imagedestroy($new_image);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists($destination))
|
if (!file_exists($destination))
|
||||||
|
|
Loading…
Add table
Reference in a new issue