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 .= '| ' . $title . ' |
';
+ $table .= '| ' . $title . ' |
';
}
foreach ($var as $k => $v) {
$table .= '';
- $table .= '| ' . htmlspecialchars($k) . ' | ';
- $table .= '';
+ $table .= ' | ' . htmlspecialchars($k) . ' | ';
+ $table .= '';
if (is_array($v)) {
$table .= self::arrayToTable($v);
} else {
- $table .= htmlspecialchars($v);
+ $table .= '' . htmlspecialchars($v) . ' ';
}
$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