<?php
require'config.php';;
$title='Отправь E-Mail';
head();
aut();
$headmod = "Mail";
if ($_GET[view]=="")
{
$rand = rand(1000, 9999);
$_SESSION['rand'] = "$rand";
echo "<form method=\"post\" action=\"e-mail.php?view=3\">";
echo "<p class=\"b\">";
echo "<b>E-mail получателя:</b><br/>";
echo "<input type=\"text\" name=\"mail\" maxlength=\"20\"/><br/>";
echo "<b>Ваш e-mail:</b>";
echo "<br/><input type=\"text\" name=\"to-mail\" maxlength=\"20\"/><br/>";
echo "<b>Тема [50 сим.]:</b>";
echo "<br/><input type=\"text\" name=\"thema\" maxlength=\"50\"/><br/>";
echo "<b>Сообщение:</b>";
echo "<br/><textarea name=\"text\" rows=\"5\" cols=\"30\"></textarea><br/>";
echo "<b>Введите число:</b> <font color=\"red\">$rand</font><br/><input size=\"5\" maxlength=\"5\" name=\"imgrand\" value=\"\" /><br/>";
echo "<input type=\"submit\" name=\"do\" value=\"Отправить\"/></p></form>";
}
if($_GET[view]==script)
{
}
if($_GET[view]==3)
{
$text=htmlspecialchars(stripslashes(trim($_POST['text'])));
$tema= check($_POST['thema']);
$ot_email = check($_POST['to-mail']);
if (!eregi("^([0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-wyz][a-z](fo|g|l|m|mes|o|op|pa|ro|seum|t|u|v|z)?)$", check($_POST['mail'])))
if(empty($_POST['imgrand']))
{
echo"<p><b>Не введено проверочное число</b><br/><br/>";
echo"<a href=\"e-mail.php\"><b>Пожалуйста повторите!</b></a></p>";
echo gb.'<a href="'.H.'enter">Прихожая</a>'.div;
foot();
}
if(!empty($_POST['imgrand']))
{
if($_POST['imgrand'] != $_SESSION['rand'])
{
echo"<p><b>Проверочное число неверно</b><br/><br/>";
echo"<a href=\"e-mail.php\"><b>Пожалуйста повторите!</b></a></p>";
echo gb.'<a href="'.H.'enter">Прихожая</a>'.div;
foot();
}
}
$text = "
$_POST[text] <br/>----------------------------------------------------------------<br/>Написано в почтовом клиенте ".$_SERVER['HTTP_HOST']." - Ето твое пространство!</b><br/>";
$headers="Content-Type: text/html; charset=utf-8\n";
$headers.="From: $ot_email\nX-Mailer: PHP v.".phpversion();
mail($_POST['mail'],$tema,$text,$headers);
echo"<p><b><font color='green'>Ваше сообщение успешно отправлено!</font></b><br/>";
}
echo gb.'<a href="'.H.'enter">Прихожая</a>'.div;
foot();
?>