<?php
	require_once("vendor/classe.cs.php");
	$cs = new cs;
	
	if(isset($_POST['login'])){
		
		$login = mysqli_real_escape_string($cs->con, $_POST['login']);
		$senha = mysqli_real_escape_string($cs->con, $_POST['senha']);
		$result = $cs->checkLoginUser($login, $senha);
		if(count($result) == 1){
			echo '<div class="alert alert-success"><strong>Login efetuado!</strong> Aguarde! você será redirecionado.</div><div class="loader1"></div>';
		}else{
			echo '<div class="alert alert-danger"><strong>Usuário inválido!</strong> Favor verificar login e senha.</div>';
		}
		exit;
	}
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<title>Area do Cliente</title>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
<!--===============================================================================================-->	
	<link rel="icon" type="image/png" href="__clientes/images/icons/favicon.ico"/>
<!--===============================================================================================-->
	<link rel="stylesheet" type="text/css" href="__clientes/vendor/bootstrap/css/bootstrap.min.css">
<!--===============================================================================================-->
	<link rel="stylesheet" type="text/css" href="__clientes/fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<!--===============================================================================================-->
	<link rel="stylesheet" type="text/css" href="__clientes/vendor/animate/animate.css">
<!--===============================================================================================-->	
	<link rel="stylesheet" type="text/css" href="__clientes/vendor/css-hamburgers/hamburgers.min.css">
<!--===============================================================================================-->
	<link rel="stylesheet" type="text/css" href="__clientes/vendor/select2/select2.min.css">
<!--===============================================================================================-->
	<link rel="stylesheet" type="text/css" href="__clientes/css/util.css">
	<link rel="stylesheet" type="text/css" href="__clientes/css/main.css">
<!--===============================================================================================-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <link rel="stylesheet" href="css/loader.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <script>
  $(function(){
	  $('#form_login').submit(function(){
		  $('#retornoLogin').html('<div class="loader1"></div>');
		  $.ajax({
			  type: "POST",
			  url: "acesso_cliente.php",
			  data: {login:$('#email').val(), senha: $('#pwd').val()},
			  success: function(data){
				  $('#retornoLogin').html(data);
				  if(data.match('success')){
					  setTimeout(function(){
						  window.location.href = "/painel_clientes/";
					  }, 200);
				  }
			  }
		  });
		  return false;
	  });
  })
  </script>
</head>
<body>

	<div class="limiter">
		<div class="container-login100">
			<div class="wrap-login100">
				<div class="login100-pic js-tilt" data-tilt>
					<img src="__clientes/images/img-01.png" alt="IMG">
				</div>
				

				<form class="login100-form validate-form" method="post" id="form_login">
					<span class="login100-form-title">
						Acesse com mesmo login e senha do seu IPTV
					</span>

					<div class="wrap-input100 validate-input" data-validate = "Usuário obrigatorio">
						<input class="input100" type="text" required id="email" name="email" placeholder="Usuário">
						<span class="focus-input100"></span>
						<span class="symbol-input100">
							<i class="fa fa-envelope" aria-hidden="true"></i>
						</span>
					</div>

					<div class="wrap-input100 validate-input" data-validate = "Senha obrigatória">
						<input class="input100" type="password" required id="pwd" name="pass" placeholder="Senha">
						<span class="focus-input100"></span>
						<span class="symbol-input100">
							<i class="fa fa-lock" aria-hidden="true"></i>
						</span>
					</div>
					
					<div class="container-login100-form-btn">
						<button type="submit" id="btnLogin" class="login100-form-btn">
							Login
						</button>
					</div><br>
					<p id="retornoLogin"></p>
					<a href="https://www.spaceiptv.net/testeiptv"><h5><center>Testar Lista IPTV</center></h5></a>
					<div class="text-center p-t-136">
						<a class="txt2" href="#">
							<i class="fa fa-long-arrow-right m-l-5" aria-hidden="true"></i>
						</a>
					</div>
				</form>

			</div>
		</div>
	</div>
	
	

	
<!--===============================================================================================-->	
	<script src="__clientes/vendor/jquery/jquery-3.2.1.min.js"></script>
<!--===============================================================================================-->
	<script src="__clientes/vendor/bootstrap/js/popper.js"></script>
	<script src="__clientes/vendor/bootstrap/js/bootstrap.min.js"></script>
<!--===============================================================================================-->
	<script src="__clientes/vendor/select2/select2.min.js"></script>
<!--===============================================================================================-->
	<script src="__clientes/vendor/tilt/tilt.jquery.min.js"></script>
	<script >
		$('.js-tilt').tilt({
			scale: 1.1
		})
	</script>
<!--===============================================================================================-->
	<script src="js/main.js"></script>

</body>
</html>