Фикс анкеты персонажа.
This commit is contained in:
parent
7d7a83a8a0
commit
61b0ca565b
28
classes/u.php
Normal file
28
classes/u.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2018.
|
||||
* Author: Igor Barkov <lopar.4ever@gmail.com>
|
||||
* Project name: Battles-Game
|
||||
*/
|
||||
|
||||
class u
|
||||
{
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* u constructor.
|
||||
* @param $playerId
|
||||
*/
|
||||
public function __construct($playerId)
|
||||
{
|
||||
$this->id = $playerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function i()
|
||||
{
|
||||
return db::c()->query('SELECT * FROM `users` WHERE `id` = ?i',$this->id)->fetch_assoc();
|
||||
}
|
||||
}
|
@ -6,6 +6,8 @@
|
||||
*/
|
||||
|
||||
require_once 'config.php';
|
||||
require_once 'classes/u.php';
|
||||
|
||||
define("HPADDICTIONEFFECT", 33);
|
||||
|
||||
$ip = filter_input(INPUT_SERVER,'REMOTE_ADDR', FILTER_VALIDATE_IP);
|
||||
|
@ -7,11 +7,14 @@ if (!isset($_SESSION['uid'])) {
|
||||
include('config.php');
|
||||
include('functions.php');
|
||||
|
||||
if ($user['battle'] > 0) {
|
||||
$u = new u($_SESSION['uid']);
|
||||
|
||||
if ($u->i()['battle'] > 0) {
|
||||
header('Location: /fbattle.php');
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
if ($_POST['submit']) {
|
||||
$name = filter_input(INPUT_POST, $_POST['name']);
|
||||
$color = filter_input(INPUT_POST, $_POST['color']);
|
||||
@ -21,26 +24,18 @@ if ($_POST['submit']) {
|
||||
$hobbie = str_replace("\\r", "", $_POST['hobbie']);
|
||||
$hobbie = str_replace("<br />", "<br />", $_POST['hobbie']);
|
||||
|
||||
|
||||
$simbolcount = strlen($hobbie);
|
||||
|
||||
switch ($color) {
|
||||
case 1: $newcolor = 'blue'; break;
|
||||
case 2: $newcolor = 'green'; break;
|
||||
default: $newcolor = 'black'; break;
|
||||
case 1: $color = 'blue'; break;
|
||||
case 2: $color = 'green'; break;
|
||||
default: $color = 'black'; break;
|
||||
}
|
||||
|
||||
if (isset($color) && !($color == "black" || $color == "blue" || $color == "green")) {
|
||||
$error = "Возможно использовать цвета указанные только в меню анкеты!";
|
||||
$color = "Black";
|
||||
} elseif ($simbolcount > 1500) {
|
||||
$error = "Максимальная длинна поля Хобби: 1500 символов ...";
|
||||
if ($simbolcount > 1500) {
|
||||
err('Максимальная длинна поля Хобби: 1500 символов!');
|
||||
} else {
|
||||
db::c()->query('UPDATE `users` SET `realname` = "?s", `color` = "?s", `info` = "?s" WHERE `id` = ?i', $name, $color, $hobbie, $user['id']);
|
||||
|
||||
$user['realname'] = $name;
|
||||
$user['color'] = $color;
|
||||
$user['info'] = $hobbie;
|
||||
$error = 'Изменения вступили в силу ...';
|
||||
db::c()->query('UPDATE `users` SET `realname` = "?s", `color` = "?s", `info` = "?s" WHERE `id` = ?i', $name, $color, $hobbie, $u->i()['id']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,18 +50,16 @@ if ($_POST['submit']) {
|
||||
</head>
|
||||
<body>
|
||||
<a href="main.php">← на главную</a>
|
||||
<h1>Анкета персонажа <?= $user['login'] ?></h1>
|
||||
<h1>Анкета персонажа <?= $u->i()['login'] ?></h1>
|
||||
<form method="post" action="user_anketa.php">
|
||||
<input name="name" placeholder="Реальное имя" value="<?= $user['realname']; ?>"><br>
|
||||
<input name="name" placeholder="Реальное имя" value="<?= $u->i()['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>
|
||||
</select><label for="color"></label><br>
|
||||
<textarea name="hobbie" placeholder="Хобби"><?= $u->i()['info'] ?></textarea><br>
|
||||
<input name="submit" type="submit">
|
||||
</form>
|
||||
<div id="hint4"></div>
|
||||
<?php if (!empty($error)) err($error); ?>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user