ACC SHELL
<?php
//include_once('lab.nej-recepty.cz/administrace/config/config.php');
// Nastaveni konektu do databaze
define('DB_DRIVER', 'mysql');
define('CHARSET', 'utf8');
define('DB_NAME', 'nej-receptycz04');
define('HOST', '127.0.0.1');
if ($_SERVER['SERVER_ADDR'] == '127.0.0.1') {
define('DB_USERNAME', 'root');
define('DB_PASSWORD', null);
define('PROFILER', true);
}
else {
define('DB_USERNAME', 'nej-receptycz004');
define('DB_PASSWORD', 'cmsdbsenk');
define('PROFILER', false);
}
$datum = date("d_m_y_H_i_s");
$link = mysql_connect(HOST, DB_USERNAME, DB_PASSWORD);
if (!mysql_select_db(DB_NAME, $link)) {
//echo mysql_errno() .' - '. mysql_error();
}
mysql_query('SET NAMES '.CHARSET);
mysql_query('SET CHARACTER SET '.CHARSET);
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-clanky.xml', 'w+');
fwrite($handle, $this->feed);
fclose($handle);
}
}
}
//$feed = new Rss(SERVER_NAME, "FC Brumov", "http://" . SERVER_NAME);
$feed = new Rss('http://lab.nej-recepty.cz', "FC Brumov", "http://" . 'http://lab.nej-recepty.cz');
//$url = Query::getUrlSablony(3);
$url = 'novinky/novinky-a-akce';
$query = "SELECT b.seo_nazev, b.seo_url, b.datum, b.anotace, b.obsah
FROM clanky AS a
LEFT JOIN clanky_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->item($r->seo_nazev, htmlspecialchars($r->anotace), 'http://' . SERVER_NAME . '/' . $url . "/$r->seo_url.html", $r->datum);
}
}
$feed->save();
ACC SHELL 2018