diff options
Diffstat (limited to 'pages')
33 files changed, 36 insertions, 2435 deletions
diff --git a/pages/account.inc b/pages/account.inc deleted file mode 100644 index 216892c..0000000 --- a/pages/account.inc +++ /dev/null @@ -1,30 +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/components/header.inc'; ?> - -<br> -<div class="container"> - <div id="page-content"> - <h2>Account and security</h2> - <br> - - <div class="list-group"> - <a href="/-/sessions" class="list-group-item list-group-item-action" style="display: grid; grid-template-columns: max-content 1fr;"> - <img src="<?= icon('session_manager', null, true) ?>" style="margin-right: 5px; height: 24px; width: 24px;"><div style="display: flex; align-items: center; color: var(--bs-body-color);">Logged in devices</div> - </a> - <a href="/-/pair" class="list-group-item list-group-item-action" style="display: grid; grid-template-columns: max-content 1fr;"> - <img src="<?= icon('pair', null, true) ?>" style="margin-right: 5px; height: 24px; width: 24px;"><div style="display: flex; align-items: center; color: var(--bs-body-color);">Pair new device</div> - </a> - <a href="/-/logout" class="list-group-item list-group-item-action" style="display: grid; grid-template-columns: max-content 1fr;"> - <img src="<?= icon('logout', null, true) ?>" style="margin-right: 5px; height: 24px; width: 24px;"><div style="display: flex; align-items: center; color: var(--bs-body-color);">Logout</div> - </a> - </div> - - <hr> - <?php $version = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/version.json"), true); ?> - <p>Ponycule Software, build <?= $version["build"] ?>.<?= $version["revision"] ?> · © 2022-<?= date('Y') ?> <a href="https://equestria.dev" target="_blank">Equestria.dev Developers</a></p> - </div> -</div> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> diff --git a/pages/alerts.inc b/pages/alerts.inc deleted file mode 100644 index a47c84f..0000000 --- a/pages/alerts.inc +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; global $_PROFILE; global $isLowerLoggedIn; -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; ?> - -<br> -<div class="container"> - <div id="page-content"> - <h2>Alerts</h2> - <br> - - <div class="list-group"> - <a href="/-/emergency" class="list-group-item list-group-item-action" style="display: grid; grid-template-columns: max-content 1fr;"> - <img src="<?= icon('emergency', null, true) ?>" style="margin-right: 5px; height: 24px; width: 24px;"><div style="display: flex; align-items: center; color: var(--bs-body-color);">Emergency alert<?php if (isset($_GET["noCountdown"])): ?></div><?php else: ?> (<span id="emergency-countdown">10</span>)</div> - <script> - let eCountdownInterval = setInterval(() => { - document.getElementById("emergency-countdown").innerText = (parseInt(document.getElementById("emergency-countdown").innerText) - 1).toString(); - - if (parseInt(document.getElementById("emergency-countdown").innerText) <= 0) { - clearInterval(eCountdownInterval); - location.href = "/-/emergency"; - } - }, 1000); - </script><?php endif; ?> - </a> - <?php if ($isLowerLoggedIn || $_PROFILE["login"] === "raindrops"): ?> - <a href="/-/pleasure" class="list-group-item list-group-item-action" style="display: grid; grid-template-columns: max-content 1fr;"> - <img src="<?= icon('pleasure', null, true) ?>" style="margin-right: 5px; height: 24px; width: 24px;"><div style="display: flex; align-items: center; color: var(--bs-body-color);">Pleasure alert</div> - </a> - <?php endif; ?> - </div> - </div> -</div> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> diff --git a/pages/alphabet.inc b/pages/alphabet.inc deleted file mode 100644 index 2b57c76..0000000 --- a/pages/alphabet.inc +++ /dev/null @@ -1,71 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $isLowerLoggedIn; global $lang; global $pages; -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; - -if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/alphabet.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/alphabet.json", "{}"); - -$cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/alphabet.json"), true); - -function page(): void -{ global $lang; global $pages; ?> - <div id="page-content"> - <h2><?= $pages["alphabet"]["name"][$lang["_name"]] ?></h2> - <?php $members = scoreOrderGlobal(); ?> - - <div> - <?php foreach (str_split("abcdefghijklmnopqrstuvwxyz") as $letter): ?> - <div style="display:inline-grid;grid-template-columns: max-content 1fr;min-height:32px;"> - <div style="display:flex;align-items:center;justify-content:center;font-weight: bold;margin-right:10px;" class="font-monospace"><?= $letter ?>.</div> - <div> - <?php foreach ($members as $member): if (isset($member["proxy_tags"][0]) && isset($member["proxy_tags"][0]["prefix"]) && str_starts_with(strtolower($member["proxy_tags"][0]["prefix"]), strtolower($letter)) && strlen($member["proxy_tags"][0]["prefix"]) === 2): ?><a href="/<?= $member["name"] ?>" title="<b><?= $member["display_name"] ?></b> (<code class='text-white'><?= $member["proxy_tags"][0]["prefix"] ?></code>)" data-bs-toggle="tooltip" data-bs-html="true"><img src="<?= getAsset($member['system'], $member["id"], "heads") ?>" style="width:24px;"></a><?php endif; endforeach; ?> - </div> - </div> - <?php foreach (str_split("abcdefghijklmnopqrstuvwxyz") as $letter2): $list = array_filter($members, function ($member) use ($letter, $letter2) { - return isset($member["proxy_tags"][0]) && isset($member["proxy_tags"][0]["prefix"]) && str_starts_with(strtolower($member["proxy_tags"][0]["prefix"]), strtolower($letter . $letter2)) && strlen($member["proxy_tags"][0]["prefix"]) === 3; - }); if (count($list) > 0): ?> - (<div style="display:inline-grid;grid-template-columns: max-content 1fr;min-height:32px;"> - <div style="display:flex;align-items:center;justify-content:center;" class="font-monospace"><?= $letter . $letter2 ?>.</div> - <div> - <?php foreach ($list as $member): ?><a href="/<?= $member["name"] ?>" title="<b><?= $member["display_name"] ?></b> (<code class='text-white'><?= $member["proxy_tags"][0]["prefix"] ?></code>)" data-bs-toggle="tooltip" data-bs-html="true"><img src="<?= getAsset($member['system'], $member["id"], "heads") ?>" style="width:24px;"></a><?php endforeach; ?> - </div> - </div>) - <?php endif; endforeach; ?> - <br> - <?php endforeach; ?> - </div> - </div> -<?php } - -?> - -<br> -<div class="container"> - <?php if (!isset($cache["private"]) || !isset($cache["public"])) { - ob_start(); - $isLoggedInOldState = $isLoggedIn; - $isLowerLoggedInOldState = $isLowerLoggedIn; - $isLoggedIn = true; - $isLowerLoggedIn = true; - page(); - $isLoggedIn = $isLoggedInOldState; - $isLowerLoggedIn = $isLowerLoggedInOldState; - $cache["private"] = ob_get_contents(); - ob_end_clean(); - - ob_start(); - $isLoggedInOldState = $isLoggedIn; - $isLowerLoggedInOldState = $isLowerLoggedIn; - $isLoggedIn = false; - $isLowerLoggedIn = false; - page(); - $isLoggedIn = $isLoggedInOldState; - $isLowerLoggedIn = $isLowerLoggedInOldState; - $cache["public"] = ob_get_contents(); - ob_end_clean(); - } - - echo($isLoggedIn ? $cache["private"] : $cache["public"]); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/alphabet.json", json_encode($cache)); ?> -</div> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> diff --git a/pages/api/_main.php b/pages/api/_main.php new file mode 100644 index 0000000..215c1b2 --- /dev/null +++ b/pages/api/_main.php @@ -0,0 +1,30 @@ +<?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/badger.php b/pages/api/badger.php deleted file mode 100644 index d54e69f..0000000 --- a/pages/api/badger.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; - -global $isLoggedIn; global $isLowerLoggedIn; -$isLoggedIn = false; $isLowerLoggedIn = false; - -$list = scoreOrderGlobal(); - -function getAge($metadata) { - if (!isset($metadata["birth"]["year"]) || $metadata["birth"]["age"] > 0) { - if ($metadata["birth"]["age"] === -1) { - $age = " - Eternal"; - } elseif ($metadata["birth"]["age"] <= 0) { - $age = ""; - } else { - $age = " - " . ($metadata["birth"]["age"]); - } - } else { - if ($metadata["birth"]["year"] <= 1900) { - $age = ""; - } else { - $age = " - " . ((int)date('Y') - $metadata["birth"]["year"] + (strtotime(date('Y') . "-" . $metadata["birth"]["date"]) <= time() ? 0 : -1)); - } - } - - return $age; -} - -header("Content-Type: application/json"); -die(json_encode(array_map(function ($i) { - return [ - "id" => $i["id"], - "name" => $i["display_name"] ?? $i["name"], - "system" => $i["system"], - "pronouns" => $i["pronouns"], - "species" => match ($i["_metadata"]["species"][0]) { - "earth" => $i["_metadata"]["robot"] ? "Robot earth pony" : (!$i["_metadata"]["plush"] ? "Earth pony" : "Earth pony plush"), - "alicorn" => $i["_metadata"]["robot"] ? "Robot alicorn" : (!$i["_metadata"]["plush"] ? "Alicorn" : "Alicorn plush"), - "crystal" => $i["_metadata"]["robot"] ? "Robot crystal pony" : (!$i["_metadata"]["plush"] ? "Crystal pony" : "Crystal pony plush"), - "pegasus" => $i["_metadata"]["robot"] ? "Robot pegasus" : (!$i["_metadata"]["plush"] ? "Pegasus" : "Pegasus plush"), - "batpony" => $i["_metadata"]["robot"] ? "Robot bat pony" : (!$i["_metadata"]["plush"] ? "Bat pony" : "Bat pony plush"), - "unicorn" => $i["_metadata"]["robot"] ? "Robot unicorn" : (!$i["_metadata"]["plush"] ? "Unicorn" : "Unicorn plush"), - "changeling" => "Changeling", - "human" => "Human", - "merpony" => "Merpony", - default => $i["_metadata"]["species"][0] . "_" . $i["_metadata"]["robot"] - }, - "age" => getAge($i["_metadata"]), - "avatar" => "https://ponycule.p.equestria.dev" . getAsset($i["system"], $i["id"], "heads") - ]; -}, $list), JSON_PRETTY_PRINT));
\ No newline at end of file diff --git a/pages/api/disconnect.php b/pages/api/disconnect.php deleted file mode 100644 index ffd3f40..0000000 --- a/pages/api/disconnect.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; global $_PROFILE; -if (!$isLoggedIn && !$isLowerLoggedIn) { - header("Location: /-/login"); - die(); -} - -$list = array_filter([...scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens"), ...scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/lowertokens")], function ($token) { - global $_PROFILE; - if ($token === "." || $token === "..") return false; - - $session = file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . $token) ? json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . $token), true) : json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/lowertokens/" . $token), true); - - return isset($session["id"]) && $session["id"] === ($_PROFILE["id"] ?? ""); -}); - -var_dump($list); - -foreach ($list as $token) { - $session = file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . $token) ? json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . $token), true) : json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/lowertokens/" . $token), true); - - var_dump(bin2hex(substr($token, 0, 50)), trim($_GET["id"])); - - if (bin2hex(substr($token, 0, 50)) === trim($_GET["id"])) { - if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/sessions/" . $token)) { - unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/sessions/" . $token); - } - - if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . $token)) { - unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . $token); - } else { - unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/lowertokens/" . $token); - } - } -}
\ No newline at end of file diff --git a/pages/api/docs.php b/pages/api/docs.php deleted file mode 100644 index 31cd961..0000000 --- a/pages/api/docs.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $_PROFILE; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; -if (!$isLoggedIn) header("Location: /-/login") and die(); - -$request_raw = file_get_contents('php://input'); -$json_object = json_decode($request_raw, true); - -$select = $_GET['id'] ?? null; - -if (isset($select)) { - if (ctype_alnum($select) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/docs/" . $select . ".json")) { - $id = $select; - $data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/docs/" . $select . ".json"), true); - } else { - die("Not found"); - } -} else { - die("Not set"); -} - -if (isset($json_object["content"])) $data["contents"] = $json_object["content"]; -if (isset($json_object["name"])) $data["name"] = $json_object["name"]; -if (isset($json_object["explicit"])) $data["nsfw"] = $json_object["explicit"]; -if (isset($json_object["category"])) $data["category"] = trim($json_object["category"]) !== "" && trim($json_object["category"]) !== "Unsorted" && trim($json_object["category"]) !== "unsorted" && trim($json_object["category"]) !== "/no" && trim($json_object["category"]) !== "Unsort" && trim($json_object["category"]) !== "unsort" ? $json_object["category"] : null; - -$data["last"]["date"] = time(); -$data["last"]["author"] = $_PROFILE['login']; - -file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/docs/" . $select . ".json", utf8_encode(json_encode($data)));
\ No newline at end of file diff --git a/pages/api/emergency-real.php b/pages/api/emergency-real.php deleted file mode 100644 index 04fd56e..0000000 --- a/pages/api/emergency-real.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; global $_PROFILE; - -if (!$isLoggedIn && !$isLowerLoggedIn) { - header("Location: /-/login"); - die(); -} - -global $_PROFILE; - -$ntfy = $GLOBALS["ColdHazeApp"]["ntfy"]; -$channels = []; - -if (isset($_GET["raindrops"])) $channels[] = "emergency-raindrops"; -if (isset($_GET["moonglow"])) $channels[] = "emergency-moonglow"; -if (isset($_GET["hailstorm"])) $channels[] = "emergency-hailstorm"; -if (isset($_GET[$GLOBALS["ColdHazeApp"]["other"]["slug"]])) $channels[] = "emergency"; - -$context = stream_context_create([ - 'http' => [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: " . formatPonypush("⚠️ Emergency alert") . "\r\n" . - "Priority: urgent\r\n" . - "Tags: emergency\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => formatPonypush("This is an emergency, " . $_PROFILE['name'] . " is in need of immediate help. Please act now!") - ] -]); - -foreach ($channels as $channel) { - file_get_contents('https://' . $ntfy["server"] . '/' . $channel, false, $context); -} - -die();
\ No newline at end of file diff --git a/pages/api/emergency.php b/pages/api/emergency.php deleted file mode 100644 index e682598..0000000 --- a/pages/api/emergency.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; global $_PROFILE; - -if (!$isLoggedIn && !$isLowerLoggedIn) { - header("Location: /-/login"); - die(); -} - -global $_PROFILE; - -$ntfy = $GLOBALS["ColdHazeApp"]["ntfy"]; -$channels = []; - -if (isset($_GET["raindrops"])) $channels[] = "emergency-raindrops"; -if (isset($_GET["moonglow"])) $channels[] = "emergency-moonglow"; -if (isset($_GET["hailstorm"])) $channels[] = "emergency-hailstorm"; -if (isset($_GET[$GLOBALS["ColdHazeApp"]["other"]["slug"]])) $channels[] = "emergency"; - -$context = stream_context_create([ - 'http' => [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: " . formatPonypush("[Test] ⚠️ Emergency alert") . "\r\n" . - "Priority: urgent\r\n" . - "Tags: emergency\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => formatPonypush("[This notification is test] This is an emergency, " . $_PROFILE['name'] . " is in need of immediate help. Please act now! [This notification is test]") - ] -]); - -foreach ($channels as $channel) { - file_get_contents('https://' . $ntfy["server"] . '/' . $channel, false, $context); -} - -die();
\ No newline at end of file diff --git a/pages/api/me.php b/pages/api/me.php deleted file mode 100644 index 0e91189..0000000 --- a/pages/api/me.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php - -$app = $GLOBALS["ColdHazeApp"]; - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; - -header("Content-Type: application/json"); - -if (!$isLoggedIn && !$isLowerLoggedIn) die('{"valid": false}'); -global $_PROFILE; - -if ($_PROFILE['login'] === "raindrops") { - die(json_encode([ - "valid" => true, - "name" => "Raindrops System", - "id" => "raindrops", - "pluralkit" => "gdapd", - "avatar" => getAsset("gdapd"), - "email" => $_PROFILE["profile"]["email"]["email"] - ])); -} else if ($_PROFILE["login"] === "Moonglow") { - die(json_encode([ - "valid" => true, - "name" => "Moonglow", - "id" => "moonglow", - "pluralkit" => "hrbom", - "avatar" => getAsset("hrbom"), - "email" => $_PROFILE["profile"]["email"]["email"] - ])); -} else { - die(json_encode([ - "valid" => true, - "name" => $app["other"]["name"], - "id" => $app["other"]["slug"], - "pluralkit" => $app["other"]["id"], - "avatar" => getAsset($app["other"]["id"]), - "email" => $_PROFILE["profile"]["email"]["email"] - ])); -}
\ No newline at end of file diff --git a/pages/api/pleasure-real.php b/pages/api/pleasure-real.php deleted file mode 100644 index c1cbd59..0000000 --- a/pages/api/pleasure-real.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; global $_PROFILE; - -if (!$isLoggedIn && !$isLowerLoggedIn) { - header("Location: /-/login"); - die(); -} - -global $_PROFILE; - -$frontRaindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/fronters.json"), true)["members"]; -$frontOther = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/fronters.json"), true)["members"]; -$frontMoonglow = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/hrbom/fronters.json"), true)["members"]; - -if ($_PROFILE["login"] === "raindrops" && isset($frontRaindrops[0])) { - $pony = $frontRaindrops[0]["display_name"] ?? $frontRaindrops[0]["name"]; -} else if ($_PROFILE["login"] === "Moonglow" && isset($frontMoonglow[0])) { - $pony = $frontMoonglow[0]["display_name"] ?? $frontMoonglow[0]["name"]; -} else if ($_PROFILE["login"] !== "raindrops" && $_PROFILE["login"] !== "Moonglow" && isset($frontOther[0])) { - $pony = $frontOther[0]["display_name"] ?? $frontOther[0]["name"]; -} else { - $pony = "somepony"; -} - -$ntfy = $GLOBALS["ColdHazeApp"]["ntfy"]; -$channels = []; - -if (isset($_GET["raindrops"])) $channels[] = "emergency-raindrops"; -if (isset($_GET["moonglow"])) $channels[] = "emergency-moonglow"; -if (isset($_GET[$GLOBALS["ColdHazeApp"]["other"]["slug"]])) $channels[] = "pleasure"; - -$context = stream_context_create([ - 'http' => [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: " . formatPonypush("🏩 $pony wants to play for a bit") . "\r\n" . - "Priority: high\r\n" . - "Tags: pleasure\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => formatPonypush("Hey, $pony wants to play and have fun with you, get up!") - ] -]); - -foreach ($channels as $channel) { - file_get_contents('https://' . $ntfy["server"] . '/' . $channel, false, $context); -} - -die();
\ No newline at end of file diff --git a/pages/api/pleasure.php b/pages/api/pleasure.php deleted file mode 100644 index 7b268cb..0000000 --- a/pages/api/pleasure.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; global $_PROFILE; - -if (!$isLoggedIn && !$isLowerLoggedIn) { - header("Location: /-/login"); - die(); -} - -global $_PROFILE; - -$frontRaindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/fronters.json"), true)["members"]; -$frontOther = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/fronters.json"), true)["members"]; -$frontMoonglow = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/hrbom/fronters.json"), true)["members"]; - -if ($_PROFILE["login"] === "raindrops" && isset($frontRaindrops[0])) { - $pony = $frontRaindrops[0]["display_name"] ?? $frontRaindrops[0]["name"]; -} else if ($_PROFILE["login"] === "Moonglow" && isset($frontMoonglow[0])) { - $pony = $frontMoonglow[0]["display_name"] ?? $frontMoonglow[0]["name"]; -} else if ($_PROFILE["login"] !== "raindrops" && $_PROFILE["login"] !== "Moonglow" && isset($frontOther[0])) { - $pony = $frontOther[0]["display_name"] ?? $frontOther[0]["name"]; -} else { - $pony = "somepony"; -} - -$ntfy = $GLOBALS["ColdHazeApp"]["ntfy"]; -$channels = []; - -if (isset($_GET["raindrops"])) $channels[] = "emergency-raindrops"; -if (isset($_GET["moonglow"])) $channels[] = "emergency-moonglow"; -if (isset($_GET[$GLOBALS["ColdHazeApp"]["other"]["slug"]])) $channels[] = "pleasure"; - -$context = stream_context_create([ - 'http' => [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: " . formatPonypush("[Test] 🏩 $pony wants to play for a bit") . "\r\n" . - "Priority: high\r\n" . - "Tags: pleasure\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => formatPonypush("[This notification is a test] Hey, $pony wants to play and have fun with you, get up! [This notification is a test]") - ] -]); - -foreach ($channels as $channel) { - file_get_contents('https://' . $ntfy["server"] . '/' . $channel, false, $context); -} - -die();
\ No newline at end of file diff --git a/pages/api/pluralkit-integration.php b/pages/api/pluralkit-integration.php index a3faa6f..9b0033d 100644 --- a/pages/api/pluralkit-integration.php +++ b/pages/api/pluralkit-integration.php @@ -1,7 +1,5 @@ <?php -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/agewarning.inc"; - $app = $GLOBALS["ColdHazeApp"]; $user = $_GET['user'] ?? null; $inputJSON = file_get_contents('php://input'); @@ -63,4 +61,4 @@ if ($input["type"] === "CREATE_SWITCH" || $input["type"] === "UPDATE_SWITCH" || createJob("FrontersNotification", [ "system" => $system ]); -}
\ No newline at end of file +} diff --git a/pages/api/ponytown.php b/pages/api/ponytown.php deleted file mode 100644 index bc40975..0000000 --- a/pages/api/ponytown.php +++ /dev/null @@ -1,121 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $_PROFILE; global $isLowerLoggedIn; global $app; -if (!$isLoggedIn && !$isLowerLoggedIn) header("Location: /-/login") and die(); - -$request_raw = file_get_contents('php://input'); -$json_object = json_decode($request_raw, true); - -$select = $_GET['id'] ?? null; - -if (!isset($select)) { - peh_error("System member not found", 404); - return; -} - -if (getMemberWithoutSystem($select) === null) { - peh_error("System member not found", 404); - return; -} - -$member = getMemberWithoutSystem($select); - -if ($isLowerLoggedIn && $member["_system"] !== $app["other"]["id"] && $member["_system"] !== "hrbom") { - peh_error("System member not found", 404); - return; -} - -if (!isset($json_object[0]) || !isset($json_object[1])) { - die("Missing data"); -} - -$errors = []; - -foreach ([1, 2] as $_) { - $input = $json_object[$_ - 1]; - - $mime = explode(";", substr($input, 5))[0]; - $file = base64_decode(explode(",", explode(";", substr($input, 5))[1])[1]); - - $image = @imagecreatefromstring($file); - $size = @getimagesizefromstring($file); - - if ($image === false) { - $errors[] = "0x{$_}000000F: Failed to open image #" . $_ . ", it is probably not using a supported format"; - } - - if ($size === false) { - $errors[] = "0x{$_}000000E: Failed to get metadata for image #" . $_ . ", it is probably corrupted"; - } - - if ($image === false || $size === false) continue; - - $foundColor = false; - - for ($i = 0; $i < $size[0]; $i++) { - if (imagecolorat($image, $i, 0) !== 2130706432) { - $foundColor = true; - } - } - - if (!$foundColor) { - $errors[] = "0x{$_}000001A: Image #" . $_ . " seems to contain padding (based on the first row of pixels)"; - } - - $foundColor = false; - - for ($i = 0; $i < $size[1]; $i++) { - if (imagecolorat($image, 0, $i) !== 2130706432) { - $foundColor = true; - } - } - - if (!$foundColor) { - $errors[] = "0x{$_}000001B: Image #" . $_ . " seems to contain padding (based on the first column of pixels)"; - } - - if ($_ === 1 && $size[0] > 70) { - $errors[] = "0x{$_}000002A: Image #" . $_ . " is wider than it should, are you sure you set zoom to 1x? Maybe you inverted the files?"; - } - - if ($_ === 1 && $size[1] > 70) { - $errors[] = "0x{$_}000002B: Image #" . $_ . " is higher than it should, are you sure you set zoom to 1x? Maybe you inverted the files?"; - } - - if ($_ === 2 && $size[0] > 40) { - $errors[] = "0x{$_}000002A: Image #" . $_ . " is wider than it should, are you sure you set zoom to 1x? Maybe you inverted the files?"; - } - - if ($_ === 2 && $size[1] > 35) { - $errors[] = "0x{$_}000002B: Image #" . $_ . " is higher than it should, are you sure you set zoom to 1x? Maybe you inverted the files?"; - } -} - -if (count($errors) === 0 && isset($_GET["real"])) { - foreach ([1, 2] as $_) { - $input = $json_object[$_ - 1]; - - $mime = explode(";", substr($input, 5))[0]; - $file = base64_decode(explode(",", explode(";", substr($input, 5))[1])[1]); - - $image = @imagecreatefromstring($file); - - imagealphablending($image, false); - imagesavealpha($image, true); - - if ($_ === 1) { - imagepng($image, $_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $member["id"] . ".png"); - } else { - imagepng($image, $_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $member["name"] . ".png"); - } - } -} - -createJob("UpdateAssets", [ - "type" => "ponytown" -]); - -die(json_encode([ - "success" => count($errors) === 0, - "errors" => $errors -]));
\ No newline at end of file diff --git a/pages/api/reauthenticate.php b/pages/api/reauthenticate.php deleted file mode 100644 index b194098..0000000 --- a/pages/api/reauthenticate.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; global $_PROFILE; - -header("Content-Type: text/plain"); - -if (!$isLoggedIn || $isLowerLoggedIn) { - header("Location: /-/login"); - die(); -} - -$newToken = generateToken(); - -if (isset($_COOKIE['PEH2_SESSION_TOKEN']) && $isLoggedIn) { - $old = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . $_COOKIE['PEH2_SESSION_TOKEN']), true); - - if (!isset($_GET["plain"])) { - $old["name"] = base64_decode($_GET["name"] ?? "LQo="); - } else { - $old["name"] = $_GET["name"] ?? "-"; - } - - $old["created"] = time(); - $old["addresses"] = []; - $old["last"] = time(); - $old["profile"] = $_PROFILE; - - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/sessions/" . $newToken, json_encode($old)); - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . $newToken, json_encode($_PROFILE)); -} else if (isset($_COOKIE['PEH2_SESSION_TOKEN']) && $isLowerLoggedIn) { - $old = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/sessions/" . $_COOKIE['PEH2_SESSION_TOKEN']), true); - - if (!isset($_GET["plain"])) { - $old["name"] = base64_decode($_GET["name"] ?? "LQo="); - } else { - $old["name"] = $_GET["name"] ?? "-"; - } - - $old["created"] = time(); - $old["addresses"] = []; - $old["last"] = time(); - $old["profile"] = $_PROFILE; - - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/sessions/" . $newToken, json_encode($old)); - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/lowertokens/" . $newToken, json_encode($_PROFILE)); -} - -die($newToken);
\ No newline at end of file diff --git a/pages/api/rename.php b/pages/api/rename.php deleted file mode 100644 index 4e01b06..0000000 --- a/pages/api/rename.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; - -header("Content-Type: application/json"); - -if (!$isLoggedIn || $isLowerLoggedIn) { - header("Location: /-/login"); - die(); -} - -$obj = [ - "success" => true -]; - -global $token; -$data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/sessions/" . str_replace("/", "", $token))), true); - -$data["name"] = $_POST["name"] ?? $_GET["name"] ?? $data["name"]; -$obj["pre_name"] = $data["name"]; - -$request_raw = file_get_contents('php://input'); -$json_object = json_decode($request_raw, true); - -if (json_last_error() === JSON_ERROR_NONE) { - $obj["json_error"] = [ json_last_error(), json_last_error_msg() ]; - if (isset($json_object["name"])) { - $data["name"] = $json_object["name"]; - $obj["json_name"] = $json_object["name"]; - } -} - -$obj["new_name"] = $data["name"]; - -file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/sessions/" . str_replace("/", "", $token), pf_utf8_encode(json_encode($data))); -die(json_encode($obj));
\ No newline at end of file diff --git a/pages/api/session.php b/pages/api/session.php deleted file mode 100644 index 25d833d..0000000 --- a/pages/api/session.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; - -header("Content-Type: application/json"); -global $token; - -if (isset($_GET["raw"])) { - die(json_encode(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/sessions/" . str_replace("/", "", $token)), true), JSON_PRETTY_PRINT)); -} else { - if (!$isLoggedIn || $isLowerLoggedIn) { - die(json_encode([ - "name" => null, - "created" => null, - "last_seen" => null, - "seen_at" => null - ], JSON_PRETTY_PRINT)); - } - - $data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/sessions/" . str_replace("/", "", $token)), true); - - die(json_encode([ - "name" => $data["name"], - "created" => date('c', $data["created"]), - "last_seen" => date('c', $data["last"]), - "seen_at" => array_keys($data["addresses"] ?? []) - ], JSON_PRETTY_PRINT)); -}
\ No newline at end of file diff --git a/pages/api/token.php b/pages/api/token.php deleted file mode 100644 index 5c80ca3..0000000 --- a/pages/api/token.php +++ /dev/null @@ -1,7 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; -if (!$isLoggedIn) header("Location: /-/login") and die(); - -header("Content-Type: text/plain"); -die($_COOKIE['PEH2_SESSION_TOKEN']);
\ No newline at end of file diff --git a/pages/byfront.inc b/pages/byfront.inc deleted file mode 100644 index 0974091..0000000 --- a/pages/byfront.inc +++ /dev/null @@ -1,201 +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/components/header.inc'; -global $app; global $_PROFILE; - -?> - -<br> -<div class="container"> - <div id="page-content"> - <h2>Members by last fronted</h2> - <select id="selected-system" class="form-select" style="margin-bottom: 20px;" onchange="refreshList()"> - <option value="gdapd" <?= $_PROFILE["login"] === "raindrops" ? "select" : "" ?>>Raindrops System</option> - <option value="hrbom" <?= $_PROFILE["login"] === "Moonglow" ? "select" : "" ?>>Moonglow</option> - <option value="<?= $app["other"]["id"] ?>" <?= $_PROFILE["login"] === $app["other"]["user"] ? "select" : "" ?>><?= $app["other"]["name"] ?></option> - <option value="">(all systems)</option> - </select> - - <?php $members = [ - ...array_map(function ($i) { - $system = "gdapd"; - $i["_lastFronted"] = -1; - $id = $i["id"]; - $memberData = $i; - - $fronters = array_map(function ($item) { - return $item["id"]; - }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["members"]); - - if (in_array($id, $fronters)) { - $i["_lastFronted"] = time(); - } else { - $switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json"), true); - - $thisMember = array_filter($switches, function ($item) use ($memberData) { - return in_array($memberData["id"], $item["members"]); - }); - - $thisMember = array_values($thisMember); - $frontingEnd = null; - - if (count($thisMember) > 0) { - $thisIndex = array_search($thisMember[0], $switches); - - $frontingStart = $thisMember[0]; - $frontingEnd = $switches[$thisIndex - 1]; - } - - if ($frontingEnd !== null && isset($frontingStart)) { - $i["_lastFronted"] = strtotime($frontingEnd["timestamp"]); - } - } - - return $i; - }, array_values(array_filter(scoreOrderGlobal(), function ($i) { - return $i["_system"] === "gdapd"; - }))), - ...array_map(function ($i) { - $system = "hrbom"; - $i["_lastFronted"] = -1; - $id = $i["id"]; - $memberData = $i; - - $fronters = array_map(function ($item) { - return $item["id"]; - }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["members"]); - - if (in_array($id, $fronters)) { - $i["_lastFronted"] = time(); - } else { - $switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json"), true); - - $thisMember = array_filter($switches, function ($item) use ($memberData) { - return in_array($memberData["id"], $item["members"]); - }); - - $thisMember = array_values($thisMember); - $frontingEnd = null; - - if (count($thisMember) > 0) { - $thisIndex = array_search($thisMember[0], $switches); - - $frontingStart = $thisMember[0]; - $frontingEnd = $switches[$thisIndex - 1]; - } - - if ($frontingEnd !== null && isset($frontingStart)) { - $i["_lastFronted"] = strtotime($frontingEnd["timestamp"]); - } - } - - return $i; - }, array_values(array_filter(scoreOrderGlobal(), function ($i) { - return $i["_system"] === "hrbom"; - }))), - ...array_map(function ($i) { - global $app; - $system = $app["other"]["id"]; - $i["_lastFronted"] = -1; - $id = $i["id"]; - $memberData = $i; - - $fronters = array_map(function ($item) { - return $item["id"]; - }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["members"]); - - if (in_array($id, $fronters)) { - $i["_lastFronted"] = time(); - } else { - $switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json"), true); - - $thisMember = array_filter($switches, function ($item) use ($memberData) { - return in_array($memberData["id"], $item["members"]); - }); - - $thisMember = array_values($thisMember); - $frontingEnd = null; - - if (count($thisMember) > 0) { - $thisIndex = array_search($thisMember[0], $switches); - - $frontingStart = $thisMember[0]; - $frontingEnd = $switches[$thisIndex - 1]; - } - - if ($frontingEnd !== null && isset($frontingStart)) { - $i["_lastFronted"] = strtotime($frontingEnd["timestamp"]); - } - } - - return $i; - }, array_values(array_filter(scoreOrderGlobal(), function ($i) { - global $app; - return $i["_system"] === $app["other"]["id"]; - }))) - ]; uasort($members, function ($a, $b) { - return $b["_lastFronted"] - $a["_lastFronted"]; - }); $members = array_reverse($members); foreach ($members as $member): - - $metadata = $member["_metadata"];?> - <div data-relation-system="<?= $member["_system"] ?>" class="relation" style="display: none; margin-bottom:10px;padding:10px;border-radius:10px;grid-template-columns: 1fr 2fr max-content;"> - <a class="relation-intro" style="background-color:rgba(255, 255, 255, .05);border-right:1px solid rgba(255, 255, 255, .1);margin:-10px;padding:10px;border-top-left-radius:10px;border-bottom-left-radius:10px;color: white;display:flex;align-items:center;text-decoration: none;" href="/<?= $member["name"] ?>"> - <img src="<?= getAsset($member['system'], $member["id"], "heads") ?>" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> - </a> - - <div class="relation-item" style="display:flex;align-items:center;margin-left:10px;padding:0 20px;"> - <?php if ($member["_lastFronted"] === -1): ?> - Never fronted - <?php else: ?> - Last fronted <?= timeAgo($member["_lastFronted"]) ?><?php if ($member["_lastFronted"] !== time()): ?> (<?= date('l j F Y', $member["_lastFronted"]) ?>)<?php endif; ?> - <?php endif; ?> - </div> - </div> - <?php endforeach; ?> - - <script> - function refreshList() { - let system = document.getElementById("selected-system").value; - - for (let relation of document.getElementsByClassName("relation")) { - if (relation.getAttribute("data-relation-system") === system || system === "") { - relation.style.display = "grid"; - } else { - relation.style.display = "none"; - } - } - } - - refreshList(); - </script> - - <style> - @media (max-width: 991px) { - .relation { - grid-template-columns: 1fr !important; - } - - .relation-intro { - text-align: center; - border-bottom-left-radius: 0 !important; - border-top-right-radius: 10px; - border-right: none !important; - border-bottom: 1px solid rgba(255, 255, 255, .1); - } - - .relation-item-marefriends { - margin-top: 20px !important; - } - - .relation-item { - margin-top: 10px; - margin-left: 0 !important; - padding: 10px 0 !important; - text-align: center; - } - } - </style> -</div> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> diff --git a/pages/byspecies.inc b/pages/byspecies.inc deleted file mode 100644 index 4a9ce66..0000000 --- a/pages/byspecies.inc +++ /dev/null @@ -1,97 +0,0 @@ -<?php global $system; global $systemCommonName; global $lang; global $pages; global $systemID; $pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pages.json"), true); $title = $pages["s:species"]["name"][$lang["_name"]]; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; global $travelling; global $isLowerLoggedIn; global $isLoggedIn; - -if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/species.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/species.json", "{}"); - -$cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/species.json"), true); - -function species(array $members, string $id, string $name) { global $systemID; global $travelling; ?> - <div class="relation" style="background-color:rgba(255, 255, 255, .1);margin-bottom:10px;padding:10px;border-radius:10px;display:grid;grid-template-columns: 1fr 4fr;"> - <div class="relation-intro" style="background-color:rgba(255, 255, 255, .05);border-right:1px solid rgba(255, 255, 255, .1);margin:-10px;padding:10px;border-top-left-radius:10px;border-bottom-left-radius:10px;color: white;text-decoration: none;"> - <img src="/assets/species/<?= $id ?>.png" style="width:24px;"><span class="species-name"> <?= $name ?></span> (<?= count($members) ?>) - </div> - - <div class="relation-item" style="margin-left:10px;padding:0 20px;"> - <?php if (count($members) > 0): ?> - <?php $index = 0; foreach ($members as $member): ?><a class="member-link" href="/<?= $member["name"] ?>"><img src="<?= getAsset($member["_system"], $member["id"], "heads") ?>" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?></a><?php if ($index + 2 <= count($members)) echo('<span class="list-separator-desktop">, </span><span class="list-separator-mobile"><br></span>'); $index++; endforeach; ?> - <?php else: ?>-<?php endif; ?> - </div> - </div> -<?php } - -function page() { global $lang; - $members = scoreOrderGlobal(); - - $earth = []; - $pegasus = []; - $unicorn = []; - $alicorn = []; - $batpony = []; - $crystal = []; - $changeling = []; - $merpony = []; - $human = []; - $kirin = []; - $deer = []; - - foreach ($members as $member) { - foreach ($member["_metadata"]["species"] as $species) { - if ($species === "earth") $earth[] = $member; - if ($species === "pegasus") $pegasus[] = $member; - if ($species === "unicorn") $unicorn[] = $member; - if ($species === "alicorn") $alicorn[] = $member; - if ($species === "batpony") $batpony[] = $member; - if ($species === "crystal") $crystal[] = $member; - if ($species === "changeling") $changeling[] = $member; - if ($species === "human") $human[] = $member; - if ($species === "merpony") $merpony[] = $member; - if ($species === "kirin") $kirin[] = $member; - if ($species === "deer") $deer[] = $member; - } - } - - if (count($earth) > 0) species($earth, "earth", $lang["species"]["earth"][3]); - if (count($pegasus) > 0) species($pegasus, "pegasus", $lang["species"]["pegasus"][3]); - if (count($unicorn) > 0) species($unicorn, "unicorn", $lang["species"]["unicorn"][3]); - if (count($alicorn) > 0) species($alicorn, "alicorn", $lang["species"]["alicorn"][3]); - if (count($batpony) > 0) species($batpony, "batpony", $lang["species"]["batpony"][3]); - if (count($crystal) > 0) species($crystal, "crystal", $lang["species"]["crystal"][3]); - if (count($deer) > 0 ) species($deer, "deer", "Deers"); - if (count($kirin) > 0) species($kirin, "kirin", "Kirins"); - if (count($changeling) > 0) species($changeling, "changeling", "Changelings"); - if (count($merpony) > 0) species($merpony, "merpony", "Merponies"); - if (count($human) > 0) species($human, "human", "Humans"); -} - -?> - - <br> - <div class="container" id="page-content"> - <h2>Members by species</h2> - <?php if (!isset($cache["private"]) || !isset($cache["public"])) { - ob_start(); - $isLoggedInOldState = $isLoggedIn; - $isLowerLoggedInOldState = $isLowerLoggedIn; - $isLoggedIn = true; - $isLowerLoggedIn = true; - page(); - $isLoggedIn = $isLoggedInOldState; - $isLowerLoggedIn = $isLowerLoggedInOldState; - $cache["private"] = ob_get_contents(); - ob_end_clean(); - - ob_start(); - $isLoggedInOldState = $isLoggedIn; - $isLowerLoggedInOldState = $isLowerLoggedIn; - $isLoggedIn = false; - $isLowerLoggedIn = false; - page(); - $isLoggedIn = $isLoggedInOldState; - $isLowerLoggedIn = $isLowerLoggedInOldState; - $cache["public"] = ob_get_contents(); - ob_end_clean(); - } - - echo($isLoggedIn ? $cache["private"] : $cache["public"]); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/species.json", json_encode($cache)); ?> - </div> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?>
\ No newline at end of file diff --git a/pages/emergency.inc b/pages/emergency.inc deleted file mode 100644 index d57269a..0000000 --- a/pages/emergency.inc +++ /dev/null @@ -1,15 +0,0 @@ -<?php - -$emergencyHeader = true; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; global $_PROFILE; -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; - -?> - -<br> -<div class="container"> - <div id="page-content"> - <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/components/emergency.inc"; ?> - </div> -</div> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> diff --git a/pages/front.inc b/pages/front.inc deleted file mode 100644 index ad38a14..0000000 --- a/pages/front.inc +++ /dev/null @@ -1,28 +0,0 @@ -<?php - -$parts = explode("/", $_GET["_"]); - -if (isset($parts[2])) { - if ($parts[2] === "moonglow") { - $fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/hrbom/fronters.json"), true); - } elseif ($parts[2] === "raindrops") { - $fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/fronters.json"), true); - } else { - peh_error("Invalid argument; got " . strip_tags($parts[2]), 400); - die(); - } - - if (count($fronters["members"]) > 0) { - header("Location: /" . $fronters["members"][0]["name"]); - die(); - } else { - if ($parts[2] === "moonglow") { - header("Location: /moonglow"); - } else { - header("Location: /raindrops"); - } - } -} else { - peh_error("Missing operand", 400); - die(); -}
\ No newline at end of file diff --git a/pages/lists.inc b/pages/lists.inc deleted file mode 100644 index e14f706..0000000 --- a/pages/lists.inc +++ /dev/null @@ -1,29 +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/components/header.inc'; ?> - -<br> -<div class="container"> - <div id="page-content"> - <h2>Member lists</h2> - <br> - - <div class="list-group"> - <a href="/-/splitting" class="list-group-item list-group-item-action" style="display: grid; grid-template-columns: max-content 1fr;"> - <img src="<?= icon('splitting', null, true) ?>" style="margin-right: 5px; height: 24px; width: 24px;"><div style="display: flex; align-items: center; color: var(--bs-body-color);">Members by splitting date</div> - </a> - <a href="/-/byfront" class="list-group-item list-group-item-action" style="display: grid; grid-template-columns: max-content 1fr;"> - <img src="<?= icon('front', null, true) ?>" style="margin-right: 5px; height: 24px; width: 24px;"><div style="display: flex; align-items: center; color: var(--bs-body-color);">Members by last fronted date</div> - </a> - <a href="/-/alphabet" class="list-group-item list-group-item-action" style="display: grid; grid-template-columns: max-content 1fr;"> - <img src="<?= icon('letters', null, true) ?>" style="margin-right: 5px; height: 24px; width: 24px;"><div style="display: flex; align-items: center; color: var(--bs-body-color);">Members by prefix letters</div> - </a> - <a href="/-/byspecies" class="list-group-item list-group-item-action" style="display: grid; grid-template-columns: max-content 1fr;"> - <img src="<?= icon('species', null, true) ?>" style="margin-right: 5px; height: 24px; width: 24px;"><div style="display: flex; align-items: center; color: var(--bs-body-color);">Members by species</div> - </a> - </div> - </div> -</div> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> diff --git a/pages/metadata.inc b/pages/metadata.inc deleted file mode 100644 index 53d5c05..0000000 --- a/pages/metadata.inc +++ /dev/null @@ -1,197 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLowerLoggedIn; global $isLoggedIn; global $lang; global $pages; global $app; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; - -if (!isset($_GET['_']) || trim($_GET['_']) === "") peh_error("Invalid request", 400); - -$parts = explode("/", $_GET['_']); -array_shift($parts); -array_shift($parts); -$system = $parts[0]; -$member = !isset($parts[1]) || $parts[1] === "" ? null : $parts[1]; - -if ($system !== "raindrops" && $system !== "moonglow" && $system !== $app["other"]["slug"]) peh_error("Invalid system name: " . $system, 400); -$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 ($isLowerLoggedIn && $systemID !== $app["other"]["id"] && $systemID !== "hrbom") { - header("Location: /"); - die(); -} - -if ($member === null) { - header("Location: /"); - die(); -} else { - $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "/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']; - } - } - - if ($memberData === null) { - peh_error("Not found", 404); - } - - if (isset($_GET["submit"])) { - if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $memberID . ".json")) { - $metadata = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $memberID . ".json"), true); - } else { - die(); - } - - $toUpdate = []; - - header("Content-Type: text/plain"); - - if (isset($_GET["food"]) && is_numeric($_GET["food"])) { - $toUpdate["food"] = (int)$_GET["food"]; - } - - if (isset($_GET["shared_memory"]) && is_numeric($_GET["shared_memory"])) { - $toUpdate["shared_memory"] = (int)$_GET["shared_memory"]; - } - - if (isset($_GET["species"][0])) { - if (trim($_GET["species"][0]) === "") { - $toUpdate["species"][0] = null; - } else { - $toUpdate["species"][0] = $_GET["species"][0]; - } - } - - if (isset($_GET["species"][1])) { - if (trim($_GET["species"][1]) === "") { - $toUpdate["species"][1] = null; - } else { - $toUpdate["species"][1] = $_GET["species"][1]; - } - } - - $toUpdate["alignment"] = []; - - if (isset($_GET["alignment"]["sexual"])) { - $toUpdate["alignment"]["sexual"] = $_GET["alignment"]["sexual"]; - } - - if (isset($_GET["alignment"]["romantic"])) { - $toUpdate["alignment"]["romantic"] = $_GET["alignment"]["romantic"]; - } - - if (isset($_GET["interest"])) { - $toUpdate["interest"] = strip_tags($_GET["interest"]); - } - - if (isset($_GET["gender"])) { - $toUpdate["gender"] = strip_tags($_GET["gender"]); - } - - $regex = "/^(hrbom|gdapd|" . $app["other"]["id"] . ")\/[a-z]{5}$/m"; - - if (isset($_GET["marefriends"])) { - $toUpdate["marefriends"] = array_values(array_filter(array_map(function ($i) { return trim($i); }, explode(",", $_GET["marefriends"])), function ($i) use ($regex) { - return !!preg_match($regex, $i); - })); - } - - if (isset($_GET["sexfriends"])) { - $toUpdate["sexfriends"] = array_values(array_filter(array_map(function ($i) { return trim($i); }, explode(",", $_GET["sexfriends"])), function ($i) use ($regex) { - return !!preg_match($regex, $i); - })); - } - - if (isset($_GET["sisters"])) { - $toUpdate["sisters"] = array_values(array_filter(array_map(function ($i) { return trim($i); }, explode(",", $_GET["sisters"])), function ($i) use ($regex) { - return !!preg_match($regex, $i); - })); - } - - if (isset($_GET["caretakers"])) { - $toUpdate["caretakers"] = array_values(array_filter(array_map(function ($i) { return trim($i); }, explode(",", $_GET["caretakers"])), function ($i) use ($regex) { - return !!preg_match($regex, $i); - })); - } - - if (isset($_GET["friends"])) { - $toUpdate["friends"] = array_values(array_filter(array_map(function ($i) { return trim($i); }, explode(",", $_GET["friends"])), function ($i) use ($regex) { - return !!preg_match($regex, $i); - })); - } - - if (isset($_GET['regressed'])) { - if (!!preg_match("/^[a-z]{5}$/m", $_GET['regressed'])) { - $toUpdate["regression"] = $_GET['regressed']; - } else { - $toUpdate["regression"] = null; - } - } - - $toUpdate["birth"] = [ - "date" => "01-01", - "year" => null, - "age" => 0 - ]; - - if (isset($_GET["age"]) && is_numeric($_GET["age"])) { - $toUpdate["birth"]["age"] = (int)$_GET["age"]; - } else if (isset($_GET["age"]) && preg_match("/^\d{1,2}-\d{1,2}$/", $_GET["age"]) === 1) { - $toUpdate["birth"]["age"] = $_GET["age"]; - } - - if (isset($_GET["birth"]) && trim($_GET['birth']) !== "" && !!preg_match("/^\d{4}-\d{2}-\d{2}$/m", $_GET['birth'])) { - $toUpdate["birth"]["year"] = (int)substr($_GET["birth"],0, 4); - $toUpdate["birth"]["date"] = substr($_GET["birth"],5); - } - - if (isset($_GET["membc"])) { - $toUpdate["code"] = $_GET['membc']; - } - - $flags = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/flags.json"), true); - - foreach ($flags as $id => $name) if (!is_array($name)) { - if (isset($_GET['flags'][$id])) { - $toUpdate[$id] = true; - } else { - $toUpdate[$id] = false; - } - } else foreach ($name as $id2 => $_) { - if (isset($_GET['flags'][$id][$id2])) { - $toUpdate[$id][$id2] = true; - } else { - $toUpdate[$id][$id2] = false; - } - } - - foreach ($toUpdate as $item => $value) { - $metadata[$item] = $value; - } - - if (isset($metadata["bitset"])) unset($metadata["bitset"]); - if (isset($metadata["code"])) unset($metadata["code"]); - if (trim($metadata["species"][1]) === "") unset($metadata["species"][1]); - - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $memberID . ".json", json_encode($metadata)); - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/navigation.json", "{}"); - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/home.json", "{}"); - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/species.json", "{}"); - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/relations.json", "{}"); - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}"); - - createJob("RefreshCache", []); - - header("Location: /" . $_GET['_']); - } else { - require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/fragments/metadata.inc'; - } -} - -exit;
\ No newline at end of file diff --git a/pages/page.inc b/pages/page.inc index fa82a10..4de846b 100644 --- a/pages/page.inc +++ b/pages/page.inc @@ -4,7 +4,7 @@ global $lang; global $pages; global $isLoggedIn; global $isLowerLoggedIn; $app = $GLOBALS["ColdHazeApp"]; -$travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json"), true); +$travelling = []; if (!isset($_GET['_']) || trim($_GET['_']) === "") peh_error("Invalid request", 400); $parts = explode("/", $_GET['_']); @@ -16,7 +16,7 @@ if (($parts[0] !== "raindrops" && $parts[0] !== "moonglow" && $parts[0] !== $app $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 file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $i["id"] . ".json"); + return true; })); $namesOther = []; @@ -110,4 +110,4 @@ if ($member === null) { require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/fragments/member.inc'; } -exit;
\ No newline at end of file +exit; diff --git a/pages/pair.inc b/pages/pair.inc deleted file mode 100644 index 3adc14f..0000000 --- a/pages/pair.inc +++ /dev/null @@ -1,216 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $isLowerLoggedIn; global $lang; global $pages; -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; global $_PROFILE; - -?> - -<br> -<div class="container"> - <h1>Pair a new device</h1> - - <div class="alert alert-success alert-dismissible" id="pair-confirm" style="display: none;"> - <button type="button" class="btn-close" onclick="document.getElementById('pair-confirm').style.display='none';"></button> - Successfully paired "<span id="paired-name-1">-</span>" with your Ponycule account. You may now close this page. - </div> - - <div class="alert alert-danger alert-dismissible" id="pair-cancel" style="display: none;"> - <button type="button" class="btn-close" onclick="document.getElementById('pair-cancel').style.display='none';"></button> - Cancelled pairing "<span id="paired-name-2">-</span>", this device does not have access to your account. You may now close this page. - </div> - - <p>Pairing allows a connected device that cannot normally use Ponycule to gather data. This device will get full access to your account as if they were acting on your behalf, so make sure you trust the device and/or application you are using.</p> - - <?php $data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . str_replace("/", "", $_COOKIE['PEH2_SESSION_TOKEN'])), true); if (isset($data["profile"])): ?> - <p>Equestria.dev may not have verified the application you use, always check for a signature. Enter the pairing code displayed on your device below:</p> - - <input autofocus type="text" placeholder="Pairing code" class="form-control" style="margin-bottom:15px;color:white;background:#111;border-color:#222;" id="code"> - <?php else: ?> - <div class="alert alert-danger"> - <b>Error:</b> You cannot use the pairing feature because your current session is using the old authentication system. Please log out and log in again to continue. - </div> - <?php endif; ?> -</div> - -<div class="modal fade" id="confirm"> - <div class="modal-dialog"> - <div class="modal-content"> - - <div class="modal-header"> - <h4 class="modal-title">Confirm pairing request</h4> - <button type="button" class="btn-close" onclick="reject();"></button> - </div> - - <div class="modal-body"> - <p>You are about to pair the following device with your Ponycule account:</p> - <blockquote style="display: grid; grid-template-columns: max-content 1fr; grid-gap: 10px;"> - <div style="display: flex; align-items: center; justify-content: center;"> - <img src="/assets/logo/newlogo-ng.png" id="device-icon" style="width: 32px; height: 32px;"> - </div> - <div> - <b>Name:</b> <span id="device-name">-</span><br> - <b>Address:</b> <span id="device-address">-</span> - </div> - </blockquote> - <p class="text-danger">Only enter pairing codes coming from your physical device, not a screenshot or a photo. Never use a code sent to you by another user, even if you trust them.</p> - <span class="btn btn-success disabled" id="modal-button" style="margin-right: 5px;" onclick="confirm();">Confirm</span><span class="btn btn-outline-secondary" onclick="reject();">Cancel</span> - </div> - </div> - </div> -</div> - -<style> - <?php global $use2023UI; if (!$use2023UI): ?> - .modal-header { - border-bottom: 1px solid #353738; - } - - .modal-content { - border: 1px solid rgba(255, 255, 255, .2); - background-color: #111; - } - - .btn-close { - filter: invert(1); - } - - .alert-dismissible .btn-close { - filter: none !important; - } - <?php endif ?> - - blockquote { - margin-left: 5px; - padding-left: 10px; - border-left: 3px solid var(--palette-5, rgba(255, 255, 255, .25)); - } -</style> - -<script src="/assets/editor/ua-parser.js"></script> -<script> - const modal = new bootstrap.Modal(document.getElementById("confirm")); - - function getIconForName(name) { - if (name.startsWith("Luna Desktop ") || name.startsWith("Luna Mobile ")) { - return "https://git.equestria.dev/equestria.dev/luna/raw/branch/mane/icons/logo.png"; - } - - if (name.startsWith("Cold Haze for Wear OS ") || name.startsWith("Ponycule for Wear OS ")) { - return "https://cdn.equestria.dev/ch-wear.png"; - } - - return "/assets/logo/newlogo-ng.png"; - } - - (async () => { - const token = await (await fetch("/api/token")).text(); - let ws = window.ws = new WebSocket("wss://ponycule.p.equestria.dev/_PairingServices-WebSocket-EntryPoint/socket"); - - ws.onopen = (event) => { - console.log(event); - - if (location.hash && location.hash.startsWith("#/")) { - document.getElementById("code").value = location.hash.substring(2); - document.getElementById("code").onkeydown(); - location.hash = ""; - } - } - - ws.onclose = (event) => { - console.log(event); - } - - ws.onmessage = (event) => { - let data = JSON.parse(event.data); - console.log(event, data); - - if (data.type === "init") { - ws.send(JSON.stringify({ - type: "init", - token - })); - } else if (data.type === "invalid") { - document.getElementById("code").value = ""; - document.getElementById("code").disabled = false; - modal.hide(); - document.getElementById("code").focus(); - } else if (data.type === "device") { - document.getElementById("device-name").innerText = document.getElementById("paired-name-1").innerText = document.getElementById("paired-name-2").innerText = window.currentName = data.identity.name; - document.getElementById("device-address").innerText = data.identity.address; - document.getElementById("device-icon").src = getIconForName(data.identity.name ?? ""); - document.getElementById("modal-button").classList.add("disabled"); - modal.show(); - - setTimeout(() => { - document.getElementById("modal-button").classList.remove("disabled"); - }, 3000); - } - } - })(); - - document.getElementById("code").onkeyup = document.getElementById("code").onkeydown = () => { - if (document.getElementById("code").value.length > 0) { - document.getElementById("pair-confirm").style.display = "none"; - document.getElementById("pair-cancel").style.display = "none"; - } - - if (document.getElementById("code").value.length === 5) { - document.getElementById("code").disabled = true; - pair(document.getElementById("code").value); - } - } - - window.currentCode = null; - window.currentName = ""; - - function pair(code) { - const ua = new UAParser(navigator.userAgent).getResult(); - const username = `<?= $_PROFILE["name"] ?>`; - - window.currentCode = code; - - ws.send(JSON.stringify({ - type: "fetch", - identity: { - name: username, - platform: ua.browser.name + " " + ua.browser.major + " on " + ua.os.name - }, - code - })); - } - - async function confirm() { - document.getElementById("pair-confirm").style.display = ""; - - document.getElementById("code").value = ""; - document.getElementById("code").disabled = false; - modal.hide(); - document.getElementById("code").focus(); - - ws.send(JSON.stringify({ - type: "confirm", - code: window.currentCode, - token: (await (await fetch("/api/reauthenticate/?name=" + encodeURIComponent(btoa(window.currentName)))).text()).trim() - })); - } - - async function reject() { - document.getElementById("pair-cancel").style.display = ""; - - document.getElementById("code").value = ""; - document.getElementById("code").disabled = false; - modal.hide(); - document.getElementById("code").focus(); - - ws.send(JSON.stringify({ - type: "reject", - code: window.currentCode - })); - } - - window.onload = () => { - document.getElementById("code").focus(); - } -</script> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> diff --git a/pages/pleasure.inc b/pages/pleasure.inc deleted file mode 100644 index 5435bd1..0000000 --- a/pages/pleasure.inc +++ /dev/null @@ -1,16 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $_PROFILE; global $pages; - -$emergencyHeader = true; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; - -?> - -<br> -<div class="container"> - <div id="page-content"> - <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/components/pleasure.inc"; ?> - </div> -</div> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> diff --git a/pages/ponytown.inc b/pages/ponytown.inc deleted file mode 100644 index b268aa3..0000000 --- a/pages/ponytown.inc +++ /dev/null @@ -1,258 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; global $isLowerLoggedIn; global $app; - -$parts = explode("/", $_GET["_"]); - -if (!isset($parts[2])) { - peh_error("System member not found", 404); - return; -} - -if (getMemberWithoutSystem($parts[2]) === null) { - peh_error("System member not found", 404); - return; -} - -$member = getMemberWithoutSystem($parts[2]); - -if ($isLowerLoggedIn && $member["_system"] !== $app["other"]["id"] && $member["_system"] !== "hrbom") { - peh_error("System member not found", 404); - return; -} - -$title = ($member["display_name"] ?? $member["name"]) . " · " . $title; - -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; - -$member = getMemberWithoutSystem($parts[2]); - -?> - -<br> -<div class="container"> - <div id="page-content"> - <h2>Pony Town uploader for <?= $member["display_name"] ?? $member["name"] ?></h2> - - <?php if (isset($_GET["updated"])): ?> - <div class="alert alert-success">Successfully uploaded a new Pony Town character for this member, it may take a few minutes to update across the website.</div> - <?php endif; ?> - - <div style="display: grid; grid-template-columns: repeat(2, 1fr); grid-gap: 20px; margin-top: 15px;"> - <div class="card"> - <div class="card-body"> - <h3>Current version</h3> - - <div style="display: grid; grid-template-columns: repeat(2, 1fr); grid-gap: 10px;"> - <div style="display: flex; align-items: center; justify-content: center;"> - <img src="data:image/png;base64,<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $member["id"] . ".png") ? base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $member["id"] . ".png")) : "" ?>" style="width: 100%; border: 1px dashed rgba(255, 255, 255, .5); border-radius: 10px;"> - </div> - <div style="display: flex; align-items: center; justify-content: center;"> - <img src="data:image/png;base64,<?= file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $member["name"] . ".png") ? base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $member["name"] . ".png")) : (file_exists($_SERVER['DOCUMENT_ROOT'] . getAsset($member["_system"], $member["id"], "heads")) ? base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . getAsset($member["_system"], $member["id"], "heads"))) : "") ?>" style="width: 100%; border: 1px dashed rgba(255, 255, 255, .5); border-radius: 10px;"> - </div> - </div> - - <?php - - if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $member["id"] . ".png")) { - $info = getimagesize($_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $member["id"] . ".png"); - } else { - $info = [null, 61]; - } - - if ($info[1] > 60): ?> - <p class="text-warning" style="margin-top: 15px; margin-bottom: 0; text-align: center;"><b>This Pony Town character needs to be updated.</b><br>Ponycule now relies on pixel-perfect versions of one's Pony Town character to work properly, and the current character for this member is not compliant or non-existant.</p> - <?php endif; ?> - </div> - </div> - - <div class="card"> - <div class="card-body"> - <h3>Upload a new version</h3> - - <div id="uploader"> - <ol> - <li>Open Pony Town [<a href="https://pony.town/" target="_blank">main</a>, <a href="https://event.pony.town/" target="_blank">event</a>, <a href="https://eventblue.pony.town/" target="_blank">eventblue</a>, <a href="https://eventgreen.pony.town/" target="_blank">eventgreen</a>, <a href="https://breezy.pony.town/" target="_blank">breezy</a>, <a href="https://building.pony.town/" target="_blank">building</a>], login if needed, and select the right pony</li> - <li>Click on <img class="antialias" alt="edit" src="/assets/editor/ponytown/step1.png" style="height: 2rem;"></li> - <li>Focus on <img class="antialias" alt="Export" src="/assets/editor/ponytown/step2.png" style="height: 2rem;"> and click on <img class="antialias" alt="Image export zoom" src="/assets/editor/ponytown/step2b.png" style="height: 2rem;"></li> - <li>In the menu, select <img class="antialias" alt="1x" src="/assets/editor/ponytown/step3.png" style="height: 2rem;"></li> - <li>Click on <img class="antialias" alt="Image export settings" src="/assets/editor/ponytown/step4.png" style="height: 2rem;"> and uncheck everything, like this:<br><img class="antialias" alt="[all settings unchecked]" src="/assets/editor/ponytown/step4b.png" style="width: 25%;"></li> - <li>Click on <img class="antialias" alt="PNG" src="/assets/editor/ponytown/step5.png" style="height: 2rem;"> and download the file to your device</li> - <li>Upload this file here (yes this is a button):<br><input type="file" id="file-uploader"></li> - <li>Go back to Pony Town, click on <img class="antialias" alt="Image export settings" src="/assets/editor/ponytown/step4.png" style="height: 2rem;"> again</li> - <li>Check "Head only", and nothing else, like this:<br><img class="antialias" alt="[Head only checked]" src="/assets/editor/ponytown/step9.png" style="width: 25%;"></li> - <li>Click on <img class="antialias" alt="PNG" src="/assets/editor/ponytown/step5.png" style="height: 2rem;"> once again and download the file to your device</li> - <li>Upload this file (the second one) here (yes this is also a button):<br><input type="file" id="file-uploader2"></li> - <li>We will check if you used the correct settings and save it if everything is good.</li> - </ol> - </div> - - <div id="checker" style="display: none;"> - <img src="/assets/editor/load.svg" style="width: 36px;"><span style="vertical-align: middle;" id="checker-message">Reading files...</span> - </div> - - <div id="error" style="display: none;"> - <p>Hmm, I don't think this is working! Check the errors below and try again:</p> - <ul id="errors"></ul> - <span class="btn btn-primary" onclick="upload();">Back</span> - </div> - - <div id="confirm" style="display: none;"> - <div style="display: grid; grid-template-columns: repeat(2, 1fr); grid-gap: 10px;"> - <div style="display: flex; align-items: center; justify-content: center;"> - <img id="confirm-preview-1" style="width: 100%; border: 1px dashed rgba(255, 255, 255, .5); border-radius: 10px;"> - </div> - <div style="display: flex; align-items: center; justify-content: center;"> - <img id="confirm-preview-2" style="width: 100%; border: 1px dashed rgba(255, 255, 255, .5); border-radius: 10px;"> - </div> - </div> - - <div style="margin-top: 10px;"> - <span class="btn btn-primary" onclick="uploadActual();">Upload</span> - <span class="btn btn-outline-primary" onclick='document.getElementById("file-uploader").value = "";document.getElementById("file-uploader2").value = "";upload();'>Cancel</span> - </div> - </div> - </div> - </div> - - <script> - function errors(list) { - document.getElementById("file-uploader").value = ""; - document.getElementById("file-uploader2").value = ""; - - document.getElementById("uploader").style.display = "none"; - document.getElementById("error").style.display = ""; - document.getElementById("checker").style.display = "none"; - document.getElementById("confirm").style.display = "none"; - - document.getElementById("errors").innerHTML = `<li>${list.map(i => i.replaceAll("<", "<").replaceAll(">", ">")).join("</li><li>")}</li>`; - } - - let files = [ - null, - null - ]; - - function uploadCandidate() { - if (files[0] && files[1]) { - document.getElementById("checker-message").innerText = "Uploading files for review..."; - - let data = JSON.stringify(files); - - if (data.length > 1024 ** 2) { - errors(["0xFF000001: The data being sent to the server is too large, your images are huge!"]); - return; - } - - window.fetch("/api/ponytown/?id=<?= $member["id"] ?>", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: data - }).then((res) => { - res.json().then((data) => { - document.getElementById("checker-message").innerText = "Processing response..."; - console.log(data); - - if (data.success) { - document.getElementById("confirm-preview-1").src = files[0]; - document.getElementById("confirm-preview-2").src = files[1]; - - document.getElementById("uploader").style.display = "none"; - document.getElementById("checker").style.display = "none"; - document.getElementById("confirm").style.display = ""; - document.getElementById("error").style.display = "none"; - } else { - errors(data.errors); - } - }) - }) - } - } - - function uploadActual() { - if (files[0] && files[1]) { - document.getElementById("checker-message").innerText = "Uploading final files..."; - - let data = JSON.stringify(files); - - if (data.length > 1024 ** 2) { - errors(["0xFF000001: The data being sent to the server is too large, your images are huge!"]); - return; - } - - window.fetch("/api/ponytown/?id=<?= $member["id"] ?>&real", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: data - }).then((res) => { - res.json().then((data) => { - document.getElementById("checker-message").innerText = "Processing response..."; - console.log(data); - - if (data.success) { - document.getElementById("checker-message").innerText = "Reloading..."; - location.href = "/-/ponytown/<?= $member["id"] ?>/?updated"; - } else { - errors(data.errors); - } - }) - }) - } - } - - document.getElementById("file-uploader").onchange = document.getElementById("file-uploader2").onchange = upload = () => { - files = [ - null, - null - ]; - - if (document.getElementById("file-uploader").files.length >= 1 && document.getElementById("file-uploader2").files.length >= 1) { - document.getElementById("errors").innerHTML = ""; - - document.getElementById("uploader").style.display = "none"; - document.getElementById("checker").style.display = ""; - document.getElementById("confirm").style.display = "none"; - document.getElementById("error").style.display = "none"; - - let file1 = document.getElementById("file-uploader").files[0]; - let file2 = document.getElementById("file-uploader2").files[0]; - - let reader1 = new FileReader(); - let reader2 = new FileReader(); - - reader1.readAsDataURL(file1); - reader2.readAsDataURL(file2); - - reader1.onerror = () => { - errors(["Unable to read file #1, an internal error occurred"]); - } - reader2.onerror = () => { - errors(["Unable to read file #2, an internal error occurred"]); - } - - reader1.onload = () => { - files[0] = reader1.result; - uploadCandidate(); - } - - reader2.onload = () => { - files[1] = reader2.result; - uploadCandidate(); - } - } else { - document.getElementById("uploader").style.display = ""; - document.getElementById("checker").style.display = "none"; - document.getElementById("confirm").style.display = "none"; - document.getElementById("error").style.display = "none"; - } - } - </script> - </div> - </div> -</div> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?>
\ No newline at end of file diff --git a/pages/public.inc b/pages/public.inc index f87256b..f714f89 100644 --- a/pages/public.inc +++ b/pages/public.inc @@ -20,7 +20,7 @@ function banner() { $isLoggedIn = false; $isLowerLoggedIn = false; $byColor = ge <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;"><img title="<?= $member["display_name"] ?? $member["name"] ?>" data-bs-toggle="tooltip" src="<?= getAsset($member["_system"], $member["id"], "heads") ?>" style="height:32px;position:absolute;z-index:99;"></a><?php endforeach; ?> + <?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> @@ -200,4 +200,4 @@ function members() { $isLoggedIn = false; $isLowerLoggedIn = false; global $app; <?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'; ?>
\ No newline at end of file +<?php file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/home.json", json_encode($cache)); require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> diff --git a/pages/relations.inc b/pages/relations.inc deleted file mode 100644 index 5d3f7ef..0000000 --- a/pages/relations.inc +++ /dev/null @@ -1,135 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; global $isLowerLoggedIn; global $app; -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; - -if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/relations.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/relations.json", "{}"); - -$cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/relations.json"), true); - -function page() { global $isLoggedIn; global $isLowerLoggedIn; global $pages; global $lang; global $app; ?> - <div id="page-content"> - <h2><?= $pages["relations"]["name"][$lang["_name"]] ?></h2> - <?php foreach (withCaretakersDown(scoreOrderGlobal()) as $member): ?> - <div class="relation" style="background-color:rgba(255, 255, 255, .1);margin-bottom:10px;padding:10px;border-radius:10px;display:grid;grid-template-columns: 2fr 2.25fr 2.25fr 2.25fr;"> - <a class="relation-intro" style="background-color:rgba(255, 255, 255, .05);border-right:1px solid rgba(255, 255, 255, .1);margin:-10px;padding:10px;border-top-left-radius:10px;border-bottom-left-radius:10px;color: white;text-decoration: none;" href="/<?= $member["name"] ?>"> - <img src="<?= getAsset($member["system"], $member["id"], "heads") ?>" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> - </a> - - <table class="relation-item relation-item-marefriends" style="margin-left:10px;padding:0 20px;"> - <tbody><tr> - <td style="width: 50%;text-align:right;"> - <b style="padding-right:5px;"><?= $lang["relations"]["marefriends"] ?></b><span class="list-separator-mobile"><br></span> - </td> - <td style="width: 50%;text-align:left;"> - <?php if (count($member["_metadata"]["marefriends"]) === 0): ?> - <span class="text-muted"><?= $lang["relations"]["no"] ?></span> - <?php else: ?> - <?php foreach ($member["_metadata"]["marefriends"] as $id): $mfSystem = explode("/", $id)[0]; $marefriend = getSystemMember(explode("/", $id)[0], explode("/", $id)[1]); if (!($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn)): ?> - <a title="<?= getMiniName($marefriend["display_name"] ?? $marefriend["name"]) ?>" data-bs-toggle="tooltip" class="member-link tooltip-nohelp" href="/<?= $marefriend["name"] ?>"><img src="<?= getAsset($mfSystem, $marefriend["id"], "heads") ?>" style="width:24px;"></a> - <?php endif; endforeach; ?> - <?php endif; ?> - </td> - </tr></tbody> - </table> - - <table class="relation-item relation-item-sisters" style="padding:0 20px;"> - <tbody><tr> - <td style="width: 50%;text-align:right;"> - <b style="padding-right:5px;"><?= $lang["relations"]["sisters"] ?></b><span class="list-separator-mobile"><br></span> - </td> - <td style="width: 50%;text-align:left;"> - <?php if (count($member["_metadata"]["sisters"]) === 0): ?> - <span class="text-muted"><?= $lang["relations"]["no"] ?></span> - <?php else: ?> - <?php foreach ($member["_metadata"]["sisters"] as $id): $mfSystem = explode("/", $id)[0]; $marefriend = getSystemMember(explode("/", $id)[0], explode("/", $id)[1]); if (!($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn)): ?> - <a title="<?= getMiniName($marefriend["display_name"] ?? $marefriend["name"]) ?>" data-bs-toggle="tooltip" class="member-link tooltip-nohelp" href="/<?= $marefriend["name"] ?>"><img src="<?= getAsset($mfSystem, $marefriend["id"], "heads") ?>" style="width:24px;"></a> - <?php endif; endforeach; ?> - <?php endif; ?> - </td> - </tr></tbody> - </table> - - <table class="relation-item relation-item-caretakers" style="padding:0 20px;"> - <tbody><tr> - <td style="width: 50%;text-align:right;"> - <b style="padding-right:5px;"><?= $lang["relations"]["caretakers"] ?></b><span class="list-separator-mobile"><br></span> - </td> - <td style="width: 50%;text-align:left;"> - <?php if (count($member["_metadata"]["caretakers"]) === 0): ?> - <span class="text-muted"><?= $lang["relations"]["no"] ?></span> - <?php else: ?> - <?php foreach ($member["_metadata"]["caretakers"] as $id): $mfSystem = explode("/", $id)[0]; $marefriend = getSystemMember(explode("/", $id)[0], explode("/", $id)[1]); if (!($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn)): ?> - <a title="<?= $marefriend["display_name"] ?? $marefriend["name"] ?>" data-bs-toggle="tooltip" class="member-link tooltip-nohelp" href="/<?= $marefriend["name"] ?>"><img src="<?= getAsset($mfSystem, $marefriend["id"], "heads") ?>" style="width:24px;"></a> - <?php endif; endforeach; ?> - <?php endif; ?> - </td> - </tr></tbody> - </table> - </div> - <?php endforeach; ?> - </div> - - <style> - @media (max-width: 991px) { - .relation { - grid-template-columns: 1fr !important; - } - - .relation-intro { - text-align: center; - border-bottom-left-radius: 0 !important; - border-top-right-radius: 10px; - border-right: none !important; - border-bottom: 1px solid rgba(255, 255, 255, .1); - } - - .relation-item-marefriends { - margin-top: 20px !important; - } - - .relation-item { - margin-top: 10px; - margin-left: 0 !important; - padding: 10px 0 !important; - } - } - - .relation-item { - text-align: center; - } - </style> -<?php } - -?> - -<br> -<div class="container"> - <?php if (!isset($cache["private"]) || !isset($cache["public"])) { - ob_start(); - $isLoggedInOldState = $isLoggedIn; - $isLowerLoggedInOldState = $isLowerLoggedIn; - $isLoggedIn = true; - $isLowerLoggedIn = true; - page(); - $isLoggedIn = $isLoggedInOldState; - $isLowerLoggedIn = $isLowerLoggedInOldState; - $cache["private"] = ob_get_contents(); - ob_end_clean(); - - ob_start(); - $isLoggedInOldState = $isLoggedIn; - $isLowerLoggedInOldState = $isLowerLoggedIn; - $isLoggedIn = false; - $isLowerLoggedIn = false; - page(); - $isLoggedIn = $isLoggedInOldState; - $isLowerLoggedIn = $isLowerLoggedInOldState; - $cache["public"] = ob_get_contents(); - ob_end_clean(); - } - - echo($isLoggedIn ? $cache["private"] : $cache["public"]); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/relations.json", json_encode($cache)); ?> -</div> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> diff --git a/pages/schedule.inc b/pages/schedule.inc deleted file mode 100644 index 3c6bc2a..0000000 --- a/pages/schedule.inc +++ /dev/null @@ -1,235 +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/components/header.inc'; -global $app; global $_PROFILE; - -$pairs = []; - -$pairs2 = [ - ["lqolg"], - ["tfbob"], - ["zajrk"], - ["ktrdb"], - ["hpwyq"], - ["qbzxm"], - ["qraku"], - ["mhnqy"], - ["ztfjz"], - ["ufadt"], - ["ckqsw"] -]; - -// -------------------- - -function getRelativeDay($offset) { - if ($offset === 0) return "Today"; - if ($offset === 1) return "Tomorrow"; - return "On " . date('l', time() + ($offset * 86400)) . " (in $offset days, " . date('j M', time() + ($offset * 86400)) . ")"; -} - -$ignored = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/schedule/ignored.json"), true); -$locked = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/schedule/locked.json"), true); - -$members = array_map(function ($i) { - $system = "gdapd"; - $i["_lastFronted"] = -1; - $id = $i["id"]; - $memberData = $i; - - $fronters = array_map(function ($item) { - return $item["id"]; - }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["members"]); - - if (in_array($id, $fronters)) { - $i["_lastFronted"] = time(); - } else { - $switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json"), true); - - $thisMember = array_filter($switches, function ($item) use ($memberData) { - return in_array($memberData["id"], $item["members"]); - }); - - $thisMember = array_values($thisMember); - $frontingEnd = null; - - if (count($thisMember) > 0) { - $thisIndex = array_search($thisMember[0], $switches); - - $frontingStart = $thisMember[0]; - $frontingEnd = $switches[$thisIndex - 1]; - } - - if ($frontingEnd !== null && isset($frontingStart)) { - $i["_lastFronted"] = strtotime($frontingEnd["timestamp"]); - } - } - - return $i; -}, array_values(array_filter(scoreOrderGlobal(), function ($i) { - return $i["_system"] === "gdapd"; -}))); - -if (isset($_GET["ignore"]) && isset($_GET["day"])) { - if ($_GET["ignore"] === "1") { - if (preg_match("/^\d{4}-\d{2}-\d{2}$/m", $_GET["day"]) === false) { - header("Location: /-/schedule"); - die(); - } - - if (!in_array($_GET["day"], $ignored)) { - $ignored[] = $_GET["day"]; - } - - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/schedule/ignored.json", json_encode($ignored)); - header("Location: /-/schedule"); - die(); - } elseif ($_GET["ignore"] === "0") { - if (preg_match("/^\d{4}-\d{2}-\d{2}$/m", $_GET["day"]) === false) { - header("Location: /-/schedule"); - die(); - } - - if (in_array($_GET["day"], $ignored)) { - unset($ignored[array_search($_GET["day"], $ignored)]); - } - - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/schedule/ignored.json", json_encode($ignored)); - header("Location: /-/schedule"); - die(); - } - - die(); -} - - -?> - -<style> - #main a { - color: inherit; - text-decoration: inherit; - } - - #main a:hover { - opacity: .75; - } - - #main a:active, #main a:focus { - opacity: .75; - } -</style> - -<br> -<div class="container" id="main"> - <details> - <summary style="list-style: none; outline: none; cursor: text;"> - <h2>Raindrops System schedule</h2> - </summary> - <ul> - <?php $requested = []; foreach ([...$pairs, ...$pairs2] as $pair) { - array_push($requested, ...$pair); - } $requested = array_unique($requested); foreach ($requested as $id) { - if (getMemberWithoutSystem($id) !== null) { - echo("<li>" . (getMemberWithoutSystem($id)["display_name"] ?? getMemberWithoutSystem($id)["name"]) . "</li>"); - } else { - echo("<li>NULL (" . $id . ")</li>"); - } - } ?> - </ul> - <ul> - <?php usort($pairs, function ($a, $b) use ($members) { - $times = []; - - foreach ($a as $id) { - if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id); - } - - $timeA = time() - min($times); - $times = []; - - foreach ($b as $id) { - if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id); - } - - $timeB = time() - min($times); - - if ($timeA < 5 || $timeB < 5) { - return -INF; - } else { - return $timeB - $timeA; - } - }); $pairsM = array_values($pairs); foreach ($pairsM as $pair): $times = []; ?> - <li> - <?php foreach ($pair as $id): ?> - <img style="width: 24px;" src="<?= getAsset("gdapd", $id) ?>"> <?= getMemberWithoutSystem($id)["display_name"] ?> - <?php $times[] = getLastFronted($members, $id); endforeach; ?> - (<?= time() - max($times) ?>) - </li> - <?php endforeach; ?> - </ul> - <ul> - <?php usort($pairs2, function ($a, $b) use ($members) { - $times = []; - - foreach ($a as $id) { - if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id); - } - - $timeA = time() - min($times); - $times = []; - - foreach ($b as $id) { - if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id); - } - - $timeB = time() - min($times); - - if ($timeA < 5 || $timeB < 5) { - return -INF; - } else { - return $timeB - $timeA; - } - }); $pairsM = array_values($pairs2); foreach ($pairsM as $pair): $times = []; ?> - <li> - <?php foreach ($pair as $id): ?> - <img style="width: 24px;" src="<?= getAsset("gdapd", $id) ?>"> <?= getMemberWithoutSystem($id)["display_name"] ?> - <?php $times[] = getLastFronted($members, $id); endforeach; ?> - (<?= time() - max($times) ?>) - </li> - <?php endforeach; ?> - </ul> - </details> - - <div style="display: grid; grid-template-columns: max-content 1fr; grid-column-gap: 10px;"> - <?php - - $pairs = array_values($pairs); - $pairs2 = array_values($pairs2); - - $i = 0; - $i1 = 0; - $i2 = 0; - $max = 62; - - while ($i < $max): ?> - <div style="text-align: right;"> - <b><?= getRelativeDay($i) ?>:</b> - </div> - <div> - <?php $j = 0; foreach ($pairs2[$i2] as $id): ?> - <a href="/<?= getMemberWithoutSystem($id)["name"] ?>"><img style="width: 24px;" src="<?= getAsset("gdapd", $id, "heads") ?>"> <?= getMemberWithoutSystem($id)["display_name"] ?></a> - <?php if (isset($pairs2[$i2][$j + 1])): ?>and<?php endif; ?> - <?php $j++; endforeach; $i2++; ?> - </div> - - <?php $i++; - - if (!isset($pairs2[$i2])) $i2 = 0; - if (!isset($pairs[$i1])) $i1 = 0; - - endwhile; ?> - </div> -</div> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> diff --git a/pages/sessions.inc b/pages/sessions.inc deleted file mode 100644 index 444e981..0000000 --- a/pages/sessions.inc +++ /dev/null @@ -1,226 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $isLowerLoggedIn; global $lang; global $pages; -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; global $_PROFILE; global $app; - -$verified = [ - dns_get_record("zephyrheights.equestria.dev", DNS_A)[0]["ip"], - dns_get_record("maretimebay.equestria.dev", DNS_A)[0]["ip"], - dns_get_record("bridlewood.equestria.dev", DNS_A)[0]["ip"], - dns_get_record("manehattan.equestria.dev", DNS_A)[0]["ip"], - dns_get_record("everfree.equestria.dev", DNS_A)[0]["ip"], -]; - -$verifiedNames = [ - "Raindrops System", - "Raindrops System", - "Equestria.dev bridlewood", - "Equestria.dev manehattan", - $app["other"]["name"] -]; - -?> - -<br> -<div class="container"> - <h1>Sessions</h1> - <script>window.devices = {};</script> - - <p>Here are all the currently open sessions for your account. Clicking on a session will delete it, meaning the device using this session will be logged out.</p> - - <?php $data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . str_replace("/", "", $_COOKIE['PEH2_SESSION_TOKEN'])), true); if (isset($data["profile"])): ?> - <div class="list-group"> - <?php - - $list = array_filter([...scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens"), ...scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/lowertokens")], function ($token) { - if ($token === "." || $token === "..") return false; - - $session = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/sessions/" . $token), true); - - return isset($session["last"]) && isset($session["profile"]); - }); - usort($list, function ($token1, $token2) { - $session1 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/sessions/" . $token1), true); - $session2 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/sessions/" . $token2), true); - - if (isset($session1["last"]) && isset($session2["last"])) { - return $session2["last"] - $session1["last"]; - } else { - return INF; - } - }); - - $addressFetchIndex = 0; - - foreach ($list as $token): $session = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/sessions/" . $token), true); if (isset($session["profile"]) && isset($session["name"]) && ($session["profile"]["id"] ?? "") === ($_PROFILE["id"] ?? "")): uasort($session["addresses"], function ($a, $b) { - return $b - $a; - }); ?> - <a class="list-group-item list-group-item-action" onclick="logOut("<?= bin2hex(substr($token, 0, 50)) ?>");"> - <b><?= $session["name"] ?></b><?php if ($token === $_COOKIE["PEH2_SESSION_TOKEN"]): ?><span style="margin-left: 10px;" class="badge bg-primary">This device</span><?php endif; ?><script>window.devices["<?= bin2hex(substr($token, 0, 50)) ?>"]=JSON.parse(`<?= json_encode([ - "name" => trim($session["name"]), - "lastIP" => array_keys($session["addresses"])[count(array_keys($session["addresses"])) > 0 ? count(array_keys($session["addresses"])) - 1 : 0] ?? "-", - "lastSeen" => timeAgo($session["last"]), - "currentDevice" => $token === $_COOKIE["PEH2_SESSION_TOKEN"] - ]) ?>`);</script><br> - Logged in <?= timeAgo($session["created"]) ?>, last activity <?= timeAgo($session["last"]) ?> - <blockquote class="session-bq"> - <?php foreach ($session["addresses"] as $address => $last): ?> - <?= $address ?><?php if (in_array($address, $verified)): ?><span class="text-success" style="filter: invert(1) hue-rotate(180deg);"> (verified: <?= $verifiedNames[array_search($address, $verified)] ?? "-" ?>)</span><?php else: ?> <span class="text-muted" style="filter: invert(1) hue-rotate(180deg);" id="aft-<?= $addressFetchIndex ?>">(unverified: …)<script> - setTimeout(async () => { - let json = JSON.parse(await (await fetch("https://api.iplocation.net/?ip=<?= $address ?>")).text()); - - if ( - (json['country_code2'] !== "FR" && json['country_code2'] !== "GB") || - (json['isp'] === "Academie Orleans-Tours" && json['isp'] === "Free Mobile SAS" && json['isp'] === "Google One Services" && json['isp'] === "Vodafone Ltd" && json['isp'] === "Telefonica UK Limited") - ) { - document.getElementById("aft-<?= $addressFetchIndex ?>").classList.remove("text-muted"); - document.getElementById("aft-<?= $addressFetchIndex ?>").classList.add("text-danger"); - document.getElementById("aft-<?= $addressFetchIndex ?>").innerText = `(unsafe: ${json['isp']}, ${json['country_code2'] === "GB" ? "UK" : json['country_code2']})`; - } else { - document.getElementById("aft-<?= $addressFetchIndex ?>").innerText = `(unverified: ${json['isp']}, ${json['country_code2'] === "GB" ? "UK" : json['country_code2']})`; - } - }, 500 * <?= $addressFetchIndex ?>); - </script></span><?php $addressFetchIndex++; endif; ?> · <?= timeAgo($last) ?><br> - <?php endforeach; ?> - </blockquote> - </a> - <?php endif; endforeach; ?> - </div> - <?php else: ?> - <div class="alert alert-danger"> - <b>Error:</b> You cannot use the session manager because your current session is using the old authentication system. Please log out and log in again to continue. - </div> - <?php endif; ?> -</div> - -<div class="modal fade" id="confirm"> - <div class="modal-dialog"> - <div class="modal-content"> - - <div class="modal-header"> - <h4 class="modal-title">Log out this device?</h4> - <button type="button" class="btn-close" data-bs-toggle="modal"></button> - </div> - - <div class="modal-body"> - <p>You are about to log out the following device from your Ponycule account:</p> - <blockquote id="device-bq"> - <div> - <b>Name:</b> <span id="device-name">-</span><br> - <b>Last address:</b> <span id="device-address">-</span><br> - <b>Last activity:</b> <span id="device-activity">-</span> - </div> - </blockquote> - <p class="text-danger" id="device-current" style="display: none;">This is the device you are currently using, which means you will get logged out as soon as you click on confirm.</p> - <p id="device-normal"></p> - <span class="btn btn-success" id="modal-button" style="margin-right: 5px;" onclick="confirm();">Confirm</span><span class="btn btn-outline-secondary" data-bs-toggle="modal">Cancel</span> - </div> - </div> - </div> -</div> - -<script> - window.currentSession = null; - window.currentDevice = null; - window.modal = new bootstrap.Modal(document.getElementById("confirm")); - - async function confirm() { - await fetch("/api/disconnect?id=" + window.currentSession); - - if (currentDevice.currentDevice) { - location.href = "/-/logout"; - } else { - location.reload(); - } - } - - function logOut(id) { - window.currentSession = id; - window.currentDevice = devices[id]; - - if (currentDevice.currentDevice) { - document.getElementById("device-current").style.display = ""; - document.getElementById("device-normal").style.display = "none"; - } else { - document.getElementById("device-current").style.display = "none"; - document.getElementById("device-normal").style.display = ""; - } - - document.getElementById("device-name").innerText = currentDevice.name; - document.getElementById("device-address").innerText = currentDevice.lastIP; - document.getElementById("device-activity").innerText = currentDevice.lastSeen; - - modal.show(); - } -</script> - -<style> - <?php global $use2023UI; if (!$use2023UI): ?> - .modal-header { - border-bottom: 1px solid #353738; - } - - .modal-content { - border: 1px solid rgba(255, 255, 255, .2); - background-color: #111; - } - - .btn-close { - filter: invert(1); - } - - .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 else: ?> - - .list-group-item .text-muted { - color: var(--palette-9) !important; - } - - <?php endif; ?> - - .member-link, .list-group-item-action { - cursor: pointer !important; - } - - .alert-dismissible .btn-close { - filter: none !important; - } - - .session-bq { - margin-bottom: 5px; - margin-top: 10px; - margin-left: 5px; - padding-left: 10px; - border-left: 3px solid var(--palette-5, rgba(255, 255, 255, .25)); - } - - #device-bq { - margin-left: 5px; - padding-left: 10px; - border-left: 3px solid var(--palette-5, rgba(255, 255, 255, .25)); - } -</style> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> diff --git a/pages/splitting.inc b/pages/splitting.inc deleted file mode 100644 index 2f5fa39..0000000 --- a/pages/splitting.inc +++ /dev/null @@ -1,62 +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/components/header.inc'; - -if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/splitting.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/splitting.json", "{}"); - -$cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/splitting.json"), true); - -?> - -<br> -<div class="container"> - <?php if (!isset($cache["content"])): ob_start(); ?> - <div id="page-content"> - <h2>Members by splitting date</h2> - <?php $members = scoreOrderGlobal(); uasort($members, function ($a, $b) { - return strtotime($a["created"]) - strtotime($b["created"]); - }); foreach ($members as $member): ?> - <div class="relation" style="background-color:rgba(255, 255, 255, .1);margin-bottom:10px;padding:10px;border-radius:10px;display:grid;grid-template-columns: 1fr 2fr max-content;"> - <a class="relation-intro" style="background-color:rgba(255, 255, 255, .05);border-right:1px solid rgba(255, 255, 255, .1);margin:-10px;padding:10px;border-top-left-radius:10px;border-bottom-left-radius:10px;color: white;display:flex;align-items:center;text-decoration: none;" href="/<?= $member["name"] ?>"> - <img src="<?= getAsset($member["system"], $member["id"], "heads") ?>" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> - </a> - - <div class="relation-item" style="display:flex;align-items:center;margin-left:10px;padding:0 20px;"> - Formed at least <?= timeAgo($member["created"]) ?> (<?= date('l j F Y', strtotime($member["created"])) ?>) - </div> - </div> - <?php endforeach; ?> - </div> - - <style> - @media (max-width: 991px) { - .relation { - grid-template-columns: 1fr !important; - } - - .relation-intro { - text-align: center; - border-bottom-left-radius: 0 !important; - border-top-right-radius: 10px; - border-right: none !important; - border-bottom: 1px solid rgba(255, 255, 255, .1); - } - - .relation-item-marefriends { - margin-top: 20px !important; - } - - .relation-item { - margin-top: 10px; - margin-left: 0 !important; - padding: 10px 0 !important; - text-align: center; - } - } - </style> - <?php $cache["content"] = ob_get_contents(); ob_end_clean(); endif; - echo($cache["content"]); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/splitting.json", json_encode($cache)); ?> -</div> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> |