From 7ef42a9cf4dc3b9697f12cf58b2c4b9da1d3d793 Mon Sep 17 00:00:00 2001 From: rsgrinko Date: Mon, 20 Jun 2022 22:42:41 +0300 Subject: [PATCH] [*] fix index --- core/config.php | 5 ++++ core/lib/Core/Helpers/Mail.class.php | 13 ++++++++++ core/lib/Core/Models/User.class.php | 7 +++--- test.php | 36 +++++++++++++++------------- 4 files changed, 41 insertions(+), 20 deletions(-) diff --git a/core/config.php b/core/config.php index e84d072..62e4eda 100644 --- a/core/config.php +++ b/core/config.php @@ -29,6 +29,11 @@ */ const TELEGRAM_BOT_TOKEN = '5232660453:AAGfMWu6EcRfBGSSURJsEEvGPmAqhCyzYHU'; + /** + * ID чата канала уведомлений в телеграм + */ + const TELEGRAM_NOTIFICATION_CHANNEL = '-1001714289174'; + /** * Время, в течении которого считаем пользователя онлайн, сек. */ diff --git a/core/lib/Core/Helpers/Mail.class.php b/core/lib/Core/Helpers/Mail.class.php index 4426999..a672aae 100644 --- a/core/lib/Core/Helpers/Mail.class.php +++ b/core/lib/Core/Helpers/Mail.class.php @@ -31,6 +31,11 @@ */ public $body = ''; + /** + * Тип + */ + public $type = ''; + /** * Массив заголовков файлов */ @@ -70,6 +75,14 @@ $this->body = $body; } + /** + * Тело письма + */ + public function setType($type = 'html') + { + $this->type = $type; + } + /** * Добавление файла к письму */ diff --git a/core/lib/Core/Models/User.class.php b/core/lib/Core/Models/User.class.php index a2d4e7f..b849415 100644 --- a/core/lib/Core/Models/User.class.php +++ b/core/lib/Core/Models/User.class.php @@ -127,7 +127,7 @@ } /** - * Получение имени текущего пользователя + * Получение времени ппоследней активности * * @return string|null */ @@ -155,7 +155,7 @@ * @return array * @throws CoreException */ - public static function getUsers(string $limit = '10', $sort = 'ASC') + public static function getUsers(string $limit = '10', string $sort = 'ASC'): array { $cacheId = md5('User_getUsers_' . $limit . '_' . $sort); if (Cache::check($cacheId)) { @@ -186,6 +186,7 @@ * Генерация GUID * * @return string + * @throws \Exception */ private static function generateGUID(): string { @@ -272,7 +273,7 @@ * * @throws CoreException */ - public static function registration(string $login, string $password, string $email, string $name = '', string $image = ''): int + public static function create(string $login, string $password, string $email, string $name = '', string $image = ''): int { Log::logToFile(__METHOD__, 'User.log', func_get_args()); diff --git a/test.php b/test.php index a89bd0a..7c5302c 100644 --- a/test.php +++ b/test.php @@ -1,25 +1,27 @@ > /dev/null 2>&1'; + passthru($handler); + $currentRunThread = (int)exec('ps -awx | grep \'test.php\' | grep -v \'grep\' | wc -l'); + echo 'Now running: ' . $currentRunThread . PHP_EOL; } - echo 'stop' . PHP_EOL; } else { - //$currentRunThread = (int)exec('ps -awx | grep \'test.php\' | grep -v \'grep\' | wc -l'); - //if ($currentRunThread < 4) { - //echo 'run new (' . $currentRunThread . ')'; - $handler = 'php /home/rsgrinko/sites/dev.it-stories.ru/test.php cli &'; - exec($handler); - //} + $res = (new TelegramSender(TELEGRAM_BOT_TOKEN))->setChat(TELEGRAM_NOTIFICATION_CHANNEL)->sendMessage('Start proc #' . $argv[1]); + Log::logToFile(json_encode($res, JSON_UNESCAPED_UNICODE), 'test.log', $argv[1]); + sleep(rand(2, 10)); + $res = (new TelegramSender(TELEGRAM_BOT_TOKEN))->setChat(TELEGRAM_NOTIFICATION_CHANNEL)->sendMessage('End proc #' . $argv[1]); + Log::logToFile(json_encode($res, JSON_UNESCAPED_UNICODE), 'test.log', $argv[1]); }