作者 lyh

变更数据

@@ -73,7 +73,7 @@ class lyhDemo extends Command @@ -73,7 +73,7 @@ class lyhDemo extends Command
73 $host = $this->getDomainWithWWW($info['url']); 73 $host = $this->getDomainWithWWW($info['url']);
74 $result = $geoService->daResult($host); 74 $result = $geoService->daResult($host);
75 }else{ 75 }else{
76 - return $this->success($info); 76 + continue;
77 } 77 }
78 }else{ 78 }else{
79 $host = $this->getDomainWithWWW($info['url']); 79 $host = $this->getDomainWithWWW($info['url']);
@@ -81,13 +81,29 @@ class lyhDemo extends Command @@ -81,13 +81,29 @@ class lyhDemo extends Command
81 } 81 }
82 if(!isset($result['data']) || empty($result['data'])){ 82 if(!isset($result['data']) || empty($result['data'])){
83 $this->model->edit(['time'=>date('Y-m-d')], ['id'=>$info['id']]); 83 $this->model->edit(['time'=>date('Y-m-d')], ['id'=>$info['id']]);
84 - return $this->success($info); 84 + continue;
85 } 85 }
86 $info['da'] = (int)$result['data']['mozDA'];//获取数据中的da值 86 $info['da'] = (int)$result['data']['mozDA'];//获取数据中的da值
87 $this->model->edit(['time'=>date('Y-m-d'),'da'=>$info['da']], ['id'=>$info['id']]); 87 $this->model->edit(['time'=>date('Y-m-d'),'da'=>$info['da']], ['id'=>$info['id']]);
88 } 88 }
89 } 89 }
90 90
  91 + public function getDomainWithWWW($url) {
  92 + // 获取 host
  93 + $host = parse_url($url, PHP_URL_HOST);
  94 + // 去掉端口号等情况
  95 + $host = preg_replace('/:\d+$/', '', $host);
  96 + // 分割域名
  97 + $parts = explode('.', $host);
  98 + // 判断是几段
  99 + $count = count($parts);
  100 + // 如果只有两段,比如 fox8.com、theamericawatch.com,就拼接 www.
  101 + if ($count === 2) {
  102 + return 'www.' . $host;
  103 + }
  104 + return $host;
  105 + }
  106 +
91 /** 107 /**
92 * @remark :查看路由是否为空 108 * @remark :查看路由是否为空
93 * @name :_actionRoute 109 * @name :_actionRoute