Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
13 个修改的文件
包含
205 行增加
和
826 行删除
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Console\Commands\Domain; | ||
| 4 | - | ||
| 5 | -use App\Models\Devops\Servers; | ||
| 6 | -use App\Models\Devops\ServersIp; | ||
| 7 | -use App\Models\Domain\DomainCreateTask; | ||
| 8 | -use App\Models\Domain\DomainInfo; | ||
| 9 | -use App\Models\Project\Project; | ||
| 10 | -use App\Utils\HttpUtils; | ||
| 11 | -use GuzzleHttp\Exception\GuzzleException; | ||
| 12 | -use Illuminate\Console\Command; | ||
| 13 | - | ||
| 14 | -class CreateSite extends Command | ||
| 15 | -{ | ||
| 16 | - /** | ||
| 17 | - * The name and signature of the console command. | ||
| 18 | - * | ||
| 19 | - * @var string | ||
| 20 | - */ | ||
| 21 | - protected $signature = 'create_domain_site'; | ||
| 22 | - | ||
| 23 | - /** | ||
| 24 | - * The console command description. | ||
| 25 | - * | ||
| 26 | - * @var string | ||
| 27 | - */ | ||
| 28 | - protected $description = '创建域名站点'; | ||
| 29 | - | ||
| 30 | - public function handle() | ||
| 31 | - { | ||
| 32 | - $model = new DomainCreateTask(); | ||
| 33 | - | ||
| 34 | - $task = $model->read(['status' => DomainCreateTask::STATUS_UN]); | ||
| 35 | - if ($task) { | ||
| 36 | - $model->edit(['status' => DomainCreateTask::STATUS_ING], ['id' => $task['id']]); | ||
| 37 | - | ||
| 38 | - $re = $this->editDomainBt($task['domain_id'], $task['type']); | ||
| 39 | - | ||
| 40 | - if (is_array($re)) { | ||
| 41 | - $model->edit(['status' => DomainCreateTask::STATUS_FAL, 'error_msg' => $re[1]], ['id' => $task['id']]); | ||
| 42 | - } else { | ||
| 43 | - $model->edit(['status' => DomainCreateTask::STATUS_SUC], ['id' => $task['id']]); | ||
| 44 | - } | ||
| 45 | - } | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | - protected function editDomainBt($domain_id, $type) | ||
| 49 | - { | ||
| 50 | - //获取域名数据 | ||
| 51 | - $domain_model = new DomainInfo(); | ||
| 52 | - $domain_info = $domain_model->read(['id' => $domain_id]); | ||
| 53 | - if ($domain_info === false) { | ||
| 54 | - return [false, '获取域名数据失败']; | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | - //获取项目数据 | ||
| 58 | - $project_model = new Project(); | ||
| 59 | - $project_info = $project_model->read(['id' => $domain_info['project_id']], 'serve_id'); | ||
| 60 | - if ($project_info === false) { | ||
| 61 | - return [false, '获取项目数据失败']; | ||
| 62 | - } | ||
| 63 | - | ||
| 64 | - //获取服务器数据 | ||
| 65 | - $serverIpModel = new ServersIp(); | ||
| 66 | - $serversIpInfo = $serverIpModel->read(['id' => $project_info['serve_id']], ['servers_id']); | ||
| 67 | - if ($serversIpInfo === false) { | ||
| 68 | - return [false, '获取服务器数据失败1']; | ||
| 69 | - } | ||
| 70 | - $serverModel = new Servers(); | ||
| 71 | - $serverInfo = $serverModel->read(['id' => $serversIpInfo['servers_id']], ['init_domain']); | ||
| 72 | - if ($serverInfo === false) { | ||
| 73 | - return [false, '获取服务器数据失败2']; | ||
| 74 | - } | ||
| 75 | - | ||
| 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 | - ]; | ||
| 91 | - } else { | ||
| 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 | - ]; | ||
| 102 | - } | ||
| 103 | - | ||
| 104 | - try { | ||
| 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'] . ',主站创建成功'); | ||
| 109 | - } else { | ||
| 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()]; | ||
| 140 | - } | ||
| 141 | - } | ||
| 142 | - } | ||
| 143 | - | ||
| 144 | - return true; | ||
| 145 | - } | ||
| 146 | - | ||
| 147 | - /** | ||
| 148 | - * 输出处理日志 | ||
| 149 | - * @param $message | ||
| 150 | - */ | ||
| 151 | - public function output($message) | ||
| 152 | - { | ||
| 153 | - echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL; | ||
| 154 | - } | ||
| 155 | -} |
| @@ -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) { | 75 | + if (!$project_info) { |
| 76 | + continue; | ||
| 77 | + } | ||
| 78 | + | ||
| 105 | $servers_ip_info = $serverIpModel->read(['id' => $project_info['serve_id']], ['servers_id', 'ip', 'domain']); | 79 | $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); | 80 | + if (!$servers_ip_info) { |
| 81 | + continue; | ||
| 82 | + } | ||
| 109 | 83 | ||
| 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']; | 84 | + //过滤自建站项目域名 |
| 85 | + if ($servers_ip_info['servers_id'] == ServerConfig::SELF_SITE_ID) { | ||
| 86 | + continue; | ||
| 113 | } | 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) { | 134 | + if (!$project_info) { |
| 135 | + continue; | ||
| 136 | + } | ||
| 137 | + | ||
| 154 | $servers_ip_info = $serverIpModel->read(['id' => $project_info['serve_id']], ['servers_id', 'ip', 'domain']); | 138 | $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); | 139 | + if (!$servers_ip_info) { |
| 140 | + continue; | ||
| 141 | + } | ||
| 158 | 142 | ||
| 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']; | 143 | + //过滤自建站项目域名 |
| 144 | + if ($servers_ip_info['servers_id'] == ServerConfig::SELF_SITE_ID) { | ||
| 145 | + continue; | ||
| 162 | } | 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 | - } | ||
| 201 | - } | ||
| 202 | - | ||
| 203 | - $customModel->edit($data, ['id' => $v['id']]); | ||
| 204 | - } | 183 | + if (!$project_info) { |
| 184 | + continue; | ||
| 205 | } | 185 | } |
| 206 | 186 | ||
| 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); | 187 | + $servers_ip_info = $serverIpModel->read(['id' => $project_info['serve_id']], ['servers_id', 'ip', 'domain']); |
| 188 | + if (!$servers_ip_info) { | ||
| 189 | + continue; | ||
| 227 | } | 190 | } |
| 228 | 191 | ||
| 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); | 192 | + //过滤自建站项目域名 |
| 193 | + if ($servers_ip_info['servers_id'] == ServerConfig::SELF_SITE_ID) { | ||
| 194 | + continue; | ||
| 246 | } | 195 | } |
| 247 | 196 | ||
| 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); | 197 | + //过滤已解析到别的ip的域名 |
| 198 | + if (!$this->check_cname($v['custom_domain'], $servers_ip_info)) { | ||
| 199 | + continue; | ||
| 266 | } | 200 | } |
| 267 | 201 | ||
| 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 | - } | ||
| 290 | - | ||
| 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 | - ], | 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 | ||
| 310 | ]); | 210 | ]); |
| 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 | - } | ||
| 318 | } | 211 | } |
| 319 | - fclose($stream); | ||
| 320 | - } catch (\Exception $e) { | ||
| 321 | - $valid_from = ''; | ||
| 322 | - $valid_to = ''; | ||
| 323 | - } | ||
| 324 | - return ['from' => $valid_from, 'to' => $valid_to]; | ||
| 325 | - } | ||
| 326 | - | ||
| 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']; | ||
| 343 | } | 212 | } |
| 344 | - return ['start' => $start, 'end' => $end]; | ||
| 345 | } | 213 | } |
| 346 | 214 | ||
| 347 | /** | 215 | /** |
| @@ -64,7 +64,7 @@ class RankData extends BaseCommands | @@ -64,7 +64,7 @@ class RankData extends BaseCommands | ||
| 64 | foreach ($list as $item) { | 64 | foreach ($list as $item) { |
| 65 | Log::channel('rank_data')->info('项目开始:ID' . $item['project_id'] .' - '. $item['api_no']) . ''; | 65 | Log::channel('rank_data')->info('项目开始:ID' . $item['project_id'] .' - '. $item['api_no']) . ''; |
| 66 | try { | 66 | try { |
| 67 | - (new RankDataLogic())->syncRankData($item['api_no'], $site_res); | 67 | + (new RankDataLogic())->syncRankData($item['api_no'], $site_res, true); |
| 68 | } catch (\Exception $e) { | 68 | } catch (\Exception $e) { |
| 69 | Log::channel('rank_data')->error('RankData:失败 ' . $item['api_no'] . $e->getMessage()); | 69 | Log::channel('rank_data')->error('RankData:失败 ' . $item['api_no'] . $e->getMessage()); |
| 70 | $error++; | 70 | $error++; |
| @@ -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 | +} |
| @@ -4,21 +4,12 @@ namespace App\Http\Logic\Aside\Domain; | @@ -4,21 +4,12 @@ namespace App\Http\Logic\Aside\Domain; | ||
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | use App\Http\Logic\Aside\BaseLogic; | 6 | use App\Http\Logic\Aside\BaseLogic; |
| 7 | -use App\Jobs\EditAmpDomainBt; | ||
| 8 | -use App\Jobs\EditCustomDomainBt; | ||
| 9 | -use App\Jobs\EditDomainBt; | ||
| 10 | use App\Models\Devops\ServerConfig; | 7 | use App\Models\Devops\ServerConfig; |
| 11 | -use App\Models\Devops\Servers; | ||
| 12 | use App\Models\Devops\ServersIp; | 8 | use App\Models\Devops\ServersIp; |
| 13 | use App\Models\Domain\DomainCreateTask; | 9 | use App\Models\Domain\DomainCreateTask; |
| 14 | use App\Models\Domain\DomainInfo; | 10 | use App\Models\Domain\DomainInfo; |
| 15 | use App\Models\Project\CountryCustom; | 11 | use App\Models\Project\CountryCustom; |
| 16 | -use App\Models\Project\DeployOptimize; | ||
| 17 | use App\Models\Project\Project; | 12 | use App\Models\Project\Project; |
| 18 | -use App\Utils\HttpUtils; | ||
| 19 | -use GuzzleHttp\Client; | ||
| 20 | -use GuzzleHttp\Exception\GuzzleException; | ||
| 21 | -use Illuminate\Support\Carbon; | ||
| 22 | use Symfony\Component\Process\Process; | 13 | use Symfony\Component\Process\Process; |
| 23 | 14 | ||
| 24 | class DomainInfoLogic extends BaseLogic | 15 | class DomainInfoLogic extends BaseLogic |
| @@ -152,98 +143,6 @@ class DomainInfoLogic extends BaseLogic | @@ -152,98 +143,6 @@ class DomainInfoLogic extends BaseLogic | ||
| 152 | } | 143 | } |
| 153 | 144 | ||
| 154 | /** | 145 | /** |
| 155 | - * 编辑网站证书 | ||
| 156 | - * @return array | ||
| 157 | - * @throws \App\Exceptions\AsideGlobalException | ||
| 158 | - * @throws \App\Exceptions\BsideGlobalException | ||
| 159 | - * @author Akun | ||
| 160 | - * @date 2023/10/17 11:52 | ||
| 161 | - */ | ||
| 162 | - public function setDomainSsl($initDomain,$domain,$rewrite,$other_domain,$is_https) | ||
| 163 | - { | ||
| 164 | - if($this->param['type'] == 2){ | ||
| 165 | - if(empty($this->param['key'])){ | ||
| 166 | - $this->fail('证书KEY值不能为空'); | ||
| 167 | - } | ||
| 168 | - if(empty($this->param['cert'])){ | ||
| 169 | - $this->fail('证书cert值不能为空'); | ||
| 170 | - } | ||
| 171 | - $api_url = 'http://'.$initDomain.'/api/setSsl'; | ||
| 172 | - $api_param = [ | ||
| 173 | - 'domain' => $domain, | ||
| 174 | - 'private_key' => $this->param['key'], | ||
| 175 | - 'cert' => $this->param['cert'], | ||
| 176 | - 'rewrite'=>$rewrite, | ||
| 177 | - 'other_domain'=>$other_domain, | ||
| 178 | - 'is_https' => $is_https | ||
| 179 | - ]; | ||
| 180 | - }else{ | ||
| 181 | - $api_url = 'http://'.$initDomain.'/api/applySsl'; | ||
| 182 | - $api_param = [ | ||
| 183 | - 'domain' => $domain, | ||
| 184 | - 'rewrite'=>$rewrite, | ||
| 185 | - 'other_domain'=>$other_domain, | ||
| 186 | - 'is_https' => $is_https | ||
| 187 | - ]; | ||
| 188 | - } | ||
| 189 | - try { | ||
| 190 | - $rs = HttpUtils::get($api_url, $api_param); | ||
| 191 | - $rs = json_decode($rs, true); | ||
| 192 | - if(isset($rs['status']) && $rs['status'] == 200){ | ||
| 193 | - return $this->success(); | ||
| 194 | - }else{ | ||
| 195 | - $this->fail($rs['message']??''); | ||
| 196 | - } | ||
| 197 | - } catch (\Exception | GuzzleException $e) { | ||
| 198 | - errorLog('创建站点', $api_param, $e); | ||
| 199 | - $this->fail('编辑证书失败'); | ||
| 200 | - } | ||
| 201 | - return $this->success(); | ||
| 202 | - } | ||
| 203 | - | ||
| 204 | - /** | ||
| 205 | - * 编辑amp网站证书 | ||
| 206 | - * @param $initDomain | ||
| 207 | - * @param $domain | ||
| 208 | - * @return array | ||
| 209 | - * @throws \App\Exceptions\AsideGlobalException | ||
| 210 | - * @throws \App\Exceptions\BsideGlobalException | ||
| 211 | - * @author Akun | ||
| 212 | - * @date 2024/02/22 14:58 | ||
| 213 | - */ | ||
| 214 | - public function setAmpDomainSsl($initDomain,$domain) | ||
| 215 | - { | ||
| 216 | - if($this->param['amp_type'] == 2){ | ||
| 217 | - if(empty($this->param['amp_key'])){ | ||
| 218 | - $this->fail('AMP站点证书KEY值不能为空'); | ||
| 219 | - } | ||
| 220 | - if(empty($this->param['amp_cert'])){ | ||
| 221 | - $this->fail('AMP站点证书cert值不能为空'); | ||
| 222 | - } | ||
| 223 | - } | ||
| 224 | - $api_url = 'http://'.$initDomain.'/api/createSiteAmp'; | ||
| 225 | - $api_param = [ | ||
| 226 | - 'domain' => $domain, | ||
| 227 | - 'private_key' => $this->param['amp_key']??'', | ||
| 228 | - 'cert' => $this->param['amp_cert']??'' | ||
| 229 | - ]; | ||
| 230 | - | ||
| 231 | - try { | ||
| 232 | - $rs = HttpUtils::get($api_url, $api_param); | ||
| 233 | - $rs = json_decode($rs, true); | ||
| 234 | - if(isset($rs['status']) && $rs['status'] == 200){ | ||
| 235 | - return $this->success(); | ||
| 236 | - }else{ | ||
| 237 | - $this->fail($rs['message']??''); | ||
| 238 | - } | ||
| 239 | - } catch (\Exception | GuzzleException $e) { | ||
| 240 | - errorLog('创建AMP站点', $api_param, $e); | ||
| 241 | - $this->fail('编辑AMP站点证书失败'); | ||
| 242 | - } | ||
| 243 | - return $this->success(); | ||
| 244 | - } | ||
| 245 | - | ||
| 246 | - /** | ||
| 247 | * @remark :保存证书相关配置 | 146 | * @remark :保存证书相关配置 |
| 248 | * @name :sslSave | 147 | * @name :sslSave |
| 249 | * @author :lyh | 148 | * @author :lyh |
| @@ -340,12 +239,6 @@ class DomainInfoLogic extends BaseLogic | @@ -340,12 +239,6 @@ class DomainInfoLogic extends BaseLogic | ||
| 340 | } | 239 | } |
| 341 | } | 240 | } |
| 342 | 241 | ||
| 343 | -// //主站生成证书 | ||
| 344 | -// EditDomainBt::dispatch($this->param['id']); | ||
| 345 | -// //amp站生成证书 | ||
| 346 | -// if($data['amp_status']){ | ||
| 347 | -// EditAmpDomainBt::dispatch($this->param['id']); | ||
| 348 | -// } | ||
| 349 | return $this->success(); | 242 | return $this->success(); |
| 350 | } | 243 | } |
| 351 | 244 | ||
| @@ -460,9 +353,6 @@ class DomainInfoLogic extends BaseLogic | @@ -460,9 +353,6 @@ class DomainInfoLogic extends BaseLogic | ||
| 460 | 'type' => DomainCreateTask::TYPE_CUSTOM | 353 | 'type' => DomainCreateTask::TYPE_CUSTOM |
| 461 | ]); | 354 | ]); |
| 462 | } | 355 | } |
| 463 | - | ||
| 464 | -// //创建站点,设置证书 | ||
| 465 | -// EditCustomDomainBt::dispatch($id); | ||
| 466 | } | 356 | } |
| 467 | 357 | ||
| 468 | return $this->success(); | 358 | 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']; |
app/Jobs/EditAmpDomainBt.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Jobs; | ||
| 4 | - | ||
| 5 | -use App\Models\Devops\ServerConfig; | ||
| 6 | -use App\Models\Devops\Servers; | ||
| 7 | -use App\Models\Devops\ServersIp; | ||
| 8 | -use App\Models\Domain\DomainInfo; | ||
| 9 | -use App\Models\Project\Project; | ||
| 10 | -use App\Utils\HttpUtils; | ||
| 11 | -use GuzzleHttp\Exception\GuzzleException; | ||
| 12 | -use Illuminate\Bus\Queueable; | ||
| 13 | -use Illuminate\Contracts\Queue\ShouldQueue; | ||
| 14 | -use Illuminate\Foundation\Bus\Dispatchable; | ||
| 15 | -use Illuminate\Queue\InteractsWithQueue; | ||
| 16 | -use Illuminate\Queue\SerializesModels; | ||
| 17 | - | ||
| 18 | -class EditAmpDomainBt implements ShouldQueue | ||
| 19 | -{ | ||
| 20 | - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
| 21 | - | ||
| 22 | - public $tries = 1; // 可配置任务重试次数 | ||
| 23 | - | ||
| 24 | - protected $domain_id; | ||
| 25 | - | ||
| 26 | - /** | ||
| 27 | - * Create a new job instance. | ||
| 28 | - * | ||
| 29 | - * @param $domain_id | ||
| 30 | - */ | ||
| 31 | - public function __construct($domain_id) | ||
| 32 | - { | ||
| 33 | - $this->domain_id = $domain_id; | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | - /** | ||
| 37 | - * Execute the job. | ||
| 38 | - * | ||
| 39 | - * @return bool | ||
| 40 | - */ | ||
| 41 | - public function handle() | ||
| 42 | - { | ||
| 43 | - //获取域名数据 | ||
| 44 | - $domain_model = new DomainInfo(); | ||
| 45 | - $domain_info = $domain_model->read(['id' => $this->domain_id]); | ||
| 46 | - if ($domain_info === false) { | ||
| 47 | - return $this->output($domain_info['domain'] . ':获取域名数据失败'); | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - //获取项目数据 | ||
| 51 | - $project_model = new Project(); | ||
| 52 | - $project_info = $project_model->read(['id' => $domain_info['project_id']], 'serve_id'); | ||
| 53 | - if ($project_info === false) { | ||
| 54 | - return $this->output($domain_info['domain'] . ':获取项目数据失败'); | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | - //获取服务器数据 | ||
| 58 | - $serverIpModel = new ServersIp(); | ||
| 59 | - $serversIpInfo = $serverIpModel->read(['id' => $project_info['serve_id']], ['servers_id']); | ||
| 60 | - if ($serversIpInfo === false) { | ||
| 61 | - return $this->output($domain_info['domain'] . ':获取服务器数据失败'); | ||
| 62 | - } | ||
| 63 | - $serverModel = new Servers(); | ||
| 64 | - $serverInfo = $serverModel->read(['id' => $serversIpInfo['servers_id']], ['init_domain']); | ||
| 65 | - if ($serverInfo === false) { | ||
| 66 | - return $this->output($domain_info['domain'] . ':获取服务器数据失败'); | ||
| 67 | - } | ||
| 68 | - | ||
| 69 | - //编辑amp站 | ||
| 70 | - $api_url_amp = 'http://' . $serverInfo['init_domain'] . '/api/createSiteAmp'; | ||
| 71 | - $api_param_amp = [ | ||
| 72 | - 'domain' => $domain_info['domain'], | ||
| 73 | - 'not_allow_country' => $domain_info['not_allow_country'], | ||
| 74 | - 'not_allow_ip' => $domain_info['not_allow_ip'], | ||
| 75 | - 'is_redirect' => $domain_info['is_redirect'] | ||
| 76 | - ]; | ||
| 77 | - if ($domain_info['amp_type'] == 2) { | ||
| 78 | - $api_param_amp['private_key'] = $domain_info['amp_private_key']; | ||
| 79 | - $api_param_amp['cert'] = $domain_info['amp_private_cert']; | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - try { | ||
| 83 | - $rs_amp = HttpUtils::get($api_url_amp, $api_param_amp); | ||
| 84 | - $rs_amp = json_decode($rs_amp, true); | ||
| 85 | - if (isset($rs_amp['status']) && $rs_amp['status'] == 200) { | ||
| 86 | - $this->output($domain_info['domain'] . ':amp站编辑成功'); | ||
| 87 | - } else { | ||
| 88 | - $this->output($domain_info['domain'] . ':amp站编辑失败,原因:' . ($rs_amp['message'] ?? '')); | ||
| 89 | - } | ||
| 90 | - } catch (\Exception | GuzzleException $e_amp) { | ||
| 91 | - $this->output($domain_info['domain'] . ':amp站编辑失败,原因:' . $e_amp->getMessage()); | ||
| 92 | - } | ||
| 93 | - | ||
| 94 | - return true; | ||
| 95 | - } | ||
| 96 | - | ||
| 97 | - /** | ||
| 98 | - * 输出处理日志 | ||
| 99 | - * @param $message | ||
| 100 | - * @return bool | ||
| 101 | - */ | ||
| 102 | - public function output($message) | ||
| 103 | - { | ||
| 104 | - echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL; | ||
| 105 | - return true; | ||
| 106 | - } | ||
| 107 | - | ||
| 108 | - public function failed(\Exception $exception) | ||
| 109 | - { | ||
| 110 | - return $this->output($exception->getMessage()); | ||
| 111 | - } | ||
| 112 | -} |
app/Jobs/EditCustomDomainBt.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Jobs; | ||
| 4 | - | ||
| 5 | -use App\Models\Devops\ServerConfig; | ||
| 6 | -use App\Models\Devops\Servers; | ||
| 7 | -use App\Models\Devops\ServersIp; | ||
| 8 | -use App\Models\Project\CountryCustom; | ||
| 9 | -use App\Models\Project\Project; | ||
| 10 | -use App\Utils\HttpUtils; | ||
| 11 | -use GuzzleHttp\Exception\GuzzleException; | ||
| 12 | -use Illuminate\Bus\Queueable; | ||
| 13 | -use Illuminate\Contracts\Queue\ShouldQueue; | ||
| 14 | -use Illuminate\Foundation\Bus\Dispatchable; | ||
| 15 | -use Illuminate\Queue\InteractsWithQueue; | ||
| 16 | -use Illuminate\Queue\SerializesModels; | ||
| 17 | - | ||
| 18 | -class EditCustomDomainBt implements ShouldQueue | ||
| 19 | -{ | ||
| 20 | - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
| 21 | - | ||
| 22 | - public $tries = 1; // 可配置任务重试次数 | ||
| 23 | - | ||
| 24 | - protected $domain_id; | ||
| 25 | - | ||
| 26 | - /** | ||
| 27 | - * Create a new job instance. | ||
| 28 | - * | ||
| 29 | - * @param $domain_id | ||
| 30 | - */ | ||
| 31 | - public function __construct($domain_id) | ||
| 32 | - { | ||
| 33 | - $this->domain_id = $domain_id; | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | - /** | ||
| 37 | - * Execute the job. | ||
| 38 | - * | ||
| 39 | - * @return bool | ||
| 40 | - */ | ||
| 41 | - public function handle() | ||
| 42 | - { | ||
| 43 | - //获取域名数据 | ||
| 44 | - $domain_model = new CountryCustom(); | ||
| 45 | - $domain_info = $domain_model->read(['id' => $this->domain_id]); | ||
| 46 | - if ($domain_info === false) { | ||
| 47 | - return $this->output($domain_info['custom_domain'] . ':获取域名数据失败'); | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - //获取项目数据 | ||
| 51 | - $project_model = new Project(); | ||
| 52 | - $project_info = $project_model->read(['id' => $domain_info['project_id']], 'serve_id'); | ||
| 53 | - if ($project_info === false) { | ||
| 54 | - return $this->output($domain_info['custom_domain'] . ':获取项目数据失败'); | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | - //获取服务器数据 | ||
| 58 | - $serverIpModel = new ServersIp(); | ||
| 59 | - $serversIpInfo = $serverIpModel->read(['id' => $project_info['serve_id']], ['servers_id']); | ||
| 60 | - if ($serversIpInfo === false) { | ||
| 61 | - return $this->output($domain_info['custom_domain'] . ':获取服务器数据失败'); | ||
| 62 | - } | ||
| 63 | - $serverModel = new Servers(); | ||
| 64 | - $serverInfo = $serverModel->read(['id' => $serversIpInfo['servers_id']], ['init_domain']); | ||
| 65 | - | ||
| 66 | - //编辑站点 | ||
| 67 | - if ($domain_info['type'] == 2) { | ||
| 68 | - $api_url = 'http://' . $serverInfo['init_domain'] . '/api/setSsl'; | ||
| 69 | - $api_param = [ | ||
| 70 | - 'domain' => $domain_info['custom_domain'], | ||
| 71 | - 'private_key' => $domain_info['private_key'], | ||
| 72 | - 'cert' => $domain_info['private_cert'], | ||
| 73 | - 'rewrite' => [], | ||
| 74 | - 'other_domain' => [], | ||
| 75 | - 'is_https' => 1 | ||
| 76 | - ]; | ||
| 77 | - } else { | ||
| 78 | - $api_url = 'http://' . $serverInfo['init_domain'] . '/api/applySsl'; | ||
| 79 | - $api_param = [ | ||
| 80 | - 'domain' => $domain_info['custom_domain'], | ||
| 81 | - 'rewrite' => [], | ||
| 82 | - 'other_domain' => [], | ||
| 83 | - 'is_https' => 1 | ||
| 84 | - ]; | ||
| 85 | - } | ||
| 86 | - try { | ||
| 87 | - $rs = HttpUtils::get($api_url, $api_param); | ||
| 88 | - $rs = json_decode($rs, true); | ||
| 89 | - if (isset($rs['status']) && $rs['status'] == 200) { | ||
| 90 | - $this->output($domain_info['custom_domain'] . ':站点编辑成功'); | ||
| 91 | - } else { | ||
| 92 | - $this->output($domain_info['custom_domain'] . ':站点编辑失败,原因:' . ($rs['message'] ?? '')); | ||
| 93 | - } | ||
| 94 | - } catch (\Exception | GuzzleException $e) { | ||
| 95 | - $this->output($domain_info['custom_domain'] . ':站点编辑失败,原因:' . $e->getMessage()); | ||
| 96 | - } | ||
| 97 | - | ||
| 98 | - return true; | ||
| 99 | - } | ||
| 100 | - | ||
| 101 | - /** | ||
| 102 | - * 输出处理日志 | ||
| 103 | - * @param $message | ||
| 104 | - * @return bool | ||
| 105 | - */ | ||
| 106 | - public function output($message) | ||
| 107 | - { | ||
| 108 | - echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL; | ||
| 109 | - return true; | ||
| 110 | - } | ||
| 111 | - | ||
| 112 | - public function failed(\Exception $exception) | ||
| 113 | - { | ||
| 114 | - return $this->output($exception->getMessage()); | ||
| 115 | - } | ||
| 116 | -} |
app/Jobs/EditDomainBt.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Jobs; | ||
| 4 | - | ||
| 5 | -use App\Models\Devops\ServerConfig; | ||
| 6 | -use App\Models\Devops\Servers; | ||
| 7 | -use App\Models\Devops\ServersIp; | ||
| 8 | -use App\Models\Domain\DomainInfo; | ||
| 9 | -use App\Models\Project\Project; | ||
| 10 | -use App\Utils\HttpUtils; | ||
| 11 | -use GuzzleHttp\Exception\GuzzleException; | ||
| 12 | -use Illuminate\Bus\Queueable; | ||
| 13 | -use Illuminate\Contracts\Queue\ShouldQueue; | ||
| 14 | -use Illuminate\Foundation\Bus\Dispatchable; | ||
| 15 | -use Illuminate\Queue\InteractsWithQueue; | ||
| 16 | -use Illuminate\Queue\SerializesModels; | ||
| 17 | - | ||
| 18 | -class EditDomainBt implements ShouldQueue | ||
| 19 | -{ | ||
| 20 | - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
| 21 | - | ||
| 22 | - public $tries = 1; // 可配置任务重试次数 | ||
| 23 | - | ||
| 24 | - protected $domain_id; | ||
| 25 | - | ||
| 26 | - /** | ||
| 27 | - * Create a new job instance. | ||
| 28 | - * | ||
| 29 | - * @param $domain_id | ||
| 30 | - */ | ||
| 31 | - public function __construct($domain_id) | ||
| 32 | - { | ||
| 33 | - $this->domain_id = $domain_id; | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | - /** | ||
| 37 | - * Execute the job. | ||
| 38 | - * | ||
| 39 | - * @return bool | ||
| 40 | - */ | ||
| 41 | - public function handle() | ||
| 42 | - { | ||
| 43 | - //获取域名数据 | ||
| 44 | - $domain_model = new DomainInfo(); | ||
| 45 | - $domain_info = $domain_model->read(['id' => $this->domain_id]); | ||
| 46 | - if ($domain_info === false) { | ||
| 47 | - return $this->output($domain_info['domain'] . ':获取域名数据失败'); | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - //获取项目数据 | ||
| 51 | - $project_model = new Project(); | ||
| 52 | - $project_info = $project_model->read(['id' => $domain_info['project_id']], 'serve_id'); | ||
| 53 | - if ($project_info === false) { | ||
| 54 | - return $this->output($domain_info['domain'] . ':获取项目数据失败'); | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | - //获取服务器数据 | ||
| 58 | - $serverIpModel = new ServersIp(); | ||
| 59 | - $serversIpInfo = $serverIpModel->read(['id' => $project_info['serve_id']], ['servers_id']); | ||
| 60 | - if ($serversIpInfo === false) { | ||
| 61 | - return $this->output($domain_info['domain'] . ':获取服务器数据失败'); | ||
| 62 | - } | ||
| 63 | - $serverModel = new Servers(); | ||
| 64 | - $serverInfo = $serverModel->read(['id' => $serversIpInfo['servers_id']], ['init_domain']); | ||
| 65 | - if ($serverInfo === false) { | ||
| 66 | - return $this->output($domain_info['domain'] . ':获取服务器数据失败'); | ||
| 67 | - } | ||
| 68 | - | ||
| 69 | - //编辑主站 | ||
| 70 | - if ($domain_info['type'] == 2) { | ||
| 71 | - $api_url = 'http://' . $serverInfo['init_domain'] . '/api/setSsl'; | ||
| 72 | - $api_param = [ | ||
| 73 | - 'domain' => $domain_info['domain'], | ||
| 74 | - 'private_key' => $domain_info['private_key'], | ||
| 75 | - 'cert' => $domain_info['private_cert'], | ||
| 76 | - 'rewrite' => $domain_info['extend_config'], | ||
| 77 | - 'other_domain' => $domain_info['other_domain'], | ||
| 78 | - 'is_https' => $domain_info['is_https'], | ||
| 79 | - 'not_allow_country' => $domain_info['not_allow_country'], | ||
| 80 | - 'not_allow_ip' => $domain_info['not_allow_ip'], | ||
| 81 | - 'is_redirect' => $domain_info['is_redirect'] | ||
| 82 | - ]; | ||
| 83 | - } else { | ||
| 84 | - $api_url = 'http://' . $serverInfo['init_domain'] . '/api/applySsl'; | ||
| 85 | - $api_param = [ | ||
| 86 | - 'domain' => $domain_info['domain'], | ||
| 87 | - 'rewrite' => $domain_info['extend_config'], | ||
| 88 | - 'other_domain' => $domain_info['other_domain'], | ||
| 89 | - 'is_https' => $domain_info['is_https'], | ||
| 90 | - 'not_allow_country' => $domain_info['not_allow_country'], | ||
| 91 | - 'not_allow_ip' => $domain_info['not_allow_ip'], | ||
| 92 | - 'is_redirect' => $domain_info['is_redirect'] | ||
| 93 | - ]; | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - try { | ||
| 97 | - $rs = HttpUtils::get($api_url, $api_param); | ||
| 98 | - $rs = json_decode($rs, true); | ||
| 99 | - if (isset($rs['status']) && $rs['status'] == 200) { | ||
| 100 | - $this->output($domain_info['domain'] . ':主站编辑成功'); | ||
| 101 | - } else { | ||
| 102 | - $this->output($domain_info['domain'] . ':主站编辑失败,原因:' . ($rs['message'] ?? '')); | ||
| 103 | - } | ||
| 104 | - } catch (\Exception | GuzzleException $e) { | ||
| 105 | - $this->output($domain_info['domain'] . ':主站编辑失败,原因:' . $e->getMessage()); | ||
| 106 | - } | ||
| 107 | - | ||
| 108 | - return true; | ||
| 109 | - } | ||
| 110 | - | ||
| 111 | - /** | ||
| 112 | - * 输出处理日志 | ||
| 113 | - * @param $message | ||
| 114 | - * @return bool | ||
| 115 | - */ | ||
| 116 | - public function output($message) | ||
| 117 | - { | ||
| 118 | - echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL; | ||
| 119 | - return true; | ||
| 120 | - } | ||
| 121 | - | ||
| 122 | - public function failed(\Exception $exception) | ||
| 123 | - { | ||
| 124 | - return $this->output($exception->getMessage()); | ||
| 125 | - } | ||
| 126 | -} |
app/Models/Log/OperationHeartbeat.php
0 → 100644
| 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 => '俄语旗舰版', |
| @@ -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 () { |
-
请 注册 或 登录 后发表评论