Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into develop
正在显示
5 个修改的文件
包含
80 行增加
和
26 行删除
| @@ -28,28 +28,80 @@ class DomainInfo extends Command | @@ -28,28 +28,80 @@ class DomainInfo extends Command | ||
| 28 | */ | 28 | */ |
| 29 | protected $description = '域名相关'; | 29 | protected $description = '域名相关'; |
| 30 | 30 | ||
| 31 | + /** | ||
| 32 | + * @remark :更新证书+证书有效时间 | ||
| 33 | + * @name :handle | ||
| 34 | + * @author :lyh | ||
| 35 | + * @method :post | ||
| 36 | + * @time :2023/9/11 15:09 | ||
| 37 | + */ | ||
| 31 | public function handle(){ | 38 | public function handle(){ |
| 32 | $domainModel = new DomainInfoModel(); | 39 | $domainModel = new DomainInfoModel(); |
| 33 | - $map = []; | 40 | + $map = ['status'=>['!=',2]]; |
| 34 | $list = $domainModel->list($map); | 41 | $list = $domainModel->list($map); |
| 35 | - $context = stream_context_create([ | ||
| 36 | - 'ssl' => [ | ||
| 37 | - 'capture_peer_cert' => true, | ||
| 38 | - 'capture_peer_cert_chain' => false, | ||
| 39 | - ], | ||
| 40 | - ]); | ||
| 41 | - $stream = stream_socket_client('ssl://oa.quanqiusou.cn:443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context); | ||
| 42 | - if(!$stream) { | ||
| 43 | - die("Failed to connect: $errno - $errstr"); | 42 | + foreach ($list as $v){ |
| 43 | + $ssl = $this->updateDomainSsl($v['domain']); | ||
| 44 | + $time = $this->updateDomain($v['domain']); | ||
| 45 | + $data = [ | ||
| 46 | + 'certificate_start_time'=>$ssl['from'], | ||
| 47 | + 'certificate_end_time'=>$ssl['to'], | ||
| 48 | + 'domain_start_time'=>$time['start'], | ||
| 49 | + 'domain_end_time'=>$time['end'] | ||
| 50 | + ]; | ||
| 51 | + $domainModel->edit($data,['id'=>$v['id']]); | ||
| 44 | } | 52 | } |
| 45 | - $remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate']; | ||
| 46 | - if(!$remote_cert) { | ||
| 47 | - die("Failed to retrieve certificate"); | 53 | + return 1; |
| 54 | + } | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * @remark :更新域名证书 | ||
| 58 | + * @name :updateDomainSsl | ||
| 59 | + * @author :lyh | ||
| 60 | + * @method :post | ||
| 61 | + * @time :2023/9/11 15:07 | ||
| 62 | + */ | ||
| 63 | + public function updateDomainSsl($domain){ | ||
| 64 | + try { | ||
| 65 | + $context = stream_context_create([ | ||
| 66 | + 'ssl' => [ | ||
| 67 | + 'capture_peer_cert' => true, | ||
| 68 | + 'capture_peer_cert_chain' => false, | ||
| 69 | + ], | ||
| 70 | + ]); | ||
| 71 | + $stream = stream_socket_client('ssl://'.$domain.':443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context); | ||
| 72 | + if(!$stream) { | ||
| 73 | + die("Failed to connect: $errno - $errstr"); | ||
| 74 | + } | ||
| 75 | + $remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate']; | ||
| 76 | + if(!$remote_cert) { | ||
| 77 | + die("Failed to retrieve certificate"); | ||
| 78 | + } | ||
| 79 | + $valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']); | ||
| 80 | + $valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']); | ||
| 81 | + fclose($stream); | ||
| 82 | + }catch (\Exception $e){ | ||
| 83 | + $valid_from = date('Y-m-d H:i:s'); | ||
| 84 | + $valid_to = date('Y-m-d H:i:s'); | ||
| 85 | + } | ||
| 86 | + return ['from'=>$valid_from,'to'=>$valid_to]; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + /** | ||
| 90 | + * @remark :更新域名有限时间 | ||
| 91 | + * @name :updateDomain | ||
| 92 | + * @author :lyh | ||
| 93 | + * @method :post | ||
| 94 | + * @time :2023/9/11 15:11 | ||
| 95 | + */ | ||
| 96 | + public function updateDomain($domain){ | ||
| 97 | + $url = 'http://openai.waimaoq.com/v1/whois_api?domain='.$domain; | ||
| 98 | + $response = http_get($url); | ||
| 99 | + $start = ''; | ||
| 100 | + $end = ''; | ||
| 101 | + if($response['code'] == 200){ | ||
| 102 | + $start = $response['text']['creation_date']; | ||
| 103 | + $end = $response['text']['expiration_date']; | ||
| 48 | } | 104 | } |
| 49 | - $valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']); | ||
| 50 | - $valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']); | ||
| 51 | - fclose($stream); | ||
| 52 | - echo "Certificate Valid From: $valid_from<br>"; | ||
| 53 | - echo "Certificate Valid To: $valid_to<br>"; | 105 | + return ['start'=>$start,'end'=>$end]; |
| 54 | } | 106 | } |
| 55 | } | 107 | } |
| @@ -33,8 +33,7 @@ class Kernel extends ConsoleKernel | @@ -33,8 +33,7 @@ class Kernel extends ConsoleKernel | ||
| 33 | $schedule->command('forward_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计转发询盘记录 | 33 | $schedule->command('forward_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计转发询盘记录 |
| 34 | $schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次 | 34 | $schedule->command('inquiry_delay')->everyMinute()->withoutOverlapping(1);//TODO::上线放开,转发询盘,每分钟执行一次 |
| 35 | $schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次 | 35 | $schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次 |
| 36 | -// // 更新域名|证书结束时间,每天凌晨1点执行一次 | ||
| 37 | -// $schedule->command('domain_time')->dailyAt('01:00')->withoutOverlapping(1); | 36 | + $schedule->command('domain_info')->dailyAt('01:00')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次 |
| 38 | } | 37 | } |
| 39 | 38 | ||
| 40 | /** | 39 | /** |
| @@ -88,16 +88,16 @@ if (!function_exists('http_get')) { | @@ -88,16 +88,16 @@ if (!function_exists('http_get')) { | ||
| 88 | function http_get($url, $header = []) | 88 | function http_get($url, $header = []) |
| 89 | { | 89 | { |
| 90 | if (empty($header)) { | 90 | if (empty($header)) { |
| 91 | - $header[] = "content-type: application/json; | ||
| 92 | - charset = UTF-8"; | 91 | + $header[] = "content-type: application/json"; |
| 93 | } | 92 | } |
| 94 | $ch1 = curl_init(); | 93 | $ch1 = curl_init(); |
| 95 | $timeout = 0; | 94 | $timeout = 0; |
| 96 | curl_setopt($ch1, CURLOPT_URL, $url); | 95 | curl_setopt($ch1, CURLOPT_URL, $url); |
| 97 | curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true); | 96 | curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true); |
| 97 | + curl_setopt($ch1, CURLOPT_ENCODING, ''); | ||
| 98 | + curl_setopt($ch1, CURLOPT_MAXREDIRS, 10); | ||
| 98 | curl_setopt($ch1, CURLOPT_HTTPHEADER, $header); | 99 | curl_setopt($ch1, CURLOPT_HTTPHEADER, $header); |
| 99 | curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout); | 100 | curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, $timeout); |
| 100 | - curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false); | ||
| 101 | curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, true); | 101 | curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, true); |
| 102 | curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, 'GET'); | 102 | curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, 'GET'); |
| 103 | curl_setopt($ch1, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | 103 | curl_setopt($ch1, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
| @@ -72,9 +72,9 @@ class BTemplateController extends BaseController | @@ -72,9 +72,9 @@ class BTemplateController extends BaseController | ||
| 72 | */ | 72 | */ |
| 73 | public function save(TemplateRequest $templateRequest,BTemplateLogic $BTemplateLogic){ | 73 | public function save(TemplateRequest $templateRequest,BTemplateLogic $BTemplateLogic){ |
| 74 | //演示项目,不允许其他号码编辑 | 74 | //演示项目,不允许其他号码编辑 |
| 75 | -// if(($this->user['project_id'] == 1) && ($this->user['mobile'] != '15928018676') && ($this->param['source'] == 1)){ | ||
| 76 | -// $this->response('演示项目仅支持演示功能,无法更改首页',Code::USER_ERROR); | ||
| 77 | -// } | 75 | + if(($this->user['project_id'] == 1) && ($this->user['mobile'] != '15928018676' || $this->user['mobile'] != '15680871314') && ($this->param['source'] == 1)){ |
| 76 | + $this->response('演示项目仅支持演示功能,无法更改首页',Code::USER_ERROR); | ||
| 77 | + } | ||
| 78 | $templateRequest->validated(); | 78 | $templateRequest->validated(); |
| 79 | $BTemplateLogic->templateSave(); | 79 | $BTemplateLogic->templateSave(); |
| 80 | $this->response('success'); | 80 | $this->response('success'); |
-
请 注册 或 登录 后发表评论