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