Advertisement
Guest User

Untitled

a guest
May 27th, 2016
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.70 KB | None | 0 0
  1. <?php
  2. function ValidateEmail($email)
  3. {
  4.    $pattern = '/^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i';
  5.    return preg_match($pattern, $email);
  6. }
  7. if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['formid'] == 'indexform2')
  8. {
  9.    $mailto = 'visa-pro1@mail.ru';
  10.    $mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto;
  11.    $mailcc = 'manara1974@mail.ru';
  12.    $subject = 'Заявка с VisaPRO.KZ';
  13.    $message = 'Values submitted from web site form:';
  14.    $success_url = './thanks.html';
  15.    $error_url = '';
  16.    $error = '';
  17.    $eol = "\n";
  18.    $max_filesize = isset($_POST['filesize']) ? $_POST['filesize'] * 1024 : 1024000;
  19.    $boundary = md5(uniqid(time()));
  20.    $header  = 'From: '.$mailfrom.$eol;
  21.    $header .= 'Reply-To: '.$mailfrom.$eol;
  22.    $header .= 'Cc: '.$mailcc.$eol;
  23.    $header .= 'MIME-Version: 1.0'.$eol;
  24.    $header .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'.$eol;
  25.    $header .= 'X-Mailer: PHP v'.phpversion().$eol;
  26.    if (!ValidateEmail($mailfrom))
  27.    {
  28.       $error .= "The specified email address is invalid!\n<br>";
  29.    }
  30.    if (!empty($error))
  31.    {
  32.       $errorcode = file_get_contents($error_url);
  33.       $replace = "##error##";
  34.       $errorcode = str_replace($replace, $error, $errorcode);
  35.       echo $errorcode;
  36.       exit;
  37.    }
  38.    $internalfields = array ("submit", "reset", "send", "filesize", "formid", "captcha_code", "recaptcha_challenge_field", "recaptcha_response_field");
  39.    $message .= $eol;
  40.    $message .= "IP Address : ";
  41.    $message .= $_SERVER['REMOTE_ADDR'];
  42.    $message .= $eol;
  43.    foreach ($_POST as $key => $value)
  44.    {
  45.       if (!in_array(strtolower($key), $internalfields))
  46.       {
  47.          if (!is_array($value))
  48.          {
  49.             $message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol;
  50.          }
  51.          else
  52.          {
  53.             $message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol;
  54.          }
  55.       }
  56.    }
  57.    $body  = 'This is a multi-part message in MIME format.'.$eol.$eol;
  58.    $body .= '--'.$boundary.$eol;
  59.    $body .= 'Content-Type: text/plain; charset=UTF-8'.$eol;
  60.    $body .= 'Content-Transfer-Encoding: 8bit'.$eol;
  61.    $body .= $eol.stripslashes($message).$eol;
  62.    if (!empty($_FILES))
  63.    {
  64.        foreach ($_FILES as $key => $value)
  65.        {
  66.           if ($_FILES[$key]['error'] == 0 && $_FILES[$key]['size'] <= $max_filesize)
  67.           {
  68.              $body .= '--'.$boundary.$eol;
  69.              $body .= 'Content-Type: '.$_FILES[$key]['type'].'; name='.$_FILES[$key]['name'].$eol;
  70.              $body .= 'Content-Transfer-Encoding: base64'.$eol;
  71.              $body .= 'Content-Disposition: attachment; filename='.$_FILES[$key]['name'].$eol;
  72.              $body .= $eol.chunk_split(base64_encode(file_get_contents($_FILES[$key]['tmp_name']))).$eol;
  73.           }
  74.       }
  75.    }
  76.    $body .= '--'.$boundary.'--'.$eol;
  77.    if ($mailto != '')
  78.    {
  79.       mail($mailto, $subject, $body/*, $header*/);
  80.    }
  81.    header('Location: '.$success_url);
  82.    exit;
  83. }
  84. if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['formid'] == 'indexform1')
  85. {  
  86.    $mailto = 'visa-pro1@mail.ru';
  87.    $mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto;
  88.    $mailcc = 'manara1974@mail.ru';
  89.    $subject = 'Заявка с VisaPRO.KZ';
  90.    $message = 'Values submitted from web site form:';
  91.    $success_url = './thanks.html';
  92.    $error_url = '';
  93.    $error = '';
  94.    $eol = "\n";
  95.    $max_filesize = isset($_POST['filesize']) ? $_POST['filesize'] * 1024 : 1024000;
  96.    $boundary = md5(uniqid(time()));
  97.    $header  = 'From: '.$mailfrom.$eol;
  98.    $header .= 'Reply-To: '.$mailfrom.$eol;
  99.    $header .= 'Cc: '.$mailcc.$eol;
  100.    $header .= 'MIME-Version: 1.0'.$eol;
  101.    $header .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'.$eol;
  102.    $header .= 'X-Mailer: PHP v'.phpversion().$eol;
  103.    if (!ValidateEmail($mailfrom))
  104.    {
  105.       $error .= "The specified email address is invalid!\n<br>";
  106.    }
  107.    if (!empty($error))
  108.    {
  109.       $errorcode = file_get_contents($error_url);
  110.       $replace = "##error##";
  111.       $errorcode = str_replace($replace, $error, $errorcode);
  112.       echo $errorcode;
  113.       exit;
  114.    }
  115.    $internalfields = array ("submit", "reset", "send", "filesize", "formid", "captcha_code", "recaptcha_challenge_field", "recaptcha_response_field");
  116.    $message .= $eol;
  117.    $message .= "IP Address : ";
  118.    $message .= $_SERVER['REMOTE_ADDR'];
  119.    $message .= $eol;
  120.    foreach ($_POST as $key => $value)
  121.    {
  122.       if (!in_array(strtolower($key), $internalfields))
  123.       {
  124.          if (!is_array($value))
  125.          {
  126.             $message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol;
  127.          }
  128.          else
  129.          {
  130.             $message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol;
  131.          }
  132.       }
  133.    }
  134.    $body  = 'This is a multi-part message in MIME format.'.$eol.$eol;
  135.    $body .= '--'.$boundary.$eol;
  136.    $body .= 'Content-Type: text/plain; charset=UTF-8'.$eol;
  137.    $body .= 'Content-Transfer-Encoding: 8bit'.$eol;
  138.    $body .= $eol.stripslashes($message).$eol;
  139.    if (!empty($_FILES))
  140.    {
  141.        foreach ($_FILES as $key => $value)
  142.        {
  143.           if ($_FILES[$key]['error'] == 0 && $_FILES[$key]['size'] <= $max_filesize)
  144.           {
  145.              $body .= '--'.$boundary.$eol;
  146.              $body .= 'Content-Type: '.$_FILES[$key]['type'].'; name='.$_FILES[$key]['name'].$eol;
  147.              $body .= 'Content-Transfer-Encoding: base64'.$eol;
  148.              $body .= 'Content-Disposition: attachment; filename='.$_FILES[$key]['name'].$eol;
  149.              $body .= $eol.chunk_split(base64_encode(file_get_contents($_FILES[$key]['tmp_name']))).$eol;
  150.           }
  151.       }
  152.    }
  153.    $body .= '--'.$boundary.'--'.$eol;
  154.    if ($mailto != '')
  155.    {
  156.       mail($mailto, $subject, $body/*, $header*/);
  157.      
  158.    }
  159.    header('Location: '.$success_url);
  160.    exit;
  161. }
  162. if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['formid'] == 'indexform3')
  163. {  
  164.    $mailto = 'visa-pro1@mail.ru';
  165.    $mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto;
  166.    $mailcc = 'manara1974@mail.ru';
  167.    $subject = 'Заявка с VisaPRO.KZ';
  168.    $message = 'Values submitted from web site form:';
  169.    $success_url = './thanks.html';
  170.    $error_url = '';
  171.    $error = '';
  172.    $eol = "\n";
  173.    $max_filesize = isset($_POST['filesize']) ? $_POST['filesize'] * 1024 : 1024000;
  174.    $boundary = md5(uniqid(time()));
  175.    $header  = 'From: '.$mailfrom.$eol;
  176.    $header .= 'Reply-To: '.$mailfrom.$eol;
  177.    $header .= 'Cc: '.$mailcc;
  178.    $header .= 'MIME-Version: 1.0'.$eol;
  179.    $header .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'.$eol;
  180.    $header .= 'X-Mailer: PHP v'.phpversion().$eol;
  181.    if (!ValidateEmail($mailfrom))
  182.    {
  183.       $error .= "The specified email address is invalid!\n<br>";
  184.    }
  185.    if (!empty($error))
  186.    {
  187.       $errorcode = file_get_contents($error_url);
  188.       $replace = "##error##";
  189.       $errorcode = str_replace($replace, $error, $errorcode);
  190.       echo $errorcode;
  191.       exit;
  192.    }
  193.    $internalfields = array ("submit", "reset", "send", "filesize", "formid", "captcha_code", "recaptcha_challenge_field", "recaptcha_response_field");
  194.    $message .= $eol;
  195.    $message .= "IP Address : ";
  196.    $message .= $_SERVER['REMOTE_ADDR'];
  197.    $message .= $eol;
  198.    foreach ($_POST as $key => $value)
  199.    {
  200.       if (!in_array(strtolower($key), $internalfields))
  201.       {
  202.          if (!is_array($value))
  203.          {
  204.             $message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol;
  205.          }
  206.          else
  207.          {
  208.             $message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol;
  209.          }
  210.       }
  211.    }
  212.    $body  = 'This is a multi-part message in MIME format.'.$eol.$eol;
  213.    $body .= '--'.$boundary.$eol;
  214.    $body .= 'Content-Type: text/plain; charset=UTF-8'.$eol;
  215.    $body .= 'Content-Transfer-Encoding: 8bit'.$eol;
  216.    $body .= $eol.stripslashes($message).$eol;
  217.    if (!empty($_FILES))
  218.    {
  219.        foreach ($_FILES as $key => $value)
  220.        {
  221.           if ($_FILES[$key]['error'] == 0 && $_FILES[$key]['size'] <= $max_filesize)
  222.           {
  223.              $body .= '--'.$boundary.$eol;
  224.              $body .= 'Content-Type: '.$_FILES[$key]['type'].'; name='.$_FILES[$key]['name'].$eol;
  225.              $body .= 'Content-Transfer-Encoding: base64'.$eol;
  226.              $body .= 'Content-Disposition: attachment; filename='.$_FILES[$key]['name'].$eol;
  227.              $body .= $eol.chunk_split(base64_encode(file_get_contents($_FILES[$key]['tmp_name']))).$eol;
  228.           }
  229.       }
  230.    }
  231.    $body .= '--'.$boundary.'--'.$eol;
  232.    if ($mailto != '')
  233.    {
  234.       mail($mailto, $subject, $body/*, $header*/);
  235.    }
  236.    header('Location: '.$success_url);
  237.  
  238.  
  239.    exit;
  240. }
  241. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement