54 lines
1.8 KiB
PHP
54 lines
1.8 KiB
PHP
<?php
|
|
|
|
use Battles\Template;
|
|
use Battles\User;
|
|
|
|
session_start();
|
|
require_once 'functions.php';
|
|
$name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING);
|
|
$oldpsw = filter_input(INPUT_POST, 'oldpsw', FILTER_SANITIZE_SPECIAL_CHARS);
|
|
$newpsw = filter_input(INPUT_POST, 'newpsw', FILTER_SANITIZE_SPECIAL_CHARS);
|
|
$hobbie = filter_input(INPUT_POST, 'hobbie', FILTER_SANITIZE_STRING);
|
|
$hobbie = str_replace("\\n", "<br />", $hobbie);
|
|
$hobbie = str_replace("\\r", "", $hobbie);
|
|
$hobbie = str_replace("<br />", "<br />", $hobbie);
|
|
|
|
if ($name || $hobbie) {
|
|
if (strlen($hobbie) > User::INFO_CHAR_LIMIT) {
|
|
err('Максимальная длинна поля Хобби: ' . User::INFO_CHAR_LIMIT . ' символов!');
|
|
} else {
|
|
if ($name) {
|
|
$user->setRealname($name);
|
|
}
|
|
if ($hobbie) {
|
|
$user->setInfo($hobbie);
|
|
}
|
|
$user->saveAnketa();
|
|
}
|
|
}
|
|
if ($oldpsw && $newpsw) {
|
|
if (password_verify($oldpsw, $user->getPass())) {
|
|
$user->setPass(password_hash($newpsw, PASSWORD_DEFAULT));
|
|
$user->savePass();
|
|
} else {
|
|
err('Неверный текущий пароль!');
|
|
}
|
|
}
|
|
Template::header('Анкета');
|
|
?>
|
|
<a href="main.php">← на главную</a>
|
|
<h1>Анкета персонажа <?= $user->getLogin() ?></h1>
|
|
<form method="post">
|
|
<label>
|
|
<input name="name" placeholder="Реальное имя" value="<?= $user->getRealname() ?>">
|
|
Реальное имя
|
|
</label><br>
|
|
<textarea name="hobbie" placeholder="Хобби"><?= $user->getInfo() ?></textarea><br>
|
|
<input name="submit" type="submit">
|
|
</form>
|
|
<h1>Безопасность</h1>
|
|
<form method="post">
|
|
<input placeholder="Старый пароль" name="oldpsw">
|
|
<input placeholder="Новый пароль" name="newpsw">
|
|
<input type="submit">
|
|
</form>
|