From 7c07467792b4cad5fba028c120889b202a937528 Mon Sep 17 00:00:00 2001 From: Aleksey Filippov Date: Fri, 28 Mar 2025 11:27:49 +0300 Subject: [PATCH] =?utf8?q?=D0=BE=D1=82=D0=BB=D0=B0=D0=B4=D0=BA=D0=B0=20?= =?utf8?q?=D0=BF=D1=83=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../controllers/NotificationController.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/erp24/media/controllers/NotificationController.php b/erp24/media/controllers/NotificationController.php index 3b9cf8e3..65c5e94e 100644 --- a/erp24/media/controllers/NotificationController.php +++ b/erp24/media/controllers/NotificationController.php @@ -27,6 +27,11 @@ class NotificationController extends Controller //"/www/media/notification"; "/var/www/erp24/media/notification"; + private static function getPathNotification() + { + return self::getPath() . "/notification"; + } + private static function getPath() { return dirname(__DIR__, 1); @@ -90,11 +95,11 @@ class NotificationController extends Controller */ $rawBody = Yii::$app->request->getRawBody(); - if (!is_dir(self::OUT_DIR)) { - mkdir(self::OUT_DIR, 0777, true); + if (!is_dir(self::getPathNotification())) { + mkdir(self::getPathNotification(), 0777, true); } file_put_contents( - self::OUT_DIR . '/notifications.txt', + self::getPathNotification() . '/notifications.txt', PHP_EOL . date('Y-m-d H:i:s') . ' ' . $rawBody, FILE_APPEND ); @@ -104,7 +109,7 @@ class NotificationController extends Controller Yii::error("Ошибка декодирования JSON: " . $e->getMessage()); Yii::$app->response->statusCode = 400; file_put_contents( - self::getPath() . '/notification_error.txt', + self::getPathNotification() . '/notification_error.txt', PHP_EOL . date("d.m.Y H:i:s", time()) . " " . $e->getMessage() . $e->getLine(), FILE_APPEND ); @@ -323,7 +328,7 @@ class NotificationController extends Controller } catch (\Exception $e) { Yii::$app->response->statusCode = 400; file_put_contents( - self::OUT_DIR . '/notification_error.txt', + self::getPathNotification() . '/notification_error.txt', PHP_EOL . date("d.m.Y H:i:s", time()) . $e->getMessage() . $e->getLine(), FILE_APPEND ); @@ -382,7 +387,7 @@ class NotificationController extends Controller default: Yii::info("Неизвестный тип события: {$eventType}"); file_put_contents( - self::OUT_DIR . '/notification_error.txt', + self::getPathNotification() . '/notification_error.txt', PHP_EOL . date("d.m.Y H:i:s", time()) . " Неизвестный тип события: {$eventType}", FILE_APPEND ); @@ -394,7 +399,7 @@ class NotificationController extends Controller } catch (\Exception $e) { Yii::error("Error processing event {$eventType}: " . $e->getMessage()); file_put_contents( - self::OUT_DIR . '/notification_error.txt', + self::getPathNotification() . '/notification_error.txt', PHP_EOL . date("d.m.Y H:i:s", time()) . $e->getMessage() . $e->getLine(), FILE_APPEND ); -- 2.39.5