summaryrefslogtreecommitdiff
path: root/includes/short.php
blob: dec0e09996ae1b0068d9225a8c2539aad0ab657f (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
38
39
40
41
42
43
44
45
46
47
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/bitset.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php";

global $toplevel;

header("Content-Type: text/plain");
$members = scoreOrderGlobal();
$list = [
    "rd" => "/raindrops",
    "cb" => "/cloudburst",
    "minty" => "/cloudy"
];

foreach ($members as $member) {
    for ($i = 1; $i < strlen($member["name"]); $i++) {
        $part = substr($member["name"], 0, $i);

        if (in_array($part, array_keys($list))) {
            $list[$part] = false;
        } else {
            $list[$part] = "/" . $member["name"];
        }
    }

    foreach ($member["proxy_tags"] as $proxy) {
        $system = $member["_system"] === "gdapd" ? "rd" : "cb";
        $list[$system . preg_replace("/[^a-z]/m", "", $proxy["prefix"])] = "/" . $member["name"];
    }

    $list[$member["id"]] = "/" . $member["name"];
    $list[$member["uuid"]] = "/" . $member["name"];
}

$list["minty"] = "/cloudy";

if (in_array($toplevel, array_keys($list)) && $list[$toplevel]) {
    if ($toplevel !== "unknown") {
        header("Location: " . $list[$toplevel]);
    } else {
        header("Location: /?error=Page not found: " . strip_tags($toplevel)) and die();
    }
} else {
    header("Location: /?error=Page not found: " . strip_tags($toplevel)) and die();
}