multiple rss feeds and geeklog

Ok, working again with kellan on doing multiple rss feeds for the new media alliance site. Got a good solution, or at least a hack which allows three different rss feeds to be displayed. Joy! I'm doing this in a geeklog block via lib custom.

function phpblock_getnews() {
require_once '/home/mediaalliance/public_html/scripts/magpie/rss_fetch.inc';

// Set how often we want to update the feed (in hours)
$updateTime = 0;

// Open newsfeed page
$filename = "rssFeed.rdf";

// Check the current time
$rawNowTime = time();

// Check the last time we modified the newsfeed page
$rawModifiedTime = filemtime($filename);

// Has it been long enough since we last updated it?
if ( (($rawNowTime - $rawModifiedTime) / 60 / 60) > $updateTime)
{
// Open the newsfeed file now so no one else grabs it while you're populating it
$fp = fopen($filename, "w");

// Set the number of headlines per site
$total = 4;

// Initialize our sites
$url[0] = 'http://reclaimthemedia.org/backend/rtmsum.rdf';
$url[1] = 'http://pissedkid.net/medianews/index.rdf';
$url[2] = 'http://www.freepress.net/news/allnews.rss';

// Fetch the XML for each one
$count = 0;
foreach($url as $thisURL)
{ $rss[$count] = fetch_rss($thisURL);
$count++;
}

// This is the variable we'll use to write to the file
$string = "";

// Print out the data for each one
foreach ($rss as $thisRSS)
{ // Display the site's name
$string .= "From " . $thisRSS->channel['title'] . ":
\n";

// Limit to $total entries
$items = array_slice($thisRSS->items, 0, $total);

foreach ($items as $item ) {
$title = $item[title];
$linkURL = $item[link];
$date = $item[pubDate];
$description = $item[description];

// If we have no title, use the first 20 characters of the description
if ($title == "")
{ $title = substr(strip_tags($description), 0, 20) . "...";
}

// If we have no link, use the site's link
if ($linkURL == "")
{ $linkURL = $thisRSS->channel['link'];
}

// Add this headline to our variable
$string .= "- $title$date
\n";
}

$string .= "\n
";
}

// Write the data to the file
$write = fputs($fp, $string);
fclose($fp);
}

// Show the RSS!
// open the file, read it and dump it into
// a var.
$fp = fopen($filename, "r");
$contents = fread($fp, filesize($filename));
fclose($fp);

return $contents;
}