xml_encode($_SERVER['REQUEST_URI']) : ''; $extraInfos = $this->getExtraInfos(); $title = $this->xml_encode($extraInfos['name']); if(!empty($extraInfos['uri'])) { $uri = $this->xml_encode($extraInfos['uri']); } else { $uri = REPOSITORY; } $uriparts = parse_url($uri); $icon = $this->xml_encode($uriparts['scheme'] . '://' . $uriparts['host'] . '/favicon.ico'); $items = ''; foreach($this->getItems() as $item) { $itemAuthor = $this->xml_encode($item->getAuthor()); $itemTitle = $this->xml_encode($item->getTitle()); $itemUri = $this->xml_encode($item->getURI()); $itemTimestamp = $this->xml_encode(date(DATE_RFC2822, $item->getTimestamp())); $itemContent = $this->xml_encode($this->sanitizeHtml($item->getContent())); $entryEnclosuresWarning = ''; $entryEnclosures = ''; if(!empty($item->getEnclosures())) { $entryEnclosures .= ''; if(count($item->getEnclosures()) > 1) { $entryEnclosures .= PHP_EOL; $entryEnclosuresWarning = '<br>Warning: Some media files might not be shown to you. Consider using the ATOM format instead!'; foreach($item->getEnclosures() as $enclosure) { $entryEnclosures .= '' . PHP_EOL; } } } $entryCategories = ''; foreach($item->getCategories() as $category) { $entryCategories .= '' . $category . '' . PHP_EOL; } $items .= << {$itemTitle} {$itemUri} {$itemUri} {$itemTimestamp} {$itemContent}{$entryEnclosuresWarning} {$itemAuthor} {$entryEnclosures} {$entryCategories} EOD; } $charset = $this->getCharset(); /* xml attributes need to have certain characters escaped to be w3c compliant */ $imageTitle = htmlspecialchars($title, ENT_COMPAT); /* Data are prepared, now let's begin the "MAGIE !!!" */ $toReturn = << {$title} http{$https}://{$httpHost}{$httpInfo}/ {$title} {$items} EOD; // Remove invalid non-UTF8 characters ini_set('mbstring.substitute_character', 'none'); $toReturn = mb_convert_encoding($toReturn, $this->getCharset(), 'UTF-8'); return $toReturn; } public function display(){ $this ->setContentType('application/rss+xml; charset=' . $this->getCharset()) ->callContentType(); return parent::display(); } private function xml_encode($text){ return htmlspecialchars($text, ENT_XML1); } }