|
@@ -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
|
|