X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/2b56d0fa69a4608fb1b582fca5f08d343f5b90eb..7333dc046075c7873b15643ecd73f6e3b32c7a79:/page.php
diff --git a/page.php b/page.php
index f6c2346..cb201f2 100644
--- a/page.php
+++ b/page.php
@@ -2,6 +2,11 @@
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
+set_exception_handler(function ($error) {
+ include_once 'page.inc.php';
+ include_once '500.php';
+});
+
include_once 'auth.inc.php';
$Edit = isset($_GET['edit']);
@@ -23,44 +28,39 @@ while (TRUE) {
}
}
-# execute dynamic code
+# load static contents
-$prepend = $append = '';
-if ($Page) {
- require "./$Page.php";
- if (ob_get_level() > 1) $append = ob_get_clean();
- if (ob_get_level() > 0) $prepend = ob_get_clean();
+ob_start(); # page body
+ob_start(); # inner html
+print '
'."\n\n";
+
+$found = FALSE;
+if (file_exists("$Page$Args/index.html")) {
+ $found = include "./$Page$Args/index.html";
+}
+elseif (file_exists("$Page$Args.html")) {
+ $found = include "./$Page$Args.html";
}
-# prepare static contents
+print "
\n\n";
-include_once 'page.inc.php'; # global html
+# execute dynamic code
-if (file_exists("$Page$Args/index.html")) {
- $Args .= '/index';
+if ($Page) {
+ $found |= require "./$Page.php";
}
-if (!$Page and !file_exists("$Page$Args.html")) {
- # include not found
- $Args = '';
+# global html
+
+include_once 'page.inc.php';
+
+if (!$found) {
+ # no resulting output
if (isset($User) and $User['admin']) {
- $Page = 'template';
+ require './template.html';
}
else {
- $Page = '404';
- require "./$Page.php";
+ require "./404.php";
}
}
-# output prepared html
-
-print $prepend;
-
-print ''."\n\n";
-if (file_exists("$Page$Args.html")) {
-include "./$Page$Args.html"; # static contents
-}
-print "
\n\n";
-
-print $append;
-