作者 赵彬吉
@@ -35,7 +35,7 @@ class CreateSite extends Command @@ -35,7 +35,7 @@ class CreateSite extends Command
35 if ($task) { 35 if ($task) {
36 $model->edit(['status' => DomainCreateTask::STATUS_ING], ['id' => $task['id']]); 36 $model->edit(['status' => DomainCreateTask::STATUS_ING], ['id' => $task['id']]);
37 37
38 - $re = $this->editDomainBt($task['domain_id']); 38 + $re = $this->editDomainBt($task['domain_id'], $task['type']);
39 39
40 if (is_array($re)) { 40 if (is_array($re)) {
41 $model->edit(['status' => DomainCreateTask::STATUS_FAL, 'error_msg' => $re[1]], ['id' => $task['id']]); 41 $model->edit(['status' => DomainCreateTask::STATUS_FAL, 'error_msg' => $re[1]], ['id' => $task['id']]);
@@ -45,7 +45,7 @@ class CreateSite extends Command @@ -45,7 +45,7 @@ class CreateSite extends Command
45 } 45 }
46 } 46 }
47 47
48 - protected function editDomainBt($domain_id) 48 + protected function editDomainBt($domain_id, $type)
49 { 49 {
50 //获取域名数据 50 //获取域名数据
51 $domain_model = new DomainInfo(); 51 $domain_model = new DomainInfo();
@@ -73,69 +73,71 @@ class CreateSite extends Command @@ -73,69 +73,71 @@ class CreateSite extends Command
73 return [false, '获取服务器数据失败2']; 73 return [false, '获取服务器数据失败2'];
74 } 74 }
75 75
76 - /*****************编辑主站*******************/  
77 - if ($domain_info['type'] == 2) {  
78 - $api_url = 'http://' . $serverInfo['init_domain'] . '/api/setSsl';  
79 - $api_param = [  
80 - 'domain' => $domain_info['domain'],  
81 - 'private_key' => $domain_info['private_key'],  
82 - 'cert' => $domain_info['private_cert'],  
83 - 'rewrite' => $domain_info['extend_config'],  
84 - 'other_domain' => $domain_info['other_domain'],  
85 - 'is_https' => $domain_info['is_https'],  
86 - 'not_allow_country' => $domain_info['not_allow_country'],  
87 - 'not_allow_ip' => $domain_info['not_allow_ip'],  
88 - 'is_redirect' => $domain_info['is_redirect']  
89 - ];  
90 - } else {  
91 - $api_url = 'http://' . $serverInfo['init_domain'] . '/api/applySsl';  
92 - $api_param = [  
93 - 'domain' => $domain_info['domain'],  
94 - 'rewrite' => $domain_info['extend_config'],  
95 - 'other_domain' => $domain_info['other_domain'],  
96 - 'is_https' => $domain_info['is_https'],  
97 - 'not_allow_country' => $domain_info['not_allow_country'],  
98 - 'not_allow_ip' => $domain_info['not_allow_ip'],  
99 - 'is_redirect' => $domain_info['is_redirect']  
100 - ];  
101 - }  
102 -  
103 - try {  
104 - $rs = HttpUtils::get($api_url, $api_param);  
105 - $rs = json_decode($rs, true);  
106 - if (isset($rs['status']) && $rs['status'] == 200) {  
107 - $this->output($domain_info['domain'] . ',主站创建成功'); 76 + if ($type == 1) {
  77 + /*****************编辑主站*******************/
  78 + if ($domain_info['type'] == 2) {
  79 + $api_url = 'http://' . $serverInfo['init_domain'] . '/api/setSsl';
  80 + $api_param = [
  81 + 'domain' => $domain_info['domain'],
  82 + 'private_key' => $domain_info['private_key'],
  83 + 'cert' => $domain_info['private_cert'],
  84 + 'rewrite' => $domain_info['extend_config'],
  85 + 'other_domain' => $domain_info['other_domain'],
  86 + 'is_https' => $domain_info['is_https'],
  87 + 'not_allow_country' => $domain_info['not_allow_country'],
  88 + 'not_allow_ip' => $domain_info['not_allow_ip'],
  89 + 'is_redirect' => $domain_info['is_redirect']
  90 + ];
108 } else { 91 } else {
109 - return [false, '主站:' . ($rs['message'] ?? '未知错误')];  
110 - }  
111 - } catch (\Exception | GuzzleException $e) {  
112 - return [false, '主站:' . $e->getMessage()];  
113 - }  
114 -  
115 - /*****************编辑amp站*******************/  
116 - if ($domain_info['amp_status']) {  
117 - $api_url_amp = 'http://' . $serverInfo['init_domain'] . '/api/createSiteAmp';  
118 - $api_param_amp = [  
119 - 'domain' => $domain_info['domain'],  
120 - 'not_allow_country' => $domain_info['not_allow_country'],  
121 - 'not_allow_ip' => $domain_info['not_allow_ip'],  
122 - 'is_redirect' => $domain_info['is_redirect']  
123 - ];  
124 - if ($domain_info['amp_type'] == 2) {  
125 - $api_param_amp['private_key'] = $domain_info['amp_private_key'];  
126 - $api_param_amp['cert'] = $domain_info['amp_private_cert']; 92 + $api_url = 'http://' . $serverInfo['init_domain'] . '/api/applySsl';
  93 + $api_param = [
  94 + 'domain' => $domain_info['domain'],
  95 + 'rewrite' => $domain_info['extend_config'],
  96 + 'other_domain' => $domain_info['other_domain'],
  97 + 'is_https' => $domain_info['is_https'],
  98 + 'not_allow_country' => $domain_info['not_allow_country'],
  99 + 'not_allow_ip' => $domain_info['not_allow_ip'],
  100 + 'is_redirect' => $domain_info['is_redirect']
  101 + ];
127 } 102 }
128 103
129 try { 104 try {
130 - $rs_amp = HttpUtils::get($api_url_amp, $api_param_amp);  
131 - $rs_amp = json_decode($rs_amp, true);  
132 - if (isset($rs_amp['status']) && $rs_amp['status'] == 200) {  
133 - $this->output($domain_info['domain'] . ',amp站创建成功'); 105 + $rs = HttpUtils::get($api_url, $api_param, [], 180);
  106 + $rs = json_decode($rs, true);
  107 + if (isset($rs['status']) && $rs['status'] == 200) {
  108 + $this->output($domain_info['domain'] . ',主站创建成功');
134 } else { 109 } else {
135 - return [false, 'amp站:' . ($rs['message'] ?? '未知错误')]; 110 + return [false, $rs['message'] ?? '未知错误'];
  111 + }
  112 + } catch (\Exception | GuzzleException $e) {
  113 + return [false, $e->getMessage()];
  114 + }
  115 + } else {
  116 + /*****************编辑amp站*******************/
  117 + if ($domain_info['amp_status']) {
  118 + $api_url_amp = 'http://' . $serverInfo['init_domain'] . '/api/createSiteAmp';
  119 + $api_param_amp = [
  120 + 'domain' => $domain_info['domain'],
  121 + 'not_allow_country' => $domain_info['not_allow_country'],
  122 + 'not_allow_ip' => $domain_info['not_allow_ip'],
  123 + 'is_redirect' => $domain_info['is_redirect']
  124 + ];
  125 + if ($domain_info['amp_type'] == 2) {
  126 + $api_param_amp['private_key'] = $domain_info['amp_private_key'];
  127 + $api_param_amp['cert'] = $domain_info['amp_private_cert'];
  128 + }
  129 +
  130 + try {
  131 + $rs_amp = HttpUtils::get($api_url_amp, $api_param_amp, [], 180);
  132 + $rs_amp = json_decode($rs_amp, true);
  133 + if (isset($rs_amp['status']) && $rs_amp['status'] == 200) {
  134 + $this->output($domain_info['domain'] . ',amp站创建成功');
  135 + } else {
  136 + return [false, $rs['message'] ?? '未知错误'];
  137 + }
  138 + } catch (\Exception | GuzzleException $e_amp) {
  139 + return [false, $e_amp->getMessage()];
136 } 140 }
137 - } catch (\Exception | GuzzleException $e_amp) {  
138 - return [false, 'amp站:' . $e_amp->getMessage()];  
139 } 141 }
140 } 142 }
141 143
@@ -11,6 +11,7 @@ namespace App\Console\Commands\Domain; @@ -11,6 +11,7 @@ namespace App\Console\Commands\Domain;
11 11
12 use App\Models\Devops\ServerConfig; 12 use App\Models\Devops\ServerConfig;
13 use App\Models\Devops\ServersIp; 13 use App\Models\Devops\ServersIp;
  14 +use App\Models\Domain\DomainCreateTask;
