2011-03-28 14:21:28 +00:00
|
|
|
<?
|
|
|
|
class FEED {
|
2012-08-30 08:00:17 +00:00
|
|
|
var $UseSSL = true; // If we're using SSL for blog and news links
|
2011-05-13 08:00:07 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
function open_feed() {
|
|
|
|
header("Content-type: application/xml; charset=UTF-8");
|
|
|
|
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n","<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n\t<channel>\n";
|
2012-04-02 08:00:21 +00:00
|
|
|
echo '<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />'."\n";
|
|
|
|
echo '<meta xmlns="http://pipes.yahoo.com" name="pipes" content="noprocess" />'."\n";
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
2013-05-28 08:01:02 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
function close_feed() {
|
|
|
|
echo "\t</channel>\n</rss>";
|
|
|
|
}
|
2013-05-28 08:01:02 +00:00
|
|
|
|
|
|
|
function channel($Title, $Description, $Section = '') {
|
2011-05-13 08:00:07 +00:00
|
|
|
$Site = $this->UseSSL ? 'https://'.SSL_SITE_URL : 'http://'.NONSSL_SITE_URL;
|
|
|
|
echo "\t\t<title>$Title :: ". SITE_NAME. "</title>\n";
|
|
|
|
echo "\t\t<link>$Site/$Section</link>\n";
|
|
|
|
echo "\t\t<description>$Description</description>\n";
|
2011-03-28 14:21:28 +00:00
|
|
|
echo "\t\t<language>en-us</language>\n";
|
2011-05-13 08:00:07 +00:00
|
|
|
echo "\t\t<lastBuildDate>". date('r'). "</lastBuildDate>\n";
|
2011-03-28 14:21:28 +00:00
|
|
|
echo "\t\t<docs>http://blogs.law.harvard.edu/tech/rss</docs>\n";
|
|
|
|
echo "\t\t<generator>Gazelle Feed Class</generator>\n\n";
|
|
|
|
}
|
2013-05-28 08:01:02 +00:00
|
|
|
|
|
|
|
function item($Title, $Description, $Page, $Creator, $Comments = '', $Category = '', $Date = '') { //Escape with CDATA, otherwise the feed breaks.
|
2011-03-28 14:21:28 +00:00
|
|
|
if ($Date == '') {
|
2013-04-20 08:01:01 +00:00
|
|
|
$Date = date('r');
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
2013-05-28 08:01:02 +00:00
|
|
|
$Date = date('r', strtotime($Date));
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
2013-05-28 08:01:02 +00:00
|
|
|
$Site = ($this->UseSSL ? 'https://'.SSL_SITE_URL : 'http://'.NONSSL_SITE_URL);
|
2011-03-28 14:21:28 +00:00
|
|
|
$Item = "\t\t<item>\n";
|
|
|
|
$Item .= "\t\t\t<title><![CDATA[$Title]]></title>\n";
|
|
|
|
$Item .= "\t\t\t<description><![CDATA[$Description]]></description>\n";
|
|
|
|
$Item .= "\t\t\t<pubDate>$Date</pubDate>\n";
|
2011-05-13 08:00:07 +00:00
|
|
|
$Item .= "\t\t\t<link>$Site/$Page</link>\n";
|
|
|
|
$Item .= "\t\t\t<guid>$Site/$Page</guid>\n";
|
2011-03-28 14:21:28 +00:00
|
|
|
if ($Comments != '') {
|
2011-05-13 08:00:07 +00:00
|
|
|
$Item .= "\t\t\t<comments>$Site/$Comments</comments>\n";
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
if ($Category != '') {
|
|
|
|
$Item .= "\t\t\t<category><![CDATA[$Category]]></category>\n";
|
|
|
|
}
|
|
|
|
$Item .= "\t\t\t<dc:creator>$Creator</dc:creator>\n\t\t</item>\n";
|
|
|
|
return $Item;
|
|
|
|
}
|
|
|
|
|
2013-04-20 08:01:01 +00:00
|
|
|
function retrieve($CacheKey, $AuthKey, $PassKey) {
|
2011-03-28 14:21:28 +00:00
|
|
|
global $Cache;
|
|
|
|
$Entries = $Cache->get_value($CacheKey);
|
2013-04-20 08:01:01 +00:00
|
|
|
if (!$Entries) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$Entries = array();
|
|
|
|
} else {
|
2013-04-20 08:01:01 +00:00
|
|
|
foreach ($Entries as $Item) {
|
2013-05-28 08:01:02 +00:00
|
|
|
echo str_replace(array('[[PASSKEY]]', '[[AUTHKEY]]'), array(display_str($PassKey), display_str($AuthKey)), $Item);
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-20 08:01:01 +00:00
|
|
|
function populate($CacheKey, $Item) {
|
2011-03-28 14:21:28 +00:00
|
|
|
global $Cache;
|
2013-05-28 08:01:02 +00:00
|
|
|
$Entries = $Cache->get_value($CacheKey, true);
|
2013-04-20 08:01:01 +00:00
|
|
|
if (!$Entries) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$Entries = array();
|
|
|
|
} else {
|
2013-04-20 08:01:01 +00:00
|
|
|
if (count($Entries) >= 50) {
|
2011-03-28 14:21:28 +00:00
|
|
|
array_pop($Entries);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
array_unshift($Entries, $Item);
|
|
|
|
$Cache->cache_value($CacheKey, $Entries, 0); //inf cache
|
|
|
|
}
|
|
|
|
}
|