CLEAN: Corrected spacing
[phorkie.git] / www / www-security.php
1 <?php
2 namespace phorkie;
3 /**
4  * security levels + login requirement:
5  */
6
7 if (!isset($GLOBALS['phorkie']['auth']['securityLevel'])) {
8     //not set? highest level of security
9     $GLOBALS['phorkie']['auth']['securityLevel'] = 2;
10 }
11
12 if ($GLOBALS['phorkie']['auth']['securityLevel'] == 0) {
13     //everyone may do everything
14     return;
15 }
16
17 $logged_in = false;
18 if (!isset($_SESSION['identity'])) {
19     //not logged in 
20 } else if ($GLOBALS['phorkie']['auth']['listedUsersOnly']) {
21     if (in_array($_SESSION['identity'], $GLOBALS['phorkie']['auth']['users'])) {
22         $logged_in = true;
23     }
24 } else {
25     //session identity exists, no special checks required
26     $logged_in = true;
27 }
28
29 if ($securityLevel >= $GLOBALS['phorkie']['auth']['securityLevel']) {
30     if ($logged_in) {
31         return;
32     }
33 } else {
34     return;
35 }
36
37 // p / G / log_in = disp
38 // 0 / 1 / true   = return
39 // 0 / 1 / false  = block
40 // 0 / 2 / true   = return
41 // 0 / 2 / false  = return
42 // 1 / 1 / true   = return
43 // 1 / 1 / false  = block
44 // 1 / 2 / true   = return
45 // 1 / 2 / false  = block
46
47 $_SESSION['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
48 require 'forbidden.php';
49 ?>