\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();
}
}
?>