正在显示
1 个修改的文件
包含
100 行增加
和
107 行删除
| @@ -33,21 +33,21 @@ class DomainInfoLogic extends BaseLogic | @@ -33,21 +33,21 @@ class DomainInfoLogic extends BaseLogic | ||
| 33 | public function saveDomain() | 33 | public function saveDomain() |
| 34 | { | 34 | { |
| 35 | $domain = parse_url($this->param['domain'], PHP_URL_HOST); | 35 | $domain = parse_url($this->param['domain'], PHP_URL_HOST); |
| 36 | - if (!empty($domain)) { | 36 | + if(!empty($domain)){ |
| 37 | $this->param['domain'] = trim($domain['host']); | 37 | $this->param['domain'] = trim($domain['host']); |
| 38 | } | 38 | } |
| 39 | //验证域名 | 39 | //验证域名 |
| 40 | - $this->verifyDomain($this->param['domain'], $this->param['id'] ?? ''); | ||
| 41 | - if (isset($this->param['id']) && !empty($this->param['id'])) { | ||
| 42 | - $rs = $this->model->edit($this->param, ['id' => $this->param['id']]); | ||
| 43 | - } else { | 40 | + $this->verifyDomain($this->param['domain'],$this->param['id'] ?? ''); |
| 41 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 42 | + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 43 | + }else{ | ||
| 44 | //查看域名是否以WWW开头 | 44 | //查看域名是否以WWW开头 |
| 45 | if (strpos($this->param['domain'], 'www.') === 0) { | 45 | if (strpos($this->param['domain'], 'www.') === 0) { |
| 46 | - $this->param['other_domain'] = json_encode([str_replace('www', '*', $this->param['domain']), str_replace('www.', '', $this->param['domain'])]); | 46 | + $this->param['other_domain'] = json_encode([str_replace('www', '*', $this->param['domain']),str_replace('www.', '', $this->param['domain'])]); |
| 47 | } | 47 | } |
| 48 | $rs = $this->model->add($this->param); | 48 | $rs = $this->model->add($this->param); |
| 49 | } | 49 | } |
| 50 | - if ($rs === false) { | 50 | + if($rs === false){ |
| 51 | $this->fail('error'); | 51 | $this->fail('error'); |
| 52 | } | 52 | } |
| 53 | return $this->success(); | 53 | return $this->success(); |
| @@ -61,15 +61,14 @@ class DomainInfoLogic extends BaseLogic | @@ -61,15 +61,14 @@ class DomainInfoLogic extends BaseLogic | ||
| 61 | * @method :post | 61 | * @method :post |
| 62 | * @time :2023/8/1 14:59 | 62 | * @time :2023/8/1 14:59 |
| 63 | */ | 63 | */ |
| 64 | - public function verifyDomain($domain, $id = '') | ||
| 65 | - { | ||
| 66 | - if (!empty($id)) { | ||
| 67 | - $info = $this->model->read(['domain' => $domain, 'id' => ['!=', $id]]); | 64 | + public function verifyDomain($domain,$id = ''){ |
| 65 | + if(!empty($id)){ | ||
| 66 | + $info = $this->model->read(['domain'=>$domain,'id'=>['!=',$id]]); | ||
| 68 | if ($info !== false) { | 67 | if ($info !== false) { |
| 69 | $this->fail('当前域名已存在'); | 68 | $this->fail('当前域名已存在'); |
| 70 | } | 69 | } |
| 71 | - } else { | ||
| 72 | - $info = $this->model->read(['domain' => $domain]); | 70 | + }else{ |
| 71 | + $info = $this->model->read(['domain'=>$domain]); | ||
| 73 | if ($info !== false) { | 72 | if ($info !== false) { |
| 74 | $this->fail('当前域名已存在'); | 73 | $this->fail('当前域名已存在'); |
| 75 | } | 74 | } |
| @@ -84,17 +83,16 @@ class DomainInfoLogic extends BaseLogic | @@ -84,17 +83,16 @@ class DomainInfoLogic extends BaseLogic | ||
| 84 | * @method :post | 83 | * @method :post |
| 85 | * @time :2023/8/1 15:43 | 84 | * @time :2023/8/1 15:43 |
| 86 | */ | 85 | */ |
| 87 | - public function editDomainStatus() | ||
| 88 | - { | 86 | + public function editDomainStatus(){ |
| 89 | //查看当前域名是否有项目在使用 | 87 | //查看当前域名是否有项目在使用 |
| 90 | - if ($this->param['status'] != $this->model::STATUS_ONE) { | ||
| 91 | - $info = $this->model->read(['id' => $this->param['id']]); | ||
| 92 | - if ($info === false) { | 88 | + if($this->param['status'] != $this->model::STATUS_ONE){ |
| 89 | + $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 90 | + if($info === false){ | ||
| 93 | $this->fail('当前域名有项目正在使用中'); | 91 | $this->fail('当前域名有项目正在使用中'); |
| 94 | } | 92 | } |
| 95 | } | 93 | } |
| 96 | - $rs = $this->model->edit(['status' => $this->param['status']], ['id' => $this->param['id']]); | ||
| 97 | - if ($rs === false) { | 94 | + $rs = $this->model->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]); |
| 95 | + if($rs === false){ | ||
| 98 | $this->fail('error'); | 96 | $this->fail('error'); |
| 99 | } | 97 | } |
| 100 | return $this->success(); | 98 | return $this->success(); |
| @@ -107,23 +105,21 @@ class DomainInfoLogic extends BaseLogic | @@ -107,23 +105,21 @@ class DomainInfoLogic extends BaseLogic | ||
| 107 | * @method :post | 105 | * @method :post |
| 108 | * @time :2023/8/1 16:10 | 106 | * @time :2023/8/1 16:10 |
| 109 | */ | 107 | */ |
| 110 | - public function getProjectList($map) | ||
| 111 | - { | 108 | + public function getProjectList($map){ |
| 112 | $projectModel = new Project(); | 109 | $projectModel = new Project(); |
| 113 | - $lists = $projectModel->list($map, 'id', ['id', 'title']); | 110 | + $lists = $projectModel->list($map,'id',['id','title']); |
| 114 | return $this->success($lists); | 111 | return $this->success($lists); |
| 115 | } | 112 | } |
| 116 | 113 | ||
| 117 | /** | 114 | /** |
| 118 | * 删除域名 | 115 | * 删除域名 |
| 119 | */ | 116 | */ |
| 120 | - public function delDomain() | ||
| 121 | - { | 117 | + public function delDomain(){ |
| 122 | $ids = $this->param['id']; | 118 | $ids = $this->param['id']; |
| 123 | // 初始化数据 | 119 | // 初始化数据 |
| 124 | if (FALSE == is_array($ids)) | 120 | if (FALSE == is_array($ids)) |
| 125 | $ids = [$ids]; | 121 | $ids = [$ids]; |
| 126 | - foreach ($ids as $k => $v) { | 122 | + foreach ($ids as $k => $v){ |
| 127 | $domain = DomainInfo::where(['id' => $v])->first(); | 123 | $domain = DomainInfo::where(['id' => $v])->first(); |
| 128 | if (empty($domain)) | 124 | if (empty($domain)) |
| 129 | continue; | 125 | continue; |
| @@ -135,14 +131,13 @@ class DomainInfoLogic extends BaseLogic | @@ -135,14 +131,13 @@ class DomainInfoLogic extends BaseLogic | ||
| 135 | } | 131 | } |
| 136 | 132 | ||
| 137 | 133 | ||
| 138 | - public function infoDomain() | ||
| 139 | - { | ||
| 140 | - $info = $this->model->read(['id' => $this->param['id']]); | ||
| 141 | - if ($info === false) { | 134 | + public function infoDomain(){ |
| 135 | + $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 136 | + if($info === false){ | ||
| 142 | $this->fail('当前数据不存在或者已被删除'); | 137 | $this->fail('当前数据不存在或者已被删除'); |
| 143 | } | 138 | } |
| 144 | - if (!empty($info['project_id'])) { | ||
| 145 | - $info['company'] = (new Project())->read(['id' => $info['project_id']], ['title'])['title']; | 139 | + if(!empty($info['project_id'])){ |
| 140 | + $info['company'] = (new Project())->read(['id'=>$info['project_id']],['title'])['title']; | ||
| 146 | } | 141 | } |
| 147 | return $this->success($info); | 142 | return $this->success($info); |
| 148 | } | 143 | } |
| @@ -154,41 +149,40 @@ class DomainInfoLogic extends BaseLogic | @@ -154,41 +149,40 @@ class DomainInfoLogic extends BaseLogic | ||
| 154 | * @method :post | 149 | * @method :post |
| 155 | * @time :2023/11/6 10:50 | 150 | * @time :2023/11/6 10:50 |
| 156 | */ | 151 | */ |
| 157 | - public function sslSave() | ||
| 158 | - { | ||
| 159 | - $info = $this->model->read(['id' => $this->param['id']]); | ||
| 160 | - if ($info === false || empty($info['domain'])) { | 152 | + public function sslSave(){ |
| 153 | + $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 154 | + if($info === false || empty($info['domain'])){ | ||
| 161 | $this->fail('当前数据不存在或者已被删除'); | 155 | $this->fail('当前数据不存在或者已被删除'); |
| 162 | } | 156 | } |
| 163 | //获取项目数据 | 157 | //获取项目数据 |
| 164 | $project_model = new Project(); | 158 | $project_model = new Project(); |
| 165 | - $project_info = $project_model->read(['id' => $info['project_id']], 'serve_id'); | ||
| 166 | - if ($project_info === false) { | 159 | + $project_info = $project_model->read(['id'=>$info['project_id']],'serve_id'); |
| 160 | + if($project_info === false){ | ||
| 167 | $this->fail('获取项目数据失败'); | 161 | $this->fail('获取项目数据失败'); |
| 168 | } | 162 | } |
| 169 | $serverIpModel = new ServersIp(); | 163 | $serverIpModel = new ServersIp(); |
| 170 | - $serversIpInfo = $serverIpModel->read(['id' => $project_info['serve_id']], ['servers_id', 'ip', 'domain']); | ||
| 171 | - if ($serversIpInfo === false) { | 164 | + $serversIpInfo = $serverIpModel->read(['id'=>$project_info['serve_id']],['servers_id','ip','domain']); |
| 165 | + if($serversIpInfo === false){ | ||
| 172 | $this->fail('获取服务器数据失败'); | 166 | $this->fail('获取服务器数据失败'); |
| 173 | } | 167 | } |
| 174 | - if ($serversIpInfo['servers_id'] == ServerConfig::SELF_TEST_ID) { | 168 | + if($serversIpInfo['servers_id'] == ServerConfig::SELF_TEST_ID){ |
| 175 | $this->fail('请切换服务器,生成站点不能使用测试服务器'); | 169 | $this->fail('请切换服务器,生成站点不能使用测试服务器'); |
| 176 | } | 170 | } |
| 177 | - if ($serversIpInfo['servers_id'] == ServerConfig::SELF_SITE_ID) { | ||
| 178 | - $this->model->edit(['amp_status' => $this->param['amp_status'] ?? 0], ['id' => $this->param['id']]); | 171 | + if($serversIpInfo['servers_id'] == ServerConfig::SELF_SITE_ID){ |
| 172 | + $this->model->edit(['amp_status' => $this->param['amp_status'] ?? 0],['id'=>$this->param['id']]); | ||
| 179 | $this->fail('自建站服务器无需生成站点'); | 173 | $this->fail('自建站服务器无需生成站点'); |
| 180 | } | 174 | } |
| 181 | //域名是否都已经解析 | 175 | //域名是否都已经解析 |
| 182 | - if (!check_domain_record($info['domain'], $serversIpInfo)) { | 176 | + if(!check_domain_record($info['domain'], $serversIpInfo)){ |
| 183 | $this->fail('域名' . $info['domain'] . '未解析至目标服务器'); | 177 | $this->fail('域名' . $info['domain'] . '未解析至目标服务器'); |
| 184 | } | 178 | } |
| 185 | $domain_301 = ''; | 179 | $domain_301 = ''; |
| 186 | - foreach ($this->param['other_domain'] ?? [] as $other_domain) { | ||
| 187 | - if ($other_domain && substr($other_domain, 0, 2) != '*.') { | ||
| 188 | - if (check_domain_record($other_domain, ['domain' => '', 'ip' => DomainInfo::SERVER_IP_301])) { | 180 | + foreach ($this->param['other_domain']??[] as $other_domain){ |
| 181 | + if($other_domain && substr($other_domain,0,2) != '*.'){ | ||
| 182 | + if(check_domain_record($other_domain,['domain'=>'','ip'=>DomainInfo::SERVER_IP_301])){ | ||
| 189 | $domain_301 = $other_domain; | 183 | $domain_301 = $other_domain; |
| 190 | - } else { | ||
| 191 | - if (!check_domain_record($other_domain, $serversIpInfo)) { | 184 | + }else{ |
| 185 | + if(!check_domain_record($other_domain, $serversIpInfo)){ | ||
| 192 | $this->fail('域名' . $other_domain . '未解析至目标服务器'); | 186 | $this->fail('域名' . $other_domain . '未解析至目标服务器'); |
| 193 | } | 187 | } |
| 194 | } | 188 | } |
| @@ -196,32 +190,32 @@ class DomainInfoLogic extends BaseLogic | @@ -196,32 +190,32 @@ class DomainInfoLogic extends BaseLogic | ||
| 196 | } | 190 | } |
| 197 | 191 | ||
| 198 | //如果要开通amp站点,判断m域名是否已经解析 | 192 | //如果要开通amp站点,判断m域名是否已经解析 |
| 199 | - if (isset($this->param['amp_status']) && $this->param['amp_status'] == 1) { | 193 | + if(isset($this->param['amp_status']) && $this->param['amp_status'] == 1){ |
| 200 | $domain_array = parse_url($info['domain']); | 194 | $domain_array = parse_url($info['domain']); |
| 201 | $host = $domain_array['host'] ?? $domain_array['path']; | 195 | $host = $domain_array['host'] ?? $domain_array['path']; |
| 202 | - $host_array = explode('.', $host); | 196 | + $host_array = explode('.',$host); |
| 203 | if (count($host_array) <= 2) { | 197 | if (count($host_array) <= 2) { |
| 204 | array_unshift($host_array, 'm'); | 198 | array_unshift($host_array, 'm'); |
| 205 | } else { | 199 | } else { |
| 206 | $host_array[0] = 'm'; | 200 | $host_array[0] = 'm'; |
| 207 | } | 201 | } |
| 208 | - $amp_domain = implode('.', $host_array); | ||
| 209 | - if (!check_domain_record($amp_domain, $serversIpInfo)) { | 202 | + $amp_domain = implode('.',$host_array); |
| 203 | + if(!check_domain_record($amp_domain, $serversIpInfo)){ | ||
| 210 | $this->fail('AMP站点域名' . $amp_domain . '未解析至目标服务器'); | 204 | $this->fail('AMP站点域名' . $amp_domain . '未解析至目标服务器'); |
| 211 | } | 205 | } |
| 212 | 206 | ||
| 213 | $is_redirect = $this->param['is_redirect'] ?? 0; | 207 | $is_redirect = $this->param['is_redirect'] ?? 0; |
| 214 | - } else { | 208 | + }else{ |
| 215 | //未开通amp站,主站和m站相互跳转也自动取消 | 209 | //未开通amp站,主站和m站相互跳转也自动取消 |
| 216 | $is_redirect = 0; | 210 | $is_redirect = 0; |
| 217 | } | 211 | } |
| 218 | 212 | ||
| 219 | $not_allow_ip = array_filter($this->param['not_allow_ip'] ?? []); | 213 | $not_allow_ip = array_filter($this->param['not_allow_ip'] ?? []); |
| 220 | - if ($not_allow_ip) { | 214 | + if($not_allow_ip){ |
| 221 | //判断禁止访问IP是否填写正确 | 215 | //判断禁止访问IP是否填写正确 |
| 222 | - foreach ($not_allow_ip as $vn) { | ||
| 223 | - $vn_count = count(explode('.', $vn)); | ||
| 224 | - if ($vn_count != 4) { | 216 | + foreach ($not_allow_ip as $vn){ |
| 217 | + $vn_count = count(explode('.',$vn)); | ||
| 218 | + if($vn_count != 4){ | ||
| 225 | $this->fail('禁止访问IP填写有误'); | 219 | $this->fail('禁止访问IP填写有误'); |
| 226 | } | 220 | } |
| 227 | } | 221 | } |
| @@ -229,9 +223,9 @@ class DomainInfoLogic extends BaseLogic | @@ -229,9 +223,9 @@ class DomainInfoLogic extends BaseLogic | ||
| 229 | 223 | ||
| 230 | $extend_config = []; | 224 | $extend_config = []; |
| 231 | $unique_extend = []; | 225 | $unique_extend = []; |
| 232 | - if (isset($this->param['extend_config']) && $this->param['extend_config']) { | ||
| 233 | - foreach ($this->param['extend_config'] as $k => $v) { | ||
| 234 | - if ($v['origin'] && (!in_array($v['origin'], $unique_extend))) { | 226 | + if(isset($this->param['extend_config']) && $this->param['extend_config']){ |
| 227 | + foreach ($this->param['extend_config'] as $k=>$v){ | ||
| 228 | + if($v['origin'] && (!in_array($v['origin'],$unique_extend))){ | ||
| 235 | $unique_extend[] = $v['origin']; | 229 | $unique_extend[] = $v['origin']; |
| 236 | $extend_config[] = $v; | 230 | $extend_config[] = $v; |
| 237 | } | 231 | } |
| @@ -240,9 +234,9 @@ class DomainInfoLogic extends BaseLogic | @@ -240,9 +234,9 @@ class DomainInfoLogic extends BaseLogic | ||
| 240 | 234 | ||
| 241 | $amp_extend_config = []; | 235 | $amp_extend_config = []; |
| 242 | $amp_unique_extend = []; | 236 | $amp_unique_extend = []; |
| 243 | - if (isset($this->param['amp_extend_config']) && $this->param['amp_extend_config']) { | ||
| 244 | - foreach ($this->param['amp_extend_config'] as $ka => $va) { | ||
| 245 | - if ($va['origin'] && (!in_array($va['origin'], $amp_unique_extend))) { | 237 | + if(isset($this->param['amp_extend_config']) && $this->param['amp_extend_config']){ |
| 238 | + foreach ($this->param['amp_extend_config'] as $ka=>$va){ | ||
| 239 | + if($va['origin'] && (!in_array($va['origin'],$amp_unique_extend))){ | ||
| 246 | $amp_unique_extend[] = $va['origin']; | 240 | $amp_unique_extend[] = $va['origin']; |
| 247 | $amp_extend_config[] = $va; | 241 | $amp_extend_config[] = $va; |
| 248 | } | 242 | } |
| @@ -250,7 +244,7 @@ class DomainInfoLogic extends BaseLogic | @@ -250,7 +244,7 @@ class DomainInfoLogic extends BaseLogic | ||
| 250 | } | 244 | } |
| 251 | 245 | ||
| 252 | //小语种为二级目录的站点,强制跳转https | 246 | //小语种为二级目录的站点,强制跳转https |
| 253 | - $is_https = $this->param['is_https'] ?? 0; | 247 | + $is_https = 0; |
| 254 | $buildModel = new DeployBuild(); | 248 | $buildModel = new DeployBuild(); |
| 255 | $build_info = $buildModel->read(['project_id' => $info['project_id']], ['linking_format']); | 249 | $build_info = $buildModel->read(['project_id' => $info['project_id']], ['linking_format']); |
| 256 | if ($build_info && $build_info['linking_format'] == 1) { | 250 | if ($build_info && $build_info['linking_format'] == 1) { |
| @@ -259,27 +253,27 @@ class DomainInfoLogic extends BaseLogic | @@ -259,27 +253,27 @@ class DomainInfoLogic extends BaseLogic | ||
| 259 | 253 | ||
| 260 | //保存301跳转数据+其他域名 | 254 | //保存301跳转数据+其他域名 |
| 261 | $data = [ | 255 | $data = [ |
| 262 | - 'other_domain' => json_encode(array_filter($this->param['other_domain'] ?? [])), | ||
| 263 | - 'extend_config' => json_encode($extend_config), | ||
| 264 | - 'type' => $this->param['type'], | 256 | + 'other_domain'=>json_encode(array_filter($this->param['other_domain'] ?? [])), |
| 257 | + 'extend_config'=>json_encode($extend_config), | ||
| 258 | + 'type'=>$this->param['type'], | ||
| 265 | 'private_key' => $this->param['key'] ?? '', | 259 | 'private_key' => $this->param['key'] ?? '', |
| 266 | 'private_cert' => $this->param['cert'] ?? '', | 260 | 'private_cert' => $this->param['cert'] ?? '', |
| 267 | 'is_https' => $is_https, | 261 | 'is_https' => $is_https, |
| 268 | 'amp_status' => $this->param['amp_status'] ?? 0, | 262 | 'amp_status' => $this->param['amp_status'] ?? 0, |
| 269 | 'amp_type' => $this->param['amp_type'] ?? 0, | 263 | 'amp_type' => $this->param['amp_type'] ?? 0, |
| 270 | - 'amp_extend_config' => json_encode($amp_extend_config), | 264 | + 'amp_extend_config'=>json_encode($amp_extend_config), |
| 271 | 'amp_private_key' => $this->param['amp_key'] ?? '', | 265 | 'amp_private_key' => $this->param['amp_key'] ?? '', |
| 272 | 'amp_private_cert' => $this->param['amp_cert'] ?? '', | 266 | 'amp_private_cert' => $this->param['amp_cert'] ?? '', |
| 273 | - 'not_allow_country' => json_encode(array_filter($this->param['not_allow_country'] ?? [])), | ||
| 274 | - 'not_allow_ip' => json_encode($not_allow_ip), | 267 | + 'not_allow_country'=>json_encode(array_filter($this->param['not_allow_country'] ?? [])), |
| 268 | + 'not_allow_ip'=>json_encode($not_allow_ip), | ||
| 275 | 'is_redirect' => $is_redirect, | 269 | 'is_redirect' => $is_redirect, |
| 276 | ]; | 270 | ]; |
| 277 | - $this->model->edit($data, ['id' => $this->param['id']]); | 271 | + $this->model->edit($data,['id'=>$this->param['id']]); |
| 278 | 272 | ||
| 279 | //新增建站任务 | 273 | //新增建站任务 |
| 280 | $task_model = new DomainCreateTask(); | 274 | $task_model = new DomainCreateTask(); |
| 281 | - $task_info = $task_model->read(['type' => DomainCreateTask::TYPE_MAIN, 'domain_id' => $this->param['id'], 'status' => ['<', DomainCreateTask::STATUS_SUC]]); | ||
| 282 | - if (!$task_info) { | 275 | + $task_info = $task_model->read(['type'=>DomainCreateTask::TYPE_MAIN,'domain_id'=>$this->param['id'],'status'=>['<',DomainCreateTask::STATUS_SUC]]); |
| 276 | + if(!$task_info){ | ||
| 283 | $task_model->add([ | 277 | $task_model->add([ |
| 284 | 'server_id' => $serversIpInfo['servers_id'], | 278 | 'server_id' => $serversIpInfo['servers_id'], |
| 285 | 'project_id' => $info['project_id'], | 279 | 'project_id' => $info['project_id'], |
| @@ -287,9 +281,9 @@ class DomainInfoLogic extends BaseLogic | @@ -287,9 +281,9 @@ class DomainInfoLogic extends BaseLogic | ||
| 287 | 'type' => DomainCreateTask::TYPE_MAIN | 281 | 'type' => DomainCreateTask::TYPE_MAIN |
| 288 | ]); | 282 | ]); |
| 289 | } | 283 | } |
| 290 | - if ($data['amp_status']) { | ||
| 291 | - $task_amp_info = $task_model->read(['type' => DomainCreateTask::TYPE_AMP, 'domain_id' => $this->param['id'], 'status' => ['<', DomainCreateTask::STATUS_SUC]]); | ||
| 292 | - if (!$task_amp_info) { | 284 | + if($data['amp_status']){ |
| 285 | + $task_amp_info = $task_model->read(['type'=>DomainCreateTask::TYPE_AMP,'domain_id'=>$this->param['id'],'status'=>['<',DomainCreateTask::STATUS_SUC]]); | ||
| 286 | + if(!$task_amp_info){ | ||
| 293 | $task_model->add([ | 287 | $task_model->add([ |
| 294 | 'server_id' => $serversIpInfo['servers_id'], | 288 | 'server_id' => $serversIpInfo['servers_id'], |
| 295 | 'project_id' => $info['project_id'], | 289 | 'project_id' => $info['project_id'], |
| @@ -301,11 +295,11 @@ class DomainInfoLogic extends BaseLogic | @@ -301,11 +295,11 @@ class DomainInfoLogic extends BaseLogic | ||
| 301 | 295 | ||
| 302 | //新增重定向任务 | 296 | //新增重定向任务 |
| 303 | $redirect_model = new DomainRedirectTask(); | 297 | $redirect_model = new DomainRedirectTask(); |
| 304 | - if ($domain_301) { | ||
| 305 | - $task_redirect_info = $redirect_model->read(['origin_domain' => $domain_301]); | ||
| 306 | - if (!$task_redirect_info) { | 298 | + if($domain_301){ |
| 299 | + $task_redirect_info = $redirect_model->read(['origin_domain'=>$domain_301]); | ||
| 300 | + if(!$task_redirect_info){ | ||
| 307 | $redirect_model->add([ | 301 | $redirect_model->add([ |
| 308 | - 'origin_domain' => $domain_301, | 302 | + 'origin_domain'=> $domain_301, |
| 309 | 'other_domain' => json_encode([]), | 303 | 'other_domain' => json_encode([]), |
| 310 | 'target_domain' => $info['domain'] | 304 | 'target_domain' => $info['domain'] |
| 311 | ]); | 305 | ]); |
| @@ -322,64 +316,63 @@ class DomainInfoLogic extends BaseLogic | @@ -322,64 +316,63 @@ class DomainInfoLogic extends BaseLogic | ||
| 322 | * @author Akun | 316 | * @author Akun |
| 323 | * @date 2024/03/05 9:48 | 317 | * @date 2024/03/05 9:48 |
| 324 | */ | 318 | */ |
| 325 | - public function country_custom($project_id) | ||
| 326 | - { | 319 | + public function country_custom($project_id){ |
| 327 | $project_model = new Project(); | 320 | $project_model = new Project(); |
| 328 | - $project_info = $project_model->read(['id' => $project_id], 'serve_id'); | ||
| 329 | - if ($project_info === false) { | 321 | + $project_info = $project_model->read(['id'=>$project_id],'serve_id'); |
| 322 | + if($project_info === false){ | ||
| 330 | $this->fail('获取项目数据失败'); | 323 | $this->fail('获取项目数据失败'); |
| 331 | } | 324 | } |
| 332 | 325 | ||
| 333 | $custom_model = new CountryCustom(); | 326 | $custom_model = new CountryCustom(); |
| 334 | - if ($this->param['is_create']) { | 327 | + if($this->param['is_create']){ |
| 335 | //需要创建站点 | 328 | //需要创建站点 |
| 336 | $serverIpModel = new ServersIp(); | 329 | $serverIpModel = new ServersIp(); |
| 337 | - $serversIpInfo = $serverIpModel->read(['id' => $project_info['serve_id']], ['servers_id', 'ip', 'domain']); | ||
| 338 | - if ($serversIpInfo === false) { | 330 | + $serversIpInfo = $serverIpModel->read(['id'=>$project_info['serve_id']],['servers_id','ip','domain']); |
| 331 | + if($serversIpInfo === false){ | ||
| 339 | $this->fail('获取服务器数据失败'); | 332 | $this->fail('获取服务器数据失败'); |
| 340 | } | 333 | } |
| 341 | - if ($serversIpInfo['servers_id'] == ServerConfig::SELF_TEST_ID) { | 334 | + if($serversIpInfo['servers_id'] == ServerConfig::SELF_TEST_ID){ |
| 342 | $this->fail('请切换服务器,生成站点不能使用测试服务器'); | 335 | $this->fail('请切换服务器,生成站点不能使用测试服务器'); |
| 343 | } | 336 | } |
| 344 | - if ($serversIpInfo['servers_id'] == ServerConfig::SELF_SITE_ID) { | 337 | + if($serversIpInfo['servers_id'] == ServerConfig::SELF_SITE_ID){ |
| 345 | $this->fail('自建站服务器无法生成站点'); | 338 | $this->fail('自建站服务器无法生成站点'); |
| 346 | } | 339 | } |
| 347 | //域名是否都已经解析 | 340 | //域名是否都已经解析 |
| 348 | - if (strpos($this->param['custom_domain'], '//') === false) { | ||
| 349 | - $this->param['custom_domain'] = '//' . $this->param['custom_domain']; | 341 | + if(strpos($this->param['custom_domain'],'//') === false){ |
| 342 | + $this->param['custom_domain'] = '//'.$this->param['custom_domain']; | ||
| 350 | } | 343 | } |
| 351 | $domain_arr = parse_url($this->param['custom_domain']); | 344 | $domain_arr = parse_url($this->param['custom_domain']); |
| 352 | - if (!isset($domain_arr['host'])) { | 345 | + if(!isset($domain_arr['host'])){ |
| 353 | $this->fail('自定义域名填写错误'); | 346 | $this->fail('自定义域名填写错误'); |
| 354 | } | 347 | } |
| 355 | $this->param['custom_domain'] = $domain_arr['host']; | 348 | $this->param['custom_domain'] = $domain_arr['host']; |
| 356 | //判断域名是否已经被使用 | 349 | //判断域名是否已经被使用 |
| 357 | - $has_info = $custom_model->read(['custom_domain' => $this->param['custom_domain']]); | ||
| 358 | - if ($has_info && ($has_info['project_id'] != $project_id || $has_info['language_id'] != $this->param['language_id'])) { | 350 | + $has_info = $custom_model->read(['custom_domain'=>$this->param['custom_domain']]); |
| 351 | + if($has_info && ($has_info['project_id'] != $project_id || $has_info['language_id'] != $this->param['language_id'])){ | ||
| 359 | $this->fail('自定义域名已被使用'); | 352 | $this->fail('自定义域名已被使用'); |
| 360 | } | 353 | } |
| 361 | - if (!check_domain_record($this->param['custom_domain'], $serversIpInfo)) { | 354 | + if(!check_domain_record($this->param['custom_domain'], $serversIpInfo)){ |
| 362 | $this->fail('域名' . $this->param['custom_domain'] . '未解析至目标服务器'); | 355 | $this->fail('域名' . $this->param['custom_domain'] . '未解析至目标服务器'); |
| 363 | } | 356 | } |
| 364 | - } else { | ||
| 365 | - $this->param['custom_domain'] = str_replace('https://', '', $this->param['custom_domain']); | ||
| 366 | - $this->param['custom_domain'] = str_replace('http://', '', $this->param['custom_domain']); | ||
| 367 | - $this->param['custom_domain'] = str_replace('//', '', $this->param['custom_domain']); | 357 | + }else{ |
| 358 | + $this->param['custom_domain'] = str_replace('https://','',$this->param['custom_domain']); | ||
| 359 | + $this->param['custom_domain'] = str_replace('http://','',$this->param['custom_domain']); | ||
| 360 | + $this->param['custom_domain'] = str_replace('//','',$this->param['custom_domain']); | ||
| 368 | } | 361 | } |
| 369 | 362 | ||
| 370 | - $info = $custom_model->read(['project_id' => $project_id, 'language_id' => $this->param['language_id']]); | ||
| 371 | - if ($info === false) { | 363 | + $info = $custom_model->read(['project_id'=>$project_id,'language_id'=>$this->param['language_id']]); |
| 364 | + if($info === false){ | ||
| 372 | $this->param['project_id'] = $project_id; | 365 | $this->param['project_id'] = $project_id; |
| 373 | $id = $custom_model->addReturnId($this->param); | 366 | $id = $custom_model->addReturnId($this->param); |
| 374 | - } else { | ||
| 375 | - $custom_model->edit($this->param, ['id' => $info['id']]); | 367 | + }else{ |
| 368 | + $custom_model->edit($this->param,['id'=>$info['id']]); | ||
| 376 | $id = $info['id']; | 369 | $id = $info['id']; |
| 377 | } | 370 | } |
| 378 | 371 | ||
| 379 | - if ($this->param['is_create']) { | 372 | + if($this->param['is_create']){ |
| 380 | $task_model = new DomainCreateTask(); | 373 | $task_model = new DomainCreateTask(); |
| 381 | - $task_amp_info = $task_model->read(['type' => DomainCreateTask::TYPE_CUSTOM, 'domain_id' => $id, 'status' => ['<', DomainCreateTask::STATUS_SUC]]); | ||
| 382 | - if (!$task_amp_info) { | 374 | + $task_amp_info = $task_model->read(['type'=>DomainCreateTask::TYPE_CUSTOM,'domain_id'=>$id,'status'=>['<',DomainCreateTask::STATUS_SUC]]); |
| 375 | + if(!$task_amp_info){ | ||
| 383 | $task_model->add([ | 376 | $task_model->add([ |
| 384 | 'server_id' => $serversIpInfo['servers_id'], | 377 | 'server_id' => $serversIpInfo['servers_id'], |
| 385 | 'project_id' => $project_id, | 378 | 'project_id' => $project_id, |
-
请 注册 或 登录 后发表评论