first code that allows you to create pastes and view them
[phorkie.git] / www / www-header.php
1 <?php
2 require_once __DIR__ . '/../data/config.default.php';
3 require_once 'VersionControl/Git.php';
4 require_once 'Twig/Autoloader.php';
5 Twig_Autoloader::register();
6
7 $loader = new Twig_Loader_Filesystem($GLOBALS['phorkie']['cfg']['tpl']);
8 $twig = new Twig_Environment(
9     $loader,
10     array(
11         //'cache' => '/path/to/compilation_cache',
12         'debug' => true
13     )
14 );
15
16 function render($tplname, $vars)
17 {
18     $template = $GLOBALS['twig']->loadTemplate($tplname . '.htm');
19     echo $template->render($vars);
20 }
21 function redirect($target)
22 {
23     header('Location: /' . $target);
24     exit();
25 }
26 function errout($statusCode, $message)
27 {
28     header('HTTP/1.0 ' . $statusCode);
29     echo $message;
30     exit();
31 }
32 function get_type_from_file($file)
33 {
34     return substr($file, strrpos($file, '.') + 1);
35 }
36 ?>