作者 刘锟

白帽-二级域名绑定改版

... ... @@ -36,26 +36,31 @@ class DomainSettingLogic extends BaseLogic
*/
public function infoDomain()
{
$domain = $record = '';
$domain_info = $this->model->read(['project_id' => $this->user['project_id']], ['seo_domain']);
if (isset($domain_info['seo_domain']) && $domain_info['seo_domain']) {
//已经绑定了主域名
$domain = $domain_info['seo_domain'];
//获取域名解析
$project_model = new Project();
$project_info = $project_model->read(['id' => $this->user['project_id']], ['serve_id']);
if ($project_info) {
$server_model = new ServersIp();
$record_info = $server_model->read(['id' => $project_info['serve_id']], ['domain']);
$record = $record_info ? $record_info['domain'] : '';
$domain_info = $this->model->read(['project_id' => $this->user['project_id']], ['seo_type', 'seo_domain', 'seo_ftp']);
$domain = $domain_info['seo_domain'] ?: '';
$ftp = $domain_info['seo_ftp'] ? json_decode($domain['seo_ftp'], true) : null;
$type = $domain_info['seo_type'] ?: 1;
$record = '';
if ($type == WebSetting::SEO_TYPE_PUBLIC) {
//公共服务器
if ($domain) {
//已经绑定了主域名,获取域名解析
$project_model = new Project();
$project_info = $project_model->read(['id' => $this->user['project_id']], ['serve_id']);
if ($project_info) {
$server_model = new ServersIp();
$record_info = $server_model->read(['id' => $project_info['serve_id']], ['domain']);
$record = $record_info ? $record_info['domain'] : '';
}
} else {
//未绑定主域名,分配域名解析
$record = Servers::where('init_domain', 'like', 'seo%')->where('being_number', '<', 10)->orderBy('being_number', 'desc')->orderBy('id', 'asc')->value('init_domain') ?? '';
}
} else {
//未绑定主域名
$record = Servers::where('init_domain', 'like', 'seo%')->where('being_number', '<', 10)->orderBy('being_number', 'desc')->orderBy('id', 'asc')->value('init_domain') ?? '';
}
return ['domain' => $domain, 'record' => $record];
return ['type' => $type, 'domain' => $domain, 'record' => $record, 'ftp' => $ftp];
}
/**
... ...
... ... @@ -20,6 +20,9 @@ class WebSetting extends Base
public static $okStatus = 200;
public static $errStatus = 500;
const SEO_TYPE_PUBLIC = 1;
const SEO_TYPE_OWN = 2;
/**
* 网站设置
*/
... ...