From 436839ac9a0ebe80e5703634ef68602a03c932b0 Mon Sep 17 00:00:00 2001 From: rsgrinko Date: Wed, 27 Apr 2022 12:58:49 +0300 Subject: [PATCH] =?UTF-8?q?[*]=20=D0=BD=D0=BE=D0=B2=D1=8B=D0=B5=20=D1=84?= =?UTF-8?q?=D0=B8=D1=87=D0=B8=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/bootstrap.php | 23 ++++++++++++++++++++++- index.php | 18 +++++------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/core/bootstrap.php b/core/bootstrap.php index 13e0852..a86619f 100644 --- a/core/bootstrap.php +++ b/core/bootstrap.php @@ -3,6 +3,8 @@ use Core\Models\User; use Core\Helpers\Cache; use Core\Template; + use Core\ExternalServices\Telegram; + use Core\CoreException; if (session_status() == PHP_SESSION_NONE) { session_start(); @@ -41,7 +43,26 @@ Cache::init(ROOT_PATH . '/core/cache/', true); - + // очистка кэша if(isset($_REQUEST['clear_cache']) && $_REQUEST['clear_cache'] === CODE_VALUE_Y) { Cache::flush(); + } + + // выход из системы + if (isset($_REQUEST['logout']) && $_REQUEST['logout'] === CODE_VALUE_Y) { + User::logout(); + } + + Telegram::init('5232660453:AAGfMWu6EcRfBGSSURJsEEvGPmAqhCyzYHU', './'); + + + $userId = User::getCurrentUserId(); + if(!empty($userId)) { + try { + $USER = new User($userId); + } catch (CoreException $e) { + $USER = null; + } + } else { + $USER = null; } \ No newline at end of file diff --git a/index.php b/index.php index b1fc00a..408163a 100644 --- a/index.php +++ b/index.php @@ -45,24 +45,16 @@ + + +
'; - } catch (CoreException $e) { - echo $e->showTrace(); - } - echo '

'; - if (User::isAuthorized()) { - echo str_replace('getAllUserData(), 'Информация о пользователе')); + global $USER; + echo str_replace('
getAllUserData(), 'Информация о пользователе')); } //echo str_replace('