diff --git a/config.php b/config.php
new file mode 100644
index 0000000..4d6004d
--- /dev/null
+++ b/config.php
@@ -0,0 +1,43 @@
+connect_error) {
+ // 返回错误信息而非直接终止
+ return [
+ 'success' => false,
+ 'error' => '连接失败: ' . $conn->connect_error .
+ '
服务器: ' . $db_host .
+ '
用户名: ' . $db_user .
+ '
数据库: ' . $db_name
+ ];
+ }
+
+ return [
+ 'success' => true,
+ 'connection' => $conn
+ ];
+ }
+?>
\ No newline at end of file
diff --git a/db_config.php b/db_config.php
new file mode 100644
index 0000000..5a47ee3
--- /dev/null
+++ b/db_config.php
@@ -0,0 +1,21 @@
+ PDO::ERRMODE_EXCEPTION,
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
+ PDO::ATTR_EMULATE_PREPARES => false,
+];
+
+try {
+ $conn = new PDO($dsn, $user, $pass, $options);
+} catch (\PDOException $e) {
+ throw new \PDOException($e->getMessage(), (int)$e->getCode());
+}
+?>
diff --git a/db_connect.php b/db_connect.php
new file mode 100644
index 0000000..57b4cbe
--- /dev/null
+++ b/db_connect.php
@@ -0,0 +1,56 @@
+ PDO::ERRMODE_EXCEPTION,
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
+ PDO::ATTR_EMULATE_PREPARES => false
+ ]
+ );
+} catch(PDOException $e) {
+ // 记录连接错误
+ $logMsg = date('[Y-m-d H:i:s] ') . "数据库连接错误: " . $e->getMessage() . "\n";
+ file_put_contents('db_error.log', $logMsg, FILE_APPEND);
+ $pdo = false;
+}
+
+// 如果数据库不存在,尝试创建(仅用于开发环境)
+if ($pdo && !isset($e)) {
+ try {
+ // 检查recommendations表是否存在,如果不存在则创建
+ $tableCheck = $pdo->query("SHOW TABLES LIKE 'recommendations'");
+ if ($tableCheck->rowCount() === 0) {
+ $createTableSql = "
+ CREATE TABLE recommendations (
+ id INT AUTO_INCREMENT PRIMARY KEY,
+ song_name VARCHAR(255) NOT NULL,
+ artist_name VARCHAR(255) NOT NULL,
+ reason TEXT,
+ file_path VARCHAR(512) NOT NULL,
+ status TINYINT NOT NULL DEFAULT 0 COMMENT '0:待审核,1:已同意,2:已驳回',
+ created_at DATETIME NOT NULL,
+ reviewed_at DATETIME NULL
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4";
+
+ $pdo->exec($createTableSql);
+ }
+ } catch(PDOException $e) {
+ $logMsg = date('[Y-m-d H:i:s] ') . "表创建错误: " . $e->getMessage() . "\n";
+ file_put_contents('db_error.log', $logMsg, FILE_APPEND);
+ }
+}
+?>
+
\ No newline at end of file
diff --git a/delete_recommendation.php b/delete_recommendation.php
new file mode 100644
index 0000000..bf07e6c
--- /dev/null
+++ b/delete_recommendation.php
@@ -0,0 +1,44 @@
+prepare($sql);
+ $stmt->bindParam(':id', $id, PDO::PARAM_INT);
+
+ // 执行删除
+ $result = $stmt->execute();
+
+ if ($result && $stmt->rowCount() > 0) {
+ header("Location: $adminHome?delete_status=success&msg=推荐已成功删除");
+ } else {
+ header("Location: $adminHome?delete_status=error&msg=删除失败,推荐不存在或已被删除");
+ }
+ } catch(PDOException $e) {
+ // 记录错误日志
+ $logMsg = date('[Y-m-d H:i:s] ') . "删除推荐错误: " . $e->getMessage() . "\n";
+ file_put_contents('db_error.log', $logMsg, FILE_APPEND);
+
+ header("Location: $adminHome?delete_status=error&msg=数据库错误,请稍后再试");
+ }
+} else {
+ header("Location: $adminHome?delete_status=error&msg=数据库连接失败");
+}
+
+exit;
+?>
\ No newline at end of file
diff --git a/forgot_password.php b/forgot_password.php
new file mode 100644
index 0000000..9deb2da
--- /dev/null
+++ b/forgot_password.php
@@ -0,0 +1,432 @@
+query($sql)) {
+ return "创建密码重置表失败: " . $conn->error;
+ }
+ return true;
+ }
+
+ // 生成随机令牌
+ function generateToken() {
+ return bin2hex(random_bytes(32));
+ }
+
+ // 使用QQ SMTP发送密码重置邮件
+ function sendResetEmailViaQQSMTP($toEmail, $resetLink, $smtpHost, $smtpPort, $smtpUsername, $smtpPassword, $fromName) {
+ // 邮件主题
+ $subject = "=?UTF-8?B?" . base64_encode("密码重置请求 - 音乐分享网站") . "?=";
+
+ // 邮件内容
+ $message = '
+
+
您好!我们收到了您的密码重置请求,若此操作非您本人发起,请忽略此邮件。
+请点击下方按钮重置您的密码(链接有效期为1小时,过期后需重新申请):
+若按钮无法点击,可将下方链接复制到浏览器地址栏访问:
++ ' . htmlspecialchars($resetLink) . ' +
+