ACC SHELL
<?php
include_once('lab.nej-recepty.cz/administrace/config/config.php');
//include(WWW_DIR . "/inc/funkce.php");
class Rss {
# vytvoreni hlavicky, informace o feedu
public $feed = '';
private $save = 'file'; // file, direct
public function __construct($title="", $description="", $url="") {
if ($this->save == 'direct') {
header("Content-type: text/xml"); # nezbytne, aby kanal spravne fungoval
}
$this->feed = "<" . "?xml version='1.0' encoding='utf-8'?" . ">";
$this->feed .= "<rss version=\"2.0\">\n";
$this->feed .= " <channel>\n";
$this->feed .= " <title>$title</title>\n";
$this->feed .= " <link>$url</link>\n";
$this->feed .= " <description>$description</description>\n";
$this->feed .= " <language>cs</language>\n";
$this->feed .= " <generator>PHP RSS generator</generator>\n";
}
# jednotlive polozky
public function item($title, $description, $url, $date) {
$this->feed .= " <item>\n";
$this->feed .= " <title>$title</title>\n";
$this->feed .= " <link>$url</link>\n";
$this->feed .= " <description>$description</description>\n";
$this->feed .= " <pubDate>$date</pubDate>\n";
$this->feed .= " </item>\n";
}
# ukonceni feedu
public function save() {
$this->feed .= " </channel>\n";
$this->feed .= "</rss>\n";
//print_r($this->feed);
if ($this->save == 'direct') {
echo $this->feed;
}
if ($this->save == 'file') {
$handle = fopen('lab.nej-recepty.cz/rss-novinky.xml', 'w+');
fwrite($handle, $this->feed);
fclose($handle);
}
}
}
$feed = new Rss(SERVER_NAME, "FC Brumov", "http://" . SERVER_NAME);
$url = Query::getUrlSablony(4);
$query = "SELECT b.seo_nazev, b.seo_url, b.datum, b.anotace, b.obsah
FROM novinky AS a
LEFT JOIN novinky_popis AS b ON a.id = b.main_id
WHERE b.lang = '1'
ORDER BY b.datum DESC";
$result = mysql_query($query);
if (mysql_num_rows($result) != 0) {
while ($r = mysql_fetch_object($result)) {
$feed->item($r->seo_nazev, htmlspecialchars($r->anotace), 'http://' . SERVER_NAME . '/' . $url->url . "/$r->seo_url.html", $r->datum);
}
}
$feed->save();
//print_r($query);
//save file
?>
ACC SHELL 2018