reset(); } function reset() { $this->rss_feed = ''; } function rssBegin($encoding) { $this->rss_feed .= '' . "\n"; $this->rss_feed .= '' . "\n"; return true; } function rssBeginChannel($title, $link, $description, $language = false, $image = false, $copyright = false, $managingEditor = false, $webMaster = false, $category = false, $generator = 'PHP RSS Feed Class, (c) 2005 Joshua Dechant ', $docs = 'http://feedvalidator.org/docs/rss2.html', $lastBuildDate = false) { $this->rss_feed .= '' . "\n"; $this->rss_feed .= '' . $this->cleanItem($title) . '' . "\n"; $this->rss_feed .= '' . $this->cleanItem($link) . '' . "\n"; $this->rss_feed .= '' . $this->cleanItem($description) . '' . "\n"; if ($image) { $this->rss_feed .= '' . "\n"; $this->rss_feed .= '' . $this->cleanItem($title) . '' . "\n"; $this->rss_feed .= '' . $this->cleanItem($image) . '' . "\n"; $this->rss_feed .= '' . $this->cleanItem($link) . '' . "\n"; $this->rss_feed .= '' . "\n"; } if ($copyright) { $this->rss_feed .= '' . $this->cleanItem($copyright) . '' . "\n"; } if ($managingEditor) { $this->rss_feed .= '' . $this->cleanItem($managingEditor) . '' . "\n"; } if ($webMaster) { $this->rss_feed .= '' . $this->cleanItem($webMaster) . '' . "\n"; } if ($category) { $this->rss_feed .= '' . $this->cleanItem($category) . '' . "\n"; } if ($generator) { $this->rss_feed .= '' . $this->cleanItem($generator) . '' . "\n"; } if ($docs) { $this->rss_feed .= '' . $docs . '' . "\n"; } if ($lastBuildDate) { $this->rss_feed .= '' . $lastBuildDate . '' . "\n"; } else { $this->rss_feed .= '' . gmstrftime("%a, %d %b %Y %T %Z", time()) . '' . "\n"; } return true; } function rssItem($title, $link, $description, $author = false, $category = false, $comments = false, $guid = false, $pubDate = false) { $this->rss_feed .= '' . "\n"; $this->rss_feed .= '' . $this->cleanItem($title) . '' . "\n"; $this->rss_feed .= '' . $this->cleanItem($link) . '' . "\n"; $this->rss_feed .= '' . $this->cleanItem($description) . '' . "\n"; if ($author) { $this->rss_feed .= '' . $this->cleanItem($author) . '' . "\n"; } if ($category) { $this->rss_feed .= '' . $this->cleanItem($category) . '' . "\n"; } if ($comments) { $this->rss_feed .= '' . $this->cleanItem($comments) . '' . "\n"; } if ($guid) { $this->rss_feed .= '' . $this->cleanItem($guid) . '' . "\n"; } if ($pubDate) { $this->rss_feed .= '' . $pubDate . '' . "\n"; } $this->rss_feed .= '' . "\n"; return true; } function rssChannelEnd() { $this->rss_feed .= '' . "\n"; return true; } function rssEnd() { $this->rss_feed .= '' . "\n"; return true; } function cleanItem($item) { // Bad HTML entities not allowed in XML $item = str_replace('…', '. . .', $item); $item = str_replace('©', '(c)', $item); // symbols $item = str_replace('&', '&', $item); $item = str_replace('<', '<', $item); $item = str_replace('>', '>', $item); // fix them $item = str_replace('&', '&', $item); $item = str_replace('<', '<', $item); $item = str_replace('>', '>', $item); return $item; } function displayRSS($type = 'xml', $direct_output = true) { if ($direct_output) { if ($type == 'xml') { $content_type = 'xml'; } elseif ($type == 'rss') { $content_type = 'rss-xml'; } else { return false; } header('Content-Type: application/' . $content_type); echo $this->rss_feed; return true; } else { return $this->rss_feed; } } } ?>