<?php
	#################################################################
	##  WHMX Billing system for cPanel / WHM					   ##
	##-------------------------------------------------------------##
	##  Version: 1.00 - ENVATO MARKET                              ##
	##-------------------------------------------------------------##
	##  Author: Gianck Luiz obviosistemas@gmail.com         	   ##
	##-------------------------------------------------------------##
	##  Copyright ©2016 . All rights reserved.	                   ##
	##-------------------------------------------------------------##
	#################################################################
	
	session_start();
	ob_start();
	require_once("config/conexao.class.php");
    require_once("config/crud.class.php");  
	include_once("config/common.php"); // Language

    $con = new conexao(); // New conection 
    $con->connect(); // Open conection 

	if (@$_POST['operacao'] == 'login') { 
	$login = anti_injection($_POST['login']);
	$passmdr = md5(anti_injection($_POST['senha']));
    
    $query = mysql_query("SELECT * FROM users WHERE login = '$login' AND senha = '$passmdr'");
    $linha = mysql_fetch_array($query);
	$contagem = mysql_num_rows($query); 
	
	if (@$contagem == 1 ) {
	if($linha['status'] == 'S') { 
	$_SESSION['login'] = $linha['login']; // Login 
	$_SESSION['admid'] = $linha['id']; // ID 
	$_SESSION['nivel'] = $linha['nivel']; // ID 
	echo "<script>
		window.location = 'index.php';
		</script>";
	} else { 
	$retorno = "<div class='alert alert-danger alert-dismissable'>
                    <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                    <h4><i class='icon fa fa-ban'></i> Alert!</h4> $lang[LOGIN_ERROR_BLOCK]
                  </div>"; 
	}
	} else {
	$retorno = "<div class='alert alert-danger alert-dismissable'>
                    <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                    <h4><i class='icon fa fa-ban'></i> Alert!</h4> $lang[LOGIN_ERROR]
                  </div>"; 
	}
	}
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="ISO-8859-1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Log in</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="assets/dist/css/AdminLTE.min.css">
    <!-- iCheck -->
    <link rel="stylesheet" href="assets/plugins/iCheck/square/blue.css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body class="hold-transition login-page">
    <div class="login-box">
      <div class="login-logo">
        <a href=""><b>WHM</b>X</a>
      </div><!-- /.login-logo -->
      <div class="login-box-body">
		 
		 <?php echo $retorno; ?>
		  
        <p class="login-box-msg"><?php echo $lang['LOGIN_TXT']; ?></p>
        <form action="login.php" method="POST">
			<input type="hidden" value="login" name="operacao">
          <div class="form-group has-feedback">
            <input type="text" name="login" class="form-control" placeholder="<?php echo $lang['LOGIN_USERNAME']; ?>">
            <span class="glyphicon glyphicon-user form-control-feedback"></span>
          </div>
          <div class="form-group has-feedback">
            <input type="password" name="senha" class="form-control" placeholder="<?php echo $lang['LOGIN_PWD']; ?>">
            <span class="glyphicon glyphicon-lock form-control-feedback"></span>
          </div>
          <div class="row">
            <div class="col-xs-8">
             
            </div><!-- /.col -->
            <div class="col-xs-4">
              <input type="submit" class="btn btn-primary btn-block btn-flat" value="Login">
            </div><!-- /.col -->
          </div>
        </form>

       
      </div><!-- /.login-box-body -->
    </div><!-- /.login-box -->

    <!-- jQuery 2.1.4 -->
    <script src="assets/plugins/jQuery/jQuery-2.1.4.min.js"></script>
    <!-- Bootstrap 3.3.5 -->
    <script src="assets/bootstrap/js/bootstrap.min.js"></script>
  </body>
</html>
