-function abort($body, $status = NULL) {
- if ($status) header("HTTP/1.1 $status");
- print "$body\n";
- exit;
-}
-
-function getoutput($blocks = [])
-{
- $rep = [];
- foreach ($blocks as $name => $html) {
- $rep["[[$name]]"] = sprintf('<!--BLOCK:%s-->%s<!--/-->',
- is_numeric($name) ? '' : "[[$name]]",
- preg_replace('{<!--[^-]*-->}', '', $html)
- );
- }
- $doc = ob_get_clean();
- if (!empty($blocks['warn'])) {
- $warn = '<p class="warn">[[warn]]</p>';
- if ($offset = strpos($doc, '</h2>')) {
- $doc = substr_replace($doc, "\n\n".$warn, $offset + 5, 0);
- }
- else {
- $doc = $warn . "\n\n" . $doc;
- }
- }
- return str_replace(array_keys($rep), array_values($rep), $doc);
-}
-
-# custom error handling
+define('DOCROOT', getcwd());
+set_include_path(implode(PATH_SEPARATOR, [ DOCROOT, __DIR__ ]));