public static function auto_vesti()
 {
     $brojac = 0;
     $novine = Aplikacija::novine_za_auto();
     echo "Izvestaj za auto dodavanje vesti.\r\n";
     echo "Vreme: " . date("G:i   d(D). m. Y.");
     foreach ($novine as $nov) {
         $id = $nov["id_novina"];
         $n = new Novina($id);
         echo "\r\nNovine: " . $n->naziv() . "\r\n";
         $brojac = $brojac + $n->ucitaj_vesti(1);
         $rez = $n->prikazi_vesti_neobjavljene(1, "10 MINUTE", "datum_unosa");
         $bool = false;
         foreach ($rez as $r) {
             $vest = new Vest($r["id_vesti"]);
             if ($vest->grad() != "") {
                 $bool = true;
                 $vest->topublic(1);
                 echo "Grad: " . $vest->grad() . ".  Naslov: " . $vest->naslov() . "\r\n";
             }
         }
         if (!$bool) {
             echo "\r\nNema dodatih vesti vesti";
         }
     }
     echo "\r\nUkupno " . $brojac . " vesti ucitanih";
 }
 public static function ubaci_vest($naslov, $link, $kategorija, $vreme, $descr, $id_novina, $automatic)
 {
     $db = new DB();
     if (!Vest::da_li_postoji($naslov)) {
         $db->set("INSERT INTO vesti (naslov,link,kategorija,vreme,descr,id_novina,automatic,datum_unosa) VALUES ('{$naslov}','{$link}','{$kategorija}','{$vreme}',\n                      '{$descr}', '{$id_novina}', '{$automatic}', NOW()) ");
         if ($db->num == 1) {
             return $db->last_id();
         } else {
             return 0;
         }
     }
     return 0;
 }
<?php

/**
 * Created by PhpStorm.
 * User: Stefan
 * Date: 31.7.2015
 * Time: 16:29
 */
require_once 'core/init.php';
if (!isset($_SESSION["id_korisnika"])) {
    header("Location:index.php");
    die;
}
if (isset($_GET['q']) && isset($_GET['kat'])) {
    $id = sanitize($_GET['q']);
    $kat = sanitize($_GET['kat']);
    $db = new DB();
    $v = new Vest($id);
    if ($v->promeni_kategoriju($kat)) {
        echo 'Kategorija je promenjena';
    } else {
        echo 'Doslo je do greske.';
    }
} else {
    echo 'Greska (GET)';
}
    header("Location:index.php");
    die;
} else {
    $id_korisnika = $_SESSION["id_korisnika"];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>CMS</title>
    <?php 
require "includes/header.php";
?>
</head>
<body>
<div class="container">
<?php 
if (isset($_GET["id"])) {
    $vest = new Vest(sanitize($_GET["id"]));
    $reci = $vest->get_words();
    foreach ($reci as $rec) {
        echo $rec;
        echo "<br/>";
    }
} else {
    echo "Greska u GET id";
}
?>
</div>
</body>
</html>
                </div>
                <!-- kraj clanka -->
            <?php 
    }
}
?>
        <span class="label label-success">Vesti bez pronadjenog grada</span>
    <?php 
