posts WHERE post_content LIKE ('%get_results($sql); if( $posts ) { $img_nums = 0; echo ''; } } function generate_thumb_image($img_src, $thumb_width, $thumb_height){ $img_name = get_img_name($img_src); $img_thumb = get_thumb_img($img_name); if(file_exists($img_thumb) ) { return 1; } list($im_width, $im_height, $type) = @getimagesize($img_src); switch ($type){ case 1: $im = @imageCreateFromGIF($img_src); break; case 2: $im = @imageCreateFromJPEG($img_src); break; case 3: $im = @imageCreateFromPNG($img_src); break; default: return 0; } if($thumb_width == 0 && $thumb_height == 0){ $thumb_height == 50; $thumb_width = $thumb_height / $im_height * $im_width; } elseif($thumb_width == 0){ $thumb_width = $thumb_height / $im_height * $im_width; } elseif( $thumb_height == 0){ $thumb_height = $thumb_width / $im_width * $im_height; } $to = imagecreatetruecolor($thumb_width, $thumb_height); if(!$to) { return 0; } if(!imagecopyresampled($to, $im, 0, 0, 0, 0, $thumb_width, $thumb_height, $im_width, $im_height)) { return 0; } switch ($type){ case 1: imageGIF($to, $img_thumb); break; case 2: imageJPEG($to, $img_thumb); break; case 3: imagePNG($to, $img_thumb); break; default: return 0; } imageDestroy($im); return 1; } function get_thumb_img($img_name){ global $thumn_path, $prefix; return $thumn_path.$prefix.$img_name; } function get_img_name($img_src){ return substr($img_src,strrpos($img_src,"/")+1); } ?>