+# 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;