| Class RSS { var $title; var $link; var $description; var $language = "en-US"; var $pubDate; var $items; var $tags; function RSS () { $this->items = Array (); $this->tags = Array (); } function AddItem ($item) { $this->items[] = $item; } function Setpubdate ($when) { if (Strtotime ($when) = = False) $this->pubdate = Date ("D, D M Y h:i:s", $when). " GMT "; Else $this->pubdate = Date ("D, D M Y h:i:s", Strtotime ($when)). " GMT "; } function Getpubdate () { if (Empty ($this->pubdate)) Return Date ("D, D M Y h:i:s"). " GMT "; Else return $this->pubdate; } function Addtag ($tag, $value) { $this->tags[$tag] = $value; } function out () { $out = $this->header (); $out. = " \ n"; $out. = "" . $this->title. "\ n "; $out. = " ". $this->link. "\ n"; $out. = " ". $this->description. " \ n"; $out. = " ". $this->language. " \ n"; $out. = " ". $this->getpubdate (). " \ n"; foreach ($this->tags as $key = = $val) $out. = "< $key > $val \ n"; foreach ($this->items as $item) $out. = $item->out (); $out. = "\ n"; $out. = $this->footer (); $out = Str_replace ("&", "&", $out); return $out; } function serve ($contentType = "Application/xml") { $xml = $this->out (); Header ("Content-type: $contentType"); Echo $xml; } function Header () { $out = ' . "\ n"; $out. = ' . "\ n"; return $out; } function Footer () { Return '; } } Class RssItem { var $title; var $link; var $description; var $pubDate; var $guid; var $tags; var $attachment; var $length; var $mimetype; function RssItem () { $this->tags = Array (); } function Setpubdate ($when) { if (Strtotime ($when) = = False) $this->pubdate = Date ("D, D M Y h:i:s", $when). " GMT "; Else $this->pubdate = Date ("D, D M Y h:i:s", Strtotime ($when)). " GMT "; } function Getpubdate () { if (Empty ($this->pubdate)) Return Date ("D, D M Y h:i:s"). " GMT "; Else return $this->pubdate; } function Addtag ($tag, $value) { $this->tags[$tag] = $value; } function out () { $out. = " \ n"; $out. = "" . $this->title. "\ n "; $out. = " ". $this->link. "\ n"; $out. = " ". $this->description. " \ n"; $out. = " ". $this->getpubdate (). " \ n"; if ($this->attachment! = "") $out. = " "; if (Empty ($this->guid)) $this->guid = $this->link; $out. = " ". $this->guid. " \ n"; foreach ($this->tags as $key = + $val) $out. = "< $key > $val "; $out. = "\ n"; return $out; } Function Enclosure ($url, $mimetype, $length) { $this->attachment = $url; $this->mimetype = $mimetype; $this->length = $length; } } |