Commit e7c2fcbc33535225f829d631fef569ae91c812e4
1 parent
61ff58c3
Exists in
master
Inclusão de verificação de tentativas de login, máximo de 3 última hora
Showing
4 changed files
with
27 additions
and
3 deletions
Show diff stats
admin/php/login.php
... | ... | @@ -115,6 +115,11 @@ switch (strtoupper($funcao)) |
115 | 115 | $senha = $_POST["senha"]; |
116 | 116 | |
117 | 117 | $teste = autenticaUsuario($usuario,$senha); |
118 | + if($teste == "muitas tentativas"){ | |
119 | + logoutUsuario(); | |
120 | + header ( "HTTP/1.1 403 Muitas tentativas" ); | |
121 | + exit; | |
122 | + } | |
118 | 123 | if($teste != false){ |
119 | 124 | $_SESSION["usuario"] = $usuario; |
120 | 125 | $_SESSION["id_usuario"] = $teste["usuario"]["id_usuario"]; |
... | ... | @@ -290,11 +295,26 @@ function autenticaUsuario($usuario,$senha){ |
290 | 295 | include(dirname(__FILE__)."/conexao.php"); |
291 | 296 | $senhamd5 = md5($senha); |
292 | 297 | $senhaHash = password_hash($senha, PASSWORD_DEFAULT); |
298 | + //faz um teste de tentativas de acesso | |
299 | + $nomeArquivo = $dir_tmp."/a".md5($usuario."testeTentativas").intval(time() / 1000); | |
300 | + if(!file_exists($dir_tmp)){ | |
301 | + return false; | |
302 | + } | |
303 | + if(file_exists($nomeArquivo)){ | |
304 | + $tentativas = (int) file_get_contents($nomeArquivo); | |
305 | + if($tentativas > 3){ | |
306 | + return "muitas tentativas"; | |
307 | + } | |
308 | + $tentativas = $tentativas + 1; | |
309 | + file_put_contents($nomeArquivo, $tentativas); | |
310 | + } | |
311 | + else { | |
312 | + file_put_contents($nomeArquivo, 1); | |
313 | + } | |
293 | 314 | //verifica se o usuario esta cadastrado no ms_configura.php em $i3geomaster |
294 | 315 | //echo "select * from ".$esquemaadmin."i3geousr_usuarios where login = '$usuario' and (senha = '$senhamd5' or senha = '$senha') and ativo = 1";exit; |
295 | 316 | //exit; |
296 | 317 | if(verificaMaster($usuario,$senha) == true){ |
297 | - | |
298 | 318 | $pa = pegaDados("select * from ".$esquemaadmin."i3geousr_papelusuario ",$dbh,false); |
299 | 319 | $op = pegadados("SELECT O.codigo FROM ".$esquemaadmin."i3geousr_operacoes AS O",$dbh,false); |
300 | 320 | $gr = pegadados("SELECT * from ".$esquemaadmin."i3geousr_grupos ",$dbh,false); |
... | ... | @@ -317,6 +337,7 @@ function autenticaUsuario($usuario,$senha){ |
317 | 337 | $r = array("usuario"=>$master,"papeis"=>$papeis,"operacoes"=>$operacoes,"gruposusr"=>$gruposusr); |
318 | 338 | $dbh = null; |
319 | 339 | $dbhw = null; |
340 | + file_put_contents($nomeArquivo, 1); | |
320 | 341 | return $r; |
321 | 342 | } |
322 | 343 | else{ |
... | ... | @@ -362,6 +383,7 @@ function autenticaUsuario($usuario,$senha){ |
362 | 383 | $r = array("usuario"=>$dados[0],"papeis"=>$papeis,"operacoes"=>$operacoes,"gruposusr"=>$gruposusr); |
363 | 384 | $dbh = null; |
364 | 385 | $dbhw = null; |
386 | + file_put_contents($nomeArquivo, 1); | |
365 | 387 | return $r; |
366 | 388 | } |
367 | 389 | else{ | ... | ... |
ferramentas/loginusuario/dicionario.js
ferramentas/loginusuario/template_mst.html
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 | <p class='paragrafo'> |
3 | 3 | {{{ativo}}}: <b><i>{{{usuarioLogado}}}</i></b> |
4 | 4 | <p class='paragrafo'>{{{usuario}}}:</p> |
5 | + <p class="paragrafo">{{{tentativas}}}</p> | |
5 | 6 | <div class='i3geoForm i3geoFormIconeUsuario'> |
6 | 7 | <input id=i3geousuario type=text value=''/> |
7 | 8 | </div> | ... | ... |
ferramentas/loginusuario/template_mst_bt.html