Advertisement
tjromano

td

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