3 if (session_id() == "") {
9 . PATH_SEPARATOR . get_include_path()
11 spl_autoload_register(
13 $file = str_replace(array('\\', '_'), '/', $class) . '.php';
14 $hdl = @fopen($file, 'r', true);
21 set_exception_handler(
23 if ($e instanceof Exception) {
24 header('HTTP/1.0 ' . $e->httpStatusCode);
26 header('HTTP/1.0 500 Internal server error');
29 if (!isset($GLOBALS['twig'])) {
30 echo '<h1>Exception</h1>';
31 echo '<p>' . $e->getMessage() . '</p>';
39 'debug' => $GLOBALS['phorkie']['cfg']['debug']
46 require_once __DIR__ . '/../data/config.default.php';
47 if (file_exists(__DIR__ . '/../data/config.php')) {
48 require_once __DIR__ . '/../data/config.php';
50 if ($GLOBALS['phorkie']['cfg']['setupcheck']) {
54 // Set/Get git commit session variables
55 $_SESSION['ipaddr'] = $_SERVER['REMOTE_ADDR'];
56 if (!isset($_SESSION['name'])) {
57 $_SESSION['name'] = $GLOBALS['phorkie']['auth']['anonymousName'];
59 if (!isset($_SESSION['email'])) {
60 $_SESSION['email'] = $GLOBALS['phorkie']['auth']['anonymousEmail'];
63 \Twig_Autoloader::register();
65 $loader = new \Twig_Loader_Filesystem($GLOBALS['phorkie']['cfg']['tpl']);
66 $twig = new \Twig_Environment(
69 //'cache' => '/path/to/compilation_cache',
73 //$twig->addExtension(new \Twig_Extension_Debug());
75 require __DIR__ . '/www-security.php';
77 function render($tplname, $vars = array())
79 $vars['css'] = $GLOBALS['phorkie']['cfg']['css'];
80 $vars['title'] = $GLOBALS['phorkie']['cfg']['title'];
81 $vars['topbar'] = $GLOBALS['phorkie']['cfg']['topbar'];
82 if (isset($_SESSION['identity'])) {
83 $vars['identity'] = $_SESSION['identity'];
84 $vars['name'] = $_SESSION['name'];
85 $vars['email'] = $_SESSION['email'];
87 $vars['db'] = new Database();
89 $template = $GLOBALS['twig']->loadTemplate($tplname . '.htm');
90 echo $template->render($vars);
92 function redirect($target)
94 header('Location: ' . $target);