Remove releasenotes from build.xml
[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 ($logged_in) {
30     //you may do everything if you're logged in
31     return;
32 }
33
34 if (!isset($reqWritePermissions)) {
35     $reqWritePermissions = true;
36 }
37 if ($GLOBALS['phorkie']['auth']['securityLevel'] == 1
38     && !$reqWritePermissions
39 ) {
40     return;
41 }
42
43 $_SESSION['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
44 require 'forbidden.php';
45 ?>