<?php
include("connect.php");
$email = addslashes($_POST['email']);
$email = trim($email);

$ipp = $_SERVER['REMOTE_ADDR'];

$reg = intval($_POST['reg']);

if($reg==1){
$act = 1;
}else{
$act = 0;
}

if (empty($email)){
$msgx = $LANGAUGE[286];
$noi = "no";
}

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

$qn = mysql_num_rows(mysql_query("SELECT * FROM maillist where email='$email'"));
if($qn > 0){
$msgx .= $LANGAUGE[284];
$noi = "no";
}


if($noi != "no"){
$query =  mysql_query ("INSERT INTO maillist (email,active,date,ip,type) VALUES ('$email','1','".time()."','$ipp','1')") or die ("error");
$msgx = $LANGAUGE[283];
$msgx .= "<META HTTP-EQUIV='refresh' CONTENT='1; URL=index.php' />";
}else{
$msgx .= $LANGAUGE[131];
}

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