2018-03-01 18:43:46 +00:00
|
|
|
<?php
|
2018-01-28 16:40:49 +00:00
|
|
|
session_start();
|
2018-03-01 18:43:46 +00:00
|
|
|
if (!isset($_SESSION['uid'])) {
|
|
|
|
header('Location: /index.php');
|
|
|
|
die();
|
|
|
|
}
|
2018-01-28 16:40:49 +00:00
|
|
|
include('config.php');
|
|
|
|
include('functions.php');
|
|
|
|
|
2018-03-01 18:43:46 +00:00
|
|
|
if ($user['battle'] > 0) {
|
|
|
|
header('Location: /fbattle.php');
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($_POST['submit']) {
|
|
|
|
$name = filter_input(INPUT_POST, $_POST['name']);
|
|
|
|
$color = filter_input(INPUT_POST, $_POST['color']);
|
|
|
|
// $name = htmlspecialchars($_POST['name'], NULL, 'cp1251');
|
|
|
|
// $color = htmlspecialchars($_POST['color'], NULL, 'cp1251');
|
|
|
|
$hobbie = str_replace("\\n", "<br />", $_POST['hobbie']);
|
|
|
|
$hobbie = str_replace("\\r", "", $_POST['hobbie']);
|
|
|
|
$hobbie = str_replace("<br />", "<br />", $_POST['hobbie']);
|
2018-01-28 16:40:49 +00:00
|
|
|
|
|
|
|
|
2018-03-01 18:43:46 +00:00
|
|
|
$simbolcount = strlen($hobbie);
|
|
|
|
switch ($color) {
|
|
|
|
case 1: $newcolor = 'blue'; break;
|
|
|
|
case 2: $newcolor = 'green'; break;
|
|
|
|
default: $newcolor = 'black'; break;
|
|
|
|
}
|
2018-01-28 16:40:49 +00:00
|
|
|
|
2018-03-01 18:43:46 +00:00
|
|
|
if (isset($color) && !($color == "black" || $color == "blue" || $color == "green")) {
|
|
|
|
$error = "Возможно использовать цвета указанные только в меню анкеты!";
|
|
|
|
$color = "Black";
|
|
|
|
} elseif ($simbolcount > 1500) {
|
|
|
|
$error = "Максимальная длинна поля Хобби: 1500 символов ...";
|
|
|
|
} else {
|
|
|
|
db::c()->query('UPDATE `users` SET `realname` = "?s", `color` = "?s", `info` = "?s" WHERE `id` = ?i', $name, $color, $hobbie, $user['id']);
|
2018-01-28 16:40:49 +00:00
|
|
|
|
2018-03-01 18:43:46 +00:00
|
|
|
$user['realname'] = $name;
|
|
|
|
$user['color'] = $color;
|
|
|
|
$user['info'] = $hobbie;
|
|
|
|
$error = 'Изменения вступили в силу ...';
|
|
|
|
}
|
2018-01-28 16:40:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
2018-03-01 18:43:46 +00:00
|
|
|
<!doctype html>
|
2018-01-28 16:40:49 +00:00
|
|
|
<html>
|
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>
|
|
|
|
<h1>Анкета персонажа <?= $user['login'] ?></h1>
|
|
|
|
<form method="post" action="user_anketa.php">
|
|
|
|
<input name="name" placeholder="Реальное имя" value="<?= $user['realname']; ?>"><br>
|
|
|
|
<select name="color" id="color">
|
|
|
|
<option value="0" selected>Чёрный</option>
|
|
|
|
<option value="1">Синий</option>
|
|
|
|
<option value="2">Зелёный</option>
|
|
|
|
</select><label for="color"></label>
|
|
|
|
<textarea name="hobby" placeholder="Хобби"><?= $user['info'] ?></textarea>
|
|
|
|
<input name="submit" type="submit">
|
|
|
|
</form>
|
|
|
|
<div id="hint4"></div>
|
|
|
|
<?php if (!empty($error)) err($error); ?>
|
|
|
|
</body>
|
2018-01-28 16:40:49 +00:00
|
|
|
</html>
|