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'])) {
54 $_SESSION['name'] = $GLOBALS['phorkie']['auth']['anonymousName'];
56 if (!isset($_SESSION['email'])) {
57 $_SESSION['email'] = $GLOBALS['phorkie']['auth']['anonymousEmail'];
60 \Twig_Autoloader::register();
62 $loader = new \Twig_Loader_Filesystem($GLOBALS['phorkie']['cfg']['tpl']);
63 $twig = new \Twig_Environment(
66 //'cache' => '/path/to/compilation_cache',
70 //$twig->addExtension(new \Twig_Extension_Debug());
72 function render($tplname, $vars)
74 $vars['css'] = $GLOBALS['phorkie']['cfg']['css'];
75 $vars['title'] = $GLOBALS['phorkie']['cfg']['title'];
76 $vars['topbar'] = $GLOBALS['phorkie']['cfg']['topbar'];
77 if (isset($_SESSION['identity'])) {
78 $vars['identity'] = $_SESSION['identity'];
79 $vars['name'] = $_SESSION['name'];
80 $vars['email'] = $_SESSION['email'];
82 $vars['db'] = new Database();
84 $template = $GLOBALS['twig']->loadTemplate($tplname . '.htm');
85 echo $template->render($vars);
87 function redirect($target)
89 header('Location: ' . $target);