View Single Post
Old 06-04-2011, 07:38 AM  
just a punk
So fuckin' bored
 
just a punk's Avatar
 
Industry Role:
Join Date: Jun 2003
Posts: 32,386

Ah, now i see the problem. It's because the cache file is initially blank and it will update only after a hour

Here is a slightly fixed code:
Code:
<?php
$feed = file_get_contents ( "http://nubilestube.com/rss.php?location=most_recent" );
$filename = "cache.txt";
if (file_exists ( $filename ) && filesize ( $filename ) && (time () - filectime ( $filename )) < 60 * 60) {
	$content = file_get_contents ( $filename );
} else {
	$xml_parser = xml_parser_create ();
	xml_parse_into_struct ( $xml_parser, $feed, $vals, $index );
	$cnt = min ( 5, count ( $index ["TITLE"] ) );
	$content = "";
	for($i = 1; $i < $cnt; $i ++) {
		$content .= "<h3>" . html_entity_decode ( $vals [$index ["TITLE"] [$i]] ["value"], ENT_QUOTES ) . "</h3>\n";
		$content .= "<p>" . html_entity_decode ( $vals [$index ["DESCRIPTION"] [$i]] ["value"], ENT_QUOTES ) . "</p>\n";
	}
	file_put_contents ( $filename, $content, LOCK_EX );
	xml_parser_free ( $xml_parser );
}
echo $content;
?>
__________________
Obey the Cowgod
just a punk is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote