X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/f065f4739ae477d8877805463017f2e7b15e2db5..2bed41fd9817049d5f8822e381c4f70cc3bf33c8:/page.php diff --git a/page.php b/page.php index 214f9d2..ba58306 100644 --- a/page.php +++ b/page.php @@ -23,9 +23,12 @@ function fail($error) $Page->title = 'Fout'; } include_once 'page.inc.php'; + ob_start(); require '500.inc.html'; - print $Page->render(['debug' => htmlspecialchars($error)]); + $Page->place['debug'] = htmlspecialchars($error); + $Page->raw = ob_get_clean(); + print $Page->render(); } set_exception_handler('fail'); @@ -94,8 +97,7 @@ header(sprintf('Content-Security-Policy: %s', implode('; ', [ "frame-ancestors 'none'", # prevent malicious embedding ]))); -ob_start(); # page body -$Place = [ +$Page->place += [ 'user' => $User->login ?: '', 'url' => htmlspecialchars($_SERVER['REQUEST_URI']), ]; @@ -109,6 +111,7 @@ if (!isset($Page->raw) and $User->admin("edit {$Page->link}")) { $Page->raw($template); $Page->meta['article:published_time'] = date('Y-m-d h:i:s O'); $Page->meta['article:author'] = '/' . $User->dir; + $Page->body = NULL; } if (isset($Page->raw)) { @@ -126,15 +129,18 @@ if (isset($Page->raw)) { # output dynamic and/or static html -if (!$Page->handler or require("./{$Page->handler}/index.php")) { - # static contents - if (isset($Page->raw)) { - print $Page->raw; - } - else { +ob_start(); +if ($Page->handler and !require("./{$Page->handler}/index.php")) { + # replace contents by code output on false return + $Page->raw = ob_get_clean(); +} +else { + # keep article contents + if (!isset($Page->body)) { # no resulting output http_response_code(404); @require '404.inc.html'; + $Page->raw = ob_get_clean() . $Page->raw; } }