cqpCow 1 年之前
父节点
当前提交
abc8499868
共有 3 个文件被更改,包括 17 次插入1 次删除
  1. 4 0
      app/Service/FyyOrderService.php
  2. 1 1
      app/Service/FyySqlServerService.php
  3. 12 0
      app/Service/Service.php

+ 4 - 0
app/Service/FyyOrderService.php

@@ -443,6 +443,10 @@ class FyyOrderService extends Service
         $sqlServerModel = new FyySqlServerService($user);
         if($sqlServerModel->error) return [false,$sqlServerModel->error];
 
+        //映射ip是否通畅
+        $bool = $this->isDomainAvailable($sqlServerModel->host);
+        if(! $bool) return [false, "U8程序外部域名不可达,请重新操作"];
+
         $result = $sqlServerModel->getDataFromDispatchListPage($data);
 
         return [true,$result];

+ 1 - 1
app/Service/FyySqlServerService.php

@@ -17,7 +17,7 @@ class FyySqlServerService extends Service
     public $error = null;
     public $host = "s6j9560970.goho.co";//数据库外网域名
     public $host_api = 'https://s6j9560970.goho.co:443';//用友接口外网域名
-    public $port = 29703;
+    public $port = 44773;
     public $database = "UFDATA_999_2023";
     public $url = "";
     public $sAccID = "(default)@999";

+ 12 - 0
app/Service/Service.php

@@ -272,4 +272,16 @@ class Service
 
         return [false,'操作频繁, 请在 ' . $ttl . '秒后重试'];
     }
+
+    // 校验域名是否通畅可达
+    // $domain baidu.com 不要带http这些协议头
+    // gethostbyname() 函数可能会受到 PHP 配置中的 allow_url_fopen 和 disable_functions 选项的限制
+    function isDomainAvailable($domain) {
+        $ip = gethostbyname($domain);
+
+        // 如果解析失败或者返回的 IP 地址与输入的域名相同,则说明域名无效
+        if ($ip === $domain || filter_var($ip, FILTER_VALIDATE_IP) === false)  return false;
+
+        return true;
+    }
 }