6) show_error_image("The request can have maximum 6 characters"); if($query == 'game'){ function get_xml($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_ENCODING, ""); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8"); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120); curl_setopt($ch, CURLOPT_TIMEOUT, 120); $content = curl_exec($ch); curl_close($ch); preg_match("!(.*?)!si", $content, $contens); $content = $contens[1]; return $content; } $content = get_xml("http://www.igropoisk.com/rating/{$id}.xml"); $pic = imagecreatefrompng(RATING_DIR."game.png"); $color = ImageColorAllocate($pic, 255, 255, 255); imagealphablending($pic, true); imagestring($pic, 3, 6, 19, $content, $color); } elseif ($query == 'film'){ function subX($dbl){ switch ($dbl) { case 1: return 9; break; case 2: return 8; break; case 3: return 7; break; case 4: return 6; break; case 5: return 5; break; case 6: return 4; break; case 7: return 4; break; case 8: return 3; break; case 9: return 2; break; } } $rating = file_get_contents("http://rating.kinopoisk.ru/{$id}.xml"); preg_match("/kp_rating num_vote=['\"](.+)['\"]>(.+)(.+) 0) ? imagecreatefrompng(RATING_DIR."rating.png") : imagecreatefrompng(RATING_DIR."kinopoisk.png"); $star = imagecreatefrompng(RATING_DIR."star.png"); $color = ImageColorAllocate($pic, 0, 0, 0); $colorDown = ImageColorAllocate($pic, 120, 120, 120); imagealphablending($pic, true); ($kino_rating > 10) ? $kino_rating = 10 : ""; imagestring($pic, 3, 5, 19, $kino_rating, $color); imagestring($pic, 1, 5+(strlen($kino_rating)+1)*6, 23, $kino_votes, $colorDown); if($imdb_rating > 0) { ($imdb_rating > 10) ? $imdb_rating = 10 : ""; imagestring($pic, 3, 191 - (strlen($imdb_rating)-1) * 7, 1, $imdb_rating, $color); imagestring($pic, 1, 188 - (strlen($imdb_votes)-2) * 5, 17, $imdb_votes, $colorDown); for ($i = 0, $next = 0; $i != (int)$imdb_rating; $i++, $next = $next + 10) { imagecopy($pic, $star, 109 + $next, 26, 0, 0, imagesx($star), imagesy($star)); } $imdb_rating = explode(".", $imdb_rating); if(is_array($imdb_rating) and $imdb_rating[1] != 0) { $dbl = (int)$imdb_rating[1]; imagecopy($pic, $star, 109 + $next, 26, 0, 0, imagesx($star) - subX($dbl), imagesy($star)); } } } imagesavealpha($pic, true); imagepng($pic); imagedestroy($pic); $cache = ob_get_contents(); ob_end_clean(); echo $cache; $fp = @fopen ($file, "w"); @fwrite($fp, $cache); @fclose($fp); ?>