Files
battles/rememberpassword.php
2022-08-09 22:57:43 +03:00

43 lines
1.9 KiB
PHP

<?php
use Battles\Template, Battles\RememberPassword;
require_once("config.php");
$_GET['change'] ??= null;
$operation = new RememberPassword();
if (filter_input(INPUT_POST, 'loginid', FILTER_SANITIZE_SPECIAL_CHARS)) {
$statusMessage = $operation->sendRecoveryMail(filter_input(INPUT_POST, 'loginid', FILTER_SANITIZE_SPECIAL_CHARS));
}
if (!empty($_POST['newpasswd']) && !empty($_POST['hashcheck'])) {
$statusMessage = $operation->setNewPassword($_POST['newpasswd'], $_POST['hashcheck']);
}
Template::header('Восстановление пароля');
?>
<a href="/"> ← на главную</a>
<?php if (!empty($statusMessage)): ?>
<h3><?php echo $statusMessage; ?></h3>
<?php endif; ?>
<?php if ($operation->isAllowed($_GET['change']) === true): ?>
<h1>Создайте себе новый пароль</h1>
<form method="post">
<label>
<input required name="newpasswd" placeholder="Новый пароль"> Новый пароль.
</label>
<input type="hidden" name="hashcheck" value="<?= $_GET['change'] ?>"><br>
<input type=submit>
</form>
<?php else: ?>
<h1>Восстановление пароля</h1>
<p>Для восстановления пароля введите свой login и нажмите кнопку &laquo;Отправить письмо&raquo;.<br>
Письмо будет выслано на email адрес, указанный вами при регистрации.<br>
Восстанавливать пароль можно только раз в сутки.</p>
<form method="post">
<label>
<input required name="loginid" placeholder="Имя персонажа" value="<?= filter_input(INPUT_POST, 'loginid', FILTER_SANITIZE_SPECIAL_CHARS) ?>"> Имя персонажа.
</label><br>
<input type=submit>
</form>
<?php endif;