Advertisement
tjromano

Untitled

May 10th, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.65 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. // call the swift mailer lib file
  86. require_once 'lib/swift_required.php';
  87.  
  88. // create the swift mailer transport
  89. $transport = Swift_SMTPTransport::newInstance('172.16.4.18', 'ssl');
  90.  
  91. // crate the Mailer using your created Transport
  92. $mailer = Swift_Mailer::newInstance($transport);
  93.  
  94.  
  95.  
  96. $message->setSubject('Auto Insurance Quote Request form the Tracy-Driscoll web site');
  97.  
  98. $message-> setFrom = '"' . stripslashes(checkit($_POST['insuredName'])) . '" <' . stripslashes(checkit($_POST['email'])) . '>';
  99.  
  100. $message->setTo=(array('DPolletta@mbcinteractive.com' => 'Don Polletta', 'teresa.romano@nc.rr.com' => 'Teresa J Romano'));
  101.  
  102. $message->setBody=(
  103.  
  104. 'Received On: '.date('m/d/Y H:i:s').''
  105.  
  106. 'Insured Information'
  107.  
  108. 'Name: ' . stripslashes(checkit($_POST['$insuredName'])) .'
  109. 'Address: $address'
  110. 'City: $city'
  111. 'State: $state'
  112. 'Zip: $zip'
  113. 'Phone: $phone'
  114. 'Email: $email\n';
  115. 'Date of Birth: $dobMonth'/'$dobDay'/'$dobYear'
  116. 'Drivers License Number: $driversLicense'
  117.  
  118. 'Current Insurance'
  119.  
  120. 'Do you have Insurance: $do_you'
  121.  
  122. 'Coverages';
  123.  
  124. 'Bodily Injury Liability: $bodilyInjury'
  125. 'Property Damage Liability: $propertyDamage'
  126. 'Medical Payments: $medicalPayments'
  127. 'Comprehensive Deductible: $comprehensiveDeductible'
  128. 'Collision Deductible: $collisionDeductible'
  129. 'Rental Reimbursement: $rentalReimbursement'
  130. 'Towing & Labor: $towing'
  131.  
  132. 'Vehicle 1 Information:'
  133. 'Year: $v1year'
  134. 'Make & Model: $v1make'
  135. ' VIN: $v1vin'
  136.  
  137. 'Vehicle 2 Information:'
  138. ' Year: $v2year'
  139. ' Make & Model: $v2make'
  140. ' VIN: $v2vin'
  141.  
  142. 'Licensed Drivers:'
  143.  
  144. 'Any other Drivers: $otherDrivers'
  145. 'How Many?: $howMany'
  146.  
  147. 'Credit Check'
  148.  
  149. 'Permission: $permission'
  150. 'SSN: $ssn');
  151.  
  152. $result = $mailer->send($message);
  153.  
  154. // call the swift mailer lib file
  155. require_once 'lib/swift_required.php';
  156.  
  157. // create the swift mailer transport
  158. $transport = Swift_SMTPTransport::newInstance('172.16.4.18', 'ssl');
  159.  
  160. // crate the Mailer using your created Transport
  161. $mailer = Swift_Mailer::newInstance($transport);
  162.  
  163. $message->setSubject('Auto Insurance Quote Request form the Tracy-Driscoll web site');
  164.  
  165. $message-> setFrom = '"' . stripslashes(checkit($_POST['insuredName'])) . '" <' . stripslashes(checkit($_POST['email'])) . '>';
  166.  
  167. $message->setTo=(array('DPolletta@mbcinteractive.com' => 'Don Polletta', 'teresa.romano@nc.rr.com' => 'Teresa J Romano', $email));
  168.  
  169. $message->setBody=(
  170.  
  171. 'Hello '.$_POST['$insuredName'].','
  172. '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.'
  173.  
  174. '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.'
  175. 'Thank you,'
  176. 'Tracy Driscoll'
  177.  
  178. // send the message
  179. $result = $mailer->send($message);
  180.  
  181. // Pass a variable name to the send() method
  182. if (!$mailer->send($message, $failures))
  183. {
  184. echo "Failures:";
  185. print_r($failures);
  186. }
  187.  
  188. /*
  189. Failures:
  190. Array (
  191. 0 => receiver@bad-domain.org,
  192. 1 => other-receiver@bad-domain.org
  193. )
  194. */
  195.  
  196. //header("Location: thankyou.php?n=".$insuredName."&date=");
  197. exit();
  198. }else{
  199. echo "you have errors!<br />";
  200. print_r($errorFields);
  201. }
  202. }else{
  203. // need to show the form here.. or just re-direct back to the form.
  204. header("Location: autoquote.html");
  205. }
  206.  
  207. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement