Добавлена возможность перехешировать пароль по запросу.
This commit is contained in:
parent
4f46e7e5ed
commit
9196512713
27
enter.php
27
enter.php
@ -7,17 +7,18 @@ foreach ($_POST as $key => $val) { //???????????????
|
||||
}
|
||||
|
||||
$username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_SPECIAL_CHARS);
|
||||
$password = filter_input(INPUT_POST, 'password');
|
||||
$password = password_hash(filter_input(INPUT_POST, 'password'), PASSWORD_DEFAULT);
|
||||
$battle = filter_input(INPUT_COOKIE, 'battle');
|
||||
$error = "";
|
||||
|
||||
$data = db::c()->query('SELECT `id`, `login` ,`pass`, `room`, `block` FROM `users` WHERE `login` = "?s" AND `pass` = "?s" LIMIT 1', $username, md5($password))->fetch_assoc();
|
||||
if ($username && $password) {
|
||||
$data = db::c()->query('SELECT `id`, `login` ,`pass`, `room`, `block` FROM `users` WHERE `login` = "?s" AND `pass` = "?s"', $username, $password)->fetch_assoc();
|
||||
|
||||
if (!$data['id']) {
|
||||
$error = 'Неверные учётные данные!';
|
||||
} elseif ($data['block'] == 1) {
|
||||
$error = 'Ваш персонаж был заблокирован!';
|
||||
}
|
||||
} elseif (password_verify($password, $data['pass'])) {
|
||||
|
||||
if (!$error) {
|
||||
if ($battle != null && $data['id'] != $battle) {
|
||||
@ -51,6 +52,26 @@ if (!$error) {
|
||||
db::c()->query('DELETE FROM `telegraph` WHERE `owner` = ?i', $data['id']);
|
||||
header("Location: fight.php");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Обновляем пароли пользователей...
|
||||
*/
|
||||
|
||||
$username_upd = filter_input(INPUT_POST, 'username_upd', FILTER_SANITIZE_SPECIAL_CHARS);
|
||||
$password_upd = filter_input(INPUT_POST, 'password_upd');
|
||||
|
||||
if ($username_upd && $password_upd) {
|
||||
$data = db::c()->query('SELECT `id`, `login` ,`pass`, `room`, `block` FROM `users` WHERE `login` = "?s" AND `pass` = "?s"', $username, md5($password))->fetch_assoc();
|
||||
if ($data) {
|
||||
$hashed_password = password_hash($password_upd, PASSWORD_DEFAULT);
|
||||
db::c()->query('UPDATE `users` SET `pass` = "?s" WHERE `login` = "?s"', $username_upd, $hashed_password);
|
||||
echo '<span class="greenalert">Пароль обновлён!</span>';
|
||||
}
|
||||
echo '<span class="redalert">Ошибка!</span>';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
|
@ -17,6 +17,15 @@
|
||||
<input type=submit value='Отправить'>
|
||||
</form>
|
||||
|
||||
<div style="background: seashell; border-radius: 5px; margin: 10px; padding: 10px;">
|
||||
<form method="post" action="enter.php">
|
||||
Обновление пароля<br>
|
||||
<input name='username_upd' placeholder='Логин'>
|
||||
<input name='password_upd' placeholder='Пароль' type="password">
|
||||
<input type=submit value='Отправить'>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<ul class="menu">
|
||||
<li><a href="register.php">Регистрация</a></li>
|
||||
<li><a href="rememberpassword.php">Забыли пароль?</a></li>
|
||||
|
Loading…
Reference in New Issue
Block a user