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