From d492c5ebf9a1a3a6e6027da076452f11fab6aa81 Mon Sep 17 00:00:00 2001 From: Vladimir Fomichev Date: Fri, 12 Sep 2025 15:36:16 +0300 Subject: [PATCH] =?utf8?q?=D0=9E=D1=82=D0=B4=D0=B0=D1=87=D0=B0=20=D1=84?= =?utf8?q?=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/media/config/media.config.php | 2 +- erp24/media/controllers/FlowwowController.php | 25 ++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/erp24/media/config/media.config.php b/erp24/media/config/media.config.php index f4b3eba9..38dba6ff 100644 --- a/erp24/media/config/media.config.php +++ b/erp24/media/config/media.config.php @@ -97,7 +97,7 @@ return [ '@npm' => '@vendor/npm-asset', '@dist' => '@app/dist', '@uploads' => "@yii_app/uploads", - '@feeds' => '@app/media/feeds', + '@feeds' => '@app/feeds', ], 'params' => require dirname(__DIR__, 2) . '/config/params.php', 'timeZone' => 'Europe/Moscow', diff --git a/erp24/media/controllers/FlowwowController.php b/erp24/media/controllers/FlowwowController.php index 18d2db5c..04b0d076 100644 --- a/erp24/media/controllers/FlowwowController.php +++ b/erp24/media/controllers/FlowwowController.php @@ -27,14 +27,27 @@ class FlowwowController extends Controller */ public function actionFeed($id) { - $dir = Yii::getAlias('@feeds'); - $matches = glob($dir . DIRECTORY_SEPARATOR . "feed_{$id}.xml") ?: []; - if (!$matches) { - throw new \yii\web\NotFoundHttpException('Фид ещё не сгенерирован'); } + $id = (int)$id; + + $dir = Yii::getAlias('@feeds'); + $path = $dir . DIRECTORY_SEPARATOR . "feed_{$id}.xml"; + + if (!is_file($path)) { + Yii::error([ + 'msg' => 'feed not found', + 'alias' => '@feeds', + 'dir' => $dir, + 'dirReal' => @realpath($dir), + 'path' => $path, + 'exists' => file_exists($path), + ], __METHOD__); + + throw new \yii\web\NotFoundHttpException('Фид ещё не сгенерирован' . $dir); + } - return Yii::$app->response->sendFile($matches[0], basename($matches[0]), [ + return Yii::$app->response->sendFile($path, "feed_{$id}.xml", [ 'mimeType' => 'application/xml; charset=utf-8', - 'inline' => true, + 'inline' => true, ]); } -- 2.39.5