From 9ec0f42e1705ffcdb3bff2d86ed35578875aada8 Mon Sep 17 00:00:00 2001 From: Maksym Date: Thu, 12 Jan 2023 21:38:13 +0100 Subject: [PATCH 01/14] =?UTF-8?q?=D0=9E=D0=B1=D1=83=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5.=20=D0=9D=D0=B0=D1=87=D0=B0=D0=BB=D0=BE=20Frontend?= =?UTF-8?q?=20=D1=87=D0=B0=D1=81=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _incl_data/autoload.php | 18 +++ .../DarksLight2/Training/Steps/FirstStep.php | 8 +- css/training/modal.css | 94 ++++++++++++++ js/training/index.js | 0 js/training/modal.js | 118 ++++++++++++++++++ main.php | 1 + modules_data/location/cp1.php | 10 +- modules_data/steps/first_step.php | 21 +++- test.php | 16 --- 9 files changed, 264 insertions(+), 22 deletions(-) create mode 100644 css/training/modal.css create mode 100644 js/training/index.js create mode 100644 js/training/modal.js diff --git a/_incl_data/autoload.php b/_incl_data/autoload.php index 4c68d220..a803892f 100644 --- a/_incl_data/autoload.php +++ b/_incl_data/autoload.php @@ -1,4 +1,9 @@ info['id']); + $training_manager->createDatabaseRecord(); + $training_manager->register([ + new FirstStep(), + ]); +} catch (TrainingException $e) { +} \ No newline at end of file diff --git a/_incl_data/class/DarksLight2/Training/Steps/FirstStep.php b/_incl_data/class/DarksLight2/Training/Steps/FirstStep.php index 4e93b75e..23a963ec 100644 --- a/_incl_data/class/DarksLight2/Training/Steps/FirstStep.php +++ b/_incl_data/class/DarksLight2/Training/Steps/FirstStep.php @@ -9,12 +9,16 @@ class FirstStep extends StepFactory public function getTitle(): string { - return 'Первое знакомство'; + return 'Добро пожаловать в игру!'; } public function getMessage(): string { - return 'test'; + return 'Мы поможем Вам адаптироваться в нашей браузерной онлайн игре.
+ Суть игры, заключается стремлении стать непобедимым бойцом в игре среди других персонажей!
+ Сделать это сможет каждый игрок, путём усиления своего персонажа, предметов улучшенного качества, интеграции рун и чарок в предметы и других, интересных усилений.
+ На общем фоне слева, Вы можете наблюдать своего персонажа ( слева ), на котором показаны пустые слоты под предметы, его параметры, ваши деньги, победы/поражения, а с права, общее окно разных локаций, таких как: Магазин, Ремонтная Мастерская, Здание лото, Здание Бойцовского Клуба где проходят поединки, Почта, Переход на Страшилкину Улицу и т.д.
+ Далее, мы подскажем Вам, для чего служит нижний фрейм.'; } public function getRewards(): array diff --git a/css/training/modal.css b/css/training/modal.css new file mode 100644 index 00000000..95bfa33d --- /dev/null +++ b/css/training/modal.css @@ -0,0 +1,94 @@ +.modal__backdrop { + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + background: rgba(0, 0, 0, 0.5); + opacity: 0; + z-index: -1; + pointer-events: none; + transition: opacity0 .2s ease-in; +} + +.modal__content { + position: relative; + width: auto; + margin: 10px; + transition: opacity 0.3s ease-in; + display: flex; + flex-direction: column; + background-color: #fff; + background-clip: padding-box; + border: 1px solid rgba(0, 0, 0, 0.2); + border-radius: 0.3rem; + box-shadow: 0 0 7px 0 rgba(0, 0, 0, 0.3); +} + +@media (min-width: 576px) { + .modal__content { + max-width: 500px; + margin: 50px auto; + } +} + +.modal__show .modal__backdrop, +.modal__show .modal__content { + opacity: 1; + z-index: 1050; + pointer-events: auto; + overflow-y: auto; +} + +.modal__header { + display: flex; + align-items: center; + justify-content: space-between; + padding: 15px; + border-bottom: 1px solid #eceeef; +} + +.modal__title { + margin-top: 0; + margin-bottom: 0; + line-height: 1.5; + font-size: 1.25rem; + font-weight: 500; +} + +.modal__btn-close { + float: right; + font-family: sans-serif; + font-size: 24px; + font-weight: 700; + line-height: 1; + color: #000; + text-shadow: 0 1px 0 #fff; + opacity: 0.5; + text-decoration: none; +} + +.modal__btn-close:focus, +.modal__btn-close:hover { + color: #000; + text-decoration: none; + cursor: pointer; + opacity: 0.75; +} + +.modal__body { + position: relative; + flex: 1 1 auto; + padding: 15px; + overflow: auto; +} + +.modal__footer { + display: flex; + align-items: center; + justify-content: flex-end; + padding: 1rem; + border-top: 1px solid #e9ecef; + border-bottom-right-radius: 0.3rem; + border-bottom-left-radius: 0.3rem; +} \ No newline at end of file diff --git a/js/training/index.js b/js/training/index.js new file mode 100644 index 00000000..e69de29b diff --git a/js/training/modal.js b/js/training/modal.js new file mode 100644 index 00000000..6abec861 --- /dev/null +++ b/js/training/modal.js @@ -0,0 +1,118 @@ +(function () { + if (typeof window.CustomEvent === "function") return false; + function CustomEvent(event, params) { + params = params || { bubbles: false, cancelable: false, detail: null }; + var evt = document.createEvent('CustomEvent'); + evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); + return evt; + } + window.CustomEvent = CustomEvent; +})(); + +$modal = function (options) { + var + _elemModal, + _eventShowModal, + _eventHideModal, + _hiding = false, + _destroyed = false, + _animationSpeed = 200; + + function _createModal(options) { + var + elemModal = document.createElement('div'), + modalTemplate = '', + modalFooterTemplate = '', + modalButtonTemplate = '', + modalHTML, + modal_content, + modalFooterHTML = ''; + + elemModal.classList.add('modal'); + modalHTML = modalTemplate.replace('{{title}}', options.title || 'Новое окно'); + //modalHTML = modalHTML.replace('{{content}}', options.content || ''); + + if (options.footerButtons) { + for (var i = 0, length = options.footerButtons.length; i < length; i++) { + var modalFooterButton = modalButtonTemplate.replace('{{button_class}}', options.footerButtons[i].class); + modalFooterButton = modalFooterButton.replace('{{button_handler}}', options.footerButtons[i].handler); + modalFooterButton = modalFooterButton.replace('{{button_text}}', options.footerButtons[i].text); + modalFooterHTML += modalFooterButton; + } + modalFooterHTML = modalFooterTemplate.replace('{{buttons}}', modalFooterHTML); + } + modalHTML = modalHTML.replace('{{footer}}', modalFooterHTML); + elemModal.innerHTML = modalHTML; + document.body.appendChild(elemModal); + + modal_content = document.getElementById('modal_content') + modal_content.innerHTML = options.content + + return elemModal; + } + + function _showModal() { + if (!_destroyed && !_hiding) { + _elemModal.classList.add('modal__show'); + document.dispatchEvent(_eventShowModal); + } + } + + function _hideModal() { + _hiding = true; + _elemModal.classList.remove('modal__show'); + _elemModal.classList.add('modal__hiding'); + setTimeout(function () { + _elemModal.classList.remove('modal__hiding'); + _hiding = false; + }, _animationSpeed); + document.dispatchEvent(_eventHideModal); + } + + function _handlerCloseModal(e) { + if (e.target.dataset.dismiss === 'modal') { + _hideModal(); + } + } + + _elemModal = _createModal(options || {}); + + + _elemModal.addEventListener('click', _handlerCloseModal); + _eventShowModal = new CustomEvent('show.modal', { detail: _elemModal }); + _eventHideModal = new CustomEvent('hide.modal', { detail: _elemModal }); + + return { + show: _showModal, + hide: _hideModal, + destroy: function () { + _elemModal.parentElement.removeChild(_elemModal), + _elemModal.removeEventListener('click', _handlerCloseModal), + _destroyed = true; + }, + setContent: function (html) { + _elemModal.querySelector('[data-modal="content"]').innerHTML = html; + }, + setTitle: function (text) { + _elemModal.querySelector('[data-modal="title"]').innerHTML = text; + } + } +}; + +let modal = $modal({ + title: training_data().title, + content: training_data().content, + footerButtons: [ + { + class: 'btn btn__ok', + text: 'Продолжить', + handler: 'next_step' + } + ] +}); + +document.addEventListener('click', function (e) { + if (e.target.dataset.handler === 'next_step') { + training_handler() + } +}) \ No newline at end of file diff --git a/main.php b/main.php index bbed52f0..7fb492b8 100644 --- a/main.php +++ b/main.php @@ -25,6 +25,7 @@ +
room['file']=='cp1') -{ +if($u->room['file']=='cp1') { + + $training_manager = TrainingManager::getInstance(); + $training_manager->first_step->render(); + if(date("H")>=8 && date("H")<=23) { $now = 'day'; $tattack = 'Напасть на игрока   '; diff --git a/modules_data/steps/first_step.php b/modules_data/steps/first_step.php index 2bae859e..aeab505f 100644 --- a/modules_data/steps/first_step.php +++ b/modules_data/steps/first_step.php @@ -5,7 +5,24 @@ use DarksLight2\Training\TrainingManager; $short_name = 'first_step'; $manager = TrainingManager::getInstance(); +$step = $manager->$short_name; +$button_text = 'Продолжить'; +if(!$manager) { + $button_text = ''; +} +?> -var_dump($manager->$short_name->progress); + + -echo 'it\'s work'; + \ No newline at end of file diff --git a/test.php b/test.php index 63691622..862d26c6 100644 --- a/test.php +++ b/test.php @@ -15,19 +15,3 @@ if (!defined('GAME_VERSION')) { require_once '_incl_data/autoload.php'; } -$user = User::start(); - -$manager = TrainingManager::getInstance($user->info['id']); - -$manager->createDatabaseRecord(); - -try { - $manager->register([ - new FirstStep(), - ]); -} catch (TrainingException $e) { -} - -if(!$manager->first_step->complete) { - $manager->first_step->render(); -} -- 2.45.2 From 45fc2f51b42052845c3dc43a73c0893135713269 Mon Sep 17 00:00:00 2001 From: Maksym Date: Fri, 13 Jan 2023 18:56:41 +0100 Subject: [PATCH 02/14] =?UTF-8?q?=D0=92=D0=BE=D1=81=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=B0?= =?UTF-8?q?=D1=80=D0=BE=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- repass.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/repass.php b/repass.php index a89768c1..216c9bc3 100644 --- a/repass.php +++ b/repass.php @@ -21,6 +21,7 @@ if (isset($_POST['relogin'])) { $u = User::start(); $usr = Db::getRow('select * from users where login =?', [$_POST['relogin']]); + if (!isset($usr['id'])) { $error = 'Логин "' . htmlspecialchars($_POST['relogin'], null) . '" не найден в базе.'; } else { @@ -58,9 +59,11 @@ if (isset($_POST['relogin'])) { $txt .= 'Отвечать на данное письмо не нужно.

'; $txt .= 'С уважением,
'; $txt .= 'Администрация Бойцовского Клуба'; - $mail = Core\Mail::send($usr['mail'], $txt, $title); - if ($mail === 1) { + $mail = mail($usr['mail'], $title, $txt); + //$mail = Core\Mail::send($usr['mail'], $txt, $title); + + if ($mail) { Db::sql( 'update users set securetime = unix_timestamp(), allLock = unix_timestamp(), pass = ? where id = ?', [password_hash($newPassword, PASSWORD_DEFAULT), $usr['id']] -- 2.45.2 From 35c0b6825f55ccd6b9c7ed1e2224a13595878d02 Mon Sep 17 00:00:00 2001 From: DarksLight2 Date: Fri, 13 Jan 2023 21:41:44 +0000 Subject: [PATCH 03/14] revert 45fc2f51b42052845c3dc43a73c0893135713269 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit revert Восстановление пароля --- repass.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/repass.php b/repass.php index 216c9bc3..a89768c1 100644 --- a/repass.php +++ b/repass.php @@ -21,7 +21,6 @@ if (isset($_POST['relogin'])) { $u = User::start(); $usr = Db::getRow('select * from users where login =?', [$_POST['relogin']]); - if (!isset($usr['id'])) { $error = 'Логин "' . htmlspecialchars($_POST['relogin'], null) . '" не найден в базе.'; } else { @@ -59,11 +58,9 @@ if (isset($_POST['relogin'])) { $txt .= 'Отвечать на данное письмо не нужно.

'; $txt .= 'С уважением,
'; $txt .= 'Администрация Бойцовского Клуба'; + $mail = Core\Mail::send($usr['mail'], $txt, $title); - $mail = mail($usr['mail'], $title, $txt); - //$mail = Core\Mail::send($usr['mail'], $txt, $title); - - if ($mail) { + if ($mail === 1) { Db::sql( 'update users set securetime = unix_timestamp(), allLock = unix_timestamp(), pass = ? where id = ?', [password_hash($newPassword, PASSWORD_DEFAULT), $usr['id']] -- 2.45.2 From 739caee04bb48583465472405333fee41c66d1a1 Mon Sep 17 00:00:00 2001 From: Maksym Date: Sun, 15 Jan 2023 22:47:19 +0100 Subject: [PATCH 04/14] =?UTF-8?q?=D0=97=D0=B0=D0=BA=D0=BE=D0=BD=D1=87?= =?UTF-8?q?=D0=B8=D0=BB=20=D1=80=D0=B0=D0=B7=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D1=83=20=D0=BE=D0=B1=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DarksLight2/Training/Steps/SecondStep.php | 30 +++++ .../DarksLight2/Training/TrainingManager.php | 103 ++++++++++++++---- api/.htaccess | 4 + api/index.php | 47 ++++++++ css/training/modal.css | 2 +- js/training/modal.js | 21 ++++ main.php | 9 ++ modules_data/location/cp1.php | 5 - modules_data/steps/first_step.php | 21 ++-- modules_data/steps/second_step.php | 31 ++++++ modules_data/steps/step.php | 16 +++ 11 files changed, 253 insertions(+), 36 deletions(-) create mode 100644 _incl_data/class/DarksLight2/Training/Steps/SecondStep.php create mode 100644 api/.htaccess create mode 100644 api/index.php create mode 100644 modules_data/steps/second_step.php create mode 100644 modules_data/steps/step.php diff --git a/_incl_data/class/DarksLight2/Training/Steps/SecondStep.php b/_incl_data/class/DarksLight2/Training/Steps/SecondStep.php new file mode 100644 index 00000000..ec5ce3b3 --- /dev/null +++ b/_incl_data/class/DarksLight2/Training/Steps/SecondStep.php @@ -0,0 +1,30 @@ +user_id = $user_id; - + $this->generateToken(); } /** @@ -71,14 +71,16 @@ class TrainingManager public function render() { - $path = $_SERVER['DOCUMENT_ROOT'] . '/modules_data/steps/' . $this->short_name . '.php'; + if(!$this->isComplete) { + $path = $_SERVER['DOCUMENT_ROOT'] . '/modules_data/steps/' . $this->short_name . '.php'; - if(file_exists($path)) { - require $path; - return; + if (file_exists($path)) { + require $path; + return; + } + + throw TrainingException::noRenderingFile(); } - - throw TrainingException::noRenderingFile(); } }; } @@ -87,19 +89,61 @@ class TrainingManager private function stepData(string $short_name): object { - return json_decode($this->getDatabaseRecords()->data)->$short_name; + $data = $this->getDatabaseRecords()->data; + + if(!isset($data->$short_name)) { + $this->updateDatabaseRecord($short_name); + $data = $this->getDatabaseRecords()->data; + } + + return $data->$short_name; } - private function getDatabaseRecords() + private function generateToken($length = 16) + { + $letters = 'abcdefgmikiHGJKLjkGASysj7603456'; + + $token = ''; + + for ($i = 0; $i <= $length; $i++) { + $token .= $letters[rand(0, strlen($letters))]; + } + + Db::run('UPDATE user_training SET api_token = ? WHERE user_id = ?', [ + $token, + $this->user_id + ]); + } + + public function getDatabaseRecords(): stdClass { if(!$this->database_records) { - $this->database_records = Db::run('SELECT * FROM user_training WHERE user_id = ?', [$this->user_id]) + $data = Db::run('SELECT * FROM user_training WHERE user_id = ?', [$this->user_id]) ->fetch(PDO::FETCH_OBJ); + + $this->database_records = new stdClass(); + + $this->database_records->user_id = $data->user_id; + $this->database_records->api_token = $data->api_token; + $this->database_records->data = json_decode($data->data); } return $this->database_records; } + public function updateDatabaseRecord(string $short_name) + { + if($this->getDatabaseRecords()) { + + $this->database_records->data->$short_name = $this->firstRecordData()->$short_name; + + Db::run('UPDATE user_training SET data = ? WHERE user_id = ?', [ + json_encode($this->database_records->data), + $this->user_id + ]); + } + } + public function createDatabaseRecord() { if(!$this->getDatabaseRecords()) { @@ -110,19 +154,22 @@ class TrainingManager } } - private function firstRecordData(): array + private function firstRecordData(): stdClass { - return [ - 'first_step' => [ - 'complete' => 0, - 'progress' => [ - 'current' => 0, - 'need' => 0, - ] - ] + $data = new stdClass(); + $short_names = [ + 'first_step', + 'second_step' ]; - } + foreach ($short_names as $name) { + $data->$name->complete = false; + $data->$name->progress->current = 0; + $data->$name->progress->need = 1; + } + + return $data; + } public function __get(string $name) { return $this->steps[$name]; @@ -130,11 +177,25 @@ class TrainingManager public function addPoint(string $short_name) { - $this->$short_name->progress++; + $this->database_records->data->$short_name->progress->current++; + } + + public function nextStep() + { + foreach ($this->database_records->data as $step) { + if($step->complete === false && $step->progress->current >= $step->progress->need) { + $step->complete = true; + } + } } public function store() { + $this->nextStep(); + Db::run('UPDATE user_training SET data = ? WHERE user_id = ?', [ + json_encode($this->database_records->data), + $this->user_id + ]); } } \ No newline at end of file diff --git a/api/.htaccess b/api/.htaccess new file mode 100644 index 00000000..5b0712ea --- /dev/null +++ b/api/.htaccess @@ -0,0 +1,4 @@ + + RewriteEngine On + RewriteRule ^training/complete/?$ index.php?get=complete [L] + \ No newline at end of file diff --git a/api/index.php b/api/index.php new file mode 100644 index 00000000..07462aa2 --- /dev/null +++ b/api/index.php @@ -0,0 +1,47 @@ +info)) { + + $training = TrainingManager::getInstance($user->info['id']); + + if (!isset($data->token) || !password_verify( + $training->getDatabaseRecords()->api_token . $data->time . $user->info['id'], + $data->token + )) { + http_response_code(401); + die; + } + + if (isset($_GET['get'])) { + switch ($_GET['get']) { + default: + http_response_code(400); + die; + case 'complete': + if ($training->{$data->short_name}->isComplete) { + http_response_code(400); + die; + } + + $training->addPoint($data->short_name); + $training->nextStep(); + $training->store(); + + die(json_encode(['status' => 'ok'])); + } + } +} \ No newline at end of file diff --git a/css/training/modal.css b/css/training/modal.css index 95bfa33d..09fda884 100644 --- a/css/training/modal.css +++ b/css/training/modal.css @@ -4,7 +4,7 @@ right: 0; bottom: 0; left: 0; - background: rgba(0, 0, 0, 0.5); + /*background: rgba(0, 0, 0, 0.5);*/ opacity: 0; z-index: -1; pointer-events: none; diff --git a/js/training/modal.js b/js/training/modal.js index 6abec861..b4be8069 100644 --- a/js/training/modal.js +++ b/js/training/modal.js @@ -1,3 +1,24 @@ +const request = new XMLHttpRequest(); + +const training_handler = () => { + request.open('POST', '/api/training/complete') + request.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); + request.onreadystatechange = function() {//Call a function when the state changes. + if(request.readyState === 4 && request.status === 200) { + parent.frames['main'].location.reload(); + } + } + + request.send(JSON.stringify({ + time: training_data().time, + token: training_data().token, + short_name: training_data().short_name + })) + +} + +let active_training = null; + (function () { if (typeof window.CustomEvent === "function") return false; function CustomEvent(event, params) { diff --git a/main.php b/main.php index 7fb492b8..9ab501f5 100644 --- a/main.php +++ b/main.php @@ -29,11 +29,14 @@
top.myexpLineTop27(' . $u->info['exp'] . ',' . $spl . ');' . $tjs . 'top.ctest("' . $u->info['city'] . '");top.sd4key="' . $u->info['nextAct'] . '"; var battle = ' . (0 + $u->info['battle']) . '; top.hic(); '; +$training_manager = TrainingManager::getInstance(); + +if($u->room['file']=='cp1') { + $training_manager->first_step->render(); + $training_manager->second_step->render(); +} ?> diff --git a/modules_data/steps/second_step.php b/modules_data/steps/second_step.php new file mode 100644 index 00000000..920294f3 --- /dev/null +++ b/modules_data/steps/second_step.php @@ -0,0 +1,31 @@ + + + + + \ No newline at end of file diff --git a/modules_data/steps/step.php b/modules_data/steps/step.php new file mode 100644 index 00000000..15b8c9e2 --- /dev/null +++ b/modules_data/steps/step.php @@ -0,0 +1,16 @@ +$short_name; +$button_text = 'Продолжить'; +$time = time(); + +$token = password_hash($manager->getDatabaseRecords()->api_token . $time . $user->info['id'], PASSWORD_DEFAULT); -- 2.45.2 From bae941e155b70e76e08b2befe70ba501902d067b Mon Sep 17 00:00:00 2001 From: Maksym Date: Wed, 18 Jan 2023 12:43:45 +0100 Subject: [PATCH 05/14] =?UTF-8?q?=D0=9E=D0=B1=D1=83=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5.=20=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DarksLight2/Training/StepFactory.php | 39 ++- .../DarksLight2/Training/TrainingManager.php | 283 +++++++++--------- api/index.php | 31 +- js/training/modal.js | 43 ++- modules_data/steps/step.php | 30 +- 5 files changed, 265 insertions(+), 161 deletions(-) diff --git a/_incl_data/class/DarksLight2/Training/StepFactory.php b/_incl_data/class/DarksLight2/Training/StepFactory.php index 992eca25..c30742e3 100644 --- a/_incl_data/class/DarksLight2/Training/StepFactory.php +++ b/_incl_data/class/DarksLight2/Training/StepFactory.php @@ -2,12 +2,47 @@ namespace DarksLight2\Training; +use DarksLight2\Helpers\Str; +use User; + abstract class StepFactory { - abstract public function getTitle(): string; abstract public function getMessage(): string; - abstract public function getShortName(): string; abstract public function getRewards(): array; + public function onLocations(): array + { + return ['all']; + } + + public function getShortName(): string + { + return Str::snakeCase(get_class($this)); + } + public function getAnswer() + { + return null; + } + + public function allowedToMove(): array + { + return []; + } + + public function isInfo(): bool + { + return true; + } + + public function databaseRecord() + { + return [ + 'completed' => false, + 'progress' => [ + 'current' => 0, + 'need' => 1, + ] + ]; + } } \ No newline at end of file diff --git a/_incl_data/class/DarksLight2/Training/TrainingManager.php b/_incl_data/class/DarksLight2/Training/TrainingManager.php index 05b56298..e61df599 100644 --- a/_incl_data/class/DarksLight2/Training/TrainingManager.php +++ b/_incl_data/class/DarksLight2/Training/TrainingManager.php @@ -3,24 +3,127 @@ namespace DarksLight2\Training; use Core\Db; +use DarksLight2\Training\Steps\ChatFirstStep; +use DarksLight2\Training\Steps\MyUserFirstQuest; +use DarksLight2\Training\Steps\MyUserFirstStep; +use DarksLight2\Training\Steps\MyUserFourthQuest; +use DarksLight2\Training\Steps\MyUserFourthStep; +use DarksLight2\Training\Steps\MyUserSecondQuest; +use DarksLight2\Training\Steps\MyUserSecondStep; +use DarksLight2\Training\Steps\MyUserThirdQuest; +use DarksLight2\Training\Steps\MyUserThirdStep; use DarksLight2\Traits\Singleton; +use PassGen; use PDO; use stdClass; +use User; class TrainingManager { - use Singleton; - - private $database_records = false; - private array $steps_data; private int $user_id; - private array $steps; + public string $current_step = ''; + private array $registered_steps; + private array $completed_steps; + private array $active_steps; - public function __construct(int $user_id) + private $database; + + public function __construct(int $user_id, $refresh_token = true) { + try { + $this->register([ + new ChatFirstStep(), + new MyUserFirstStep(), + new MyUserFirstQuest(), + new MyUserSecondStep(), + new MyUserSecondQuest(), + new MyUserThirdStep(), + new MyUserThirdQuest(), + new MyUserFourthStep(), + new MyUserFourthQuest(), + ]); + } catch (TrainingException $e) { + } + $this->user_id = $user_id; - $this->generateToken(); + + if($refresh_token) { + $this->generateToken(); + } + + $this->database = Db::getRow('SELECT * FROM user_training WHERE user_id = ?', [$user_id]); + + $this->createDatabaseRecord(); + + $this->database['data'] = json_decode($this->database['data'], true); + + $this->selectActiveSteps(); + } + + public function getCurrentStepName(): string + { + if(empty($this->current_step)) { + $this->current_step = array_key_first($this->active_steps) ?? ''; + } + + return $this->current_step; + } + public function getRegistered(): array + { + return $this->registered_steps; + } + + public function getDatabaseData() + { + return $this->database; + } + + public function addPoint($short_name, $closure = null) + { + if($short_name === $this->getCurrentStepName()) { + $this->database['data'][$short_name]['progress']['current']++; + if(isset($closure)) { + $closure($this); + } + } + } + + public function nextStep() + { + + if($this->database['data'][$this->getCurrentStepName()]['progress']['need'] <= $this->database['data'][$this->getCurrentStepName()]['progress']['current']) { + $this->database['data'][$this->getCurrentStepName()]['progress']['current'] = 0; + $this->database['data'][$this->getCurrentStepName()]['completed'] = true; + unset($this->active_steps[$this->getCurrentStepName()]); + $this->current_step = array_key_first($this->active_steps) ?? ''; + $this->database['current'] = $this->getCurrentStepName(); + } + } + + public function previousStep() + { + $this->current_step = end($this->completed_steps) ?? ''; + $this->database['current'] = $this->current_step; + $this->database['data'][$this->getCurrentStepName()]['completed'] = false; + } + + public function selectActiveSteps() + { + foreach ($this->database['data'] as $step_name => $data) { + if($data['completed'] === false) { + $this->active_steps[$step_name] = $data; + continue; + } + + $this->completed_steps[] = $step_name; + + } + } + + public function store() + { + Db::sql('UPDATE user_training SET data = ?, current = ? WHERE user_id = ?', [json_encode($this->database['data']), $this->database['current'], $this->user_id]); } /** @@ -37,77 +140,14 @@ class TrainingManager foreach ($steps as $step) { if($step instanceof StepFactory) { - $this->steps[$step->getShortName()] = new class ( - $step->getMessage(), - $step->getTitle(), - $step->getRewards(), - $this->stepData($step->getShortName())->complete, - $step->getShortName(), - $this->stepData($step->getShortName())->progress - ) { - public string $message; - public string $title; - public string $short_name; - public array $rewards; - public bool $isComplete; - - public stdClass $progress; - - public function __construct( - string $message, - string $title, - array $rewards, - bool $isComplete, - string $short_name, - stdClass $progress - ) { - $this->rewards = $rewards; - $this->title = $title; - $this->isComplete = $isComplete; - $this->message = $message; - $this->short_name = $short_name; - $this->progress = $progress; - } - - public function render() - { - if(!$this->isComplete) { - $path = $_SERVER['DOCUMENT_ROOT'] . '/modules_data/steps/' . $this->short_name . '.php'; - - if (file_exists($path)) { - require $path; - return; - } - - throw TrainingException::noRenderingFile(); - } - } - }; + $this->registered_steps[$step->getShortName()] = $step; } } } - - private function stepData(string $short_name): object - { - $data = $this->getDatabaseRecords()->data; - - if(!isset($data->$short_name)) { - $this->updateDatabaseRecord($short_name); - $data = $this->getDatabaseRecords()->data; - } - - return $data->$short_name; - } - private function generateToken($length = 16) { - $letters = 'abcdefgmikiHGJKLjkGASysj7603456'; - $token = ''; - - for ($i = 0; $i <= $length; $i++) { - $token .= $letters[rand(0, strlen($letters))]; - } + $token = PassGen::new($length); Db::run('UPDATE user_training SET api_token = ? WHERE user_id = ?', [ $token, @@ -115,87 +155,42 @@ class TrainingManager ]); } - public function getDatabaseRecords(): stdClass - { - if(!$this->database_records) { - $data = Db::run('SELECT * FROM user_training WHERE user_id = ?', [$this->user_id]) - ->fetch(PDO::FETCH_OBJ); - - $this->database_records = new stdClass(); - - $this->database_records->user_id = $data->user_id; - $this->database_records->api_token = $data->api_token; - $this->database_records->data = json_decode($data->data); - } - - return $this->database_records; - } - - public function updateDatabaseRecord(string $short_name) - { - if($this->getDatabaseRecords()) { - - $this->database_records->data->$short_name = $this->firstRecordData()->$short_name; - - Db::run('UPDATE user_training SET data = ? WHERE user_id = ?', [ - json_encode($this->database_records->data), - $this->user_id - ]); - } - } - public function createDatabaseRecord() { - if(!$this->getDatabaseRecords()) { - Db::run('INSERT INTO user_training (user_id, data) VALUES (?, ?)', [ - $this->user_id, - json_encode($this->firstRecordData()) - ]); - } - } + if(!$this->database) { - private function firstRecordData(): stdClass - { - $data = new stdClass(); - $short_names = [ - 'first_step', - 'second_step' - ]; + $data = []; - foreach ($short_names as $name) { - $data->$name->complete = false; - $data->$name->progress->current = 0; - $data->$name->progress->need = 1; - } - - return $data; - } - public function __get(string $name) - { - return $this->steps[$name]; - } - - public function addPoint(string $short_name) - { - $this->database_records->data->$short_name->progress->current++; - } - - public function nextStep() - { - foreach ($this->database_records->data as $step) { - if($step->complete === false && $step->progress->current >= $step->progress->need) { - $step->complete = true; + foreach ($this->registered_steps as $step) { + $data[$step->getShortName()] = $step->databaseRecord(); } + + Db::sql('INSERT INTO user_training (user_id, data, current) VALUES (?, ?, ?)', [ + $this->user_id, + json_encode($data, true), + array_key_first($data) + ]); + + $this->database = Db::getRow('SELECT * FROM user_training WHERE user_id = ?', [$this->user_id]); } } - public function store() + /** + * @throws \DarksLight2\Training\TrainingException + */ + public function render() { - $this->nextStep(); + if(in_array(User::start()->room['file'], $this->registered_steps[$this->getCurrentStepName()]->onLocations()) || in_array('all', $this->registered_steps[$this->getCurrentStepName()]->onLocations())) { + $path = $_SERVER['DOCUMENT_ROOT'] . '/modules_data/steps/step.php'; - Db::run('UPDATE user_training SET data = ? WHERE user_id = ?', [ - json_encode($this->database_records->data), - $this->user_id - ]); + if (file_exists($path)) { + $short_name = $this->getCurrentStepName(); + $answer = $this->registered_steps[$this->getCurrentStepName()]->getAnswer(); + require $path; + return; + } + + throw TrainingException::noRenderingFile(); + } } } \ No newline at end of file diff --git a/api/index.php b/api/index.php index 07462aa2..4f4d0702 100644 --- a/api/index.php +++ b/api/index.php @@ -1,5 +1,8 @@ info)) { - $training = TrainingManager::getInstance($user->info['id']); + $training = TrainingManager::getInstance($user->info['id'], false); + + try { + $training->createDatabaseRecord(); + $training->register([ + new MyUserFirstQuest(), + new ChatFirstStep() + ]); + } catch (TrainingException $e) { + } if (!isset($data->token) || !password_verify( - $training->getDatabaseRecords()->api_token . $data->time . $user->info['id'], + $training->getDatabaseData()->api_token . $data->time . $user->info['id'], $data->token )) { http_response_code(401); @@ -32,16 +44,27 @@ if(!empty($user->info)) { http_response_code(400); die; case 'complete': - if ($training->{$data->short_name}->isComplete) { + if ($training->getDatabaseData()['data'][$training->getCurrentStepName()]['completed']) { http_response_code(400); die; } - $training->addPoint($data->short_name); + if($training->getRegistered()[$data->short_name]->isInfo()) { + + $training->addPoint($training->getCurrentStepName()); + } + $training->nextStep(); + $training->store(); die(json_encode(['status' => 'ok'])); + + case 'go_back': + $training->previousStep(); + $training->store(); + die(json_encode(['status' => 'ok', 'message' => 'Вы указал не верный ответ!'])); + } } } \ No newline at end of file diff --git a/js/training/modal.js b/js/training/modal.js index b4be8069..11c3ea62 100644 --- a/js/training/modal.js +++ b/js/training/modal.js @@ -1,23 +1,44 @@ const request = new XMLHttpRequest(); const training_handler = () => { - request.open('POST', '/api/training/complete') + + const url = (condition) => { + return condition ? '/api/training/complete' : '/api/training/go_back'; + }; + + request.open('POST', url(training_data().answer === null || training_data().answer === get_user_answer())) request.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); - request.onreadystatechange = function() {//Call a function when the state changes. - if(request.readyState === 4 && request.status === 200) { - parent.frames['main'].location.reload(); + request.onreadystatechange = function () {//Call a function when the state changes. + if (request.readyState === 4) { + if(request.status === 200) { + parent.frames['main'].location.reload(); + } + + if(request.responseText !== '') { + let response = JSON.parse(request.responseText); + + if (response.message !== undefined) { + alert(response.message); + } + } } } request.send(JSON.stringify({ time: training_data().time, token: training_data().token, - short_name: training_data().short_name + short_name: training_data().short_name, + answer: get_user_answer(), })) - } -let active_training = null; +function get_user_answer() { + if(training_data().answer === '') { + return ''; + } + + return document.getElementsByName('user_answer')[0].value; +} (function () { if (typeof window.CustomEvent === "function") return false; @@ -44,20 +65,24 @@ $modal = function (options) { elemModal = document.createElement('div'), modalTemplate = '', modalFooterTemplate = '', + modalInputAnswer = '', modalButtonTemplate = '', modalHTML, modal_content, modalFooterHTML = ''; + if(training_data().answer !== '') { + modalInputAnswer = '

'; + } + elemModal.classList.add('modal'); modalHTML = modalTemplate.replace('{{title}}', options.title || 'Новое окно'); - //modalHTML = modalHTML.replace('{{content}}', options.content || ''); if (options.footerButtons) { for (var i = 0, length = options.footerButtons.length; i < length; i++) { var modalFooterButton = modalButtonTemplate.replace('{{button_class}}', options.footerButtons[i].class); modalFooterButton = modalFooterButton.replace('{{button_handler}}', options.footerButtons[i].handler); - modalFooterButton = modalFooterButton.replace('{{button_text}}', options.footerButtons[i].text); + modalFooterButton = modalFooterButton.replace('{{button_text}}', options.footerButtons[i].text) + modalInputAnswer; modalFooterHTML += modalFooterButton; } modalFooterHTML = modalFooterTemplate.replace('{{buttons}}', modalFooterHTML); diff --git a/modules_data/steps/step.php b/modules_data/steps/step.php index 15b8c9e2..70e68993 100644 --- a/modules_data/steps/step.php +++ b/modules_data/steps/step.php @@ -1,16 +1,42 @@ $short_name; +$step = $manager->getRegistered()[$short_name]; $button_text = 'Продолжить'; $time = time(); -$token = password_hash($manager->getDatabaseRecords()->api_token . $time . $user->info['id'], PASSWORD_DEFAULT); +$token = password_hash($manager->getDatabaseData()->api_token . $time . $user->info['id'], PASSWORD_DEFAULT); +?> + + + + + -- 2.45.2 From 3f579afaed0038ce521751c61077e597ef08fd16 Mon Sep 17 00:00:00 2001 From: Maksym Date: Wed, 18 Jan 2023 12:51:06 +0100 Subject: [PATCH 06/14] =?UTF-8?q?=D0=9E=D0=B1=D1=83=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5.=20=D0=9D=D0=BE=D0=B2=D1=8B=D0=B5=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{SecondStep.php => ChatFirstQuest.php} | 20 +- .../Training/Steps/ChatFirstStep.php | 30 ++ .../Training/Steps/ChatSecondQuest.php | 35 ++ .../Training/Steps/ChatThirdQuest.php | 34 ++ .../DarksLight2/Training/Steps/FirstStep.php | 34 -- .../Training/Steps/MyUserFirstQuest.php | 35 ++ .../Training/Steps/MyUserFirstStep.php | 30 ++ .../Training/Steps/MyUserFourthQuest.php | 35 ++ .../Training/Steps/MyUserFourthStep.php | 48 +++ .../Training/Steps/MyUserSecondQuest.php | 35 ++ .../Training/Steps/MyUserSecondStep.php | 39 ++ .../Training/Steps/MyUserThirdQuest.php | 40 ++ .../Training/Steps/MyUserThirdStep.php | 45 +++ _incl_data/class/Priems.php | 5 + main.php | 12 +- modules_data/_locations.php | 364 +++++++++--------- modules_data/_umenie.php | 8 + modules_data/location/cp1.php | 2 - modules_data/steps/first_step.php | 31 -- modules_data/steps/second_step.php | 31 -- online.php | 13 + 21 files changed, 643 insertions(+), 283 deletions(-) rename _incl_data/class/DarksLight2/Training/Steps/{SecondStep.php => ChatFirstQuest.php} (55%) create mode 100644 _incl_data/class/DarksLight2/Training/Steps/ChatFirstStep.php create mode 100644 _incl_data/class/DarksLight2/Training/Steps/ChatSecondQuest.php create mode 100644 _incl_data/class/DarksLight2/Training/Steps/ChatThirdQuest.php delete mode 100644 _incl_data/class/DarksLight2/Training/Steps/FirstStep.php create mode 100644 _incl_data/class/DarksLight2/Training/Steps/MyUserFirstQuest.php create mode 100644 _incl_data/class/DarksLight2/Training/Steps/MyUserFirstStep.php create mode 100644 _incl_data/class/DarksLight2/Training/Steps/MyUserFourthQuest.php create mode 100644 _incl_data/class/DarksLight2/Training/Steps/MyUserFourthStep.php create mode 100644 _incl_data/class/DarksLight2/Training/Steps/MyUserSecondQuest.php create mode 100644 _incl_data/class/DarksLight2/Training/Steps/MyUserSecondStep.php create mode 100644 _incl_data/class/DarksLight2/Training/Steps/MyUserThirdQuest.php create mode 100644 _incl_data/class/DarksLight2/Training/Steps/MyUserThirdStep.php delete mode 100644 modules_data/steps/first_step.php delete mode 100644 modules_data/steps/second_step.php diff --git a/_incl_data/class/DarksLight2/Training/Steps/SecondStep.php b/_incl_data/class/DarksLight2/Training/Steps/ChatFirstQuest.php similarity index 55% rename from _incl_data/class/DarksLight2/Training/Steps/SecondStep.php rename to _incl_data/class/DarksLight2/Training/Steps/ChatFirstQuest.php index ec5ce3b3..9c4f5f8d 100644 --- a/_incl_data/class/DarksLight2/Training/Steps/SecondStep.php +++ b/_incl_data/class/DarksLight2/Training/Steps/ChatFirstQuest.php @@ -4,22 +4,17 @@ namespace DarksLight2\Training\Steps; use DarksLight2\Training\StepFactory; -class SecondStep extends StepFactory +class ChatFirstQuest extends StepFactory { public function getTitle(): string { - return 'Тест'; + return 'Начало.'; } public function getMessage(): string { - return 'Тест'; - } - - public function getShortName(): string - { - return 'second_step'; + return 'Отправьте сообщение в общий чат.'; } public function getRewards(): array @@ -27,4 +22,13 @@ class SecondStep extends StepFactory return []; } + public function getShortName(): string + { + return 'chat_first_quest'; + } + + public function isInfo(): bool + { + return false; + } } \ No newline at end of file diff --git a/_incl_data/class/DarksLight2/Training/Steps/ChatFirstStep.php b/_incl_data/class/DarksLight2/Training/Steps/ChatFirstStep.php new file mode 100644 index 00000000..debe5c5e --- /dev/null +++ b/_incl_data/class/DarksLight2/Training/Steps/ChatFirstStep.php @@ -0,0 +1,30 @@ + - Суть игры, заключается стремлении стать непобедимым бойцом в игре среди других персонажей!
- Сделать это сможет каждый игрок, путём усиления своего персонажа, предметов улучшенного качества, интеграции рун и чарок в предметы и других, интересных усилений.
- На общем фоне слева, Вы можете наблюдать своего персонажа ( слева ), на котором показаны пустые слоты под предметы, его параметры, ваши деньги, победы/поражения, а с права, общее окно разных локаций, таких как: Магазин, Ремонтная Мастерская, Здание лото, Здание Бойцовского Клуба где проходят поединки, Почта, Переход на Страшилкину Улицу и т.д.
- Далее, мы подскажем Вам, для чего служит нижний фрейм.'; - } - - public function getRewards(): array - { - return []; - } - - public function getShortName(): string - { - return 'first_step'; - } - -} \ No newline at end of file diff --git a/_incl_data/class/DarksLight2/Training/Steps/MyUserFirstQuest.php b/_incl_data/class/DarksLight2/Training/Steps/MyUserFirstQuest.php new file mode 100644 index 00000000..190ad7d4 --- /dev/null +++ b/_incl_data/class/DarksLight2/Training/Steps/MyUserFirstQuest.php @@ -0,0 +1,35 @@ + + Все игроки имеют свободные очки распределения параметров, что они дают игрокам конкретные модификаторы в зависимости от того, в какой из параметров распределяются очки распределения.
+ --- если можно, добавить скрин как выглядит эта кнопка --- + Сила - Увеличивает мощность рубящего урона ( для Силачей )
+ Ловкость - Увеличивает мощность колющего урона ( для Критоуворотов и Уворотов )
+ Интуиция - Увеличивает мощность режущего урона ( для Критовиков )
+ Выносливость - Увеличивает защиту от урона и магии, а так же добавит немного жизней. ( для Танков )
+ Интелект - Увеличивает мощность магии. ( Для Любого Мага )
+ Мудрость - Увеличивает колличество маны. ( Для Любого Мага )
+
+ Дополнительно, игроки имеют очки распределения Мастерства Оружия, это позволит воинам увеличить урон, а магам, открыть новые приемы.
+ Очки распределения Оружий распределяются точно так же, как и очки распределения параметров ( статов ).
+
+ В случае, если вы распределили неверно любые доступные очки распределения, или хотите их изменить, вы можете это сделать, поднявшись на 2 этаж здания " Бойцовский Клуб ".'; + } + + public function getShortName(): string + { + return 'my_user_fourth_step'; + } + + public function getRewards(): array + { + return []; + } + + public function getAnswer(): string + { + return ''; + } + +} \ No newline at end of file diff --git a/_incl_data/class/DarksLight2/Training/Steps/MyUserSecondQuest.php b/_incl_data/class/DarksLight2/Training/Steps/MyUserSecondQuest.php new file mode 100644 index 00000000..7e23fbd3 --- /dev/null +++ b/_incl_data/class/DarksLight2/Training/Steps/MyUserSecondQuest.php @@ -0,0 +1,35 @@ + + Текущий уровень - Отображает ваш текущий уровень персонажа.
+ Победы - Отображает сумму всех ваших побед, в любых поединках.
+ Поражения - Отображает сумму всех ваших поражений, в любых поединках.
+ Ничьих - Отображает сумму всех поединков, которые завершились в ничью.
+ Кредиты - Обычная игровая валюта - кредиты ( креды ), которые можно потратить в обычном магазине.
+ Еврокредиты - Покупная игровая валюта - еврокредиты ( екры ) , которые можно потратить в магазине " Берёзка ".
+ Воинственность - Дополнительная игровая валюта, потратить её можно в Подпольной Лавке.
+ Ежедневное задание - Отображает текущее ежедневное задание либо предоставляет возможность его взятия.
+ Бонус - Позволяет получить немного кредитов или еврокредитов.'; + } + + public function getShortName(): string + { + return 'my_user_second_step'; + } + + public function getRewards(): array + { + return []; + } + +} \ No newline at end of file diff --git a/_incl_data/class/DarksLight2/Training/Steps/MyUserThirdQuest.php b/_incl_data/class/DarksLight2/Training/Steps/MyUserThirdQuest.php new file mode 100644 index 00000000..7c78455b --- /dev/null +++ b/_incl_data/class/DarksLight2/Training/Steps/MyUserThirdQuest.php @@ -0,0 +1,40 @@ + + Критовик - Убивает Танков и Магов, основное оружие - Мечи
+ Уворот - Убивает Критовиков и Силачей, основное оружие - Кинжалы
+ Танк - Убивает Уворотов и Силачей, основное оружие - Дубина и щит.
+ Силач - Убивает Критовиков и Магов, основное оружие - Топоры
+ Критоуворот - Убивает Силачей и с небольшим шансом Критовиков и Уворотов, основное оружие - Кинжалы.
+
+ Маг Огня - Атакующий маг, убивает Уворотов и Танков.
+ Маг Воздуха - Атакующий маг, убивает Уворотов и Танков.
+ Маг Земли - Защищающийся маг, слабый урон, хорошая защита.
+ Маг Воды - Защищающийся маг, слабый урон, хорошая защита.'; + } + + public function getShortName(): string + { + return 'my_user_third_step'; + } + + public function getRewards(): array + { + return []; + } + + public function allowedToMove(): array + { + return ['cp1']; + } + +} \ No newline at end of file diff --git a/_incl_data/class/Priems.php b/_incl_data/class/Priems.php index 7af8851b..dfac9620 100644 --- a/_incl_data/class/Priems.php +++ b/_incl_data/class/Priems.php @@ -1,6 +1,7 @@ u->info['id'] . '" LIMIT 1' ); if ($upd) { + TrainingManager::getInstance() + ->addPoint('my_user_fourth_quest', function (TrainingManager $manager) { + $manager->store(); + }); $this->u->info['priems'] = $p; } } else { diff --git a/main.php b/main.php index 9ab501f5..ec4a2d6c 100644 --- a/main.php +++ b/main.php @@ -36,8 +36,11 @@ if (!defined('GAME_VERSION')) { } use Core\{Config, Database, Db}; +use DarksLight2\Training\TrainingException; use DarksLight2\Training\TrainingManager; +$training_manager = TrainingManager::getInstance(User::start()->info['id']); + function var_info($vars, $d = false) { echo "
\n";
@@ -559,11 +562,10 @@ $spl = $spl['exp'];
 echo '
 ';
 
-$training_manager = TrainingManager::getInstance();
-
-if($u->room['file']=='cp1') {
-    $training_manager->first_step->render();
-    $training_manager->second_step->render();
+try {
+    $training_manager->render();
+} catch (TrainingException $e) {
+    echo $e->getMessage();
 }
 ?>
 
diff --git a/modules_data/_locations.php b/modules_data/_locations.php
index 799e0d41..1e1bcf48 100644
--- a/modules_data/_locations.php
+++ b/modules_data/_locations.php
@@ -139,6 +139,8 @@ function thisInfRm($id, $tp = null, $json = false)
 }
 
 if (isset($_GET['loc'])) {
+    $training_manager = \DarksLight2\Training\TrainingManager::getInstance();
+
     $go = mysql_fetch_array(
         mysql_query(
             'SELECT * FROM `room` WHERE `code` = "' . mysql_real_escape_string(
@@ -146,210 +148,228 @@ if (isset($_GET['loc'])) {
             ) . '" AND `city` = "' . $u->info['city'] . '" LIMIT 1'
         )
     );
-    $tr_pl = mysql_fetch_array(
-        mysql_query(
-            'SELECT `id`,`v1` FROM `eff_users` WHERE `id_eff` = 4 AND `uid` = "' . $u->info['id'] . '" AND `delete` = "0" ORDER BY `v1` DESC LIMIT 1'
-        )
-    );
 
-    //Проверяем костыли
-    $kos1 = mysql_fetch_array(
-        mysql_query(
-            'SELECT `id`,`item_id` FROM `items_users` WHERE `inOdet` = 3 AND `uid` = "' . $u->info['id'] . '" AND `delete` = 0 LIMIT 1'
-        )
-    );
-    $kos2 = mysql_fetch_array(
-        mysql_query(
-            'SELECT `id`,`item_id` FROM `items_users` WHERE `inOdet` = 14 AND `uid` = "' . $u->info['id'] . '" AND `delete` = 0 LIMIT 1'
-        )
-    );
+    if (in_array(
+        $go['file'],
+        $training_manager->getRegistered(
+        )[$training_manager->getCurrentStepName()]->allowedToMove()
+    )) {
 
-    if ($kos1['item_id'] == 630 || $kos1['item_id'] == 631) {
-        $kos1['good'] = 1;
-    } else {
-        $kos1['good'] = 0;
-    }
-    if ($kos2['item_id'] == 630 || $kos2['item_id'] == 631) {
-        $kos2['good'] = 1;
-    } else {
-        $kos2['good'] = 0;
-    }
+        $tr_pl = mysql_fetch_array(
+            mysql_query(
+                'SELECT `id`,`v1` FROM `eff_users` WHERE `id_eff` = 4 AND `uid` = "' . $u->info['id'] . '" AND `delete` = "0" ORDER BY `v1` DESC LIMIT 1'
+            )
+        );
 
-    if (isset($tr_pl['id'])) {
+        //Проверяем костыли
+        $kos1 = mysql_fetch_array(
+            mysql_query(
+                'SELECT `id`,`item_id` FROM `items_users` WHERE `inOdet` = 3 AND `uid` = "' . $u->info['id'] . '" AND `delete` = 0 LIMIT 1'
+            )
+        );
+        $kos2 = mysql_fetch_array(
+            mysql_query(
+                'SELECT `id`,`item_id` FROM `items_users` WHERE `inOdet` = 14 AND `uid` = "' . $u->info['id'] . '" AND `delete` = 0 LIMIT 1'
+            )
+        );
 
-        $zadej = 0;
-
-        if ($tr_pl['v1'] == 1) {
-            //все ок
-        } elseif ($tr_pl['v1'] == 2) {
-            if ($kos1['good'] == 0 && $kos2['good'] == 0) {
-                $re = 'Вы травмированы. Не возможно с такими увечиями передвигаться без костылей.';
-                $zadej = -1;
-            } else {
-                $zadej = 20;
-            }
-        } elseif ($tr_pl['v1'] == 3 || $tr_pl['v1'] == 4) {
-            if ($kos1['good'] == 0 || $kos2['good'] == 0) {
-                $re = 'Вы травмированы. Не возможно с такими увечиями передвигаться без костылей.';
-                $zadej = -1;
-            } else {
-                $zadej = 30;
-            }
+        if ($kos1['item_id'] == 630 || $kos1['item_id'] == 631) {
+            $kos1['good'] = 1;
+        } else {
+            $kos1['good'] = 0;
         }
-    }
-    if ($u->room['extdlg'] > 0) {
-        header('location: main.php?talk=' . $u->room['extdlg'] . '');
-    } elseif (isset($zadej) && $zadej == -1) {
-        if (!isset($re) || $re == '') {
-            $re = 'У вас травма, нельзя перемещаться...';
+        if ($kos2['item_id'] == 630 || $kos2['item_id'] == 631) {
+            $kos2['good'] = 1;
+        } else {
+            $kos2['good'] = 0;
         }
-        //Травма...
-    } elseif ($u->info['align'] == 2 && $go['nochaos'] == 1) {
-        $re = 'Проход для хаосников закрыт!';
-    } elseif ($u->info['inTurnir'] > 0) {
-        $re = 'Вы не можете перемещаться, Вы приняли заявку на турнир ...';
-    } elseif (($kos1['good'] == 0 && $kos2['good'] == 0) && ((!isset($zadej) || $zadej == 0) && $u->aves['now'] >= $u->aves['max'] && $u->room['name'] != 'Общежитие' && $u->room['name'] != 'Общ. Этаж 1' && $u->room['name'] != 'Общ. Этаж 2' && $u->room['name'] != 'Общ. Этаж 3')) {
-        $re = 'Вы не можете перемещаться, рюкзак переполнен ...';
-    } elseif (isset($go['id'])) {
-        $rmgo = [];
-        $rg = explode(',', $u->room['roomGo']);
-        $mlvl = explode('-', $go['level']);
-        $i = 0;
-        while ($i < count($rg)) {
-            if ($rg[$i] >= 0) {
-                $rmgo[$rg[$i]] = 1;
 
-            }
-            $i++;
-        }
-        $sleep = $u->testAction('`vars` = "sleep" AND `uid` = "' . $u->info['id'] . '" LIMIT 1', 1);
-        if (isset($sleep['id']) && $sleep['vars'] == 'sleep' && $go['name'] != 'Общ. Этаж 1' && $go['name'] != 'Общ. Этаж 2' && $go['name'] != 'Общ. Этаж 3') {
-            $re = 'Вы можете перемещаться только когда бодрствуете.';
-            echo ' ' . $re;
-        } elseif ($u->info['timeGo'] >= time()) {
-            $re = 'Вы не можете перемещаться еще ' . ($u->info['timeGo'] - time()) . ' сек.';
-        } elseif ($rmgo[$go['id']] == 1) {
-            $alg = explode('-', $go['align']);
-            $ku = mysql_fetch_array(
-                mysql_query('SELECT `id` FROM `katok_zv` WHERE `uid` = "' . $u->info['id'] . '" LIMIT 1')
-            );
+        if (isset($tr_pl['id'])) {
+            $zadej = 0;
 
-            if (isset($ku['id'])) {
-                $re = 'Вы подали заявку на турнир и не можете перемещаться...';
-            } elseif (($alg[0] > $u->info['align'] || $alg[1] < $u->info['align']) && $go['align'] != 0 && $u->info['admin'] == 0) {
-                $re = 'Ты не ту склонность выбрал.. Дружок :)';
-            } elseif ($u->info['zv'] > 0) {
-                $test_zv = mysql_fetch_array(
-                    mysql_query(
-                        'SELECT * FROM `zayvki` WHERE `id` = "' . $u->info['zv'] . '" AND `cancel` = 0 AND `start` = 0 AND `time` > "' . (time(
-                            ) - 60 * 60 * 2) . '" LIMIT 1'
-                    )
-                );
-                if (isset($test_zv['id'])) {
-                    $re = 'Подали заявку и убегаем?.. Не хорошо!';
+            if ($tr_pl['v1'] == 1) {
+                //все ок
+            } elseif ($tr_pl['v1'] == 2) {
+                if ($kos1['good'] == 0 && $kos2['good'] == 0) {
+                    $re = 'Вы травмированы. Не возможно с такими увечиями передвигаться без костылей.';
+                    $zadej = -1;
                 } else {
-                    $re = 'Ваша заявка была удалена... Теперь вы можете перейти в другую локацию!';
-                    mysql_query('UPDATE `stats` SET `zv` = 0 WHERE `id` = "' . $u->info['id'] . '" LIMIT 1');
+                    $zadej = 20;
                 }
-            } elseif ((($go['clan'] > 0 && $u->info['clan'] != $go['clan']) || ($go['clan'] == -1 && $u->info['clan'] == 0)) && $u->info['admin'] == 0) {
-                $re = 'Вы не можете попасть в эту комнату';
-            } elseif ($go['sex'] > 0 && $go['sex'] - 1 != $u->info['sex'] && $u->info['invis'] != 1 && $u->info['invis'] < time(
-                ) && $u->info['admin'] == 0) {
-                $re = 'Вы не можете попасть в эту комнату';
-            } elseif ($mlvl[0] > $u->info['level'] && $u->info['admin'] == 0) {
-                $re = 'Вы не можете попасть в эту комнату, уровень маловат ;)';
-            } elseif ($mlvl[1] < $u->info['level'] && $u->info['admin'] == 0) {
-                $re = 'Вы не можете попасть в эту комнату, уровень высоковат ;)';
-            } elseif ($go['close'] == 0 || $u->info['admin'] > 0) {
-                $travms = mysql_fetch_array(
+            } elseif ($tr_pl['v1'] == 3 || $tr_pl['v1'] == 4) {
+                if ($kos1['good'] == 0 || $kos2['good'] == 0) {
+                    $re = 'Вы травмированы. Не возможно с такими увечиями передвигаться без костылей.';
+                    $zadej = -1;
+                } else {
+                    $zadej = 30;
+                }
+            }
+        }
+        if ($u->room['extdlg'] > 0) {
+            header('location: main.php?talk=' . $u->room['extdlg'] . '');
+        } elseif (isset($zadej) && $zadej == -1) {
+            if (!isset($re) || $re == '') {
+                $re = 'У вас травма, нельзя перемещаться...';
+            }
+            //Травма...
+        } elseif ($u->info['align'] == 2 && $go['nochaos'] == 1) {
+            $re = 'Проход для хаосников закрыт!';
+        } elseif ($u->info['inTurnir'] > 0) {
+            $re = 'Вы не можете перемещаться, Вы приняли заявку на турнир ...';
+        } elseif (($kos1['good'] == 0 && $kos2['good'] == 0) && ((!isset($zadej) || $zadej == 0) && $u->aves['now'] >= $u->aves['max'] && $u->room['name'] != 'Общежитие' && $u->room['name'] != 'Общ. Этаж 1' && $u->room['name'] != 'Общ. Этаж 2' && $u->room['name'] != 'Общ. Этаж 3')) {
+            $re = 'Вы не можете перемещаться, рюкзак переполнен ...';
+        } elseif (isset($go['id'])) {
+            $rmgo = [];
+            $rg = explode(',', $u->room['roomGo']);
+            $mlvl = explode('-', $go['level']);
+            $i = 0;
+            while ($i < count($rg)) {
+                if ($rg[$i] >= 0) {
+                    $rmgo[$rg[$i]] = 1;
+                }
+                $i++;
+            }
+            $sleep = $u->testAction(
+                '`vars` = "sleep" AND `uid` = "' . $u->info['id'] . '" LIMIT 1',
+                1
+            );
+            if (isset($sleep['id']) && $sleep['vars'] == 'sleep' && $go['name'] != 'Общ. Этаж 1' && $go['name'] != 'Общ. Этаж 2' && $go['name'] != 'Общ. Этаж 3') {
+                $re = 'Вы можете перемещаться только когда бодрствуете.';
+                echo ' ' . $re;
+            } elseif ($u->info['timeGo'] >= time()) {
+                $re = 'Вы не можете перемещаться еще ' . ($u->info['timeGo'] - time(
+                        )) . ' сек.';
+            } elseif ($rmgo[$go['id']] == 1) {
+                $alg = explode('-', $go['align']);
+                $ku = mysql_fetch_array(
                     mysql_query(
-                        'SELECT * FROM `eff_users` WHERE `uid` = "' . $u->info['id'] . '" and (`v1`="2" or `v1`="3") and `delete`=0 ORDER by v1 DESC'
+                        'SELECT `id` FROM `katok_zv` WHERE `uid` = "' . $u->info['id'] . '" LIMIT 1'
                     )
                 );
 
-                //замедление перемешения при травмах
-                $plus_timeGo = 0 + $zadej; // добавочное время при травме
-                if ($plus_timeGo < 0) {
-                    $plus_timeGo = 0;
-                }
-
-                if (((!isset($zadej) || $zadej == 0) && $u->aves['now'] >= $u->aves['max'] && $u->room['name'] != 'Общежитие' && $u->room['name'] != 'Общ. Этаж 1' && $u->room['name'] != 'Общ. Этаж 2' && $u->room['name'] != 'Общ. Этаж 3')) {
-                    $plus_timeGo += 2 * 60;
-                    if ($kos1['good'] == 0) {
-                        $plus_timeGo += 1.5 * 60;
-                    } elseif ($kos1['good'] == 0) {
-                        $plus_timeGo += 1.5 * 60;
-                    }
-                }
-
-                //end freez time go
-
-                if ($u->stats['silver'] >= 1) {//время перемещения -20%
-                    $go['timeGO'] = floor($go['timeGO'] / 100 * 80);
-                    $plus_timeGo = floor($plus_timeGo / 100 * 80);
-                }
-                $u->info['timeGo'] = time() + $go['timeGO'] + $plus_timeGo;
-                $u->info['timeGoL'] = time();
-                $upd = mysql_query(
-                    'UPDATE `stats` SET `timeGo` = "' . $u->info['timeGo'] . '",`timeGoL` = "' . $u->info['timeGoL'] . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'
-                );
-                if ($upd) {
-                    $upd2 = mysql_query(
-                        'UPDATE `users` SET `room` = "' . $go['id'] . '",`online` = "' . time(
-                        ) . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'
+                if (isset($ku['id'])) {
+                    $re = 'Вы подали заявку на турнир и не можете перемещаться...';
+                } elseif (($alg[0] > $u->info['align'] || $alg[1] < $u->info['align']) && $go['align'] != 0 && $u->info['admin'] == 0) {
+                    $re = 'Ты не ту склонность выбрал.. Дружок :)';
+                } elseif ($u->info['zv'] > 0) {
+                    $test_zv = mysql_fetch_array(
+                        mysql_query(
+                            'SELECT * FROM `zayvki` WHERE `id` = "' . $u->info['zv'] . '" AND `cancel` = 0 AND `start` = 0 AND `time` > "' . (time(
+                                ) - 60 * 60 * 2) . '" LIMIT 1'
+                        )
+                    );
+                    if (isset($test_zv['id'])) {
+                        $re = 'Подали заявку и убегаем?.. Не хорошо!';
+                    } else {
+                        $re = 'Ваша заявка была удалена... Теперь вы можете перейти в другую локацию!';
+                        mysql_query(
+                            'UPDATE `stats` SET `zv` = 0 WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'
+                        );
+                    }
+                } elseif ((($go['clan'] > 0 && $u->info['clan'] != $go['clan']) || ($go['clan'] == -1 && $u->info['clan'] == 0)) && $u->info['admin'] == 0) {
+                    $re = 'Вы не можете попасть в эту комнату';
+                } elseif ($go['sex'] > 0 && $go['sex'] - 1 != $u->info['sex'] && $u->info['invis'] != 1 && $u->info['invis'] < time(
+                    ) && $u->info['admin'] == 0) {
+                    $re = 'Вы не можете попасть в эту комнату';
+                } elseif ($mlvl[0] > $u->info['level'] && $u->info['admin'] == 0) {
+                    $re = 'Вы не можете попасть в эту комнату, уровень маловат ;)';
+                } elseif ($mlvl[1] < $u->info['level'] && $u->info['admin'] == 0) {
+                    $re = 'Вы не можете попасть в эту комнату, уровень высоковат ;)';
+                } elseif ($go['close'] == 0 || $u->info['admin'] > 0) {
+                    $travms = mysql_fetch_array(
+                        mysql_query(
+                            'SELECT * FROM `eff_users` WHERE `uid` = "' . $u->info['id'] . '" and (`v1`="2" or `v1`="3") and `delete`=0 ORDER by v1 DESC'
+                        )
                     );
-                    if ($upd2) {
 
-                        if ($u->room['file'] == 'bsenter' && $go['file'] != 'bsenter') {
-                            //Удаляем все ставки в БС
-                            $sp_bs = mysql_query(
-                                'SELECT `id`,`bsid`,`money` FROM `bs_zv` WHERE `uid` = "' . $u->info['id'] . '" AND `inBot` = "0" AND `finish` = "0"'
-                            );
-                            while ($pl_bs = mysql_fetch_array($sp_bs)) {
+                    //замедление перемешения при травмах
+                    $plus_timeGo = 0 + $zadej; // добавочное время при травме
+                    if ($plus_timeGo < 0) {
+                        $plus_timeGo = 0;
+                    }
+
+                    if (((!isset($zadej) || $zadej == 0) && $u->aves['now'] >= $u->aves['max'] && $u->room['name'] != 'Общежитие' && $u->room['name'] != 'Общ. Этаж 1' && $u->room['name'] != 'Общ. Этаж 2' && $u->room['name'] != 'Общ. Этаж 3')) {
+                        $plus_timeGo += 2 * 60;
+                        if ($kos1['good'] == 0) {
+                            $plus_timeGo += 1.5 * 60;
+                        } elseif ($kos1['good'] == 0) {
+                            $plus_timeGo += 1.5 * 60;
+                        }
+                    }
+
+                    //end freez time go
+
+                    if ($u->stats['silver'] >= 1) {//время перемещения -20%
+                        $go['timeGO'] = floor($go['timeGO'] / 100 * 80);
+                        $plus_timeGo = floor($plus_timeGo / 100 * 80);
+                    }
+                    $u->info['timeGo'] = time() + $go['timeGO'] + $plus_timeGo;
+                    $u->info['timeGoL'] = time();
+                    $upd = mysql_query(
+                        'UPDATE `stats` SET `timeGo` = "' . $u->info['timeGo'] . '",`timeGoL` = "' . $u->info['timeGoL'] . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'
+                    );
+                    if ($upd) {
+                        $upd2 = mysql_query(
+                            'UPDATE `users` SET `room` = "' . $go['id'] . '",`online` = "' . time(
+                            ) . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'
+                        );
+                        if ($upd2) {
+                            if ($u->room['file'] == 'bsenter' && $go['file'] != 'bsenter') {
+                                //Удаляем все ставки в БС
+                                $sp_bs = mysql_query(
+                                    'SELECT `id`,`bsid`,`money` FROM `bs_zv` WHERE `uid` = "' . $u->info['id'] . '" AND `inBot` = "0" AND `finish` = "0"'
+                                );
+                                while ($pl_bs = mysql_fetch_array($sp_bs)) {
+                                    mysql_query(
+                                        'UPDATE `bs_turnirs` SET `users` = `users` - 1 WHERE `id` = "' . $pl_bs['bsid'] . '" LIMIT 1'
+                                    );
+                                }
+                                unset($sp_bs, $pl_bs);
                                 mysql_query(
-                                    'UPDATE `bs_turnirs` SET `users` = `users` - 1 WHERE `id` = "' . $pl_bs['bsid'] . '" LIMIT 1'
+                                    'UPDATE `bs_zv` SET `finish` = "' . time(
+                                    ) . '" WHERE `uid` = "' . $u->info['id'] . '" AND `inBot` = "0" AND `finish` = "0"'
                                 );
                             }
-                            unset($sp_bs, $pl_bs);
-                            mysql_query(
-                                'UPDATE `bs_zv` SET `finish` = "' . time(
-                                ) . '" WHERE `uid` = "' . $u->info['id'] . '" AND `inBot` = "0" AND `finish` = "0"'
+
+                            $smt = $u->testAction(
+                                '`uid` = "' . $u->info['id'] . '" AND `time`>=' . (time(
+                                    ) - 600) . ' AND `vars` = "create_snowball_cp" LIMIT 1',
+                                1
+                            );
+                            if (isset($smt['id'])) {
+                                mysql_query(
+                                    'DELETE FROM `actions` WHERE `id` = "' . $smt['id'] . '" LIMIT 1'
+                                );
+                            }
+                            mysql_query(
+                                'UPDATE `eff_users` SET `delete` = "' . time(
+                                ) . '" WHERE `id_eff` = "24" AND `uid` = "' . $u->info['id'] . '" AND `delete` = "0" LIMIT 24'
                             );
-                        }
 
-                        $smt = $u->testAction(
-                            '`uid` = "' . $u->info['id'] . '" AND `time`>=' . (time(
-                                ) - 600) . ' AND `vars` = "create_snowball_cp" LIMIT 1', 1
-                        );
-                        if (isset($smt['id'])) {
-                            mysql_query('DELETE FROM `actions` WHERE `id` = "' . $smt['id'] . '" LIMIT 1');
-                        }
-                        mysql_query(
-                            'UPDATE `eff_users` SET `delete` = "' . time(
-                            ) . '" WHERE `id_eff` = "24" AND `uid` = "' . $u->info['id'] . '" AND `delete` = "0" LIMIT 24'
-                        );
-
-                        $u->info['room'] = $go['id'];
-                        $u->room = $go;
-                        if (!isset($_GET['mAjax'])) {
-                            echo '';
+                            $u->info['room'] = $go['id'];
+                            $u->room = $go;
+                            if (!isset($_GET['mAjax'])) {
+                                echo '';
+                            }
+                        } else {
+                            $re = 'Вы не смогли перейти в локацию, возможно она была разрушена';
                         }
                     } else {
-                        $re = 'Вы не смогли перейти в локацию, возможно она была разрушена';
+                        $re = 'Вы не смогли перейти в локацию';
                     }
+                } elseif ($go['destroy'] == 1) {
+                    $re = 'Здание было разрушено, в данный момент оно реставрируется';
                 } else {
-                    $re = 'Вы не смогли перейти в локацию';
+                    $re = 'Временно закрыто';
                 }
-            } elseif ($go['destroy'] == 1) {
-                $re = 'Здание было разрушено, в данный момент оно реставрируется';
             } else {
-                $re = 'Временно закрыто';
+                $re = 'Проход не существует';
             }
         } else {
             $re = 'Проход не существует';
         }
     } else {
-        $re = 'Проход не существует';
+        $re = 'Вам запрещено передвигаться до окончания обучения!!!';
     }
 }
 
diff --git a/modules_data/_umenie.php b/modules_data/_umenie.php
index ea1bba4f..9b8d5c30 100644
--- a/modules_data/_umenie.php
+++ b/modules_data/_umenie.php
@@ -1,4 +1,7 @@
 info['id'] . "';"
                 )) {
+                    TrainingManager::getInstance()
+                        ->addPoint('my_user_third_quest', function (TrainingManager $manager) {
+                            $manager->store();
+                        });
+
                     //if($_GET['energy']>0) {echo '   Увеличение способности "Энергия" произведено удачно
';} if ($_GET['str'] > 0) { echo '   Увеличение способности "Сила" произведено удачно
'; diff --git a/modules_data/location/cp1.php b/modules_data/location/cp1.php index 701780ea..272c8222 100644 --- a/modules_data/location/cp1.php +++ b/modules_data/location/cp1.php @@ -4,8 +4,6 @@ if(!defined('GAME')) { die(); } -require_once('/home/newcom1/public_html/_incl_data/__config.php'); -require_once('/home/newcom1/public_html/_incl_data/class/__db_connect.php'); if($u->room['file']=='cp1') { diff --git a/modules_data/steps/first_step.php b/modules_data/steps/first_step.php deleted file mode 100644 index 4d49f776..00000000 --- a/modules_data/steps/first_step.php +++ /dev/null @@ -1,31 +0,0 @@ - - - - - \ No newline at end of file diff --git a/modules_data/steps/second_step.php b/modules_data/steps/second_step.php deleted file mode 100644 index 920294f3..00000000 --- a/modules_data/steps/second_step.php +++ /dev/null @@ -1,31 +0,0 @@ - - - - - \ No newline at end of file diff --git a/online.php b/online.php index cf050dbf..a26ac39c 100644 --- a/online.php +++ b/online.php @@ -7,6 +7,7 @@ if (!defined('GAME_VERSION')) { use Core\Config; use Core\Database; use Core\Db; +use DarksLight2\Training\TrainingManager; Config::init(); @@ -265,6 +266,18 @@ if (isset($_POST['msg']) && str_replace(' ', '', $_POST['msg']) != '') { mysql_query("UPDATE `chat` SET `delete` = 1 WHERE `login` = '" . $u->info['login'] . "' LIMIT 1000"); $_POST['msg'] = 'Я спамер ' . $u->info['login'] . ' и меня нужно заблокировать https://new-combats.com/info/' . $u->info['id'] . ''; + $training_manager = TrainingManager::getInstance(); + + $training_manager->addPoint('chat_first_quest'); + + if(preg_match("/to\[(.*?)\]/", $_POST['msg'])) { + $training_manager->addPoint('chat_second_quest'); + } + + if(preg_match("/private\[(.*?)\]/", $_POST['msg'])) { + $training_manager->addPoint('chat_third_quest'); + } + mysql_query( 'INSERT INTO `chat` (`nosee`,`invis`,`da`,`delete`,`molch`,`new`,`login`,`to`,`city`,`room`,`time`,`type`,`spam`,`text`,`toChat`,`color`,`typeTime`,`sound`,`global`) VALUES ( "0", -- 2.45.2 From 328e7483cd6f60cbdaecbdbcc0d36b40c60c2da1 Mon Sep 17 00:00:00 2001 From: Maksym Date: Wed, 18 Jan 2023 12:51:33 +0100 Subject: [PATCH 07/14] =?UTF-8?q?=D0=9D=D0=BE=D0=B2=D0=B0=D1=8F=20=D1=84?= =?UTF-8?q?=D0=B8=D1=87=D0=B0=20=D1=81=20=D1=85=D1=8D=D0=BB=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _incl_data/class/DarksLight2/Helpers/Str.php | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 _incl_data/class/DarksLight2/Helpers/Str.php diff --git a/_incl_data/class/DarksLight2/Helpers/Str.php b/_incl_data/class/DarksLight2/Helpers/Str.php new file mode 100644 index 00000000..506aa30e --- /dev/null +++ b/_incl_data/class/DarksLight2/Helpers/Str.php @@ -0,0 +1,11 @@ + Date: Wed, 18 Jan 2023 12:51:58 +0100 Subject: [PATCH 08/14] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BB=20=D0=BB?= =?UTF-8?q?=D0=B8=D1=88=D0=BD=D0=B5=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test.php | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 test.php diff --git a/test.php b/test.php deleted file mode 100644 index 862d26c6..00000000 --- a/test.php +++ /dev/null @@ -1,17 +0,0 @@ - Date: Wed, 18 Jan 2023 12:53:20 +0100 Subject: [PATCH 09/14] =?UTF-8?q?=D0=92=D1=8B=D0=BD=D0=B5=D1=81=20=D0=BB?= =?UTF-8?q?=D0=BE=D0=B3=D0=B8=D0=BA=D1=83=20=D0=B8=D0=B7=20=D0=B0=D0=B2?= =?UTF-8?q?=D1=82=D0=BE=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D1=87=D0=B8?= =?UTF-8?q?=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _incl_data/autoload.php | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/_incl_data/autoload.php b/_incl_data/autoload.php index a803892f..d5f54a2b 100644 --- a/_incl_data/autoload.php +++ b/_incl_data/autoload.php @@ -1,9 +1,5 @@ info['id']); - $training_manager->createDatabaseRecord(); - $training_manager->register([ - new FirstStep(), - ]); -} catch (TrainingException $e) { -} \ No newline at end of file +}); \ No newline at end of file -- 2.45.2 From 5518b335a864931d89930be546340e8843aa260a Mon Sep 17 00:00:00 2001 From: Maksym Date: Wed, 18 Jan 2023 12:54:10 +0100 Subject: [PATCH 10/14] =?UTF-8?q?=D0=9E=D0=B1=D1=83=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5.=20=D0=9F=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=D0=BE=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=B9=20=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=8B=20=D1=81=20=D0=BD?= =?UTF-8?q?=D0=B5=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=D1=8C=D0=BD=D1=8B?= =?UTF-8?q?=D0=BC=20=D0=B2=D0=B2=D0=BE=D0=B4=D0=BE=D0=BC=20=D0=BE=D1=82?= =?UTF-8?q?=D0=B2=D0=B5=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/.htaccess | 1 + 1 file changed, 1 insertion(+) diff --git a/api/.htaccess b/api/.htaccess index 5b0712ea..6705c6ff 100644 --- a/api/.htaccess +++ b/api/.htaccess @@ -1,4 +1,5 @@ RewriteEngine On RewriteRule ^training/complete/?$ index.php?get=complete [L] + RewriteRule ^training/go_back/?$ index.php?get=go_back [L] \ No newline at end of file -- 2.45.2 From d1be4995e2415313a99ecf8d091195e88d95453f Mon Sep 17 00:00:00 2001 From: Maksym Date: Wed, 18 Jan 2023 13:00:56 +0100 Subject: [PATCH 11/14] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BB=20notise?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules_data/steps/step.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules_data/steps/step.php b/modules_data/steps/step.php index 70e68993..49b31cb6 100644 --- a/modules_data/steps/step.php +++ b/modules_data/steps/step.php @@ -19,7 +19,7 @@ $step = $manager->getRegistered()[$short_name]; $button_text = 'Продолжить'; $time = time(); -$token = password_hash($manager->getDatabaseData()->api_token . $time . $user->info['id'], PASSWORD_DEFAULT); +$token = password_hash($manager->getDatabaseData()['api_token'] . $time . $user->info['id'], PASSWORD_DEFAULT); ?> '; -try { - $training_manager->render(); -} catch (TrainingException $e) { - echo $e->getMessage(); -} +$training_manager->render(); ?>