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>';
37 'debug' => $GLOBALS['phorkie']['cfg']['debug']
44 require_once __DIR__ . '/../data/config.default.php';
45 if (file_exists(__DIR__ . '/../data/config.php')) {
46 require_once __DIR__ . '/../data/config.php';
48 if ($GLOBALS['phorkie']['cfg']['setupcheck']) {
52 // Set/Get git commit session variables
53 $_SESSION['ipaddr'] = $_SERVER['REMOTE_ADDR'];
54 if (!isset($_SESSION['name'])) {
55 $_SESSION['name'] = $GLOBALS['phorkie']['auth']['anonymousName'];
57 if (!isset($_SESSION['email'])) {
58 $_SESSION['email'] = $GLOBALS['phorkie']['auth']['anonymousEmail'];
61 \Twig_Autoloader::register();
63 $loader = new \Twig_Loader_Filesystem($GLOBALS['phorkie']['cfg']['tpl']);
64 $twig = new \Twig_Environment(
67 //'cache' => '/path/to/compilation_cache',
71 $twig->addFunction('ntext', new \Twig_Function_Function('\phorkie\ntext'));
72 function ntext($value, $singular, $plural)
74 if (abs($value) == 1) {
75 return sprintf($singular, $value);
77 return sprintf($plural, $value);
79 //$twig->addExtension(new \Twig_Extension_Debug());
81 if (!isset($noSecurityCheck) || $noSecurityCheck !== true) {
82 require __DIR__ . '/www-security.php';
85 function render($tplname, $vars = array())
87 $vars['baseurl'] = '/';
88 if (!empty($GLOBALS['phorkie']['cfg']['baseurl'])) {
89 $vars['baseurl'] = $GLOBALS['phorkie']['cfg']['baseurl'];
91 $vars['css'] = $GLOBALS['phorkie']['cfg']['css'];
92 $vars['iconpng'] = $GLOBALS['phorkie']['cfg']['iconpng'];
93 $vars['title'] = $GLOBALS['phorkie']['cfg']['title'];
94 $vars['topbar'] = $GLOBALS['phorkie']['cfg']['topbar'];
95 if (isset($_SESSION['identity'])) {
96 $vars['identity'] = $_SESSION['identity'];
97 $vars['name'] = $_SESSION['name'];
98 $vars['email'] = $_SESSION['email'];
100 $vars['db'] = new Database();
101 if (!isset($vars['htmlhelper'])) {
102 $vars['htmlhelper'] = new HtmlHelper();
105 $template = $GLOBALS['twig']->loadTemplate($tplname . '.htm');
106 echo $template->render($vars);
108 function redirect($target)
110 header('Location: ' . $target);