Advertisement
Guest User

Untitled

a guest
Aug 16th, 2018
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.27 KB | None | 0 0
  1. <?php
  2. if ($_POST) {
  3.     switch ($_POST['form_name']) {
  4.         case 'question':{
  5.  
  6.  
  7.             $country = htmlspecialchars(implode($_POST['country'], ', '));
  8.             $type = htmlspecialchars(implode($_POST['type'], ', '));
  9.             $like = htmlspecialchars(implode($_POST['like'], ', '));
  10.             $budget = (empty(htmlspecialchars($_POST["budget"]))) ? "" : htmlspecialchars($_POST["budget"]);
  11.             $quantity = (empty(htmlspecialchars($_POST["quantity"]))) ? "" : htmlspecialchars($_POST["quantity"]);
  12.             $children = (empty(htmlspecialchars($_POST["children"]))) ? "" : htmlspecialchars($_POST["children"]);
  13.             $tel = (empty(htmlspecialchars($_POST["tel"]))) ? "" : htmlspecialchars($_POST["tel"]);
  14.  
  15.             $emailgo= new TEmail;
  16.             $emailgo->from_email= ''; //email отправителя, можно оставить пустым
  17.             $emailgo->from_name= 'Опросник'; //Тема сообщения
  18.             $emailgo->to_email= 'skptyler@gmail.com'; // email получателя
  19.             $emailgo->to_name= '';
  20.  
  21.             $emailgo->info = array(
  22.                 'country' => $country,
  23.                 'type' => $type,
  24.                 'like' => $like,
  25.                 'budget' => $budget,
  26.                 'quantity' => $quantity,
  27.                 'children' => $children,
  28.                 'tel' => $tel
  29.             );
  30.  
  31.  
  32.             $body = "";
  33.             if($emailgo->info['country'] != '') $body .= "Страна: ".$emailgo->info['country']."\n";
  34.             if($emailgo->info['type'] != '') $body .= "Вид отдыха: ".$emailgo->info['type']."\n";
  35.             if($emailgo->info['like'] != '') $body .= "Уподобания: ".$emailgo->info['like']."\n";
  36.             if($emailgo->info['budget'] != '') $body .= "Бюджет: ".$emailgo->info['budget']."\n";
  37.             if($emailgo->info['quantity'] != '') $body .= "Количество человек: ".$emailgo->info['quantity']."\n";
  38.             if($emailgo->info['children'] != '') $body .= "Есть дети?: ".$emailgo->info['children']."\n";
  39.             if($emailgo->info['tel'] != '') $body .= "Телефон: ".$emailgo->info['tel']."\n";
  40.  
  41.             $emailgo->body= $body;
  42.             $emailgo->send();
  43.  
  44.             // $json['error'] = false;
  45.  
  46.             // echo json_encode($json);
  47.                
  48.             break;
  49.         }
  50.         case 'rest':{
  51.            
  52.             $tel = (empty(htmlspecialchars($_POST["rest-tel"]))) ? "" : htmlspecialchars($_POST["rest-tel"]);
  53.            
  54.  
  55.             $emailgo= new TEmail;
  56.             $emailgo->from_email= ''; //email отправителя, можно оставить пустым
  57.             $emailgo->from_name= '10 лучших вариантов ближайших туров со скидкой 1 000 руб'; //Тема сообщения
  58.             $emailgo->to_email= 'skptyler@gmail.com'; // email получателя
  59.             $emailgo->to_name= '';
  60.  
  61.  
  62.             $emailgo->info = array(
  63.                 'rest-tel' => $tel 
  64.             );
  65.  
  66.  
  67.             $body = "";
  68.             if($emailgo->info['rest-tel'] != '') $body .= "Телефон: ".$emailgo->info['rest-tel']."\n";
  69.            
  70.             $emailgo->body= $body;
  71.             $emailgo->send();
  72.  
  73.             // $json['error'] = false;
  74.  
  75.             // echo json_encode($json);
  76.  
  77.             break;
  78.         }
  79.         case 'asked':{
  80.            
  81.             $tel = (empty(htmlspecialchars($_POST["asked-tel"]))) ? "" : htmlspecialchars($_POST["asked-tel"]);
  82.            
  83.  
  84.             $emailgo= new TEmail;
  85.             $emailgo->from_email= ''; //email отправителя, можно оставить пустым
  86.             $emailgo->from_name= 'Беспланая консультация'; //Тема сообщения
  87.             $emailgo->to_email= 'skptyler@gmail.com'; // email получателя
  88.             $emailgo->to_name= '';
  89.  
  90.  
  91.             $emailgo->info = array(
  92.                 'asked-tel' => $tel
  93.             );
  94.  
  95.  
  96.             $body = "";
  97.             if($emailgo->info['asked-tel'] != '') $body .= "Телефон: ".$emailgo->info['asked-tel']."\n";
  98.            
  99.             $emailgo->body= $body;
  100.             $emailgo->send();
  101.  
  102.             // $json['error'] = false;
  103.  
  104.             // echo json_encode($json);
  105.  
  106.             break;
  107.         }
  108.         case 'toors':{
  109.            
  110.             $tel = (empty(htmlspecialchars($_POST["toors-tel"]))) ? "" : htmlspecialchars($_POST["toors-tel"]);
  111.            
  112.  
  113.             $emailgo= new TEmail;
  114.             $emailgo->from_email= ''; //email отправителя, можно оставить пустым
  115.             $emailgo->from_name= 'Заказ тура'; //Тема сообщения
  116.             $emailgo->to_email= 'skptyler@gmail.com'; // email получателя
  117.             $emailgo->to_name= '';
  118.  
  119.  
  120.             $emailgo->info = array(
  121.                 'toors-tel' => $tel
  122.             );
  123.  
  124.  
  125.             $body = "";
  126.             if($emailgo->info['toors-tel'] != '') $body .= "Телефон: ".$emailgo->info['toors-tel']."\n";
  127.            
  128.             $emailgo->body= $body;
  129.             $emailgo->send();
  130.  
  131.             // $json['error'] = false;
  132.  
  133.             // echo json_encode($json);
  134.  
  135.             break;
  136.         }
  137.         case 'gift':{
  138.            
  139.             $tel = (empty(htmlspecialchars($_POST["gift-tel"]))) ? "" : htmlspecialchars($_POST["gift-tel"]);
  140.            
  141.  
  142.             $emailgo= new TEmail;
  143.             $emailgo->from_email= ''; //email отправителя, можно оставить пустым
  144.             $emailgo->from_name= 'Скидка 30%'; //Тема сообщения
  145.             $emailgo->to_email= 'skptyler@gmail.com'; // email получателя
  146.             $emailgo->to_name= '';
  147.  
  148.  
  149.             $emailgo->info = array(
  150.                 'gift-tel' => $tel 
  151.             );
  152.  
  153.  
  154.             $body = "";
  155.             if($emailgo->info['gift-tel'] != '') $body .= "Телефон: ".$emailgo->info['gift-tel']."\n";
  156.            
  157.             $emailgo->body= $body;
  158.             $emailgo->send();
  159.  
  160.             // $json['error'] = false;
  161.  
  162.             // echo json_encode($json);
  163.  
  164.             break;
  165.         }
  166.     }
  167. } else {
  168.     // echo json_encode(array("error" => false));
  169. }
  170.  
  171. function mime_header_encode($str, $data_charset, $send_charset) {
  172.     if($data_charset != $send_charset)
  173.     $str=iconv($data_charset,$send_charset.'//IGNORE',$str);
  174.     return ('=?'.$send_charset.'?B?'.base64_encode($str).'?=');
  175. }
  176. class TEmail {
  177.     public $from_email;
  178.     public $from_name;
  179.     public $to_email;
  180.     public $to_name;
  181.     public $info = array();
  182.     public $data_charset='UTF-8';
  183.     public $send_charset='windows-1251';
  184.     public $body='';
  185.     public $type='text/plain';
  186.  
  187.     function send(){
  188.         $dc=$this->data_charset;
  189.         $sc=$this->send_charset;
  190.         $enc_to=mime_header_encode($this->to_name,$dc,$sc).' <'.$this->to_email.'>';
  191.         $enc_city=mime_header_encode($this->city,$dc,$sc);
  192.         $enc_from=mime_header_encode($this->from_name,$dc,$sc).' <'.$this->from_email.'>';
  193.         $enc_body=$dc==$sc?$this->body:iconv($dc,$sc.'//IGNORE',$this->body);
  194.         $headers='';
  195.         $headers.="Mime-Version: 1.0\r\n";
  196.         $headers.="Content-type: ".$this->type."; charset=".$sc."\r\n";
  197.         $headers.="From: ".$enc_from."\r\n";
  198.         return mail($enc_to,'Обратная связь',$enc_body,$headers);
  199.     }
  200.  
  201. }
  202. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement