Advertisement
johncarlson21

Untitled

Aug 2nd, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php session_start();
  2.  
  3. $con = mysql_connect("172.16.4.23","reportswo","writeonly");
  4. if (!$con)
  5.   {
  6.   die('Could not connect: ' . mysql_error());
  7.   }
  8.  
  9.  
  10. $date = date('Y-m-d');
  11. $quote_type = $_POST["auto"];
  12.  
  13. echo "you got here";
  14.  
  15. mysql_select_db("reports", $con);
  16. $sql="INSERT INTO tracydriscoll (date, contactName, address, city, state, zip, email, quote_type) VALUES ('".$date."','".$_POST['contactName']."','".$_POST['address']."','".$_POST['city']."','".$_POST['state']."','".$_POST['zip']."','".$_POST['email']."','".$_POST['quote_type']."')";
  17.  
  18. if (!mysql_query($sql,$con))
  19.   {
  20.   die('Error: ' . mysql_error());
  21.   }
  22. echo "1 record added";
  23.  
  24. mysql_close($con);
  25.  
  26.     ini_set('display_errors', 'On');
  27.     error_reporting(E_ALL);
  28.      
  29.      
  30.     /* *********** FUNCTIONS ****************** */
  31.      
  32.     function checkit($contactName) {
  33.             return(str_replace(array("\r", "\n", "%OA", "%oa", "%OD", "%od", "Content-Type:","BCC:","bcc:"), "", $contactName));
  34.     }
  35.      
  36.     function cleanUp($data) {
  37.        $data = trim(strip_tags(htmlspecialchars($data)));
  38.        return $data;
  39.     }
  40.      
  41.     $referer=$_SERVER['HTTP_REFERER'];
  42.     #print($referer);
  43.    $refsplit=explode("?",$referer);
  44.     #if($refsplit[0]=='http://www.tracy-driscoll.com/landingpages/auto/quote2.html'){
  45.    
  46.     $errorFields = array();
  47.      
  48.     if (isset($_POST['submit'])) {
  49.         echo "got to this stage<br />";
  50.         $contactName =cleanUp($_POST['contactName']);
  51.         $address=cleanUp($_POST['address']);
  52.         $city=cleanUp($_POST['city']);
  53.         $state=cleanUp($_POST['state']);
  54.         $zip=cleanUp($_POST['zip']);
  55.         $phone=cleanUp($_POST['phone']);
  56.         $email=cleanUp($_POST['email']);
  57.         $dobMonth=cleanUp($_POST['dobMonth']);
  58.         $dobDay=cleanUp($_POST['dobDay']);
  59.         $dobYear=cleanUp($_POST['dobYear']);
  60.         $driversLicense=cleanUp($_POST['driversLicense']);
  61.         $doYou=cleanUp($_POST['doYou']);
  62.         $bodilyInjury=cleanUp($_POST['bodilyInjury']);
  63.         $propertyDamage=cleanUp($_POST['propertyDamage']);
  64.         $medicalPayments=cleanUp($_POST['medicalPayments']);
  65.         $comprehensiveDeductible=cleanUp($_POST['comprehensiveDeductible']);
  66.         $collisionDeductible=cleanUp($_POST['collisionDeductible']);
  67.         $rentalReimbursement=cleanUp($_POST['rentalReimbursement']);
  68.         $towing=cleanUp($_POST['towing']);
  69.         $v1year=cleanUp($_POST['v1year']);
  70.         $v1make=cleanUp($_POST['v1make']);
  71.         $v1vin=cleanUp($_POST['v1vin']);
  72.         $v2year=cleanUp($_POST['v2year']);
  73.         $v2make=cleanUp($_POST['v2make']);
  74.         $v2vin=cleanUp($_POST['v2vin']);
  75.         $otherDrivers=cleanUp($_POST['otherDrivers']);
  76.         $howMany=cleanUp($_POST['howMany']);
  77.         $permission=cleanUp($_POST['permission']);
  78.         $ssn=cleanUp($_POST['ssn']);
  79.                    
  80.         if (!strlen($contactName)) array_push($errorFields, 'contactName');
  81.         if (!strlen($email)) array_push($errorFields, 'email');
  82.         if (!strlen($phone)) array_push($errorFields, 'phone');
  83.         echo "got here step 2";
  84.  
  85.         #check for valid e-mail address
  86.         if (!preg_match("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$^",$email)) {
  87.                  array_push($errorFields, 'email');
  88.                  die("Invalid Email Address.  Email will not be sent");
  89.         }
  90.      
  91.     #die if there are line returns in the name or e-mail field
  92.            //if (!preg_match("\r",$contactName) || !preg_match("\n",$contactName) || !preg_match("\r",$email) || !preg_match("\n",$email)){
  93.                      //die("Why ?? :(");
  94.             //}
  95.      
  96.         if (!count($errorFields)) {
  97.             echo "no errors";
  98.             #replace manual line returns in e-mail field
  99.             $email = preg_replace("([\r\n])", "", $email);
  100.    
  101.             #prevent BCC
  102.             $find = "[content-type|Content-Type|bcc:|cc:|viagra|levitra|pariscialis|angelfire|freewebpages|xxx|gay|sluts|incest|hardcore|anal]";
  103.             #$find2 = "[http:]";
  104.             if (preg_match($find, $contactName) || preg_match($find, $email) || preg_match($find, $phone) || preg_match($find, $city) || preg_match($find, $state) || preg_match($find, $zip)) {
  105.                     print("<p>No meta/header injections, please.  E-mail will not be sent.</p>");
  106.                exit;
  107.             }
  108.                    
  109. /* *********** First email to Don, Teresa and TD ****************** */                    
  110.                                
  111. require_once('class.phpmailer.php');    
  112. include_once("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded                
  113.                              
  114. $mail = new PHPMailer(); // the true param means it will throw exceptions on errors, which we need to catch
  115.            
  116. $mail->IsSMTP(); // telling the class to use SMTP
  117.            
  118. try{
  119.            
  120.     $mail->Host       = "172.16.4.18"; // SMTP server
  121.     $mail->Port       = 25;
  122.     $mail->SMTPAuth = true;
  123.     $mail->Username   = "tracy1@oldgate.org"; // SMTP account username
  124.     $mail->Password   = "driscoll2";
  125.     $mail->SMTPDebug = 0; // enables SMTP debug information (for testing)
  126.                
  127.     $mail->AddReplyTo(stripslashes(checkit($_POST['email'])), stripslashes(checkit($_POST['contactName'])));
  128.     //$mail->AddAddress('bkdehm@tracy-driscoll.com' , 'Brian Dehm');
  129.     //$mail->AddAddress('DPolletta@mbcinteractive.com' , 'Don Polletta');
  130.     $mail->AddAddress('teresa.romano@nc.rr.com' , 'Teresa Romano');
  131.     $mail->SetFrom(stripslashes(checkit($_POST['email'])), stripslashes(checkit($_POST['contactName'])));
  132.     $mail->Subject = 'Auto Insurance Quote Request from the Tracy-Driscoll web site';
  133.     $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
  134.     $mail->msgHTML(
  135.                        
  136.         'Received On: '.date('m/d/Y H:i:s').'<br/><br/>
  137.                                
  138.         <h3>Insured Information</h3><br/>'.
  139.                        
  140.         'Name: ' . stripslashes(checkit($contactName)) . '<br/>'.
  141.         'Address:  '.$address.'<br/>'.
  142.         'City:  '.$city.'<br/>'.
  143.         'State: '.$state.'<br/>'.
  144.         'Zip: '.$zip.'<br/>'.
  145.         'Phone:  '.$phone.'<br/>'.
  146.         'Email:  '.$email.'<br/>'.
  147.         'Date of Birth: '.$dobMonth.' '.$dobDay.','.$dobYear.'<br/>'.
  148.         'Drivers License Number:  '.$driversLicense.'<br/>'.
  149.                
  150.         '<h3>Current Insurance</h3><br/>'.
  151.                
  152.         'Do you have Insurance:  '.$do_you.'<br/><br/>'.
  153.                  
  154.         '<h3>Coverages</h3><br/>'.
  155.                  
  156.         'Bodily Injury Liability:  '.$bodilyInjury.'<br/>'.
  157.         'Property Damage Liability:  '.$propertyDamage.'<br/>'.
  158.         'Medical Payments:  '.$medicalPayments.'<br/>'.
  159.         'Comprehensive Deductible:  '.$comprehensiveDeductible.'<br/>'.
  160.         'Collision Deductible:  '.$collisionDeductible.'<br/>'.
  161.         'Rental Reimbursement:  '.$rentalReimbursement.'<br/>'.
  162.         'Towing & Labor:  '.$towing.'<br/><br/>'.
  163.                  
  164.         '<h3>Vehicle 1 Information:</h3><br/>'.
  165.               'Year:  '.$v1year.'<br/>'.
  166.               'Make & Model:  '.$v1make.'<br/>'.
  167.               'VIN:  '.$v1vin.'<br/><br/>'.
  168.                  
  169.         '<h3>Vehicle 2 Information:</h3><br/>'.
  170.             'Year:  '.$v2year.'<br/>'.
  171.             'Make & Model:  '.$v2make.'<br/>'.
  172.             'VIN:  '.$v2vin.'<br/><br/>'.
  173.                  
  174.         '<h3>Licensed Drivers:</h3><br/>'.
  175.                  
  176.         'Any other Drivers:  '.$otherDrivers.'<br/>'.
  177.         'How Many?:  '.$howMany.'<br/><br/>'.
  178.                  
  179.         '<h3>Credit Check</h3><br/>'.
  180.                  
  181.         'Permission:  '.$permission.'<br/>'.
  182.         'SSN:  '.$ssn);
  183.                
  184.                
  185.         $mail->Send();
  186.                  
  187.               echo "Message Sent OK</p><br/>";
  188.           } catch (phpmailerException $e) {
  189.             echo $e->errorMessage(); //Pretty error messages from PHPMailer
  190.           } catch (Exception $e) {
  191.             echo $e->getMessage(); //Boring error messages from anything else!
  192.           }
  193.  
  194.           /* *********** Second email to customer ****************** */
  195.          
  196.           require_once('class.phpmailer.php');    
  197.           include_once("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded                    
  198.                            
  199.          
  200.           $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
  201.          
  202.           $mail->IsSMTP(); // telling the class to use SMTP
  203.          
  204.           try {
  205.          
  206.             $mail->Host     = "172.16.4.18"; // SMTP server
  207.             $mail->Port       = 25;
  208.             $mail->SMTPAuth = true;
  209.             $mail->Username   = "tracy1@oldgate.org"; // SMTP account username
  210.             $mail->Password   = "driscoll2";
  211.          
  212.             $mail->SMTPDebug  = 0; // enables SMTP debug information (for testing);
  213.                  
  214.             $mail->AddReplyTo('webserver@tracy-driscoll.com', 'Online Quote');
  215.             $mail->AddAddress('teresa.romano@nc.rr.com' , 'Teresa Romano');
  216.             $mail->AddAddress(stripslashes(checkit($_POST['email'])), stripslashes(checkit($_POST['contactName'])));
  217.             $mail->SetFrom('webserver@tracy-driscoll.com', 'Online Quote');
  218.             $mail->Subject = 'Auto Insurance Quote Request from the Tracy-Driscoll web site';
  219.          
  220.             $mail->msgHTML(
  221.                
  222.                   'Hello '.$contactName.',<br/><br/>
  223.                  
  224.                   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 insurance options with a Tracy-Driscoll agent shortly.<br/><br/>'.
  225.                                      
  226.                   'No matter what type of service you are in search of, there are certain things you probably look for when choosing a company to do business with: quality work, exceptional products, friendly assistance, prompt attention, fair pricing... <br/><br/>'.
  227.                  
  228.                   'When you are looking for someone to meet your insurance coverage needs, Tracy-Driscoll Insurance & Financial Services provides all this and more.  We will carefully analyze your needs and recommend the right plan to make sure you are adequately protected, at the most reasonable rates.  <br/><br/>'.
  229.                  
  230.                   'Whether you are in need of auto, homeowners, health, life or business coverage, trust Tracy-Driscoll, supporting our community for 90 years.  <br/><br/>'.
  231.                  
  232.                   'Call us today to speak with an insurance specialist (860) 589-3434, or visit us online at www.Tracy-Driscoll.com.   <br/><br/>'.
  233.                  
  234.                   'Sincerely,<br/>'.
  235.                   'Brian K. Dehm, President ');
  236.                  
  237.           $mail->Send();
  238.            
  239.             echo "Message Sent OK</p>\n";
  240.             } catch (phpmailerException $e) {
  241.               echo $e->errorMessage(); //Pretty error messages from PHPMailer
  242.             } catch (Exception $e) {
  243.               echo $e->getMessage(); //Boring error messages from anything else!
  244.             }
  245.  
  246.             header("Location: http://www.tracydriscoll.com/landingpages/auto/thanks.html");
  247.       }else{ // else for errors..
  248.           echo "you have errors!<br />";
  249.           print_r($errorFields);
  250.       }
  251.   }else{
  252.       header("Location: https://www.tracy-driscoll.com/forms/auto_quote.php");
  253.   }
  254.  
  255.      
  256. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement