Advertisement
billabau

fields disappeared

Apr 20th, 2018
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1.  
  2. application/x-httpd-php rd-mailform.php ( PHP script, ASCII text )
  3. <?php
  4.  
  5. $recipients = 'marketing@first-beauty.it';
  6.  
  7. try {
  8. require './phpmailer/PHPMailerAutoload.php';
  9.  
  10. preg_match_all("/([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)/", $recipients, $addresses, PREG_OFFSET_CAPTURE);
  11.  
  12. if (!count($addresses[0])) {
  13. die('MF001');
  14. }
  15.  
  16. if (preg_match('/^(127\.|192\.168\.)/', $_SERVER['REMOTE_ADDR'])) {
  17. die('MF002');
  18. }
  19.  
  20. $template = file_get_contents('rd-mailform.tpl');
  21.  
  22. if (isset($_POST['form-type'])) {
  23. switch ($_POST['form-type']){
  24. case 'contact':
  25. $subject = 'A message from your site visitor';
  26. break;
  27. case 'subscribe':
  28. $subject = 'Subscribe request';
  29. break;
  30. case 'order':
  31. $subject = 'Order request';
  32. break;
  33. default:
  34. $subject = 'A message from your site visitor';
  35. break;
  36. }
  37. }else{
  38. die('MF004');
  39. }
  40.  
  41. if (isset($_POST['email'])) {
  42. $template = str_replace(
  43. array("<!-- #{FromState} -->", "<!-- #{FromEmail} -->"),
  44. array("Email:", $_POST['email']),
  45. $template);
  46. }else{
  47. die('MF003');
  48. }
  49.  
  50. if (isset($_POST['message'])) {
  51. $template = str_replace(
  52. array("<!-- #{MessageState} -->", "<!-- #{MessageDescription} -->"),
  53. array("Message:", $_POST['message']),
  54. $template);
  55. }
  56.  
  57. preg_match("/(<!-- #{BeginInfo} -->)(.|\n)+(<!-- #{EndInfo} -->)/", $template, $tmp, PREG_OFFSET_CAPTURE);
  58. foreach ($_POST as $key => $value) {
  59. if ($key != "email" && $key != "message" && $key != "form-type" && !empty($value)){
  60. $info = str_replace(
  61. array("<!-- #{BeginInfo} -->", "<!-- #{InfoState} -->", "<!-- #{InfoDescription} -->"),
  62. array("", ucfirst($key) . ':', $value),
  63. $tmp[0][0]);
  64.  
  65. $template = str_replace("<!-- #{EndInfo} -->", $info, $template);
  66. }
  67. }
  68.  
  69. $template = str_replace(
  70. array("<!-- #{Subject} -->", "<!-- #{SiteName} -->"),
  71. array($subject, $_SERVER['SERVER_NAME']),
  72. $template);
  73.  
  74. $mail = new PHPMailer();
  75. $mail->From = $_POST['email'];
  76.  
  77.  
  78. # Attach file
  79. if (isset($_FILES['file']) &&
  80. $_FILES['file']['error'] == UPLOAD_ERR_OK) {
  81. $mail->AddAttachment($_FILES['file']['tmp_name'],
  82. $_FILES['file']['name']);
  83. }
  84.  
  85. if (isset($_POST['name'])){
  86. $mail->FromName = $_POST['name'];
  87. }else{
  88. $mail->FromName = "Site Visitor";
  89. }
  90.  
  91. foreach ($addresses[0] as $key => $value) {
  92. $mail->addAddress($value[0]);
  93. }
  94.  
  95. $mail->CharSet = 'utf-8';
  96. $mail->Subject = $subject;
  97. $mail->MsgHTML($template);
  98. $mail->send();
  99.  
  100. die('MF000');
  101. } catch (phpmailerException $e) {
  102. die('MF254');
  103. } catch (Exception $e) {
  104. die('MF255');
  105. }?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement