Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ($_POST) {
- switch ($_POST['form_name']) {
- case 'question':{
- $country = htmlspecialchars(implode($_POST['country'], ', '));
- $type = htmlspecialchars(implode($_POST['type'], ', '));
- $like = htmlspecialchars(implode($_POST['like'], ', '));
- $budget = (empty(htmlspecialchars($_POST["budget"]))) ? "" : htmlspecialchars($_POST["budget"]);
- $quantity = (empty(htmlspecialchars($_POST["quantity"]))) ? "" : htmlspecialchars($_POST["quantity"]);
- $children = (empty(htmlspecialchars($_POST["children"]))) ? "" : htmlspecialchars($_POST["children"]);
- $tel = (empty(htmlspecialchars($_POST["tel"]))) ? "" : htmlspecialchars($_POST["tel"]);
- $emailgo= new TEmail;
- $emailgo->from_email= ''; //email отправителя, можно оставить пустым
- $emailgo->from_name= 'Опросник'; //Тема сообщения
- $emailgo->to_email= 'skptyler@gmail.com'; // email получателя
- $emailgo->to_name= '';
- $emailgo->info = array(
- 'country' => $country,
- 'type' => $type,
- 'like' => $like,
- 'budget' => $budget,
- 'quantity' => $quantity,
- 'children' => $children,
- 'tel' => $tel
- );
- $body = "";
- if($emailgo->info['country'] != '') $body .= "Страна: ".$emailgo->info['country']."\n";
- if($emailgo->info['type'] != '') $body .= "Вид отдыха: ".$emailgo->info['type']."\n";
- if($emailgo->info['like'] != '') $body .= "Уподобания: ".$emailgo->info['like']."\n";
- if($emailgo->info['budget'] != '') $body .= "Бюджет: ".$emailgo->info['budget']."\n";
- if($emailgo->info['quantity'] != '') $body .= "Количество человек: ".$emailgo->info['quantity']."\n";
- if($emailgo->info['children'] != '') $body .= "Есть дети?: ".$emailgo->info['children']."\n";
- if($emailgo->info['tel'] != '') $body .= "Телефон: ".$emailgo->info['tel']."\n";
- $emailgo->body= $body;
- $emailgo->send();
- // $json['error'] = false;
- // echo json_encode($json);
- break;
- }
- case 'rest':{
- $tel = (empty(htmlspecialchars($_POST["rest-tel"]))) ? "" : htmlspecialchars($_POST["rest-tel"]);
- $emailgo= new TEmail;
- $emailgo->from_email= ''; //email отправителя, можно оставить пустым
- $emailgo->from_name= '10 лучших вариантов ближайших туров со скидкой 1 000 руб'; //Тема сообщения
- $emailgo->to_email= 'skptyler@gmail.com'; // email получателя
- $emailgo->to_name= '';
- $emailgo->info = array(
- 'rest-tel' => $tel
- );
- $body = "";
- if($emailgo->info['rest-tel'] != '') $body .= "Телефон: ".$emailgo->info['rest-tel']."\n";
- $emailgo->body= $body;
- $emailgo->send();
- // $json['error'] = false;
- // echo json_encode($json);
- break;
- }
- case 'asked':{
- $tel = (empty(htmlspecialchars($_POST["asked-tel"]))) ? "" : htmlspecialchars($_POST["asked-tel"]);
- $emailgo= new TEmail;
- $emailgo->from_email= ''; //email отправителя, можно оставить пустым
- $emailgo->from_name= 'Беспланая консультация'; //Тема сообщения
- $emailgo->to_email= 'skptyler@gmail.com'; // email получателя
- $emailgo->to_name= '';
- $emailgo->info = array(
- 'asked-tel' => $tel
- );
- $body = "";
- if($emailgo->info['asked-tel'] != '') $body .= "Телефон: ".$emailgo->info['asked-tel']."\n";
- $emailgo->body= $body;
- $emailgo->send();
- // $json['error'] = false;
- // echo json_encode($json);
- break;
- }
- case 'toors':{
- $tel = (empty(htmlspecialchars($_POST["toors-tel"]))) ? "" : htmlspecialchars($_POST["toors-tel"]);
- $emailgo= new TEmail;
- $emailgo->from_email= ''; //email отправителя, можно оставить пустым
- $emailgo->from_name= 'Заказ тура'; //Тема сообщения
- $emailgo->to_email= 'skptyler@gmail.com'; // email получателя
- $emailgo->to_name= '';
- $emailgo->info = array(
- 'toors-tel' => $tel
- );
- $body = "";
- if($emailgo->info['toors-tel'] != '') $body .= "Телефон: ".$emailgo->info['toors-tel']."\n";
- $emailgo->body= $body;
- $emailgo->send();
- // $json['error'] = false;
- // echo json_encode($json);
- break;
- }
- case 'gift':{
- $tel = (empty(htmlspecialchars($_POST["gift-tel"]))) ? "" : htmlspecialchars($_POST["gift-tel"]);
- $emailgo= new TEmail;
- $emailgo->from_email= ''; //email отправителя, можно оставить пустым
- $emailgo->from_name= 'Скидка 30%'; //Тема сообщения
- $emailgo->to_email= 'skptyler@gmail.com'; // email получателя
- $emailgo->to_name= '';
- $emailgo->info = array(
- 'gift-tel' => $tel
- );
- $body = "";
- if($emailgo->info['gift-tel'] != '') $body .= "Телефон: ".$emailgo->info['gift-tel']."\n";
- $emailgo->body= $body;
- $emailgo->send();
- // $json['error'] = false;
- // echo json_encode($json);
- break;
- }
- case 'tours2':{
- $tel = (empty(htmlspecialchars($_POST["tours2-tel"]))) ? "" : htmlspecialchars($_POST["tours2-tel"]);
- $emailgo= new TEmail;
- $emailgo->from_email= ''; //email отправителя, можно оставить пустым
- $emailgo->from_name= 'Подборка туров'; //Тема сообщения
- $emailgo->to_email= 'skptyler@gmail.com'; // email получателя
- $emailgo->to_name= '';
- $emailgo->info = array(
- 'tours2-tel' => $tel
- );
- $body = "";
- if($emailgo->info['tours2-tel'] != '') $body .= "Телефон: ".$emailgo->info['tours2-tel']."\n";
- $emailgo->body= $body;
- $emailgo->send();
- // $json['error'] = false;
- // echo json_encode($json);
- break;
- }
- }
- } else {
- // echo json_encode(array("error" => false));
- }
- function mime_header_encode($str, $data_charset, $send_charset) {
- if($data_charset != $send_charset) {
- $str=iconv($data_charset,$send_charset.'//IGNORE',$str);
- return ('=?'.$send_charset.'?B?'.base64_encode($str).'?=');
- }
- }
- class TEmail {
- public $from_email;
- public $from_name;
- public $to_email;
- public $to_name;
- public $info = array();
- public $data_charset='UTF-8';
- public $send_charset='windows-1251';
- public $body='';
- public $type='text/plain';
- function send(){
- $dc=$this->data_charset;
- $sc=$this->send_charset;
- $enc_to=mime_header_encode($this->to_name,$dc,$sc).' <'.$this->to_email.'>';
- $enc_city=mime_header_encode($this->city,$dc,$sc);
- $enc_from=mime_header_encode($this->from_name,$dc,$sc).' <'.$this->from_email.'>';
- $enc_body=$dc==$sc?$this->body:iconv($dc,$sc.'//IGNORE',$this->body);
- $headers='';
- $headers.="Mime-Version: 1.0\r\n";
- $headers.="Content-type: ".$this->type."; charset=".$sc."\r\n";
- $headers.="From: ".$enc_from."\r\n";
- return mail($enc_to,'Обратная связь',$enc_body,$headers);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement