diff --git a/index.php b/index.php index 836d57d..6c5a9ad 100755 --- a/index.php +++ b/index.php @@ -453,15 +453,7 @@ switch($_GET["action"]) http_response_code(203); header("location: index.php?page=" . $_GET["page"]); } - - if(!$isloggedin and !$anonedits) - { - //future let the user view the page source instead - http_response_code(403); - header("refresh: 5; url=index.php?page=" . $_GET["page"]); - header("content-type: text/plain"); - exit("You must be logged in to edit $sitename. Redirecting to page view in 5 seconds...."); - } + $filename = $_GET["page"] . ".md"; $creatingpage = !isset($pageindex->$_GET["page"]); if((isset($_GET["newpage"]) and $_GET["newpage"] == "true") or $creatingpage) @@ -472,14 +464,27 @@ switch($_GET["action"]) { $title = "Editing " . $_GET["page"]; } - - + $pagetext = ""; if(isset($pageindex->$_GET["page"])) { $pagetext = file_get_contents($filename); } + if((!$isloggedin and !$anonedits) or !$editing) + { + if(!$creatingpage) + { + //the page already exists - let the user view the page source + exit(renderpage("Viewing source for " . $_GET["page"], "")); + } + else + { + http_response_code(404); + exit(renderpage("404 - " . $_GET["page"], "
The page " . $_GET["page"] . "
does not exist, but you do not have permission to create it.
If you haven't already, perhaps you should try logging in.
")); + } + } + $content = "