作者 刘锟

update

... ... @@ -37,7 +37,7 @@ class Temp extends Command
public function handle()
{
$this->check_no_cname_projects();
$this->check_cname_projects();
}
/**
... ... @@ -425,6 +425,58 @@ class Temp extends Command
}
}
/**
* 检查服务器上解析cname的项目
* @author Akun
* @date 2025/02/17 14:21
*/
public function check_cname_projects()
{
$server_id = 1;
$server_name = '硅谷云服务器';
$server_ip_model = new ServersIp();
$server_ip_ids = $server_ip_model->where('servers_id', $server_id)->get()->pluck('id')->toArray();
$project_list = Project::select(['id', 'serve_id', 'title'])->whereIn('serve_id', $server_ip_ids)->get();
$domain_model = new DomainInfo();
$data = [];
foreach ($project_list as $value) {
$domain_info = $domain_model->read(['project_id' => $value->id, 'status' => 1], ['id', 'domain']);
if (!$domain_info) {
//过滤未绑定正式域名的项目
continue;
}
$domain = $domain_info['domain'];
$check = dns_get_record($domain, DNS_A);
$ip = $check[0]['ip'] ?? '';
$host = $check[0]['host'] ?? '';
if ($host == 'cname.globalso.com') {
$data[] = [
$value->id,
$value->title,
$domain,
$ip
];
}
}
$map = ['项目id', '名称', '域名', '解析IP'];
if ($data) {
$table = new BatchExportService($server_name . '解析cname的项目');
$file = $table->head($map)->data($data)->save();
if (!$file) {
$this->output('文件生成失败,请重试');
} else {
$this->output('export success');
}
} else {
$this->output('no data');
}
}
/**
* 检查不在所属服务器解析上的域名
... ...