From 02eda3e4c9b4ba718f1fff70b7328ed8cdd5e63b Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Sun, 2 Apr 2023 23:03:02 +0200 Subject: Updated 35 files, added 11 files and deleted includes/components/search.inc (automated) --- app.php | 19 +- auth/callback/index.php | 2 +- auth/init/index.php | 2 +- includes/components/footer.inc | 13 +- includes/components/header.inc | 16 +- includes/components/navigation.inc | 148 +++--- includes/components/pane.inc | 5 +- includes/components/search.inc | 534 --------------------- includes/components/wakeup.inc | 2 +- includes/external/chvfs/index.js | 104 ++++ .../external/chvfs/node_modules/.package-lock.json | 15 + .../external/chvfs/node_modules/node-watch/LICENSE | 22 + .../chvfs/node_modules/node-watch/README.md | 233 +++++++++ .../node-watch/lib/has-native-recursive.js | 115 +++++ .../chvfs/node_modules/node-watch/lib/is.js | 78 +++ .../chvfs/node_modules/node-watch/lib/watch.d.ts | 75 +++ .../chvfs/node_modules/node-watch/lib/watch.js | 530 ++++++++++++++++++++ .../chvfs/node_modules/node-watch/package.json | 36 ++ includes/external/chvfs/package-lock.json | 27 ++ includes/external/chvfs/package.json | 5 + includes/jobs/FrontersNotification.php | 18 +- includes/jobs/PKMembers.php | 9 +- includes/jobs/PKSystem.php | 2 +- includes/jobs/UpdateAssets.php | 4 +- includes/pages.json | 350 +++----------- includes/util/agewarning.inc | 10 +- includes/util/banner.inc | 13 +- includes/util/functions.inc | 16 +- includes/util/score.inc | 2 +- includes/util/session.inc | 6 + includes/util/travelling.inc | 2 +- pages/api/emergency-real.php | 10 +- pages/api/emergency.php | 10 +- pages/api/me.php | 2 +- pages/api/pleasure-real.php | 6 +- pages/api/pleasure.php | 6 +- pages/api/plex-thumb.php | 2 +- pages/api/plex.php | 2 +- pages/api/pluralkit-integration.php | 8 +- pages/api/wakeup-real.php | 6 +- pages/api/wakeup.php | 6 +- pages/home.inc | 133 ++++- pages/jobs.inc | 30 +- pages/metadata.inc | 2 + pages/money.inc | 12 +- pages/page.inc | 2 +- pages/travelling.inc | 2 +- 47 files changed, 1621 insertions(+), 1031 deletions(-) delete mode 100644 includes/components/search.inc create mode 100644 includes/external/chvfs/index.js create mode 100644 includes/external/chvfs/node_modules/.package-lock.json create mode 100644 includes/external/chvfs/node_modules/node-watch/LICENSE create mode 100644 includes/external/chvfs/node_modules/node-watch/README.md create mode 100644 includes/external/chvfs/node_modules/node-watch/lib/has-native-recursive.js create mode 100644 includes/external/chvfs/node_modules/node-watch/lib/is.js create mode 100644 includes/external/chvfs/node_modules/node-watch/lib/watch.d.ts create mode 100644 includes/external/chvfs/node_modules/node-watch/lib/watch.js create mode 100644 includes/external/chvfs/node_modules/node-watch/package.json create mode 100644 includes/external/chvfs/package-lock.json create mode 100644 includes/external/chvfs/package.json diff --git a/app.php b/app.php index b6651c9..ec85fbe 100644 --- a/app.php +++ b/app.php @@ -1,12 +1,21 @@ @@ -16,8 +17,10 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; global $lang; global $pages; + $time = microtime(true) - $GLOBALS["ColdHazeStart"]; + ?> - © · build . + © · build ., took ms




