prepare("SELECT * FROM stations WHERE slug = ? AND is_active = 1 LIMIT 1"); $st->execute([$slug]); $station = $st->fetch(PDO::FETCH_ASSOC); } else { $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; if ($id > 0) { $st = $pdo->prepare("SELECT * FROM stations WHERE id = ? AND is_active = 1 LIMIT 1"); $st->execute([$id]); $station = $st->fetch(PDO::FETCH_ASSOC); } } if (!$station) { http_response_code(404); exit('Station not found'); } $stationId = (int)$station['id']; $slugReal = (string)($station['slug'] ?? ''); $href = $slugReal ? '/station/' . $slugReal : '/station/' . $stationId; $name = (string)$station['name']; $country = trim((string)($station['country'] ?? '')); $lang = trim((string)($station['language'] ?? '')); $genre = trim((string)($station['genre'] ?? '')); $bitrate = (int)($station['bitrate'] ?? 0); $website = trim((string)($station['website_url'] ?? '')); // Enrichment fields $description = trim((string)($station['description'] ?? '')); $descriptionSrc = trim((string)($station['description_src'] ?? '')); $pageTitle = trim((string)($station['page_title'] ?? '')); /* Normalize logo */ $logoRaw = (string)($station['logo'] ?? ''); $logo = $logoRaw; if ($logo !== '' && strncasecmp($logo, "http://", 7) === 0) { $logo = "https://" . substr($logo, 7); } /* ---------------------------------------------- Related stations ---------------------------------------------- */ $related = []; try { $rel = $pdo->prepare(" SELECT id, slug, name, logo, country, genre, bitrate FROM stations WHERE is_active = 1 AND id <> ? AND ( (country <> '' AND country = ?) OR (genre <> '' AND genre = ?) ) ORDER BY featured DESC, name ASC LIMIT 10 "); $rel->execute([$stationId, $country, $genre]); $related = $rel->fetchAll(PDO::FETCH_ASSOC); } catch (Throwable $e) { $related = []; } /* ---------------------------------------------- Meta for layout – use enrichment when present ---------------------------------------------- */ $page = 'station'; if ($pageTitle !== '') { $metaTitle = $pageTitle; } else { $metaTitle = $name . " – " . $siteName; } if ($description !== '') { $short = mb_substr($description, 0, 160); if (mb_strlen($description) > 160) { $short .= '…'; } $metaDesc = $short; } else { $metaDesc = "Listen to " . $name . " and similar stations on " . $siteName . "."; } // ---- SEO: canonical URL, OG image, JSON-LD ---- $base = rtrim(base_url(), '/'); $metaUrl = $base . $href; $metaType = 'music.radio_station'; // Build absolute logo URL for social cards $metaImage = ''; if ($logo !== '') { if (strpos($logo, '//') === 0) { $metaImage = 'https:' . $logo; } elseif (preg_match('~^https?://~i', $logo)) { $metaImage = $logo; } else { $metaImage = $base . '/' . ltrim($logo, '/'); } } else { $fallbackImage = (string)get_setting('seo_default_image', ''); if ($fallbackImage !== '') { $metaImage = $fallbackImage; } } // JSON-LD RadioStation schema $schema = [ '@context' => 'https://schema.org', '@type' => 'RadioStation', 'name' => $name, 'url' => $metaUrl, 'image' => $metaImage ?: null, 'areaServed' => $country ?: null, 'inLanguage' => $lang ?: null, 'genre' => $genre ?: null, ]; $schema = array_filter($schema, static fn($v) => $v !== null && $v !== ''); $metaExtra = ''; /* ---------------------------------------------- Social share helpers ---------------------------------------------- */ $shareUrl = $metaUrl; $shareText = $name . ' – ' . $siteName; $shareUrlEncoded = rawurlencode($shareUrl); $shareTextEncoded = rawurlencode($shareText); $whatsTextEncoded = rawurlencode($shareText . ' ' . $shareUrl); ob_start(); ?>
<?= h($name) ?>

Country:
Language:
Genre:
Bitrate: kbps
Website:
About this station
Source:
About this station

This station doesn't have a description yet. Stay tuned – the mouse is still enriching it.