作者 刘锟

合并分支 'akun' 到 'master'

Akun



查看合并请求 !2421
... ... @@ -1087,13 +1087,19 @@ if (!function_exists('check_domain_record')) {
if(!$is_record){
//解析不正确,再判断是否开启cnd
$cnd = curlGet('http://sitebak.globalso.com/get_records?domain=' . $domain);
$top_domain = getTopDomain($domain);
$cnd = curlGet('http://sitebak.globalso.com/get_records?domain=' . $top_domain);
if (isset($cnd['data']) && $cnd['data']) {
if($domain == $top_domain || substr($domain,0,4) == 'www.'){
$check_domain = $domain;
}else{
$check_domain = '*.'.$domain;
}
foreach ($cnd['data'] as $vc) {
if ($vc['type'] == 'A' && $vc['content'] == $server_info['ip']) {
if ($vc['name'] == $check_domain && $vc['type'] == 'A' && $vc['content'] == $server_info['ip']) {
$is_record = true;
break;
}elseif ($vc['type'] == 'CNAME' && $vc['content'] == $server_info['domain']){
}elseif ($vc['name'] == $check_domain && $vc['type'] == 'CNAME' && $vc['content'] == $server_info['domain']){
$is_record = true;
break;
}
... ... @@ -1388,3 +1394,30 @@ function analysisRoute($pathInfo)
return $router;
}
function getTopDomain ($url) {
$url = strtolower($url); //首先转成小写
$url = mb_ereg_replace('^( | )+', '', trim($url));
$url = mb_ereg_replace('( | )+$', '', $url);
if (!preg_match('/^(http:\/\/|https)/', $url)) {
$url = "https://".$url;
}
$hosts = parse_url($url);
$host = $hosts['host'] ?? '';
//查看是几级域名
$data = explode('.', $host);
$n = count($data);
if ($n < 2) {
return $host;
}
//判断是否是双后缀
$preg = '/[\w].+\.(com|net|org|gov|edu|co|ne)\.[\w]/';
if (($n > 2) && preg_match($preg, $host)) {
//双后缀取后3位
$host = $data[$n - 3].'.'.$data[$n - 2].'.'.$data[$n - 1];
} else {
//非双后缀取后两位
$host = $data[$n - 2].'.'.$data[$n - 1];
}
return $host;
}
... ...