diff options
Diffstat (limited to 'pages')
-rw-r--r-- | pages/api.inc | 23 | ||||
-rw-r--r-- | pages/api/_main.php | 30 | ||||
-rw-r--r-- | pages/api/pluralkit-integration.php | 64 | ||||
-rw-r--r-- | pages/api/timeline.php | 12 | ||||
-rw-r--r-- | pages/api/violette.php | 23 | ||||
-rw-r--r-- | pages/home.inc | 13 | ||||
-rw-r--r-- | pages/jobs.inc | 138 | ||||
-rw-r--r-- | pages/login.inc | 48 | ||||
-rw-r--r-- | pages/logout.inc | 13 | ||||
-rw-r--r-- | pages/page.inc | 113 | ||||
-rw-r--r-- | pages/public.inc | 203 |
11 files changed, 0 insertions, 680 deletions
diff --git a/pages/api.inc b/pages/api.inc deleted file mode 100644 index 8bcea02..0000000 --- a/pages/api.inc +++ /dev/null @@ -1,23 +0,0 @@ -<?php - -if (str_ends_with($_GET['_'], "/")) { - $pagename = substr($_GET['_'], 0, strlen($_GET['_']) - 1); -} else { - $pagename = $_GET['_']; -} - -$toplevel = explode("/", $pagename)[1]; -$middlelevel = explode("/", $pagename)[2] ?? null; - -if (isset($middlelevel) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . "/" . $middlelevel . ".php") && is_file($_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . "/" . $middlelevel . ".php")) { - require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . "/" . $middlelevel . ".php"; -} else { - if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . ".php") && is_file($_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . ".php")) { - require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/api/" . $toplevel . ".php"; - } else { - header("HTTP/1.1 500 Internal Server Error"); - header("Content-Type: text/plain"); - echo("Endpoint not found"); - die(); - } -}
\ No newline at end of file diff --git a/pages/api/_main.php b/pages/api/_main.php deleted file mode 100644 index 215c1b2..0000000 --- a/pages/api/_main.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - -if (str_ends_with($_GET['_'], "/")) { - $pagename = substr($_GET['_'], 0, strlen($_GET['_']) - 1); -} else { - $pagename = $_GET['_']; -} - -$toplevel = explode("/", $pagename)[1]; -$middlelevel = explode("/", $pagename)[2] ?? null; - -if ($toplevel === "_main" || $middlelevel === "_main") { - header("HTTP/1.1 404 Not Found"); - header("Content-Type: text/plain"); - echo("Endpoint not found"); - die(); -} - -if (isset($middlelevel) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/api/" . $toplevel . "/" . $middlelevel . ".php") && is_file($_SERVER['DOCUMENT_ROOT'] . "/api/" . $toplevel . "/" . $middlelevel . ".php")) { - require_once $_SERVER['DOCUMENT_ROOT'] . "/api/" . $toplevel . "/" . $middlelevel . ".php"; -} else { - if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/api/" . $toplevel . ".php") && is_file($_SERVER['DOCUMENT_ROOT'] . "/api/" . $toplevel . ".php")) { - require_once $_SERVER['DOCUMENT_ROOT'] . "/api/" . $toplevel . ".php"; - } else { - header("HTTP/1.1 404 Not Found"); - header("Content-Type: text/plain"); - echo("Endpoint not found"); - die(); - } -} diff --git a/pages/api/pluralkit-integration.php b/pages/api/pluralkit-integration.php deleted file mode 100644 index 9b0033d..0000000 --- a/pages/api/pluralkit-integration.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php - -$app = $GLOBALS["ColdHazeApp"]; -$user = $_GET['user'] ?? null; -$inputJSON = file_get_contents('php://input'); -$input = json_decode($inputJSON, true); -$data = $GLOBALS["ColdHazeApp"]["webhook"]; - -if ($user === null) { - header("HTTP/1.1 500 Internal Server Error") and die(); -} - -if (!in_array($user, array_keys($data))) { - header("HTTP/1.1 404 Not Found") and die(); -} - -if ($input["signing_token"] !== $data[$user]) { - header("HTTP/1.1 401 Unauthorized") and die(); -} - -if ($input['system_id'] === "7d9f543e-f742-40f6-9d07-86c3f2983124") { - $system = "gdapd"; - $name = "Raindrops System"; -} elseif ($input['system_id'] === "d1cd97eb-9c92-4e42-94cd-4397a5074ff9") { - $system = "hrbom"; - $name = "Moonglow"; -} elseif (isset($app["other"]) && $input["system_id"] === $app["other"]["uuid"]) { - $system = $app["other"]["id"]; - $name = $app["other"]["name"]; -} else { - die(); -} - -$lastFronter = json_decode(@file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/last.json"), true) ?? ""; - -if ($input["type"] === "CREATE_MEMBER" || $input["type"] === "UPDATE_MEMBER" || $input["type"] === "DELETE_MEMBER") { - createJob("PKMembers", [ - "system" => $system - ]); - createJob("UpdateAssets", [ - "type" => "members" - ]); -} - -if ($input["type"] === "UPDATE_SYSTEM") { - createJob("PKSystem", [ - "system" => $system - ]); - createJob("UpdateAssets", [ - "type" => "system" - ]); -} - -if ($input["type"] === "CREATE_SWITCH" || $input["type"] === "UPDATE_SWITCH" || $input["type"] === "DELETE_SWITCH") { - createJob("PKFronters", [ - "system" => $system - ]); - createJob("PKSwitches", [ - "system" => $system - ]); - createJob("FrontersNotification", [ - "system" => $system - ]); -} diff --git a/pages/api/timeline.php b/pages/api/timeline.php deleted file mode 100644 index 8271b7a..0000000 --- a/pages/api/timeline.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; global $app; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; global $_PROFILE; - -$systems = array_filter(array_keys($_GET), function ($i) { - global $isLowerLoggedIn; global $isLoggedIn; global $app; - return $i === "gdapd" || $i === "hrbom" || (($isLowerLoggedIn || $isLoggedIn) && $i === $app["other"]["id"]); -}); - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/components/timeline.inc"; -displayTimeline($systems);
\ No newline at end of file diff --git a/pages/api/violette.php b/pages/api/violette.php deleted file mode 100644 index 1f6f4f0..0000000 --- a/pages/api/violette.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; - -$data = [ - "count" => 0, - "ponies" => [] -]; - -$list = scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true), "gdapd"); - -$data["count"] = count($list); -$data["ponies"] = array_values(array_filter(array_map(function ($i) { - return [ - "url" => "https://ponycule.p.equestria.dev" . getAsset("gdapd", $i["id"] ?? "", "heads"), - "label" => $i["display_name"] ?? $i["name"] - ]; -}, $list), function ($i) { - return isset($i["url"]) && getAsset("gdapd", $i["id"] ?? "", "heads") !== null; -})); - -header("Content-Type: application/json"); -die(json_encode($data, JSON_PRETTY_PRINT));
\ No newline at end of file diff --git a/pages/home.inc b/pages/home.inc deleted file mode 100644 index b4dc96a..0000000 --- a/pages/home.inc +++ /dev/null @@ -1,13 +0,0 @@ -<?php - -if (isset($_GET["ec"])) { - header("HTTP/1.1 " . $_GET["ec"] . " Error"); -} - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $isLoggedIn; global $isLowerLoggedIn; - -if ($isLoggedIn || $isLowerLoggedIn) { - require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/fragments/dashboard.inc"; -} else { - require_once $_SERVER['DOCUMENT_ROOT'] . "/pages/public.inc"; -}
\ No newline at end of file diff --git a/pages/jobs.inc b/pages/jobs.inc deleted file mode 100644 index 3c0bb3d..0000000 --- a/pages/jobs.inc +++ /dev/null @@ -1,138 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/util/functions.inc'; - -$history = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history.json"), true); -$running = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/running.json"), true); - -if (isset($_GET["enqueue"]) && isset($history[(int)$_GET["enqueue"]])) { - createJob(explode("(", $history[(int)$_GET["enqueue"]]["name"])[0], $history[(int)$_GET["enqueue"]]["options"]); - header("Location: /-/jobs/?enqueued"); - die(); -} - -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; - -?> - -<style> - <?php global $use2023UI; if (!$use2023UI): ?> - .list-group-item { - color: #fff; - background-color: #222; - border: 1px solid rgba(255, 255, 255, .125); - } - - .list-group-item.disabled { - color: #fff; - background-color: #222; - border-color: rgba(255, 255, 255, .125); - opacity: .75; - } - - .list-group-item:hover { - background-color: #252525; - color: #ddd; - } - - .list-group-item:active, .list-group-item:focus { - background-color: #272727; - color: #bbb; - } - - <?php endif; ?> - - details[open] summary { - font-weight: bold; - } - - <?php if ($use2023UI): ?> - pre { - background: var(--palette-4); - color: var(--palette-6); - padding: 10px 20px; - margin-top: 10px; - } - <?php else: ?> - pre { - background: #000000; - color: #ffffff; - padding: 10px 20px; - margin-top: 10px; - } - <?php endif; ?> - - pre.last { - margin-bottom: 0; - } - - .tracking li { - margin-bottom: 5px; - } - - .tracking li:nth-last-child(1), .tracking { - margin-bottom: 0 !important; - } -</style> - -<br> -<div class="container"> - <div id="page-content"> - <h2>Jobs history</h2> - - <?php if (isset($_GET["enqueued"])): ?> - <div class="alert alert-success">Successfully enqueued a new job, it will be run shortly and appear on this page once it has finished.</div> - <?php endif; ?> - - <div class="list-group"> - <?php foreach (array_reverse(array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/jobs"), function ($i) { - return !str_starts_with($i, "."); - })) as $index => $file): $item = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/jobs/" . $file), true); ?> - <div class="list-group-item disabled" style="list-style: none; display: grid; grid-template-columns: 3fr repeat(2, 1fr);"> - <div><?= $item["name"] ?>(<?php foreach ($item["options"] as $name => $value): echo($name . "=" . json_encode($value)); endforeach; ?>)</div> - <div><?= timeAgo($item["date"]) ?></div> - <div><?php if (isset($running) && $file === $running): ?><span class="text-info">Running</span><?php else: ?><span class="text-warning">Pending</span><?php endif; ?></div> - </div> - <?php endforeach; ?> - - <?php foreach ($history as $index => $item): ?> - <details class="list-group-item"> - <summary style="list-style: none; display: grid; grid-template-columns: 3fr repeat(2, 1fr);"> - <div><?= $item["name"] ?></div> - <div><?= timeAgo($item["tracking"]["queue"]) ?></div> - <div><?php if ($item["completed"]): ?><span class="text-success" style="filter: invert(1) hue-rotate(180deg);">Completed</span><?php else: ?><span class="text-danger" style="filter: invert(1) hue-rotate(180deg);">Failed</span><?php endif; ?></div> - </summary> - - <div class="list-group" style="margin-top: 10px;"> - <div class="list-group-item"> - <p> - <b>Duration:</b> <?= $item["time"] ?>ms · <a href="/-/jobs/?enqueue=<?= $index ?>">Enqueue again</a> - <b></b> - </p> - - <b>Console output:</b> - <pre><?= $item["output"] ?></pre> - - <?php if (isset($item["error"])): ?> - <b>Server error message:</b> - <pre><?= $item["error"] ?></pre> - <?php endif; ?> - - <b>Job lifetime:</b> - <ul class="tracking"> - <li><b>Queued by PHP</b><br><?= date('M jS Y, G:i:s', strtotime($item["tracking"]["queue"])) ?></li> - <?php if (isset($item["tracking"]["pickup"])): ?><li><b>Picked up by the runner</b><br><?= date('M jS Y, G:i:s', strtotime($item["tracking"]["pickup"])) ?></li><?php endif; ?> - <?php if (isset($item["tracking"]["start"])): ?><li><b>Started</b><br><?= date('M jS Y, G:i:s', strtotime($item["tracking"]["start"])) ?></li><?php endif; ?> - <?php if (isset($item["tracking"]["end"])): ?><li><b><?= $item["completed"] ? "Finished" : "Failed" ?></b><br><?= date('M jS Y, G:i:s', strtotime($item["tracking"]["end"])) ?></li><?php endif; ?> - <?php if (isset($item["tracking"]["logged"])): ?><li><b>Tracking logged</b><br><?= date('M jS Y, G:i:s', strtotime($item["tracking"]["logged"])) ?></li><?php endif; ?> - </ul> - </div> - </div> - </details> - <?php endforeach; ?> - </div> - </div> -</div> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?>
\ No newline at end of file diff --git a/pages/login.inc b/pages/login.inc deleted file mode 100644 index 0e306f1..0000000 --- a/pages/login.inc +++ /dev/null @@ -1,48 +0,0 @@ -<?php - -if (isset($_GET["return"])) { - setcookie("PEH2_RETURN_PAGE", $_GET["return"], 0, "/"); -} - -if (isset($_GET["immediate"]) || (isset($_COOKIE["new2023UI"]) && !isset($_GET["no2023"]))) { - header("Location: /auth/init"); - die(); -} - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; global $readOnly; global $isNormallyLoggedIn; - -?> - -<br> -<div class="container"> - <div> - <h2><?= $pages["login"]["name"][$lang["_name"]] ?></h2> - <?php if ($readOnly): ?> - <div class="alert alert-warning"> - <b><?= $lang["login"]["maintenance"][0] ?> </b><?= $lang["login"]["maintenance"][1] ?> - </div> - <?php else: ?> - <?php global $isLoggedIn; if ($isLoggedIn): ?> - <div class="alert alert-warning"> - <b>You are already logged in.</b> If you want to log into a different account or using a different authentication method, you may do so now. - </div> - <?php else: ?> - <p><?= $lang["login"]["select"] ?> Ponycule.</p> - <div class="row"> - <div class="col-md-6"> - <div class="card" style="margin-bottom:10px;text-align: center;"> - <div class="card-body"> - <h4 class="card-title" style="margin-top:15px;"><?= $lang["login"]["private"][0] ?></h4> - <p><?= $lang["login"]["private"][1] ?></p> - <a href="/auth/init" class="btn btn-primary"><?= $lang["login"]["private"][2] ?></a> - </div> - </div> - </div> - <div class="col-md-6"></div> - </div> - <?php endif; endif; ?> - </div> -</div> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> diff --git a/pages/logout.inc b/pages/logout.inc deleted file mode 100644 index 3d3f39b..0000000 --- a/pages/logout.inc +++ /dev/null @@ -1,13 +0,0 @@ -<?php - -if (isset($_COOKIE['PEH2_SESSION_TOKEN'])) { - if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . str_replace(".", "", str_replace("/", "", $_COOKIE['PEH2_SESSION_TOKEN'])))) { - unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . str_replace(".", "", str_replace("/", "", $_COOKIE['PEH2_SESSION_TOKEN']))); - } elseif (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/lowertokens/" . str_replace(".", "", str_replace("/", "", $_COOKIE['PEH2_SESSION_TOKEN'])))) { - unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/lowertokens/" . str_replace(".", "", str_replace("/", "", $_COOKIE['PEH2_SESSION_TOKEN']))); - } - - header("Set-Cookie: PEH2_SESSION_TOKEN=; SameSite=None; Path=/; Secure; HttpOnly; Expires=0"); -} - -header("Location: /") and die();
\ No newline at end of file diff --git a/pages/page.inc b/pages/page.inc deleted file mode 100644 index 4de846b..0000000 --- a/pages/page.inc +++ /dev/null @@ -1,113 +0,0 @@ -<?php - -global $lang; global $pages; global $isLoggedIn; global $isLowerLoggedIn; - -$app = $GLOBALS["ColdHazeApp"]; - -$travelling = []; -if (!isset($_GET['_']) || trim($_GET['_']) === "") peh_error("Invalid request", 400); - -$parts = explode("/", $_GET['_']); - -if (($parts[0] !== "raindrops" && $parts[0] !== "moonglow" && $parts[0] !== $app["other"]["slug"]) && (!(count($parts) > 2) || $parts[1] === "-")) { - $namesRaindrops = [...array_map(function ($i) { - return $i['name']; - }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true)), "unknown-rd"]; - $namesMoonglow = array_map(function ($i) { - return $i['name']; - }, array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/hrbom/members.json"), true), function ($i) { - return true; - })); - $namesOther = []; - - if ($isLoggedIn || $isLowerLoggedIn) { - $namesOther = [...array_map(function ($i) { - return $i['name']; - }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/members.json"), true)), $app["other"]["unknown"]]; - } - - $parts = explode("/", $_GET['_']); - array_unshift($parts, ""); - $parts = array_values($parts); - - if (in_array($parts[1], $namesRaindrops)) { - $parts[0] = "raindrops"; - } else if (in_array($parts[1], $namesMoonglow)) { - $parts[0] = "moonglow"; - } else if (in_array($parts[1], $namesOther) && ($isLoggedIn || $isLowerLoggedIn)) { - $parts[0] = $app["other"]["slug"]; - } - - if ($parts[1] === "unknown-rd" || $parts[1] === "unknown-cb" || (($isLoggedIn || $isLowerLoggedIn) && $parts[1] === $app["other"]["unknown"])) $parts[1] = "unknown"; -} - -$system = $parts[0]; -$member = ($parts[1] ?? null) === "" ? null : ($parts[1] ?? null); - -if ($system !== "raindrops" && $system !== "moonglow" && ($system !== $app["other"]["slug"] && !$isLowerLoggedIn && !$isLoggedIn)) peh_error("System not found", 404); -$systemCommonName = $system === $app["other"]["slug"] && ($isLoggedIn || $isLowerLoggedIn) ? $app["other"]["name"] : ($system === "moonglow" ? "Moonglow" : "Raindrops System"); -$systemID = $system === $app["other"]["slug"] && ($isLoggedIn || $isLowerLoggedIn) ? $app["other"]["id"] : ($system === "moonglow" ? "hrbom" : "gdapd"); - -if ($member === null) { - global $_SystemName; - $_SystemName = $system; - $pageFile = $_SERVER['DOCUMENT_ROOT'] . '/includes/fragments/system.inc'; - require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/fragments/system.inc'; -} else if ($member === "-" && isset($parts[2])) { - if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/includes/system/' . $parts[2] . '.inc')) { - global $_SystemPage; - $_SystemPage = $parts[2]; - $pageFile = $_SERVER['DOCUMENT_ROOT'] . '/includes/system/' . $parts[2] . '.inc'; - require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/system/' . $parts[2] . '.inc'; - } else { - peh_error("System page not found: " . strip_tags($parts[2]), 404); - } -} else { - $memberFoundInAnotherSystem = false; - $traveller = false; - - $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === $app["other"]["id"] ? "other" : $systemID) . "/members.json"), true); - $members2 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($systemID === "gdapd" ? "hrbom" : "gdapd") . "/members.json"), true); - $memberData = null; - $memberCommonName = null; - $memberID = null; - - foreach ($members as $m) {if ($m['name'] === $member) { - $memberData = $m; - $memberCommonName = $m['display_name'] ?? $m['name']; - $memberID = $m['id']; - } - } - - foreach ($members2 as $m) { - if ($m['name'] === $member) { - $memberFoundInAnotherSystem = true; - } - } - - global $_SystemName; - $_SystemName = $system; - - if (str_ends_with($member, "-travelling")) { - header("Location: /" . substr($member, 0, strlen($member) - 11)) and die(); - } - - if (isset($parts[2]) && $parts[2] === "-" && isset($parts[3])) { - if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/includes/member/' . $parts[3] . '.inc')) { - global $_MemberPage; - $_MemberPage = $parts[3]; - $pageFile = $_SERVER['DOCUMENT_ROOT'] . '/includes/member/' . $parts[3] . '.inc'; - require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/member/' . $parts[3] . '.inc'; - } else { - peh_error("Member page not found: " . strip_tags($parts[3]), 404); - } - die(); - } - - global $_MemberName; - $_MemberName = $member; - $pageFile = $_SERVER['DOCUMENT_ROOT'] . '/includes/fragments/member.inc'; - require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/fragments/member.inc'; -} - -exit; diff --git a/pages/public.inc b/pages/public.inc deleted file mode 100644 index f714f89..0000000 --- a/pages/public.inc +++ /dev/null @@ -1,203 +0,0 @@ -<?php - -if (isset($_GET["ec"])) { - header("HTTP/1.1 " . $_GET["ec"] . " Error"); -} - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; $title = ""; global $isNormallyLoggedIn; global $_PROFILE; global $lang; global $pages; global $isLowerLoggedIn; global $app; global $isLoggedIn; -$isOrigLoggedIn = $isLoggedIn; $isOrigLowerLoggedIn = $isLowerLoggedIn; - -if ($isOrigLowerLoggedIn || $isOrigLoggedIn) { - $title = "Public home page"; -} - -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; global $readOnly; -$isLoggedIn = false; $isLowerLoggedIn = false; - -global $use2023UI; - -function banner() { $isLoggedIn = false; $isLowerLoggedIn = false; $byColor = getMembersByColor(false, true); global $lang; global $use2023UI; ?> - <div style="text-align: center;"> - <img alt="" src="/assets/logo/newlogo-ng.png" style="width:128px;"> - <p style="z-index:999;position:relative;background:transparent;margin: 20px -10px 0 -20px;padding-right:30px;height:32px;text-align: center;display:grid;grid-template-columns: repeat(<?= count($byColor) ?>, 1fr);"> - <?php foreach ($byColor as $member): ?><a class="rainbow-item" style="overflow: hidden;"></a><?php endforeach; ?> - </p> - <div style="margin-top:-33px;margin-bottom:0;margin-left:-20px;margin-right:20px;height:32px;text-align: center;display:grid;grid-template-columns: repeat(<?= count($byColor) ?>, 1fr);position:relative;left:10px;"> - <?php foreach ($byColor as $member): ?><div> - <span style="display: inline-block;background: transparent;position:absolute;width: 0;height: 0;margin-top: 17px;box-shadow: 0 6px 20px 20px #<?= $member["color"] ?>;z-index: 9;margin-left: 8px;opacity: .75;"></span> - </div><?php endforeach; ?> - </div> - <div id="banner-lower" style="padding:5px 10px;background:#3332328a;position:relative;z-index: 999;backdrop-filter: blur(30px);"> - <h2 style="margin-top: 20px;">Ponycule</h2> - <?php if ($isLoggedIn || $isLowerLoggedIn): ?> - <p><?= count($byColor) ?> ponies in 4 plural systems</p> - <?php else: ?> - <p><?= count($byColor) ?> ponies in 3 plural systems</p> - <?php endif; ?> - </div> - </div> -<?php } - -function members() { $isLoggedIn = false; $isLowerLoggedIn = false; global $app; ?> - <div id="new-homepage" style="margin-top:20px;"> - - <div id="new-homepage-systems" <?php if ($isLoggedIn || $isLowerLoggedIn): ?>style="grid-template-columns: repeat(3, 1fr);"<?php endif; ?>> - <?php newHomepage("gdapd", "raindrops", true); ?> - <?php if ($isLoggedIn || $isLowerLoggedIn) newHomepage($app["other"]["id"], $app["other"]["slug"], true); ?> - <?php newHomepage("hrbom", "moonglow", true); ?> - </div> - - </div> -<?php } ?> - -<br> -<div class="container"> - <?php if (isset($_GET['em'])): ?> - <div class="alert alert-danger alert-dismissible"> - <button onclick='window.history.pushState({"html":null,"pageTitle":document.title},"", "/");' type="button" class="btn-close" data-bs-dismiss="alert"></button> - <b><?= $lang["home"]["error"] ?> </b><?= strip_tags(base64_decode($_GET['em'])) ?> - </div> - <?php endif; ?> - - <div class="alert alert-warning alert-dismissible" id="gpuWarning" style="display: none;"> - <button onclick='window.history.pushState({"html":null,"pageTitle":document.title},"", "/");' type="button" class="btn-close" data-bs-dismiss="alert"></button> - <b>GPU acceleration is turned off or not supported.</b> A lot of visual effects on this website rely on GPU acceleration, which is currently disabled on your browser, meaning the website's overall look will be affected. Please enable GPU acceleration in your browser settings. - </div> - - <?php if ($readOnly && $isNormallyLoggedIn || $readOnly && $isLowerLoggedIn): ?> - <div class="alert alert-warning"> - <b>Notice: </b>This website is temporarily under maintenance and the administrators have locked the database. Although you are logged in as <?= $_PROFILE['name'] ?>, you cannot access any of the logged-in features while the website is under maintenance. <a href="/-/emergency">Alerts dispatching</a> remains possible in case of an emergency. - </div> - <?php endif; ?> - - - <?php - - if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/home.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/home.json", "{}"); - $cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/home.json"), true); - if (!isset($cache["banner"])) $cache["banner"] = []; - if (!isset($cache["members"])) $cache["members"] = []; - - if (!isset($cache["banner"]["public"])) { - ob_start(); - - $isLoggedInOldState = $isLoggedIn; - $isLowerLoggedInOldState = $isLowerLoggedIn; - $isLoggedIn = false; - $isLowerLoggedIn = false; - banner(); - $isLoggedIn = $isLoggedInOldState; - $isLowerLoggedIn = $isLowerLoggedInOldState; - - $cache["banner"]["public"] = ob_get_contents(); - ob_end_clean(); - } - - if (!isset($cache["banner"]["private"])) { - ob_start(); - - $isLoggedInOldState = $isLoggedIn; - $isLowerLoggedInOldState = $isLowerLoggedIn; - $isLoggedIn = true; - $isLowerLoggedIn = true; - banner(); - $isLoggedIn = $isLoggedInOldState; - $isLowerLoggedIn = $isLowerLoggedInOldState; - - $cache["banner"]["private"] = ob_get_contents(); - ob_end_clean(); - } - - if (!isset($cache["members"]["public"])) { - ob_start(); - - $isLoggedInOldState = $isLoggedIn; - $isLowerLoggedInOldState = $isLowerLoggedIn; - $isLoggedIn = false; - $isLowerLoggedIn = false; - members(); - $isLoggedIn = $isLoggedInOldState; - $isLowerLoggedIn = $isLowerLoggedInOldState; - - $cache["members"]["public"] = ob_get_contents(); - ob_end_clean(); - } - - if (!isset($cache["members"]["private"])) { - ob_start(); - - $isLoggedInOldState = $isLoggedIn; - $isLowerLoggedInOldState = $isLowerLoggedIn; - $isLoggedIn = true; - $isLowerLoggedIn = true; - members(); - $isLoggedIn = $isLoggedInOldState; - $isLowerLoggedIn = $isLowerLoggedInOldState; - - $cache["members"]["private"] = ob_get_contents(); - ob_end_clean(); - } - - if ($isLowerLoggedIn || $isLoggedIn) { - echo($cache["banner"]["private"]); - } else { - echo($cache["banner"]["public"]); - } - - ?> - <div id="timeline-container" style="background: #3332328a;padding: 5px 10px;border-top:1px solid rgba(255,255,255,.1);border-bottom-left-radius: 10px;border-bottom-right-radius: 10px;"> - <div id="timeline"></div> - <script> - async function refreshTimeline() { - document.getElementById("timeline").innerHTML = await (await fetch("/api/timeline?gdapd&hrbom<?= ($isLowerLoggedIn || $isLoggedIn) ? "&" . $app["other"]["id"] : "" ?>&hrbom")).text(); - - Array.from(document.getElementsByClassName("dynamic-time")).forEach((el) => { - let time = el.getAttribute("data-time"); - el.innerText = new Date(parseInt(time) * 1000).toTimeString().split(":").splice(0, 2).join(":"); - }); - - Array.from(document.getElementsByClassName("dynamic-time-mobile")).forEach((el) => { - let time = el.getAttribute("data-time"); - el.innerText = new Date(parseInt(time) * 1000).toTimeString().split(":")[0] + ":"; - }); - } - - setInterval(refreshTimeline, 10000); - refreshTimeline(); - </script> - </div> - - <!--<div class="alert alert-warning" style="margin-top:20px;"> - <b>Notice:</b> The administrators are currently trying a new optimisation technique based on a virtual file system (chvfs). Data loss, corruption or inconsistency may happen and should be reported on <a href="https://bugs.equestria.dev/issues/CH" target="_blank">bugs.equestria.dev</a>. - </div>--> - - <?php if (isset($_COOKIE["PEH2_SESSION_TOKEN"]) && $_COOKIE["PEH2_SESSION_TOKEN"] !== "" && !$isOrigLoggedIn && !$isOrigLowerLoggedIn): ?> - <div class="alert alert-warning" style="margin-top:20px;"> - <b>You were previously logged in to Ponycule, </b>however you have been logged out due to inactivity, due to your device being removed, or due to switching to a new authentication system (such as the v3). Please log in again. <a href="https://bugs.equestria.dev/issue/CH-56/Better-session-security" target="_blank">Learn more.</a> - </div> - <?php endif; ?> - - <?php - - if ($isLowerLoggedIn || $isLoggedIn) { - echo($cache["members"]["private"]); - } else { - echo($cache["members"]["public"]); - } - - ?> -</div> - -<style> -<?php if ($use2023UI): ?> -.old-ui { - display: none; -} -<?php else: ?> -.new-ui { - display: none; -} -<?php endif; ?> -</style> - -<?php file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/home.json", json_encode($cache)); require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> |