2018-03-01 18:43:46 +00:00
|
|
|
|
<?php
|
2018-01-28 16:40:49 +00:00
|
|
|
|
session_start();
|
2020-09-29 22:39:06 +00:00
|
|
|
|
$hreject = $_COOKIE[GAMEDOMAIN] ?? null;
|
2018-01-28 16:40:49 +00:00
|
|
|
|
if ($hreject) {
|
|
|
|
|
$error = "Не больше одной регистрации в час!";
|
|
|
|
|
} else {
|
2020-09-29 22:39:06 +00:00
|
|
|
|
require_once "config.php";
|
|
|
|
|
$login = $_POST['login'] ?? '';
|
|
|
|
|
$password = password_hash($_POST['psw'], PASSWORD_DEFAULT) ?? null;
|
|
|
|
|
$birthday = $_POST['birthday'] ?? null;
|
2018-01-28 16:40:49 +00:00
|
|
|
|
$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
|
|
|
|
|
$law = filter_input(INPUT_POST, 'law', FILTER_VALIDATE_BOOLEAN);
|
|
|
|
|
$law2 = filter_input(INPUT_POST, 'law2', FILTER_VALIDATE_BOOLEAN);
|
|
|
|
|
$ip = filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP);
|
|
|
|
|
|
|
|
|
|
if ($login && $password && $email && $birthday && $law && $law2) {
|
|
|
|
|
$check = db::c()->query('SELECT 1 FROM `users` WHERE `login` = "?s" OR `email` = "?s"', $login, $email)->getNumRows();
|
|
|
|
|
if ($check > 0) {
|
|
|
|
|
$error = "В системе уже есть такие данные!";
|
|
|
|
|
} else {
|
2018-02-27 02:58:48 +00:00
|
|
|
|
db::c()->query('INSERT INTO `users` (`login`,`pass`,`email`,`borndate`,`ip`,`sid`)
|
|
|
|
|
VALUES ("?s", "?s", "?s", "?s", "?s", "?s")', $login, $password, $email, $birthday, $ip, session_id());
|
2018-01-28 16:40:49 +00:00
|
|
|
|
$nid = db::c()->getLastInsertId();
|
2020-06-23 05:49:36 +00:00
|
|
|
|
db::c()->query('INSERT INTO `online` (`user_id`, `date`, `room`) VALUES (?i, ?i, ?i)', $nid, time(), 1);
|
|
|
|
|
db::c()->query('INSERT INTO `bank` (`user_id`) VALUES (?i)', $nid, 5);
|
2018-01-28 16:40:49 +00:00
|
|
|
|
setcookie(GAMEDOMAIN, $nid, time() + 3600);
|
|
|
|
|
setcookie("battle", time());
|
|
|
|
|
$_SESSION['uid'] = $nid;
|
|
|
|
|
$_SESSION['sid'] = session_id();
|
|
|
|
|
header('Location: fight.php');
|
|
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
<!DOCTYPE html>
|
2020-06-23 05:49:36 +00:00
|
|
|
|
<html lang="ru">
|
2018-01-28 16:40:49 +00:00
|
|
|
|
<head>
|
|
|
|
|
<meta charset="utf-8">
|
|
|
|
|
<link href="css/main.css" rel="stylesheet"/>
|
|
|
|
|
<title>Регистрация персонажа</title>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<a href="/"> ← на главную</a>
|
|
|
|
|
<?php if (!empty($error)): ?>
|
|
|
|
|
<h1><?php echo $error; ?></h1>
|
|
|
|
|
<?php else: ?>
|
|
|
|
|
<h1>Регистрация</h1>
|
2018-12-10 16:15:11 +00:00
|
|
|
|
<form method="post">
|
2018-01-28 16:40:49 +00:00
|
|
|
|
<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>
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|