session_start();
@ob_start("ob_gzhandler");
require_once('inc/config.inc.php');
require_once 'libs/smarty/Smarty.class.php';
//require_once 'class/MySmarty.class.php';
require_once "class/class.img_validator.php";
//mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS);
//mysql_select_db(MYSQL_DATABASE);
$connection = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DATABASE);
$connection->set_charset("utf8");
$added = false;
$word = isset($_REQUEST['code']) ? $_REQUEST['code'] :'';
$aname = isset($_REQUEST['yourname']) ? $_REQUEST['yourname'] :'';
$entry = isset($_REQUEST['entry']) ? $_REQUEST['entry'] :'';
$email = isset($_REQUEST['email']) ? $_REQUEST['email'] :'';
$cmd = isset($_REQUEST['cmd']) ? $_REQUEST['cmd'] : '';
$msg = '';
if($cmd == 'add')
{
$img = new img_validator();
if( $aname == '' || $email == '')
{
$msg = "Bitte geben Sie Ihren Namen und Emailadresse ein!";
}
else
{
if( $img->checks_word($word))
{
$entry = addslashes($entry);
$trace = implode("\n", $_SERVER);
mysqli_query($connection,"insert into tron_guestbook (name, email, entry, create_date, trace) values ('$aname', '$email', '$entry', NOW(), '$trace')");
$added = true;
}
else $msg="Fehler bei der Überprüfung des Sicherheitscodes. Versuchen Sie es noch einmal!";
}
}
$smarty = new Smarty();
$page = "guestbook.php";
include '_currentTab.inc.php';
$smarty->template_dir = SMARTY_DIR.'templates/';
$smarty->compile_dir = SMARTY_DIR.'templates_c/';
$smarty->config_dir = SMARTY_DIR.'configs/';
$smarty->cache_dir = SMARTY_DIR.'cache/';
$smarty->assign("title", "CNC Fräse, Portalfräse, Bauanleitung, DIY Router, Fräser, Modellbau Fräse, Bauplan, CNC Fräsen");
$smarty->assign("language", "de");
$guests = array();
$res = mysqli_query($connection,"select *,date_format(create_date, '%d.%m.%Y') as cdate from tron_guestbook order by create_date desc");
while($row =mysqli_fetch_assoc($res))
{
$row['entry'] = str_replace("\n", "
", $row['entry']);
$row['comment'] = str_replace("\n", "
", $row['comment']);
$guests[] = $row;
}
$smarty->assign('guests', $guests);
$smarty->assign('msg', $msg);
$smarty->assign('added', $added);
$smarty->assign('aname', $aname);
$smarty->assign('entry', $entry);
$smarty->assign('email', $email);
$smarty->display("guestbook.tpl");
?>