From: fomichev Date: Mon, 24 Feb 2025 14:52:15 +0000 (+0300) Subject: Обработка адресов и переименование в index X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=6e4344b73e69d091481e11805649757f230a9f81;p=erp24_rep%2Fyii-erp24%2F.git Обработка адресов и переименование в index --- diff --git a/erp24/media/controllers/NotificationController.php b/erp24/media/controllers/NotificationController.php index 69fe1f2e..b3a4fd63 100644 --- a/erp24/media/controllers/NotificationController.php +++ b/erp24/media/controllers/NotificationController.php @@ -27,12 +27,39 @@ class NotificationController extends Controller return ['ok']; } - public function actionNotification() + public function actionIndex() { if (!Yii::$app->request->isPost) { throw new BadRequestHttpException('Только POST запросы разрешены'); } + /*$requestIp = Yii::$app->request->userIP; + $ipLong = ip2long($requestIp); + + $allowedRanges = [ + ['start' => ip2long('5.45.207.0'), 'end' => ip2long('5.45.207.127')], + ['start' => ip2long('141.8.142.0'), 'end' => ip2long('141.8.142.127')], + ['start' => ip2long('5.255.253.0'), 'end' => ip2long('5.255.253.127')], + ]; + + $allowed = false; + foreach ($allowedRanges as $range) { + if ($ipLong >= $range['start'] && $ipLong <= $range['end']) { + $allowed = true; + break; + } + } + + if (!$allowed) { + Yii::$app->response->statusCode = 403; + return $this->asJson([ + 'error' => [ + 'type' => 'FORBIDDEN', + 'message' => 'Доступ запрещен' + ] + ]); + }*/ + $rawBody = Yii::$app->request->getRawBody(); try { $data = Json::decode($rawBody); @@ -63,7 +90,7 @@ class NotificationController extends Controller switch ($eventType) { case 'PING': return $this->asJson([ - 'version' => '1', + 'version' => '1.0.0', 'name' => 'БазаЦветов24', 'timestamp' => date('Y-m-d H:i:s') ]);