From c84d259b1e3f9e71ee46be3e5c22d0e5a5094551 Mon Sep 17 00:00:00 2001 From: zgcwkj Date: Fri, 18 Apr 2025 16:44:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8A=9F=E8=83=BD=201?= =?UTF-8?q?=E3=80=81=E5=9C=A8=E6=A0=B9=E7=9B=AE=E5=BD=95=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B9=E9=97=AE=E9=A2=98=202=E3=80=81?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=20OpenSSL=20=E6=97=B6=EF=BC=8C=E5=BF=BD?= =?UTF-8?q?=E7=95=A5=E5=AE=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/function.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/app/function.php b/app/function.php index 08ef5c5..1f3384d 100644 --- a/app/function.php +++ b/app/function.php @@ -244,13 +244,14 @@ function config_path($path = null) // php7.0 $path = $path ?? date('Y/m/d/'); $img_path = $config['path'] . $path; - - if (!is_dir($img_path)) { - @mkdir($img_path, 0755, true); + + //检查文件夹状态 + $img_path_root = APP_ROOT . $img_path; + if (!is_dir($img_path_root)) { + @mkdir($img_path_root, 0755, true); } - - if (!is_writable($img_path)) { - @chmod($img_path, 0755); + if (!is_writable($img_path_root)) { + @chmod($img_path_root, 0755); } return $img_path; @@ -567,9 +568,17 @@ function urlHash($data, $mode, $key = null) $iv = 'sciCuBC7orQtDhTO'; if ($mode) { - return openssl_decrypt(base64_decode($data), "AES-128-XTS", $key, 0, $iv); + //如果没有 OpenSSL 的则用 Base64 函数解码 + if (function_exists('openssl_decrypt')){ + return openssl_decrypt(base64_decode($data), "AES-128-XTS", $key, 0, $iv); + } + return base64_decode($data); } else { - return base64_encode(openssl_encrypt($data, "AES-128-XTS", $key, 0, $iv)); + //如果没有 OpenSSL 的则用 Base64 函数编码 + if (function_exists('openssl_encrypt')){ + return base64_encode(openssl_encrypt($data, "AES-128-XTS", $key, 0, $iv)); + } + return base64_encode($data); } }