1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-12-22 13:45:02 +00:00

raw action: send a 404 if a page couldn't be found

This commit is contained in:
Starbeamrainbowlabs 2017-10-14 16:09:46 +01:00
parent 3b00f56485
commit 3409fcc4ca
3 changed files with 15 additions and 3 deletions

View file

@ -2287,9 +2287,15 @@ register_module([
* ██ ██ ██ ██ ███ ███
*/
add_action("raw", function() {
global $env;
global $pageindex, $env;
if(empty($pageindex->{$env->page})) {
http_response_code(404);
exit("Error: The page with the name $env->page could not be found.\n");
}
header("content-type: text/markdown");
header("content-length: " . filesize($env->page_filename));
exit(file_get_contents($env->page_filename));
});

View file

@ -32,7 +32,7 @@
"author": "Starbeamrainbowlabs",
"description": "Adds a 'raw' action that shows you the raw source of a page.",
"id": "action-raw",
"lastupdate": 1476906745,
"lastupdate": 1507993680,
"optional": false
},
{

View file

@ -24,9 +24,15 @@ register_module([
* ██ ██ ██ ██ ███ ███
*/
add_action("raw", function() {
global $env;
global $pageindex, $env;
if(empty($pageindex->{$env->page})) {
http_response_code(404);
exit("Error: The page with the name $env->page could not be found.\n");
}
header("content-type: text/markdown");
header("content-length: " . filesize($env->page_filename));
exit(file_get_contents($env->page_filename));
});