作者 刘锟

合并分支 'akun' 到 'master'

Akun



查看合并请求 !447
... ... @@ -9,6 +9,7 @@
namespace App\Console\Commands\Domain;
use App\Models\Project\CountryCustom;
use Illuminate\Console\Command;
use App\Models\Domain\DomainInfo as DomainInfoModel;
... ... @@ -37,14 +38,17 @@ class DomainInfo extends Command
*/
public function handle()
{
//更新域名到期时间
$this->startUpdateDomain();
//更新主站域名有效时间
// $this->startUpdateDomain();
//主站证书到期更新
$this->startUpdateCert();
// $this->startUpdateCert();
//AMP站证书到期更新
$this->startUpdateAmpCert();
// $this->startUpdateAmpCert();
//创建的自定义小语种域名证书到期更新
$this->startUpdateCustomCert();
return true;
}
... ... @@ -138,7 +142,35 @@ class DomainInfo extends Command
}
/**
* @remark :更新正式
* 自定义小语种站证书到期更新
* @author Akun
* @date 2024/03/23 10:08
*/
public function startUpdateCustomCert()
{
$customModel = new CountryCustom();
$end_day = date('Y-m-d H:i:s', time() + 2 * 24 * 3600);//2天后到期
$list = $customModel->where('status', 1)->where('is_create', 1)->where(function ($query) use ($end_day) {
$query->whereNull('certificate_end_time')->orWhere('certificate_end_time', '<', $end_day);
})->get()->toArray();
foreach ($list as $v) {
//更新证书到期时间
$data = [];
$ssl = $this->updateDomainSsl($v['domain']);
$ssl['from'] && $data['certificate_start_time'] = $ssl['from'];
$ssl['to'] && $data['certificate_end_time'] = $ssl['to'];
$customModel->edit($data, ['id' => $v['id']]);
if ($v['type'] == 1 && ($data['certificate_end_time'] ?? '') < $end_day) {
//申请免费证书
$this->updateCustomPrivate($v['domain']);
}
}
}
/**
* @remark :更新主站证书
* @name :updatePrivate
* @author :lyh
* @method :post
... ... @@ -168,7 +200,7 @@ class DomainInfo extends Command
}
/**
* 更新证书
* 更新amp站证书
* @param $domain
* @return array
* @author Akun
... ... @@ -185,6 +217,26 @@ class DomainInfo extends Command
return $this->curlRequest($url, $param);
}
/**
* 更新小语种自定义站证书
* @param $domain
* @return array
* @author Akun
* @date 2024/03/23 10:07
*/
public function updateCustomPrivate($domain)
{
$url = 'http://' . $domain . '/api/applySsl';
$param = [
'domain' => $domain,
'rewrite' => [],
'other_domain' => [],
'is_https' => 1
];
return $this->curlRequest($url, $param);
}
public static function getTopDomain($url)
{
$url = strtolower($url); //首先转成小写
... ... @@ -237,7 +289,7 @@ class DomainInfo extends Command
}
/**
* @remark :更新域名证书
* @remark :获取域名证书有效时间
* @name :updateDomainSsl
* @author :lyh
* @method :post
... ... @@ -273,7 +325,7 @@ class DomainInfo extends Command
}
/**
* @remark :更新域名有时间
* @remark :更新域名有时间
* @name :updateDomain
* @author :lyh
* @method :post
... ...