e61408701f6be5be3496eddde69c76f4aaeb5281
[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         header('HTTP/1.1 403 Forbidden');
16         $db = new Database();
17         render(
18             'forbidden',
19             array(
20                 'recents'     => $db->getSearch()->listAll(0, 5, 'crdate', 'desc'),
21             )
22         );
23         exit;
24     }
25 }
26 ?>