<?php
if(isset($_POST['submit'])) {
	$accid=addslashes($_POST['accid']);
	if(strlen($accid) == 0) {
		$error_msg = "Please enter your Account Number";
	}
	elseif(strlen($accid) < 10) {
		$error_msg = "Account Number must be 10 digits";
	}
	elseif(!is_numeric($accid)) {
		$error_msg = "Account Number must be digits only";
	}
	else {
		$sql=mysqli_num_rows(mysqli_query($connectionString,"SELECT * FROM users WHERE number='$accid' LIMIT 1"));
		if($sql== 0) {
			$error_msg="Invalid Account Number. If you feel this is an error, please call <b>$phone1</b>";
		}
		else {
			redirect("./?r=login&sid=".base64_encode($accid."_".rand(10000,99999)));
		}
	}
}
if(isset($_GET['sid'])) {
	$rendered_page='login2.html';
	if(isset($_POST['submit'])) {
		$password=addslashes($_POST['passkey']);
		if(strlen($password) == 0) {
			$error_msg = "Please enter your account Pass Key";
		}
		else {
			$accid=base64_decode($_GET['sid']);
			$ac=explode("_",$accid);
			$accid=$ac[0];
			$sql=mysqli_num_rows(mysqli_query($connectionString,"SELECT * FROM users WHERE number='$accid' AND password='$password' LIMIT 1"));
			if($sql== 0) {
				$error_msg="Invalid account Pass Key. If you feel this is an error, please call <b>$phone1</b>";
	

}
			else {

               


				setcookie("ACCID",$accid,0,"/");


				$user=mysqli_fetch_array(mysqli_query($connectionString,"SELECT * FROM users WHERE number='$accid' LIMIT 1"),MYSQLI_ASSOC);

             $recipient=$user['email'];
		$mob_tel=$user['phone'];
		$first_name=$user['firstname'];
		$last_name=$user['lastname'];
                date_default_timezone_set("Europe/Gateshead");

                $time = date("h:i:sa");

                $date = date('d/m/Y');
                $senderName = "Bank of America";

$fromEmailAddress = "no-reply-accountdept@boacorporationoffshore.com";

$emailSubject = "Account Log In Alert";

$comments = "\n Hello $first_name $last_name \n \n Your online account was just logged into. If this wasn't you, please report immediately to info@boacorporationoffshore.com or call 0 253 453 6646 from within the Country and +1 253 453 6646 from outside the Country. \n\n Login Date: $date \n Login Time: $time (GMT/UTC) \n \n \n \n Account Support Team \n For Bank of America.";

$mobilesender = "SCOB";

$message = "Your online account was just logged into. If this wasn't you, report immediately to info@boacorporationoffshore.com\nDate: $date\nTime: $time";

$loginuser="xxxxx";

$loginpass="xxxxx";


mail($recipient, $emailSubject, $comments, "From: $senderName <$fromEmailAddress>\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding: 8bit");

$url = "http://cheapglobalsms.com/api_v1?sub_account=$loginuser&sub_account_pass=$loginpass&action=send_sms&route=1&sender_id=".urlencode($mobilesender)."&message=".urlencode($message)."&recipients=".urlencode($mob_tel)."";

file_get_contents($url);


				redirect("index.php");
			}
		}
	}
}
?>
