diff --git a/admin/review_apps.php b/admin/review_apps.php
index 7c7c101..30b6112 100644
--- a/admin/review_apps.php
+++ b/admin/review_apps.php
@@ -1,5 +1,8 @@
bind_param("ssi", $status, $rejectionReason, $appId);
if ($stmt->execute()) {
+ // 获取应用信息和开发者邮箱
+ $getAppStmt = $conn->prepare("SELECT name, developer_email FROM apps WHERE id = ?");
+ $getAppStmt->bind_param("i", $appId);
+ $getAppStmt->execute();
+ $appResult = $getAppStmt->get_result();
+ $appInfo = $appResult->fetch_assoc();
+ $getAppStmt->close();
+
$success = '应用审核已更新';
+ $appName = $appInfo['name'] ?? '未知应用';
+ $devEmail = $appInfo['developer_email'] ?? '';
+
+ // 发送邮件通知
+ if (!empty($devEmail)) {
+ $mail = new PHPMailer(true);
+ try {
+ // 服务器配置
+ $mail->isSMTP();
+ $mail->Host = SMTP_HOST;
+ $mail->Port = SMTP_PORT;
+ $mail->SMTPSecure = SMTP_ENCRYPTION;
+ $mail->SMTPAuth = true;
+ $mail->Username = SMTP_USERNAME;
+ $mail->Password = SMTP_PASSWORD;
+ $mail->CharSet = 'UTF-8';
+ $mail->isHTML(true);
+ $mail->setFrom(SMTP_FROM_EMAIL, SMTP_FROM_NAME);
+ $mail->addAddress($devEmail);
+
+ // 邮件内容
+ if ($status === 'approved') {
+ $mail->Subject = '应用审核通过通知';
+ $mail->Body = "
+
应用审核通过通知
+
您好,
+
您的应用 {$appName} 已成功通过审核!
+
现在可以在应用商店中查看您的应用。
+
此致
应用商店团队
+
";
+ } else {
+ $mail->Subject = '应用审核未通过通知';
+ $mail->Body = "
+
应用审核未通过通知
+
您好,
+
您的应用 {$appName} 未通过审核。
+
原因:
{$rejectionReason}
+
此致
应用商店团队
+
";
+ }
+
+ $mail->send();
+ $success .= ',邮件通知已发送';
+ } catch (Exception $e) {
+ log_error("邮件发送失败: {$mail->ErrorInfo}", __FILE__, __LINE__);
+ $error = "审核状态已更新,但邮件发送失败: {$mail->ErrorInfo}";
+ }
+ }
} else {
$error = '更新审核状态失败: ' . $conn->error;
}
diff --git a/app_store.sql b/app_store.sql
index 9cf163c..d210802 100644
--- a/app_store.sql
+++ b/app_store.sql
@@ -15,7 +15,8 @@ CREATE TABLE IF NOT EXISTS apps (
version VARCHAR(20) NOT NULL,
changelog TEXT NOT NULL,
file_path VARCHAR(255) NOT NULL,
- status ENUM('pending', 'approved', 'rejected') DEFAULT 'pending'
+ status ENUM('pending', 'approved', 'rejected') DEFAULT 'pending',
+ developer_email VARCHAR(255) NOT NULL
);
-- 确保状态列存在(用于现有数据库)
diff --git a/developer/register.php b/developer/register.php
index eb2f68d..235e84c 100644
--- a/developer/register.php
+++ b/developer/register.php
@@ -147,6 +147,7 @@ log_error('OpenSSL扩展状态: ' . (extension_loaded('openssl') ? '已启用' :
$mail->SMTPSecure = defined('SMTP_ENCRYPTION') ? SMTP_ENCRYPTION : 'tls'; // Ensure SMTP_ENCRYPTION is defined in config.php
$mail->AuthType = 'PLAIN'; // 尝试使用PLAIN认证方式
$mail->Port = defined('SMTP_PORT') ? SMTP_PORT : 587;
+ $mail->CharSet = 'UTF-8';
$mail->setFrom(defined('SMTP_FROM_EMAIL') ? SMTP_FROM_EMAIL : 'noreply@example.com', defined('SMTP_FROM_NAME') ? SMTP_FROM_NAME : 'App Store'); // Ensure SMTP_FROM_EMAIL is defined in config.php
$mail->addAddress($email, $username);
diff --git a/developer/upload_app.php b/developer/upload_app.php
index 94fa17d..c4cea7a 100644
--- a/developer/upload_app.php
+++ b/developer/upload_app.php
@@ -159,10 +159,21 @@ if (!($conn instanceof mysqli)) {
throw new Exception('缺少必要的上传参数');
}
+ // 获取开发者邮箱
+ $userStmt = $conn->prepare('SELECT email FROM developers WHERE id = ?');
+ $userStmt->bind_param('i', $developerId);
+ $userStmt->execute();
+ $userResult = $userStmt->get_result();
+ $user = $userResult->fetch_assoc();
+ $developerEmail = $user['email'] ?? '';
+ $userStmt->close();
+
+ if (empty($developerEmail)) {
+ throw new Exception('无法获取开发者邮箱信息');
+ }
+
// 插入应用基本信息
- $filePath = ''; // 初始化file_path为空字符串以满足数据库要求
- // 添加created_at字段并设置为当前时间戳
- $stmt = $conn->prepare('INSERT INTO apps (name, description, developer_id, platforms, status, age_rating, age_rating_description, version, changelog, file_path, created_at) VALUES (?, ?, ?, ?, \'pending\', ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)');
+ $stmt = $conn->prepare('INSERT INTO apps (name, description, platforms, status, age_rating, age_rating_description, version, changelog, file_path, developer_email, created_at) VALUES (?, ?, ?, \'pending\', ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)');
if (!$stmt) {
throw new Exception('应用基本信息查询准备失败: ' . $conn->error);
}
@@ -178,7 +189,7 @@ if (!($conn instanceof mysqli)) {
// 移除多余的$status参数,匹配SQL中9个占位符
// 修正age_rating_description类型为字符串,并确保9个参数与占位符匹配
// 修复变量名错误:使用已验证的$appFilePath替换未定义的$file_path
- $stmt->bind_param('ssissssss', $appName, $appDescription, $developerId, $platforms_json, $ageRating, $ageRatingDescription, $version, $changelog, $appRelativePath);
+ $stmt->bind_param('sssssssss', $appName, $appDescription, $platforms_json, $ageRating, $ageRatingDescription, $version, $changelog, $appRelativePath, $developerEmail);
if (!$stmt->execute()) {
throw new Exception('应用基本信息查询执行失败: ' . $stmt->error);
}