From 0cb150b0e4a646287182baff533068c05b75359a Mon Sep 17 00:00:00 2001 From: rsgrinko Date: Tue, 26 Apr 2022 23:36:59 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B8=20=D1=81=D0=B8=D0=BC=D0=BF?= =?UTF-8?q?=D0=B0=D1=82=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D0=BE=D0=B4=D0=B0=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=D0=B0?= =?UTF-8?q?=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D1=8B=20=D0=B8=D0=B7=20?= =?UTF-8?q?=D0=BC=D0=B0=D1=81=D1=81=D0=B8=D0=B2=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core/Helpers/SystemFunctions.class.php | 14 ++++++---- index.php | 27 ++++++++++--------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/core/lib/Core/Helpers/SystemFunctions.class.php b/core/lib/Core/Helpers/SystemFunctions.class.php index 0e23337..d55fa9b 100644 --- a/core/lib/Core/Helpers/SystemFunctions.class.php +++ b/core/lib/Core/Helpers/SystemFunctions.class.php @@ -332,19 +332,23 @@ */ public static function arrayToTable($var, string $title = ''): ?string { + $tableStyle = 'border: 1px solid #7b9ea3;border-collapse: collapse;'; + $tdBoldStyle = 'padding: 10px;border: 1px solid #7b9ea3;background: powderblue;font-weight: bold; text-align: center;'; + $tdStyle = 'padding: 10px;border: 1px solid #7b9ea3;'; + $thStyle = 'background: #b0e0e6;font-size: 1.3em;padding: 10px;'; if (is_array($var)) { - $table = ''; + $table = '
'; if ($title) { - $table .= ''; + $table .= ''; } foreach ($var as $k => $v) { $table .= ''; - $table .= ''; - $table .= ''; + $table .= ''; $table .= ''; diff --git a/index.php b/index.php index 436ea51..c987ec7 100644 --- a/index.php +++ b/index.php @@ -2,42 +2,43 @@ use Core\CoreException; use Core\ExternalServices\Telegram; - use Core\Models\User; + use Core\Models\{User, DB}; use Core\Helpers\{SystemFunctions, Cache, Log, Mail, Zip}; require_once $_SERVER['DOCUMENT_ROOT'] . '/core/bootstrap.php'; - Log::logToFile('Скрипт начал свою работу', 'test.log'); echo '{{ADMIN_PANEL_LINK_NAME}} | {{CLEAR_CACHE_LINK_NAME}} | {{REFRESH_PAGE_LINK_NAME}}
'; Telegram::init('5232660453:AAGfMWu6EcRfBGSSURJsEEvGPmAqhCyzYHU', './'); - //$userId = User::registration('test', '12345', 'support@it-stories.ru', 'user', 'Тестировщик', 'http://samag.ru/uploads/5222447.png'); - - /*if (isset($_REQUEST['log']) && $_REQUEST['log'] === CODE_VALUE_Y) { - Log::logToFile('Тестовое сообщение в лог', 'test.log', $_REQUEST); - }*/ - - /*$user = new User($userId);*/ $userId = User::getCurrentUserId(); - Log::logToFile('Проверка пользователя на авторизованность', 'test.log', ['userId' => $userId]); try { $user = new User($userId); User::authorize((int)$userId); echo 'Current user id: ' . $userId . '
'; } catch (CoreException $e) { - Log::logToFile('CoreException: ' . $e->getMessage(), 'test.log', $_REQUEST); echo $e->showTrace(); } echo '

'; if (User::isAuthorized()) { - Log::logToFile('Пользователь авторизован, выводим данные о нем', 'test.log', $user->getAllUserData()); echo SystemFunctions::arrayToTable($user->getAllUserData(), 'Информация о пользователе'); } echo SystemFunctions::arrayToTable(Cache::getCacheInfo(), 'Информация о кэше'); +$arPosts = (DB::getInstance())->query('select * from d_posts where post_type="post" and post_status="publish" order by id desc limit 10'); +$arResult = []; +foreach($arPosts as $post) { + $arResult[] = [ + 'title' => $post['post_title'], + 'postname' => $post['post_name'], + 'date' => $post['post_date'], + 'userId' => $post['post_author'], + 'userName' => (new User((int)$post['post_author']))->getName() - Log::logToFile('Скрипт завершил свою работу', 'test.log'); + ]; +} + +echo SystemFunctions::arrayToTable($arResult, 'Статьи'); \ No newline at end of file
' . $title . '
' . $title . '
' . htmlspecialchars($k) . ''; + $table .= '' . htmlspecialchars($k) . ''; if (is_array($v)) { $table .= self::arrayToTable($v); } else { - $table .= htmlspecialchars($v); + $table .= '
' . htmlspecialchars($v) . '
'; } $table .= '