+19
-30
@@ -4,50 +4,39 @@ use Battles\Template;
|
||||
use Battles\User;
|
||||
|
||||
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::getInstance()->setRealname($name);
|
||||
}
|
||||
if ($hobbie) {
|
||||
User::getInstance()->setInfo($hobbie);
|
||||
}
|
||||
User::getInstance()->saveUser();
|
||||
}
|
||||
if (isset($_POST['name'])) {
|
||||
User::getInstance()->profile()->setRealname($_POST['name']);
|
||||
}
|
||||
if ($oldpsw && $newpsw) {
|
||||
if (password_verify($oldpsw, User::getInstance()->getPass())) {
|
||||
User::getInstance()->setPass(password_hash($newpsw, PASSWORD_DEFAULT));
|
||||
User::getInstance()->saveUser();
|
||||
} else {
|
||||
err('Неверный текущий пароль!');
|
||||
}
|
||||
if (isset($_POST['hobbie'])) {
|
||||
User::getInstance()->profile()->setInfo($_POST['hobbie']);
|
||||
}
|
||||
|
||||
if (isset($_POST['oldpsw']) && isset($_POST['newpsw'])) {
|
||||
User::getInstance()->profile()->changePassword($_POST['oldpsw'], $_POST['newpsw']);
|
||||
}
|
||||
|
||||
if (!empty($_POST)) {
|
||||
echo User::getInstance()->profile()->save();
|
||||
}
|
||||
|
||||
Template::header('Анкета');
|
||||
?>
|
||||
<a href="main.php">← на главную</a>
|
||||
<h1>Анкета персонажа <?= User::getInstance()->getLogin() ?></h1>
|
||||
<form method="post">
|
||||
<label>
|
||||
<input name="name" placeholder="Реальное имя" value="<?= User::getInstance()->getRealname() ?>">
|
||||
<input name="name" placeholder="Реальное имя" value="<?= User::getInstance()->profile()->getRealname() ?>">
|
||||
Реальное имя
|
||||
</label><br>
|
||||
<textarea name="hobbie" placeholder="Хобби"><?= User::getInstance()->getInfo() ?></textarea><br>
|
||||
<label>
|
||||
<textarea name="hobbie" placeholder="Хобби"><?= User::getInstance()->profile()->getInfo() ?></textarea>
|
||||
</label><br>
|
||||
<input name="submit" type="submit">
|
||||
</form>
|
||||
<h1>Безопасность</h1>
|
||||
<form method="post">
|
||||
<input placeholder="Старый пароль" name="oldpsw">
|
||||
<input placeholder="Новый пароль" name="newpsw">
|
||||
<label><input placeholder="Старый пароль" name="oldpsw"></label>
|
||||
<label><input placeholder="Новый пароль" name="newpsw"></label>
|
||||
<input type="submit">
|
||||
</form>
|
||||
Reference in New Issue
Block a user