From 9fea80faecfb83dec14cc8769ad3e06bf0ef6ab0 Mon Sep 17 00:00:00 2001 From: rsgrinko Date: Wed, 22 Jun 2022 13:56:58 +0300 Subject: [PATCH] =?UTF-8?q?[*]=20=D0=B2=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=B0=20=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=B0=20=D0=B0=D0=B4=D0=BC=D0=B8=D0=BD=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=B2=20=D0=BE=D0=B1=D1=85=D0=BE=D0=B4=20=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D0=BD=D0=B4=D0=B0=D1=80=D1=82=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=80?= =?UTF-8?q?=D0=BE=D1=83=D1=82=D0=B8=D0=BD=D0=B3=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/php.xml | 8 ++++++++ core/bootstrap.php | 22 +++++++++++----------- core/lib/Panel.class.php | 21 +++++++++++++++++++++ core/routes.php | 1 - index.php | 1 + 5 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 core/lib/Panel.class.php diff --git a/.idea/php.xml b/.idea/php.xml index 7341688..c3bbe93 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -1,4 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/core/bootstrap.php b/core/bootstrap.php index 882f13c..bc57ac7 100644 --- a/core/bootstrap.php +++ b/core/bootstrap.php @@ -12,25 +12,24 @@ require_once __DIR__ . '/../vendor/autoload.php'; - ob_start(function($buffer) { + ob_start(function ($buffer) { try { Template::set('CLEAR_CACHE_LINK_NAME', 'Сброс файлового кэша'); Template::set('ADMIN_PANEL_LINK_NAME', 'Панель администратора'); Template::set('REFRESH_PAGE_LINK_NAME', 'Перезагрузить страницу'); Template::set('PHP_CMD_LINK_NAME', 'Командная PHP строка'); return Template::render($buffer); - } catch(Throwable $e) { + } catch (Throwable $e) { return $e->getMessage(); } }); - define('START_TIME', microtime(true)); // засекаем время старта скрипта + define('START_TIME', microtime(true)); // засекаем время старта скрипта const CORE_LOADED = true; // флаг корректного запуска require_once __DIR__ . '/config.php'; - /** * Реализация механизма автозагрузки классов */ @@ -50,14 +49,13 @@ * Инициализация шаблонизатора */ $loader = new \Twig\Loader\FilesystemLoader(PATH_TO_TEMPLATES); - $twig = new \Twig\Environment($loader, [ - //'cache' => CACHE_DIR, + $twig = new \Twig\Environment($loader, [//'cache' => CACHE_DIR, ]); Cache::init(CACHE_DIR, USE_CACHE); // очистка кэша - if(isset($_REQUEST['clear_cache']) && $_REQUEST['clear_cache'] === CODE_VALUE_Y) { + if (isset($_REQUEST['clear_cache']) && $_REQUEST['clear_cache'] === CODE_VALUE_Y) { Cache::flush(); } @@ -71,7 +69,7 @@ } catch (CoreException $e) { $userId = null; } - if(!empty($userId)) { + if (!empty($userId)) { try { $USER = new User($userId); } catch (CoreException $e) { @@ -82,7 +80,9 @@ } /** - * Запускаем маршрутизатор + * Запускаем маршрутизатор если не сказано иного */ - Router::execute(); - die(); \ No newline at end of file + if (defined('USE_ROUTER') && USE_ROUTER === true) { + Router::execute(); + die(); + } \ No newline at end of file diff --git a/core/lib/Panel.class.php b/core/lib/Panel.class.php new file mode 100644 index 0000000..cd0d7e1 --- /dev/null +++ b/core/lib/Panel.class.php @@ -0,0 +1,21 @@ + 'Главная', 'url' => '/', 'active' => true], + ['name' => 'Админка', 'url' => '/admin', 'active' => false], + ['name' => 'Командная PHP строка', 'url' => '/phpcmd.php', 'active' => false], + ['name' => 'Тест', 'url' => '/test', 'active' => false], + ]; + echo $twig->render('admin/index.twig', ['navbarItems' => $navbarItems, 'name' => 'Roman Grinko']); + } + } \ No newline at end of file diff --git a/core/routes.php b/core/routes.php index 4780a58..4b37653 100644 --- a/core/routes.php +++ b/core/routes.php @@ -1,7 +1,6 @@