2018-03-01 18:43:46 +00:00
|
|
|
<?php
|
2018-01-28 16:40:49 +00:00
|
|
|
session_start();
|
2020-08-30 00:55:53 +00:00
|
|
|
if (empty($_SESSION['uid'])) {
|
2018-03-01 18:43:46 +00:00
|
|
|
header('Location: /index.php');
|
2020-08-30 00:55:53 +00:00
|
|
|
exit();
|
2018-03-01 18:43:46 +00:00
|
|
|
}
|
2018-03-01 20:26:45 +00:00
|
|
|
include_once('functions.php');
|
2018-03-01 19:14:51 +00:00
|
|
|
|
2020-08-30 00:55:53 +00:00
|
|
|
if ($user->battle) {
|
2018-03-01 18:43:46 +00:00
|
|
|
header('Location: /fbattle.php');
|
2020-08-30 00:55:53 +00:00
|
|
|
exit();
|
2018-03-01 18:43:46 +00:00
|
|
|
}
|
2020-08-30 00:55:53 +00:00
|
|
|
|
2020-07-03 15:39:46 +00:00
|
|
|
use Krugozor\Database\Mysql\Mysql as Mysql;
|
|
|
|
$db = Mysql::create("192.168.20.100", "battles", "bottle-neck-horse")
|
|
|
|
->setDatabaseName("battles")
|
|
|
|
->setCharset("utf8");
|
2018-03-01 18:43:46 +00:00
|
|
|
|
2020-08-30 00:55:53 +00:00
|
|
|
define('INFO_CHAR_LIMIT', 1500);
|
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);
|
|
|
|
$color = filter_input(INPUT_POST, 'color', FILTER_VALIDATE_INT);
|
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
|
|
|
|
2018-03-01 20:26:45 +00:00
|
|
|
if ($name || $color || $hobbie) {
|
2018-01-28 16:40:49 +00:00
|
|
|
|
2018-03-01 18:43:46 +00:00
|
|
|
$simbolcount = strlen($hobbie);
|
2018-03-01 19:14:51 +00:00
|
|
|
|
2018-03-01 18:43:46 +00:00
|
|
|
switch ($color) {
|
2020-08-30 00:55:53 +00:00
|
|
|
case 1:
|
|
|
|
$color = 'blue';
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
$color = 'green';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$color = 'black';
|
|
|
|
break;
|
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 ($simbolcount > INFO_CHAR_LIMIT) {
|
|
|
|
err('Максимальная длинна поля Хобби: ' . INFO_CHAR_LIMIT . ' символов!');
|
2018-03-01 18:43:46 +00:00
|
|
|
} else {
|
2020-08-30 00:55:53 +00:00
|
|
|
$values = ['realname' => $name, 'color' => $color, 'info' => $hobbie];
|
2020-07-03 15:39:46 +00:00
|
|
|
$db->query('UPDATE users SET ?As WHERE id = ?i', $values, $user['id']);
|
2018-03-01 18:43:46 +00:00
|
|
|
}
|
2018-01-28 16:40:49 +00:00
|
|
|
}
|
2018-03-02 15:31:43 +00:00
|
|
|
|
2020-08-30 00:55:53 +00:00
|
|
|
if ($oldpsw && $newpsw) {
|
|
|
|
if (password_verify($oldpsw, $user['pass'])) {
|
|
|
|
db::c()->query('UPDATE `users` SET `pass` = "?s" WHERE `id` = ?i', password_hash($newpsw, PASSWORD_DEFAULT), $user['id']);
|
|
|
|
} else {
|
|
|
|
err('Неверный текущий пароль!');
|
|
|
|
}
|
2018-03-02 15:31:43 +00:00
|
|
|
}
|
2018-01-28 16:40:49 +00:00
|
|
|
?>
|
2018-03-01 18:43:46 +00:00
|
|
|
<!doctype html>
|
2020-08-30 00:55:53 +00:00
|
|
|
<html lang="ru">
|
2018-03-01 18:43:46 +00:00
|
|
|
<head>
|
|
|
|
<meta charset="utf-8"/>
|
|
|
|
<link rel="stylesheet" href="css/main.css">
|
|
|
|
<title>Анкета</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a href="main.php">← на главную</a>
|
2018-03-03 20:59:09 +00:00
|
|
|
<h1>Анкета персонажа <?= $user['login'] ?></h1>
|
2018-03-01 18:43:46 +00:00
|
|
|
<form method="post" action="user_anketa.php">
|
2018-03-03 20:59:09 +00:00
|
|
|
<input name="name" placeholder="Реальное имя" value="<?= $user['realname']; ?>"><br>
|
2018-03-01 18:43:46 +00:00
|
|
|
<select name="color" id="color">
|
|
|
|
<option value="0" selected>Чёрный</option>
|
|
|
|
<option value="1">Синий</option>
|
|
|
|
<option value="2">Зелёный</option>
|
2018-03-01 19:14:51 +00:00
|
|
|
</select><label for="color"></label><br>
|
2018-03-03 20:59:09 +00:00
|
|
|
<textarea name="hobbie" placeholder="Хобби"><?= $user['info'] ?></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>
|
|
|
|
<form method="post" action="user_anketa.php">
|
|
|
|
<input placeholder="Старый пароль" name="oldpsw">
|
|
|
|
<input placeholder="Новый пароль" name="newpsw">
|
|
|
|
<input type="submit">
|
|
|
|
</form>
|
2018-03-01 18:43:46 +00:00
|
|
|
</body>
|
2018-01-28 16:40:49 +00:00
|
|
|
</html>
|