From 91bde9fa4b7bf0ee3cedd584df4d33c5149cee59 Mon Sep 17 00:00:00 2001 From: cloud Date: Mon, 23 Dec 2024 12:34:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9curl=E5=A2=9E=E5=8A=A0=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/admin/index.class.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/admin/index.class.php b/src/admin/index.class.php index 3c3f4a8..2a156e7 100644 --- a/src/admin/index.class.php +++ b/src/admin/index.class.php @@ -1088,9 +1088,23 @@ class curls $data = curl_exec($curl); $code = curl_getinfo($curl, CURLINFO_HTTP_CODE); //http响应码 $errno = curl_errno($curl); //错误码 + $error = curl_error($curl); // 获取cURL错误信息 curl_close($curl); - $this->data = empty($errno) ? $data : $this->appcore->codemsg(4011, "{$code}-{$errno}")->coderes(false); +// $this->data = empty($errno) ? $data : $this->appcore->codemsg(4011, "{$code}-{$errno}")->coderes(false); + if ($errno){ + // 如果发生错误,记录错误信息到日志文件 + $logMessage = "[" . date('Y-m-d H:i:s') . "] ERROR: HTTP Code: $code, cURL Error No: $errno, Error: $error\n"; + file_put_contents(PATH_APP_FILE.'config/curl_error.log', $logMessage, FILE_APPEND); // 将日志追加到文件中 + + $this->data = $this->appcore->codemsg(4011, "{$code}-{$errno}")->coderes(false); + }else{ + $this->data = $data; + } } else { + // 如果发生错误,记录错误信息到日志文件 + $logMessage = "[" . date('Y-m-d H:i:s') . "] ERROR: cURL extension is not available.\n"; + file_put_contents(PATH_APP_FILE.'config/curl_error_b.log', $logMessage, FILE_APPEND); // 将日志追加到文件中 + $this->data = $this->appcore->codemsg(4000)->coderes(false); } return $this;