|
...
|
...
|
@@ -175,16 +175,16 @@ class DomainInfoLogic extends BaseLogic |
|
|
|
$this->fail('自建站服务器无法生成站点');
|
|
|
|
}
|
|
|
|
//域名是否都已经解析
|
|
|
|
if(!$this->check_cname($info['domain'], $serversIpInfo)){
|
|
|
|
if(!check_domain_record($info['domain'], $serversIpInfo)){
|
|
|
|
$this->fail('域名' . $info['domain'] . '未解析至目标服务器');
|
|
|
|
}
|
|
|
|
$domain_301 = '';
|
|
|
|
foreach ($this->param['other_domain']??[] as $other_domain){
|
|
|
|
if($other_domain && substr($other_domain,0,2) != '*.'){
|
|
|
|
if($this->check_a($other_domain,DomainInfo::SERVER_IP_301)){
|
|
|
|
if(check_domain_record($other_domain,['domain'=>'','ip'=>DomainInfo::SERVER_IP_301])){
|
|
|
|
$domain_301 = $other_domain;
|
|
|
|
}else{
|
|
|
|
if(!$this->check_cname($other_domain, $serversIpInfo)){
|
|
|
|
if(!check_domain_record($other_domain, $serversIpInfo)){
|
|
|
|
$this->fail('域名' . $other_domain . '未解析至目标服务器');
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -202,7 +202,7 @@ class DomainInfoLogic extends BaseLogic |
|
|
|
$host_array[0] = 'm';
|
|
|
|
}
|
|
|
|
$amp_domain = implode('.',$host_array);
|
|
|
|
if(!$this->check_cname($amp_domain, $serversIpInfo)){
|
|
|
|
if(!check_domain_record($amp_domain, $serversIpInfo)){
|
|
|
|
$this->fail('AMP站点域名' . $amp_domain . '未解析至目标服务器');
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -286,64 +286,6 @@ class DomainInfoLogic extends BaseLogic |
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 验证是否cname或者A记录解析到目标服务器
|
|
|
|
* @param $domain
|
|
|
|
* @param $server_info
|
|
|
|
* @return mixed
|
|
|
|
* @author zbj
|
|
|
|
* @date 2023/11/13
|
|
|
|
*/
|
|
|
|
public function check_cname($domain, $server_info){
|
|
|
|
$process = new Process(['nslookup', '-qt=a', $domain]);
|
|
|
|
$process->run();
|
|
|
|
$output = explode(PHP_EOL, $process->getOutput());
|
|
|
|
foreach ($output as $line){
|
|
|
|
if($line){
|
|
|
|
$checkA = strpos($line, $server_info['ip']) !== false;
|
|
|
|
if($checkA){
|
|
|
|
return $domain;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//是否cname
|
|
|
|
$process = new Process(['nslookup', '-qt=cname', $domain]);
|
|
|
|
$process->run();
|
|
|
|
$output = explode(PHP_EOL, $process->getOutput());
|
|
|
|
foreach ($output as $line){
|
|
|
|
if($line){
|
|
|
|
$checkCname = (strpos($line, $server_info['domain']) !== false);
|
|
|
|
if($checkCname){
|
|
|
|
return $domain;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 验证是否A记录解析到目标服务器
|
|
|
|
* @param $domain
|
|
|
|
* @param $ip
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function check_a($domain, $ip){
|
|
|
|
$process = new Process(['nslookup', '-qt=a', $domain]);
|
|
|
|
$process->run();
|
|
|
|
$output = explode(PHP_EOL, $process->getOutput());
|
|
|
|
foreach ($output as $line){
|
|
|
|
if($line){
|
|
|
|
$checkA = strpos($line, $ip) !== false;
|
|
|
|
if($checkA){
|
|
|
|
return $domain;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 设置语种自定义跳转链接
|
|
|
|
* @param $project_id
|
|
...
|
...
|
@@ -386,7 +328,7 @@ class DomainInfoLogic extends BaseLogic |
|
|
|
if($has_info && ($has_info['project_id'] != $project_id || $has_info['language_id'] != $this->param['language_id'])){
|
|
|
|
$this->fail('自定义域名已被使用');
|
|
|
|
}
|
|
|
|
if(!$this->check_cname($this->param['custom_domain'], $serversIpInfo)){
|
|
|
|
if(!check_domain_record($this->param['custom_domain'], $serversIpInfo)){
|
|
|
|
$this->fail('域名' . $this->param['custom_domain'] . '未解析至目标服务器');
|
|
|
|
}
|
|
|
|
}else{
|
...
|
...
|
|