+<?php
+error_reporting(E_ALL);
+ini_set('display_errors', 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")) {
+ # unformatted script override
+ require "$Page.php";
+ break;
+ }
+
+ $up = strrpos($Page, '/');
+ if ($up === FALSE) {
+ http_response_code(404);
+ $Page = '404';
+ break;
+ }
+ $Args = substr($Page, $up) . $Args;
+ $Page = substr($Page, 0, $up);
+}
+
+include 'head.inc.php';