@@ -35,7 +38,9 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; }) - + +
+ \ No newline at end of file diff --git a/includes/components/header.inc b/includes/components/header.inc index 06b9bdb..0542314 100644 --- a/includes/components/header.inc +++ b/includes/components/header.inc @@ -1,14 +1,6 @@ -Cold Haze .png" type="image/png"> - id="admin-page"> + @@ -246,4 +238,4 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; display: none; } - + diff --git a/includes/components/navigation.inc b/includes/components/navigation.inc index bd4ea4b..29168ec 100644 --- a/includes/components/navigation.inc +++ b/includes/components/navigation.inc @@ -4,7 +4,78 @@ $pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pa global $navigation; global $toplevel; -global $lang; global $pages; global $app; global $isLowerLoggedIn; +global $lang; global $pages; global $app; global $isLowerLoggedIn; global $isLoggedIn; + +$cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/navigation.json"), true); + +if (!isset($cache["raindrops"])) $cache["raindrops"] = []; +if (!isset($cache["cloudburst"])) $cache["cloudburst"] = []; +if (!isset($cache["other"])) $cache["other"] = []; + +foreach ([ + [ + "name" => "raindrops", + "id" => "gdapd" + ], + [ + "name" => "cloudburst", + "id" => "ynmuc" + ], + [ + "name" => "other", + "id" => $app["other"]["id"] + ] +] as $cacheSystem) { + if (!isset($cache[$cacheSystem["name"]]["public"])) { + $isLoggedInOldState = $isLoggedIn; + $isLowerLoggedInOldState = $isLowerLoggedIn; + + $isLoggedIn = false; + $isLowerLoggedIn = false; + + $cache[$cacheSystem["name"]]["public"] = array_map(function ($member) { + return [ + "name" => $member['display_name'] ?? $member['name'], + "icon" => getAsset($member["system"], $member["id"], "heads"), + "invert" => false, + "link" => "/$member[name]", + "stepped" => null, + "private" => false + ]; + }, array_filter(scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$cacheSystem[id]/members.json"), true), "$cacheSystem[id]"), "$cacheSystem[id]"), function ($member) { + return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new"; + })); + + $isLoggedIn = $isLoggedInOldState; + $isLowerLoggedIn = $isLowerLoggedInOldState; + } + + if (!isset($cache[$cacheSystem["name"]]["private"])) { + $isLoggedInOldState = $isLoggedIn; + $isLowerLoggedInOldState = $isLowerLoggedIn; + + $isLoggedIn = true; + $isLowerLoggedIn = false; + + $cache[$cacheSystem["name"]]["private"] = array_map(function ($member) { + return [ + "name" => $member['display_name'] ?? $member['name'], + "icon" => getAsset($member["system"], $member["id"], "heads"), + "invert" => false, + "link" => "/$member[name]", + "stepped" => null, + "private" => false + ]; + }, array_filter(scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$cacheSystem[id]/members.json"), true), "$cacheSystem[id]"), "$cacheSystem[id]"), function ($member) { + return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new"; + })); + + $isLoggedIn = $isLoggedInOldState; + $isLowerLoggedIn = $isLowerLoggedInOldState; + } +} + +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/navigation.json", json_encode($cache)); $navigation_admin = [ "admin" => !$isLowerLoggedIn, @@ -173,41 +244,7 @@ $navigation_admin = [ "private" => false ], ] - ], - /*"debug" => [ - "name" => $lang["navigation"]["debug"], - "minimal" => false, - "items" => [ - [ - "name" => $pages["debug"]["name"][$lang["_name"]], - "icon" => "/assets/icons/debug.svg", - "invert" => true, - "link" => "/-/debug", - "stepped" => null - ], - [ - "name" => $pages["bitset"]["name"][$lang["_name"]], - "icon" => "/assets/icons/bitset.svg", - "invert" => true, - "link" => "/-/bitset", - "stepped" => null - ], - [ - "name" => $pages["score"]["name"][$lang["_name"]], - "icon" => "/assets/icons/score.svg", - "invert" => true, - "link" => "/-/score", - "stepped" => null - ], - [ - "name" => $pages["logout"]["name"][$lang["_name"]], - "icon" => "/assets/icons/logout.svg", - "invert" => true, - "link" => "/-/logout", - "stepped" => null - ] - ] - ]*/ + ] ] ]; $navigation_global = [ @@ -287,18 +324,7 @@ $navigation_cloudburst = [ "members" => [ "name" => $lang["navigation"]["members"], "minimal" => false, - "items" => array_map(function ($member) { - return [ - "name" => $member['display_name'] ?? $member['name'], - "icon" => getAsset($member["system"], $member["id"], "heads"), - "invert" => false, - "link" => "/$member[name]", - "stepped" => null, - "private" => false - ]; - }, array_filter(scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true), "ynmuc"), "ynmuc"), function ($member) { - return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new"; - })) + "items" => $cache["cloudburst"][$isLoggedIn || $isLowerLoggedIn ? "private" : "public"] ] ] ]; @@ -341,18 +367,7 @@ $navigation_other = [ "members" => [ "name" => $lang["navigation"]["members"], "minimal" => false, - "items" => array_map(function ($member) { - return [ - "name" => $member['display_name'] ?? $member['name'], - "icon" => getAsset($member["system"], $member["id"], "heads"), - "invert" => false, - "link" => "/$member[name]", - "stepped" => null, - "private" => false - ]; - }, array_filter(scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/members.json"), true), $app["other"]["id"]), function ($member) { - return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new"; - })) + "items" => $cache["other"][$isLoggedIn || $isLowerLoggedIn ? "private" : "public"] ] ] ]; @@ -395,18 +410,7 @@ $navigation_raindrops = [ "members" => [ "name" => $lang["navigation"]["members"], "minimal" => false, - "items" => array_map(function ($member) { - return [ - "name" => $member['display_name'] ?? $member['name'], - "icon" => getAsset($member["system"], $member["id"], "heads"), - "invert" => false, - "link" => "/$member[name]", - "stepped" => null, - "private" => false - ]; - }, array_filter(scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true), "gdapd"), "gdapd"), function ($member) { - return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new"; - })) + "items" => $cache["raindrops"][$isLoggedIn || $isLowerLoggedIn ? "private" : "public"] ] ] ]; diff --git a/includes/components/pane.inc b/includes/components/pane.inc index eb735f5..1ecbcdf 100644 --- a/includes/components/pane.inc +++ b/includes/components/pane.inc @@ -22,8 +22,9 @@ foreach ($list as $color) { -
- - - +function banner() { global $isLoggedIn; global $isLowerLoggedIn; $byColor = getMembersByColor(); global $lang; ?>
.png" style="width:128px;">

@@ -30,18 +15,20 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SE

;z-index: 9;margin-left: 8px;opacity: .75;"> -
+

Cold Haze

-

ponies in 3 plural systems

+

ponies in 3 plural systems

-

+

+
style="grid-template-columns: repeat(3, 1fr);"> @@ -73,6 +60,110 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SE endforeach; ?>
+ + +
+
+ +
+ + +
+ + + +
+ Notice: This website is temporarily under maintenance and the administrators have locked the database. Although you are logged in as , you cannot access any of the logged-in features while the website is under maintenance. Alerts dispatching remains possible in case of an emergency. +
+ + + + +
+ Notice: The administrators are currently trying a new optimisation technique based on a virtual file system (chvfs). Data loss, corruption or inconsistency may happen and should be reported on bugs.equestria.dev. +
+ +
- \ No newline at end of file + \ No newline at end of file diff --git a/pages/jobs.inc b/pages/jobs.inc index ae1405d..109b484 100644 --- a/pages/jobs.inc +++ b/pages/jobs.inc @@ -86,31 +86,11 @@ $history = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/ Job lifetime: diff --git a/pages/metadata.inc b/pages/metadata.inc index adde5e7..04579a8 100644 --- a/pages/metadata.inc +++ b/pages/metadata.inc @@ -178,6 +178,8 @@ if ($member === null) { 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", "{}"); header("Location: /" . $_GET['_']); } else { diff --git a/pages/money.inc b/pages/money.inc index 15a7a83..387f5c0 100644 --- a/pages/money.inc +++ b/pages/money.inc @@ -64,16 +64,16 @@ if ((isset($_GET["create"]) || isset($_GET["delete"])) && isset($parts[2])) { if (!isset($_GET["description"])) $_GET["description"] = ""; $_GET["description"] = substr($_GET["description"], 0, 150); - $ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"]; + $ntfy = $GLOBALS["ColdHazeApp"]["ntfy"]; file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy["topic"], false, stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: text/plain\r\n" . - "Title: " . (getMember($myId)["display_name"] ?? getMember($myId)["name"]) . " created a transaction to " . $account["name"] . " (" . ucfirst($account["owner"]) . ")\r\n" . + "Title: " . formatPonypush((getMember($myId)["display_name"] ?? getMember($myId)["name"]) . " created a transaction to " . $account["name"] . " (" . ucfirst($account["owner"]) . ")") . "\r\n" . "Tags: bits\r\n" . "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => ($account["currency"] === "gbp" ? "£" : "€") . abs((float)$_GET["amount"]) . " were " . ((float)$_GET["amount"] >= 0 ? "added" : "removed") . " just now" . (trim($_GET["description"]) !== "" ? ": " . $_GET["description"] : "") + 'content' => formatPonypush(($account["currency"] === "gbp" ? "£" : "€") . abs((float)$_GET["amount"]) . " were " . ((float)$_GET["amount"] >= 0 ? "added" : "removed") . " just now" . (trim($_GET["description"]) !== "" ? ": " . $_GET["description"] : "")) ] ])); @@ -90,16 +90,16 @@ if ((isset($_GET["create"]) || isset($_GET["delete"])) && isset($parts[2])) { file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/money/" . $name . ".json", json_encode($account, JSON_PRETTY_PRINT)); } else { if (isset($_GET["id"]) && is_numeric($_GET["id"]) && isset($account["transactions"][(int)$_GET["id"]])) { - $ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"]; + $ntfy = $GLOBALS["ColdHazeApp"]["ntfy"]; file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy["topic"], false, stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: text/plain\r\n" . - "Title: " . (getMember($myId)["display_name"] ?? getMember($myId)["name"]) . " deleted a transaction from " . $account["name"] . " (" . ucfirst($account["owner"]) . ")\r\n" . + "Title: " . formatPonypush((getMember($myId)["display_name"] ?? getMember($myId)["name"]) . " deleted a transaction from " . $account["name"] . " (" . ucfirst($account["owner"]) . ")") . "\r\n" . "Tags: bits\r\n" . "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => ($account["currency"] === "gbp" ? "£" : "€") . abs((float)$account["transactions"][(int)$_GET["id"]]["amount"]) . " " . ((float)$account["transactions"][(int)$_GET["id"]]["amount"] >= 0 ? "advance" : "withdrawal") . " created by " . (getMemberWithoutSystem($account["transactions"][(int)$_GET["id"]]["author"])["display_name"] ?? getMemberWithoutSystem($account["transactions"][(int)$_GET["id"]]["author"])["name"]) . " " . timeAgo($account["transactions"][(int)$_GET["id"]]["date"]) + 'content' => formatPonypush(($account["currency"] === "gbp" ? "£" : "€") . abs((float)$account["transactions"][(int)$_GET["id"]]["amount"]) . " " . ((float)$account["transactions"][(int)$_GET["id"]]["amount"] >= 0 ? "advance" : "withdrawal") . " created by " . (getMemberWithoutSystem($account["transactions"][(int)$_GET["id"]]["author"])["display_name"] ?? getMemberWithoutSystem($account["transactions"][(int)$_GET["id"]]["author"])["name"]) . " " . timeAgo($account["transactions"][(int)$_GET["id"]]["date"])) ] ])); diff --git a/pages/page.inc b/pages/page.inc index 8446062..931e6e5 100644 --- a/pages/page.inc +++ b/pages/page.inc @@ -2,7 +2,7 @@ global $lang; global $pages; global $isLoggedIn; global $isLowerLoggedIn; -$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); +$app = $GLOBALS["ColdHazeApp"]; $travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json"), true); if (!isset($_GET['_']) || trim($_GET['_']) === "") peh_error("Invalid request", 400); diff --git a/pages/travelling.inc b/pages/travelling.inc index fdcfa99..cfbd4ac 100644 --- a/pages/travelling.inc +++ b/pages/travelling.inc @@ -2,7 +2,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; global $isLowerLoggedIn; $travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json"), true); -$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); +$app = $GLOBALS["ColdHazeApp"]; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; -- cgit