From e8677d6b8f399abb363889a7108ffcbf94e05952 Mon Sep 17 00:00:00 2001 From: admin <15630053159@163.com> Date: Fri, 27 Nov 2026 15:42:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- change_password.php | 114 +++++++++++++++ config.example.php | 9 ++ config.php | 27 ++++ delete_image.php | 75 ++++++++++ gallery.php | 338 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 563 insertions(+) create mode 100644 change_password.php create mode 100644 config.example.php create mode 100644 config.php create mode 100644 delete_image.php create mode 100644 gallery.php diff --git a/change_password.php b/change_password.php new file mode 100644 index 0000000..d347edd --- /dev/null +++ b/change_password.php @@ -0,0 +1,114 @@ += 8 && strlen($pw) <= 64 + && preg_match('/[A-Za-z]/', $pw) && preg_match('/\d/', $pw) + && preg_match('/^[\x21-\x7e]+$/', $pw); // 可打印 ASCII,禁空格/中文 +} + +if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['change_password']) && !$locked) { + if (!csrf_ok()) { + $message = '请求校验失败,请刷新页面重试。'; + } else { + $current = $_POST['current_password'] ?? ''; + $new = $_POST['new_password'] ?? ''; + + if (!strong_password_ok($new)) { + $message = $password_rule . '。'; + } elseif ($new === $current) { + $message = '新密码不能与当前密码相同。'; + } else { + $stmt = $conn->prepare("SELECT password FROM photo_users WHERE user_id = ?"); + $stmt->bind_param("i", $user['user_id']); + $stmt->execute(); + $hash = $stmt->get_result()->fetch_assoc()['password'] ?? ''; + $stmt->close(); + + if (!password_verify($current, $hash)) { + $message = '当前密码错误。'; + } else { + $newHash = password_hash($new, PASSWORD_DEFAULT); + $upd = $conn->prepare("UPDATE photo_users SET password = ?, must_change_password = 0 WHERE user_id = ?"); + $upd->bind_param("si", $newHash, $user['user_id']); + $ok = $upd->execute(); + $upd->close(); + $message = $ok ? '密码已修改成功。' : '修改失败,请稍后再试。'; + if ($ok && $forced) { + $_SESSION['login_pending_pwd'] = false; + flash_set('success', '密码已更新,欢迎使用'); + header($user['is_admin'] ? 'Location: admin.php' : 'Location: gallery.php'); + exit; + } + } + } + } +} + +render_header('修改密码', $user, 'change_password.php', '账号安全'); +?> +