<?php ob_start(); //if (false) { if (!str_starts_with($_SERVER['REQUEST_URI'], "/api")) { require_once $_SERVER['DOCUMENT_ROOT'] . "/error.php"; set_error_handler("ch_error"); } $start = microtime(true); $GLOBALS["ColdHazeStart"] = microtime(true); $GLOBALS["ColdHazePerformance"] = []; if (!function_exists("formatPonypush")) { function formatPonypush($message) { return "Update to Ponypush 3.1.0 or later — (\$PA1$\$" . base64_encode($message) . "\$\$)"; } } require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/language.inc"; global $lang; global $pages; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; global $app; $app = $GLOBALS["ColdHazeApp"] = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); 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 { peh_error("File not found", 404); } } elseif ($toplevel === "") { $pageFile = $_SERVER['DOCUMENT_ROOT'] . "/pages/home.inc"; $GLOBALS["ColdHazePerformance"]["router"] = (microtime(true) - $start) * 1000; require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/home.inc"; } else { if ($toplevel === "-") { $pagename = substr($pagename, 2); $toplevel = explode("/", $pagename)[0]; if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".inc")) { $pageFile = $_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".inc"; $GLOBALS["ColdHazePerformance"]["router"] = (microtime(true) - $start) * 1000; require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".inc"; } else { peh_error("Page not found: " . strip_tags($pagename), 404); } } else if ($toplevel === "api") { if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".inc")) { $pageFile = $_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".inc"; $GLOBALS["ColdHazePerformance"]["router"] = (microtime(true) - $start) * 1000; require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".inc"; } } else if ($toplevel === "cloudburst" || $toplevel === "raindrops" || (($isLoggedIn || $isLowerLoggedIn) && $toplevel === $app["other"]["slug"])) { $parts = explode("/", $_GET['_']); if (isset($parts[1]) && $parts[1] !== "-") { if ($parts[1] === "unknown") { if ($parts[0] === "cloudburst") { header("Location: /unknown-cb"); } else { header("Location: /unknown-rd"); } } else { header("Location: /" . $parts[1]); } die(); } $pageFile = $_SERVER['DOCUMENT_ROOT'] . "/pages/page.inc"; $GLOBALS["ColdHazePerformance"]["router"] = (microtime(true) - $start) * 1000; require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/page.inc"; } else { if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/pages/" . $toplevel . ".inc")) { header("Location: /-/" . $toplevel); } else { $namesCloudburst = [...array_map(function ($i) { return $i['name']; }, array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true), function ($i) { return file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $i["id"] . ".json"); })), "unknown-cb"]; $namesRaindrops = [...array_map(function ($i) { return $i['name']; }, array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true), function ($i) { return file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $i["id"] . ".json"); })), "unknown-rd"]; $namesOther = []; if ($isLoggedIn || $isLowerLoggedIn) { $namesOther = [...array_map(function ($i) { return $i['name']; }, array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/members.json"), true), function ($i) { return file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $i["id"] . ".json"); })), $app["other"]["unknown"]]; } if ((in_array($toplevel, $namesCloudburst) || in_array($toplevel, $namesRaindrops) || in_array($toplevel, $namesOther)) && $toplevel !== "unknown") { $pageFile = $_SERVER['DOCUMENT_ROOT'] . "/pages/page.inc"; $GLOBALS["ColdHazePerformance"]["router"] = (microtime(true) - $start) * 1000; require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/page.inc"; } else { global $toplevel; $pageFile = $_SERVER['DOCUMENT_ROOT'] . "/includes/util/short.inc"; $GLOBALS["ColdHazePerformance"]["router"] = (microtime(true) - $start) * 1000; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/short.inc"; } } } } $output = ob_get_contents(); ob_end_clean(); echo($output);