14 use App\Models\Project\CountryCustom; 15 use App\Models\Project\CountryCustom;
15 use App\Models\Project\Project; 16 use App\Models\Project\Project;
16 use Illuminate\Console\Command; 17 use Illuminate\Console\Command;
@@ -42,9 +43,6 @@ class DomainInfo extends Command @@ -42,9 +43,6 @@ class DomainInfo extends Command
42 */ 43 */
43 public function handle() 44 public function handle()
44 { 45 {
45 - //更新主站域名有效时间  
46 - $this->startUpdateDomain();  
47 -  
48 //主站证书到期更新 46 //主站证书到期更新
49 $this->startUpdateCert(); 47 $this->startUpdateCert();
50 48
@@ -58,27 +56,6 @@ class DomainInfo extends Command @@ -58,27 +56,6 @@ class DomainInfo extends Command
58 } 56 }
59 57
60 /** 58 /**
61 - * 更新域名到期时间  
62 - * @author Akun  
63 - * @date 2024/02/26 10:26  
64 - */  
65 - public function startUpdateDomain()  
66 - {  
67 - $domainModel = new DomainInfoModel();  
68 - $list = $domainModel->where('status', '=', 1)->where(function ($query) {  
69 - $query->whereNull('domain_end_time')->orWhere('domain_end_time', '<', date('Y-m-d H:i:s'));  
70 - })->get()->toArray();  
71 - foreach ($list as $v) {  
72 - $time = $this->updateDomain($v['domain']);  
73 - $data = [  
74 - 'domain_start_time' => $time['start'],  
75 - 'domain_end_time' => $time['end']  
76 - ];  
77 - $domainModel->edit($data, ['id' => $v['id']]);  
78 - }  
79 - }  
80 -  
81 - /**  
82 * 主站证书到期更新 59 * 主站证书到期更新
83 * @author Akun 60 * @author Akun
84 * @date 2024/02/26 10:26 61 * @date 2024/02/26 10:26
@@ -88,33 +65,42 @@ class DomainInfo extends Command @@ -88,33 +65,42 @@ class DomainInfo extends Command
88 $domainModel = new DomainInfoModel(); 65 $domainModel = new DomainInfoModel();
89 $projectModel = new Project(); 66 $projectModel = new Project();
90 $serverIpModel = new ServersIp(); 67 $serverIpModel = new ServersIp();
  68 + $domainCreateTaskModel = new DomainCreateTask();
91 $end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期 69 $end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期
92 - $list = $domainModel->where('status', '=', 1)->where(function ($query) use ($end_day) { 70 + $list = $domainModel->where('status', '=', 1)->where('type', 1)->where(function ($query) use ($end_day) {
93 $query->whereNull('certificate_end_time')->orWhere('certificate_end_time', '<', $end_day); 71 $query->whereNull('certificate_end_time')->orWhere('certificate_end_time', '<', $end_day);
94 })->get()->toArray(); 72 })->get()->toArray();
95 foreach ($list as $v) { 73 foreach ($list as $v) {
96 - //更新证书到期时间  
97 - $data = [];  
98 -  
99 - $ssl = $this->updateDomainSsl($v['domain']);  
100 - $ssl['from'] && $data['certificate_start_time'] = $ssl['from'];  
101 - $ssl['to'] && $data['certificate_end_time'] = $ssl['to'];  
102 -  
103 $project_info = $projectModel->read(['id' => $v['project_id']], ['serve_id']); 74 $project_info = $projectModel->read(['id' => $v['project_id']], ['serve_id']);
104 - if ($v['type'] == 1 && $ssl['to'] < $end_day && $project_info) {  
105 - $servers_ip_info = $serverIpModel->read(['id' => $project_info['serve_id']], ['servers_id', 'ip', 'domain']);  
106 - if ($servers_ip_info && $servers_ip_info['servers_id'] != ServerConfig::SELF_SITE_ID && $this->check_cname($v['domain'], $servers_ip_info)) {  
107 - //非自建站项目,申请免费证书  
108 - $this->updatePrivate($v); 75 + if (!$project_info) {
  76 + continue;
  77 + }
109 78
110 - $ssl_new = $this->updateDomainSsl($v['domain']);  
111 - $ssl_new['from'] && $data['certificate_start_time'] = $ssl_new['from'];  
112 - $ssl_new['to'] && $data['certificate_end_time'] = $ssl_new['to'];  
113 - } 79 + $servers_ip_info = $serverIpModel->read(['id' => $project_info['serve_id']], ['servers_id', 'ip', 'domain']);
  80 + if (!$servers_ip_info) {
  81 + continue;
  82 + }
  83 +
  84 + //过滤自建站项目域名
  85 + if ($servers_ip_info['servers_id'] == ServerConfig::SELF_SITE_ID) {
  86 + continue;
  87 + }
114 88
  89 + //过滤已解析到别的ip的域名
  90 + if (!$this->check_cname($v['domain'], $servers_ip_info)) {
  91 + continue;
115 } 92 }
116 93
117 - $domainModel->edit($data, ['id' => $v['id']]); 94 + //创建更新站点证书任务
  95 + $task_info = $domainCreateTaskModel->read(['type' => DomainCreateTask::TYPE_MAIN, 'domain_id' => $v['id'], 'status' => ['<', DomainCreateTask::STATUS_SUC]]);
  96 + if (!$task_info) {
  97 + $domainCreateTaskModel->add([
  98 + 'server_id' => $servers_ip_info['servers_id'],
  99 + 'project_id' => $v['project_id'],
  100 + 'domain_id' => $v['id'],
  101 + 'type' => DomainCreateTask::TYPE_MAIN
  102 + ]);
  103 + }
118 } 104 }
119 } 105 }
120 106
@@ -128,12 +114,12 @@ class DomainInfo extends Command @@ -128,12 +114,12 @@ class DomainInfo extends Command
128 $domainModel = new DomainInfoModel(); 114 $domainModel = new DomainInfoModel();
129 $projectModel = new Project(); 115 $projectModel = new Project();
130 $serverIpModel = new ServersIp(); 116 $serverIpModel = new ServersIp();
  117 + $domainCreateTaskModel = new DomainCreateTask();
131 $end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期 118 $end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期
132 - $list = $domainModel->where('status', '=', 1)->where('amp_status', 1)->where(function ($query) use ($end_day) { 119 + $list = $domainModel->where('status', '=', 1)->where('amp_status', 1)->where('amp_type', 1)->where(function ($query) use ($end_day) {
133 $query->whereNull('amp_certificate_end_time')->orWhere('amp_certificate_end_time', '<', $end_day); 120 $query->whereNull('amp_certificate_end_time')->orWhere('amp_certificate_end_time', '<', $end_day);
134 })->get()->toArray(); 121 })->get()->toArray();
135 foreach ($list as $v) { 122 foreach ($list as $v) {
136 - //更新amp站点证书到期时间  
137 $domain_array = parse_url($v['domain']); 123 $domain_array = parse_url($v['domain']);
138 $host = $domain_array['host'] ?? $domain_array['path']; 124 $host = $domain_array['host'] ?? $domain_array['path'];
139 $host_array = explode('.', $host); 125 $host_array = explode('.', $host);
@@ -144,25 +130,36 @@ class DomainInfo extends Command @@ -144,25 +130,36 @@ class DomainInfo extends Command
144 } 130 }
145 $amp_domain = implode('.', $host_array); 131 $amp_domain = implode('.', $host_array);
146 132
147 - $data = [];  
148 - $ssl = $this->updateDomainSsl($amp_domain);  
149 - $ssl['from'] && $data['amp_certificate_start_time'] = $ssl['from'];  
150 - $ssl['to'] && $data['amp_certificate_end_time'] = $ssl['to'];  
151 -  
152 $project_info = $projectModel->read(['id' => $v['project_id']], ['serve_id']); 133 $project_info = $projectModel->read(['id' => $v['project_id']], ['serve_id']);
153 - if ($v['amp_type'] == 1 && $ssl['to'] < $end_day && $project_info) {  
154 - $servers_ip_info = $serverIpModel->read(['id' => $project_info['serve_id']], ['servers_id', 'ip', 'domain']);  
155 - if ($servers_ip_info && $servers_ip_info['servers_id'] != ServerConfig::SELF_SITE_ID && $this->check_cname($amp_domain, $servers_ip_info)) {  
156 - //非自建站项目,申请免费证书  
157 - $this->updateAmpPrivate($v); 134 + if (!$project_info) {
  135 + continue;
  136 + }
158 137
159 - $ssl_new = $this->updateDomainSsl($amp_domain);  
160 - $ssl_new['from'] && $data['amp_certificate_start_time'] = $ssl_new['from'];  
161 - $ssl_new['to'] && $data['amp_certificate_end_time'] = $ssl_new['to'];  
162 - } 138 + $servers_ip_info = $serverIpModel->read(['id' => $project_info['serve_id']], ['servers_id', 'ip', 'domain']);
  139 + if (!$servers_ip_info) {
  140 + continue;
  141 + }
  142 +
  143 + //过滤自建站项目域名
  144 + if ($servers_ip_info['servers_id'] == ServerConfig::SELF_SITE_ID) {
  145 + continue;
  146 + }
  147 +
  148 + //过滤已解析到别的ip的域名
  149 + if (!$this->check_cname($amp_domain, $servers_ip_info)) {
  150 + continue;
163 } 151 }
164 152
165 - $domainModel->edit($data, ['id' => $v['id']]); 153 + //创建更新站点证书任务
  154 + $task_info = $domainCreateTaskModel->read(['type' => DomainCreateTask::TYPE_AMP, 'domain_id' => $v['id'], 'status' => ['<', DomainCreateTask::STATUS_SUC]]);
  155 + if (!$task_info) {
  156 + $domainCreateTaskModel->add([
  157 + 'server_id' => $servers_ip_info['servers_id'],
  158 + 'project_id' => $v['project_id'],
  159 + 'domain_id' => $v['id'],
  160 + 'type' => DomainCreateTask::TYPE_AMP
  161 + ]);
  162 + }
166 } 163 }
167 } 164 }
168 165
@@ -176,172 +173,43 @@ class DomainInfo extends Command @@ -176,172 +173,43 @@ class DomainInfo extends Command
176 $customModel = new CountryCustom(); 173 $customModel = new CountryCustom();
177 $projectModel = new Project(); 174 $projectModel = new Project();
178 $serverIpModel = new ServersIp(); 175 $serverIpModel = new ServersIp();
  176 + $domainCreateTaskModel = new DomainCreateTask();
179 $end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期 177 $end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期
180 - $list = $customModel->where('status', 1)->where('is_create', 1)->where(function ($query) use ($end_day) { 178 + $list = $customModel->where('status', 1)->where('is_create', 1)->where('type', 1)->where(function ($query) use ($end_day) {
181 $query->whereNull('certificate_end_time')->orWhere('certificate_end_time', '<', $end_day); 179 $query->whereNull('certificate_end_time')->orWhere('certificate_end_time', '<', $end_day);
182 })->get()->toArray(); 180 })->get()->toArray();
183 foreach ($list as $v) { 181 foreach ($list as $v) {
184 - //更新证书到期时间  
185 - $data = [];  
186 - $ssl = $this->updateDomainSsl($v['custom_domain']);  
187 - $ssl['from'] && $data['certificate_start_time'] = $ssl['from'];  
188 - $ssl['to'] && $data['certificate_end_time'] = $ssl['to'];  
189 -  
190 $project_info = $projectModel->read(['id' => $v['project_id']], ['serve_id']); 182 $project_info = $projectModel->read(['id' => $v['project_id']], ['serve_id']);
191 - if ($v['type'] == 1 && $ssl['to'] < $end_day && $project_info) {  
192 - $servers_ip_info = $serverIpModel->read(['id' => $project_info['serve_id']], ['servers_id', 'ip', 'domain']);  
193 - if ($servers_ip_info && $servers_ip_info['servers_id'] != ServerConfig::SELF_SITE_ID && $this->check_cname($v['custom_domain'], $servers_ip_info)) {  
194 - //申请免费证书  
195 - $this->updateCustomPrivate($v['custom_domain']);  
196 -  
197 - $ssl_new = $this->updateDomainSsl($v['domain']);  
198 - $ssl_new['from'] && $data['certificate_start_time'] = $ssl_new['from'];  
199 - $ssl_new['to'] && $data['certificate_end_time'] = $ssl_new['to'];  
200 - } 183 + if (!$project_info) {
  184 + continue;
201 } 185 }
202 186
203 - $customModel->edit($data, ['id' => $v['id']]);  
204 - }  
205 - }  
206 -  
207 - /**  
208 - * @remark :更新主站证书  
209 - * @name :updatePrivate  
210 - * @author :lyh  
211 - * @method :post  
212 - * @time :2023/12/8 16:16  
213 - */  
214 - public function updatePrivate($param)  
215 - {  
216 - $url = 'https://' . $param['domain'] . '/api/applySsl/';  
217 - $param = [  
218 - "domain" => $param['domain'],  
219 - "rewrite" => $param['extend_config'],  
220 - 'other_domain' => $param['other_domain'],  
221 - 'is_https' => $param['is_https'],  
222 - 'not_allow_country' => $param['not_allow_country'],  
223 - 'not_allow_ip' => $param['not_allow_ip'],  
224 - 'is_redirect' => $param['is_redirect']  
225 - ];  
226 - return $this->curlRequest($url, $param);  
227 - }  
228 -  
229 - /**  
230 - * 更新amp站证书  
231 - * @param $param  
232 - * @return array  
233 - * @author Akun  
234 - * @date 2024/02/26 10:25  
235 - */  
236 - public function updateAmpPrivate($param)  
237 - {  
238 - $url = 'https://' . $param['domain'] . '/api/createSiteAmp/';  
239 - $param = [  
240 - "domain" => $param['domain'],  
241 - 'not_allow_country' => $param['not_allow_country'],  
242 - 'not_allow_ip' => $param['not_allow_ip'],  
243 - 'is_redirect' => $param['is_redirect']  
244 - ];  
245 - return $this->curlRequest($url, $param);  
246 - }  
247 -  
248 - /**  
249 - * 更新小语种自定义站证书  
250 - * @param $domain  
251 - * @return array  
252 - * @author Akun  
253 - * @date 2024/03/23 10:07  
254 - */  
255 - public function updateCustomPrivate($domain)  
256 - {  
257 - $url = 'http://' . $domain . '/api/applySsl';  
258 - $param = [  
259 - 'domain' => $domain,  
260 - 'rewrite' => [],  
261 - 'other_domain' => [],  
262 - 'is_https' => 1  
263 - ];  
264 -  
265 - return $this->curlRequest($url, $param);  
266 - } 187 + $servers_ip_info = $serverIpModel->read(['id' => $project_info['serve_id']], ['servers_id', 'ip', 'domain']);
  188 + if (!$servers_ip_info) {
  189 + continue;
  190 + }
