作者 lyh

Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6 into lyh-server

... ... @@ -4,6 +4,7 @@ namespace App\Console\Commands\Project;
use App\Helper\Arr;
use App\Models\Product\Product;
use App\Models\Project\Project;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
... ... @@ -30,24 +31,68 @@ class ThumbProjectImage extends Command
if ($project_id > 0) {
//指定项目
ProjectServer::useProject($project_id);
$this->output('project_id:' . $project_id . ' | start');
Product::select(['id', 'thumb'])->chunk(100, function ($products) {
$project_info = ProjectServer::useProject($project_id);
if ($project_info) {
$thumb_w = $project_info->deploy_build->thumb_w ?? 0;
Product::select(['id', 'thumb'])->chunk(100, function ($products) use ($thumb_w) {
foreach ($products as $product) {
$thumb = $product->thumb;
if (isset($thumb['url']) && $thumb['url']) {
$thumb['url'] = thumbImageByUrl($thumb['url']);
$new_thumb = thumbImageByUrl($thumb['url'], $thumb_w);
if ($new_thumb != $thumb['url']) {
$thumb['url'] = $new_thumb;
$product->timestamps = false;
$product->thumb = Arr::a2s($thumb);
$product->save();
$this->output('product_id:' . $product->id . ' | success');
}
}
}
});
DB::disconnect('custom_mysql');
}
$this->output('project_id:' . $project_id . ' | success');
$this->output('project_id:' . $project_id . ' | end');
} else {
//TODO:所有项目
//所有项目
$projectModel = new Project();
$list = $projectModel->list(['delete_status' => 0, 'is_upgrade' => 0, 'type' => ['in', [1, 2, 3, 4, 6]]], 'id', ['id'], 'asc');
foreach ($list as $k => $v) {
$project_id = $v['id'];
$this->output('project_id:' . $project_id . ' | start');
$project_info = ProjectServer::useProject($project_id);
if ($project_info) {
$thumb_w = $project_info->deploy_build->thumb_w ?? 0;
Product::select(['id', 'thumb'])->chunk(100, function ($products) use ($thumb_w) {
foreach ($products as $product) {
$thumb = $product->thumb;
if (isset($thumb['url']) && $thumb['url']) {
$new_thumb = thumbImageByUrl($thumb['url'], $thumb_w);
if ($new_thumb != $thumb['url']) {
$thumb['url'] = $new_thumb;
$product->timestamps = false;
$product->thumb = Arr::a2s($thumb);
$product->save();
$this->output('product_id:' . $product->id . ' | success');
}
}
}
});
DB::disconnect('custom_mysql');
}
$this->output('project_id:' . $project_id . ' | end');
}
}
}
... ...
... ... @@ -137,6 +137,7 @@ class ProjectUpdate extends Command
//设置数据库
$project = ProjectServer::useProject($project_id);
$thumb_w = $project_info->deploy_build->thumb_w ?? 0;//缩略图压缩宽度
if ($project) {
if ($api_type == 'category') {
//产品分类
... ... @@ -332,6 +333,12 @@ class ProjectUpdate extends Command
$gallery[] = ['alt' => '', 'url' => $this->source_download($img, $project_id, $domain_arr['host'], $web_url_domain, $home_url)];
}
}
//缩略图
$thumb = $gallery[0] ?? [];
if (isset($thumb['url']) && $thumb['url']) {
//生成缩略图
$thumb['url'] = thumbImageByUrl($thumb['url'], $thumb_w);
}
//关键词
$keyword_id = '';
if ($item['tags'] ?? []) {
... ... @@ -371,7 +378,7 @@ class ProjectUpdate extends Command
'content' => $content,
'category_id' => $category_id,
'keyword_id' => $keyword_id,
'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '',
'thumb' => Arr::a2s($thumb),
'gallery' => Arr::a2s($gallery),
'attrs' => Arr::a2s($attrs),
'seo_mate' => Arr::a2s([
... ... @@ -417,7 +424,7 @@ class ProjectUpdate extends Command
'content' => $content,
'category_id' => $category_id,
'keyword_id' => $keyword_id,
'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '',
'thumb' => Arr::a2s($thumb),
'gallery' => Arr::a2s($gallery),
'attrs' => Arr::a2s($attrs),
'seo_mate' => Arr::a2s([
... ...
... ... @@ -1482,15 +1482,19 @@ function thumbImageByUrl($url, $width = 360)
return $url;
}
if ($width == 0) {
return $url;
}
if (strpos($url, '_thumb') !== false) {
return $url;
}
//获取图片完整访问地址
$url = getImageUrl($url);
$url_complete = getImageUrl($url);
//获取与原图存储路径相同的压缩路径
$path = parse_url($url, PHP_URL_PATH);
$path = parse_url($url_complete, PHP_URL_PATH);
$path_arr = explode('.', $path);
if (count($path_arr) != 2) {
return $url;
... ... @@ -1499,7 +1503,7 @@ function thumbImageByUrl($url, $width = 360)
$key = implode('.', $path_arr);
try {
$img = \Intervention\Image\Facades\Image::make($url);
$img = \Intervention\Image\Facades\Image::make($url_complete);
//宽度按设定,高度自动调整
$img->resize($width, null, function ($constraint) {
... ... @@ -1520,3 +1524,37 @@ function thumbImageByUrl($url, $width = 360)
return $url;
}
if (!function_exists('httpGetSsl')) {
/**
* 获取通配符证书
* @param $domain
* @return mixed
* @author Akun
* @date 2025/04/21 16:51
*/
function httpGetSsl($domain)
{
$header = array(
"Accept:application/json",
"Content-Type:application/json;charset=utf-8",
"X-CmerApi-Host:" . env('GET_SSL_HOST'),
"Apikey:" . env('GET_SSL_KEY'),
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, env('GET_SSL_URL') . '?domain=' . $domain);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
curl_close($ch);
$result = json_decode($res, true);
return is_array($result) ? $result : $res;
}
}
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Api;
use App\Exceptions\InquiryFilterException;
use App\Models\Domain\DomainInfo;
use App\Models\Mail\Mail;
use App\Models\Project\DeployBuild;
use App\Models\Project\Project;
... ... @@ -69,7 +70,7 @@ class SelfSiteController extends BaseController
$cos = new CosService();
$fileName = uniqid() . rand(10000, 99999) . '.' . $file['ext'];
$file_data = base64_decode($file['data']);
$path = $cos->uploadFile($file_data, '/inquiry/' . date('Ymd'), $fileName,true);
$path = $cos->uploadFile($file_data, '/inquiry/' . date('Ymd'), $fileName, true);
$data[$key] = [
'path' => $path,
'original_name' => $file['name'],
... ... @@ -191,4 +192,50 @@ class SelfSiteController extends BaseController
return $this->success([]);
}
/**
* 自建站获取通配符证书接口
* @param Request $request
* @return false|string
* @author Akun
* @date 2025/09/02 16:55
*/
public function selfSiteSsl(Request $request)
{
$token = $request->header('token');//token
$pid = $request->header('pid');//项目id
if (empty($token) || empty($pid)) {
return $this->error('token无效', 401);
}
//判断token是否有效
$project_model = new Project();
$project_info = $project_model->read(['id' => $pid, 'site_token' => $token]);
if (!$project_info) {
return $this->error('token无效', 401);
}
//获取域名信息
$domain_model = new DomainInfo();
$domain_info = $domain_model->read(['project_id' => $pid]);
if (!$domain_info) {
return $this->error('获取域名失败', 401);
}
//获取通配符证书
$top_domain = getTopDomain($domain_info['domain']);
$ssl_re = httpGetSsl($top_domain);
$return = [
'ssl_key' => '',
'ssl_cert' => ''
];
if (isset($ssl_re['status']) && $ssl_re['status'] == 2) {
//获取成功
$return['ssl_key'] = $ssl_re['ssl_key'];
$return['ssl_cert'] = $ssl_re['ssl_cert'];
}
return $this->success($return);
}
}
... ...
... ... @@ -359,7 +359,7 @@ class ProductLogic extends BaseLogic
$thumb = $param['gallery'][0] ?? [];
if(isset($thumb['url']) && $thumb['url']){
//生成缩略图
$thumb['url'] = thumbImageByUrl($thumb['url']);
$thumb['url'] = thumbImageByUrl($thumb['url'],$this->user['thumb_w']??0);
}
$param['thumb'] = Arr::a2s($thumb);
$param['gallery'] = Arr::a2s($param['gallery'] ?? []);
... ...
... ... @@ -322,6 +322,8 @@ class UserLoginLogic
$info['import_products_url'] = 'https://ecdn6.globalso.com/upload/p/1/file/2024-12/products.csv';
$info['import_news_url'] = 'https://ecdn6.globalso.com/upload/p/1/file/2024-12/news.csv';
$info['import_blogs_url'] = 'https://ecdn6.globalso.com/upload/p/1/file/2024-12/blogs.csv';
//缩略图宽度
$info['thumb_w'] = $project['deploy_build']['thumb_w'] ?? 0;
return $info;
}
... ...
... ... @@ -66,6 +66,7 @@ Route::any('get_monitor_keyword', [\App\Http\Controllers\Api\PrivateController::
Route::post('selfSiteApi', [\App\Http\Controllers\Api\SelfSiteController::class, 'selfSiteApi']);
Route::post('selfSiteNotify', [\App\Http\Controllers\Api\SelfSiteController::class, 'selfSiteNotify']);
Route::post('selfSiteVerify', [\App\Http\Controllers\Api\SelfSiteController::class, 'selfSiteVerify']);
Route::post('selfSiteSsl', [\App\Http\Controllers\Api\SelfSiteController::class, 'selfSiteSsl']);
//创建301跳转任务
Route::any('/addRedirect',[\App\Http\Controllers\Api\NoticeController::class,'addRedirect']);
... ...