|
...
|
...
|
@@ -11,6 +11,7 @@ namespace App\Http\Logic\Bside\SeoSetting; |
|
|
|
|
|
|
|
use App\Http\Logic\Bside\BaseLogic;
|
|
|
|
use App\Models\SeoSetting\LinkData;
|
|
|
|
use App\Services\Geo\GeoService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取外链数据
|
|
...
|
...
|
@@ -50,4 +51,64 @@ class LinkDataLogic extends BaseLogic |
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :返回数据data
|
|
|
|
* @name :daResultData
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/10/9 09:43
|
|
|
|
*/
|
|
|
|
public function daResultData()
|
|
|
|
{
|
|
|
|
$info = $this->model->read(['id'=>$this->param['id']]);
|
|
|
|
if($info === false){
|
|
|
|
$this->fail('当前数据不存在或者已被删除');
|
|
|
|
}
|
|
|
|
$geoService = new GeoService();
|
|
|
|
if(!empty($info['time'])){
|
|
|
|
$date1 = new DateTime($info['time']);
|
|
|
|
$date2 = new DateTime(date('Y-m-d'));
|
|
|
|
$diff = $date1->diff($date2);
|
|
|
|
if($diff >= 60){
|
|
|
|
$host = $this->getDomainWithWWW($info['da_values']);
|
|
|
|
$result = $geoService->daResult($host);
|
|
|
|
}else{
|
|
|
|
return $this->success($info);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$host = $this->getDomainWithWWW($info['da_values']);
|
|
|
|
$result = $geoService->daResult($host);
|
|
|
|
}
|
|
|
|
if(!isset($result['data']) || empty($result['data'])){
|
|
|
|
$this->model->edit(['time'=>date('Y-m-d')], ['id'=>$info['id']]);
|
|
|
|
return $this->success($info);
|
|
|
|
}
|
|
|
|
$info['da_values'] = (int)$result['data']['mozDA'];//获取数据中的da值
|
|
|
|
$this->model->edit(['time'=>date('Y-m-d'),'da_values'=>$info['da_values']], ['id'=>$info['id']]);
|
|
|
|
return $this->success($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取域名
|
|
|
|
* @name :getDomainWithWWW
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/10/9 10:28
|
|
|
|
*/
|
|
|
|
public function getDomainWithWWW($url) {
|
|
|
|
// 获取 host
|
|
|
|
$host = parse_url($url, PHP_URL_HOST);
|
|
|
|
// 去掉端口号等情况
|
|
|
|
$host = preg_replace('/:\d+$/', '', $host);
|
|
|
|
// 分割域名
|
|
|
|
$parts = explode('.', $host);
|
|
|
|
// 判断是几段
|
|
|
|
$count = count($parts);
|
|
|
|
// 如果只有两段,比如 fox8.com、theamericawatch.com,就拼接 www.
|
|
|
|
if ($count === 2) {
|
|
|
|
return 'www.' . $host;
|
|
|
|
}
|
|
|
|
return $host;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|