作者 刘锟

白帽-二级域名绑定改版

@@ -36,26 +36,31 @@ class DomainSettingLogic extends BaseLogic @@ -36,26 +36,31 @@ class DomainSettingLogic extends BaseLogic
36 */ 36 */
37 public function infoDomain() 37 public function infoDomain()
38 { 38 {
39 - $domain = $record = '';  
40 - $domain_info = $this->model->read(['project_id' => $this->user['project_id']], ['seo_domain']);  
41 - if (isset($domain_info['seo_domain']) && $domain_info['seo_domain']) {  
42 - //已经绑定了主域名  
43 - $domain = $domain_info['seo_domain'];  
44 - //获取域名解析  
45 - $project_model = new Project();  
46 - $project_info = $project_model->read(['id' => $this->user['project_id']], ['serve_id']);  
47 -  
48 - if ($project_info) {  
49 - $server_model = new ServersIp();  
50 - $record_info = $server_model->read(['id' => $project_info['serve_id']], ['domain']);  
51 - $record = $record_info ? $record_info['domain'] : ''; 39 + $domain_info = $this->model->read(['project_id' => $this->user['project_id']], ['seo_type', 'seo_domain', 'seo_ftp']);
  40 + $domain = $domain_info['seo_domain'] ?: '';
  41 + $ftp = $domain_info['seo_ftp'] ? json_decode($domain['seo_ftp'], true) : null;
  42 + $type = $domain_info['seo_type'] ?: 1;
  43 + $record = '';
  44 +
  45 + if ($type == WebSetting::SEO_TYPE_PUBLIC) {
  46 + //公共服务器
  47 + if ($domain) {
  48 + //已经绑定了主域名,获取域名解析
  49 + $project_model = new Project();
  50 + $project_info = $project_model->read(['id' => $this->user['project_id']], ['serve_id']);
  51 +
  52 + if ($project_info) {
  53 + $server_model = new ServersIp();
  54 + $record_info = $server_model->read(['id' => $project_info['serve_id']], ['domain']);
  55 + $record = $record_info ? $record_info['domain'] : '';
  56 + }
  57 + } else {
  58 + //未绑定主域名,分配域名解析
  59 + $record = Servers::where('init_domain', 'like', 'seo%')->where('being_number', '<', 10)->orderBy('being_number', 'desc')->orderBy('id', 'asc')->value('init_domain') ?? '';
52 } 60 }
53 - } else {  
54 - //未绑定主域名  
55 - $record = Servers::where('init_domain', 'like', 'seo%')->where('being_number', '<', 10)->orderBy('being_number', 'desc')->orderBy('id', 'asc')->value('init_domain') ?? '';  
56 } 61 }
57 62
58 - return ['domain' => $domain, 'record' => $record]; 63 + return ['type' => $type, 'domain' => $domain, 'record' => $record, 'ftp' => $ftp];
59 } 64 }
60 65
61 /** 66 /**
@@ -20,6 +20,9 @@ class WebSetting extends Base @@ -20,6 +20,9 @@ class WebSetting extends Base
20 public static $okStatus = 200; 20 public static $okStatus = 200;
21 public static $errStatus = 500; 21 public static $errStatus = 500;
22 22
  23 + const SEO_TYPE_PUBLIC = 1;
  24 + const SEO_TYPE_OWN = 2;
  25 +
23 /** 26 /**
24 * 网站设置 27 * 网站设置
25 */ 28 */