summaryrefslogtreecommitdiff
path: root/includes/init.inc
blob: 8773ba494e6e5a2cd62de9aa3b87a10e659726e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php

global $title;
global $toplevel;
global $emergencyHeader;
global $pages;
global $lang; global $pages;

$pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pages.json"), true);
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn;

if (in_array($toplevel, array_keys($pages))) {
    $title = $pages[$toplevel]["name"][$lang["_name"]];

    if ($pages[$toplevel]["admin"]) {
        $readOnly = false;
        @file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/.test", "hello");

        if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/.test")) {
            unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/data/.test");
        } else {
            $readOnly = true;
        }

        if (!isset($emergencyHeader)) {
            $emergencyHeader = false;
        }

        if ($pages[$toplevel]["limited"]) {
            if ((!$isLoggedIn && !$isLowerLoggedIn) || ($readOnly && !$emergencyHeader)) header("Location: /-/login/?return=/-/$toplevel") and die();
        } else {
            if (!$isLoggedIn || ($readOnly && !$emergencyHeader)) header("Location: /-/login/?return=/-/$toplevel") and die();
        }
    }
} else {
    $title = $toplevel;
}