ACC SHELL

Path : /www/hosting/oltv.cz/www/class/system/
File Upload :
Current File : /www/hosting/oltv.cz/www/class/system/rss.php

<?php

class RSS {
	public $title;
	public $link;
	public $webMaster;
	public $description;
	public $category;
	public $rssLink;
	public $imageUrl;
	private $_items = array();

	public function render() {
		$ret = '<?xml version="1.0" encoding="utf-8"?>'
			  .'<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">'
					.'<channel>'
						.'<title>'.self::encode($this->title).'</title>'
						.'<link>'.$this->link.'</link>'
						.'<webMaster>'.self::encode($this->webMaster).'</webMaster>'
						.'<description>'.self::encode($this->description).'</description>'
						.'<category>'.self::encode($this->category).'</category>'
						.'<docs>'.$this->rssLink.'</docs>'
						.'<lastBuildDate>'.gmdate('D, d M Y H:i:s').' GMT</lastBuildDate>'
						.'<image>'
							.'<url>'.$this->imageUrl.'</url>'
							.'<title>'.self::encode($this->title).'</title>'
							.'<link>'.$this->link.'</link>'
						.'</image>'
						.'<atom:link href="'.$this->rssLink.'" rel="self" type="application/rss+xml" />';

		$ret .= $this->_renderItems();

		$ret .= 	'</channel>'
				.'</rss>';

		return $ret;
	}

	public function _renderItems() {
		$ret = '';
		foreach($this->_items as $item) {
			$values = $item->get();

			$ret .= '<item>'
						.'<title>'.self::encode($values['title']).'</title>'
						.'<link>'.$values['link'].'</link>'
						.'<guid>'.$values['link'].'</guid>'
						.'<description>'.$values['description'].'</description>'
						.(isset($values['enclosure'])?'<enclosure url="'.$values['enclosure'].'" type="image/jpeg" length="23562" />':'')
						.'<pubDate>'.self::convertDate($values['date']).'</pubDate>'
					.'</item>';
		}
		return $ret;
	}

	public function add() {
		$item = new RSSItem;
		$this->_items[] = &$item;
		return $item;
	}

	public function encode($string) { return htmlspecialchars(preg_replace('#[\x00-\x08\x0B\x0C\x0E-\x1F]+#', '', $string), ENT_QUOTES); }
	public function convertDate($date) { return gmdate("D, d M Y H:i:s", strtotime($date))." GMT"; }
}


class RSSItem {
	private $_values = array();
	public function title($title) { $this->_values['title'] = $title; return $this; }
	public function link($link) { $this->_values['link'] = $link; return $this; }
	public function description($description) { $this->_values['description'] = $description; return $this; }
	public function enclosure ($enclosure) { $this->_values['enclosure'] = $enclosure ; return $this; }
	public function date($date) { $this->_values['date'] = $date; return $this; }
	public function get() { return $this->_values; }
}

ACC SHELL 2018