From bbb612eabf761ca4ad7dc45f4057aeef0b92506d Mon Sep 17 00:00:00 2001 From: jhunkeler Date: Mon, 21 Dec 2009 01:04:41 +0000 Subject: Added caching support to the rss aggregator block. git-svn-id: http://svn.3rd-infantry-division.org/testing/branches/Bayonet CMS v2@383 c5b2fb0a-d05d-0410-98c8-828840a80ff6 --- blocks/rss_agw/index.php | 51 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/blocks/rss_agw/index.php b/blocks/rss_agw/index.php index c811ecc..0c90e7c 100644 --- a/blocks/rss_agw/index.php +++ b/blocks/rss_agw/index.php @@ -1,18 +1,55 @@ "); + $fp = fopen($cacheRead, "x+"); + fclose($fp); + } + + decho("reading internal cache state
"); + $internal = fopen($cacheFile, "r"); + $cacheRead = fread($internal, $cacheReadLength); + fclose($internal); + + decho("reading inbound cache data
"); + $inbound = fopen($url, "r+"); + $cacheTempRead = fread($inbound, $cacheReadLength); + fclose($inbound); + + decho("comparing
"); + if((strncmp($cacheTempRead, $cacheRead, $cacheReadLength)) == 0) + { + $cacheTemp = implode('', file($url)); + decho("Length of cached RSS is " . strlen($cacheTemp) . "
"); + decho("Writing cached data to file
"); + $cachefp = fopen($cacheFile, "w+"); + $cacheWritten = fwrite($cachefp, $cacheTemp, strlen($cacheTemp)); + fclose($cachefp); + decho("$cacheWritten bytes written to cache.
"); + } + else + { + decho("cache matches external source, using internal
"); + } - $rss->load('http://www.armedglobalwarfare.com/index.php?type=rss;action=.xml;limit=150'); - + $rss->load($cacheFile); + $items = $rss->getItems(); #returns all rss items $numFeeds = 0; @@ -21,10 +58,12 @@ function stripBBCode($text_to_search) { if($story['category']=="Tournament Announcements"){ $numFeeds++; // $text = $story['description']; + // $text = stripBBCode($text); // $text = preg_replace("(\[font(.+?)...)","",$text); echo "{$story['title']}
{$story['pubDate']}
"; - echo "{$text}

"; + //echo "{$text}

"; + echo "

"; } } if(!$numFeeds){ -- cgit