page: replace error scripts by editable html with placeholders
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 13 Sep 2017 20:20:22 +0000 (22:20 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 18 Sep 2017 18:21:28 +0000 (20:21 +0200)
404.html [new file with mode: 0644]
404.php [deleted file]
500.html [new file with mode: 0644]
500.php [deleted file]
page.php

diff --git a/404.html b/404.html
new file mode 100644 (file)
index 0000000..a7cf3ac
--- /dev/null
+++ b/404.html
@@ -0,0 +1,3 @@
+<h2>Pagina niet gevonden</h2>
+
+<p>De gevraagde pagina <em>[[url]]</em> bestaat niet.</p>
diff --git a/404.php b/404.php
deleted file mode 100644 (file)
index f6e1489..0000000
--- a/404.php
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php
-$extra = ob_get_clean();
-http_response_code(404);
-$request = htmlspecialchars($_SERVER['REQUEST_URI']);
-echo "<h2>Pagina niet gevonden</h2>\n\n";
-echo "<p>De gevraagde pagina <em>$request</em> bestaat niet.</p>\n\n";
-echo $extra;
diff --git a/500.html b/500.html
new file mode 100644 (file)
index 0000000..4d0802e
--- /dev/null
+++ b/500.html
@@ -0,0 +1,5 @@
+<h2>Scriptfout</h2>
+
+<p>Er ging iets mis: <pre class="warn">[[debug]]</pre>
+Waarschijnlijk wordt hier aan gewerkt, maar als het probleem aanhoudt
+geef het dan aan <a href="/contact">ons</a> door.
diff --git a/500.php b/500.php
deleted file mode 100644 (file)
index c2ae655..0000000
--- a/500.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-$extra = ob_get_clean();
-http_response_code(500);
-?>
-<h2>Scriptfout</h2>
-
-<p>Er ging iets mis: <pre class="warn"><?php print $error; ?></pre>
-Waarschijnlijk wordt hier aan gewerkt, maar als het probleem aanhoudt
-geef het dan aan <a href="/contact">ons</a> door.
-<?php
-print $extra;
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());
        }
 }