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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
<?php
if (str_ends_with($_GET['_'], "/")) {
$pagename = substr($_GET['_'], 0, strlen($_GET['_']) - 1);
} else {
$pagename = $_GET['_'];
}
$toplevel = explode("/", $pagename)[0];
if (in_array($toplevel, ["editor", "icons", "species", "uploads"])) {
$filename = explode("/", $pagename)[1];
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/" . $toplevel . "/" . $filename)) {
header("Location: /assets/" . $toplevel . "/" . $filename) and die();
} else {
header("Location: /?error=File not found") and die();
}
} elseif ($toplevel === "") {
require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/home.php";
} else {
if ($toplevel === "-") {
$pagename = substr($pagename, 2);
$toplevel = explode("/", $pagename)[0];
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".php")) {
require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".php";
}
} else if ($toplevel === "api") {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".php")) {
require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".php";
}
} else if ($toplevel === "cloudburst" || $toplevel === "raindrops") {
require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/page.php";
} else {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".php")) {
header("Location: /-/" . $toplevel);
} else {
$namesCloudburst = array_map(function ($i) {
return $i['name'];
}, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true));
$namesRaindrops = array_map(function ($i) {
return $i['name'];
}, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true));
if (in_array($pagename, $namesCloudburst)) {
header("Location: /cloudburst/" . $pagename) and die();
} else if (in_array($pagename, $namesRaindrops)) {
header("Location: /raindrops/" . $pagename) and die();
} else {
header("Location: /?error=Page not found: " . strip_tags($pagename)) and die();
}
}
}
}
|