Browse Source

Bug fix for invalid image detection.

pull/40/head
Savetheinternet 14 years ago
parent
commit
2eddc7a4ee
  1. 22
      inc/functions.php

22
inc/functions.php

@ -356,23 +356,37 @@
}
function createimage($type, $source_pic) {
$image = false;
switch($type) {
case 'jpg':
case 'jpeg':
return imagecreatefromjpeg($source_pic);
if(!$image = @imagecreatefromjpeg($source_pic)) {
unlink($source_pic);
error(ERR_INVALIDIMG);
}
break;
case 'png':
return imagecreatefrompng($source_pic);
if(!$image = @imagecreatefrompng($source_pic)) {
unlink($source_pic);
error(ERR_INVALIDIMG);
}
break;
case 'gif':
return imagecreatefromgif($source_pic);
if(!$image = @imagecreatefromgif($source_pic)) {
unlink($source_pic);
error(ERR_INVALIDIMG);
}
break;
case 'bmp':
return imagecreatefrombmp($source_pic);
if(!$image = @imagecreatefrombmp($source_pic)) {
unlink($source_pic);
error(ERR_INVALIDIMG);
}
break;
default:
error('Unknwon file extension.');
}
return $image;
}
function resize($src, $width, $height, $destination_pic, $max_width, $max_height) {

Loading…
Cancel
Save