View Single Post
Old 07-07-2008, 02:16 PM   #3 (permalink)
codefreek
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Application Error 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 != && $desclimit $desclimit +$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 != && $i == $limit)
        break;
    }
    
$str .= "</ol>";

    return 
$str;

}

////////////////////////////////////////////////////////////
// USE FUNCTION

print fetchRSSFeed($location,$limit,$desclimit);

// THE END

?>
WORKING!

Last edited by codefreek : 07-07-2008 at 02:32 PM. Reason: CODE WORKING NOW!
codefreek is offline  
Reply With Quote