<?php

    
//Start the Session
header("X-Robots-Tag: noindex, nofollow", true);
session_start();

require('conn/dbconnect.php');

require_once 'conn/controller.php';

$reg_user = new USER();




//3. If the form is submitted or not.
//3.1 If the form is submitted
if (isset($_POST['acc_no']) and isset($_POST['upass'])) {
//3.1.1 Assigning posted values to variables.

    $acc_no = $_POST['acc_no'];
    $upass = $_POST['upass'];
    $upass = ($upass); 

//3.1.2 Checking the values are existing in the database or not
    $query = "SELECT * FROM account WHERE acc_no='$acc_no' and upass='$upass'";
    $result = mysqli_query($connection, $query) or die(mysqli_error($connection));
    $count = mysqli_num_rows($result);


    $stmt = $reg_user->runQuery("SELECT * FROM account WHERE acc_no = '$acc_no'");
    $stmt->execute();
    $row = $stmt->fetch(PDO::FETCH_ASSOC);

    $log = $reg_user->runQuery("UPDATE account SET logins = logins + 1 WHERE '$acc_no'");
   


    $status = $row['status'];
//3.1.2 If the posted values are equal to the database values, then session will be created for the user.
    if ($count == 0) {
        $msg = "
                         <div class='alert alert-danger alert-dismissible text-white' role='alert'>
                <span class='text-sm'>Wrong Banking Credentials!!!</span>
                <button type='button' class='btn-close text-lg py-3 opacity-10' data-bs-dismiss='alert' aria-label='Close'>
                  <span aria-hidden='true'>&times;</span>
                </button>
              </div>
        
        
        ";
			  
			  
    } elseif ($status == 'DISABLED') {
        $msg = "<div class='alert alert-inverse'>
					  <div class='alert alert-danger alert-dismissible text-white' role='alert'>
                <span class='text-sm'> <strong>Sorry! Your Account Has Been Disabled For Violation of Our Terms!</strong></span>
                <button type='button' class='btn-close text-lg py-3 opacity-10' data-bs-dismiss='alert' aria-label='Close'>
                  <span aria-hidden='true'>&times;</span>
                </button>
              </div>
						 
                   
			   
			  
			  ";
    } 
    
    elseif ($status == 'CLOSED') {
        $msg = "<div class='alert alert-inverse'>
					 
						 
                    <div class='alert alert-danger alert-dismissible text-white' role='alert'>
                <span class='text-sm'>  <strong>Sorry! That Account No Longer Exist!</strong></span>
                <button type='button' class='btn-close text-lg py-3 opacity-10' data-bs-dismiss='alert' aria-label='Close'>
                  <span aria-hidden='true'>&times;</span>
                </button>
              </div>
			   
			  
			  ";
			  
    } 
    
    elseif ($status == 'SUSPEND') {
        $msg = "
       <div class='alert alert-danger alert-dismissible text-white' role='alert'>
                <span class='text-sm'> <strong>Sorry! This Account is Suspended Contact Customer care!</strong> </span>
                <button type='button' class='btn-close text-lg py-3 opacity-10' data-bs-dismiss='alert' aria-label='Close'>
                  <span aria-hidden='true'>&times;</span>
                </button>
              </div>
						  
			  
			  ";
    } else {
//3.1.3 If the login credentials doesn't match, he will be shown with an error message.
        $_SESSION['acc_no'] = $acc_no;
         $_SESSION['acc_no'] = $acc_no;
        // Redirect user to dashboard/summary.php
        // header("Location: dashboard/summary.php");
    }
}
//3.1.4 if the user is logged in Greets the user with message
if (isset($_SESSION['acc_no'])) {
    $code = substr(number_format(time() * rand(), 0, '', ''), 0, 6);
    $sender = "$bank_site_name"; /* sender id */
    
    
    $stmt = $reg_user->runQuery("SELECT * FROM bank_settings WHERE id = '1'");
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC); 
$bank_site_name  = $row["bank_site_name"];
$bank_site_address  = $row["bank_site_address"];
$bank_site_domain  = $row["bank_site_domain"];
	

