Skip to content

Instantly share code, notes, and snippets.

@roamn
Created July 11, 2017 12:52
Show Gist options
  • Save roamn/dda906437c29972137c4bac77d807450 to your computer and use it in GitHub Desktop.
Save roamn/dda906437c29972137c4bac77d807450 to your computer and use it in GitHub Desktop.
<?php
$name = htmlspecialchars( $_POST["name"] );
$tel = htmlspecialchars( $_POST["tel"] );
$radio = htmlspecialchars( $_POST["radio"] );
$comment = htmlspecialchars( $_POST["comment"] );
$order = htmlspecialchars( $_POST["pops_list"] );
$hidden = htmlspecialchars( $_POST["hidden"] );
/**
* Фильтрация спам-писем
*/
/** Простой спам-фильтр */
if ( strpos( $comment, 'http' ) || strpos( $order, 'http' ) )
show_error("Попытка отправить письмо со спамом.");
/** Простой спам-фильтр: проверка комментария на наличие ссылок */
if ( preg_match( '/[0-9]/', $name ) )
show_error("Попытка отправить письмо со спамом.");
if ($comment == ""){($comment = "Посетитель ничего не написал. :(");}
$Length2 = iconv_strlen($hidden, 'UTF-8');
if ($Length2 > 0) {show_error("Это поле должно оставаться пустым.");}
/** @var string Почта разработчика */
$to_dev = "roamn.design@ya.ru";
/*------------------------------------*/
$to = "Tops_cake_pops.Rostov@mail.ru";
$from = "$name";
$subject = "Заказ с сайта TOPS CAKE POPS";
$subject = "=?utf-8?b?". base64_encode($subject) .'?=';
$message = "
Посетитель сайта TOPS CAKE POPS, $name, оставил заказ
----------------------------------------------------
Телефон: $tel
----------------------------------------------------
Заказ:
$order
Упаковка: $radio
Комментарий: $comment
Форма: order
";
mail($to, $subject, $message, "TOPS_CAKE_POPS");
mail( $to_dev, $subject, $message, "TOPS_CAKE_POPS" );
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TOPS CAKE POPS :: Ваш заказ отправлен</title>
<link rel="stylesheet" href="contact.css" type="text/css">
</head>
<body onLoad="box3.style.marginTop=12+'%'">
<div id="box3">
<img src="../img/site/logo_small.png" alt="" width="120">
<h2>Спасибо за заказ!</h2>
<p>Мы свяжемся с Вами в ближайшее время.</p>
<br>
<a href="#" onClick="window.history.go(-1);return false;">вернуться на сайт</a>
</div>
</body>
</html>
<?php
function check_input($data, $problem = "")
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TOPS CAKE POPS :: Ваш заказ не отправлен</title>
<link rel="stylesheet" href="contact.css" type="text/css" />
</head>
<body onLoad="box3.style.marginTop=15+'%'">
<div id="box3">
<img src="../img/site/logo_small.png" alt="" width="120">
<h2>Ваш заказ не отправлен</h2>
<p><?php echo $myError; ?></p>
<br>
<p><a href="#" onClick="window.history.go(-1);return false;">назад</a></p>
</div>
</body>
</html>
<?php exit();} ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment