<?php class RSS { public string $Charset; public string $Title; public string $Link; public string $Description; public string $WebmasterEmail; public array $Items; function __construct() { $this->Charset = 'utf8'; $this->Title = ''; $this->Link = ''; $this->Description = ''; $this->WebmasterEmail = ''; $this->Items = array(); } function Generate(): string { $Result = '<?xml version="1.0" encoding="'.$this->Charset.'" ?>'."\n". //<? '<rss version="2.0">'."\n". " <channel>\n". " <title>".$this->Title."</title>\n". " <link>".$this->Link."</link>\n". " <description>".$this->Description."</description>\n". " <language>cs</language>\n". " <webMaster>".$this->WebmasterEmail."</webMaster>\n". " <pubDate>".date('r')."</pubDate>\n". " <ttl>20</ttl>\n"; foreach ($this->Items as $Item) { $Result .= " <item>\n". ' <title>'.htmlspecialchars($Item['Title'])."</title>\n". ' <description>'.htmlspecialchars($Item['Description'])."</description>\n". ' <pubDate>'.date('r',$Item['Time'])."</pubDate>\n". ' <link>'.$Item['Link']."</link>\n". " </item>\n"; } $Result .= " </channel>\n". "</rss>"; return $Result; } }