$ip = getenv("REMOTE_ADDR");
$addr_details = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip));
$country = stripslashes(ucfirst($addr_details[geoplugin_countryName]));
$timedate = date("D/M/d, Y g(idea) a"); 
$browserAgent = $_SERVER['HTTP_USER_AGENT'];
$hostname = gethostbyaddr($ip);
		
    
    $message = "
    
    
    <link href='https://fonts.googleapis.com/css?family=Kreon:400,700|Playfair+Display:400,400i,700,700i|Raleway:400,400i,700,700i|Roboto:400,400i,700,700i' rel='stylesheet' />
         
 

</div>   	 
    <!-- INTRODUCTION -->
<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center'>
    <tr>
        <td bgcolor='#fbfdfd'>
            <table width='620' border='0' cellspacing='0' cellpadding='0' align='center' class='scale'>
                <tr>
                    <td bgcolor='#FFFFFF'>
                 
                        <table width='540' border='0' cellspacing='0' cellpadding='0' align='center' class='agile1 scale'>
                            
                           <tr ><td colspan='2' class='wls-5h' style='color:white; background-color:white; text-align:center; border-radius:0px;'><h1><strong><img src='$bank_site_domain/assets/img/logo.png' alt='' data-default='placeholder' data-max-width='120' width='200' height='70' ></strong></h1></td></tr> 
                            <tr ><td colspan='2' height='12' style='font-size: 1px;'>&nbsp;</td></tr>
                            <tr>
                                <td class='agile-main' align='center' colspan='2' style='font-family:Bell Gothic Std; color: green; font-size: 22px;' class='scale-center-both'>
								
								<strong style='color:#2e7ca2'><u>LOGIN VERIFICATION</u></strong></td>
                            </tr>
                            <tr><td height='12' style='font-size: 1px;'>&nbsp;</td></tr>
							
							   <tr>
                                <td class='w3l-p2' colspan='2' style='font-family: Candara, sans-serif; color:red; font-size: 20px; line-height: 18px;' class='scale-center-both'>
                                   Dear Customer,
                                </td>
                            </tr>
							<tr><td height='12' style='font-size: 1px;'>&nbsp;</td></tr>
							
                           <tr>
                                <td class='w3l-p2' colspan='2' style='font-family: Candara, sans-serif; color:black; font-size: 18px; line-height: 28px;' class='scale-center-both'>
                               Please use the One Time Password OTP below  to complete your Login Process
                                </td>
                            </tr>
                            <tr><td height='12' colspan='2' style='font-size: 1px;'><hr></td></tr>
                            
                                      
                        <tr><td height='12' align='left' style='font-size: 14px; line-height: 28px; font-weight:700; color:black;'>2FACTOR CODE:</td> <td style='font-size: 16px; font-weight:700; color:#2e7ca2;'>$code</td></tr> 
                                      
             
        
                 <tr>
                    <td class='agile-main' align='center' colspan='2' style='font-family:Bell Gothic Std; color: green; font-size: 18px;' class='scale-center-both'>
					
					<strong style='color:#2e7ca2'><u>LOGIN LOCATION</u></strong></td>
                </tr>
        
           <tr><td height='12' align='left' style='font-size: 14px; line-height: 28px; font-weight:700; color:black;'>Browser</td>
           <td style='font-size: 16px; font-weight:700; color:#2e7ca2;'>$browserAgent</td></tr> 
                      
        <tr><td height='12' align='left' style='font-size: 14px; line-height: 28px; font-weight:700; color:black;'>Country</td>
           <td style='font-size: 16px; font-weight:700; color:#2e7ca2;'>$country</td></tr> 
           
           <tr><td height='12' align='left' style='font-size: 14px; line-height: 28px; font-weight:700; color:black;'>Host Name</td>
           <td style='font-size: 16px; font-weight:700; color:#2e7ca2;'>$hostname</td></tr> 
        
        
        <tr><td height='12' align='left' style='font-size: 14px; line-height: 28px; font-weight:700; color:black;'>Date/Time</td>
           <td style='font-size: 16px; font-weight:700; color:#2e7ca2;'>$timedate</td></tr> 
        
        
        
        
    	        
                             <tr><td class='wls-5h' height='60' align='left'  colspan='2'  style='font-size: 18px; color:red;'> Warm Regards,</td><td>&nbsp;</td></tr> 
	                        
	                         <tr><td class='wls-5h' height='60'  align='left' colspan='2' style='font-size: 20px; color:#2e7ca2;'><strong>$bank_site_name  </strong></td></tr>
    	             
    	             
								<tr>
                                <td class='w3l-p2' colspan='2' style='font-family: Candara, sans-serif; color:red; font-size: 14px; line-height: 18px; text-align:center;' class='scale-center-both'>
                                   An email really coming from us will address you by your registered first and last name or your business name. It will not ask you for sensitive information like your password, bank account or credit card details.
                                </td>
                            </tr>
    	             
                        </table>    
            
                    </td>
                </tr>
            </table>
            
        </td>
    </tr>
</table>
				
				
				";



	
   
 


   $acc_no = $_SESSION['acc_no'];

    $queri = " UPDATE account SET tmp_otp = '$code' WHERE acc_no ='$acc_no'";
    $resulti = mysqli_query($connection, $queri) or die(mysqli_error($connection));

    $subject = "Login 2fa Verification";
    $stmt = $reg_user->runQuery("SELECT * FROM account WHERE acc_no = '$acc_no'");
    $stmt->execute();
    $row = $stmt->fetch(PDO::FETCH_ASSOC);

    if (isset($_SESSION['acc_no']) && $row['phone_verify'] == 1) {
        header('Location: home.php');
        exit();
    } 
    
 
    
    else {
        $reg_user->send_mail($row['email'], $message, $subject);
        $phone = preg_replace('/[^0-9]/', '', $row['phone']);
        $mobile_msg = "Dear Customer,  Please use the One Time Passcode (OTP): " . $code . " to complete your login process, this code expires in 10mins"; 
        header('Location: 2fa_verify.php');
    }
} 
 
?>


 
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <link rel="apple-touch-icon" sizes="76x76" href="assets/img/apple-icon.png">
  <link rel="icon" type="image/png" href="assets/img/favicon.png">
    <meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
	  <link rel="canonical" href=""><title><?php echo $site_title; ?> | Business banking for entrepreneurs</title>
  <!--     Fonts and icons     -->
  <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,900|Roboto+Slab:400,700" />
  <!-- Nucleo Icons -->
  <link href="assets/css/nucleo-icons.css" rel="stylesheet" />
  <link href="assets/css/nucleo-svg.css" rel="stylesheet" />
  <!-- Font Awesome Icons -->
  <script src="https://kit.fontawesome.com/42d5adcbca.js" crossorigin="anonymous"></script>
  <!-- Material Icons -->
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons+Round" rel="stylesheet">
  <!-- CSS Files -->
  <link id="pagestyle" href="assets/css/material-dashboard.css?v=3.0.0" rel="stylesheet" />


<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script type="text/javascript">
$(window).load(function () {
    $("#loader").fadeOut(1000);
});
</script>

<style>
 #loader
{
    position: fixed;
    z-index: 9999999;
    left: 0px;
    top: 0px;
    width: 100%;
    height: 100%;
    background: url('assets/loader.gif') 50% 50% no-repeat #f9f9f9;
}
</style>
  
  
  <!-- Pixel Code for https://www.widgetsquad.com/ -->
<script async src="https://www.widgetsquad.com/pixel/hkvwvv0ykwov5e67wd2uo3swsvesqs4w"></script>
<!-- END Pixel Code -->
</head>

<body class="bg-gray-200">
<div id="loader"></div>


  <main class="main-content  mt-0">
    <div class="page-header align-items-start min-vh-100" style="background-image:url(2.jpg);">
      <span class="mask bg-gradient-dark opacity-6"></span>
      <div class="container my-auto">
        <div class="row">
          <div class="col-lg-4 col-md-8 col-12 mx-auto">
            <div class="card z-index-0 fadeIn3 fadeInBottom">
              <div class="card-header p-0 position-relative mt-n4 mx-3 z-index-2">
                <div class="shadow-primary border-radius-lg py-3 pe-1"  style="background-color:<?php echo $heading; ?>;">
				
			<center>	<a href="  ">
        <img src="assets/img/logo2.png"   height="60px" alt="main_logo"> 
      </a></center>
				<hr>
				
                  <h4 class="text-white font-weight-bolder text-center mt-2 mb-0">  <i class="material-icons opacity-10">account_balance</i> Banking Login</h4>
     
                </div>
              </div>
              <div class="card-body">

			  <?php
if (isset($_GET['inactive'])) {
    ?>
                        <div class=''>
                            <button class='close' data-dismiss='alert'><ion-icon name="chevron-back-outline"></ion-icon></button>
                                <strong>Sorry!</strong> This Account is not Activated, Contact Support for Activation. 
                        </div>
    <?php
}
?>
                          <?php if (isset($msg)) echo $msg; ?>
				 <form  action=""  method="POST" role="form" class="text-start">
                  <div class="input-group input-group-outline my-3">
                    <label class="form-label">Account Number</label>
                    <input type="text" class="form-control"  name="acc_no" required>
                  </div>
                  <div class="input-group input-group-outline mb-3">
                    <label class="form-label">Password</label>
                    <input type="password" class="form-control" name="upass" required  >
                  </div>
                  <div class="form-check form-switch d-flex align-items-center mb-3">
                    <input class="form-check-input" type="checkbox" id="rememberMe">
                    <label class="form-check-label mb-0 ms-2" for="rememberMe">Remember this Device</label>
                  </div>
                  <div class="text-center">
                    <button type="submit" name="login" class="btn w-100 my-4 mb-2" style="background-color:<?php echo $heading; ?>; color:<?php echo $text; ?>;">  <i class="material-icons opacity-10">account_balance</i> Authorize</button>
                  </div>
                  <p class="mt-4 text-sm text-center">
                    Don't have an account?
                    <a href="auth_enroll_1.php" class="text-primary text-gradient font-weight-bold">Enroll Now</a>
					<hr>
					<a href="https://citycreditfinance.com" class="text-primary text-gradient font-weight-bold">Visit Main Website</a>
                  </p>
                </form>
              </div>
            </div>
          </div>
        </div>
      </div>
 
    </div>
  </main>
  <!--   Core JS Files   -->
  <script src="assets/js/core/popper.min.js"></script>
  <script src="assets/js/core/bootstrap.min.js"></script>
  <script src="assets/js/plugins/perfect-scrollbar.min.js"></script>
  <script src="assets/js/plugins/smooth-scrollbar.min.js"></script>
  <script>
    var win = navigator.platform.indexOf('Win') > -1;
    if (win && document.querySelector('#sidenav-scrollbar')) {
      var options = {
        damping: '0.5'
      }
      Scrollbar.init(document.querySelector('#sidenav-scrollbar'), options);
    }
  </script>
  <!-- Github buttons -->
  <script async defer src="https://buttons.github.io/buttons.js"></script>
  <!-- Control Center for Material Dashboard: parallax effects, scripts for the example pages etc -->
  <script src="assets/js/material-dashboard.min.js?v=3.0.0"></script>
</body>

</html>
 
	 
	 

                         
                     
                     
	
 
	 
 
	 
	 