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

require('include/connectdb.php');
require_once 'include/class.user.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 sg-Btn sg-Btn--primaryy sg-u-widthLarge'>
					
						  Invalid Account No or Password!
                   
			  </div>";
    } elseif ($status == 'Disabled') {
        $msg = "<div class='alert alert-inverse'>
					
						  <strong>Sorry! Your Account Has Been Disabled For Violation of Our Terms!</strong>
                   
			  </div>";
    } elseif ($status == 'Closed') {
        $msg = "<div class='alert alert-inverse'>
						
						  <strong>Sorry! That Account No Longer Exist!</strong>
                   
			  </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 = "DEMOBANK"; /* sender id */
    $message = "Please enter this code to continue proceed
				$code";


    $message = "
				<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>

  <title>[SUBJECT]</title>
  <style type='text/css'>
  body {
   padding-top: 0 !important;
   padding-bottom: 0 !important;
   padding-top: 0 !important;
   padding-bottom: 0 !important;
   margin:0 !important;
   width: 100% !important;
   -webkit-text-size-adjust: 100% !important;
   -ms-text-size-adjust: 100% !important;
   -webkit-font-smoothing: antialiased !important;
 }
 .tableContent img {
   border: 0 !important;
   display: block !important;
   outline: none !important;
 }
 a{
  color:#382F2E;
}

p, h1{
  color:#382F2E;
  margin:0;
}

div,p,ul,h1{
  margin:0;
}
p{
font-size:13px;
color:#99A1A6;
line-height:19px;
}
h2,h1{
color:#444444;
font-weight:normal;
font-size: 22px;
margin:0;
}
a.link2{
padding:15px;
font-size:13px;
text-decoration:none;
background:#2D94DF;
color:#ffffff;
border-radius:6px;
-moz-border-radius:6px;
-webkit-border-radius:6px;
}
.bgBody{
background: #f6f6f6;
}
.bgItem{
background: #2C94E0;
}

@media only screen and (max-width:480px)
		
{
		
table[class='MainContainer'], td[class='cell'] 
	{
		width: 100% !important;
		height:auto !important; 
	}
td[class='specbundle'] 
	{
		width: 100% !important;
		float:left !important;
		font-size:13px !important;
		line-height:17px !important;
		display:block !important;
		
	}
	td[class='specbundle1'] 
	{
		width: 100% !important;
		float:left !important;
		font-size:13px !important;
		line-height:17px !important;
		display:block !important;
		padding-bottom:20px !important;
		
	}	
td[class='specbundle2'] 
	{
		width:90% !important;
		float:left !important;
		font-size:14px !important;
		line-height:18px !important;
		display:block !important;
		padding-left:5% !important;
		padding-right:5% !important;
	}
	td[class='specbundle3'] 
	{
		width:90% !important;
		float:left !important;
		font-size:14px !important;
		line-height:18px !important;
		display:block !important;
		padding-left:5% !important;
		padding-right:5% !important;
		padding-bottom:20px !important;
	}
	td[class='specbundle4'] 
	{
		width: 100% !important;
		float:left !important;
		font-size:13px !important;
		line-height:17px !important;
		display:block !important;
		padding-bottom:20px !important;
		text-align:center !important;
		
	}
		
td[class='spechide'] 
	{
		display:none !important;
	}
	    img[class='banner'] 
	{
	          width: 100% !important;
	          height: auto !important;
	}
		td[class='left_pad'] 
	{
			padding-left:15px !important;
			padding-right:15px !important;
	}
		 
}
	
@media only screen and (max-width:540px) 

{
		
table[class='MainContainer'], td[class='cell'] 
	{
		width: 100% !important;
		height:auto !important; 
	}
td[class='specbundle'] 
	{
		width: 100% !important;
		float:left !important;
		font-size:13px !important;
		line-height:17px !important;
		display:block !important;
		
	}
	td[class='specbundle1'] 
	{
		width: 100% !important;
		float:left !important;
		font-size:13px !important;
		line-height:17px !important;
		display:block !important;
		padding-bottom:20px !important;
		
	}		
td[class='specbundle2'] 
	{
		width:90% !important;
		float:left !important;
		font-size:14px !important;
		line-height:18px !important;
		display:block !important;
		padding-left:5% !important;
		padding-right:5% !important;
	}
	td[class='specbundle3'] 
	{
		width:90% !important;
		float:left !important;
		font-size:14px !important;
		line-height:18px !important;
		display:block !important;
		padding-left:5% !important;
		padding-right:5% !important;
		padding-bottom:20px !important;
	}
	td[class='specbundle4'] 
	{
		width: 100% !important;
		float:left !important;
		font-size:13px !important;
		line-height:17px !important;
		display:block !important;
		padding-bottom:20px !important;
		text-align:center !important;
		
	}
		
td[class='spechide'] 
	{
		display:none !important;
	}
	    img[class='banner'] 
	{
	          width: 100% !important;
	          height: auto !important;
	}
		td[class='left_pad'] 
	{
			padding-left:15px !important;
			padding-right:15px !important;
	}
		
	.font{
		font-size:15px !important;
		line-height:19px !important;
		
		}
}

</style>

<script type='colorScheme' class='swatch active'>
  {
    'name':'Default',
    'bgBody':'f6f6f6',
    'link':'ffffff',
    'color':'99A1A6',
    'bgItem':'2C94E0',
    'title':'444444'
  }
</script>

</head>
<body paddingwidth='0' paddingheight='0' bgcolor='#d1d3d4'  style=' margin-left:5px; margin-right:5px; margin-bottom:0px; margin-top:0px;padding-top: 0; padding-bottom: 0; background-repeat: repeat; width: 100% !important; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; -webkit-font-smoothing: antialiased;' offset='0' toppadding='0' leftpadding='0'>
  <table width='100%' border='0' cellspacing='0' cellpadding='0' class='tableContent bgBody' align='center'  style='font-family:Helvetica, Arial,serif;'>
  
    <!-- =============================== Header ====================================== -->

  <tr>
    <td class='movableContentContainer' >
    	<div class='movableContent' style='border: 0px; padding-top: 0px; position: relative;'>
        	<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' valign='top'>
                   <tr><td height='25'  colspan='3'></td></tr>

                    <tr>
                     
                    </tr>
                </table>
        </div>
        <div class='movableContent' style='border: 0px; padding-top: 0px; position: relative;'>
        	<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' valign='top'>
                        <tr><td height='2'  ></td></tr>

                        <tr>
                          <td height='200'  bgcolor='#fdfefe'>
                            <table align='center' border='0' cellspacing='0' cellpadding='0' class='MainContainer'>
  <tr>
    <td></td>
  </tr>
  

                                    <tr>
                                      <td></td>
                                      <td valign='top'>
                                        <table width='300' border='0' cellspacing='0' cellpadding='0' align='center' valign='top'>
                                          <tr>
                                            <td valign='top'>
                                              <div class='contentEditableContainer contentTextEditable'>
                                                <div class='contentEditable' >
                                                  <h1 style='font-size:20px;font-weight:normal;color:#fFFF;line-height:19px;'>Welcome!</h1>
                                                </div>
                                              </div>
                                            </td>
                                          </tr>
                                          <tr><td height='18'></td></tr>
                                          <tr>
                                            <td valign='top'>
                                              <div class='contentEditableContainer contentTextEditable'>
                                                <div class='contentEditable' >
                                                  <p style='font-size:13px;color:#0000;line-height:19px;'>Please enter OTP to sign into your account <br> <h4>$code</h4></p>
                                                </div>
                                              </div>
                                            </td>
                                          </tr>
                                          
                                          <tr><td height='1'></td></tr>
                                        </table>
                                      </td>
                                      <td></td>
                                    </tr>
                                  </table>
                                </td>
  </tr>
</table>
</td>
  </tr>

</table>

                          </td>
                        </tr>

                        <tr><td height='0' ></td></tr>
                </table>
       
        
        
        
        <div class='movableContent' style='border: 0px; padding-top: 0px; position: relative;'>
        	<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' valign='top'>
                  <tr>
                    <td>
                      <table width='600' border='0' cellspacing='0' cellpadding='0' align='center' valign='top' class='MainContainer'>
                        <tr>
                          <td>
                            <table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' valign='top'>

                              <tr>
                                <td>
                                  
                                </td>
                              </tr>
                              
                              <tr>
                                <td valign='top' align='center'>
                                  <div class='contentEditableContainer contentTextEditable'>
                                    <div class='contentEditable' >
                                     <p style=' font-weight:bold;font-size:13px;line-height: 30px;'>DEMO</p>
                                    </div>
    <br>                           <div class='contentEditableContainer contentTextEditable'>
                                    <div class='contentEditable' >
                                      <p style='#F00; font-size:13px;line-height: 15px;'>This message is sent to this email to $fname <br /> <br /> <center><b>How do I know this is not a fake email?</b></center> <br />

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.<br /><br />
                                      </p>
                                      <p style='#F00; font-size:13px;line-height: 15px;'>Remember not to click any links in suspicious looking emails. </p>
                                    </div>
                                  </div>                               </div>
                                  <div class='contentEditableContainer contentTextEditable'>
                                    <div class='contentEditable' >
                                      <p style='color:#A8B0B6; font-size:13px;line-height: 15px;'>&nbsp;</p>
                                    </div>
                                  </div>
                                  <div class='contentEditableContainer contentTextEditable'>
                                  </div>
                                  <div class='contentEditableContainer contentTextEditable'>
                                    
                                  </div>
                                </td>
                              </tr>

                              <tr><td height='28'>&nbsp;</td></tr>
                            </table>
                          </td>
                        </tr>
                      </table>
                    </td>
                  </tr>
          </table>
        </div>
    </td>
  </tr>
</table>


</body>
  </html>";



    $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 = "Verification OTP";
    $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: dashboard/pin_auth.php');
        exit();
    } else {
        $reg_user->send_mail($row['email'], $message, $subject);
        $phone = preg_replace('/[^0-9]/', '', $row['phone']);
        $mobile_msg = "Dear " . $row['fname'] . ", Please use the One Time Passcode (OTP): " . $code . " to complete your login process";
        $reg_user->otp($phone,$mobile_msg);
        header('Location: dashboard/otp.php');
    }
} else {
    
}
//3.2 When the user visits the page first time, simple login form will be displayed.
?>
<!doctype html>
<html class=" responsive js flexbox flexboxlegacy canvas canvastext webgl no-touch geolocation postmessage websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients cssreflections csstransforms csstransforms3d csstransitions fontface generatedcontent video audio localstorage sessionstorage webworkers applicationcache svg inlinesvg smil svgclippaths" lang="en" style=""><!--<![endif]--><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><script type="text/javascript" async="" src="dist/f1979f5a70587665c1296dd83182f431.js.download"></script><script type="text/javascript" async="" src="dist/4b5db88949505f0bc95de8ea817f7f76.js.download"></script><script type="text/javascript" async="" src="dist/e39348687472637c96bba61aec1d465d.js.download"></script><script src="dist/serverComponent.php"></script>
   <title>DEMO Login</title>
   <meta http-equiv="cache-control" content="no-cache">
    
    <meta http-equiv="pragma" content="no-cache">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta http-equiv="Content-Security-Policy" content="
        
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">

    <link rel="shortcut icon" href="dashboard/favicon.png" type="image/x-icon">
    <link rel="stylesheet" type="text/css" href="dist/normalize.css">
