From cce5e7710295021b41d9aaecc503a60fb99256be Mon Sep 17 00:00:00 2001 From: deva Date: Sat, 4 Oct 2008 10:38:03 +0000 Subject: Initial revision --- utils/rss.php | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 utils/rss.php (limited to 'utils/rss.php') diff --git a/utils/rss.php b/utils/rss.php new file mode 100644 index 0000000..e6aa83f --- /dev/null +++ b/utils/rss.php @@ -0,0 +1,112 @@ +\n"; + echo "
" . + htmlspecialchars_decode($this->title, ENT_QUOTES) . "
\n"; + echo "
" . date("D M jS Y G:i", $this->time) . "
\n"; + echo "
" . + htmlspecialchars_decode($this->description, ENT_QUOTES) . "
\n"; + echo "\n"; + } + */ + public function RSSEntry($title, $time, $category, $description) + { + $this->title = $title; + $this->time = $time; + $this->category = $category; + $this->description = $description; + } +} + +class RSS { + + private $newsfile; + private $rssfile; + private $news = array(); + + public function add($newsentry) { + $key = $newsentry->time; + $this->news[$key] = $newsentry; + } + + private function date($time) { + return date("r", $time); + } + + public function write() + { + $fp = fopen($this->rssfile, "w"); + fwrite($fp, "\n"); + fwrite($fp, "\n"); + fwrite($fp, " \n"); + fwrite($fp, " DIE News\n"); + fwrite($fp, " http://www.executionroom.com\n"); + fwrite($fp, " DIE - News from ExecutionRoom.com\n"); + fwrite($fp, " en-us\n"); + fwrite($fp, " ".$this->date(time())."\n"); + fwrite($fp, " ".$this->date(time())."\n"); + fwrite($fp, " http://blogs.law.harvard.edu/tech/rss\n"); + fwrite($fp, " ExecutionRoom CMS\n"); + fwrite($fp, " info@executionroom.com\n"); + fwrite($fp, " info@executionroom.com\n"); + + $i = 0; + foreach($this->news as $newsentry) { + fwrite($fp, " \n"); + fwrite($fp, " ".$newsentry->title."\n"); + fwrite($fp, " http://www.executionroom.com/?page=news&id=".$newsentry->time."\n"); + fwrite($fp, " ".$newsentry->description."\n"); + fwrite($fp, " ".$this->date($newsentry->time)."\n"); + fwrite($fp, " http://www.executionroom.com/?page=news&id=".$newsentry->time."\n"); + fwrite($fp, " \n"); + $i++; + if($i > 6) break; + } + + fwrite($fp, " \n"); + fwrite($fp, "\n"); + + fclose($fp); + } + + private function read() + { + + $dom = new DomDocument; + $dom->preserveWhiteSpace = FALSE; + $dom->load($this->newsfile); + $params = $dom->getElementsByTagName('newsentry'); + + foreach ($params as $param) { + $rssentry = new RSSEntry($param->getAttribute('title'), + $param->getAttribute('time'), + $param->getAttribute('category'), + $param->getAttribute('description')); + $this->add($rssentry); + } + + // Key sort + krsort($this->news); + } + + public function RSS($newsfile, $rssfile) + { + $this->newsfile = $newsfile; + $this->rssfile = $rssfile; + $this->read(); + } + +} + +?> -- cgit v1.2.3