Advertisement
tjromano

auto.php

May 14th, 2012
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.44 KB | None | 0 0
  1. <?php session_start();
  2. //ini_set('display_errors', 'On');
  3. //error_reporting(E_ALL);
  4.  
  5.  
  6. /* *********** FUNCTIONS ****************** */
  7.  
  8. function checkit($insuredName) {
  9. return(str_replace(array("\r", "\n", "%OA", "%oa", "%OD", "%od", "Content-Type:","BCC:","bcc:"), "", $insuredName));
  10. }
  11.  
  12. function cleanUp($data) {
  13. $data = trim(strip_tags(htmlspecialchars($data)));
  14. return $data;
  15. }
  16.  
  17. $referer=$_SERVER['HTTP_REFERER'];
  18. #print($referer);
  19. $refsplit=explode("?",$referer);
  20. #if($refsplit[0]=='http://www.tracy-driscoll.com/landingpages/auto/quote2.html'){
  21.  
  22. $errorFields = array();
  23.  
  24. if (isset($_POST['submit'])) {
  25. echo "got to this stage<br />";
  26. $insuredName =cleanUp($_POST['insuredName']);
  27. $address=cleanUp($_POST['address']);
  28. $city=cleanUp($_POST['city']);
  29. $state=cleanUp($_POST['state']);
  30. $zip=cleanUp($_POST['zip']);
  31. $phone=cleanUp($_POST['phone']);
  32. $email=cleanUp($_POST['email']);
  33. $dobMonth=cleanUp($_POST['dobMonth']);
  34. $dobDay=cleanUp($_POST['dobDay']);
  35. $dobYear=cleanUp($_POST['dobYear']);
  36. $driversLicense=cleanUp($_POST['driversLicense']);
  37. $doYou=cleanUp($_POST['doYou']);
  38. $bodilyInjury=cleanUp($_POST['bodilyInjury']);
  39. $propertyDamage=cleanUp($_POST['propertyDamage']);
  40. $medicalPayments=cleanUp($_POST['medicalPayments']);
  41. $comprehensiveDeductible=cleanUp($_POST['comprehensiveDeductible']);
  42. $collisionDeductible=cleanUp($_POST['collisionDeductible']);
  43. $rentalReimbursement=cleanUp($_POST['rentalReimbursement']);
  44. $towing=cleanUp($_POST['towing']);
  45. $v1year=cleanUp($_POST['v1year']);
  46. $v1make=cleanUp($_POST['v1make']);
  47. $v1vin=cleanUp($_POST['v1vin']);
  48. $v2year=cleanUp($_POST['v2year']);
  49. $v2make=cleanUp($_POST['v2make']);
  50. $v2vin=cleanUp($_POST['v2vin']);
  51. $otherDrivers=cleanUp($_POST['otherDrivers']);
  52. $howMany=cleanUp($_POST['howMany']);
  53. $permission=cleanUp($_POST['permission']);
  54. $ssn=cleanUp($_POST['ssn']);
  55.  
  56. if (!strlen($insuredName)) array_push($errorFields, 'insuredName');
  57. if (!strlen($email)) array_push($errorFields, 'email');
  58. if (!strlen($phone)) array_push($errorFields, 'phone');
  59. echo "got here step 2";
  60.  
  61. #check for valid e-mail address
  62. if (!preg_match("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$^",$email)) {
  63. array_push($errorFields, 'email');
  64. die("Invalid Email Address. Email will not be sent");
  65. }
  66.  
  67. #die if there are line returns in the name or e-mail field
  68. //if (!preg_match("\r",$insuredName) || !preg_match("\n",$insuredName) || !preg_match("\r",$email) || !preg_match("\n",$email)){
  69. //die("Why ?? :(");
  70. //}
  71.  
  72. if (!count($errorFields)) {
  73. echo "no errors";
  74. #replace manual line returns in e-mail field
  75. $email = preg_replace("([\r\n])", "", $email);
  76.  
  77. #prevent BCC
  78. $find = "[content-type|Content-Type|bcc:|cc:|viagra|levitra|pariscialis|angelfire|freewebpages|xxx|gay|sluts|incest|hardcore|anal]";
  79. #$find2 = "[http:]";
  80. if (preg_match($find, $insuredName) || preg_match($find, $email) || preg_match($find, $phone) || preg_match($find, $city) || preg_match($find, $state) || preg_match($find, $zip)) {
  81. print("<p>No meta/header injections, please. E-mail will not be sent.</p>");
  82. exit;
  83. }
  84.  
  85. /* *********** First email to Don, Teresa and TD ****************** */
  86.  
  87. require_once('class.phpmailer.php');
  88.  
  89. $mail = new PHPMailer(); // the true param means it will throw exceptions on errors, which we need to catch
  90.  
  91. $mail->IsSMTP(); // telling the class to use SMTP
  92.  
  93. try{
  94.  
  95. $mail->Host = "172.16.4.18, 25"; // SMTP server
  96. $mail->Port = 26;
  97. $mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
  98.  
  99. $mail->AddReplyTo('webserver@tracy-driscoll.com');
  100. $mail->AddAddress('DPolletta@mbcinteractive.com' , 'Don Polletta');
  101. $mail->AddAddress('teresa.romano@nc.rr.com' , 'Teresa Romano');
  102. $mail->SetFrom('"' . stripslashes(checkit($_POST['insuredName'])) . '" <' . stripslashes(checkit($_POST['email'])) . '>');
  103. $mail->Subject = 'Auto Insurance Quote Request from the Tracy-Driscoll web site';
  104. $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
  105. $mail->msgHTML(
  106.  
  107. 'Received On: '.date('m/d/Y H:i:s').'\n\r
  108.  
  109. Insured Information\n'.
  110.  
  111. 'Name: ' . stripslashes(checkit($_POST['$insuredName'])) . '\n'.
  112. 'Address: $address\n'.
  113. 'City: $city\n'.
  114. 'State: $state\n'.
  115. 'Zip: $zip\n'.
  116. 'Phone: $phone\n'.
  117. 'Email: $email\n'.
  118. 'Date of Birth: $dobMonth'/'$dobDay'/'$dobYear\n'.
  119. 'Drivers License Number: $driversLicense\n'.
  120.  
  121. 'Current Insurance\n\r'.
  122.  
  123. 'Do you have Insurance: $do_you\n\r'.
  124.  
  125. 'Coverages\n\r'.
  126.  
  127. 'Bodily Injury Liability: $bodilyInjury\n'.
  128. 'Property Damage Liability: $propertyDamage\n'.
  129. 'Medical Payments: $medicalPayments\n'.
  130. 'Comprehensive Deductible: $comprehensiveDeductible\n'.
  131. 'Collision Deductible: $collisionDeductible\n'.
  132. 'Rental Reimbursement: $rentalReimbursement\n' .
  133. 'Towing & Labor: $towing\n\r'.
  134.  
  135. 'Vehicle 1 Information:\n'.
  136. 'Year: $v1year\n'.
  137. 'Make & Model: $v1make\n'.
  138. 'VIN: $v1vin\n\r'.
  139.  
  140. 'Vehicle 2 Information:\n'.
  141. 'Year: $v2year\n'.
  142. ' Make & Model: $v2make\n'.
  143. ' VIN: $v2vin\n\r'.
  144.  
  145. 'Licensed Drivers:\n\r'.
  146.  
  147. 'Any other Drivers: $otherDrivers\n'.
  148. 'How Many?: $howMany\n\r'.
  149.  
  150. 'Credit Check\n\r'.
  151.  
  152. 'Permission: $permission\n'.
  153. 'SSN: $ssn');
  154.  
  155.  
  156. $mail->Send();
  157.  
  158. echo "Message Sent OK</p>\n";
  159. } catch (phpmailerException $e) {
  160. echo $e->errorMessage(); //Pretty error messages from PHPMailer
  161. } catch (Exception $e) {
  162. echo $e->getMessage(); //Boring error messages from anything else!
  163. }
  164.  
  165. /* *********** Second email to customer ****************** */
  166.  
  167. require_once('class.phpmailer.php');
  168.  
  169. include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
  170.  
  171. $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
  172.  
  173. $mail->IsSMTP(); // telling the class to use SMTP
  174.  
  175. try {
  176.  
  177. $mail->Host = "172.16.4.18, 25"; // SMTP server
  178. $mail->Port = 26;
  179. $mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
  180.  
  181. $mail->AddReplyTo('webserver@tracy-driscoll.com');
  182. $mail->AddAddress('DPolletta@mbcinteractive.com' , 'Don Polletta');
  183. $mail->AddAddress('teresa.romano@nc.rr.com' , 'Teresa Romano');
  184. $mail->SetFrom('"' . stripslashes(checkit($_POST['insuredName'])) . '" <' . stripslashes(checkit($_POST['email'])) . '>');
  185. $mail->Subject = 'Auto Insurance Quote Request from the Tracy-Driscoll web site';
  186.  
  187. $mail->msgHTML(
  188.  
  189. 'Hello '.$_POST['$insuredName'].',\n.
  190. Your quote request has been received! This email is a confirmation that we have received your request and is now being processed. You will be contacted by phone or email to discuss your Automobile Insurance Options.\n\r'.
  191.  
  192. 'For more exciting offers and news, please join our email list or become our fan on Facebook. Thank you for choosing Tracy-Driscoll for your Automobile Insurance Needs.\n\r'.
  193. 'Thank you,\n'.
  194. 'Tracy Driscoll');
  195.  
  196. $mail->Send();
  197.  
  198. echo "Message Sent OK</p>\n";
  199. } catch (phpmailerException $e) {
  200. echo $e->errorMessage(); //Pretty error messages from PHPMailer
  201. } catch (Exception $e) {
  202. echo $e->getMessage(); //Boring error messages from anything else!
  203. }
  204.  
  205. exit();
  206. }
  207. else
  208. {
  209. echo "you have errors!<br />";
  210. print_r($errorFields);
  211. }
  212. }
  213. else
  214. {
  215. header("Location: http://www.tracy-driscoll.com/landingpages/auto/autoquote2.html");
  216. }
  217.  
  218.  
  219. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement