getOne('vote', "id = $id"); if (!$vote) { header('Location: topic.php'); exit; } include 'topic_form.php'; break; // 管理选项页面 case 'options': $pageTitle = "管理选项"; $id = isset($_GET['id']) ? intval($_GET['id']) : 0; if (!$id) { header('Location: topic.php'); exit; } // 获取投票信息 $vote = $db->getOne('vote', "id = $id"); if (!$vote) { header('Location: topic.php'); exit; } // 获取选项列表 $options = $db->getAll('xuan', "topic_id = $id", '*', 'sort ASC, id ASC'); include 'topic_options.php'; break; // 投票列表页面(默认) default: $pageTitle = "投票管理"; // 获取分页参数 $page = isset($_GET['page']) ? intval($_GET['page']) : 1; $pageSize = 10; // 获取筛选参数 $status = isset($_GET['status']) ? intval($_GET['status']) : -1; $type = isset($_GET['type']) ? intval($_GET['type']) : -1; $keyword = isset($_GET['keyword']) ? safeFilter($_GET['keyword']) : ''; // 构建查询条件 $whereConditions = []; if ($status >= 0) { $whereConditions[] = "status = $status"; } if ($type >= 0) { $whereConditions[] = "itype = $type"; } if ($keyword) { $whereConditions[] = "(title LIKE '%$keyword%' OR idesc LIKE '%$keyword%')"; } $whereStr = !empty($whereConditions) ? implode(' AND ', $whereConditions) : ''; // 获取总记录数 $total = $db->count('vote', $whereStr); // 计算分页信息 $pagination = getPagination($total, $page, $pageSize); // 获取投票列表 $orderBy = "addtime DESC"; $limit = "{$pagination['offset']}, {$pagination['pageSize']}"; $voteList = $db->getAll('vote', $whereStr, '*', $orderBy, $limit); // 页面标题 $pageTitle = "投票管理"; ?>