Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $result = $con->prepare("SELECT attempts FROM failed_attempt WHERE ip=? AND datetime BETWEEN DATE_SUB( NOW() , INTERVAL 1 DAY ) AND NOW()");
- $result->bind_param("s",$addres);
- $result->execute();
- $result->store_result();
- //Variable para saber si existe registro o no para insert o update.
- $check_result = $result->num_rows;
- if ($result->num_rows===1) {
- //Obtenemos datos para comparar intentos y para resetear intentos por su ultimo fecha.
- $result->bind_result($failed_login_attempt);
- $result->fetch();
- $result->close();
- } else {
- $result->close();
- $failed_login_attempt=0;
- }
- if(count($_POST)>0 && $captcha == true) {
- $username = $_POST["username"] ?: '';
- $password = $_POST["password"] ?: '';
- //Buscar usuario ingresado - INICIO
- $sql = $con->prepare("SELECT id_user,username,password,logindatetime, CASE WHEN logindatetime BETWEEN DATE_SUB( NOW() , INTERVAL 2 MINUTE ) AND NOW() THEN '1' ELSE '0' END as logueado FROM users where username=? AND active=? LIMIT 1");
- $sql->bind_param("si",$username,$active);
- $active=1;
- $sql->execute();
- $sql->store_result();
- if ($sql->num_rows===1) {
- $sql->bind_result($id_userBD,$usernameBD,$passwordDB,$logindatetime,$activeBD);
- if ($sql->fetch()){
- if (password_verify($password, $passwordDB)) {
- $check_password = true;
- } else {
- $check_password = false;
- }
- } $sql->close();
- } else {
- $sql->close();
- $check_password = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement