30 lines
977 B
Text
30 lines
977 B
Text
<?php
|
|
|
|
require __DIR__ . "/../../vendor/autoload.php";
|
|
require __DIR__ . "/../../server/utils/init.php";
|
|
|
|
use App\Classes\GenreFetcher;
|
|
use voku\helper\HtmlMin;
|
|
|
|
$requestUri = $_SERVER["REQUEST_URI"];
|
|
$url = trim(parse_url($requestUri, PHP_URL_PATH), "/");
|
|
|
|
if (!preg_match('/^music\/genres\/[\w-]+$/', $url)) redirectTo404();
|
|
|
|
$genre = (new GenreFetcher())->fetch($url);
|
|
|
|
if (!$genre) redirectTo404();
|
|
|
|
$pageTitle = htmlspecialchars("Genres • " . $genre["name"], ENT_QUOTES, "UTF-8");
|
|
$pageDescription = truncateText(
|
|
htmlspecialchars(strip_tags($genre["description"]), ENT_QUOTES, "UTF-8"),
|
|
250
|
|
);
|
|
$ogImage = htmlspecialchars($genre["artists"][0]["image"] ?? "", ENT_QUOTES, "UTF-8");
|
|
$fullUrl = "https://www.coryd.dev" . $requestUri;
|
|
$oembedUrl = "https://www.coryd.dev/oembed" . $requestUri;
|
|
|
|
ob_start();
|
|
header("Cache-Control: public, max-age=3600");
|
|
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 3600) . " GMT");
|
|
?>
|