35 lines
1.1 KiB
Text
35 lines
1.1 KiB
Text
<?php
|
|
|
|
require __DIR__ . "/../../vendor/autoload.php";
|
|
require __DIR__ . "/../../server/utils/init.php";
|
|
|
|
use App\Classes\MovieFetcher;
|
|
use voku\helper\HtmlMin;
|
|
|
|
$requestUri = $_SERVER["REQUEST_URI"];
|
|
$url = trim(parse_url($requestUri, PHP_URL_PATH), "/");
|
|
|
|
if (!preg_match('/^watching\/movies\/[\w-]+$/', $url)) {
|
|
echo file_get_contents(__DIR__ . "/../../404/index.html");
|
|
exit();
|
|
}
|
|
|
|
$fetcher = new MovieFetcher();
|
|
$movie = $fetcher->fetch($url);
|
|
|
|
if (!$movie) {
|
|
echo file_get_contents(__DIR__ . "/../../404/index.html");
|
|
exit();
|
|
}
|
|
|
|
$movie["description"] = parseMarkdown($movie["description"]);
|
|
$pageTitle = htmlspecialchars("Movies • " . $movie["title"], ENT_QUOTES, "UTF-8");
|
|
$pageDescription = truncateText(htmlspecialchars(strip_tags($movie["description"]), ENT_QUOTES, "UTF-8"), 250);
|
|
$ogImage = htmlspecialchars($movie["backdrop"], 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");
|
|
?>
|