267 191
268 - public function curlRequest($url, $data, $method = 'POST', $header = [], $time_out = 60)  
269 - {  
270 - $ch = curl_init();  
271 - curl_setopt($ch, CURLOPT_TIMEOUT, $time_out);  
272 - curl_setopt($ch, CURLOPT_URL, $url);  
273 - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
274 - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);  
275 - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);  
276 - if ($data)  
277 - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));  
278 - curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge([  
279 - 'Expect:',  
280 - 'Content-type: application/json',  
281 - 'Accept: application/json',  
282 - ], $header)  
283 - );  
284 - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);  
285 - $response = curl_exec($ch);  
286 - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);  
287 - curl_close($ch);  
288 - return [$code, $response];  
289 - } 192 + //过滤自建站项目域名
  193 + if ($servers_ip_info['servers_id'] == ServerConfig::SELF_SITE_ID) {
  194 + continue;
  195 + }
290 196
291 - /**  
292 - * @remark :获取域名证书有效时间  
293 - * @name :updateDomainSsl  
294 - * @author :lyh  
295 - * @method :post  
296 - * @time :2023/9/11 15:07  
297 - */  
298 - public function updateDomainSsl($domain)  
299 - {  
300 - $valid_from = '';  
301 - $valid_to = '';  
302 - try {  
303 - $context = stream_context_create([  
304 - 'ssl' => [  
305 - 'capture_peer_cert' => true,  
306 - 'capture_peer_cert_chain' => false,  
307 - 'verify_peer' => false,  
308 - 'verify_peer_name' => false  
309 - ],  
310 - ]);  
311 - $stream = stream_socket_client('ssl://' . $domain . ':443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);  
312 - if ($stream) {  
313 - $remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate'];  
314 - if ($remote_cert) {  
315 - $valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']);  
316 - $valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']);  
317 - } 197 + //过滤已解析到别的ip的域名
  198 + if (!$this->check_cname($v['custom_domain'], $servers_ip_info)) {
  199 + continue;
318 } 200 }
319 - fclose($stream);  
320 - } catch (\Exception $e) {  
321 - $valid_from = '';  
322 - $valid_to = '';  
323 - }  
324 - return ['from' => $valid_from, 'to' => $valid_to];  
325 - }  
326 201
327 - /**  
328 - * @remark :更新域名有效时间  
329 - * @name :updateDomain  
330 - * @author :lyh  
331 - * @method :post  
332 - * @time :2023/9/11 15:11  
333 - */  
334 - public function updateDomain($domain)  
335 - {  
336 - $url = 'http://openai.waimaoq.com/v1/whois_api?domain=' . $domain;  
337 - $response = http_get($url);  
338 - $start = date('Y-m-d H:i:s');  
339 - $end = date('Y-m-d H:i:s');  
340 - if ($response['code'] == 200) {  
341 - $start = $response['text']['creation_date'];  
342 - $end = $response['text']['expiration_date']; 202 + //创建更新站点证书任务
  203 + $task_info = $domainCreateTaskModel->read(['type' => DomainCreateTask::TYPE_CUSTOM, 'domain_id' => $v['id'], 'status' => ['<', DomainCreateTask::STATUS_SUC]]);
  204 + if (!$task_info) {
  205 + $domainCreateTaskModel->add([
  206 + 'server_id' => $servers_ip_info['servers_id'],
  207 + 'project_id' => $v['project_id'],
  208 + 'domain_id' => $v['id'],
  209 + 'type' => DomainCreateTask::TYPE_CUSTOM
  210 + ]);
  211 + }
343 } 212 }
344 - return ['start' => $start, 'end' => $end];  
345 } 213 }
346 214
347 /** 215 /**
@@ -58,18 +58,16 @@ class Demo extends Command @@ -58,18 +58,16 @@ class Demo extends Command
58 protected $description = 'demo'; 58 protected $description = 'demo';
59 59
60 public function handle(){ 60 public function handle(){
61 - $domain = "https://www.xawellauto.com/";  
62 - $token = md5($domain.date("Y-m-d"));  
63 - $url = "https://form.globalso.com/api/external-interface/domain_con/15243d63ed5a5738?domain=$domain&token=$token&source=1,2,3,4&num=15";  
64 - $url = $url."&sta_date=2024-07";  
65 - try {  
66 - $res = http_get($url,['charset=utf-8']);  
67 - } catch (\Exception | GuzzleException $e) {  
68 - errorLog('提交询盘信息失败', $domain, $e);  
69 - return false; 61 + $optimizeModel = new DeployOptimize();
  62 + $list = $optimizeModel->list();
  63 + foreach ($list as $k => $v){
  64 + if(!empty($v['g_top_plan'])){
  65 + $v['g_top_plan']['is_compliance'] = 0;
  66 + $optimizeModel->edit(['g_top_plan'=>json_encode($v['g_top_plan'])],['id'=>$v['id']]);
  67 + echo date('Y-m-d H:i:s') . '重制g_top-project_id:'.$v['project_id'] . PHP_EOL;
  68 + }
70 } 69 }
71 - echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;  
72 - return $res; 70 + return true;
73 } 71 }
74 72
75 // public function handle(){ 73 // public function handle(){
@@ -33,7 +33,7 @@ class AutoPullController extends BaseController @@ -33,7 +33,7 @@ class AutoPullController extends BaseController
33 } 33 }
34 } 34 }
35 35
36 - $lists['list'][$k]['process_name'] = $process_name; 36 + $lists['list'][$k]['process_name'] = $process_name ? $process_name : ['无'];
37 } 37 }
38 } 38 }
39 39
@@ -105,6 +105,10 @@ class ComController extends BaseController @@ -105,6 +105,10 @@ class ComController extends BaseController
105 if($uploadCode != 1){ 105 if($uploadCode != 1){
106 $info['role_menu'] = trim(str_replace(',41,',',',','.$info['role_menu'].','),','); 106 $info['role_menu'] = trim(str_replace(',41,',',',','.$info['role_menu'].','),',');
107 } 107 }
  108 + $projectCode = $this->getProjectWatermark();
  109 + if($projectCode != 1){
  110 + $info['role_menu'] = trim(str_replace(',50,',',',','.$info['role_menu'].','),',');
  111 + }
108 $this->map = [ 112 $this->map = [
109 'status'=>0, 113 'status'=>0,
110 'is_role'=>0, 114 'is_role'=>0,
@@ -140,9 +144,28 @@ class ComController extends BaseController @@ -140,9 +144,28 @@ class ComController extends BaseController
140 if(!empty($data)){ 144 if(!empty($data)){
141 $this->map['id'] = ['not in',$data]; 145 $this->map['id'] = ['not in',$data];
142 } 146 }
  147 + $projectCode = $this->getProjectWatermark();
  148 + if($projectCode != 1){
  149 + $data[] = 50;
  150 + }
  151 + if(!empty($data)){
  152 + $this->map['id'] = ['not in',$data];
  153 + }
143 return $this->map; 154 return $this->map;
144 } 155 }
145 156
  157 + /**
  158 + * @remark :是否开启水印功能
  159 + * @name :getProjectWatermark
  160 + * @author :lyh
  161 + * @method :post
  162 + * @time :2024/8/28 14:47
  163 + */
  164 + public function getProjectWatermark(){
  165 + $projectModel = new Project();
  166 + $info = $projectModel->read(['id'=>$this->user['project_id']],['id','is_watermark']);
  167 + return $info['is_watermark'] ?? 0;
  168 + }
