作者 赵彬吉
@@ -80,7 +80,7 @@ class TemplateLog extends Command @@ -80,7 +80,7 @@ class TemplateLog extends Command
80 * @time :2024/11/13 16:19 80 * @time :2024/11/13 16:19
81 */ 81 */
82 public function deleteUserLog(){ 82 public function deleteUserLog(){
83 - $date = date('Y-m-d H:i:s', strtotime('-30 days')); 83 + $date = date('Y-m-d H:i:s', strtotime('-60 days'));
84 $userLogModel = new UserLog(); 84 $userLogModel = new UserLog();
85 return $userLogModel->del(['created_at'=>['<=',$date]]); 85 return $userLogModel->del(['created_at'=>['<=',$date]]);
86 } 86 }
@@ -62,25 +62,49 @@ class FileManageController extends BaseController @@ -62,25 +62,49 @@ class FileManageController extends BaseController
62 * @method :post 62 * @method :post
63 * @time :2023/12/28 17:18 63 * @time :2023/12/28 17:18
64 */ 64 */
65 - public function downLoad(){  
66 - if(!isset($this->param['path']) || empty($this->param['path'])){  
67 - $this->response('参数错误',Code::SYSTEM_ERROR); 65 + public function downLoad()
  66 + {
  67 + // 检查参数
  68 + if (!isset($this->param['path']) || empty($this->param['path'])) {
  69 + $this->response('参数错误', Code::SYSTEM_ERROR);
68 } 70 }
69 $username = basename($this->param['path']); 71 $username = basename($this->param['path']);
70 $parsed_url = parse_url($this->param['path']); 72 $parsed_url = parse_url($this->param['path']);
71 - if(isset($parsed_url['scheme'])){  
72 - $fileUrl = $this->param['path'];  
73 - } else {  
74 - $fileUrl = 'https://file.globalso.com'.$this->param['path']; 73 + // 构造文件 URL
  74 + $fileUrl = isset($parsed_url['scheme'])
  75 + ? $this->param['path']
  76 + : 'https://file.globalso.com' . $this->param['path'];
  77 + // 初始化 curl
  78 + $ch = curl_init();
  79 + curl_setopt($ch, CURLOPT_URL, $fileUrl);
  80 + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  81 + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  82 + curl_setopt($ch, CURLOPT_HEADER, false);
  83 + // 跳过 SSL 验证
  84 + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  85 + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  86 + // 执行 curl 请求
  87 + $fileContent = curl_exec($ch);
  88 + $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  89 + $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
  90 + $curlError = curl_error($ch);
  91 + curl_close($ch);
  92 + // 检查 curl 错误或 HTTP 状态码
  93 + if ($fileContent === false || $httpCode != 200) {
  94 + $errorMsg = $fileContent === false ? "Curl Error: $curlError" : "HTTP Error: $httpCode";
  95 + $this->response("文件下载失败 - $errorMsg", Code::SYSTEM_ERROR);
75 } 96 }
76 // 设置响应头 97 // 设置响应头
77 header('Content-Description: File Transfer'); 98 header('Content-Description: File Transfer');
78 - header('Content-Type: application/octet-stream'); 99 + header('Content-Type: ' . ($contentType ?: 'application/octet-stream'));
79 header('Content-Disposition: attachment; filename="' . $username . '"'); 100 header('Content-Disposition: attachment; filename="' . $username . '"');
80 - // 下载文件  
81 - readfile($fileUrl); 101 + header('Content-Length: ' . strlen($fileContent));
  102 + // 输出文件内容
  103 + echo $fileContent;
  104 + exit;
82 } 105 }
83 106
  107 +
84 public function upload(Request $request, FileManage $fileManage){ 108 public function upload(Request $request, FileManage $fileManage){
85 $request->validate([ 109 $request->validate([
86 'file'=>['required'], 110 'file'=>['required'],
@@ -105,6 +105,8 @@ class TranslateController extends BaseController @@ -105,6 +105,8 @@ class TranslateController extends BaseController
105 $translate_data[$value] = ''; 105 $translate_data[$value] = '';
106 } 106 }
107 } 107 }
  108 + }else{
  109 + $translate_data = json_decode($values['translate_data']['data'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
108 } 110 }
109 $resData['data'] = $translate_data ?? []; 111 $resData['data'] = $translate_data ?? [];
110 $res_data[] = $resData; 112 $res_data[] = $resData;
@@ -17,6 +17,8 @@ use App\Models\WebSetting\TranslateData; @@ -17,6 +17,8 @@ use App\Models\WebSetting\TranslateData;
17 use App\Models\WebSetting\WebLanguage; 17 use App\Models\WebSetting\WebLanguage;
18 use App\Helper\Translate; 18 use App\Helper\Translate;
19 use Illuminate\Support\Facades\DB; 19 use Illuminate\Support\Facades\DB;
  20 +use Illuminate\Support\Str;
  21 +
20 class TranslateLogic extends BaseLogic 22 class TranslateLogic extends BaseLogic
21 { 23 {
22 public function __construct() 24 public function __construct()
@@ -75,6 +77,7 @@ class TranslateLogic extends BaseLogic @@ -75,6 +77,7 @@ class TranslateLogic extends BaseLogic
75 if($val == ' ' || $val == ''){ 77 if($val == ' ' || $val == ''){
76 continue; 78 continue;
77 } 79 }
  80 + $val = trim(trim($val,' '));
78 if (FALSE == in_array(trim(urldecode($val),' '), $old_key)){ 81 if (FALSE == in_array(trim(urldecode($val),' '), $old_key)){
79 $arr2[] = $val; 82 $arr2[] = $val;
80 } 83 }