作者 张关杰

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into bate

... ... @@ -83,23 +83,28 @@ class DomainInfo extends Command
public function startUpdateCert()
{
$domainModel = new DomainInfoModel();
$end_day = date('Y-m-d H:i:s', time() + 2 * 24 * 3600);//2天后到期
$end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期
$list = $domainModel->where('status', '!=', 2)->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'];
$domainModel->edit($data, ['id' => $v['id']]);
if ($v['type'] == 1 && ($data['certificate_end_time'] ?? '') < $end_day) {
if ($v['type'] == 1 && $ssl['to'] < $end_day) {
//申请免费证书
$this->updatePrivate($v);
$ssl_new = $this->updateDomainSsl($v['domain']);
$ssl_new['from'] && $data['certificate_start_time'] = $ssl_new['from'];
$ssl_new['to'] && $data['certificate_end_time'] = $ssl_new['to'];
}
$domainModel->edit($data, ['id' => $v['id']]);
}
}
... ... @@ -111,7 +116,7 @@ class DomainInfo extends Command
public function startUpdateAmpCert()
{
$domainModel = new DomainInfoModel();
$end_day = date('Y-m-d H:i:s', time() + 2 * 24 * 3600);//2天后到期
$end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期
$list = $domainModel->where('status', '!=', 2)->where('amp_status', 1)->where(function ($query) use ($end_day) {
$query->whereNull('amp_certificate_end_time')->orWhere('amp_certificate_end_time', '<', $end_day);
})->get()->toArray();
... ... @@ -132,12 +137,16 @@ class DomainInfo extends Command
$ssl['from'] && $data['amp_certificate_start_time'] = $ssl['from'];
$ssl['to'] && $data['amp_certificate_end_time'] = $ssl['to'];
$domainModel->edit($data, ['id' => $v['id']]);
if ($v['amp_type'] == 1 && ($data['amp_certificate_end_time'] ?? '') < $end_day) {
if ($v['amp_type'] == 1 && $ssl['to'] < $end_day) {
//申请免费证书
$this->updateAmpPrivate($v['domain']);
$ssl_new = $this->updateDomainSsl($v['domain']);
$ssl_new['from'] && $data['certificate_start_time'] = $ssl_new['from'];
$ssl_new['to'] && $data['certificate_end_time'] = $ssl_new['to'];
}
$domainModel->edit($data, ['id' => $v['id']]);
}
}
... ... @@ -149,7 +158,7 @@ class DomainInfo extends Command
public function startUpdateCustomCert()
{
$customModel = new CountryCustom();
$end_day = date('Y-m-d H:i:s', time() + 2 * 24 * 3600);//2天后到期
$end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期
$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();
... ... @@ -160,12 +169,16 @@ class DomainInfo extends Command
$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) {
if ($v['type'] == 1 && $ssl['to'] < $end_day) {
//申请免费证书
$this->updateCustomPrivate($v['custom_domain']);
$ssl_new = $this->updateDomainSsl($v['domain']);
$ssl_new['from'] && $data['certificate_start_time'] = $ssl_new['from'];
$ssl_new['to'] && $data['certificate_end_time'] = $ssl_new['to'];
}
$customModel->edit($data, ['id' => $v['id']]);
}
}
... ... @@ -297,6 +310,8 @@ class DomainInfo extends Command
*/
public function updateDomainSsl($domain)
{
$valid_from = '';
$valid_to = '';
try {
$context = stream_context_create([
'ssl' => [
... ... @@ -307,15 +322,13 @@ class DomainInfo extends Command
],
]);
$stream = stream_socket_client('ssl://' . $domain . ':443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
if (!$stream) {
die("Failed to connect: $errno - $errstr");
}
$remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate'];
if (!$remote_cert) {
die("Failed to retrieve certificate");
if($stream){
$remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate'];
if($remote_cert){
$valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']);
$valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']);
}
}
$valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']);
$valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']);
fclose($stream);
} catch (\Exception $e) {
$valid_from = '';
... ...
... ... @@ -65,7 +65,7 @@ class RankData extends BaseCommands
$error = 0;
$api = new QuanqiusouApi();
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>', 0)->select('api_no', 'minor_languages', 'project_id')->get();
$list = DeployOptimize::where('api_no', '>', 0)->select('api_no', 'minor_languages', 'project_id')->orderBy('project_id', 'asc')->get();
Log::channel('rank_data')->info('开始-排名数据-' . count($list));
//当日所有站点谷歌收录数据
$site_res = $api->getSiteRes();
... ... @@ -73,7 +73,7 @@ class RankData extends BaseCommands
Log::channel('rank_data')->error('谷歌收录数据获取失败');
}
foreach ($list as $item) {
echo $item['api_no'] . PHP_EOL;
Log::channel('rank_data')->info('项目开始:ID' . $item['project_id'] .' - '. $item['api_no']) . '';
try {
(new RankDataLogic())->syncRankData($item['api_no'], $site_res);
} catch (\Exception $e) {
... ...
... ... @@ -55,7 +55,7 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>951]);
$list = $projectModel->list(['id'=>687]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
... ...
... ... @@ -19,6 +19,7 @@ class Kernel extends ConsoleKernel
$schedule->command('remain_day')->dailyAt('08:00')->withoutOverlapping(1); // 项目剩余服务时长
$schedule->command('rank_data_task')->everyMinute()->withoutOverlapping(1); // 排名数据更新任务
$schedule->command('rank_data')->dailyAt('07:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次
$schedule->command('rank_data')->dailyAt('08:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次
$schedule->command('rank_data_speed')->dailyAt('01:10')->withoutOverlapping(1); // 排名数据-测速数据,每周一凌晨执行一次
$schedule->command('rank_data_external_links')->dailyAt('08:30')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次
$schedule->command('rank_data_external_links')->dailyAt('18:00')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次
... ...
... ... @@ -80,7 +80,6 @@ class AyrReleaseController extends BaseController
$param['youTubeOptions'] = ['title'=>$this->param['title']];
}
}
if(isset($this->param['schedule_date']) && !empty($this->param['schedule_date'])){
$datetime = new \DateTime($this->param['schedule_date'] ?? date('Y-m-d H:i:s'));
$formattedTime = $datetime->format("Y-m-d\TH:i:s\Z");
... ...
... ... @@ -129,8 +129,8 @@ class FileController
$amazonS3Service = new AmazonS3Service();
$amazonS3Service->uploadFiles($files,$this->path,$fileName);
}
$this->synchronizationFile($files->getClientOriginalExtension(),$fileName);
$this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name);
$this->synchronizationFile($files->getClientOriginalExtension(),$fileName);
$this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
}
... ... @@ -142,14 +142,10 @@ class FileController
* @time :2024/4/8 11:10
*/
public function synchronizationFile($file_type,$fileName){
$fileTypeArr = ['zip', 'pdf', 'mp4', 'doc', 'docx', 'm4v', 'xlsx'];
if(in_array($file_type,$fileTypeArr)){
//同步到大文件
$file_path = getFileUrl($this->path.'/'.$fileName,$this->cache['storage_type'] ?? 0);
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->path.'" https://v6-file.globalso.com/upload.php';
shell_exec($cmd);
}
return true;
//同步到大文件
$file_path = getFileUrl($this->path.'/'.$fileName,$this->cache['storage_type'] ?? 0);
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->path.'" https://v6-file.globalso.com/upload.php';
shell_exec($cmd);
}
/**
... ... @@ -266,6 +262,7 @@ class FileController
$mime = $file->getMimeType();
$this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime,$name);
$data[] = $this->responseData($this->path.'/'.$fileName, $name);
$this->synchronizationFile($file_type,$fileName);
}
$this->response('资源',Code::SUCCESS,$data);
}
... ...
... ... @@ -210,10 +210,25 @@ class ImageController extends Controller
$amazonS3Service->uploadFiles($files,$this->path,$fileName);
}
$this->saveMysql($imageModel,$files->getSize(),$image_type,$fileName,$hash,$this->upload_location,$files->getMimeType(), $name);
$this->synchronizationImage($fileName);
return $this->response('图片资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
}
/**
* @remark :指定同步文件到獨立177服務器
* @name :synchronizationFile
* @author :lyh
* @method :post
* @time :2024/4/8 11:10
*/
public function synchronizationImage($fileName){
//同步到大文件
$file_path = getImageUrl($this->path.'/'.$fileName,$this->cache['storage_type'] ?? 0);
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->path.'" https://v6-file.globalso.com/upload.php';
shell_exec($cmd);
}
/**
* @remark :保存数据库
* @name :saveMysql
* @author :lyh
... ... @@ -290,6 +305,7 @@ class ImageController extends Controller
}
//批量存储
$this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name);
$this->synchronizationImage($fileName);
$data[] = $this->responseData($this->path.'/'.$fileName,$name);
}
$this->response('图片资源',Code::SUCCESS,$data);
... ...
... ... @@ -266,6 +266,8 @@ class ProjectLogic extends BaseLogic
protected function saveProjectDeployBuild($deploy_build){
$deployBuildModel = new DeployBuild();
$deploy_build['configuration'] = Arr::a2s(!empty($deploy_build['configuration']) ? $deploy_build['configuration'] : []);
$deploy_build['main_verify_file'] = $deploy_build['main_verify_file'] ?? '';
$deploy_build['amp_verify_file'] = $deploy_build['amp_verify_file'] ?? '';
$deployBuildModel->edit($deploy_build,['id'=>$deploy_build['id']]);
return $this->success();
}
... ...
... ... @@ -59,18 +59,18 @@ class AyrReleaseLogic extends BaseLogic
*/
public function image_file_param($data) {
$arr = [];
foreach ($data as $k => $v){
if($k == 'images'){
foreach ($v as $v1){
$v1 = 'https://file.globalso.com'.str_replace_url($v1);
$arr[] = $v1;
if(!empty($data)){
foreach ($data as $k => $v){
if($k == 'images'){
foreach ($v as $v1){
$arr[] = getImageUrl($v1);
}
}else{
$arr[] = getFileUrl($v);
}
}else{
$v = 'https://file.globalso.com'.str_replace_url($v);
$arr[] = $v;
}
}
return $this->success($arr);
return $this->success($arr);
}
}
... ...
... ... @@ -518,8 +518,6 @@ class ProductLogic extends BaseLogic
'created_uid'=>$this->user['id'],
'created_at'=>date('Y-m-d H:i:s'),
'updated_at'=>date('Y-m-d H:i:s'),
'six_read'=>$info['six_read'],
'is_upgrade'=>$info['is_upgrade']
];
if(isset($info['icon']) && !empty($info['icon'])){
foreach ($info['icon'] as $k1 => $v1){
... ...
... ... @@ -724,7 +724,7 @@ class RankDataLogic extends BaseLogic
}
$rank_week->project_id = $project_id;
$rank_week->data = $res['data'][$api_no];
$rank_week->data = $res['data'][$api_no] ?? [];
$rank_week->date = $res['date'];
$rank_week->updated_date = date('Y-m-d');
$rank_week->save();
... ...
... ... @@ -26,17 +26,18 @@ class TranslateLogic extends BaseLogic
}
/**
* 获取翻译校对文案
* @return array
* @throws \App\Exceptions\AsideGlobalException
* @throws \App\Exceptions\BsideGlobalException
* @remark :
* @name :getTranslateList
* @author :lyh
* @method :post
* @time :2024/4/9 10:59
*/
public function getTranslateList(){
$data = [];
if($this->param['url'] == 'All'){
if($this->param['url'] == 'All' || $this->param['url'] == 'other_all_text'){
$info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]);
if(!empty($info) && !empty($info['data'])){
$translateInfo = json_decode($info['data'],JSON_UNESCAPED_UNICODE);
$translateInfo = json_decode($info['data'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
foreach ($translateInfo as $k => $v){
$data[] = [$k=>$v];
}
... ... @@ -49,18 +50,22 @@ class TranslateLogic extends BaseLogic
$languageInfo = $this->getLanguage($this->param['language_id']);
// 原始校对内容
$info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]);
//获取当前URl的所有文本内容
$text_array = $this->getUrlRead($url);
// 原始校对程序
$old_key = [];//key值组成数据
if($info !== false){
$data_read = json_decode($info['data'],JSON_UNESCAPED_UNICODE);
$data_read = json_decode($info['data'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
foreach ($data_read as $k => $v){
$old_key[] = $k;
$data[] = [$k => $v];
}
return $this->success($data);
}else{
//获取当前URl的所有文本内容
$text_array = $this->getUrlRead($url);
}
$arr2 = array_values(array_diff($text_array, $old_key));
if(!empty($arr2)){
$i = 0;
TranslateText:
$translate_list = Translate::tran($text_array, $languageInfo['short']);
$translate_list = Translate::tran($arr2, $languageInfo['short']);
if(empty($translate_list)){
if ($i < 3) {
$i++;
... ... @@ -68,57 +73,22 @@ class TranslateLogic extends BaseLogic
}
$this->fail('翻译失败,请稍后重试!');
}
if(count($text_array) == 1){
if(count($arr2) == 1){
$data[] = [
$text_array[0]=>$translate_list
$arr2[0]=>$translate_list
];
}else{
foreach ($text_array as $k => $v){
foreach ($arr2 as $k => $v){
$data[] = [
$v=>$translate_list[$k]
];
}
}
return $this->success($data);
}
return $this->success($data);
}
// $old_key = [];//key值组成数据
// if($info !== false){
// $data_read = json_decode($info['data']);
// foreach ($data_read as $k => $v){
//// if(!in_array($k,$text_array)){
//// $arr2[] = $k;
//// }
//// $old_key[] = $k;
// $data[] = [$k => $v];
// }
// }else{
// $arr2 = array_values(array_diff($text_array, $old_key));
// }
// if(!empty($arr2)){
// $i = 0;
// TranslateText:
// $translate_list = Translate::tran($arr2, $languageInfo['short']);
// if(empty($translate_list)){
// if ($i < 3) {
// $i++;
// goto TranslateText;
// }
// $this->fail('翻译失败,请稍后重试!');
// }
// if(count($arr2) == 1){
// $data[] = [
// $arr2[0]=>$translate_list
// ];
// }else{
// foreach ($arr2 as $k => $v){
// $data[] = [
// $v=>$translate_list[$k]
// ];
// }
// }
// }
/**
* @remark :获取图片列表
... ... @@ -153,7 +123,7 @@ class TranslateLogic extends BaseLogic
}
$new_list = $this->getUrlImageRead($url);
$old_list = [];
$data_read = json_decode($info['data'],JSON_UNESCAPED_UNICODE);
$data_read = json_decode($info['data'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
foreach ($data_read as $k=>$v){
$old_list[] = $k;
$data[] = [
... ... @@ -285,11 +255,11 @@ class TranslateLogic extends BaseLogic
'language_id'=>$this->param['language_id'],
'alias'=>$this->param['alias'],
];
$param['data'] = json_encode($data,JSON_UNESCAPED_UNICODE);
$param['data'] = json_encode($data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$this->model->add($param);
}else{
if(!empty($data)){
$data = json_encode($data,JSON_UNESCAPED_UNICODE);
$data = json_encode($data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$this->model->edit(['data'=>$data],['language_id'=>$this->param['language_id'],'project_id'=>$this->user['project_id'],'url'=>$this->param['url'],'type'=>$this->param['type']]);
}
}
... ...
... ... @@ -4,6 +4,7 @@ namespace App\Models\Inquiry;
use App\Helper\FormGlobalsoApi;
use App\Models\Base;
use App\Utils\LogUtils;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\DB;
... ... @@ -83,7 +84,10 @@ class InquiryFormData extends Base
$data['message'].= "<br/>" . $k .': ' . $v;
}
}
!$has_file && (new FormGlobalsoApi())->submitInquiry($ip, $referer, $submit_at, $data);
if(!$has_file) {
$res = (new FormGlobalsoApi())->submitInquiry($ip, $referer, $submit_at, $data);
LogUtils::info('询盘提交', $data, $res?: []);
}
}
return true;
}
... ...
... ... @@ -13,8 +13,6 @@ use Illuminate\Database\Eloquent\SoftDeletes;
*/
class Category extends Base
{
use SoftDeletes;
//设置关联表名
protected $table = 'gl_product_category';
//连接数据库
... ...
... ... @@ -69,7 +69,8 @@ class SyncSubmitTaskService
];
if(Str::contains($referer, $url)){
$referer = pathinfo($referer,PATHINFO_DIRNAME);
$referer = parse_url($referer);
$referer = !empty($referer['host']) ? $referer['scheme'] . '://' . $referer['host'] . '/' : $referer['path'];
}
return $referer;
}
... ... @@ -171,8 +172,8 @@ class SyncSubmitTaskService
throw new InquiryFilterException('项目不存在');
}
// 测试环境返回信息
if (FALSE !== strpos($domain, 'globalso.site') && !$project->is_record_test_visit) {
// 访问记录过滤测试环境
if ($type == SyncSubmitTask::TYPE_VISIT && FALSE !== strpos($domain, 'globalso.site') && !$project->is_record_test_visit) {
throw new InquiryFilterException('测试环境过滤');
}
... ... @@ -180,8 +181,8 @@ class SyncSubmitTaskService
throw new InquiryFilterException('127.0.0.1过滤');
}
$country = self::getCountryByIp($ip);
//访问记录才过滤是否国内
if ($country == "中国" && !$project->is_record_china_visit && $type == SyncSubmitTask::TYPE_VISIT){
//访问记录过滤国内
if ($type == SyncSubmitTask::TYPE_VISIT && $country == "中国" && !$project->is_record_china_visit){
throw new InquiryFilterException('中国内地过滤');
}
return [
... ...