diff --git a/app/lib/DeployHelper.php b/app/lib/DeployHelper.php index 60dc693..ad09c50 100644 --- a/app/lib/DeployHelper.php +++ b/app/lib/DeployHelper.php @@ -400,45 +400,6 @@ class DeployHelper ], ], ], - 'kuocai' => [ - 'name' => '括彩云', - 'class' => 1, - 'icon' => 'kuocai.jpg', - 'note' => '填写控制台账号密码', - 'inputs' => [ - 'username' => [ - 'name' => '账号', - 'type' => 'input', - 'placeholder' => '控制台账号', - 'note' => '填写手机号或邮箱', - 'required' => true, - ], - 'password' => [ - 'name' => '密码', - 'type' => 'input', - 'placeholder' => '控制台密码', - 'required' => true, - ], - 'proxy' => [ - 'name' => '使用代理服务器', - 'type' => 'radio', - 'options' => [ - '0' => '否', - '1' => '是', - ], - 'value' => '0' - ], - ], - 'taskinputs' => [ - 'id' => [ - 'name' => '域名ID', - 'type' => 'input', - 'placeholder' => '', - 'note' => '在控制台->我的域名->配置复制浏览器地址栏显示的域名ID(19位数字),注意域名是否与证书匹配', - 'required' => true, - ], - ], - ], 'aliyun' => [ 'name' => '阿里云', 'class' => 2, @@ -1134,6 +1095,45 @@ class DeployHelper ], ], ], + 'kuocai' => [ + 'name' => '括彩云', + 'class' => 2, + 'icon' => 'kuocai.jpg', + 'note' => '填写控制台账号密码', + 'inputs' => [ + 'username' => [ + 'name' => '账号', + 'type' => 'input', + 'placeholder' => '控制台账号', + 'note' => '填写手机号或邮箱', + 'required' => true, + ], + 'password' => [ + 'name' => '密码', + 'type' => 'input', + 'placeholder' => '控制台密码', + 'required' => true, + ], + 'proxy' => [ + 'name' => '使用代理服务器', + 'type' => 'radio', + 'options' => [ + '0' => '否', + '1' => '是', + ], + 'value' => '0' + ], + ], + 'taskinputs' => [ + 'id' => [ + 'name' => '域名ID', + 'type' => 'input', + 'placeholder' => '', + 'note' => '在控制台->我的域名->配置复制浏览器地址栏显示的域名ID(19位数字),注意域名是否与证书匹配', + 'required' => true, + ], + ], + ], 'allwaf' => [ 'name' => 'AllWAF', 'class' => 2, diff --git a/app/lib/deploy/kuocai.php b/app/lib/deploy/kuocai.php index f5d2be6..7449d9e 100644 --- a/app/lib/deploy/kuocai.php +++ b/app/lib/deploy/kuocai.php @@ -25,12 +25,11 @@ class kuocai implements DeployInterface if (empty($this->username) || empty($this->password)) { throw new Exception('请填写控制台账号和密码'); } - $data = [ + $this->request('/login/loginUser', [ 'userAccount' => $this->username, 'userPwd' => $this->password, 'remember' => 'true' - ]; - $this->token = $this->request('/login/loginUser', $data); + ]); } public function deploy($fullchain, $privatekey, $config, &$info) @@ -39,7 +38,12 @@ class kuocai implements DeployInterface if (empty($id)) { throw new Exception('域名ID不能为空'); } - $data = [ + $this->token = $this->request('/login/loginUser', [ + 'userAccount' => $this->username, + 'userPwd' => $this->password, + 'remember' => 'true' + ]); + $this->request('/CdnDomainHttps/httpsConfiguration', [ 'doMainId' => $id, 'https' => [ 'certificate_name' => uniqid('cert_'), @@ -48,8 +52,7 @@ class kuocai implements DeployInterface 'https_status' => 'on', 'private_key' => $privatekey, ] - ]; - $this->request('/CdnDomainHttps/httpsConfiguration', $data); + ], true); $this->log("域名ID:{$id}更新成功!"); } @@ -65,15 +68,18 @@ class kuocai implements DeployInterface } } - private function request($path, $body = null) + private function request($path, $params = null, $json = false) { $url = 'https://kuocai.cn' . $path; + $body = $json ? json_encode($params) : $params; + $headers = []; + if ($json) $headers[] = 'Content-Type: application/json'; $response = curl_client( $url, $body, null, $this->token ? "kuocai_cdn_token={$this->token}" : null, - null, + $headers, $this->proxy ); $result = json_decode($response['body'], true);