#11
а почему у меня картинка неотображается???
такая бедаэто попытка вывести рейтинг IMDB )
View attachment 1411View attachment 1412
это попытка вывести рейтинг IMDB )
<?php /* Мини-баннер рейтинга фильма с Kinopoisk.ru by ab00 e-mail: [email protected] */ define ( 'RATING_ROOT_DIR', dirname ( __FILE__ ) ); $site_name = "bit.bks-tv.net"; //Сюда вписываем название вашего сайта. $filmurl = htmlspecialchars(trim($_REQUEST['url'])); $filmurl_array = parse_url($filmurl); $film_id = str_replace("/level/1/film/","", $filmurl_array['path']); $film_id = str_replace("/","", $film_id); $filmurl = "http://www.kinopoisk.ru/level/1/film/" . $film_id . "/"; if($filmurl_array['host'] == "www.kinopoisk.ru") { if(!file_exists( RATING_ROOT_DIR . "/kinopoisk/" . $film_id .".png" ) OR (time() - filemtime( RATING_ROOT_DIR . "/kinopoisk/" . $film_id .".png")) > 86400 ) // 86400 время в секундах через которое будет происходить обновление. { $xml = simplexml_load_file("http://www.kinopoisk.ru/rating/".$film_id.".xml"); if($xml->kp_rating != 0) { $kp_rating = substr($xml->kp_rating, 0, 3); /* preg_match($xml,'#<kp_rating num_vote="(:?.*?)?">(.*?)<#si',$matches); $kp_rating=$matches[0]; */ //echo $kp_rating; $kp_votes = number_format(intval($xml->kp_rating['num_vote'])); $image = imagecreatefrompng( RATING_ROOT_DIR . "/kpsrc/back.png"); $star = imagecreatefrompng( RATING_ROOT_DIR . "/kpsrc/star.png"); $font = RATING_ROOT_DIR . "/kpsrc/Intermosaic.ttf"; $color = imagecolorallocate($image, 190, 190, 190); $rating_font = imagecreatefrompng( RATING_ROOT_DIR . "/kpsrc/rating_font.png"); $vote_font = imagecreatefrompng( RATING_ROOT_DIR . "/kpsrc/votes_font.png"); $rating = explode(".", $kp_rating); switch(end($rating)) { case "0": $symbol = 0; break; case "1": $symbol = 0; $plus = 5; break; case "2": $symbol = 0; break; case "3": $symbol = 0; break; case "4": $symbol = 0; break; case "5": $symbol = 50; break; case "6": $symbol = 50; break; case "7": $symbol = 50; break; case "8": $symbol = 50; break; case "9": $symbol = 50; break; } switch(reset($rating)) { case "0": $symbol2 = 0; break; case "1": $symbol2 = 10;/* $plus2 = 5;*/ break; case "2": $symbol2 = 20; break; case "3": $symbol2 = 30; break; case "4": $symbol2 = 40; break; case "5": $symbol2 = 50; break; case "6": $symbol2 = 60; break; case "7": $symbol2 = 70; break; case "8": $symbol2 = 80; break; case "9": $symbol2 = 90; break; } imagecopy($image, $rating_font, 93+$plus, 4, $symbol, 0, 10, 10); imagecopy($image, $rating_font, 88+$plus, 4, 100, 0, 10, 10); imagecopy($image, $rating_font, 76+$plus+$plus2, 4, $symbol2, 0, 10, 10); $symbol_count = strlen($kp_votes); for ($i = 0, $next = 105 - $symbol_count*5; $i != $symbol_count; $i++, $next = $next + 5) { $symbol = substr($kp_votes, $i, 1); if($symbol == ",") $symbol = 40; else $symbol = intval($symbol)*4; imagecopy($image, $vote_font, $next, 18, $symbol, 0, 4, 6); } imagettftext($image, 6, 0, 4, 45, $color, $font, $site_name); for ($i = 0, $next = 0; $i != (int)$kp_rating; $i++, $next = $next + 12) { imagecopy($image, $star, $next, 27, 0, 0, 10, 10); } $half_rating = end(explode(".", $kp_rating)); imagecopy($image, $star, $next, 27, 0, 0, $half_rating, 11); imagepng($image, RATING_ROOT_DIR . "/kinopoisk/" . $film_id . ".png",9); } else { $image = imagecreatefrompng( RATING_ROOT_DIR . "/kpsrc/na_kp.png"); } } else { $image = imagecreatefrompng( RATING_ROOT_DIR . "/kinopoisk/". $film_id .".png"); } # Display the image header("Content-type: image/png"); imagepng($image); } else { $image = imagecreatefrompng( RATING_ROOT_DIR . "/kpsrc/na_kp.png"); header("Content-type: image/png"); imagepng($image); } imagedestroy ($image); ?>
$film_id = str_replace("/level/1/film/","", $filmurl_array['path']);
$film_id = str_replace("/","", $film_id);
$filmurl = "http://www.kinopoisk.ru/level/1/film/" . $film_id . "/"; preg_match('/http:\/\/[w]{0,3}[.]?kinopoisk.ru.*?film\/(\d*)/isu', $filmurl, $id);
$film_id = $id[1];
$filmurl = "http://www.kinopoisk.ru/film/" . $film_id . "/";