Handle 404 gracefully

This commit is contained in:
southerntofu 2021-03-20 17:43:07 +01:00
parent 3c0a380ce3
commit 708dc5a3f1
2 changed files with 7 additions and 6 deletions

3
includes/404.md Normal file
View File

@ -0,0 +1,3 @@
# 404
This page ("$page") does not exist.

View File

@ -7,14 +7,11 @@ Parsedown is licensed under the MIT license.
include('config.php');
include('parsedown-1.7.3/Parsedown.php');
$page = $_GET['page'];
$page = isset($_GET['page']) ? $_GET['page'] : 'main';
$Parsedown = new Parsedown();
$Parsedown->setSafeMode(true);
if ( $page == "") {
$page = "main";
}
if(isset($_GET['style']))
$site_style = $_GET['style'];
else
@ -22,7 +19,8 @@ else
$header = file_get_contents("includes/header.md");
$sidebar = file_get_contents("includes/sidebar.md");
$content = file_get_contents("articles/$page.md");
$content_file = "articles/$page.md";
$content = file_exists($content_file) ? file_get_contents($content_file) : str_replace('$page', "$page", file_get_contents("includes/404.md"));
$footer = file_get_contents("includes/footer.md");
print "<!DOCTYPE html>