borp blip
This commit is contained in:
@ -1,50 +1,47 @@
|
|||||||
<?php
|
<?php
|
||||||
if (!defined('Such_a_good_girl')) {
|
if (!defined("Such_a_good_girl")) {
|
||||||
die("Direct access not allowed.");
|
die("Direct access not allowed.");
|
||||||
}
|
}
|
||||||
if ($_SERVER['REQUEST_URI'] === '/favicon.ico') {
|
if ($_SERVER["REQUEST_URI"] === "/favicon.ico") {
|
||||||
$faviconPath = $_SERVER['DOCUMENT_ROOT'] . '/images/site/favicon.ico';
|
$faviconPath = $_SERVER["DOCUMENT_ROOT"] . "/images/site/favicon.ico";
|
||||||
if (file_exists($faviconPath)) {
|
if (file_exists($faviconPath)) {
|
||||||
header('Content-Type: image/webp');
|
header("Content-Type: image/webp");
|
||||||
header('Content-Length: ' . filesize($faviconPath));
|
header("Content-Length: " . filesize($faviconPath));
|
||||||
readfile($faviconPath);
|
readfile($faviconPath);
|
||||||
exit;
|
exit();
|
||||||
} else {
|
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/errors/404.php';
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
require_once $_SERVER["DOCUMENT_ROOT"] . "/inc/errors/404.php";
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
function getAvailableArchiveYears($baseDir = '/images') {
|
function getAvailableArchiveYears(string $baseDir = "/images"): array
|
||||||
|
{
|
||||||
$years = [];
|
$years = [];
|
||||||
$fullPath = $_SERVER['DOCUMENT_ROOT'] . $baseDir;
|
$fullPath = $_SERVER["DOCUMENT_ROOT"] . $baseDir;
|
||||||
|
if (!is_dir($fullPath)) {
|
||||||
if (is_dir($fullPath)) {
|
return $years;
|
||||||
foreach (scandir($fullPath) as $dir) {
|
}
|
||||||
if (preg_match('/^\d{4}$/', $dir) && is_dir("$fullPath/$dir")) {
|
foreach (scandir($fullPath) as $dir) {
|
||||||
$years[] = $dir;
|
if (preg_match('/^\d{4}$/', $dir) && is_dir("$fullPath/$dir")) {
|
||||||
}
|
$years[] = $dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $years;
|
return $years;
|
||||||
}
|
}
|
||||||
$path = trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/');
|
$path = trim(parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH), "/");
|
||||||
$segments = explode('/', $path);
|
$segments = explode("/", $path);
|
||||||
$availableYears = getAvailableArchiveYears();
|
$availableYears = getAvailableArchiveYears();
|
||||||
$content = '';
|
$content = "";
|
||||||
if ($path === '') {
|
if ($path === "") {
|
||||||
$content = $imageBlocks;
|
$content = $imageBlocks;
|
||||||
} elseif ($segments[0] === 'archives') {
|
} elseif ($segments[0] === "archives") {
|
||||||
if (!isset($segments[1])) {
|
if (!isset($segments[1]) || in_array($segments[1], $availableYears)) {
|
||||||
$content = $imageBlocks;
|
$year = $segments[1] ?? null;
|
||||||
} elseif (in_array($segments[1], $availableYears)) {
|
|
||||||
$year = $segments[1];
|
|
||||||
$content = $imageBlocks;
|
$content = $imageBlocks;
|
||||||
} else {
|
} else {
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/errors/404.php';
|
require_once $_SERVER["DOCUMENT_ROOT"] . "/inc/errors/404.php";
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/errors/404.php';
|
require_once $_SERVER["DOCUMENT_ROOT"] . "/inc/errors/404.php";
|
||||||
exit;
|
exit();
|
||||||
}
|
}
|
@ -12,7 +12,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/base/pages.php';
|
|||||||
<body class="is-preload">
|
<body class="is-preload">
|
||||||
<div id="wrapper">
|
<div id="wrapper">
|
||||||
<header id="header">
|
<header id="header">
|
||||||
<h1><a href="/"><strong class="title"><?php echo $config['title'] ?></strong></a></h1>
|
<h1><a href="/"><strong class="title"><?php echo htmlspecialchars($config['title']) ?></strong></a></h1>
|
||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/base/menu.php'; ?>
|
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/base/menu.php'; ?>
|
||||||
|
Reference in New Issue
Block a user