From a4229765353bee59d1b042a0db0599a83536a938 Mon Sep 17 00:00:00 2001 From: rsgrinko Date: Fri, 7 Jul 2023 14:33:10 +0300 Subject: [PATCH] =?UTF-8?q?[*]=20=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=20=D1=88=D0=B0=D0=B1=D0=BB=D0=BE=D0=BD=D0=B8?= =?UTF-8?q?=D0=B7=D0=B0=D1=82=D0=BE=D1=80=20=D0=B3=D0=BB=D0=B0=D0=B2=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/lib/Core/App.class.php | 38 ++- index.php | 4 +- phpcmd.php | 1 + templates/index.twig | 596 +++++------------------------------- templates/index_origin.twig | 536 ++++++++++++++++++++++++++++++++ 5 files changed, 640 insertions(+), 535 deletions(-) create mode 100644 templates/index_origin.twig diff --git a/core/lib/Core/App.class.php b/core/lib/Core/App.class.php index 5fe4623..17b3361 100644 --- a/core/lib/Core/App.class.php +++ b/core/lib/Core/App.class.php @@ -21,21 +21,47 @@ namespace Core; - use Core\Models\Posts; + use Core\DataBases\DB; + use Core\Helpers\Cache; + use Core\Helpers\Files; + use Core\Helpers\SystemFunctions; + use Core\Models\{Posts, User}; class App { + + /** + * Отрисовка главной страницы + * + * @return void + * @throws CoreException + */ public static function index() { global $twig, $USER; - $userData = $USER ? $USER->getAllUserData() : ''; - $userRoles = $USER ? $USER->getRolesObject()->getFullRoles() : ''; + + $finish_time = microtime(true); + $delta = round($finish_time - START_TIME, 3); + if ($delta < 0.001) { + $delta = 0.001; + } + echo $twig->render( 'index.twig', [ - 'sections' => (new Posts())->getMainSections(), - 'user' => $USER ? $USER->getAllUserData() : null, - ] + 'isAuthorized' => User::isAuthorized(), + 'isAdmin' => User::isAuthorized() && $USER->isAdmin(), + 'userDataTable' => User::isAuthorized() ? str_replace( + 'getAllUserData(), 'Информация о пользователе') + ) : '', + 'statString' => 'Использовано ОЗУ: ' + . round(memory_get_usage() / 1024 / 1024, 2) . ' МБ / БД: ' + . round(DB::$workingTime,3) . ' сек (' . DB::$quantity . ' шт.) / Кэш: ' + . Files::convertBytes(Cache::getCacheSize()) + . ' / Генерация: ' . $delta . ' сек', + ] ); } diff --git a/index.php b/index.php index 3a1b178..cfc9d25 100644 --- a/index.php +++ b/index.php @@ -85,11 +85,11 @@ //echo str_replace('
query('select count(*) as count from users')[0]['count']; + $count = (int)(DB::getInstance())->query('select count(*) as count from d_users')[0]['count']; Pagination::execute($_REQUEST['page'], $count, 2); $limit = Pagination::getLimit(); - $arData = (DB::getInstance())->query('select * from users order by id desc limit ' . $limit); + $arData = (DB::getInstance())->query('select * from d_users order by id desc limit ' . $limit); $arResult = []; foreach ($arData as $element) { diff --git a/phpcmd.php b/phpcmd.php index b2efa28..1154484 100644 --- a/phpcmd.php +++ b/phpcmd.php @@ -19,6 +19,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + die(); use Core\DataBases\DB; use Core\Helpers\{Cache, Files}; use Core\Models\{User}; diff --git a/templates/index.twig b/templates/index.twig index 76b86a7..b0e524f 100644 --- a/templates/index.twig +++ b/templates/index.twig @@ -1,536 +1,78 @@ -{% extends 'layout.twig' %} - - - -{% block title %}Главная страница{% endblock %} - -{% block main %} - - - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
- + + + + + + + + Главная тестовая + + +
+ -
- -
+
+
+
-
+ {% if isAuthorized %} + {{ userDataTable |raw }} + {% else %} +

Вы не авторизованы :(

- - -
-
-
-

Categories

- - -
- - -
-
+
+
+ +
-{% endblock %} \ No newline at end of file +

{{ statString }}

+

© Delta Project

+ + + + \ No newline at end of file diff --git a/templates/index_origin.twig b/templates/index_origin.twig new file mode 100644 index 0000000..76b86a7 --- /dev/null +++ b/templates/index_origin.twig @@ -0,0 +1,536 @@ +{% extends 'layout.twig' %} + + + +{% block title %}Главная страница{% endblock %} + +{% block main %} + + + + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+ +
+
+ +
+ + +
+ +
+ + + +
+
+
+

Categories

+ + +
+ + +
+
+
+ +
+{% endblock %} \ No newline at end of file