<?php
session_start();
include("connect.php");

if($_POST['code'] != $_SESSION['captchacode'] OR $_SESSION["captchacode"]=='')
{
tpl_header($LANGAUGE[126]);
table($LANGAUGE[126],$LANGAUGE[178],1);
tpl_footer();
exit;
}

$name         = text(1,$_POST['name']);
$message      = text(1,$_POST['message']);
$country      = text(1,$_POST['countryid']);
$email        = text(1,$_POST['sender']);
$cat          = text(1,$_POST['cat']);
$idt          = text(1,$_POST['idt']);

$d = time();
$ip = $_SERVER['REMOTE_ADDR'];

if($cat==1){
if ($htmlorphp=="1"){
$links = "news-".$idt.".html";
}else{
$links = "news.php?action=view&id=".$idt."";
}
}elseif($cat==2){

}else{
if ($htmlorphp=="1"){
$links = "index.html";
}else{
$links = "index.php";
}
}

if ($name==""){
$xxz = $LANGAUGE[127];
$fff = "no";
}

if ($message==""){
$xxz = $LANGAUGE[128];
$fff = "no";
}

if ($country==""){
$xxz = $LANGAUGE[129];
$fff = "no";
}

if (!eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+.([a-zA-z]{2,4})$',$email)){
$xxz = $LANGAUGE[130];
$fff = "no";
}

if($fff != "no"){
$query = mysql_query ("INSERT INTO comment (name,text,country,email,date,ip,active,idt,cat) VALUES ('$name','$message','$country','$email','$d','$ip','$activecomment','$idt','$cat')");
$xxzz = $LANGAUGE[132];
$xxzz .= "<meta http-equiv='Refresh' content='2;URL=$links' />";
}else{
$xxzz = $xxz.$LANGAUGE[131];
}

tpl_header($LANGAUGE[126]);
table($LANGAUGE[126],$xxzz,1);
tpl_footer();
?>