Commit a4bab3af043bb7451485e03a578caafad0ef13fd
1 parent
4f4ac832
Exists in
master
and in
7 other branches
Verifica se a função password_hash existe (para manter compatibilidade com php antes de 5.5
Showing
3 changed files
with
10 additions
and
5 deletions
Show diff stats
admin/admin.db
No preview for this file type
admin/php/login.php
... | ... | @@ -295,8 +295,9 @@ function autenticaUsuario($usuario,$senha){ |
295 | 295 | include(dirname(__FILE__)."/conexao.php"); |
296 | 296 | error_reporting(0); |
297 | 297 | $senhamd5 = md5($senha); |
298 | - | |
299 | - $senhaHash = password_hash($senha, PASSWORD_DEFAULT); | |
298 | + if(function_exists("password_hash")){ | |
299 | + $senhaHash = password_hash($senha, PASSWORD_DEFAULT); | |
300 | + } | |
300 | 301 | |
301 | 302 | //faz um teste de tentativas de acesso |
302 | 303 | $nomeArquivo = $dir_tmp."/a".md5($usuario."testeTentativas").intval(time() / 1000); |
... | ... | @@ -348,7 +349,8 @@ function autenticaUsuario($usuario,$senha){ |
348 | 349 | //verifica se a senha e uma string ou pode ser um md5 |
349 | 350 | $ok = false; |
350 | 351 | $dados = array(); |
351 | - if(strlen($senha) == 32){ | |
352 | + //por causa das versoes antigas do PHP | |
353 | + if(strlen($senha) == 32 || !function_exists("password_hash") ){ | |
352 | 354 | $dados = pegaDados("select id_usuario,nome_usuario from ".$esquemaadmin."i3geousr_usuarios where login = '$usuario' and senha = '$senhamd5' and ativo = 1",$dbh,false); |
353 | 355 | if(count($dados) == 1 && $dados[0]["senha"] == $senhamd5 && $dados[0]["login"] == $usuario){ |
354 | 356 | $ok = true; | ... | ... |
admin1/usuarios/cadastro/funcoes.php
... | ... | @@ -82,8 +82,11 @@ function alterar($id_usuario, $ativo, $data_cadastro, $email, $login, $nome_usua |
82 | 82 | ); |
83 | 83 | // se a senha foi enviada, ela sera trocada |
84 | 84 | if ($senha != "") { |
85 | - //$dataCol ["senha"] = md5 ( $senha ); | |
86 | - $dataCol["senha"] = password_hash($_GET["senha"], PASSWORD_DEFAULT); | |
85 | + if(!function_exists("password_hash")){ | |
86 | + $dataCol ["senha"] = md5 ( $senha ); | |
87 | + } else { | |
88 | + $dataCol["senha"] = password_hash($_GET["senha"], PASSWORD_DEFAULT); | |
89 | + } | |
87 | 90 | } |
88 | 91 | $resultado = \admin\php\funcoesAdmin\i3GeoAdminUpdate ( $dbhw, "i3geousr_usuarios", $dataCol, "WHERE id_usuario = $id_usuario" ); |
89 | 92 | if ($resultado === false) { | ... | ... |