1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
<link rel="stylesheet" type="text/css" href="blocks/rss_agw/style.css" media="screen"/>
<?php
function stripBBCode($text_to_search) {
$pattern = '|[[\/\!]*?[^\[\]]*?]|si';
$replace = '';
return preg_replace($pattern, $replace, $text_to_search);
}
include 'rssreader.php';
$rss = new rss_php;
$cacheReadLength = 2048;
$cacheFile = dirname(__FILE__) . "/rss.cache";
$url = 'http://www.armedglobalwarfare.com/index.php?type=rss;action=.xml;limit=150';
if(!file_exists($cacheFile))
{
decho("Creating RSS cache");
$fp = fopen($cacheRead, "x+");
fclose($fp);
}
decho("Reading internal RSS cache state");
$internal = fopen($cacheFile, "r");
$cacheRead = fread($internal, $cacheReadLength);
decho(strlen($cacheRead) . " bytes read");
fclose($internal);
decho("Reading inbound RSS cache data");
$inbound = fopen($url, "r");
$cacheTempRead = fread($inbound, $cacheReadLength);
decho(strlen($cacheTempRead) . " bytes downloaded");
fclose($inbound);
decho("Comparing RSS caches");
if((strncmp($cacheTempRead, $cacheRead, $cacheReadLength)) != 0)
{
decho("Downloading updated RSS feed");
$cacheTemp = implode('', file($url));
decho("Length of updated RSS is " . strlen($cacheTemp));
decho("Writing cached RSS data to file");
$cachefp = fopen($cacheFile, "w+");
$cacheWritten = fwrite($cachefp, $cacheTemp, strlen($cacheTemp));
fclose($cachefp);
decho("$cacheWritten bytes written to RSS cache");
}
else
{
decho("RSS cache matches external source, using internal");
}
decho("Loading RSS cache into aggregator");
$rss->load($cacheFile);
$items = $rss->getItems(); #returns all rss items
$numFeeds = 0;
echo "<div class=\"rss\" >";
foreach($items as $story){
if($story['category']=="Tournament Announcements"){
$numFeeds++;
//$text = $story['description'];
//$text = strip_tags($text);
//$text = preg_replace("(\[font(.+?)...)","", $text);
//$text = stripBBCode($text);
echo "<a href=\"{$story['link']}\" target=\"_blank\"><span class=\"title\">{$story['title']}</span></a><br />
<span class=\"date\">{$story['pubDate']}</span><br />";
//echo "{$text}<br /><br />";
echo "<br /><hr />";
}
}
if(!$numFeeds){
echo "No new updates for this news feed.";
}
echo "</div>";
// echo "<pre>";
//print_r($items);
// echo "</pre>";
?>
|