summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
6c88aa2)
Do not match *.html contents to subrequests, only traverse parents for *.php
scripts which now support an additional output layer for appended output.
This allows parent code to prepare how its subpages will be displayed
(for example, a news directory can surround static articles with metadata).
-<?php include 'head.inc.php'; ?>
-
-<h2>Niet gevonden</h2>
-
-<p>
-De gevraagde pagina <em><?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?></em> bestaat niet.
-</p>
-
+<?php
+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";
CKEDITOR.disableAutoInline = true;
// add edit link to menu
CKEDITOR.disableAutoInline = true;
// add edit link to menu
-var pagebody = document.getElementsByClassName('article')[0];
+var pagebody = document.getElementsByClassName('static')[0];
if (pagebody) {
var editlink = document.createElement('a');
editlink.style.cursor = 'pointer';
if (pagebody) {
var editlink = document.createElement('a');
editlink.style.cursor = 'pointer';
+<?php
+include 'page.inc.php';
+?>
print "</body></html>\n";
});
print "</body></html>\n";
});
-print '<div class="article">'."\n\n";
-include "./$Page.html";
-print "</div>\n\n";
-
-if (file_exists("$Page.php")) include_once("./$Page.php");
-
include_once 'auth.inc.php';
$Edit = isset($_GET['edit']);
include_once 'auth.inc.php';
$Edit = isset($_GET['edit']);
+# distinguish subpage Args from topmost Page script
+
$Args = '';
$Page = preg_replace('/\?.*/', '', $_SERVER['REQUEST_URI']);
$Page = urldecode(trim($Page, '/')) ?: 'index';
while (TRUE) {
$Args = '';
$Page = preg_replace('/\?.*/', '', $_SERVER['REQUEST_URI']);
$Page = urldecode(trim($Page, '/')) ?: 'index';
while (TRUE) {
- if (file_exists("$Page/index.html")) {
- $Page .= '/index';
- break;
- }
- if (file_exists("$Page.html")) {
- break;
- }
if (file_exists("$Page.php")) {
if (file_exists("$Page.php")) {
- # unformatted script override
- require "$Page.php";
- exit;
}
$up = strrpos($Page, '/');
}
$up = strrpos($Page, '/');
+ $Args = substr($Page, $up) . $Args;
+ $Page = substr($Page, 0, $up);
- if ($User['admin']) {
- $Page = 'template';
- break;
- }
- http_response_code(404);
- $Page = '404';
- $Args = substr($Page, $up) . $Args;
- $Page = substr($Page, 0, $up);
+# execute dynamic code
+
+$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();
+}
+
+# prepare static contents
+
+include_once 'page.inc.php'; # global html
+
+if (file_exists("$Page$Args/index.html")) {
+ $Args .= '/index';
+}
+
+if (!$Page and !file_exists("$Page$Args.html")) {
+ # include not found
+ $Args = '';
+ if (isset($User) and $User['admin']) {
+ $Page = 'template';
+ }
+ else {
+ $Page = '404';
+ require "./$Page.php";
+ }
+}
+
+# output prepared html
+
+print $prepend;
+
+print '<div class="static">'."\n\n";
+if (file_exists("$Page$Args.html")) {
+include "./$Page$Args.html"; # static contents
+}
+print "</div>\n\n";
+
+print $append;
+