rkljw 1 dzień temu
rodzic
commit
f143e73fd8
1 zmienionych plików z 4 dodań i 3 usunięć
  1. 4 3
      app/Controller/PublicController.php

+ 4 - 3
app/Controller/PublicController.php

@@ -1325,9 +1325,10 @@ class PublicController extends AbstractController
      */
     public function getIpInfo()
     {
-        $comm = new CommonService();
-        $ip = $comm->userIp();
-        $result = $this->publicServiceClient->getIpInfo(['id'=>$ip]);
+
+        $ip = $this->request->getHeader('x-forwarded-for')[0] ?? $this->request->getHeader('x-real-ip')[0] ?? $this->request->getServerParams()['remote_addr'] ?? '0.0.0.0';
+        var_dump("========",$ip);
+        $result = $this->publicServiceClient->getIpInfo(['ip'=>$ip]);
         var_dump("========",$result);
         return $result['code'] == 200 ? Result::success($result['data']) : Result::error($result['message']);
     }