146 169
147 /** 170 /**
148 * @remark :查看是否显示网站装饰 171 * @remark :查看是否显示网站装饰
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :OperationHeartbeatController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/8/28 14:02
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\BCom;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Models\Log\OperationHeartbeat;
  15 +
  16 +class OperationHeartbeatController extends BaseController
  17 +{
  18 + /**
  19 + * @remark :保存数据
  20 + * @name :saveHeartbeat
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2024/8/28 14:03
  24 + */
  25 + public function saveHeartbeat(){
  26 + $this->request->validate([
  27 + 'source'=>'required',
  28 + 'is_list' => 'required',
  29 + 'is_custom'=>'required',
  30 + 'is_template'=>'required',
  31 + 'operator_id'=>'required',
  32 + ], [
  33 + 'source.required' => '请选择页面',
  34 + 'is_list.required' => '列表页/详情页',
  35 + 'is_custom.required' => '是否为扩展模版',
  36 + 'is_template.required' => '详情页/可视化',
  37 + 'operator_id.required' => '操作人',
  38 + ]);
  39 + $condition = ['source'=>$this->param['source'],'is_list'=>$this->param['is_list'],'is_custom'=>$this->param['is_custom'],'is_template'=>$this->param['is_template']];
  40 + $operationHeartbeatModel = new OperationHeartbeat();
  41 + $info = $operationHeartbeatModel->read($condition,['id','status']);
  42 + if($info === false){
  43 + $condition['status'] = 1;
  44 + $operationHeartbeatModel->addReturnId($condition);
  45 + }else{
  46 + $operationHeartbeatModel->edit(['status'=>1],['id'=>$info['id']]);
  47 + }
  48 + $this->response('success');
  49 + }
  50 +
  51 + /**
  52 + * @remark :获取当前详情
  53 + * @name :getInfo
  54 + * @author :lyh
  55 + * @method :post
  56 + * @time :2024/8/28 14:29
  57 + */
  58 + public function getInfo(){
  59 + $this->request->validate([
  60 + 'source'=>'required',
  61 + 'is_list' => 'required',
  62 + 'is_custom'=>'required',
  63 + 'is_template'=>'required',
  64 + 'operator_id'=>'required',
  65 + ], [
  66 + 'source.required' => '请选择页面',
  67 + 'is_list.required' => '列表页/详情页',
  68 + 'is_custom.required' => '是否为扩展模版',
  69 + 'is_template.required' => '详情页/可视化',
  70 + 'operator_id.required' => '操作人',
  71 + ]);
  72 + $condition = ['source'=>$this->param['source'],'is_list'=>$this->param['is_list'],'is_custom'=>$this->param['is_custom'],'is_template'=>$this->param['is_template']];
  73 + $operationHeartbeatModel = new OperationHeartbeat();
  74 + $info = $operationHeartbeatModel->read($condition,['id','status']);
  75 + $this->response('success',Code::SUCCESS,$info);
  76 + }
  77 +}
