7 . PATH_SEPARATOR . get_include_path()
11 $file = str_replace(array('\\', '_'), '/', $class) . '.php';
12 $hdl = @fopen($file, 'r', true);
19 set_exception_handler(
21 if ($e instanceof Exception) {
22 header('HTTP/1.0 ' . $e->httpStatusCode);
24 header('HTTP/1.0 500 Internal server error');
27 if (!isset($GLOBALS['twig'])) {
28 echo '<h1>Exception</h1>';
29 echo '<p>' . $e->getMessage() . '</p>';
38 'debug' => $GLOBALS['phorkie']['cfg']['debug']
45 require_once __DIR__ . '/../data/config.default.php';
46 if (file_exists(__DIR__ . '/../data/config.php')) {
47 require_once __DIR__ . '/../data/config.php';
49 if ($GLOBALS['phorkie']['cfg']['setupcheck']) {
53 // Set/Get git commit session variables
54 $_SESSION['ipaddr'] = $_SERVER['REMOTE_ADDR'];
55 if (!isset($_SESSION['name'])) {
56 $_SESSION['name'] = $GLOBALS['phorkie']['auth']['anonymousName'];
58 if (!isset($_SESSION['email'])) {
59 $_SESSION['email'] = $GLOBALS['phorkie']['auth']['anonymousEmail'];
62 \Twig_Autoloader::register();
64 $loader = new \Twig_Loader_Filesystem($GLOBALS['phorkie']['cfg']['tpl']);
65 $twig = new \Twig_Environment(
68 //'cache' => '/path/to/compilation_cache',
72 $twig->addFunction('ntext', new \Twig_Function_Function('\phorkie\ntext'));
73 function ntext($value, $singular, $plural)
75 if (abs($value) == 1) {
76 return sprintf($singular, $value);
78 return sprintf($plural, $value);
80 //$twig->addExtension(new \Twig_Extension_Debug());
82 if (!isset($noSecurityCheck) || $noSecurityCheck !== true) {
83 require __DIR__ . '/www-security.php';
86 function render($tplname, $vars = array())
88 $vars['baseurl'] = '/';
89 if (!empty($GLOBALS['phorkie']['cfg']['baseurl'])) {
90 $vars['baseurl'] = $GLOBALS['phorkie']['cfg']['baseurl'];
92 $vars['css'] = $GLOBALS['phorkie']['cfg']['css'];
93 $vars['iconpng'] = $GLOBALS['phorkie']['cfg']['iconpng'];
94 $vars['title'] = $GLOBALS['phorkie']['cfg']['title'];
95 $vars['topbar'] = $GLOBALS['phorkie']['cfg']['topbar'];
96 if (isset($_SESSION['identity'])) {
97 $vars['identity'] = $_SESSION['identity'];
98 $vars['name'] = $_SESSION['name'];
99 $vars['email'] = $_SESSION['email'];
101 $vars['db'] = new Database();
102 if (!isset($vars['htmlhelper'])) {
103 $vars['htmlhelper'] = new HtmlHelper();
106 $template = $GLOBALS['twig']->loadTemplate($tplname . '.htm');
107 echo $template->render($vars);
109 function redirect($target)
111 header('Location: ' . $target);