fix-register #12
@ -39,7 +39,7 @@ if ($username && $password) {
|
||||
if (isset($onl['user_id'])) {
|
||||
db::c()->query('UPDATE online SET date = ?i WHERE user_id = "?s"', time(), $user_query['id']);
|
||||
} else {
|
||||
db::c()->query('INSERT INTO online (user_id, date, room) VALUES (?i, ?i, ?i)', $user_query['id'], time(), $user_query['room']);
|
||||
db::c()->query('INSERT INTO online (user_id, date, room, real_time) VALUES (?i, ?i, ?i, ?i)', $user_query['id'], time(), $user_query['room'], time());
|
||||
}
|
||||
|
||||
db::c()->query('UPDATE `users` SET `session_id` = "?s", `enter_game` = ?i WHERE `id` = ?i', session_id(), 1, $user_query['id']);
|
||||
|
44
register.php
44
register.php
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
session_start();
|
||||
$hreject = $_COOKIE[GAMEDOMAIN] ?? null;
|
||||
if ($hreject) {
|
||||
require_once "config.php";
|
||||
if ($_COOKIE[GAMEDOMAIN] ?? null) {
|
||||
$error = "Не больше одной регистрации в час!";
|
||||
} else {
|
||||
require_once "config.php";
|
||||
$login = $_POST['login'] ?? '';
|
||||
$password = password_hash($_POST['psw'], PASSWORD_DEFAULT) ?? null;
|
||||
$login = $_POST['login'] ?? null;
|
||||
if ($_POST['psw'] ?? null) {
|
||||
$password = password_hash($_POST['psw'], PASSWORD_DEFAULT);
|
||||
}
|
||||
$birthday = $_POST['birthday'] ?? null;
|
||||
$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
|
||||
$law = filter_input(INPUT_POST, 'law', FILTER_VALIDATE_BOOLEAN);
|
||||
@ -18,10 +19,10 @@ if ($hreject) {
|
||||
if ($check > 0) {
|
||||
$error = "В системе уже есть такие данные!";
|
||||
} else {
|
||||
db::c()->query('INSERT INTO `users` (`login`,`pass`,`email`,`borndate`,`ip`,`sid`)
|
||||
db::c()->query('INSERT INTO users (login,pass,email,borndate,ip,session_id)
|
||||
VALUES ("?s", "?s", "?s", "?s", "?s", "?s")', $login, $password, $email, $birthday, $ip, session_id());
|
||||
$nid = db::c()->getLastInsertId();
|
||||
db::c()->query('INSERT INTO `online` (`user_id`, `date`, `room`) VALUES (?i, ?i, ?i)', $nid, time(), 1);
|
||||
db::c()->query('INSERT INTO `online` (user_id, date, room, real_time) VALUES (?i, ?i, ?i, ?i)', $nid, time(), 1, time());
|
||||
db::c()->query('INSERT INTO `bank` (`user_id`) VALUES (?i)', $nid, 5);
|
||||
setcookie(GAMEDOMAIN, $nid, time() + 3600);
|
||||
setcookie("battle", time());
|
||||
@ -34,19 +35,20 @@ if ($hreject) {
|
||||
}
|
||||
Template::header('Регистрация персонажа');
|
||||
?>
|
||||
<a href="/"> ← на главную</a>
|
||||
<?php if (!empty($error)): ?>
|
||||
<h1><?php echo $error; ?></h1>
|
||||
<a href="/"> ← на главную</a>
|
||||
<?php if ($error ?? null): ?>
|
||||
<h1><?= $error ?></h1>
|
||||
<?php else: ?>
|
||||
<h1>Регистрация</h1>
|
||||
<form method="post">
|
||||
<input required name="login" placeholder='Имя персонажа'><br>
|
||||
<input required name="email" type=email placeholder='Электронная почта'><br>
|
||||
<input required name="psw" type=text placeholder='Пароль'><br>
|
||||
<label for="bday">Дата рождения:</label><br>
|
||||
<input required id="bday" name="birthday" type='date' min=1960-01-01 max=2010-01-01><br>
|
||||
<input required id="law" name="law" type=checkbox> <label for="law">Это мой единственный персонаж!</label><br>
|
||||
<input required id="law2" name="law2" type=checkbox> <label for="law2">Я согласен на <a href='#'>любые условия</a>, давайте играть!</label><br>
|
||||
<input type=submit value=Зарегистрироваться>
|
||||
</form>
|
||||
<h1>Регистрация</h1>
|
||||
<form method="post">
|
||||
<input required name="login" placeholder='Имя персонажа'><br>
|
||||
<input required name="email" type=email placeholder='Электронная почта'><br>
|
||||
<input required name="psw" type=text placeholder='Пароль'><br>
|
||||
<label for="bday">Дата рождения:</label><br>
|
||||
<input required id="bday" name="birthday" type='date' min=1970-01-01 max=2010-01-01><br>
|
||||
<input required id="law" name="law" type=checkbox> <label for="law">Это мой единственный персонаж!</label><br>
|
||||
<input required id="law2" name="law2" type=checkbox> <label for="law2">Я согласен на <a href='#'>любые
|
||||
условия</a>, давайте играть!</label><br>
|
||||
<input type=submit value=Зарегистрироваться>
|
||||
</form>
|
||||
<?php endif; ?>
|
@ -10,11 +10,6 @@ if ($user->battle) {
|
||||
exit();
|
||||
}
|
||||
|
||||
use Krugozor\Database\Mysql\Mysql as Mysql;
|
||||
$db = Mysql::create("192.168.20.100", "battles", "bottle-neck-horse")
|
||||
->setDatabaseName("battles")
|
||||
->setCharset("utf8");
|
||||
|
||||
define('INFO_CHAR_LIMIT', 1500);
|
||||
$name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING);
|
||||
$oldpsw = filter_input(INPUT_POST, 'oldpsw', FILTER_SANITIZE_SPECIAL_CHARS);
|
||||
@ -42,7 +37,7 @@ if ($name || $color || $hobbie) {
|
||||
err('Максимальная длинна поля Хобби: ' . INFO_CHAR_LIMIT . ' символов!');
|
||||
} else {
|
||||
$values = ['realname' => $name, 'color' => $color, 'info' => $hobbie];
|
||||
$db->query('UPDATE users SET ?As WHERE id = ?i', $values, $user->id);
|
||||
db::c()->query('UPDATE users SET ?As WHERE id = ?i', $values, $user->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user