@@ -319,13 +319,27 @@ class DomainInfoLogic extends BaseLogic @@ -319,13 +319,27 @@ class DomainInfoLogic extends BaseLogic
319 319
320 //新增建站任务 320 //新增建站任务
321 $task_model = new DomainCreateTask(); 321 $task_model = new DomainCreateTask();
322 - $task_info = $task_model->read(['domain_id'=>$this->param['id'],'status'=>['<',DomainCreateTask::STATUS_SUC]]); 322 + $task_info = $task_model->read(['type'=>DomainCreateTask::TYPE_MAIN,'domain_id'=>$this->param['id'],'status'=>['<',DomainCreateTask::STATUS_SUC]]);
323 if(!$task_info){ 323 if(!$task_info){
324 $task_model->add([ 324 $task_model->add([
  325 + 'server_id' => $serversIpInfo['servers_id'],
325 'project_id' => $info['project_id'], 326 'project_id' => $info['project_id'],
326 - 'domain_id' => $this->param['id'] 327 + 'domain_id' => $this->param['id'],
  328 + 'type' => DomainCreateTask::TYPE_MAIN
327 ]); 329 ]);
328 } 330 }
  331 + if($data['amp_status']){
  332 + $task_amp_info = $task_model->read(['type'=>DomainCreateTask::TYPE_AMP,'domain_id'=>$this->param['id'],'status'=>['<',DomainCreateTask::STATUS_SUC]]);
  333 + if(!$task_amp_info){
  334 + $task_model->add([
  335 + 'server_id' => $serversIpInfo['servers_id'],
  336 + 'project_id' => $info['project_id'],
  337 + 'domain_id' => $this->param['id'],
  338 + 'type' => DomainCreateTask::TYPE_AMP
  339 + ]);
  340 + }
  341 + }
  342 +
329 // //主站生成证书 343 // //主站生成证书
330 // EditDomainBt::dispatch($this->param['id']); 344 // EditDomainBt::dispatch($this->param['id']);
331 // //amp站生成证书 345 // //amp站生成证书
@@ -436,8 +450,19 @@ class DomainInfoLogic extends BaseLogic @@ -436,8 +450,19 @@ class DomainInfoLogic extends BaseLogic
436 } 450 }
437 451
438 if($this->param['is_create']){ 452 if($this->param['is_create']){
439 - //创建站点,设置证书  
440 - EditCustomDomainBt::dispatch($id); 453 + $task_model = new DomainCreateTask();
  454 + $task_amp_info = $task_model->read(['type'=>DomainCreateTask::TYPE_CUSTOM,'domain_id'=>$id,'status'=>['<',DomainCreateTask::STATUS_SUC]]);
  455 + if(!$task_amp_info){
  456 + $task_model->add([
  457 + 'server_id' => $serversIpInfo['servers_id'],
  458 + 'project_id' => $project_id,
  459 + 'domain_id' => $id,
  460 + 'type' => DomainCreateTask::TYPE_CUSTOM
  461 + ]);
  462 + }
  463 +
  464 +// //创建站点,设置证书
  465 +// EditCustomDomainBt::dispatch($id);
441 } 466 }
442 467
443 return $this->success(); 468 return $this->success();
@@ -180,6 +180,7 @@ class UserLoginLogic @@ -180,6 +180,7 @@ class UserLoginLogic
180 $info['project_location'] = $project['project_location']; 180 $info['project_location'] = $project['project_location'];
181 $info['open_export_product'] = $project['open_export_product']; 181 $info['open_export_product'] = $project['open_export_product'];
182 $info['is_update_language'] = $project['is_update_language']; 182 $info['is_update_language'] = $project['is_update_language'];
  183 + $info['is_watermark'] = $project['is_watermark'];
