View Single Post
  #1 (permalink)  
Old 10-03-06, 04:08 PM
APuppyDog APuppyDog is offline
Newbie Coder
 
Join Date: Jul 2003
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
help with error messages.. please

Hello, In my cPanel error logs, i see a lt of repeated errors like the one below. I have pasted the makethumb1.php code as well.. can anyone figure out why i'm getting this error message?

error:
Quote:
[Tue Oct 3 20:45:41 2006] [error] PHP Warning: Division by zero in /home/bad/public_html/car/makethumb1.php on line 315
[Tue Oct 3 20:45:41 2006] [error] PHP Warning: Division by zero in /home/bad/public_html/car/makethumb1.php on line 311
[Tue Oct 3 20:45:35 2006] [error] PHP Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 347
[Tue Oct 3 20:45:35 2006] [error] PHP Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 345
[Tue Oct 3 20:45:35 2006] [error] PHP Warning: imagestring(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 343
[Tue Oct 3 20:45:35 2006] [error] PHP Warning: imagefilledrectangle(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 339
[Tue Oct 3 20:45:35 2006] [error] PHP Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 337
[Tue Oct 3 20:45:35 2006] [error] PHP Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 335
[Tue Oct 3 20:45:35 2006] [error] PHP Warning: imagecreate() [<a href='function.imagecreate'>function.imagecreate</a>]: Invalid image dimensions in /home/bad/public_html/car/makethumb1.php on line 333
[Tue Oct 3 20:45:35 2006] [error] PHP Warning: Division by zero in /home/bad/public_html/car/makethumb1.php on line 315
[Tue Oct 3 20:45:35 2006] [error] PHP Warning: Division by zero in /home/bad/public_html/car/makethumb1.php on line 311
[Tue Oct 3 20:45:29 2006] [error] PHP Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 347
[Tue Oct 3 20:45:29 2006] [error] PHP Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 345
[Tue Oct 3 20:45:29 2006] [error] PHP Warning: imagestring(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 343
[Tue Oct 3 20:45:29 2006] [error] PHP Warning: imagefilledrectangle(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 339
[Tue Oct 3 20:45:29 2006] [error] PHP Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 337
[Tue Oct 3 20:45:29 2006] [error] PHP Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/bad/public_html/car/makethumb1.php on line 335
[Tue Oct 3 20:45:29 2006] [error] PHP Warning: imagecreate() [<a href='function.imagecreate'>function.imagecreate</a>]: Invalid image dimensions in /home/bad/public_html/car/makethumb1.php on line 333
makethumb1.php:
PHP Code:

<?


## 

$code 'function gd_info() {

       $array = Array(

                       "GD Version" => "",

                       "FreeType Support" => 0,

                       "FreeType Support" => 0,

                       "FreeType Linkage" => "",

                       "T1Lib Support" => 0,

                       "GIF Read Support" => 0,

                       "GIF Create Support" => 0,

                       "JPG Support" => 0,

                       "PNG Support" => 0,

                       "WBMP Support" => 0,

                       "XBM Support" => 0

                     );

       $gif_support = 0;



       ob_start();

       eval("phpinfo();");

       $info = ob_get_contents();

       ob_end_clean();

     

       foreach(explode("\n", $info) as $line) {

           if(strpos($line, "GD Version")!==false)

               $array["GD Version"] = trim(str_replace("GD Version", "", strip_tags($line)));

           if(strpos($line, "FreeType Support")!==false)

               $array["FreeType Support"] = trim(str_replace("FreeType Support", "", strip_tags($line)));

           if(strpos($line, "FreeType Linkage")!==false)

               $array["FreeType Linkage"] = trim(str_replace("FreeType Linkage", "", strip_tags($line)));

           if(strpos($line, "T1Lib Support")!==false)

               $array["T1Lib Support"] = trim(str_replace("T1Lib Support", "", strip_tags($line)));

           if(strpos($line, "GIF Read Support")!==false)

               $array["GIF Read Support"] = trim(str_replace("GIF Read Support", "", strip_tags($line)));

           if(strpos($line, "GIF Create Support")!==false)

               $array["GIF Create Support"] = trim(str_replace("GIF Create Support", "", strip_tags($line)));

           if(strpos($line, "GIF Support")!==false)

               $gif_support = trim(str_replace("GIF Support", "", strip_tags($line)));

           if(strpos($line, "JPG Support")!==false)

               $array["JPG Support"] = trim(str_replace("JPG Support", "", strip_tags($line)));

           if(strpos($line, "PNG Support")!==false)

               $array["PNG Support"] = trim(str_replace("PNG Support", "", strip_tags($line)));

           if(strpos($line, "WBMP Support")!==false)

               $array["WBMP Support"] = trim(str_replace("WBMP Support", "", strip_tags($line)));

           if(strpos($line, "XBM Support")!==false)

               $array["XBM Support"] = trim(str_replace("XBM Support", "", strip_tags($line)));

       }

       

       if($gif_support==="enabled") {

           $array["GIF Read Support"]  = 1;

           $array["GIF Create Support"] = 1;

       }



       if($array["FreeType Support"]==="enabled"){

           $array["FreeType Support"] = 1;    }

 

       if($array["T1Lib Support"]==="enabled")

           $array["T1Lib Support"] = 1;    

       

       if($array["GIF Read Support"]==="enabled"){

           $array["GIF Read Support"] = 1;    }

 

       if($array["GIF Create Support"]==="enabled")

           $array["GIF Create Support"] = 1;    



       if($array["JPG Support"]==="enabled")

           $array["JPG Support"] = 1;

           

       if($array["PNG Support"]==="enabled")

           $array["PNG Support"] = 1;

           

       if($array["WBMP Support"]==="enabled")

           $array["WBMP Support"] = 1;

           

       if($array["XBM Support"]==="enabled")

           $array["XBM Support"] = 1;

       

       return $array;

   }'
;



function 
gd_version() {

    global 
$code;

    if (empty(
$result)) {

        if (!
function_exists('gd_info')) $gd_info = eval($code);

        else 
$gd_info gd_info();

        

        if (
substr($gd_info['GD Version'], 0strlen('bundled (')) == 'bundled (') {

            
$result = (float) substr($gd_info['GD Version'], strlen('bundled ('), 3); 

        } else {

            
$result = (float) substr($gd_info['GD Version'], 03); 

        }

    }

    return 
$result;

}



function 
ImageCreateFunction($x_size$y_size) {

    
$ImageCreateFunction 'ImageCreate';

    if (
gd_version() >= 2.0) {

        
$ImageCreateFunction 'ImageCreateTrueColor';

    }

    if (!
function_exists($ImageCreateFunction)) {

        return 
FALSE;

    }

    return 
$ImageCreateFunction($x_size$y_size);

}



function 
ImageCopyFunction($dst_im$src_im$dstX$dstY$srcX$srcY$dstW$dstH$srcW$srcH) {

    
$ImageCopyFunction 'ImageCopyResized';

    if (
gd_version() >= 2.0) {

        
$ImageCopyFunction 'ImageCopyResampled';

    }

    if (!
function_exists($ImageCopyFunction)) {

        return 
FALSE;

    }

    return 
$ImageCopyFunction($dst_im$src_im$dstX$dstY$srcX$srcY$dstW$dstH$srcW$srcH);

}



function 
generateThumb($sourceFilename$thumb_x$square=FALSE$border=FALSE) {

    
$image_info getimagesize($sourceFilename);

    
$image_width $image_info[0];

    
$image_height $image_info[1];

    

    if (
$image_width<$thumb_x$thumb_x $image_width;

    

    if (
$square) { 

        
$thumb_image_x 468;

        
$thumb_image_y 60;

    }



    
// workaround for v1.6.2 where the GIF images arent recognized.

    
$ImgCreate 'ImageCreateFromJPEG';

    switch (
$image_info['mime']) {

        case 
'image/gif':

            
$ImgCreate 'ImageCreateFromGIF';

            break;

        case 
'image/jpeg':

            
$ImgCreate 'ImageCreateFromJPEG';

            break;

        case 
'image/png':

            
$ImgCreate 'ImageCreateFromPNG';

            break;

    }



    if (!
$square) {

        
$shrinkratio $image_width/$thumb_x;

        
$thumb_y $image_height/$shrinkratio;

        
$start_x 0;

        
$start_y 0;

    } else if (
$square) {

        if (
$image_width>$image_height) {

            
$shrinkratio $image_width/$thumb_x;

            
$thumb_y $image_height/$shrinkratio;

            
$start_x 0;

            
$start_y = (abs($thumb_image_y $thumb_y)) / 2;

        } else if (
$image_width<=$image_height) {

            
$shrinkratio $image_height/$thumb_x;

            
$thumb_y =$thumb_x;

            
$thumb_x $image_width/$shrinkratio;

            
$start_y 0;

            
$start_x = (abs($thumb_image_x $thumb_x)) / 2;

        }

    }

    

    
$thumbInput = @$ImgCreate($sourceFilename); 



       if (!
$thumbInput) { /* See if it failed */

        
$thumbInput  imagecreate($thumb_x$thumb_y); /* Create a blank image */

           
$bgc imagecolorallocate($thumbInput255255255);

           
$tc  imagecolorallocate($thumbInput000);

           
imagefilledrectangle($thumbInput0015030$bgc);

           
/* Output an errmsg */

           
imagestring($thumbInput155"Error loading $sourceFilename"$tc);

        
imagejpeg($thumbInput,'',90);

        
imagedestroy($thumbInput);

       } else {

        if (
$square) {

            
$thumbOutput ImageCreateFunction($thumb_image_x,$thumb_image_y) or die("couldn't create image"); 

            
$border_x $thumb_image_x 1;

            
$border_y $thumb_image_y 1;

        } else {

            
$thumbOutput ImageCreateFunction($thumb_x,$thumb_y) or die("couldn't create image"); 

            
$border_x $thumb_x 1;

            
$border_y $thumb_y 1;

        }

    

        
$background_color imagecolorallocate($thumbOutput255255255);

        
imagefill($thumbOutput,0,0,$background_color);

        
ImageCopyFunction($thumbOutput,$thumbInput,$start_x,$start_y,0,0,$thumb_x,$thumb_y,$image_width,$image_height) or die("coudln't resize image"); 

        if (
$border) {

            
$border_color imagecolorallocate($thumbOutput000);

            
imagerectangle($thumbOutput,0,0,$border_x,$border_y,$border_color) or die("couldn't create image"); 

        }

    

        
imagejpeg($thumbOutput,'',90);

        
imagedestroy($thumbOutput);

    }

}



### here we call the function, and we get the GET parameters;

$pic $_GET['pic'];

$thumbWidth $_GET['w'];

$isSquare = ($_GET['sq']=='Y')? TRUE FALSE;

$isBorder = ($_GET['b']=='Y') ? TRUE FALSE;



## if check is submitted then do the queries needed, otherwise create the pics

if ($_GET['check']=="phpinfo") {

    
phpinfo();

} else if (
$_GET['check']=="gdinfo") {

    
gd_info();

} if (
$_GET['check']=="") {

    if (isset(
$pic)&&$thumbWidth>0) {

        
header("Content-type: image/jpeg");

        
generateThumb($pic$thumbWidth$isSquare$isBorder);

    } else if (!isset(
$pic)) {

        echo 
"<strong>ERROR:</strong> No image submitted";

    } else if (
$thumbWidth<=0) {

        echo 
"<strong>ERROR:</strong> Invalid resizing option";

    }

}

?>
Reply With Quote