ADD: Add identity to /forbidden page for easy administration
[phorkie.git] / www / secure.php
1 <?php
2 /** 
3  * Protect page
4  */
5 namespace phorkie;
6 require_once 'www-header.php';
7 $_SESSION['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
8 if (!isset($_SESSION['identity'])) {
9     header("Location: /login");
10     exit;
11 }
12 if ($GLOBALS['phorkie']['auth']['secure'] > 0 &&
13     $GLOBALS['phorkie']['auth']['userlist']) {
14     if (!in_array($_SESSION['identity'], $GLOBALS['phorkie']['users'])) {
15         $redirect = 'http://' . $_SERVER['HTTP_HOST'] . "/forbidden";
16         header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
17         exit;
18     }
19 }
20 ?>