channel_title = $title; $this->channel_link = $link; $this->channel_description = $description; $this->channel_imgurl = $imgurl; $this->pubDate = Date('Y-m-d H:i:s', time()); $this->lastBuildDate = Date('Y-m-d H:i:s', time()); } /** * @param string $key Variable key * @param string $value Variable value */ public function config($key,$value) { $this->{$key} = $value; } /** * @param string $title Item title * @param string $link Item link * @param string $description Item description * @param string $pubDate Item publish data +---------------------------------------------------------- */ function addItem($title, $link, $description, $pubDate) { $this->items[] = array('title' => $title, 'link' => $link, 'description' => $description, 'pubDate' => $pubDate); } /** * @param void * @return string */ public function fetch() { $rss = "\r\n"; $rss .= "\r\n"; $rss .= "\r\n"; $rss .= "<![CDATA[{$this->channel_title}]]>\r\n"; $rss .= "channel_description}]]>\r\n"; $rss .= "{$this->channel_link}\r\n"; $rss .= "{$this->language}\r\n"; if (!empty($this->pubDate)) $rss .= "{$this->pubDate}\r\n"; if (!empty($this->lastBuildDate)) $rss .= "{$this->lastBuildDate}\r\n"; if (!empty($this->generator)) $rss .= "{$this->generator}\r\n"; $rss .= "5\r\n"; if (!empty($this->channel_imgurl)) { $rss .= "\r\n"; $rss .= "<![CDATA[{$this->channel_title}]]>\r\n"; $rss .= "{$this->channel_link}\r\n"; $rss .= "{$this->channel_imgurl}\r\n"; $rss .= "\r\n"; } for ($i = 0; $i < count($this->items); $i++) { $rss .= "\r\n"; $rss .= "<![CDATA[{$this->items[$i]['title']}]]>\r\n"; $rss .= "{$this->items[$i]['link']}\r\n"; $rss .= "items[$i]['description']}]]>\r\n"; $rss .= "{$this->items[$i]['pubDate']}\r\n"; $rss .= "\r\n"; } $rss .= "\r\n"; return $rss; } /** * @param void * @return void */ public function display() { header("Content-Type: text/xml; charset=utf-8"); echo $this->fetch(); exit; } } ?>