<link rel="stylesheet" type="text/css" media="screen" href="dist/suncorpnew-uama.css">
    <script id="gtag" src="dist/js" type="text/javascript"></script><script src="dist/jquery.min.js.download"></script>
    <script src="dist/ensighten.js.download"></script>
    <script src="dist/modernizr.min.js.download"></script>
    <script src="dist/styleguide.generated.js.download"></script>
  
  <style>.sg-Btn.sg-Btn--primary {
    color: white;
    background-color: #369916;
}    
 .sg-Btn.sg-Btn--primary {
    border: 1px solid #369916;
}

.sg-Btn.sg-Btn--primary:hover:not(.is-disabled),.sg-Btn.sg-Btn--primary:focus:not(.is-disabled){color:#000000;background-color:#369916}

.sg-Btn.sg-Btn--primaryy {
    color: white;
    background-color: #ff0000e0;
}
</style>    
</head>

<body class="sg-Page">
<header class="sg-Header">
    <div class="sg-Header-content">
        <div class="sg-Header-column">
           <img src='https://agencycommand.com/wp-content/uploads/2015/10/AC-Ultimate-Demo-Button.png' alt='LOGO' data-default='placeholder' data-max-width='100' width='150' height='80' >
        </div>
        <div class="sg-Header-column sg-u-width10of10 sg-u-textRight">
            <div class="sg-Grid-row">
                <h1 class="ib-header">Internet Banking</h1>
                <span class="Icon-lock--default Icon--medium"></span>
            </div>

            <div id="bannerInfo" class="ib-banner-info">
                <span class="sg-u-mediumAndSmallHidden"><strong>BSB</strong> 484-799</span>
                <span class="sg-u-mediumAndSmallHidden"><strong>Swift Code</strong> XXXXXXXX</span>
            </div>
        </div>
    </div>
</header>
    <main class="sg-Main">
        <div class="sg-Main-content">
            <div class="sg-Box sg-Box--error sg-Box--withIcon uama-hidden" id="simpleErrorBox">
                <div class="sg-Box-icon sg-Box-icon--withBackground">
                    <span class="sg-Box--errorIcon"></span>
                </div>
                <div class="sg-Box-content">
                    <p></p>
                </div>
            </div>
                <div class="sg-Flextable sg-Flextable--2cols sg-Flextable--collapseLarge">
<div login-session="" class="sg-Flextable-cell">
    <h3 class="ib-form-header sg-u-marginBottom">Login to Internet Banking</h3>
    <form method="post" id="loginForm">
     <?php
if (isset($_GET['inactive'])) {
    ?>
                        <div class='alert alert-info col-4'>
                            <button class='close' data-dismiss='alert'>&times;</button>
                                <strong>Sorry!</strong> This Account is not Activated Contact Customer Care Activate it. 
                        </div>
    <?php
}
?>
                    <?php if (isset($msg)) echo $msg; ?>
        <fieldset class="ib-question-group sg-u-marginBotton">
            <input class="sg-Input" type="hidden" name="request_id" value="">
            <div class="question">
                <label for="username" class="sg-Type--title">Customer ID</label>
                <input class="sg-Input sg-u-widthLarge" id="UserId" tabindex="1" placeholder="Enter Your Account No." autofocus="autofocus" name="acc_no" type="text" autocomplete="off" maxlength="1000" required>
            </div>

            <div class="question">
                <label for="password" class="sg-Type--title">Password</label>
                <div class="password-container">
                    <div class="password-input">
                        <input class="sg-Input sg-u-widthLarge" id="password" placeholder="Enter Your Account Password." tabindex="2" name="upass" type="password" required>
                    </div>
                </div>
                <div class="capslock-warning" style="display: none;">
                    <div class="warning">
                        <p class="sg-Type--size14"><span class="Icon-alert--error Icon--small" id="capslock-icon"></span><strong>Caps Lock is on.</strong> Passwords are case sensitive.</p>
                    </div>
                </div>
                <a href="">Forgot your password?</a>
            </div>

             <button type="submit" name="login" id="login-button" class="sg-Btn sg-Btn--primary sg-u-widthLarge" tabindex="4">
                        Login
                    </button>

            <div class="button-container">
                <p>
                   
                   
                </p>
                <p>
                    First time here?
                    <a href="dashboard/applicationform.php" target="_blank">Register for Internet Banking</a>
                </p>
            </div>
        </fieldset>
    </form>
    
</div>


<div class="sg-Flextable-cell sg-Flextable-cell--2of5 sg-Flextable-cell--light help-section">
<p>DEMO BANK BY MR SAM SCRIPTS WHATSAPP/CALL ME +2348188730307</p>
<P>WARNING:EDUCATIONAL PURPOSE</P>
    <p class="sg-Type--size24">Need some help?</p>
    <p>If you have forgotten your Internet Banking Customer ID, please call our Customer Service Team on 13 11 55 or +1234566789 if you are located overseas.</p>
    <ul class="sg-List-unstyled help-items">
        <li><a href="" target="_blank" class="sg-Type--bold sg-Type--colourDark">Other Help &amp; Support</a></li>
        <ul class="sg-List-iconXsmall">
            <li class="Icon-arrowRight--default"><a href="" target="_blank">Frequently asked questions</a></li>
            <li class="Icon-arrowRight--default"><a href="" target="_blank">How to use Internet Banking</a></li>
        </ul>
        <li><a href="" target="_blank" class="sg-Type--bold sg-Type--colourDark">Being safe online</a></li>
        <ul class="sg-List-iconXsmall">
            <li class="Icon-arrowRight--default"><a href="" target="_blank">See how we protect your money online</a></li>
            <li class="Icon-arrowRight--default"><a href="" target="_blank">Identity scams at home</a></li>
            <li class="Icon-arrowRight--default"><a href="" target="_blank">Safe banking tips</a></li>
            <li class="Icon-arrowRight--default"><a href="" target="_blank">Protecting your computer</a></li>
        </ul>
    </ul>

    <div class="sg-Box sg-Box--withIcon security-section">
        <div class="sg-Box-icon">
            <span class="Icon-security--default-security Icon--large"></span>
        </div>
        <div class="sg-Box-content">
            <strong>DEMO Security</strong>
            <p>Committed to providing you a safe banking environment</p>
        </div>
    </div>
</div>

                </div>
        </div>
    </main>
<footer class="sg-Footer">
    <div class="sg-Footer-content">
        <ul class="sg-List-horizontal">
            <li><a href="" target="_blank">Terms and Conditions</a></li>
            <li><a href="" target="_blank">Contact Us</a></li>
        </ul>
        <p id="copyright" class="sg-Type--small sg-Type--muted">© Copyright DEMO LOGIN 12345<br> Internet Banking, Issued by +2348188730307</p>
    </div>
</footer>




