page: replace error scripts by editable html with placeholders
[minimedit.git] / page.php
index cb201f2f46fe32516fbdd61611a84fe0ce9cc0d2..856a08a55f15dec44e4fb486cb4643689d6d5574 100644 (file)
--- a/page.php
+++ b/page.php
@@ -3,8 +3,11 @@ error_reporting(E_ALL);
 ini_set('display_errors', TRUE);
 
 set_exception_handler(function ($error) {
+       http_response_code(500);
        include_once 'page.inc.php';
-       include_once '500.php';
+       ob_start();
+       require_once './500.html';
+       print str_replace('[[debug]]', $error, ob_get_clean());
 });
 
 include_once 'auth.inc.php';
@@ -60,7 +63,11 @@ if (!$found) {
                require './template.html';
        }
        else {
-               require "./404.php";
+               http_response_code(404);
+               ob_start();
+               require "./404.html";
+               $url = htmlspecialchars($_SERVER['REQUEST_URI']);
+               print str_replace('[[url]]', $url, ob_get_clean());
        }
 }