$niz_novina = Aplikacija::novine_za_auto();
foreach ($niz_novina as $nov) {
    $id_novina = $nov["id_novina"];
    $novina = new Novina($id_novina);
    $rez = $novina->prikazi_vesti_neobjavljene(1);
    foreach ($rez as $r) {
        $id_vesti = $r["id_vesti"];
        $v = new Vest($id_vesti);
        ?>
            <!-- pocetak clanak -->
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h2 class="panel-title" style="display:inline;">
                        <a href="<?php 
        echo $v->link();
        ?>
"><?php 
        echo $v->naslov();
        ?>
</a>
                    </h2>

                    <div class="pull-right">
<?php

/**
 * Created by PhpStorm.
 * User: Stefan
 * Date: 28.7.2015
 * Time: 19:09
 */
require "core/init.php";
if (!isset($_SESSION["id_korisnika"])) {
    header("Location:index.php");
    die;
}
if (isset($_GET['q']) && isset($_GET['kat']) && isset($_GET['grad'])) {
    $id = sanitize($_GET['q']);
    $kat = sanitize($_GET['kat']);
    $grad = sanitize($_GET['grad']);
    $v = new Vest($id);
    $v->postavi_grad($grad);
    if ($v->topublic($kat) == 1) {
        echo 'Vest je dodata.';
    } else {
        echo 'Greska tokom dodavanja vesti.';
    }
} else {
    echo 'Greska.';
}
<?php

/**
 * Created by PhpStorm.
 * User: Stefan
 * Date: 9.8.2015
 * Time: 16:07
 */
require "core/init.php";
if (!isset($_SESSION["id_korisnika"])) {
    header("Location:index.php");
    die;
}
if (isset($_GET['q']) && isset($_GET['grad']) && isset($_GET['kat'])) {
    $id = sanitize($_GET['q']);
    $grad = sanitize($_GET['grad']);
    $kat = sanitize($_GET['kat']);
    $v = new Vest($id);
    $v->topublic($kat);
    if ($v->odobri($kat, $grad) == 1) {
        echo 'Vest je odobrena.';
    } else {
        echo 'Greska tokom odobravanja vesti.';
    }
} else {
    echo 'Greska u GET';
}
 * User: Stefan
 * Date: 28.7.2015
 * Time: 20:10
 */
require "core/init.php";
if (!isset($_SESSION["id_korisnika"])) {
    header("Location:index.php");
    die;
}
if (isset($_GET['kontrola'])) {
    $kontrola = sanitize($_GET['kontrola']);
    switch ($kontrola) {
        case "ukorpu":
            if (isset($_GET["q"])) {
                $id = sanitize($_GET["q"]);
                $vest = new Vest($id);
                if ($vest->ukorpu() == 1) {
                    echo "Vest je prebacena u korpu";
                } else {
                    echo "Greska tokom prebacivanja u korpu";
                }
            } else {
                echo "Nema q u GET";
            }
            break;
        case "ispraznikorpu":
            $br = Aplikacija::isprazni_korpu();
            echo "Ukupno " . $br . "vesti izbrisano.";
            break;
        default:
            echo "Greska u kontroli";
/**
 * Created by PhpStorm.
 * User: Stefan
 * Date: 29.7.2015
 * Time: 0:14
 */
require_once 'core/init.php';
if (!isset($_SESSION["id_korisnika"])) {
    header("Location:index.php");
    die;
} else {
    $id_korisnika = $_SESSION["id_korisnika"];
}
if (isset($_GET['q'])) {
    $id = sanitize($_GET['q']);
    $v = new Vest($id);
    $lat = $v->lat();
    $lng = $v->lng();
    $naziv = $v->grad();
} else {
    die;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>CMS</title>
<?php 
require "includes/header.php";
?>
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCqECZ8wTuVbGEVFw1o3TlwL4qhvMwYsn0"></script>
<marquee scrollamount="5">
    <?php 
$db = new DB();
$db->get("SELECT id_vesti FROM vesti WHERE obrisano=0 AND datum_publikovanja IS NOT NULL AND obrisano=0 AND vreme >= DATE(NOW() - INTERVAL 1 DAY) ORDER BY datum_publikovanja DESC ");
//$db->get("SELECT id_vesti FROM vesti WHERE datum_publikovanja IS NOT NULL AND obrisano=0");
$rez = $db->res;
foreach ($rez as $r) {
    $id_v = $r["id_vesti"];
    $v = new Vest($id_v);
    echo '<span class="mali-logo"></span><a class="fancy" href="' . $v->link() . '"><span style="color: #D54401">' . $v->kategorija() . ' </span> ' . $v->naslov() . '</a>';
}
?>
</marquee>
                        Ucitaj nove vesti
                    </div>
                </div>
                <a  href="<?php 
echo $nov->link_novina();
?>
" target="_blank" ><span class="label label-info"><?php 
echo $nov->naziv();
?>
</span></a>
        <p class="date" id="nove-vesti"></p>
    <?php 
$res = $nov->prikazi_vesti_neobjavljene(0);
foreach ($res as $r) {
    $id = $r["id_vesti"];
    $n_vest = new Vest($id);
    ?>
        <!-- pocetak clanak -->
        <div class="panel panel-default">
            <div class="panel-heading">
                <h2 class="panel-title" style="display:inline;">
                   <a href="<?php 
    echo $n_vest->link();
    ?>
"> <?php 
    echo $n_vest->naslov();
    ?>
</a>
                </h2>

                <div class="pull-right">
<?php

require "core/init.php";
if (!isset($_SESSION["id_korisnika"])) {
    header("Location:index.php");
    die;
}
if (isset($_GET["id_grada"]) && $_GET["id_vesti"]) {
    $id_grada = sanitize($_GET["id_grada"]);
    $id_vesti = sanitize($_GET["id_vesti"]);
    $vest = new Vest($id_vesti);
    if ($vest->postavi_grad($id_grada)) {
        echo "Grad je promenjen.";
    } else {
        echo "GRESKA: db->num != 1";
    }
} else {
    echo "GRESKA: nisu lepo setovane GET var";
}
 * Date: 12.6.2015
 * Time: 13:20
 */
$vreme = '1';
$kat = '0';
if (isset($_POST["filter"]) && $_POST["filter"] != "") {
    $filter = json_decode($_POST["filter"], true);
    $vreme = $filter['vreme'];
    $kat = $filter['kategorije'];
}
if ($kat == '0') {
    $katsql = "";
} else {
    $katsql = "AND kategorija='{$kat}'";
}
$db = new DB();
$sql = "SELECT id_vesti FROM vesti WHERE obrisano=0 AND datum_publikovanja IS NOT NULL AND DATE(`vreme`) >= DATE(NOW() - INTERVAL '{$vreme}' DAY)" . $katsql;
$db->get($sql);
$data = array();
$i = 0;
$rez = $db->res;
foreach ($rez as $r) {
    $vest = new Vest($r['id_vesti']);
    $data[$i]['tittle'] = $vest->naslov();
    $data[$i]['link'] = $vest->link();
    $data[$i]['lat'] = $vest->lat();
    $data[$i]['lng'] = $vest->lng();
    $data[$i]['time'] = $vest->vreme();
    $i++;
}
echo json_encode($data, JSON_PRETTY_PRINT);
<?php

/**
 * Created by PhpStorm.
 * User: Stefan
 * Date: 29.7.2015
 * Time: 20:03
 */
require_once "core/init.php";
if (!isset($_SESSION["id_korisnika"])) {
    header("Location:index.php");
    die;
} else {
    $id_korisnika = $_SESSION["id_korisnika"];
}
if (isset($_GET["q"]) && isset($_GET["lat"]) && isset($_GET["lng"]) && isset($_GET["naziv"])) {
    $id = sanitize($_GET["q"]);
    $lat = sanitize($_GET["lat"]);
    $lng = sanitize($_GET["lng"]);
    $naziv = sanitize($_GET["naziv"]);
    $n = new Vest($id);
    $id_n_g = $n->dodaj_grad($lat, $lng, $naziv, 0);
    if ($n->postavi_grad($id_n_g) == 1) {
        echo "Lokacija promenjena";
    } else {
        echo "Greska tokom promene lokacije";
    }
} else {
    echo 'Doslo je do greske (GET)';
}
 public function test()
 {
     $suma = 0;
     $rss_array = $this->link_rss();
     foreach ($rss_array as $rss) {
         $raw_rss = file_get_contents($rss["link_rss"]);
         $xml_rss = new SimpleXMLElement($raw_rss);
         foreach ($xml_rss->channel->item as $news) {
             $title = $news->title->__toString();
             $desc = $news->description->__toString();
             $link = $news->link->__toString();
             $vr = $news->pubDate->__toString();
             $vr = strtotime($vr);
             $vreme = date("Y-m-d H:i:s", $vr);
             $id = Vest::ubaci_vest($title, $link, 1, $vreme, $desc, $this->id_novina, 0);
             $vest = new Vest($id);
             $reci = $vest->get_words();
             $suma = $suma + count($reci);
         }
     }
     echo 'Broj reci = ' . $suma;
 }