Browse Source

Novas att da tela de login

Agora esta autenticando o usuario mas ainda nao esta pronto o recovery de senha
dev
Matheo Bonucia 10 months ago
parent
commit
712c863152
  1. 4
      checaSessao.php
  2. 80
      components/Footer/footer.css
  3. 90
      components/Footer/footer.php
  4. 4
      components/Sociais/sociais.php
  5. 8
      css/login.css
  6. 185
      login.php
  7. 0
      login/api_banner.php
  8. 55
      login/processar_forms.php
  9. 1
      recuperarsenha.php
  10. 10
      templates/master.tpl

4
checaSessao.php

@ -6,8 +6,8 @@ if ((IsAjax()) && (!isset($_SESSION["SSlogin"]) || !$_SESSION["SSlogin"])) {
exit;
}
/*
* verifica se sessao corrente esta válida
*/
* verifica se sessao corrente esta válida
*/
if (!isset($_SESSION["SSinSession"]) || ($_SESSION["SSinSession"] != "ok")) {
$_SESSION["SSinSession"] = "ok";
$_SESSION["SSlogin"] = null;

80
components/Footer/footer.css

@ -0,0 +1,80 @@
.footer {
display: flex;
flex: 1;
flex-direction: row;
flex-wrap: wrap;
align-items: stretch;
justify-content: center;
width: 100vw;
height: 150px;
position: relative;
background-color: white;
border-radius: 60px 60px 0 0;
top: -80px;
overflow: hidden;
transition: slideY 1s ease-in-out;
}
.logo {
display: flex;
flex-direction: column;
font-size: small;
justify-content: center;
align-items: center;
}
.mainfooter {
color: rgba(100, 100, 100, 0.833);
height: 180px;
background-color: white;
}
.content-footer {
margin-top: 3px;
margin-left: 20px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-size: small;
}
.content-footer>p {
margin-bottom: 3px;
}
.footer p {
font-size: 12px;
}
.foote img {
width: 60px;
height: 55px;
}
.links {
display: flex;
flex-direction: row;
justify-content: space-evenly;
align-items: start;
width: 100%;
margin: 45px 5px 15px 5px;
}
.links a {
text-decoration: none;
color: #2D69F5;
list-style-type: none;
font-size: 18px;
}
.line {
width: 80%;
height: 2px;
background-color: whitesmoke;
}
.mainfooter {
-webkit-animation: slide-in-blurred-bottom 0.6s cubic-bezier(0.230, 1.000, 0.320, 1.000) both;
animation: slide-in-blurred-bottom 0.6s cubic-bezier(0.230, 1.000, 0.320, 1.000) both;
}

90
components/Footer/footer.php

@ -1,6 +1,5 @@
<?php
function GerarFooter(){
echo '<div class="mainfooter">
<div class="footer">
<div class="logo">
@ -10,7 +9,7 @@ function GerarFooter(){
<div class="content-footer">
<p>Telefone: +55 65 3616-8280 - Email: meajuda@simplesip.com.br</p>
<p>simplesip.net.br</p>
<p>Copyright © ' . getDataAno() . '</p>
<p>Copyright © ' . getDataAno(). '</p>
</div>
<div class="links">
<a href="#"><li>About</li></a>
@ -24,93 +23,6 @@ function GerarFooter(){
</div>'
;
}
function ImportaEstilo(){
echo '<style>
.footer {
display: flex;
flex: 1;
flex-direction: row;
flex-wrap: wrap;
align-items: stretch;
justify-content: center;
width: 100vw;
height: 150px;
position: relative;
background-color: white;
border-radius: 60px 60px 0 0;
top: -80px;
overflow: hidden;
transition: slideY 1s ease-in-out;
}
.logo {
display: flex;
flex-direction: column;
font-size: small;
justify-content: center;
align-items: center;
}
.mainfooter {
color: rgba(100, 100, 100, 0.833);
height: 180px;
background-color: white;
}
.content-footer {
margin-top: 3px;
margin-left: 20px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-size: small;
}
.content-footer>p {
margin-bottom: 3px;
}
.footer p {
font-size: 12px;
}
.foote img {
width: 60px;
height: 55px;
}
.links {
display: flex;
flex-direction: row;
justify-content: space-evenly;
align-items: start;
width: 100%;
margin: 45px 5px 15px 5px;
}
.links a {
text-decoration: none;
color: #2D69F5;
list-style-type: none;
font-size: 18px;
}
.line {
width: 80%;
height: 2px;
background-color: whitesmoke;
}
.mainfooter {
-webkit-animation: slide-in-blurred-bottom 0.6s cubic-bezier(0.230, 1.000, 0.320, 1.000) both;
animation: slide-in-blurred-bottom 0.6s cubic-bezier(0.230, 1.000, 0.320, 1.000) both;
}
</style>';
}
function getDataAno(){
$anoAtual = date('Y');
return $anoAtual;

4
components/Sociais/sociais.php

@ -1,11 +1,11 @@
<?php
function GerarSociais() {
echo '<div class="menu">
<a href="#"><div class="social"><i class="fa-brands fa-whatsapp fa-2x"></i></div></a>
<a href="#"><div class="social"><i class="fa-brands fa-instagram fa-2x"></i></div></a>
<a href="#"><div class="social"><i class="fa-brands fa-linkedin-in fa-2x"></i></div></a>
</div>';
}
?>

8
css/login.css

@ -273,6 +273,12 @@ button {
}
.right .right-content input {
width: calc(inherit - 300%);
width: 320px;
}
}
@media screen and (max-width:560px){
.right .right-content input {
width: auto;
}
}

185
login.php

@ -1,71 +1,55 @@
<?php
include "util/funcoesLicenca.php";
/**
* Conexao com banco de dados
*/
//coloca o focus no campo login
$setFocus = "document.getElementById('loginUser').focus();";
//define alinhamento no conteudo do master.tpl
$vAlineMaster = "middle";
/** DEFINE A QUANTIDADE DE ERROS DE AUTENTICACAO PARA BLOQUEIO */
$tentativaErro = 5;
$desabilitaLayout = 1;
$smarty->assign("desabilitaLayout", $desabilitaLayout);
/*
* Vefica se existem as configuracoes para recuperacao da senha.
*/
$smarty->assign("recuperaSenha", ValidaRecuperaSenha($dbcon));
include "login/api_banner.php";
include "util/funcoesLicenca.php";
/*
* usuario nao autenticado
*/
$tentativaErro = 5;
if (!isset($_POST["loginUser"])) {
$jsStartup[] = $setFocus;
DispLogin($smarty); // or $siteError->GetPhpError("Autentica Usuario", "", "Erro ao chamar funcao smarty!");
if (!isset($_POST['btLogin'])) {
echo "<script> console.log('Bem Vindo'); </script>";
} else {
$login = strtolower(substr($_POST["loginUser"], 0, 50));
// $login = isset($_POST['loginUser']) ? strtolower(substr($_POST['loginUser'], 0, 50)) : '';
// $senha = isset($_POST['loginPass']) ? substr($_POST['loginPass'], 0, 14) : '';
$senha = substr($_POST["loginPass"], 0, 14);
$validaTentativa = countTentativas($dbcon, $login, $tentativaErro);
if (!$validaTentativa && ($_POST["loginUser"] != 'admin')) {
$jsStartup[] = "alert('Seu acesso foi bloqueado por inúmeras tentativas de acesso inválidos! Para o desbloqueio, realize a alteração de senha ou consulte seu Administrador.');";
$jsStartup[] = $setFocus;
DispLogin($smarty);
return;
} else if (!validarLicenca($dbcon) && ($_POST["loginUser"] != 'admin')) {
$jsStartup[] = "alert('Sua licença é inválida por favor entre em contato com o suporte da Simples IP para ativar sua central!');";
DispLogin($smarty);
return;
}
$query = "select id, nome, apelido, matricula,
case when((select count(*)
from pbx_grupo_usuario a, pbx_grupo_funcoes b, pbx_funcoes c
where b.gp_id = a.gp_id
and c.fun_id = b.fun_id
and a.user_id = u.id
and c.fun_nome = 'mnSupervisor') > 0)then 1 else 0 end as supervisor,
cast( admin as int) as admin, case when(agente = true)then 1 else 0 end as agente,
def_senha,
senha_expira, senha_dias_expira,
senha_ult_atualiza,
senha_ult_atualiza + senha_dias_expira as senha_dt_expira,
case when((senha_ult_atualiza + senha_dias_expira) < CURRENT_DATE)then 1 else 0 end as senha_expirada,
penalidade, senha, termo_uso_privacidade
from pbx_usuarios u
where (u.check_vl = md5(%s) OR email = %s)
and coalesce(status, true) = true
and coalesce(delete_,0) = 0 ";
$result = pg_query($dbcon, sprintf($query, QuotedStr($login), QuotedStr($login)));
/*
* Faz autenticação do usuário.
*/
case when((select count(*)
from pbx_grupo_usuario a, pbx_grupo_funcoes b, pbx_funcoes c
where b.gp_id = a.gp_id
and c.fun_id = b.fun_id
and a.user_id = u.id
and c.fun_nome = 'mnSupervisor') > 0)then 1 else 0 end as supervisor,
cast( admin as int) as admin, case when(agente = true)then 1 else 0 end as agente,
def_senha,
senha_expira, senha_dias_expira,
senha_ult_atualiza,
senha_ult_atualiza + senha_dias_expira as senha_dt_expira,
case when((senha_ult_atualiza + senha_dias_expira) < CURRENT_DATE)then 1 else 0 end as senha_expirada,
penalidade, senha, termo_uso_privacidade
from pbx_usuarios u
where (u.check_vl = md5(%s) OR email = %s)
and coalesce(status, true) = true
and coalesce(delete_,0) = 0 ";
$query = sprintf($query, QuotedStr($login), QuotedStr($login));
$result = pg_query($dbcon, $query);
// Autentica usuário //
$senhaIsValid = false;
if (pg_num_rows($result)) {
if ($result) {
$row = pg_fetch_array($result);
$senhaUser = $row['senha'];
$senhaLogin = md5($senha);
@ -82,7 +66,7 @@ if (!isset($_POST["loginUser"])) {
$_SESSION["SSadmin"] = '0'; //$row['admin'];
$_SESSION["SSagente"] = '0'; //$row['agente'];
$_SESSION["SSagentePenalidade"] = $row['penalidade'];
$_SESSION["SSaut"] = "ok";
$_SESSION["SSaut"] = "OK";
$_SESSION[SS_SENHA_DEF] = $row["def_senha"];
$_SESSION["SSTermoUsoPrivacidade"] = $row["termo_uso_privacidade"];
@ -106,8 +90,8 @@ if (!isset($_POST["loginUser"])) {
GetCofigPadrao($dbcon);
/*
* expiracao de senha
*/
* expiracao de senha
*/
if ($row["senha_expira"]) {
$dataNow = date('Y-m-d');
@ -124,8 +108,8 @@ if (!isset($_POST["loginUser"])) {
}
/*
* Informações sobre dac padrao
*/
* Informações sobre dac padrao
*/
if (true) {
$dacParao = GetDacPadraoAgente($dbcon, false);
$_SESSION[SS_DAC_PADRAO] = $dacParao;
@ -133,10 +117,9 @@ if (!isset($_POST["loginUser"])) {
/*
* Vefifica Registros que precisam esta incluidos no banco de dados
*/
* Vefifica Registros que precisam esta incluidos no banco de dados
*/
VerificaDefaults($dbcon);
/*
* Captura a resolução do computador cliente.
*/
@ -152,21 +135,15 @@ if (!isset($_POST["loginUser"])) {
RegistraAcesso($_POST["loginUser"], ($row['id'] ? $row['id'] : '0'), '1');
GravaFull(0, '', 'Tentativa de login inválido', $_POST["loginUser"]);
$_SESSION["SSaut"] = "er";
//if(!$siteError->GetNumError())
$jsStartup[] = "alert('Usuário ou senha inválidos');";
$jsStartup[] = $setFocus;
DispLogin($smarty); // or $siteError->GetPhpError("Autentica Usuario");
echo '<script> alert("Usuário ou senha inválida!");</script>';
}
}
/**
* Captura tela de login
*/
function DispLogin($smarty)
{
$smarty->display('login.tpl');
if (isset($_POST['btLogin']) && $_SESSION["SSaut"] === "OK") {
header('Location: ' . $_SERVER['PHP_SELF']);
}
}
function countTentativas($dbcon, $login, $tentativaErro)
{
$login = addslashes($login);
@ -186,4 +163,74 @@ function ValidaRecuperaSenha($dbcon)
$result = pg_query($dbcon, $query);
$res = pg_fetch_assoc($result);
return ($res ? true : false);
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
SimplesIp Login
</title>
<style>
<?php
include 'css/login.css';
include "components/Footer/footer.css";
?>
</style>
<link rel="icon" href="img/FOOTER_SIMPLES_IP.png" type="image/png">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
</head>
<body>
<div class="container-home">
<div class="container-login">
<div class="login-content">
<div class="left">
<img src=<?php echo $imagem; ?> alt="Pessoa ao telefone" />
</div>
<div class="right">
<div class="right-content">
<h1>Bem Vindo</h1>
<h2>login</h2>
<form id="formulario-login" method="post" accept-charset="utf-8" action="index.php">
<div class="user">
<i class="fa-solid fa-user"></i>
<input placeholder="Insira seu email ou usuário" type="text" maxlength="50" name="loginUser" id="loginUser" />
</div>
<div class="password">
<i class="fa-solid fa-key"></i>
<input type="password" placeholder="Insira sua senha" maxlength="14" name="loginPass" id="loginPass" />
</div>
<div class="esqueci-senha">
<a href="index.php?action=recovery_password">Esqueci minha senha</a>
</div>
</div>
<div class='bn-login'>
<input type="submit" name="btLogin" value="Entrar" id="btLogon" class="bn632-hover bn24" />
</form>
</div>
<?php include "components/Sociais/sociais.php"; ?>
</div>
</div>
</div>
</div>
<?php
include "components/Footer/footer.php"; ?>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Aguarde até que o DOM esteja completamente carregado
document.getElementById('loginUser').focus();
});
</script>
</body>
</html>

0
login/api_banner.php

55
login/processar_forms.php

@ -1,9 +1,9 @@
<?php
include "util/funcoesLicenca.php";
include "include/bd.php";
$tentativaErro = 5;
$teste = pg_ping($dbcon);
echo "<script>Valor: $teste</script>";
header('Content-Type: application/json');
@ -11,8 +11,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['loginUser']) && isset($_POST['loginPass'])) {
$login = strtolower(substr($_POST["loginUser"], 0, 50));
$password = substr($_POST["loginPass"], 0, 14);
echo json_encode(['status' => 'success', 'message' => "Teste"]);
exit;
$query = "select id, nome, apelido, matricula,
case when((select count(*)
@ -29,22 +27,33 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
case when((senha_ult_atualiza + senha_dias_expira) < CURRENT_DATE)then 1 else 0 end as senha_expirada,
penalidade, senha, termo_uso_privacidade
from pbx_usuarios u
where (u.check_vl = md5(%s) OR email = %s)
and coalesce(status, true) = true
and coalesce(delete_,0) = 0 ";
$result = pg_query($dbcon, sprintf($query, QuotedStr($login), QuotedStr($login)));
// Autentica usuário //
$senhaIsValid = false;
if (pg_num_rows($result)) {
$row = pg_fetch_array($result);
$senhaUser = $row['senha'];
$senhaLogin = md5($senha);
$senhaIsValid = $senhaUser == $senhaLogin;
}
if($senhaIsValid){
}
}}
WHERE (u.check_vl = md5($1) OR email = $2)
AND coalesce(status, true) = true AND coalesce(delete_,0) = 0";
$params = [md5($login) , $login];
$result = pg_query_params($dbcon, $query, $params);
if (!$result) {
echo json_encode(['status' => 'error', 'message' => 'Erro na consulta SQL: ' . pg_last_error($dbcon)]);
}
// Autentica usuário //
$senhaIsValid = false;
if (pg_num_rows($result)) {
$row = pg_fetch_array($result);
$senhaUser = $row['senha'];
$senhaLogin = md5($senha);
$senhaIsValid = $senhaUser == $senhaLogin;
if ($senhaIsValid) {
echo json_encode(['status' => 'success', 'message' => 'Autenticação bem-sucedida']);
} else {
echo json_encode(['status' => 'error', 'message' => 'Senha inválida']);
}
} else {
echo json_encode(['status' => 'error', 'message' => 'Usuário não encontrado']);
}
}
}
?>

1
recuperarsenha.php

@ -5,6 +5,7 @@
$setActPage = "index.php?action=recovery_password";
$email = isset($_POST['email']) ? $_POST['email'] : null;
echo 'vim aqui';
try {
if (isset($_POST['btEnviar'])) {

10
templates/master.tpl

@ -1,8 +1,10 @@
{* Agora para desabilitar o layout todo da página,
basta declarar a variável $habilitaLayout a partir
da smarty->() para ocultar tudo.
{*
## MATHEO ##
Agora para desabilitar o layout todo da página,
basta declarar a variável $desabilitaLayout a partir
da $smarty->assign("desabilitaLayout",$desabilitaLayout); para ocultar tudo.
*}
{if !$habilitaLayout}
{if !$desabilitaLayout}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

Loading…
Cancel
Save