* Date: 2026-5-30 */ if (!defined('ROOT_PATH')) { exit('Access Denied'); } if (!isset($channel) && !empty($id)) { $channel = $db->fetch("SELECT * FROM {$db->table('channel')} WHERE id = ?", [intval($id)]); } $channel = $channel ?? []; $channelType = intval($channel['channel_type'] ?? 1); $pageTitle = $channel['channel_name'] ?? '栏目页'; $sideChannels = []; $contentList = []; $currentNavId = !empty($_GET['channel_id']) ? intval($_GET['channel_id']) : intval($id ?? 0); switch ($channelType) { case 2: if (intval($id) === 22) { $sideChannels = $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE parent_id = 22 AND is_show = 1 ORDER BY list_order ASC, id ASC"); } else { $sideChannels = $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE parent_id = ? AND is_show = 1 ORDER BY list_order ASC, id ASC", [intval($id)]); if (!$sideChannels && !empty($channel) && !empty($channel['parent_id'])) { $sideChannels = $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE parent_id = ? AND is_show = 1 ORDER BY list_order ASC, id ASC", [intval($channel['parent_id'])]); } } $channelIds = [intval($id)]; foreach ($sideChannels as $sub) { $channelIds[] = intval($sub['id']); } $channelIds = array_values(array_unique(array_filter($channelIds))); if ($channelIds) { $placeholders = implode(',', array_fill(0, count($channelIds), '?')); $contentList = $db->fetchAll("SELECT p.*, c.channel_name FROM {$db->table('product')} p LEFT JOIN {$db->table('channel')} c ON p.channel_id=c.id WHERE p.status=1 AND p.channel_id IN ({$placeholders}) ORDER BY p.create_time DESC LIMIT 100", $channelIds); } if (!$contentList && !empty($sideChannels)) { $fallbackIds = array_map(function($x){ return intval($x['id']); }, $sideChannels); $fallbackIds = array_values(array_unique(array_filter($fallbackIds))); if ($fallbackIds) { $placeholders = implode(',', array_fill(0, count($fallbackIds), '?')); $contentList = $db->fetchAll("SELECT p.*, c.channel_name FROM {$db->table('product')} p LEFT JOIN {$db->table('channel')} c ON p.channel_id=c.id WHERE p.status=1 AND p.channel_id IN ({$placeholders}) ORDER BY p.create_time DESC LIMIT 100", $fallbackIds); } } break; case 4: $sideChannels = $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE parent_id = ? AND is_show = 1 ORDER BY list_order ASC, id ASC", [intval($id)]); if (!$sideChannels && !empty($channel) && !empty($channel['parent_id'])) { $sideChannels = $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE parent_id = ? AND is_show = 1 ORDER BY list_order ASC, id ASC", [intval($channel['parent_id'])]); } $channelIds = [intval($id)]; foreach ($sideChannels as $sub) { $channelIds[] = intval($sub['id']); } $channelIds = array_values(array_unique(array_filter($channelIds))); if ($channelIds) { $placeholders = implode(',', array_fill(0, count($channelIds), '?')); $contentList = $db->fetchAll("SELECT i.*, c.channel_name FROM {$db->table('image')} i LEFT JOIN {$db->table('channel')} c ON i.channel_id=c.id WHERE i.status=1 AND i.channel_id IN ({$placeholders}) ORDER BY i.create_time DESC LIMIT 100", $channelIds); } break; case 5: $sideChannels = $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE parent_id = ? AND is_show = 1 ORDER BY list_order ASC, id ASC", [intval($id)]); $contentList = $db->fetchAll("SELECT d.*, c.channel_name FROM {$db->table('download')} d LEFT JOIN {$db->table('channel')} c ON d.channel_id=c.id WHERE d.status=1 AND d.channel_id = ? ORDER BY d.create_time DESC LIMIT 100", [intval($id)]); break; case 7: $sideChannels = $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE parent_id = ? AND is_show = 1 ORDER BY list_order ASC, id ASC", [intval($id)]); $contentList = $db->fetchAll("SELECT v.*, c.channel_name FROM {$db->table('video')} v LEFT JOIN {$db->table('channel')} c ON v.channel_id=c.id WHERE v.status=1 AND v.channel_id = ? ORDER BY v.create_time DESC LIMIT 100", [intval($id)]); break; case 9: $sideChannels = $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE parent_id = ? AND is_show = 1 ORDER BY list_order ASC, id ASC", [intval($id)]); if (!$sideChannels && !empty($channel) && !empty($channel['parent_id'])) { $sideChannels = $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE parent_id = ? AND is_show = 1 ORDER BY list_order ASC, id ASC", [intval($channel['parent_id'])]); } $channelIds = [intval($id)]; foreach ($sideChannels as $sub) { $channelIds[] = intval($sub['id']); } $channelIds = array_values(array_unique(array_filter($channelIds))); if ($channelIds) { $placeholders = implode(',', array_fill(0, count($channelIds), '?')); $contentList = $db->fetchAll("SELECT r.*, c.channel_name FROM {$db->table('recruit')} r LEFT JOIN {$db->table('channel')} c ON r.channel_id=c.id WHERE r.status=1 AND r.channel_id IN ({$placeholders}) ORDER BY r.create_time DESC LIMIT 100", $channelIds); } if (!$contentList && !empty($sideChannels)) { $fallbackIds = array_map(function($x){ return intval($x['id']); }, $sideChannels); $fallbackIds = array_values(array_unique(array_filter($fallbackIds))); if ($fallbackIds) { $placeholders = implode(',', array_fill(0, count($fallbackIds), '?')); $contentList = $db->fetchAll("SELECT r.*, c.channel_name FROM {$db->table('recruit')} r LEFT JOIN {$db->table('channel')} c ON r.channel_id=c.id WHERE r.status=1 AND r.channel_id IN ({$placeholders}) ORDER BY r.create_time DESC LIMIT 100", $fallbackIds); } } break; default: if (intval($id) === 23) { $sideChannels = $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE parent_id = 23 AND is_show = 1 ORDER BY list_order ASC, id ASC"); } else { $sideChannels = $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE parent_id = ? AND is_show = 1 ORDER BY list_order ASC, id ASC", [intval($id)]); if (!$sideChannels && !empty($channel) && !empty($channel['parent_id'])) { $sideChannels = $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE parent_id = ? AND is_show = 1 ORDER BY list_order ASC, id ASC", [intval($channel['parent_id'])]); } } $channelIds = [intval($id)]; foreach ($sideChannels as $sub) { $channelIds[] = intval($sub['id']); } $channelIds = array_values(array_unique(array_filter($channelIds))); if ($channelType == 1 || $channelType == 3) { if ($channelIds) { $placeholders = implode(',', array_fill(0, count($channelIds), '?')); $contentList = $db->fetchAll("SELECT a.*, c.channel_name FROM {$db->table('article')} a LEFT JOIN {$db->table('channel')} c ON a.channel_id=c.id WHERE a.status=1 AND a.channel_id IN ({$placeholders}) ORDER BY a.create_time DESC LIMIT 100", $channelIds); } if (!$contentList && !empty($sideChannels)) { $fallbackIds = array_map(function($x){ return intval($x['id']); }, $sideChannels); $fallbackIds = array_values(array_unique(array_filter($fallbackIds))); if ($fallbackIds) { $placeholders = implode(',', array_fill(0, count($fallbackIds), '?')); $contentList = $db->fetchAll("SELECT a.*, c.channel_name FROM {$db->table('article')} a LEFT JOIN {$db->table('channel')} c ON a.channel_id=c.id WHERE a.status=1 AND a.channel_id IN ({$placeholders}) ORDER BY a.create_time DESC LIMIT 100", $fallbackIds); } } } break; } if (!empty($_GET['channel_id'])) { $filterId = intval($_GET['channel_id']); if ($channelType == 2) { $contentList = $db->fetchAll("SELECT p.*, c.channel_name FROM {$db->table('product')} p LEFT JOIN {$db->table('channel')} c ON p.channel_id=c.id WHERE p.status=1 AND p.channel_id=? ORDER BY p.create_time DESC LIMIT 100", [$filterId]); } elseif ($channelType == 9) { $contentList = $db->fetchAll("SELECT r.*, c.channel_name FROM {$db->table('recruit')} r LEFT JOIN {$db->table('channel')} c ON r.channel_id=c.id WHERE r.status=1 AND r.channel_id=? ORDER BY r.create_time DESC LIMIT 100", [$filterId]); } else { $contentList = $db->fetchAll("SELECT a.*, c.channel_name FROM {$db->table('article')} a LEFT JOIN {$db->table('channel')} c ON a.channel_id=c.id WHERE a.status=1 AND a.channel_id=? ORDER BY a.create_time DESC LIMIT 100", [$filterId]); } } require_once __DIR__ . '/../_header.php'; ?>