作者 张关杰

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

<?php
/**
* @remark :
* @name :SyncFile.php
* @author :lyh
* @method :post
* @time :2024/4/17 10:05
*/
namespace App\Console\Commands\SyncFile;
use App\Models\File\ErrorFile;
use Illuminate\Console\Command;
class SyncFile extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sync_file';
/**
* The console command description.
*
* @var string
*/
protected $description = '同步图片与文件';
public function handle(){
$errorFileModel = new ErrorFile();
$lists = $errorFileModel->list(['status'=>0]);//未同步成功的图片及文件
foreach ($lists as $k => $v){
$code = $this->synchronizationFile($v['path']);
if((int)$code == 200){
echo date('Y-m-d H:i:s') . '编辑的path为:'. $v['path'] .',主键id:'. $v['id'] . PHP_EOL;
$errorFileModel->edit(['status'=>1],['id'=>$v['id']]);
}
}
echo date('Y-m-d H:i:s') . '编辑的end为:' . PHP_EOL;
return true;
}
/**
* @remark :指定同步文件到獨立177服務器
* @name :synchronizationFile
* @author :lyh
* @method :post
* @time :2024/4/8 11:10
*/
public function synchronizationFile($path_name){
//同步到大文件
$file_path = config('filesystems.disks.cos')['cdn1'].$path_name;
$directoryPath = pathinfo($path_name, PATHINFO_DIRNAME);
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php';
return shell_exec($cmd);
}
}
... ...
... ... @@ -35,11 +35,12 @@ class EditVideoMp4 extends Command
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>1]);
$list = $projectModel->list(['is_upgrade'=>0,'delete_status'=>0,'type'=>['!=',0],'id'=>['<=',82]]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$this->copyTable();
$this->getHtml();
DB::disconnect('custom_mysql');
}
... ... @@ -56,9 +57,11 @@ class EditVideoMp4 extends Command
public function getHtml(){
$templateModel = new BTemplate();
$templateList = $templateModel->list();
if(!empty($templateList)){
foreach ($templateList as $v1){
$this->getVideoSrc($v1['id'],$v1['main_html'],'main_html',$templateModel);
}
}
return true;
}
... ... @@ -73,11 +76,13 @@ class EditVideoMp4 extends Command
$pattern = '/<video.*?src="([^"]+)"[^>]*>/i';
preg_match_all($pattern, $html, $matches);
$srcLinks = $matches[1];
if(!empty($srcLinks)){
foreach ($srcLinks as $link) {
$newLink = str_replace('ecdn6.globalso.com','v6-file.globalso.com', $link);
$html = str_replace($link, $newLink, $html);
}
$model->edit([$filed=>$html],['id'=>$id]);
}
return true;
}
... ... @@ -92,7 +97,7 @@ class EditVideoMp4 extends Command
public function copyTable(){
// 原始表名和新表名
$originalTableName = "gl_web_template";
$newTableName = "gl_web_template_copy";
$newTableName = "gl_web_template_c";
// 检查原始表是否存在
DB::connection('custom_mysql')->select("SHOW TABLES LIKE '{$originalTableName}'");
DB::connection('custom_mysql')->statement("CREATE TABLE {$newTableName} LIKE {$originalTableName}");
... ...
... ... @@ -64,7 +64,10 @@ class TranslateLogic extends BaseLogic
}
$arr2 = [];
foreach ($text_array as $val) {
if (FALSE == in_array($val, $old_key)){
if($val == ' '){
continue;
}
if (FALSE == in_array(trim(urldecode($val),' '), $old_key)){
$arr2[] = $val;
}
}
... ...