作者 Your Name
... ... @@ -192,22 +192,11 @@ class DomainInfo extends Command
public function updatePrivate($param)
{
$url = 'https://' . $param['domain'] . '/api/applySsl/';
$top_domain = $this->getTopDomain($param['domain']);
if ((empty($extend_config) || empty($extend_config[0]['origin'])) && $param['id'] != 3) {
$extend_config = [
['origin' => $top_domain, 'target' => $param['domain']]
];
}
$param = [
'project_id' => $param['project_id'],
'type' => 1,
'route' => 1,
"domain" => $param['domain'],
"rewrite" => $extend_config ?? [],
'other_domain' => [$top_domain, '*.' . $top_domain],
"rewrite" => $param['extend_config'],
'other_domain' => $param['other_domain'],
'is_https' => $param['is_https'],
'private_key' => '',
'cert' => ''
];
return $this->curlRequest($url, $param);
}
... ... @@ -250,34 +239,6 @@ class DomainInfo extends Command
return $this->curlRequest($url, $param);
}
public static function getTopDomain($url)
{
$url = strtolower($url); //首先转成小写
$url = mb_ereg_replace('^( | )+', '', trim($url));
$url = mb_ereg_replace('( | )+$', '', $url);
if (!preg_match('/^(http:\/\/|https)/', $url)) {
$url = "https://" . $url;
}
$hosts = parse_url($url);
$host = $hosts['host'] ?? '';
//查看是几级域名
$data = explode('.', $host);
$n = count($data);
if ($n < 2) {
return $host;
}
//判断是否是双后缀
$preg = '/[\w].+\.(com|net|org|gov|edu|co|ne)\.[\w]/';
if (($n > 2) && preg_match($preg, $host)) {
//双后缀取后3位
$host = $data[$n - 3] . '.' . $data[$n - 2] . '.' . $data[$n - 1];
} else {
//非双后缀取后两位
$host = $data[$n - 2] . '.' . $data[$n - 1];
}
return $host;
}
public function curlRequest($url, $data, $method = 'POST', $header = [], $time_out = 60)
{
$ch = curl_init();
... ...
... ... @@ -782,15 +782,18 @@ function check_remote_url_down($url,$project_id,$domain,$is_complete=0){
$host_arr = explode('.',$host);
$path = $arr['path'] ?? '';
$url_complete = ($scheme ?: 'https') . '://' . ($host ?: $domain) . $path;
if($path && substr($path,0,1) != '/'){
$path = '/'.$path;
}
if (
(empty($scheme) || $scheme == 'https' || $scheme == 'http')
&& (empty($host) || (strpos($host_arr[0], 'cdn') === false))
&& $path
&& (substr($path, 0, 1) == '/')
&& (strpos($path, '.') !== false)
) {
$url_complete = ($scheme ?: 'https') . '://' . ($host ?: $domain) . $path;
$new_url = CosService::uploadRemote($project_id,'image_product',$url_complete);
if($new_url){
return $is_complete ? getImageUrl($new_url) : $new_url;
... ...
... ... @@ -451,7 +451,7 @@ class ImageController extends Controller
foreach ($files as $file){
if(isset($this->cache['image_max']) && ($this->cache['image_max'] != 0)){
if ($file->getSize() > $this->cache['image_max'] * 1024) {
$this->response('图片最大为1024K',Code::SYSTEM_ERROR);
$this->response('图片最大为'.$this->cache['image_max'],Code::SYSTEM_ERROR);
}
}else{
if ($file->getSize() > $max) {
... ... @@ -462,7 +462,7 @@ class ImageController extends Controller
}else{
if(isset($this->cache['image_max']) && ($this->cache['image_max'] != 0)){
if ($files->getSize() > $this->cache['image_max'] * 1024) {
$this->response('图片最大为1024K',Code::SYSTEM_ERROR);
$this->response('图片最大为'.$this->cache['image_max'],Code::SYSTEM_ERROR);
}
}else{
if ($files->getSize() > $max) {
... ...