forked from tilde.green/wiki
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:
parent
a9999ed625
commit
b18575abb8
1 changed files with 4 additions and 3 deletions
|
@ -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";
|
||||
|
|
Loading…
Reference in a new issue