View Single Post
Old 06-04-2011, 07:01 AM  
Oracle Porn
Affiliate
 
Oracle Porn's Avatar
 
Industry Role:
Join Date: Oct 2002
Location: Icq: 94-399-723
Posts: 24,433
Quote:
Originally Posted by cyberxxx View Post
Easily, simple replace this line:
$cnt = count ( $index ["TITLE"] );

to this one:
$cnt = min ( 5, count ( $index ["TITLE"] ) );

where 5 is your limit.
Awesome

Quote:
Originally Posted by cyberxxx View Post
Here is the same code but with hourly cashing:

Code:
<?php
$feed = file_get_contents ( "http://nubilestube.com/rss.php?location=most_recent" );
$filename = "cache.txt";
if (file_exists ( $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 = 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;
?>
You just need to create the empty file "cache.txt" and chmod it to 666.

Can't be easier, right?
This one doesn't work for me
__________________


Oracle Porn is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote