getID() > 0) { $channelTitle = $dj->getName() . " | " . $serverName; $rss = new RSS($channelTitle, $serverUrl, "RSS feed for " . $channelTitle); // Retrieve mixes for the DJ. $mixes = $dj->getDJMixes(); foreach ($mixes as $mix) { $title = $mix['title'] ?? (isset($mix['details']['title']) ? $mix['details']['title'] : "New Untitled Mix"); $description = (!empty($mix['description'])) ? $mix['description'] : (isset($mix['details']['description']) ? $mix['details']['description'] : $title . " is a mix hosted on " . $serverName); $link = $serverUrl . 'mix/' . $mix['slug'] . '/'; $pubDate = $mix['recorded'] ?? ($mix['created'] ?? '2008-01-01 12:00:00'); $rss->addItem($title, $description, $link, $pubDate); } } } elseif ($mode === 'mixshow') { // Load Mixshow using the new class. $mixshow = new Mixshow($slug, $db); if ($mixshow->get_id() > 0) { $channelTitle = $mixshow->get_name() . " | " . $serverName; $rss = new RSS($channelTitle, $serverUrl, "RSS feed for " . $channelTitle); // The mixshow object returns an array of mix IDs. $mixIDs = $mixshow->get_mixes(); // Each element should contain 'mix_id' foreach ($mixIDs as $mixData) { $mixID = $mixData['mix_id']; // getMixByID() should be defined to return a mix’s details as an associative array. $mix = getMixByID($mixID); if ($mix) { $title = $mix['title'] ?? (isset($mix['details']['title']) ? $mix['details']['title'] : "New Untitled Mix"); $description = (!empty($mix['description'])) ? $mix['description'] : (isset($mix['details']['description']) ? $mix['details']['description'] : $title . " is a mix hosted on " . $serverName); $link = $serverUrl . 'mix/' . $mix['slug'] . '/'; $pubDate = $mix['recorded'] ?? ($mix['created'] ?? '2008-01-01 12:00:00'); $rss->addItem($title, $description, $link, $pubDate); } } } } elseif ($mode === 'genre') { // For genres, we assume helper functions exist. $genre = getGenreSlug($slug); // Should return an associative array with at least 'id' and 'genre' if (!empty($genre['id'])) { $channelTitle = $genre['genre'] . " | " . $serverName; $rss = new RSS($channelTitle, $serverUrl, "RSS feed for " . $channelTitle); // getMoreMixesByGenre() should return an array of mixes. $mixes = array_reverse(getMoreMixesByGenre($genre['id'])); foreach ($mixes as $mix) { $title = $mix['title'] ?? (isset($mix['details']['title']) ? $mix['details']['title'] : "New Untitled Mix"); $description = (!empty($mix['description'])) ? $mix['description'] : (isset($mix['details']['description']) ? $mix['details']['description'] : $title . " is a mix hosted on " . $serverName); $link = $serverUrl . 'mix/' . $mix['slug'] . '/'; $pubDate = $mix['recorded'] ?? ($mix['created'] ?? '2008-01-01 12:00:00'); $rss->addItem($title, $description, $link, $pubDate); } } } else { // Unknown mode – fallback to all mixes. $mixes = getAllMix(); foreach ($mixes as $mix) { $title = $mix['title'] ?? (isset($mix['details']['title']) ? $mix['details']['title'] : "New Untitled Mix"); $description = (!empty($mix['description'])) ? $mix['description'] : (isset($mix['details']['description']) ? $mix['details']['description'] : $title . " is a mix hosted on " . $serverName); $link = $serverUrl . 'mix/' . $mix['slug'] . '/'; $pubDate = $mix['recorded'] ?? ($mix['created'] ?? '2008-01-01 12:00:00'); $rss->addItem($title, $description, $link, $pubDate); } } } else { // No mode provided – default to a feed of all mixes. $mixes = getAllMix(); foreach ($mixes as $mix) { $title = $mix['title'] ?? (isset($mix['details']['title']) ? $mix['details']['title'] : "New Untitled Mix"); $description = (!empty($mix['description'])) ? $mix['description'] : (isset($mix['details']['description']) ? $mix['details']['description'] : $title . " is a mix hosted on " . $serverName); $link = $serverUrl . 'mix/' . $mix['slug'] . '/'; $pubDate = $mix['recorded'] ?? ($mix['created'] ?? '2008-01-01 12:00:00'); $rss->addItem($title, $description, $link, $pubDate); } } // Set the appropriate header and output the RSS XML. header("Content-type: application/rss+xml"); echo $rss->generateXML();