3 error_reporting(error_reporting() & ~E_STRICT);
6 require_once __DIR__ . '/../src/phorkie/autoload.php';
9 if ($e instanceof Exception) {
10 header('HTTP/1.0 ' . $e->httpStatusCode);
12 header('HTTP/1.0 500 Internal server error');
15 if (!isset($GLOBALS['twig'])) {
16 echo '<h1>Exception</h1>';
17 echo '<p>' . $e->getMessage() . '</p>';
26 'debug' => $GLOBALS['phorkie']['cfg']['debug']
33 require_once __DIR__ . '/../data/config.default.php';
34 if (file_exists(__DIR__ . '/../data/config.php')) {
35 require_once __DIR__ . '/../data/config.php';
38 // Set/Get git commit session variables
39 $_SESSION['ipaddr'] = $_SERVER['REMOTE_ADDR'];
40 if (!isset($_SESSION['name'])) {
41 $_SESSION['name'] = $GLOBALS['phorkie']['auth']['anonymousName'];
43 if (!isset($_SESSION['email'])) {
44 $_SESSION['email'] = $GLOBALS['phorkie']['auth']['anonymousEmail'];
47 \Twig_Autoloader::register();
49 $loader = new \Twig_Loader_Filesystem($GLOBALS['phorkie']['cfg']['tpl']);
50 $twig = new \Twig_Environment(
53 //'cache' => '/path/to/compilation_cache',
57 $twig->addFunction('ntext', new \Twig_Function_Function('\phorkie\ntext'));
58 function ntext($value, $singular, $plural)
60 if (abs($value) == 1) {
61 return sprintf($singular, $value);
63 return sprintf($plural, $value);
65 //$twig->addExtension(new \Twig_Extension_Debug());
67 if (!isset($noSecurityCheck) || $noSecurityCheck !== true) {
68 require __DIR__ . '/www-security.php';
71 function render($tplname, $vars = array())
73 $vars['baseurl'] = '/';
74 if (!empty($GLOBALS['phorkie']['cfg']['baseurl'])) {
75 $vars['baseurl'] = $GLOBALS['phorkie']['cfg']['baseurl'];
77 $vars['css'] = $GLOBALS['phorkie']['cfg']['css'];
78 $vars['iconpng'] = $GLOBALS['phorkie']['cfg']['iconpng'];
79 $vars['title'] = $GLOBALS['phorkie']['cfg']['title'];
80 $vars['topbar'] = $GLOBALS['phorkie']['cfg']['topbar'];
81 if (isset($_SESSION['identity'])) {
82 $vars['identity'] = $_SESSION['identity'];
83 $vars['name'] = $_SESSION['name'];
84 $vars['email'] = $_SESSION['email'];
86 $vars['db'] = new Database();
87 if (!isset($vars['htmlhelper'])) {
88 $vars['htmlhelper'] = new HtmlHelper();
91 $template = $GLOBALS['twig']->loadTemplate($tplname . '.htm');
92 echo $template->render($vars);
94 function redirect($target)
96 header('Location: ' . $target);