477 lines
15 KiB
PHP
477 lines
15 KiB
PHP
<?php
|
||
if (session_status() === PHP_SESSION_NONE) {
|
||
session_start();
|
||
}
|
||
if (isset($_GET['unset'])) {
|
||
session_unset();
|
||
}
|
||
|
||
if (!defined('GAME_VERSION')) {
|
||
require_once '_incl_data/autoload.php';
|
||
}
|
||
|
||
|
||
use Core\{Config, Database, Db};
|
||
use User\Confirmation;
|
||
use User\Register;
|
||
use User\UserIp;
|
||
|
||
Config::init();
|
||
Database::init();
|
||
$newUser = new Register();
|
||
|
||
if (empty($_SESSION['step'])) {
|
||
$_SESSION['step'] = 1;
|
||
}
|
||
|
||
if (!empty($_REQUEST['ref'])) {
|
||
$_SESSION['ref'] = Db::getValue('select count(*) from users where id = ?', [$_REQUEST['ref']]) ?? 0;
|
||
}
|
||
|
||
|
||
if (
|
||
!empty($_POST['nick_u']) &&
|
||
$newUser->hasGoodLogin($_POST['nick_u'])
|
||
) {
|
||
$_SESSION['step'] = 2;
|
||
$_SESSION['login'] = $_POST['nick_u'];
|
||
}
|
||
|
||
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']);
|
||
}
|
||
|
||
if (
|
||
$_SESSION['step'] === 3 &&
|
||
!empty($_POST['secure_code']) &&
|
||
$newUser->hasGoodEmailCode($_SESSION['email'], $_POST['secure_code'])
|
||
) {
|
||
$_SESSION['step'] = 4;
|
||
}
|
||
|
||
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'];
|
||
}
|
||
|
||
if (
|
||
$_SESSION['step'] === 5 &&
|
||
in_array((int)$_POST['pol_u'], [10, 11])
|
||
) {
|
||
$_SESSION['step'] = 6;
|
||
$_SESSION['sex'] = (int)$_POST['pol_u'];
|
||
}
|
||
|
||
if (
|
||
$_SESSION['step'] === 6 &&
|
||
!empty($_POST['bday_u'])
|
||
) {
|
||
$_SESSION['step'] = 7;
|
||
$_SESSION['birthday'] = $_POST['bday_u'];
|
||
}
|
||
|
||
if (
|
||
$_SESSION['step'] === 7 &&
|
||
in_array((int)$_POST['class_u'], range(1, 9))
|
||
) {
|
||
$_SESSION['step'] = 8;
|
||
$_SESSION['class'] = (int)$_POST['class_u'];
|
||
}
|
||
|
||
if ($_SESSION['step'] === 8) { // Всех их соберём, вместе соберём. Покемон! Кхм..
|
||
//Создаем персонажа
|
||
|
||
$uid = $newUser->new(
|
||
$_SESSION['login'],
|
||
$_SESSION['password'],
|
||
$_SESSION['email'],
|
||
$_SESSION['ref'],
|
||
$_SESSION['birthday'],
|
||
$_SESSION['sex'],
|
||
$_SESSION['class']
|
||
);
|
||
|
||
if ($uid > 0) {
|
||
unset(
|
||
$_SESSION['login'],
|
||
$_SESSION['password'],
|
||
$_SESSION['email'],
|
||
$_SESSION['ref'],
|
||
$_SESSION['birthday'],
|
||
$_SESSION['sex'],
|
||
$_SESSION['class']
|
||
);
|
||
//мульты
|
||
$ppl = Db::getRows('select * from logs_auth where ip = ? or ip = ?', [UserIp::get(), $_COOKIE['ip']]);
|
||
|
||
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']]
|
||
);
|
||
|
||
if (!$ml) {
|
||
Db::sql('insert into mults (uid, uid2, ip) values (?,?,?)', [$uid, $spl['uid'], $spl['ip']]);
|
||
}
|
||
}
|
||
Db::sql(
|
||
'insert into logs_auth (uid, ip, browser, type, time) values (?,?,?,1,unix_timestamp())',
|
||
[$uid, UserIp::get(), $_SERVER['HTTP_USER_AGENT']]
|
||
);
|
||
|
||
//Обновяем таблицы
|
||
Db::sql('update users set ip = ? where id = ?', [UserIp::get(), $uid]);
|
||
Db::sql('insert into users_learning_status (uid) values (?)', [$uid]);
|
||
|
||
header('Refresh: 1; url=/bk');
|
||
die(
|
||
'Спасибо за регистрацию в игровом мире Бойцовского Клуба, желаем вам побед и долгой игры.
|
||
В случае вопросов по игре, Вам будет доступен общий чат!'
|
||
);
|
||
}
|
||
header('Location: /');
|
||
}
|
||
|
||
$errorMessage = $newUser->getError() ? "<h4>{$newUser->getError()}</h4>" : '';
|
||
|
||
?>
|
||
|
||
<!DOCTYPE html>
|
||
<head>
|
||
|
||
<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;
|
||
}
|
||
|
||
.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;
|
||
}
|
||
|
||
.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;
|
||
}
|
||
|
||
.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;
|
||
}
|
||
|
||
.visible_class h3 {
|
||
text-align: center;
|
||
text-shadow: #000 0 0 10px; /* Свечение голубого цвета */
|
||
color: #FFF;
|
||
margin-top: 20px;
|
||
margin-left: 50px;
|
||
margin-right: 50px;
|
||
}
|
||
|
||
.visible_class h4 {
|
||
|
||
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;
|
||
|
||
}
|
||
|
||
.visible_class input[type=radio] {
|
||
text-align: center;
|
||
text-shadow: #000 0 0 10px;
|
||
color: red;
|
||
#-webkit-text-stroke: 1px red;
|
||
|
||
}
|
||
|
||
.visible_class a:visited {
|
||
color: red;
|
||
}
|
||
|
||
.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
|
||
}
|
||
|
||
.visible_class_s input[type=submit]:hover {
|
||
background: #C44D58;
|
||
}
|
||
|
||
.visible_class_s {
|
||
position: absolute;
|
||
top: 80%;
|
||
left: 50%;
|
||
margin: 0 -50% 0 0;
|
||
transform: translate(-50%, -50%)
|
||
}
|
||
|
||
.form_radio_btn {
|
||
display: inline-block;
|
||
margin-right: 10px;
|
||
}
|
||
|
||
.form_radio_btn input[type=radio] {
|
||
display: none;
|
||
}
|
||
|
||
.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;
|
||
}
|
||
|
||
/* Checked */
|
||
.form_radio_btn input[type=radio]:checked + label {
|
||
background: #790000;
|
||
color: white;
|
||
}
|
||
|
||
/* Hover */
|
||
.form_radio_btn label:hover {
|
||
color: #FFF;
|
||
}
|
||
|
||
/* Disabled */
|
||
.form_radio_btn input[type=radio]:disabled + label {
|
||
background: #efefef;
|
||
color: #666;
|
||
}
|
||
|
||
.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;
|
||
}
|
||
|
||
.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);
|
||
}
|
||
|
||
.box::before {
|
||
content: '';
|
||
position: absolute;
|
||
width: 100%;
|
||
height: 100%;
|
||
background: linear-gradient(to right, transparent, white, transparent);
|
||
left: -100%;
|
||
transition: 0.5s;
|
||
}
|
||
|
||
.box:hover::before {
|
||
left: 100%;
|
||
}
|
||
|
||
label > span {
|
||
color: wheat;
|
||
font-weight: bold;
|
||
text-shadow: black 0 0 10px;
|
||
display: block;
|
||
margin: 20px;
|
||
font-family: Verdana, serif;
|
||
}
|
||
</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='/encicl/law2.html'>правилами и законами</a> игрового мира </h3>
|
||
<br>
|
||
</div>
|
||
<?php endif; ?>
|
||
<div class="visible_class_s"><p><input class="box" type="submit"></p></div>
|
||
</form>
|
||
|