function RSS($id = null, PDO $db = null) { if (!$db) { global $db; } $q = is_numeric($id) ? 'ID=' . $id : 'auto=1'; $all = $db->query('SELECT ID,name,dsc,url,lang,num FROM ' . PRE . 'rss WHERE ' . $q)->fetchAll(3); foreach ($all as $x) { require_once './lib/rss.php'; $rss = new RSS(); $rss->title = $x[1]; $rss->desc = $x[2]; $rss->link = $x[3]; $rss->base = URL; #Pobierz ostatnie nowoĊci $q = $db->query('SELECT i.ID,i.name,i.date,i.txt,i.opt,c.name as cat FROM ' . PRE . 'news i JOIN ' . PRE . 'cats c ON i.cat=c.ID WHERE i.access=1 AND (c.access=1 OR c.access="' . $x[4] . '") ORDER BY i.ID DESC LIMIT ' . $x[5]); foreach ($q as $item) { $rss->add(array('ID' => $item['ID'], 'title' => $item['name'], 'text' => $item['opt'] & 1 ? nl2br($item['txt']) : $item['txt'], 'cat' => $item['cat'], 'date' => date('r', strtotime($item['date'] . ' UTC')), 'url' => URL . url('news/' . $item['ID']))); } $rss->save('rss/' . $x[0] . '.xml'); } }