byecorps.com/index.php

47 lines
839 B
PHP
Raw Normal View History

2024-03-29 12:55:51 +00:00
<?php
$uri_string = $_SERVER['REQUEST_URI'];
$query_string = explode('?', $uri_string);
if(isset($query_string[1])) {
$uri_string = $query_string[0];
$query_string = explode('&', $query_string[1]);
$query = array();
foreach($query_string as $string) {
$bits = explode('=', $string);
$query[$bits[0]] = $bits[1];
}
2024-03-29 13:28:29 +00:00
$path = $query['path'] ?? null;
2024-03-29 12:55:51 +00:00
}
else {
2024-03-29 13:28:29 +00:00
$path = null;
2024-03-29 12:55:51 +00:00
$query = array();
}
2024-03-29 13:28:29 +00:00
if (is_null($path)) {
$path = $query_string[0];
}
2024-03-29 12:55:51 +00:00
if (str_ends_with($path, "/")) {
$path = rtrim($path, "/");
}
$pages = [
"" => "home.php",
"/credits" => "credits.php",
"/blog" => "blog/blog.html"
];
include ("header.html");
if (isset($pages[$path])) {
include ($pages[$path]);
} else {
http_response_code(404);
include "404.html";
}
include ("footer.html");