From 2a4cb402251068dc6bb4351cd85cc48f637dd32c Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Sat, 12 Apr 2025 14:49:20 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=95=B0=E6=8D=AE=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/command/DataMigration.php | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/app/command/DataMigration.php b/app/command/DataMigration.php index 8fc74105..44cd2c7d 100644 --- a/app/command/DataMigration.php +++ b/app/command/DataMigration.php @@ -38,15 +38,15 @@ class DataMigration extends Command // $this->productCategory(); // 迁移文章 - $this->migrateArticle([ - 1 => 2, - 2 => 3, - 33 => 4, - 36 => 5, - 16 => 7, - 31 => 8, - 32 => 9 - ]); + // $this->migrateArticle([ + // 1 => 2, + // 2 => 3, + // 33 => 4, + // 36 => 5, + // 16 => 7, + // 31 => 8, + // 32 => 9 + // ]); // 迁移faq // $this->migrateFaq(); @@ -258,12 +258,19 @@ class UploadMannager } $url = self::DOWNLOAD_BASE_API . \think\helper\Str::substr($file_name, mb_strpos($file_name, $need) + mb_strlen($need)); } else { - $url = self::DOWNLOAD_BASE_API . $file_name; + $url = self::DOWNLOAD_BASE_API . str_replace(" ", "%20", $file_name); } $file_path = self::DOWNLOAD_TEMP_PATH . $file_name; - $file = file_get_contents($url); - $dir = dirname($file_path); + $opts = [ + 'http' => [ + 'method' => 'GET', + 'header' => 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)' + ] + ]; + $context = stream_context_create($opts); + $file = file_get_contents($url, false, $context); + $dir = dirname($file_path); if (!is_dir($dir)) { mkdir($dir, 0777, true); }