Strona zawiesza mi się po paru sekundach użytkownia

log błedów

http://www.kuklik.linuxpl.info/Galeria/vie....php?imageid=94
[Fri Jan 18 12:11:17 2013] [warn] [client 89.228.68.84] mod_fcgid: stderr: PHP Warning: imagecreatefromjpeg() [<a href='function.imagecreatefromjpeg'>function.imagecreatefromjpeg</a>]: gd-jpeg: JPEG library reports unrecoverable error: in /home/kuklik/domains/kuklik.linuxpl.info/public_html/Galeria/generators/preview.php on line 56, referer: http://www.kuklik.linuxpl.info/Galeria/vie....php?imageid=94
[Fri Jan 18 12:11:17 2013] [warn] [client 89.228.68.84] mod_fcgid: stderr: PHP Warning: imagecreatefromjpeg() [<a href='function.imagecreatefromjpeg'>function.imagecreatefromjpeg</a>]: '/tmp/klNbis' is not a valid JPEG file in /home/kuklik/domains/kuklik.linuxpl.info/public_html/Galeria/generators/preview.php on line 56, referer: http://www.kuklik.linuxpl.info/Galeria/vie....php?imageid=94
[Fri Jan 18 12:11:17 2013] [warn] [client 89.228.68.84] mod_fcgid: stderr: PHP Warning: imagecreatetruecolor() [<a href='function.imagecreatetruecolor'>function.imagecreatetruecolor</a>]: Invalid image dimensions in /home/kuklik/domains/kuklik.linuxpl.info/public_html/Galeria/generators/preview.php on line 57, referer: http://www.kuklik.linuxpl.info/Galeria/vie....php?imageid=94
[Fri Jan 18 12:11:17 2013] [warn] [client 89.228.68.84] mod_fcgid: stderr: PHP Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in /home/kuklik/domains/kuklik.linuxpl.info/public_html/Galeria/generators/preview.php on line 58, referer: http://www.kuklik.linuxpl.info/Galeria/vie....php?imageid=94
[Fri Jan 18 12:11:17 2013] [warn] [client 89.228.68.84] mod_fcgid: stderr: PHP Warning: Cannot modify header information - headers already sent by (output started at /home/kuklik/domains/kuklik.linuxpl.info/public_html/Galeria/generators/preview.php:24) in /home/kuklik/domains/kuklik.linuxpl.info/public_html/Galeria/generators/preview.php on line 61, referer: http://www.kuklik.linuxpl.info/Galeria/vie....php?imageid=94
[Fri Jan 18 12:11:17 2013] [warn] [client 89.228.68.84] mod_fcgid: stderr: PHP Warning: imagejpeg() expects parameter 1 to be resource, boolean given in /home/kuklik/domains/kuklik.linuxpl.info/public_html/Galeria/generators/preview.php on line 62, referer: http://www.kuklik.linuxpl.info/Galeria/vie....php?imageid=94
">
[Fri Jan 18 12:11:17 2013] [warn] [client 89.228.68.84] mod_fcgid: stderr: PHP Warning: file_get_contents(http://www.kuklik.linuxpl.info/Galeria/generators/original.php?imageid=94) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! in /home/kuklik/domains/kuklik.linuxpl.info/public_html/Galeria/generators/preview.php on line 24, referer: http://www.kuklik.linuxpl.info/Galeria/vie....php?imageid=94
[Fri Jan 18 12:11:17 2013] [warn] [client 89.228.68.84] mod_fcgid: stderr: PHP Warning: imagecreatefromjpeg() [<a href='function.imagecreatefromjpeg'>function.imagecreatefromjpeg</a>]: gd-jpeg: JPEG library reports unrecoverable error: in /home/kuklik/domains/kuklik.linuxpl.info/public_html/Galeria/generators/preview.php on line 56, referer: http://www.kuklik.linuxpl.info/Galeria/vie....php?imageid=94
[Fri Jan 18 12:11:17 2013] [warn] [client 89.228.68.84] mod_fcgid: stderr: PHP Warning: imagecreatefromjpeg() [<a href='function.imagecreatefromjpeg'>function.imagecreatefromjpeg</a>]: '/tmp/klNbis' is not a valid JPEG file in /home/kuklik/domains/kuklik.linuxpl.info/public_html/Galeria/generators/preview.php on line 56, referer: http://www.kuklik.linuxpl.info/Galeria/vie....php?imageid=94
[Fri Jan 18 12:11:17 2013] [warn] [client 89.228.68.84] mod_fcgid: stderr: PHP Warning: imagecreatetruecolor() [<a href='function.imagecreatetruecolor'>function.imagecreatetruecolor</a>]: Invalid image dimensions in /home/kuklik/domains/kuklik.linuxpl.info/public_html/Galeria/generators/preview.php on line 57, referer: http://www.kuklik.linuxpl.info/Galeria/vie....php?imageid=94
[Fri Jan 18 12:11:17 2013] [warn] [client 89.228.68.84] mod_fcgid: stderr: PHP Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in /home/kuklik/domains/kuklik.linuxpl.info/public_html/Galeria/generators/preview.php on line 58, referer: http://www.kuklik.linuxpl.info/Galeria/vie....php?imageid=94
[Fri Jan 18 12:11:17 2013] [warn] [client 89.228.68.84] mod_fcgid: stderr: PHP Warning: Cannot modify header information - headers already sent by (output started at /home/kuklik/domains/kuklik.linuxpl.info/public_html/Galeria/generators/preview.php:24) in /home/kuklik/domains/kuklik.linuxpl.info/public_html/Galeria/generators/preview.php on line 61, referer: http://www.kuklik.linuxpl.info/Galeria/vie....php?imageid=94
[Fri Jan 18 12:11:17 2013] [warn] [client 89.228.68.84] mod_fcgid: stderr: PHP Warning: imagejpeg() expects parameter 1 to be resource, boolean given in /home/kuklik/domains/kuklik.linuxpl.info/public_html/Galeria/generators/preview.php on line 62, referer: http://www.kuklik.linuxpl.info/Galeria/vie....php?imageid=94



Tu wklejam kod w którym wyrzuca warny:
  1. <?php
  2. require("../includes/global.php");
  3.  
  4. $sql = "SELECT * FROM " . $dbprefix . "images WHERE imageid = " . intval($_GET["imageid"]);
  5. $img = $db->execute($sql);
  6. if ($img->rows < 1){ notfound(); }
  7.  
  8. // support for non-GD users
  9. function default_thumb(){
  10. redirect("original.php?imageid=" . $img->fields["imageid"]);
  11. }
  12.  
  13. // check for GD support and fopen wrapters
  14. if ($gd === FALSE){ default_thumb(); }
  15. if (ini_get("allow_url_fopen") == 0){ default_thumb(); }
  16. if (ini_get("safe_mode") == 1){ default_thumb(); }
  17.  
  18. // work out thumbnail size
  19. $size_cng = intval($config["previewsize"]);
  20. if ($size_cng < 1){ default_thumb(); }
  21.  
  22. // create a temperory file
  23. $filepath = str_replace("preview", "original", "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"]);
  24. $imageFile = file_get_contents($filepath . "?imageid=" . $img->fields["imageid"]);
  25. $tmpname = tempnam("/tmp", "");
  26. $fp = fopen($tmpname, "w");
  27. fwrite($fp, $imageFile);
  28. fclose($fp);
  29.  
  30. // thumbnail size
  31. //$thumbsize = intval($config["thumbnailsize"]);
  32. $thumbsize = $size_cng;
  33. $thumbsize = ($thumbsize < 10) ? 100 : $thumbsize;
  34.  
  35. // create variables
  36. $size = GetImageSize($tmpname);
  37. if ($size[0] < $thumbsize && $size[1] < $thumbsize){
  38. $thumbnail_width = $size[0];
  39. $thumbnail_height = $size[1];
  40. } elseif($size[0] > $size[1]){
  41. $thumbnail_width = $thumbsize;
  42. $thumbnail_height = (int)($thumbsize * $size[1] / $size[0]);
  43. } else {
  44. $thumbnail_width = (int)($thumbsize * $size[0] / $size[1]);
  45. $thumbnail_height = $thumbsize;
  46. }
  47.  
  48. // create functions
  49. $function_suffix = $gd_function_suffix[$img->fields["format"]];
  50. $function_to_read = 'ImageCreateFrom' . $function_suffix;
  51. $function_to_write = 'Image' . $function_suffix;
  52.  
  53. if (!(function_exists($function_to_read))){ default_thumb(); }
  54. if (!(function_exists($function_to_write))){ default_thumb(); }
  55.  
  56. $source_handle = $function_to_read($tmpname);
  57. $destination_handle = ImageCreateTrueColor($thumbnail_width, $thumbnail_height);
  58. ImageCopyResampled($destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $size[0], $size[1]);
  59.  
  60. // output content
  61. Header("Content-type: " . $img->fields["format"]);
  62. $function_to_write($destination_handle);
  63.  
  64. // and delete the tmp line
  65. unlink($tmpname);
  66. ?>


Nie mogę rozgryźć jak zoptymalizować ten kod zeby nie było tych warnów a co za tym idzie zwiech strony..

link do strony : http://www.kuklik.linuxpl.info/Galeria

Czy ktoś może pomóc?