]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Обработка адресов и переименование в index
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 24 Feb 2025 14:52:15 +0000 (17:52 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 24 Feb 2025 14:52:15 +0000 (17:52 +0300)
erp24/media/controllers/NotificationController.php

index 69fe1f2eedec9b6368b379d2374814a5be05d872..b3a4fd6332cc92cf42b2be0099418da8a2ee2c42 100644 (file)
@@ -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')
                     ]);