Store in GIT
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
//Load required scripts
|
||||
require('../../../inc/connect.php');
|
||||
require('../../../inc/crypt.php');
|
||||
|
||||
//Get username and password
|
||||
$email = $_POST['email'];
|
||||
|
||||
$sql = "SELECT `id`, `username` FROM `user` WHERE `email`='$email'";
|
||||
$query = ExecQuery($mysqli, $sql);
|
||||
|
||||
if($query->num_rows < 1)
|
||||
{
|
||||
error("login", "No account found with that email address");
|
||||
}
|
||||
|
||||
$result = $query->fetch_assoc();
|
||||
$username = $result['username'];
|
||||
$id = $result['id'];
|
||||
|
||||
$password = RandomString(8);
|
||||
$password_hash = password_hash($password, PASSWORD_BCRYPT);
|
||||
|
||||
$sql = "UPDATE `user` SET `password`='$password_hash' WHERE `id`=$id";
|
||||
ExecQuery($mysqli, $sql);
|
||||
|
||||
//Logout everywhere else
|
||||
$sql = "DELETE FROM `session` WHERE `user`=$id";
|
||||
ExecQuery($mysqli, $sql);
|
||||
|
||||
$msg = "Dear $username,\n\n";
|
||||
$msg .= "Your password has been reset.\nEvery active session has been logged out.\n";
|
||||
$msg .= "New password: <b>" . $password . "</b>";
|
||||
|
||||
sendMail($email, "Password reset", $msg);
|
||||
|
||||
success("login", "Your password has been reset, an email has been sent to " . $email);
|
||||
?>
|
||||
Reference in New Issue
Block a user