Ejemplo n.º 1
0
 public function __construct(CDatabaza $db)
 {
     parent::__construct($db);
     $sql = "SELECT \n            Clanok.clanok_id AS id,\n            Clanok.nazov_clanku AS name,\n            Typ_clanku.nazov AS type,\n            Rubrika.nazov_rubriky AS topic,\n            Clanok.casova_znamka AS timestamp\n            FROM \n            (Clanok\n            INNER JOIN\n            Rubrika\n            ON Clanok.rubrika_id=Rubrika.rubrika_id)\n            INNER JOIN\n            Typ_clanku\n            ON Clanok.typ_clanku_id=Typ_clanku.typ_clanku_id\n            WHERE\n            Clanok.zobrazit=1\n            ORDER BY Clanok.casova_znamka DESC\n            LIMIT 0,10";
     $news_recs = $db->query($sql);
     while ($news = $news_recs->fetch_array()) {
         $id = $news['id'];
         $this->news[$id]['id'] = $id;
         $this->news[$id]['name'] = $news['name'];
         $this->news[$id]['type'] = $news['type'];
         $this->news[$id]['topic'] = $news['topic'];
         $this->news[$id]['day'] = date("j.n.Y", $news['timestamp']);
         $this->news[$id]['time'] = date("h:i:s", $news['timestamp']);
     }
 }
Ejemplo n.º 2
0
 public function __construct(CDatabaza $db)
 {
     parent::__construct($db);
     $sql = "SELECT * FROM Tema ORDER BY tema_id";
     $temy = $db->query($sql);
     while ($tema = $temy->fetch_array()) {
         $this->menu[$tema['tema_id']]['id'] = $tema['tema_id'];
         $this->menu[$tema['tema_id']]['nazov'] = $tema['nazov_temy'];
         $sql = "SELECT * FROM Rubrika WHERE tema_id='" . $tema['tema_id'] . "'\n                ORDER BY rubrika_id";
         $rubriky = $db->query($sql);
         while ($rubrika = $rubriky->fetch_array()) {
             $this->menu[$rubrika['tema_id']]['rubriky'][$rubrika['rubrika_id']]['id'] = $rubrika['rubrika_id'];
             $this->menu[$rubrika['tema_id']]['rubriky'][$rubrika['rubrika_id']]['nazov'] = $rubrika['nazov_rubriky'];
         }
     }
 }
Ejemplo n.º 3
0
 public function __construct(CDatabaza $db)
 {
     parent::__construct($db);
     if (empty($_GET['rubrika'])) {
         $this->exit_program();
     }
     $this->page = 0;
     if (!empty($_GET['strana'])) {
         $this->page = $_GET['strana'] - 1;
     }
     $this->num_on_page = 10;
     $topic = $db->escape_string($_GET['rubrika']);
     $sql = "SELECT * FROM Rubrika WHERE rubrika_id=" . $topic;
     $topics = $db->query($sql);
     $topic_data = $topics->fetch_array();
     if (!$topic_data) {
         $this->exit_program();
     }
     $this->topic = $topic_data['nazov_rubriky'];
     $sql = "SELECT COUNT(clanok_id) AS num_pages FROM Clanok WHERE Clanok.zobrazit=1 AND Clanok.rubrika_id=" . $topic;
     $num_pages = $db->query($sql)->fetch_array();
     $this->num_of_pages = ceil($num_pages['num_pages'] / $this->num_on_page);
     if ($this->page < 0) {
         $this->page = 0;
     }
     if ($this->page > $this->num_of_pages) {
         $this->page = $this->num_of_pages - 1;
     }
     $start_record = $this->page * $this->num_on_page;
     $sql = "SELECT\n                Clanok.clanok_id AS id,\n                Clanok.nazov_clanku AS name,\n                Clanok.casova_znamka AS timestamp,\n                Clanok.typ_clanku_id AS type\n              FROM\n                Clanok\n              WHERE\n                Clanok.zobrazit=1 AND Clanok.rubrika_id=" . $topic . "\n              ORDER BY Clanok.casova_znamka DESC\n              LIMIT {$start_record},{$this->num_on_page}";
     $articles = $db->query($sql);
     while ($art = $articles->fetch_array()) {
         $id = $art['id'];
         $this->articles[$id]['id'] = $id;
         $this->articles[$id]['name'] = $art['name'];
         $this->articles[$id]['type'] = $art['type'];
         $this->articles[$id]['day'] = date("j.n.Y", $art['timestamp']);
         if ($art['type'] == 3) {
             $this->readPost($db, $id);
         }
     }
 }
Ejemplo n.º 4
0
 public function __construct(CDatabaza $db, $home)
 {
     parent::__construct($db);
     if (empty($_GET['clanok'])) {
         $this->exit_program();
     }
     $article = $db->escape_string($_GET['clanok']);
     $sql = "SELECT\n            Clanok.clanok_id AS id,\n            Clanok.nazov_clanku AS name,\n            Clanok.typ_clanku_id AS type,\n            Clanok.casova_znamka AS timestamp,\n            Clanok.rubrika_id AS topic_id\n         FROM\n            Clanok     \n         WHERE\n            Clanok.clanok_id={$article}\n                AND\n            Clanok.zobrazit=1";
     $articles = $db->query($sql);
     $info = $articles->fetch_array();
     if (!$info) {
         $this->exit_program();
     }
     $this->info['id'] = $info['id'];
     $this->info['name'] = $info['name'];
     $this->info['date'] = date("j.n.Y", $info['timestamp']);
     $sql = "SELECT Rubrika.nazov_rubriky AS topic,\n                     Tema.nazov_temy AS theme\n              FROM\n                Rubrika\n                    INNER JOIN\n                Tema\n                    ON Rubrika.tema_id=Tema.tema_id\n              WHERE Rubrika.rubrika_id=" . $info['topic_id'];
     $top_nfo = $db->query($sql);
     $top_nfo_data = $top_nfo->fetch_array();
     $this->topic['topic'] = $top_nfo_data['topic'];
     $this->topic['theme'] = $top_nfo_data['theme'];
     $this->topic['id'] = $info['topic_id'];
     $this->set_program($info['type'], $home);
     $sql = "SELECT \n            Uzivatel_info.uzivatel_id AS id,\n            Uzivatel_info.meno AS name,\n            Uzivatel_info.priezvisko AS surname,\n            Uzivatel_info.trieda AS class\n         FROM\n            Uzivatel_info\n                INNER JOIN\n            Clanok_uzivatel\n                ON Uzivatel_info.uzivatel_id=Clanok_uzivatel.uzivatel_id\n         WHERE\n            Clanok_uzivatel.clanok_id={$article}";
     $users = $db->query($sql);
     while ($user = $users->fetch_array()) {
         $id = $user['id'];
         $this->users[$id]['name'] = $user['name'];
         $this->users[$id]['surname'] = $user['surname'];
         $class = $user['class'];
         if ($class) {
             $i = strpos($class, ".");
             $this->users[$id]['year'] = substr($class, 0, $i);
         }
     }
 }