From 633c264d40bf2b29372c8f1a1cf6944861ce1c8d Mon Sep 17 00:00:00 2001
From: Leonmmcoset
Date: Mon, 7 Jul 2025 17:52:22 +0800
Subject: [PATCH] =?UTF-8?q?feat(=E5=BC=80=E5=8F=91=E8=80=85=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2):=20=E6=B7=BB=E5=8A=A0=E5=BC=80=E5=8F=91=E8=80=85?=
=?UTF-8?q?=E5=BA=94=E7=94=A8=E9=A1=B5=E9=9D=A2=E5=B9=B6=E6=94=B9=E8=BF=9B?=
=?UTF-8?q?=E5=BA=94=E7=94=A8=E8=AF=A6=E6=83=85=E9=A1=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 新增开发者应用页面(developer_apps.php)展示开发者所有应用
- 在应用详情页(app.php)添加开发者信息显示和链接
- 改进错误处理,添加更详细的错误信息
- 修改SQL查询以获取开发者信息
---
app.php | 14 ++++--
developer_apps.php | 117 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 127 insertions(+), 4 deletions(-)
create mode 100644 developer_apps.php
diff --git a/app.php b/app.php
index dfa36f2..f102be8 100644
--- a/app.php
+++ b/app.php
@@ -10,17 +10,22 @@ if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
$appId = $_GET['id'];
// 获取App信息
-$sqlApp = "SELECT apps.*, AVG(reviews.rating) as avg_rating
+$sqlApp = "SELECT apps.*, apps.developer_id, developers.username as developer_name, AVG(reviews.rating) as avg_rating
FROM apps
+ LEFT JOIN developers ON apps.developer_id = developers.id
LEFT JOIN reviews ON apps.id = reviews.app_id
WHERE apps.id = $appId
- GROUP BY apps.id";
+ GROUP BY apps.id, apps.developer_id, developers.username";
$resultApp = $conn->query($sqlApp);
+if (!$resultApp) {
+ die("数据库查询错误
错误信息: " . htmlspecialchars($conn->error) . "
SQL语句: " . htmlspecialchars($sqlApp) . "
");
+}
$app = $resultApp->fetch_assoc();
+$developerId = $app['developer_id'] ?? 0;
+$developerName = ($developerId == 0) ? '管理员' : ($app['developer_name'] ?? '未知开发者');
if (!$app) {
- header('Location: index.php');
- exit;
+ die("错误:应用不存在
找不到ID为 $appId 的应用。请检查ID是否正确。
");
}
// 获取App版本信息
@@ -136,6 +141,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['rating'])) {
echo implode(', ', $platformTexts);
?>
评分: /5
+ 开发者: 管理员
diff --git a/developer_apps.php b/developer_apps.php
new file mode 100644
index 0000000..a280c8f
--- /dev/null
+++ b/developer_apps.php
@@ -0,0 +1,117 @@
+query($sqlDeveloper);
+$developer = $resultDeveloper->fetch_assoc();
+
+// 确定页面标题和开发者名称
+if ($developer) {
+ $developerName = htmlspecialchars($developer['username']);
+ $pageTitle = $developerName . ' 的应用 - ' . APP_STORE_NAME;
+} else {
+ // 如果开发者ID为0或不存在,视为管理员
+ $developerName = '管理员';
+ $pageTitle = '管理员的应用 - ' . APP_STORE_NAME;
+}
+
+// 获取该开发者的所有应用
+$sqlApps = "SELECT a.*, (SELECT AVG(rating) FROM reviews WHERE app_id = a.id) as avg_rating
+ FROM apps a
+ WHERE a.developer_id = $developerId";
+$resultApps = $conn->query($sqlApps);
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
的应用
+
+
+ num_rows > 0): ?>
+
+ fetch_assoc()): ?>
+
+
+ query($sqlImage);
+ $image = $resultImage ? $resultImage->fetch_assoc() : null;
+ $imagePath = $image ? $image['image_path'] : 'default-app.png';
+ ?>
+
![<?php echo htmlspecialchars($app['name']); ?>](<?php echo $imagePath; ?>)
+
+
+
...
+
+
+ 评分: /5
+
+
+
查看详情
+
+
+
+
+
+
+
+ 暂无上传应用
+
+
+
+
+
+
+
\ No newline at end of file