<?php
error_reporting (E_ALL);
include('komentarai/iptocountry.php');
include('komentarai/komentarai.class.php');
// Patikrinam, ar submitas
if ($_SERVER['REQUEST_METHOD'] == 'POST') 
{ // Surasom stuff ir redirect
    // disabled since 2014.04.04
    //$bu = new Irasas (file("komentarai/komentarai.txt")); 
    //$bu->put('datalaikas', date("Y-m-d H:i:s", time()));
    //$bu->put('vardas', htmlspecialchars($_POST['vardas']));
    //$bu->put('email', htmlspecialchars($_POST['email']));
    //$bu->put('komentaras', htmlspecialchars(substr($_POST['komentaras'], 0, 3000)));
    //$bu->put('ip', $_SERVER['REMOTE_ADDR']);
    //$bu->put('salis', iptocountry($_SERVER['REMOTE_ADDR']));
    //if (!$bu->write(fopen("komentarai/komentarai.txt", "w")))
    //    echo "Kazkas nepavyko su irasymu i komentarai.txt";
    print '<META HTTP-EQUIV="refresh" content="0;URL=tranzas2007.php?lucky">';
}
else // Rodom templeita
{
    require_once('/home/mo/Smarty-2.6.18/libs/'. 'Smarty.class.php');
    include ('komentarai/ip_files/countries.php');
    $smarty = new Smarty();
    $smarty->template_dir = '/home/mo/www/files/tranzas2007/komentarai/';
    $smarty->compile_dir = '/home/mo/www/files/tranzas2007/komentarai/smarty/templates_c/';
    $smarty->config_dir = '/home/mo/www/files/tranzas2007/komentarai/smarty/configs/';
    $smarty->cache_dir = '/home/mo/www/files/tranzas2007/komentarai/smarty/cache/';
    // Uzsetinsim kintamuosius pagal XML komentaru failiuka
    $bu = new Skaitymas (file("komentarai/komentarai.txt"));
    $komentarai = $bu->getComments();
    $smarty->assign('komentarai', $komentarai['komentarai']);
    $smarty->display ('tranzas2007.tpl');
}
?>
