6 . PATH_SEPARATOR . get_include_path()
10 $file = str_replace(array('\\', '_'), '/', $class) . '.php';
11 $hdl = @fopen($file, 'r', true);
18 set_exception_handler(
20 if ($e instanceof Exception) {
21 header('HTTP/1.0 ' . $e->httpStatusCode);
23 header('HTTP/1.0 500 Internal server error');
26 if (!isset($GLOBALS['twig'])) {
27 echo '<h1>Exception</h1>';
28 echo '<p>' . $e->getMessage() . '</p>';
36 'debug' => $GLOBALS['phorkie']['cfg']['debug']
43 require_once __DIR__ . '/../data/config.default.php';
44 if (file_exists(__DIR__ . '/../data/config.php')) {
45 require_once __DIR__ . '/../data/config.php';
47 if ($GLOBALS['phorkie']['cfg']['setupcheck']) {
50 \Twig_Autoloader::register();
52 $loader = new \Twig_Loader_Filesystem($GLOBALS['phorkie']['cfg']['tpl']);
53 $twig = new \Twig_Environment(
56 //'cache' => '/path/to/compilation_cache',
60 //$twig->addExtension(new \Twig_Extension_Debug());
62 function render($tplname, $vars)
64 $vars['css'] = $GLOBALS['phorkie']['cfg']['css'];
65 $vars['title'] = $GLOBALS['phorkie']['cfg']['title'];
66 $vars['topbar'] = $GLOBALS['phorkie']['cfg']['topbar'];
67 $vars['identity'] = $_SESSION['identity'];
68 $vars['name'] = $_SESSION['name'];
69 $vars['email'] = $_SESSION['email'];
70 $vars['db'] = new Database();
72 $template = $GLOBALS['twig']->loadTemplate($tplname . '.htm');
73 echo $template->render($vars);
75 function redirect($target)
77 header('Location: ' . $target);