getConnection(); $message = ''; $message_type = ''; // 处理操作 if ($_SERVER['REQUEST_METHOD'] === 'POST') { $action = $_POST['action'] ?? ''; if ($action === 'update_status') { $type = $_POST['type'] ?? ''; $id = $_POST['id'] ?? ''; $status = $_POST['status'] ?? ''; $note = $_POST['note'] ?? ''; if ($type === 'website') { $stmt = $db->prepare("UPDATE website_submissions SET status = ?, admin_note = ? WHERE id = ?"); } else { $stmt = $db->prepare("UPDATE app_submissions SET status = ?, admin_note = ? WHERE id = ?"); } if ($stmt->execute([$status, $note, $id])) { $message = '状态更新成功'; $message_type = 'success'; } else { $message = '状态更新失败'; $message_type = 'error'; } } elseif ($action === 'update_account') { $new_username = trim($_POST['new_username'] ?? ''); $new_password = $_POST['new_password'] ?? ''; $confirm_password = $_POST['confirm_password'] ?? ''; if (empty($new_username)) { $message = '用户名不能为空'; $message_type = 'error'; } elseif (!empty($new_password) && $new_password !== $confirm_password) { $message = '两次输入的密码不一致'; $message_type = 'error'; } else { $admin_id = $_SESSION['admin_id']; if (!empty($new_password)) { $hashed_password = password_hash($new_password, PASSWORD_DEFAULT); $stmt = $db->prepare("UPDATE admins SET username = ?, password = ? WHERE id = ?"); $stmt->execute([$new_username, $hashed_password, $admin_id]); } else { $stmt = $db->prepare("UPDATE admins SET username = ? WHERE id = ?"); $stmt->execute([$new_username, $admin_id]); } $_SESSION['admin_username'] = $new_username; $message = '账户信息更新成功'; $message_type = 'success'; } } } // 获取统计数据 $stats = [ 'website_pending' => 0, 'website_approved' => 0, 'website_rejected' => 0, 'app_pending' => 0, 'app_approved' => 0, 'app_rejected' => 0 ]; $stmt = $db->prepare("SELECT status, COUNT(*) as count FROM website_submissions GROUP BY status"); $stmt->execute(); while ($row = $stmt->fetch()) { $stats['website_' . $row['status']] = $row['count']; } $stmt = $db->prepare("SELECT status, COUNT(*) as count FROM app_submissions GROUP BY status"); $stmt->execute(); while ($row = $stmt->fetch()) { $stats['app_' . $row['status']] = $row['count']; } // 获取列表数据 $filter = $_GET['filter'] ?? 'pending'; $type = $_GET['type'] ?? 'website'; $page = max(1, intval($_GET['page'] ?? 1)); $limit = 10; $offset = ($page - 1) * $limit; // 强制转换为整数 $limit = (int)$limit; $offset = (int)$offset; // 检查数据库版本 $is_mysql_57 = $database->isMySQL57(); if ($type === 'website') { $count_stmt = $db->prepare("SELECT COUNT(*) FROM website_submissions WHERE status = ?"); $count_stmt->execute([$filter]); $total = $count_stmt->fetchColumn(); if ($is_mysql_57) { $stmt = $db->prepare(" SELECT id, url, title, description, platforms, contact, status, admin_note, created_at FROM website_submissions WHERE status = ? ORDER BY created_at DESC LIMIT ?, ? "); $stmt->bindValue(1, $filter, PDO::PARAM_STR); $stmt->bindValue(2, $offset, PDO::PARAM_INT); $stmt->bindValue(3, $limit, PDO::PARAM_INT); } else { $stmt = $db->prepare(" SELECT id, url, title, description, platforms, contact, status, admin_note, created_at FROM website_submissions WHERE status = ? ORDER BY created_at DESC LIMIT ? OFFSET ? "); $stmt->bindValue(1, $filter, PDO::PARAM_STR); $stmt->bindValue(2, $limit, PDO::PARAM_INT); $stmt->bindValue(3, $offset, PDO::PARAM_INT); } $stmt->execute(); } else { $count_stmt = $db->prepare("SELECT COUNT(*) FROM app_submissions WHERE status = ?"); $count_stmt->execute([$filter]); $total = $count_stmt->fetchColumn(); if ($is_mysql_57) { $stmt = $db->prepare(" SELECT id, name, platform, version, icon_url, download_url, website_url, description, platforms, contact, status, admin_note, created_at FROM app_submissions WHERE status = ? ORDER BY created_at DESC LIMIT ?, ? "); $stmt->bindValue(1, $filter, PDO::PARAM_STR); $stmt->bindValue(2, $offset, PDO::PARAM_INT); $stmt->bindValue(3, $limit, PDO::PARAM_INT); } else { $stmt = $db->prepare(" SELECT id, name, platform, version, icon_url, download_url, website_url, description, platforms, contact, status, admin_note, created_at FROM app_submissions WHERE status = ? ORDER BY created_at DESC LIMIT ? OFFSET ? "); $stmt->bindValue(1, $filter, PDO::PARAM_STR); $stmt->bindValue(2, $limit, PDO::PARAM_INT); $stmt->bindValue(3, $offset, PDO::PARAM_INT); } $stmt->execute(); } $submissions = $stmt->fetchAll(); $total_pages = ceil($total / $limit); ?>
网址待审核
网址已通过
应用待审核
应用已通过
ID | 网址 | 标题 | 应用名称 | 平台 | 版本 | 收录平台 | 联系方式 | 状态 | 提交时间 | 操作 |
---|---|---|---|---|---|---|---|---|---|---|
30 ? '...' : ''); ?> | '待处理', 'approved' => '已通过', 'rejected' => '已拒绝' ]; echo $status_text[$submission['status']]; ?> |