Hola, Hombre gracias por responder, el codigo es este.
Código PHP:
Ver originalfunction login($username, $password, $mysqli) {
// Using prepared statements means that SQL injection is not possible.
if ($stmt = $mysqli->prepare("SELECT id,
Nombre,
Apellidos,
password,
salt,
cargo,
departamento
FROM usuario
WHERE username = ? LIMIT 1")) {
$stmt->bind_param('s', $username); // Bind "$usernamel" to parameter.
$stmt->execute(); // Execute the prepared query.
$stmt->store_result();
// get variables from result.
$stmt->bind_result($username, $db_password, $salt);
$stmt->fetch();
// hash the password with the unique salt.
$password = hash('sha512', $password . $salt); if ($stmt->num_rows == 1) {
// If the user exists we check if the account is locked
// from too many login attempts
if (checkbrute($username, $mysqli) == true) {
return false;
} else {
// Check if the password in the database matches
// the password the user submitted.
if ($db_password == $password) {
// Password is correct!
// Get the user-agent string of the user.
$user_browser = $_SERVER['HTTP_USER_AGENT'];
// XSS protection as we might print this value
$_SESSION['username'] = $username;
// XSS protection as we might print this value
$username = preg_replace("/[^a-zA-Z0-9_\-]+/", "", $username);
$_SESSION['username'] = $username;
$_SESSION['login_string'] = hash('sha512', $password . $user_browser);
// Login successful.
return true;
} else {
// Password is not correct
// We record this attempt in the database
if (!$mysqli->query("INSERT INTO inyeccion(username, time)
VALUES ('$username', '$now')")) {
header("Location: ../error.php?err=Database error: inyeccion"); }
return false;
}
}
} else {
// No user exists.
return false;
}
} else {
// Could not create a prepared statement
header("Location: ../error.php?err=Database error: cannot prepare statement"); }
}
function checkbrute($username, $mysqli){
// Obtenemos el timestamp
$valid_attempts = $now - (82 * 60 * 60);
if($stmt = $mysqli->prepare("SELECT password FROM inyeccion WHERE username = ?" AND
time > '$valid_attempts')){ $stmt->bind_param('u',$username);
$stmt->execute;
$stmt->store_result();
if ($stmt->num_rows> 5){
return true;
} else {
return false;
}
} else {
[B
]header("Location: ../error.php?err=Database error: cannot prepare statement"); }
}
Este codigo me ha dado muchos problemas, :v pero ya he ejecutado la consulta del query y sale bien ya la descarte, mire las variables y tambien, solo se quedo hay estancado. Gracias por responder nuevamente!