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