<?php session_start();
if (isset($_POST["op"]) && ($_POST["op"]=="send")) {  
	//if(!empty($_SESSION['6_letters_code'] ) && strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) == 0 )
	//{	
		/******** START OF CONFIG SECTION *******/
		$subject1 = "Appointment Form - 1 Direction Australia"; // need to change
		// Select if you want to check form for standard spam text
		$SpamCheck = "Y"; // Y or N
		$SpamReplaceText = "*content removed*";
		// Error message prited if spam form attack found
		$SpamErrorMessage = "<p align=\"center\"><font color=\"red\">Malicious code content detected.
		</font><br><b>Your IP Number of <b>".getenv("REMOTE_ADDR")."</b> has been logged.</b></p>";
		/******** END OF CONFIG SECTION *******/
		// need to change
		
		//print_r($_POST);exit;
		$name		    = $_POST['name']; 
	
		$service		= $_POST['service'];
		$phone		    = $_POST['phone'];
		$email		    = $_POST['email'];
		$company	    = $_POST['company-name'];
		$adate	    = $_POST['adate'];
		$atime	    = $_POST['atime'];
		$address	    = $_POST['address'];
		$comments='';
		
		
	
		if (!filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
				
				} else { ?>
					<script type="application/javascript">
					window.location="thankyou.php?send=2#page";
					</script>
				<?php	exit();
		}
		
		
			$ccl=str_word_count($address);	
			if($ccl <=1){
			    
			     echo '<script>  alert("Please enter address more than three words!..");
          
               window.history.back();
            </script>';  
                    exit();
			}
		
		
		if ($SpamCheck == "Y") 
			{		   
			// Check for Website URL's in the form input boxes as if we block website URLs from the form,
			// then this will stop the spammers wastignt ime sending emails
			if (preg_match("/http/i", "$name")) {echo "$SpamErrorMessage"; exit();}
		//	if (preg_match("/http/i", "$service")) {echo "$SpamErrorMessage"; exit();} 
			if (preg_match("/http/i", "$email")) {echo "$SpamErrorMessage"; exit();} 
			if (preg_match("/http/i", "$phone")) {echo "$SpamErrorMessage"; exit();} 
			if (preg_match("/http/i", "$comments")) {echo "$SpamErrorMessage"; exit();} 
			
			// Patterm match search to strip out the invalid charcaters, this prevents the mail injection spammer 
			$pattern = '/(;|\||`|>|<|&|^|"|'."\r|'".'|{|}|[|]|\)|\()/i'; // build the pattern match string 
			
			$name = preg_replace($pattern, "", $name);
		//	$service = preg_replace($pattern, "", $service);
			$email = preg_replace($pattern, "", $email); 
			$phone = preg_replace($pattern, "", $phone); 
			$comments = preg_replace($pattern, " ", $comments); 
			
			$find = array("/bcc\:/i","/Content\-Type\:/i","/cc\:/i","/to\:/i"); 
			$name = preg_replace($find, "$SpamReplaceText", $name);
		//	$service = preg_replace($find, "$SpamReplaceText", $service);
			$email = preg_replace($find, "$SpamReplaceText", $email); 
			$phone = preg_replace($find, "$SpamReplaceText", $phone); 
			$comments = preg_replace($find, "$SpamReplaceText", $comments); 
			
			// Check to see if the fields contain any content we want to ban
			if(stristr($name, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} 
			if(stristr($comments, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} 
			
		
		}
		
		if (preg_match("/seo|ranking|keyword|business|optimization|errors|traffic|servers|marketing|backlink|proposal|posting|clients|records|report|domain|search engine|virtual|promote|freelance/i", "$comments")) {
		$subject = "V G R A";
		$email	= "vgra@otpspr.nets";
		$mail_content = "XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X";
	} 
	else
	{	
			$email1	= "contact@1directionaustralia.com.au"; // need to change
			$mail_content = '
			<html xmlns="http://www.w3.org/1999/xhtml">
			<head>
			<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
			<title>Notification Of Job Invitation</title>
				<style>
				body{
				font-family:Arial, Helvetica, sans-serif;
				font-size:14px;
				width:800px;
				height:auto;	
				color:#2F2F2F;
				line-height:20px;
				float:left;
				border:2px solid #CCC;
				padding:20px;
				border-radius:10px;
				-webkit-border-radius:10px;
				-moz-border-radius:10px;
				}
				figure{
				float:right;
				}
				.wrap_01{
				float:left;
				}
				.highlight{
				font-size:15px;
				color:#06C;
				}
				.highlight a {
				text-decoration:none;
				color:#06C;
				}
				.high_01{
				font-weight:bold; color:#06C;
				}
				.address{
				font-size:13px;
				float:left;
				}
				.address p{
				line-height:5px;
				}
				.title{
				font-size:30px;
				
				font-weight:bold;
				color:#00A1EB;
				}
				.footertxt{
				padding:0px;
				margin:0px;
				color:#333;
				font-size:12px;
				}
				</style>
			</head>
			<body>
			
		
				
				<div class="wrap_01">
				<p>Appointment from the website 1 Direction Australia</p>
				
				<p> <span class="high_01">Name</span> : '.$name.'.</p>
				<p> <span class="high_01">Phone</span> : '.$phone.'</p>
				<p> <span class="high_01">Email-Id</span> : '.$email.'</p>
				<p> <span class="high_01">Appointment Date</span> : '.$adate.'</p>
					<p> <span class="high_01">Appointment Time</span> : '.$atime.'</p> 
				<p> <span class="high_01">Company Name </span> : '.$company.'</p> 
				<p> <span class="high_01">Service</span> : '.$service.'</p> 
			
				<p> <span class="high_01">Address</span> : '.$address.'</p> 
				
			
				
				</div>
			</body>
			</html>';
	}
			error_reporting(E_STRICT);
			
			require_once('mailer/class.phpmailer.php');
		
			$mail= new PHPMailer();
		
			$body = $mail_content;
			//$body             = preg_replace('/[\]/','',$body);
			
			$mail->IsSMTP(); 
		
			$mail->SMTPDebug  = 1;                    
										  
			$mail->SMTPAuth   = true;                  // enable SMTP authentication
			$mail->Host       = "mail.1directionaustralia.com.au"; // sets the SMTP server mail.nextweb.com.au
			$mail->Port       = 25;                    // set the SMTP port for the GMAIL server
			$mail->Username   = "contact@1directionaustralia.com.au"; // SMTP account username mailer@nextweb.com.au
			$mail->Password   = "60WBKZUJXmfK";  // SMTP account password 7809asd$$
			
			//$mail->SetFrom($email, $name);
			$mail->SetFrom($email1, $name);
			$mail->AddReplyTo($email,$name);
			$mail->Subject    = $subject1;
		
			$mail->MsgHTML($body);
			
	    	$address1 = "onedirectionmails@gmail.com"; // need to change (to mail ID)
	    	
	    	
	
			$mail->AddAddress($address1, "Info");
			
			$mail->AddBCC("reports@nextweb.com.au", "Reports");
			$mail->AddBCC("nextwebaustralia@gmail.com", "NextWeb");

			if(!$mail->Send()) {
			   echo "Mailer Error: " . $mail->ErrorInfo;
			  //exit;?>
				<script type="application/javascript">
				window.location="thankyou.php?send=0#page";
				</script>
			<?php } else { 
			$bname		= "One Direction Australia"; // need to change
			$name 		= $name;
			$email		= $_REQUEST['email'];
			$suburb		= $suburb;
			$phone		= $phone;
			$message   	= $comments;
			$c_name		= "One Direction Australia"; // need to change
			$c_phone	= "1300 520 417"; // need to change
			$website	= $_SERVER['HTTP_HOST'];
			$c_email	= "info@onedirectionaustralia.com.au"; // need to change
			session_destroy();
		//	include("autoreply.php");

			  
			?>
			<script type="application/javascript">
					window.location="thankyou.php?send=1#page";
				 </script>
		<?php }
}
?>

