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']) {
51 // Set/Get git commit session variables
52 $_SESSION['ipaddr'] = $_SERVER['REMOTE_ADDR'];
53 if (!isset($_SESSION['name'])) { $_SESSION['name'] = $GLOBALS['phorkie']['auth']['anonymousName']; }
54 if (!isset($_SESSION['email'])) { $_SESSION['email'] = $GLOBALS['phorkie']['auth']['anonymousEmail']; }
56 \Twig_Autoloader::register();
58 $loader = new \Twig_Loader_Filesystem($GLOBALS['phorkie']['cfg']['tpl']);
59 $twig = new \Twig_Environment(
62 //'cache' => '/path/to/compilation_cache',
66 //$twig->addExtension(new \Twig_Extension_Debug());
68 function render($tplname, $vars)
70 $vars['css'] = $GLOBALS['phorkie']['cfg']['css'];
71 $vars['title'] = $GLOBALS['phorkie']['cfg']['title'];
72 $vars['topbar'] = $GLOBALS['phorkie']['cfg']['topbar'];
73 if (isset($_SESSION['identity'])) {
74 $vars['identity'] = $_SESSION['identity'];
75 $vars['name'] = $_SESSION['name'];
76 $vars['email'] = $_SESSION['email'];
78 $vars['db'] = new Database();
80 $template = $GLOBALS['twig']->loadTemplate($tplname . '.htm');
81 echo $template->render($vars);
83 function redirect($target)
85 header('Location: ' . $target);