game/register.php

466 lines
15 KiB
PHP
Raw Normal View History

2022-12-19 18:26:14 +00:00
<?php
2023-01-10 16:29:32 +00:00
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
if (isset($_GET['unset'])) {
session_unset();
}
2022-12-30 19:03:37 +00:00
if (!defined('GAME_VERSION')) {
require_once '_incl_data/autoload.php';
}
2022-12-19 18:26:14 +00:00
2023-01-10 16:29:32 +00:00
use Core\{Config, Database, Db};
use User\Confirmation;
2022-12-30 19:03:37 +00:00
Config::init();
Database::init();
2023-01-10 16:29:32 +00:00
$newUser = new UserRegister();
2022-12-19 18:26:14 +00:00
2023-01-10 16:29:32 +00:00
if (empty($_SESSION['step'])) {
$_SESSION['step'] = 1;
}
2022-06-06 21:30:34 +00:00
2023-01-10 16:29:32 +00:00
$_SESSION['ref'] = Db::getValue('select count(*) from users where id = ?', [$_REQUEST['ref']]) ?? 0;
2022-06-06 21:30:34 +00:00
2023-01-10 16:29:32 +00:00
if (
!empty($_POST['nick_u']) &&
$newUser->hasGoodLogin($_POST['nick_u'])
) {
$_SESSION['step'] = 2;
$_SESSION['login'] = $_POST['nick_u'];
2022-06-06 21:30:34 +00:00
}
2023-01-10 16:29:32 +00:00
if (
$_SESSION['step'] === 2 &&
!empty($_POST['email_u']) &&
$newUser->hasGoodEmail($_POST['email_u'])
) {
$_SESSION['step'] = 3;
$_SESSION['email'] = $_POST['email_u'];
Confirmation::userRegistrationCodeByEmail($_SESSION['email'], $_SESSION['login']);
}
2023-01-10 16:29:32 +00:00
if (
$_SESSION['step'] === 3 &&
!empty($_POST['secure_code']) &&
$newUser->hasGoodEmailCode($_SESSION['email'], $_POST['secure_code'])
) {
$_SESSION['step'] = 4;
}
2023-01-10 16:29:32 +00:00
if (
$_SESSION['step'] === 4 &&
!empty($_POST['pass1_u']) &&
!empty($_POST['pass2_u']) &&
$newUser->hasGoodPassword($_POST['pass1_u'], $_POST['pass2_u'])
) {
$_SESSION['step'] = 5;
$_SESSION['password'] = $_POST['pass1_u'];
}
2023-01-10 16:29:32 +00:00
if (
$_SESSION['step'] === 5 &&
in_array((int)$_POST['pol_u'], [10, 11])
) {
$_SESSION['step'] = 6;
$_SESSION['sex'] = (int)$_POST['pol_u'];
}
2023-01-10 16:29:32 +00:00
if (
$_SESSION['step'] === 6 &&
!empty($_POST['bday_u'])
) {
$_SESSION['step'] = 7;
$_SESSION['birthday'] = $_POST['bday_u'];
}
2023-01-10 16:29:32 +00:00
if (
$_SESSION['step'] === 7 &&
in_array((int)$_POST['class_u'], range(1, 9))
) {
$_SESSION['step'] = 8;
$_SESSION['class'] = (int)$_POST['class_u'];
}
2023-01-10 16:29:32 +00:00
if ($_SESSION['step'] === 8) { // Всех их соберём, вместе соберём. Покемон! Кхм..
//Создаем персонажа
2023-01-10 16:29:32 +00:00
$uid = $newUser->new(
2023-01-10 18:13:19 +00:00
$_SESSION['login'],
$_SESSION['password'],
$_SESSION['email'],
2023-01-10 16:29:32 +00:00
$_SESSION['ref'],
$_SESSION['birthday'],
$_SESSION['sex'],
$_SESSION['class']
);
2023-01-10 16:29:32 +00:00
if ($uid > 0) {
2023-01-10 16:29:32 +00:00
//мульты
$ppl = Db::getRows('select * from logs_auth where ip = ? or ip = ?', [UserIp::get(), $_COOKIE['ip']]);
2023-01-10 16:29:32 +00:00
foreach ($ppl as $spl) {
$ml = Db::getValue(
'select id from mults where (uid = ? and uid2 = ?) or (uid = ? and uid2 = ?)',
[$spl['uid'], $uid, $uid, $spl['uid']]
);
2023-01-10 16:29:32 +00:00
if (!$ml) {
Db::sql('insert into mults (uid, uid2, ip) values (?,?,?)', [$uid, $spl['uid'], $spl['ip']]);
}
}
2023-01-10 16:29:32 +00:00
Db::sql(
'insert into logs_auth (uid, ip, browser, type, time) values (?,?,?,1,unix_timestamp())',
[$uid, UserIp::get(), $_SERVER['HTTP_USER_AGENT']]
);
2023-01-10 16:29:32 +00:00
//Обновяем таблицы
Db::sql('update users set ip = ? where id = ?', [UserIp::get(), $uid]);
Db::sql('insert into users_learning_status (uid) values (?)', [$uid]);
session_unset();
2023-01-10 16:29:32 +00:00
header('Refresh: 1; url=/bk');
die('Спасибо за регистрацию в игровом мире Бойцовского Клуба, желаем вам побед и долгой игры.
В случае вопросов по игре, Вам будет доступен общий чат!'
);
}
header('Location: /');
}
2023-01-10 16:29:32 +00:00
$errorMessage = $newUser->getError() ? "<h4>{$newUser->getError()}</h4>" : '';
2023-01-10 16:29:32 +00:00
?>
2023-01-10 16:29:32 +00:00
<!DOCTYPE html>
<head>
2023-01-10 16:29:32 +00:00
<title><?= Config::get('name') ?>: Регистрация - создай персонажа в игре.</title>
<meta name="description" content="<?= Config::get('desc') ?>"/>
</head>
<style>
body {
/* Путь к фоновому рисунку */
/* Положение фона */
/* Отменяем повторение фона */
background: #000 url(/werhr.jpg) no-repeat center center fixed;
}
2023-01-10 16:29:32 +00:00
.visible_class {
background-image: url(script.png); /* Путь к фоновому рисунку */
background-size: 100% 100%;
position: absolute;
top: 45%;
left: 50%;
margin: 0 -50% 0 0;
#min-width: 600px;
min-height: 200px;
transform: translate(-50%, -50%);
text-align: center;
}
2023-01-10 16:29:32 +00:00
.visible_class input {
background: none repeat scroll 0 0 #720300;
border-color: #720300 #327CB5 #327CB5 #720300;
border-radius: 10px 10px 10px 10px;
border-style: solid;
border-width: 1px;
box-shadow: 1px 1px 3px #333333;
color: #FFFFFF;
cursor: pointer;
font-weight: bold;
padding: 5px;
text-shadow: 1px 1px 1px #000000;
display: block;
margin-right: auto;
margin-left: auto;
}
2023-01-10 16:29:32 +00:00
.visible_class select {
background: none repeat scroll 0 0 #720300;
border-color: #720300 #327CB5 #327CB5 #720300;
border-radius: 10px 10px 10px 10px;
border-style: solid;
border-width: 1px;
box-shadow: 1px 1px 3px #333333;
color: #FFFFFF;
cursor: pointer;
font-weight: bold;
padding: 5px;
text-shadow: 1px 1px 1px #000000;
display: block;
margin-right: auto;
margin-left: auto;
overflow-x: hidden;
overflow-y: hidden;
}
2023-01-10 16:29:32 +00:00
.visible_class h3 {
text-align: center;
text-shadow: #000 0 0 10px; /* Свечение голубого цвета */
color: #FFF;
margin-top: 20px;
margin-left: 50px;
margin-right: 50px;
}
2022-12-19 18:26:14 +00:00
2023-01-10 16:29:32 +00:00
.visible_class h4 {
2022-12-30 19:03:37 +00:00
2023-01-10 16:29:32 +00:00
text-align: center;
text-shadow: #000 0 0 10px;
color: #ffc6c6;
margin-bottom: 50px;
margin-left: 50px;
margin-right: 50px;
#-webkit-text-stroke: 1px red;
2023-01-10 16:29:32 +00:00
}
2023-01-10 16:29:32 +00:00
.visible_class input[type=radio] {
text-align: center;
text-shadow: #000 0 0 10px;
color: red;
#-webkit-text-stroke: 1px red;
2023-01-10 16:29:32 +00:00
}
2023-01-10 16:29:32 +00:00
.visible_class a:visited {
color: red;
}
2022-12-30 19:03:37 +00:00
2023-01-10 16:29:32 +00:00
.visible_class_s input[type=submit] {
margin: 20px 0;
padding: 0 10px;
background: #a50000;
color: #ffffff;
font-size: 22px;
text-transform: uppercase;
border-width: 0;
border-radius: 5px;
cursor: pointer;
transition: .2s linear
}
2023-01-10 16:29:32 +00:00
.visible_class_s input[type=submit]:hover {
background: #C44D58;
}
2022-12-30 19:03:37 +00:00
2023-01-10 16:29:32 +00:00
.visible_class_s {
position: absolute;
top: 80%;
left: 50%;
margin: 0 -50% 0 0;
transform: translate(-50%, -50%)
}
2022-12-30 19:03:37 +00:00
2023-01-10 16:29:32 +00:00
.form_radio_btn {
display: inline-block;
margin-right: 10px;
}
2023-01-06 19:26:10 +00:00
2023-01-10 16:29:32 +00:00
.form_radio_btn input[type=radio] {
display: none;
}
2022-12-30 19:03:37 +00:00
2023-01-10 16:29:32 +00:00
.form_radio_btn label {
display: inline-block;
cursor: pointer;
padding: 0 15px;
line-height: 34px;
border: 1px solid #EEE;
color: #EEE;
border-radius: 6px;
user-select: none;
}
2022-12-30 19:03:37 +00:00
2023-01-10 16:29:32 +00:00
/* Checked */
.form_radio_btn input[type=radio]:checked + label {
background: #790000;
color: white;
}
2022-12-19 18:26:14 +00:00
2023-01-10 16:29:32 +00:00
/* Hover */
.form_radio_btn label:hover {
color: #FFF;
}
2022-06-06 21:30:34 +00:00
2023-01-10 16:29:32 +00:00
/* Disabled */
.form_radio_btn input[type=radio]:disabled + label {
background: #efefef;
color: #666;
}
2022-12-30 19:03:37 +00:00
2023-01-10 16:29:32 +00:00
.box {
background: linear-gradient(to right, gold, darkorange);
color: white;
--width: 250px;
--height: calc(var(--width) / 3);
width: var(--width);
height: var(--height);
text-align: center;
line-height: var(--height);
font-size: calc(var(--height) / 2.5);
font-family: sans-serif;
letter-spacing: 0.2em;
border: 1px solid darkgoldenrod;
border-radius: 2em;
transform: perspective(500px) rotateY(-15deg);
text-shadow: 6px 3px 2px rgba(0, 0, 0, 0.2);
box-shadow: 2px 0 0 5px rgba(0, 0, 0, 0.2);
transition: 0.5s;
position: relative;
overflow: hidden;
}
2023-01-10 16:29:32 +00:00
.box:hover {
transform: perspective(500px) rotateY(15deg);
text-shadow: -6px 3px 2px rgba(0, 0, 0, 0.2);
box-shadow: -2px 0 0 5px rgba(0, 0, 0, 0.2);
}
2022-12-30 19:03:37 +00:00
2023-01-10 16:29:32 +00:00
.box::before {
content: '';
position: absolute;
width: 100%;
height: 100%;
background: linear-gradient(to right, transparent, white, transparent);
left: -100%;
transition: 0.5s;
}
2023-01-10 16:29:32 +00:00
.box:hover::before {
left: 100%;
}
2023-01-06 19:26:10 +00:00
2023-01-10 16:29:32 +00:00
label > span {
color: wheat;
font-weight: bold;
text-shadow: black 0 0 10px;
display: block;
margin: 20px;
font-family: Verdana, serif;
}
2023-01-10 16:29:32 +00:00
</style>
<form action="register.php" method="post">
<?php if ($_SESSION['step'] === 1): ?>
<div class="visible_class">
<label>
<span>Придумайте имя персонажа</span>
<input type="text" name="nick_u" placeholder="Имя"/>
</label>
<?= $errorMessage ?>
</div>
<?php elseif ($_SESSION['step'] === 2): ?>
<div class="visible_class">
<label>
<span>Предъявите электронную почту</span>
<input type="text" name="email_u" placeholder="Введите ваш email"/>
</label>
<?= $errorMessage ?>
</div>
<?php elseif ($_SESSION['step'] === 3): ?>
<div class="visible_class">
<label>
<span>Введите проверочный код, который только что был отправлен<br>
на ящик <?= $_SESSION['email'] ?>.</span>
<input type="text" name="secure_code" placeholder="Проверочный Код"/>
</label>
<?= $errorMessage ?>
</div>
<?php elseif ($_SESSION['step'] === 4): ?>
<div class="visible_class">
<label>
<span>Придумайте отличный пароль</span>
<input type="password" name="pass1_u" value=""/>
</label>
<label>
<span>Проверьте себя, введите ещё раз</span>
<input type="password" name="pass2_u" value=""/>
</label><br>
<p>
<h3>Минимум 8 символов.<br>Если лень думать, берите наш: <?= PassGen::new() ?></h3>
<?= $errorMessage ?>
</div>
<?php elseif ($_SESSION['step'] === 5): ?>
<div class="visible_class">
<label>
<span>Выберите пол вашего персонажа:</span>
<select name="pol_u" size="2" multiple>
<option value="10">Мужской</option>
<option value="11">Женский</option>
<option disabled>Боевой вертолёт Апач</option>
</select>
</label>
</div>
<?php elseif ($_SESSION['step'] === 6): ?>
<div class="visible_class">
<label for="start">
<span>Укажите дату вашего рождения:</span>
</label>
<input type="date" id="start" name="bday_u" value="1980-01-01" max="2003-01-01">
</div>
<?php elseif ($_SESSION['step'] === 7): ?>
<div class="visible_class">
<h3>Выберите игровой класс для вашего персонажа:</h3>
<h3>Внимание! Выбор игрового класса не влияет на игру в целом и нигде не фиксируется или же используется,
это необходимо для того, чтобы ваш персонаж получил нужные предметы в начале игры, а так же нужные
баффы.</h3>
<div style="margin-left: 23%;">
<div class="form_radio_btn">
<p><input name="class_u" type="radio" value="1" id="radio-1" checked>
<label for="radio-1">Топорщик</label></p>
</div>
<div class="form_radio_btn">
<p><input name="class_u" type="radio" value="2" id="radio-2">
<label for="radio-2">Уворотчик</label>
</p>
</div>
<div class="form_radio_btn">
<p><input name="class_u" type="radio" value="3" id="radio-3">
<label for="radio-3">Танк</label></p>
</div>
<div class="form_radio_btn">
<p><input name="class_u" type="radio" value="4" id="radio-4">
<label for="radio-4">Критовик</label>
</p>
</div>
<div class="form_radio_btn">
<p><input name="class_u" type="radio" value="5" id="radio-5">
<label for="radio-5">Маг Воздуха</label></p>
</div>
<div class="form_radio_btn">
<p><input name="class_u" type="radio" value="6" id="radio-6">
<label for="radio-6">Маг Огня</label>
</p>
</div>
<div class="form_radio_btn">
<p><input name="class_u" type="radio" value="7" id="radio-7">
<label for="radio-7">Маг Земли</label>
</p>
</div>
<div class="form_radio_btn">
<p><input name="class_u" type="radio" value="8" id="radio-8">
<label for="radio-8">Маг Воды</label>
</p>
</div>
<div class="form_radio_btn">
<p><input name="class_u" type="radio" value="9" id="radio-9">
<label for="radio-9">Критоуворот</label>
</p>
</div>
</div>
<h3>Внимание! Выбрав класс персонажа вы автоматически соглашаетесь с <a
href='https://new-combats.com/encicl/law2.html'>правилами и законами</a> игрового мира </h3>
<br>
</div>
<?php endif; ?>
2022-12-30 19:03:37 +00:00
<div class="visible_class_s"><p><input class="box" type="submit"></p></div>
2023-01-10 16:29:32 +00:00
</form>