check for non-existent pages correctly, this was inverted somehow

on 404 print refresh and not the rest of the page (missing exit)
This commit is contained in:
Alexander 2024-10-01 18:53:41 +00:00
parent a9999ed625
commit b18575abb8

View file

@ -11,11 +11,12 @@ $parser = wiki::factory(true);
$page = $_GET['page'];
$page = preg_replace(',/$,', '', $page);
$page = preg_replace(',/,', '-', $page);
$valid_page = (preg_match("/[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-]/", $page) || file_exists("pages/{$page}.md"));
$valid_page = (preg_match("/[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-]*/", $page) && file_exists("pages/{$page}.md"));
if ($page !== "" && !$valid_page) {
http_response_code(404);
echo "This wiki page doesn't exist, you'll be redirected to the homepage.";
echo '<META HTTP-EQUIV="refresh" content="0;URL=' . $page_start . '/">';
echo "This wiki page doesn't exist, you'll be redirected to the homepage.\n";
echo '<META HTTP-EQUIV="refresh" content="0;URL=' . $page_start . '/">'."\n";
exit;
}
if ($page == "") {
$title = "wiki.tilde.green";