| codefreek |
07-07-2008 02:16 PM |
This is the code by Noia and still the image is buging!
PHP Code:
<?php
//////////////////////////////////////////////////////////// // DECLARE CONFIGURATION HERE
//only use when needed! //ini_set("user_agent","Internet Explorer");
//Edit here for your rss link $location = "http://youtube.com/rss/global/top_rated.rss";
$limit = 0; // use 0 for no limit $desclimit = 120; // use 0 for no limit
////////////////////////////////////////////////////////// // DECLARE FUNCTION HERE
function fetchRSSFeed($location,$limit = 0, $desclimit = 0) {
$contents = file_get_contents($location); $xml = new SimpleXMLElement($contents); // var_dump($xml); $desclimit = ($desclimit != 0 && $desclimit < 3 ? $desclimit +3 : $desclimit); // Sanity check $i = 0; $str = "";
$str .= "<ol>";
foreach($xml->channel->item as $item) { //$img = preg_replace('/^.*?(<img [^>]+>).*$/is','\1',$item->description); // Uncomment if you need full <img /> tag $imgsrc = preg_replace('/^.*?(<img [^>]*?src="([^"]+)"[^>]*>).*$/is','\2',$item->description); $tmp_desc = preg_replace('#.*?(<p>.+?</p>).*#is','\1',$item->description); $tmp_desc = trim(preg_replace('#(<[^>]+>|http://\S+|www\.\S+\.\S{2,3}\S+)#','',$tmp_desc)); $str .= "<li>"; $str .= "<a href='".$item->link."' title='".$item->title."'>"; $str .= $item->title; $str .= "</a>"; $str .= $imgsrc; $str .= "<p>". ((($desclimit != 0) && (strlen($tmp_desc) > $desclimit)) ? substr($tmp_desc,0,$desclimit-3)."..." : $tmp_desc) ."</p>"; $str .= "</li>"; if ($limit != 0 && $i == $limit) break; } $str .= "</ol>";
return $str;
}
//////////////////////////////////////////////////////////// // USE FUNCTION
print fetchRSSFeed($location,$limit,$desclimit);
// THE END
?>
WORKING!
|