Merge remote-tracking branch 'origin/main'

This commit is contained in:
rsgrinko committed 2023-04-05 15:50:03 +03:00
commit 24bb9a6830
16 files changed
+84 -243

No files matched your search

+1 -35
View File
@@ -105,7 +105,7 @@
];
$userId = User::getCurrentUserId();
if (!empty($userId)) {
if ($userId !== null) {
$objectUser = new User($userId);
$env['userId'] = $objectUser->getId();
$env['userLogin'] = $objectUser->getLogin();
@@ -135,38 +135,4 @@
return $result ?: 0;
}
/**
* Метод сохранения логов в Sentry
*
* @param string $sentryMessage Сообщение, передаваемое в Sentry и отображающееся как заголовок Issue
* @param string $sentryErrorLevel Уровень события Sentry (FATAL, ERROR, WARNING, INFO, DEBUG)
* @param array $sentryData Массив данных лога
*
* @return bool
*/
public static function logToSentry(
string $sentryMessage,
string $sentryErrorLevel = 'DEBUG',
array $sentryData = []
): bool {
$sentryErrorLevelArray = ['FATAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG'];
if (empty(trim($sentryMessage))
|| !in_array($sentryErrorLevel, $sentryErrorLevelArray)) {
return false;
}
if (is_array($sentryData) && count($sentryData) > 0) {
\Sentry\configureScope(function (\Sentry\State\Scope $sentryScope) use ($sentryData) {
foreach ($sentryData as $paramName => $paramValue) {
$sentryScope->setExtra($paramName, $paramValue);
}
});
}
\Sentry\captureMessage($sentryMessage, \Sentry\Severity::$sentryErrorLevel());
return true;
}
}
-63
View File
@@ -1,63 +0,0 @@
<?php
/**
* Copyright (c) 2022 Roman Grinko <rsgrinko@gmail.com>
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* Класс реестра
*/
namespace Core\Helpers;
class Registry
{
private static $_storage = [];
/**
* Установка значения
*/
public static function set($key, $value)
{
return self::$_storage[$key] = $value;
}
/**
* Получение значения
*/
public static function get($key, $default = null)
{
return (isset(self::$_storage[$key])) ? self::$_storage[$key] : $default;
}
/**
* Удаление
*/
public static function del($key): void
{
unset(self::$_storage[$key]);
}
/**
* Очистка
*/
public static function flush(): void
{
self::$_storage = [];
}
}
+1 -28
View File
@@ -390,7 +390,7 @@ DELETE from `jokes` WHERE `jokes`.id not in (SELECT id FROM t_temp);'
foreach ($res['photos'] as $arImage) {
$result[] = [
'date' => $arImage['earth_date'],
'src' => $arImage['img_src'],
'src' => $arImage['img_src'],
];
}
$page++;
@@ -401,33 +401,6 @@ DELETE from `jokes` WHERE `jokes`.id not in (SELECT id FROM t_temp);'
return $result;
}
public static function saveSolImages($sol)
{
$counter = 0;
$files = [];
$res = self::getSolImages($sol);
sleep(5);
if (empty($res)) {
throw new CoreException('Изображений с ровера за ' . $sol . ' сол нет');
}
foreach ($res as $arImage) {
$folder = 'ftp://admin:j2medit@10.8.0.2/mars/' . $arImage['date'];
if (!file_exists($folder)) {
if (!mkdir($folder) && !is_dir($folder)) {
//throw new CoreException('Папку "' . $folder . '" не удалось создать');
}
}
if (copy($arImage['src'], $folder . '/' . basename($arImage['src']))) {
$counter++;
$files[] = basename($arImage['src']);
//throw new CoreException('Не удалось сохранить файл "' . $folder . '/' . basename($arImage['src']) . '" не удалось создать');
}
}
return ['count' => $counter, 'files' => $files];
}
public static function getStory($from = null)
{
$tableName = 'podslyshano';
+3 -1
View File
@@ -235,8 +235,10 @@
} elseif ($param === 'value') {
if (is_numeric($v)) {
$result .= $v . ', ';
} elseif ($v === null) {
$result .= 'NULL, ';
} else {
$result .= '\'' . addslashes($v) . '\', ';
$result .= '\'' . ($v === null ? null : addslashes($v)) . '\', ';
}
}
}
+2 -2
View File
@@ -372,7 +372,7 @@
* @return \Core\Models\MQResponse
* @throws CoreException
*/
public function massCreateTasks(int $count = 1, ?string $class = null, string $method, ?array $params = null): MQResponse
public function massCreateTasks(int $count, ?string $class, string $method, ?array $params = null): MQResponse
{
if (empty($params)) {
$params = [];
@@ -438,7 +438,7 @@
* @return \Core\Models\MQResponse Идентификатор созданного задания
* @throws CoreException
*/
public function createTask(?string $class = null, string $method, ?array $params = null): MQResponse
public function createTask(?string $class, string $method, ?array $params = null): MQResponse
{
if (empty($params)) {
$params = [];
+1 -1
View File
@@ -1,5 +1,5 @@
-- Таблица versions --
create table if not exists `migrations` (
create table if not exists `d_migrations` (
`id` int(10) unsigned not null auto_increment,
`name` varchar(255) not null,
`date_created` timestamp default current_timestamp,
+7 -7
View File
@@ -1,4 +1,4 @@
CREATE TABLE `users`
CREATE TABLE `d_users`
(
`id` int(11) NOT NULL,
`login` varchar(100) NOT NULL,
@@ -10,16 +10,16 @@ CREATE TABLE `users`
`last_active` varchar(100) NOT NULL,
`date_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`date_updated` datetime DEFAULT NULL
) ENGINE = MyISAM
) ENGINE = innodb
DEFAULT CHARSET = utf8;
INSERT INTO `users` (`id`, `login`, `password`, `name`, `email`, `image_id`, `token`, `last_active`, `date_created`, `date_updated`)
VALUES (1, 'admin', '5321ef98bd96cccf03f50979fdd8c893', 'Роман Гринько', 'rsgrinko@yandex.ru', 18, 'RG1819-1000-77EB-8F7A-9B112FB69D3A0',
INSERT INTO `d_users` (`id`, `login`, `password`, `name`, `email`, `image_id`, `token`, `last_active`, `date_created`, `date_updated`)
VALUES (1, 'admin', '7c607172d24d7237579acfdeffe373e2', 'Роман Гринько', 'rsgrinko@yandex.ru', 18, 'RG1819-1000-77EB-8F7A-9B112FB69D3A0',
'1657051585', '2022-06-17 16:18:56', NULL),
(2, 'a.kirilcev', 'c7e82c3d2bed998ea1f4c1aca09c282b', 'Александр Кирильцев', 'a.kirilcev@it-tula.ru', 20,
(2, 'demo', '7c607172d24d7237579acfdeffe373e2', 'Demo', 'demo@it-stories.ru', 20,
'RG17DE-1000-26FC-837F-8F9C47E643970', '1655471459', '2022-06-17 16:18:56', NULL),
(3, 'system', '', 'Система', 'info@it-stories.ru', NULL, 'RG17DE-1000-2702-816F-97E3877DD6650', '1651673702', '2022-06-17 16:18:56', NULL);
ALTER TABLE `users` ADD PRIMARY KEY (`id`);
ALTER TABLE `users` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 25;
ALTER TABLE `d_users` ADD PRIMARY KEY (`id`);
ALTER TABLE `d_users` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 25;
CREATE TABLE `roles` (
+7 -7
View File
@@ -1,4 +1,4 @@
CREATE TABLE if not exists `users`
CREATE TABLE if not exists `d_users`
(
`id` int(11) NOT NULL,
`login` varchar(100) NOT NULL,
@@ -10,20 +10,20 @@ CREATE TABLE if not exists `users`
`last_active` varchar(100) NOT NULL,
`date_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`date_updated` datetime DEFAULT NULL
) ENGINE = MyISAM
) ENGINE = innodb
DEFAULT CHARSET = utf8;
INSERT INTO `users` (`id`, `login`, `password`, `name`, `email`, `image_id`, `token`, `last_active`, `date_created`, `date_updated`)
VALUES (1, 'admin', '5321ef98bd96cccf03f50979fdd8c893', 'Роман Гринько', 'rsgrinko@yandex.ru', 18, 'RG1819-1000-77EB-8F7A-9B112FB69D3A0',
INSERT INTO `d_users` (`id`, `login`, `password`, `name`, `email`, `image_id`, `token`, `last_active`, `date_created`, `date_updated`)
VALUES (1, 'admin', '7c607172d24d7237579acfdeffe373e2', 'Роман Гринько', 'rsgrinko@yandex.ru', 18, 'RG1819-1000-77EB-8F7A-9B112FB69D3A0',
'1657051585', '2022-06-17 16:18:56', NULL),
(2, 'a.kirilcev', 'c7e82c3d2bed998ea1f4c1aca09c282b', 'Александр Кирильцев', 'a.kirilcev@it-tula.ru', 20,
(2, 'demo', '7c607172d24d7237579acfdeffe373e2', 'Demo user', 'demo@it-stories.ru', 20,
'RG17DE-1000-26FC-837F-8F9C47E643970', '1655471459', '2022-06-17 16:18:56', NULL),
(3, 'system', '', 'Система', 'info@it-stories.ru', NULL, 'RG17DE-1000-2702-816F-97E3877DD6650', '1651673702', '2022-06-17 16:18:56', NULL);
ALTER TABLE `users`
ALTER TABLE `d_users`
ADD PRIMARY KEY (`id`);
ALTER TABLE `users`
ALTER TABLE `d_users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,
AUTO_INCREMENT = 25;
COMMIT;
+4 -4
View File
@@ -1,12 +1,12 @@
CREATE TABLE if not exists `roles` (
CREATE TABLE if not exists `d_roles` (
`id` int(11) NOT NULL,
`name` text,
`description` text
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
) ENGINE=innodb DEFAULT CHARSET=utf8;
INSERT INTO `roles` (`id`, `name`, `description`) VALUES
INSERT INTO `d_roles` (`id`, `name`, `description`) VALUES
(1, 'Админисистратор', 'Группа, имеющая доступ ко всему'),
(2, 'Пользователи', 'Базовая группа для простых пользователей'),
ALTER TABLE `roles` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `id` (`id`);
ALTER TABLE `d_roles` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `id` (`id`);
+5 -5
View File
@@ -1,9 +1,9 @@
CREATE TABLE if not exists `user_roles` (
CREATE TABLE if not exists `d_user_roles` (
`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`role_id` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
) ENGINE=innodb DEFAULT CHARSET=utf8;
INSERT INTO `user_roles` (`id`, `user_id`, `role_id`) VALUES (1, 1, 1),
ALTER TABLE `user_roles` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `id` (`id`);
ALTER TABLE `user_roles` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
INSERT INTO `d_user_roles` (`id`, `user_id`, `role_id`) VALUES (1, 1, 1),
ALTER TABLE `d_user_roles` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `id` (`id`);
ALTER TABLE `d_user_roles` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
+4 -4
View File
@@ -1,7 +1,7 @@
CREATE TABLE if not exists `files` (
CREATE TABLE if not exists `d_files` (
`id` int(11) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`path` text
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
ALTER TABLE `files` ADD PRIMARY KEY (`id`);
ALTER TABLE `files` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;
) ENGINE=innodb DEFAULT CHARSET=utf8;
ALTER TABLE `d_files` ADD PRIMARY KEY (`id`);
ALTER TABLE `d_files` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;
+4 -4
View File
@@ -1,4 +1,4 @@
CREATE TABLE `threads` (
CREATE TABLE `d_threads` (
`id` int(11) NOT NULL,
`active` varchar(1) NOT NULL DEFAULT 'N',
`in_progress` varchar(1) NOT NULL DEFAULT 'N',
@@ -13,6 +13,6 @@ CREATE TABLE `threads` (
`params` text,
`status` varchar(255) DEFAULT NULL,
`response` text
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
ALTER TABLE `threads` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `id` (`id`);
ALTER TABLE `threads` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=78989;
) ENGINE=innodb DEFAULT CHARSET=utf8;
ALTER TABLE `d_threads` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `id` (`id`);
ALTER TABLE `d_threads` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=78989;
+4 -4
View File
@@ -1,4 +1,4 @@
CREATE TABLE if not exists `threads_history` (
CREATE TABLE if not exists `d_threads_history` (
`id` int(11) NOT NULL,
`task_id` int(11) DEFAULT NULL,
`execution_time` varchar(255) DEFAULT NULL,
@@ -10,6 +10,6 @@ CREATE TABLE if not exists `threads_history` (
`params` text,
`status` varchar(255) DEFAULT NULL,
`response` text
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
ALTER TABLE `threads_history` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `id` (`id`);
ALTER TABLE `threads_history` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7946;
) ENGINE=innodb DEFAULT CHARSET=utf8;
ALTER TABLE `d_threads_history` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `id` (`id`);
ALTER TABLE `d_threads_history` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7946;