2018-03-01 18:43:46 +00:00
|
|
|
<?php
|
2021-02-01 16:42:52 +00:00
|
|
|
|
|
|
|
use Battles\Template;
|
2021-03-10 21:03:59 +00:00
|
|
|
use Battles\User;
|
2021-02-01 16:42:52 +00:00
|
|
|
|
2020-09-30 19:12:34 +00:00
|
|
|
require_once 'functions.php';
|
2018-03-04 01:14:13 +00:00
|
|
|
$name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING);
|
2018-03-02 15:31:43 +00:00
|
|
|
$oldpsw = filter_input(INPUT_POST, 'oldpsw', FILTER_SANITIZE_SPECIAL_CHARS);
|
|
|
|
$newpsw = filter_input(INPUT_POST, 'newpsw', FILTER_SANITIZE_SPECIAL_CHARS);
|
2018-03-04 01:14:13 +00:00
|
|
|
$hobbie = filter_input(INPUT_POST, 'hobbie', FILTER_SANITIZE_STRING);
|
2018-03-02 17:23:17 +00:00
|
|
|
$hobbie = str_replace("\\n", "<br />", $hobbie);
|
|
|
|
$hobbie = str_replace("\\r", "", $hobbie);
|
|
|
|
$hobbie = str_replace("<br />", "<br />", $hobbie);
|
2018-03-01 19:14:51 +00:00
|
|
|
|
2021-03-10 21:03:59 +00:00
|
|
|
if ($name || $hobbie) {
|
|
|
|
if (strlen($hobbie) > User::INFO_CHAR_LIMIT) {
|
|
|
|
err('Максимальная длинна поля Хобби: ' . User::INFO_CHAR_LIMIT . ' символов!');
|
2018-03-01 18:43:46 +00:00
|
|
|
} else {
|
2021-03-10 21:38:14 +00:00
|
|
|
if ($name) {
|
|
|
|
$user->setRealname($name);
|
|
|
|
}
|
|
|
|
if ($hobbie) {
|
|
|
|
$user->setInfo($hobbie);
|
|
|
|
}
|
2021-08-26 14:44:14 +00:00
|
|
|
$user->saveUser();
|
2018-03-01 18:43:46 +00:00
|
|
|
}
|
2018-01-28 16:40:49 +00:00
|
|
|
}
|
2020-08-30 00:55:53 +00:00
|
|
|
if ($oldpsw && $newpsw) {
|
2021-02-01 16:42:52 +00:00
|
|
|
if (password_verify($oldpsw, $user->getPass())) {
|
2021-03-10 21:38:14 +00:00
|
|
|
$user->setPass(password_hash($newpsw, PASSWORD_DEFAULT));
|
2021-08-26 14:44:14 +00:00
|
|
|
$user->saveUser();
|
2020-08-30 00:55:53 +00:00
|
|
|
} else {
|
|
|
|
err('Неверный текущий пароль!');
|
|
|
|
}
|
2018-03-02 15:31:43 +00:00
|
|
|
}
|
2021-02-01 16:42:52 +00:00
|
|
|
Template::header('Анкета');
|
2018-01-28 16:40:49 +00:00
|
|
|
?>
|
2018-03-01 18:43:46 +00:00
|
|
|
<a href="main.php">← на главную</a>
|
2021-02-01 16:42:52 +00:00
|
|
|
<h1>Анкета персонажа <?= $user->getLogin() ?></h1>
|
2020-09-30 19:12:34 +00:00
|
|
|
<form method="post">
|
2021-03-10 21:47:33 +00:00
|
|
|
<label>
|
|
|
|
<input name="name" placeholder="Реальное имя" value="<?= $user->getRealname() ?>">
|
|
|
|
Реальное имя
|
|
|
|
</label><br>
|
2021-02-01 16:42:52 +00:00
|
|
|
<textarea name="hobbie" placeholder="Хобби"><?= $user->getInfo() ?></textarea><br>
|
2018-03-01 18:43:46 +00:00
|
|
|
<input name="submit" type="submit">
|
|
|
|
</form>
|
2018-03-02 15:31:43 +00:00
|
|
|
<h1>Безопасность</h1>
|
2020-09-30 19:12:34 +00:00
|
|
|
<form method="post">
|
2018-03-02 15:31:43 +00:00
|
|
|
<input placeholder="Старый пароль" name="oldpsw">
|
|
|
|
<input placeholder="Новый пароль" name="newpsw">
|
|
|
|
<input type="submit">
|
2020-09-30 19:12:34 +00:00
|
|
|
</form>
|