diff options
Diffstat (limited to 'includes/init.inc')
-rw-r--r-- | includes/init.inc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/includes/init.inc b/includes/init.inc new file mode 100644 index 0000000..7265c0e --- /dev/null +++ b/includes/init.inc @@ -0,0 +1,28 @@ +<?php + +global $title; +global $toplevel; +global $emergencyHeader; +global $pages; + +$pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pages.json"), true); +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.inc"; global $isLoggedIn; + +if (in_array($toplevel, array_keys($pages))) { + $title = $pages[$toplevel]["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 (!$isLoggedIn || ($readOnly && !$emergencyHeader)) header("Location: /-/login/?return=$toplevel") and die(); + } +} else { + $title = $toplevel; +}
\ No newline at end of file |