183 $info['configuration'] = $project['deploy_build']['configuration']; 184 $info['configuration'] = $project['deploy_build']['configuration'];
184 $info['file_cdn'] = $project['deploy_build']['file_cdn']; 185 $info['file_cdn'] = $project['deploy_build']['file_cdn'];
185 $info['project_type'] = $project['type']; 186 $info['project_type'] = $project['type'];
@@ -284,6 +285,7 @@ class UserLoginLogic @@ -284,6 +285,7 @@ class UserLoginLogic
284 $info['uptime_type'] = $this->getHistory($project); 285 $info['uptime_type'] = $this->getHistory($project);
285 $info['uptime'] = $project['uptime']; 286 $info['uptime'] = $project['uptime'];
286 $info['is_update_language'] = $project['is_update_language']; 287 $info['is_update_language'] = $project['is_update_language'];
  288 + $info['is_watermark'] = $project['is_watermark'];
287 $info['configuration'] = $project['deploy_build']['configuration']; 289 $info['configuration'] = $project['deploy_build']['configuration'];
288 $info['project_type'] = $project['type']; 290 $info['project_type'] = $project['type'];
289 $info['storage_type'] = $project['storage_type']; 291 $info['storage_type'] = $project['storage_type'];
@@ -12,4 +12,8 @@ class DomainCreateTask extends Base @@ -12,4 +12,8 @@ class DomainCreateTask extends Base
12 const STATUS_ING = 1; 12 const STATUS_ING = 1;
13 const STATUS_SUC = 2; 13 const STATUS_SUC = 2;
14 const STATUS_FAL = 3; 14 const STATUS_FAL = 3;
  15 +
  16 + const TYPE_MAIN = 1;
  17 + const TYPE_AMP = 2;
  18 + const TYPE_CUSTOM = 3;
15 } 19 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :OperationHeartbeat.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/8/28 10:35
  8 + */
  9 +
  10 +namespace App\Models\Log;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +/**
  15 + * @remark :用户心跳
  16 + * @name :OperationHeartbeat
  17 + * @author :lyh
  18 + * @method :post
  19 + * @time :2024/8/28 10:36
  20 + */
  21 +class OperationHeartbeat extends Base
  22 +{
  23 + protected $table = 'gl_operation_heartbeat';
  24 +}
@@ -77,7 +77,6 @@ class Project extends Base @@ -77,7 +77,6 @@ class Project extends Base
77 public static function planMap() 77 public static function planMap()
78 { 78 {
79 return [ 79 return [
80 - 10 => '专业版',  
81 1 => '标准版', 80 1 => '标准版',
82 2 => '商务版', 81 2 => '商务版',
83 3 => '旗舰版', 82 3 => '旗舰版',
@@ -87,6 +86,7 @@ class Project extends Base @@ -87,6 +86,7 @@ class Project extends Base
87 7 => '定制建站(PS订制)', 86 7 => '定制建站(PS订制)',
88 8 => '星链网站(1年版)', 87 8 => '星链网站(1年版)',
89 9 => '星链网站(2年版)', 88 9 => '星链网站(2年版)',
  89 + 10 => '专业版',
90 11 => '俄语标准版', 90 11 => '俄语标准版',
91 12 => '俄语商务版', 91 12 => '俄语商务版',
92 14 => '俄语旗舰版', 92 14 => '俄语旗舰版',
@@ -39,18 +39,18 @@ class HttpUtils @@ -39,18 +39,18 @@ class HttpUtils
39 * @return int 39 * @return int
40 * @throws \GuzzleHttp\Exception\GuzzleException 40 * @throws \GuzzleHttp\Exception\GuzzleException
41 */ 41 */
42 - public static function get($url, $data, $headers = []) 42 + public static function get($url, $data, $headers = [],$timeout=60)
43 { 43 {
44 LogUtils::info("HttpUtils-GET请求URL:" . $url); 44 LogUtils::info("HttpUtils-GET请求URL:" . $url);
45 - $response = Http::timeout(60)->withHeaders($headers)->get($url, $data); 45 + $response = Http::timeout($timeout)->withHeaders($headers)->get($url, $data);
46 self::checkSuccess($response); 46 self::checkSuccess($response);
47 return $response->getBody()->getContents(); 47 return $response->getBody()->getContents();
48 } 48 }
49 49
50 - public static function post($url, $data, $headers = []) 50 + public static function post($url, $data, $headers = [],$timeout=60)
51 { 51 {
52 LogUtils::info("HttpUtils-POST请求URL:" . $url); 52 LogUtils::info("HttpUtils-POST请求URL:" . $url);
53 - $response = Http::timeout(60)->withHeaders($headers)->post($url, $data); 53 + $response = Http::timeout($timeout)->withHeaders($headers)->post($url, $data);
54 self::checkSuccess($response); 54 self::checkSuccess($response);
55 return $response->getBody()->getContents(); 55 return $response->getBody()->getContents();
56 } 56 }
@@ -600,6 +600,10 @@ Route::middleware(['bloginauth'])->group(function () { @@ -600,6 +600,10 @@ Route::middleware(['bloginauth'])->group(function () {
600 Route::any('/save', [\App\Http\Controllers\Bside\Inquiry\InquiryFieldController::class, 'save'])->name('inquiry_field_save'); 600 Route::any('/save', [\App\Http\Controllers\Bside\Inquiry\InquiryFieldController::class, 'save'])->name('inquiry_field_save');
601 Route::any('/del', [\App\Http\Controllers\Bside\Inquiry\InquiryFieldController::class, 'del'])->name('inquiry_field_del'); 601 Route::any('/del', [\App\Http\Controllers\Bside\Inquiry\InquiryFieldController::class, 'del'])->name('inquiry_field_del');
602 }); 602 });
  603 +
  604 + Route::prefix('operation_heartbeat')->group(function () {
  605 + Route::any('/saveHeartbeat', [\App\Http\Controllers\Bside\BCom\OperationHeartbeatController::class, 'saveHeartbeat'])->name('operation_heartbeat_saveHeartbeat');
  606 + });
603 }); 607 });
604 //无需登录验证的路由组 608 //无需登录验证的路由组
605 Route::group([], function () { 609 Route::group([], function () {