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

$action = $_GET['action'];
if(!isset($action)) $action = "index";

IF ($action=="index"){
$text1 = rand(0,9);
$text2 = rand(0,9);
$text3 = "<label for='xzx5'>".$LANGAUGE[176]." ".$text1." + ".$text2."</label>";
$text4 = $text1 + $text2;

$_SESSION["captchacode"] = $text4;

tpl_header($LANGAUGE[181]);
bar($namelinks1,$LANGAUGE[181],"","");

?>
<script type="text/javascript">
// function to verify registration data
function regCheck(submitform) {
var correct = true;
var emailPat =/^(.+)@(.+)$/;
var matchArray = submitform.sender.value.match(emailPat);
var count = 0;


if (submitform.subject.value == "") {
        correct = false;
        alert("<?php echo $LANGAUGE[173]; ?>");
        submitform.subject.focus();
} else if (matchArray == null) {
        correct = false;
        alert("<?php echo $LANGAUGE[172]; ?>");
        submitform.sender.focus();


} else if (submitform.message.value == "") {
        correct = false;
        alert("<?php echo $LANGAUGE[174]; ?>");
        submitform.message.focus();


} else if (submitform.code.value == "") {
        correct = false;
        alert("<?php echo $LANGAUGE[177]; ?>");
        submitform.code.focus();
}

if (correct) {
        submitform.submit();
}

}
</script>
<?php

if ($htmlorphp=="1"){
$em = "tellme_ok.html";
}else{
$em = "tellme.php?action=send";
}

$form = "<form name='signup' method='POST' action='$em'>

<div>
<input type='text' name='subject' size='50' dir='rtl' id='f3' onfocus=\"this.select()\" /> <label for='f3'>".$LANGAUGE[182]."</label><br /><br />
<input type='text' name='sender' size='50' dir='ltr' id='f1' onfocus=\"this.select()\" /> <label for='f1'>".$LANGAUGE[183]."</label><br /><br />
<textarea name='message' cols='60' id='f4' rows='8' onfocus=\"this.select()\"></textarea><br /><br />
".$text3." <input id='xzx5' name='code' size='10' dir='ltr' onfocus=\"this.select()\" />&nbsp;&nbsp;&nbsp;&nbsp;
<input type='button' value='".$LANGAUGE[171]."' name='Send' id='Send' onclick=\"regCheck(signup)\" />
</div>
</form>";

table($LANGAUGE[181],$form,1);
tpl_footer();

}ELSEIF ($action=="send"){

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

$sender    = $_POST['sender'];
$message   = $_POST['message'];
$subject   = $_POST['subject'];
$signature = "\n\n_______________________\n $name_site\n $name_url";

$headers = "From: ". $sender ."<" . $sender . ">" . "\r\n";

if($sender==""){
$ch = "no";
$te1 = '<div>'.$LANGAUGE[172].'</div>';
}


if($subject==""){
$ch = "no";
$te2 = '<div>'.$LANGAUGE[173].'</div>';
}

if($message==""){
$ch = "no";
$te3 = '<div align="center">'.$LANGAUGE[174].'</div>';
}

if($ch != "no"){
$X = @mail ($name_email,$subject,$message.$signature,$headers);
If ($X){
$xxx = $LANGAUGE[179];
if($htmlorphp==1){
$zy = "index.html";
}else{
$zy = "index.php";
}
$xxx .= "<meta http-equiv='Refresh' content='1;URL=$zy' />";
}else{
$xxx = $LANGAUGE[180];
}
$tee = $xxx;
}else{
$tee = $te1.$te2.$te3.$LANGAUGE[131];
}


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