diff options
author | Minteck <contact@minteck.org> | 2023-02-25 19:59:31 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2023-02-25 19:59:31 +0100 |
commit | 3d77712a9ab014635c75a33ea0f491bbda6aead3 (patch) | |
tree | 616bef5215db4f1d1cea2566079db2a130363e6b | |
parent | 15bb1453008237edbc2cb4e82a9eb44db6f99794 (diff) | |
download | pluralconnect-3d77712a9ab014635c75a33ea0f491bbda6aead3.tar.gz pluralconnect-3d77712a9ab014635c75a33ea0f491bbda6aead3.tar.bz2 pluralconnect-3d77712a9ab014635c75a33ea0f491bbda6aead3.zip |
Updated 16 files and added 2 files (automated)
-rw-r--r-- | assets/logo/custom.css | 46 | ||||
-rw-r--r-- | assets/logo/newlogo3-template.png | bin | 40569 -> 38736 bytes | |||
-rw-r--r-- | assets/logo/newlogo3.png | bin | 5606 -> 5653 bytes | |||
-rw-r--r-- | includes/backup.inc | 4 | ||||
-rw-r--r-- | includes/external/school/index.js | 2 | ||||
-rw-r--r-- | includes/footer.inc | 2 | ||||
-rw-r--r-- | includes/functions.inc | 2 | ||||
-rw-r--r-- | includes/homepage.inc | 28 | ||||
-rw-r--r-- | includes/member.inc | 32 | ||||
-rw-r--r-- | includes/pane.inc | 2 | ||||
-rw-r--r-- | includes/planner.inc | 2 | ||||
-rw-r--r-- | includes/rainbow.inc | 8 | ||||
-rw-r--r-- | includes/refresh.php | 14 | ||||
-rw-r--r-- | includes/score.inc | 123 | ||||
-rw-r--r-- | pages/api/fronter.php | 71 | ||||
-rw-r--r-- | pages/home.inc | 55 | ||||
-rw-r--r-- | pages/home.old.inc | 95 | ||||
-rw-r--r-- | pages/travelling.inc | 2 |
18 files changed, 328 insertions, 160 deletions
diff --git a/assets/logo/custom.css b/assets/logo/custom.css index dccb432..4237274 100644 --- a/assets/logo/custom.css +++ b/assets/logo/custom.css @@ -2,6 +2,14 @@ margin-left: 32px; } +.debug-hidden { + display: none; +} + +.debug-outer:hover .debug-hidden { + display: inline-block; +} + .modal { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); @@ -583,12 +591,44 @@ dd { border-bottom: 1px solid rgba(255, 255, 255, .25); } -.rainbow-item:hover { +.new-homepage-system-title:hover { + opacity: .85; +} + +#new-homepage-systems { + display: grid; + grid-template-columns: repeat(2, 1fr); + grid-gap: 20px; +} + +@media (max-width: 991px) { + #new-homepage-systems { + grid-template-columns: 1fr !important; + } +} + +.new-homepage-system-list { + background-color: rgba(255, 255, 255, .1); + border-bottom-left-radius: 10px; + border-bottom-right-radius: 10px; + display: grid; +} + +.new-homepage-link-last { + border-bottom-left-radius: 10px; + border-bottom-right-radius: 10px; +} + +.new-homepage-link:hover { + opacity: .85; +} + +.new-homepage-link:active { opacity: .75; } -.rainbow-item:active { - opacity: .5; +.new-homepage-system-title:active { + opacity: .75; } peh-muted { diff --git a/assets/logo/newlogo3-template.png b/assets/logo/newlogo3-template.png Binary files differindex a462f45..bec8d1b 100644 --- a/assets/logo/newlogo3-template.png +++ b/assets/logo/newlogo3-template.png diff --git a/assets/logo/newlogo3.png b/assets/logo/newlogo3.png Binary files differindex 502543b..28ff3e1 100644 --- a/assets/logo/newlogo3.png +++ b/assets/logo/newlogo3.png diff --git a/includes/backup.inc b/includes/backup.inc index 489390b..361902b 100644 --- a/includes/backup.inc +++ b/includes/backup.inc @@ -54,7 +54,7 @@ function pkcs7_pad($data, $size) { } if (!file_exists("./data/backup.ponieskey")) { - echo(" Reading encryption key...\n"); + echo(" Creating encryption key...\n"); $key = openssl_random_pseudo_bytes(512); $iv = openssl_random_pseudo_bytes(16); file_put_contents("./data/backup.ponieskey", base64_encode(json_encode([ @@ -62,7 +62,7 @@ if (!file_exists("./data/backup.ponieskey")) { "key" => bin2hex($key) ]))); } else { - echo(" Creating encryption key...\n"); + echo(" Reading encryption key...\n"); $key_raw = json_decode(base64_decode(file_get_contents("./data/backup.ponieskey")), true); $key = hex2bin($key_raw["key"]); $iv = hex2bin($key_raw["iv"]); diff --git a/includes/external/school/index.js b/includes/external/school/index.js index 962cb7e..ad601d6 100644 --- a/includes/external/school/index.js +++ b/includes/external/school/index.js @@ -1,6 +1,6 @@ const axios = require('axios'); const pronote = require('pronote-api'); -const config = require('../includes/app.json'); +const config = require('../../app.json'); const url = config.pronote.url; const username = config.pronote.user; diff --git a/includes/footer.inc b/includes/footer.inc index 6e9f3d0..b2fb277 100644 --- a/includes/footer.inc +++ b/includes/footer.inc @@ -18,7 +18,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.inc"; ?> © <?= date("Y") ?> <a href="https://equestria.horse" target="_blank" class="text-muted"><?= $lang["footer"]["copyright"] ?></a> · build <?= $version["build"] ?>.<?= $version["revision"] ?><br> - <a href="/-/debug" class="text-muted" style="text-decoration: none;"><?= $lang["footer"]["update"] ?> <?= trim(timeAgo($refresh["timestamp"], $lang["_french"])) ?> (<?php if (time() - $refresh["timestamp"] > 360): ?><?= $lang["footer"]["no_update"] ?><?= $lang["footer"]["separator"] ?>; <?php endif; ?><?= date('D j M, G:i:s T', (int)$refresh["timestamp"]) ?><?= $lang["footer"]["separator"] ?>; <?= $lang["footer"]["took"] ?> <?= round($refresh["duration"] * 1000) ?> ms, <?= count($refresh["restored"]) > 0 ? (count($refresh["restored"]) > 1 ? $lang["footer"]["failures"][0] . count($refresh["restored"]) . $lang["footer"]["failures"][1] : $lang["footer"]["failure"]) : $lang["footer"]["no_failure"] ?>)</a> + <a class="debug-outer text-muted" style="text-decoration: none;"><?= $lang["footer"]["update"] ?> <?= trim(timeAgo($refresh["timestamp"], $lang["_french"])) ?><span class="debug-hidden"> (<?php if (time() - $refresh["timestamp"] > 360): ?><?= $lang["footer"]["no_update"] ?><?= $lang["footer"]["separator"] ?>; <?php endif; ?><?= date('D j M, G:i:s T', (int)$refresh["timestamp"]) ?><?= $lang["footer"]["separator"] ?>; <?= $lang["footer"]["took"] ?> <?= round($refresh["duration"]) ?> sec)</span></a> <br><br><br><br><br> </div> </div> diff --git a/includes/functions.inc b/includes/functions.inc index 7a6ad5d..1d467a0 100644 --- a/includes/functions.inc +++ b/includes/functions.inc @@ -2,6 +2,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.inc"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/bitset.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/homepage.inc"; if (!function_exists("peh_error")) { function peh_error($message, $code = 500): void { @@ -354,6 +355,7 @@ if (!function_exists("cloudburst")) { } } + if (!function_exists("raindrops")) { function raindrops(bool $hideTitle): void { showSystem("gdapd", "Raindrops System", "#a95f08a6", $hideTitle); diff --git a/includes/homepage.inc b/includes/homepage.inc new file mode 100644 index 0000000..c078e89 --- /dev/null +++ b/includes/homepage.inc @@ -0,0 +1,28 @@ +<?php + +global $app; +global $travelling; + +function newHomepage($id, $page, $title) { + $system = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $id . "/general.json"), true); + + ?> + <div class="new-homepage-system" id="new-homepage-system-<?= $id ?>"> + <?php if ($title): ?> + <a href="/<?= $page ?>" style="height: 48px; display: flex; align-items: center; justify-content: center; border-top-left-radius: 10px; border-top-right-radius: 10px; text-align: center; text-decoration: none; color: white; background-color: #<?= $system["color"] ?? "000000" ?>55" class="new-homepage-system-title" id="new-homepage-system-<?= $id ?>-title"> + <div> + <img src="<?= getAsset($id) ?>" style="width: 48px; vertical-align: middle;"><b style="vertical-align: middle; margin-left: 5px;"><?= $system["name"] ?></b> + </div> + </a> + <?php endif; ?> + + <div class="new-homepage-system-list" id="new-homepage-system-<?= $id ?>-list"> + <?php $list = array_values(withTravelers(scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $id . "/members.json"), true), $id), $id)); foreach ($list as $index => $member): ?> + <a href="/<?= $member["name"] ?>" class="new-homepage-link <?= $index === count($list) - 1 ? "new-homepage-link-last" : "" ?>" style="color: white !important; text-decoration: none !important; display: block; background-color: #<?= $member["color"] ?>22; padding: 5px 10px;"> + <img src="<?= getAsset($id, $member["id"]) ?>" style="width: 32px; height: 32px; vertical-align: middle; background-color: rgba(0, 0, 0, .25); border-radius: 999px;"> + <span style="width: calc(100% - 37px); vertical-align: middle; margin-left: 5px;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;"><?= $member["display_name"] ?? $member["name"] ?></span> + </a> + <?php endforeach; ?> + </div> + </div> +<?php }
\ No newline at end of file diff --git a/includes/member.inc b/includes/member.inc index 5292dc1..8d03285 100644 --- a/includes/member.inc +++ b/includes/member.inc @@ -137,36 +137,10 @@ if ($memberData["name"] === "fusion") { <li><b>Protector:</b> <code><?= $metadata["protector"] ? "1" : "0" ?></code> (<?= $metadata["protector"] ? "Yes" : "No" ?>)</li> <li><b>Little:</b> <code><?= $metadata["little"] ?></code> (<?= $metadata["little"] === 2 ? "Is a little" : ($metadata["little"] === 1 ? "Is an age regressor" : ($metadata["little"] === 3 ? "Not a little, but younger" : "No")) ?>)</li> <li><b>Relations count:</b> <code><?= count($metadata["marefriends"]) + count($metadata["sisters"]) ?></code></li> - <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.inc"; $score = calculateScore($metadata, $memberData["display_name"] ?? $memberData["name"]); ?> + <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.inc"; ?> <li> - <b>Score breakdown:</b> <code><?= $score["total"] ?></code> - <ul><?php - - foreach ($metadata as $type => $usage) { - if (is_string($usage)) { - echo("<li><b>" . $type . ":</b> " . $usage . "</li>"); - } else if (is_array($usage)) { - if (count($usage) === 0) { - echo("<li><b>" . $type . ":</b> []</li>"); - } else { - echo("<li><b>" . $type . ":</b><ul>"); - - foreach ($usage as $key => $item) { - if (is_string($item)) { - echo("<li><b>" . $key . ":</b> " . $item . "</li>"); - } else { - echo("<li><b>" . $key . ":</b> " . json_encode($item, JSON_UNESCAPED_SLASHES) . "</li>"); - } - } - - echo("</ul></li>"); - } - } else { - echo("<li><b>" . $type . ":</b> " . json_encode($usage, JSON_UNESCAPED_SLASHES) . "</li>"); - } - } - - ?></ul></li> + <b>Score breakdown:</b> <code>-</code> + <ul><li>-</ul></li> </ul> </div> </details> diff --git a/includes/pane.inc b/includes/pane.inc index 058c911..d135eac 100644 --- a/includes/pane.inc +++ b/includes/pane.inc @@ -15,7 +15,7 @@ foreach ($list as $color) { } ?>)"> - <a href="/" id="pane-header" class="login-link-clickable" style="color: white; text-decoration: none; padding: 20px; display: block; text-align: center; border-bottom: 1px solid rgba(255, 255, 255, .25);"> + <a href="/" id="pane-header" class="login-link-clickable" style="color: white; text-decoration: none; padding: 20px; display: block; text-align: center; border-bottom: 1px solid rgba(255, 255, 255, .25); backdrop-filter: blur(20px);"> <img src="/assets/logo/newlogo<?= $isLoggedIn || $isLowerLoggedIn ? "3" : "" ?>.png" alt="" style="width:32px;vertical-align: middle;margin-right:5px;"> <span style="vertical-align: middle; font-weight: bold;">Cold Haze</span> </a> diff --git a/includes/planner.inc b/includes/planner.inc index ce6e0cb..14bb37f 100644 --- a/includes/planner.inc +++ b/includes/planner.inc @@ -18,7 +18,7 @@ function pacifier($id) { $metadata = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $id . ".json"), true)); - if ($metadata["pacifier"] && !$isLowerLoggedIn) { + if (isset($metadata["pacifier"]) && $metadata["pacifier"] && !$isLowerLoggedIn) { return "<img title='This pony likes to sleep with a pacifier.' data-bs-toggle='tooltip' src='/assets/logo/pacifier.png' style='margin-left:auto;float: right;opacity:.75;width:24px;height:24px;vertical-align: middle; filter: invert(1);'>"; } diff --git a/includes/rainbow.inc b/includes/rainbow.inc index fba960e..01b234c 100644 --- a/includes/rainbow.inc +++ b/includes/rainbow.inc @@ -45,14 +45,6 @@ function getMembersByColor($hideCloudburst = false): array { uasort($members, function ($a, $b) { return $a['hsl'][0] - $b['hsl'][0]; }); - $members = [ - ...array_filter($members, function ($i) { - return $i['hsl'][2] < 0.9 || $i['hsl'][1] > 0.2; - }), - ...array_filter($members, function ($i) { - return $i['hsl'][2] >= 0.9 || $i['hsl'][1] <= 0.2; - }) - ]; $sorted = []; foreach ($members as $data) { diff --git a/includes/refresh.php b/includes/refresh.php index 3f3e7f4..65c570c 100644 --- a/includes/refresh.php +++ b/includes/refresh.php @@ -151,13 +151,15 @@ function getSystem(string $id, string $fileName = null, string $token = null) { $parsed = json_decode($data, true); foreach ($parsed as $index => $member) { - if (!isset($member["color"])) { - if (isset($member["avatar_url"])) { - $dominantColor = substr(ColorThief::getColor($member["avatar_url"], outputFormat: "hex"), 1); - } else { - $dominantColor = "ffffff"; - } + if (isset($member["avatar_url"])) { + $dominantColor = substr(ColorThief::getColor($member["avatar_url"], outputFormat: "hex"), 1); + } else { + $dominantColor = "ffffff"; + } + + $parsed[$index]["dominant_color"] = $dominantColor; + if (!isset($member["color"])) { $parsed[$index]["color"] = $dominantColor; } } diff --git a/includes/score.inc b/includes/score.inc index 991c132..57c7a75 100644 --- a/includes/score.inc +++ b/includes/score.inc @@ -1,59 +1,45 @@ <?php -function calculateScore($metadata, $name) { - $scoreFictive = $metadata["fictive"] ? 200 : 0; - $scoreLittle = $metadata["little"] === 2 ? 100 : ($metadata["little"] === 1 ? 50 : ($metadata["little"] === 3 ? 75 : 0)); - $scoreNotTalking = $metadata["not_talking"] ? -200 : 0; - $scoreMedian = $metadata["median"] !== false ? -50 : 0; - $scoreProtector = $metadata["protector"] ? 1000 : 0; - $scoreSharedMemory = $metadata["shared_memory"] === 0 ? 200 : ($metadata["shared_memory"] === 1 ? 50 : 0); - $scoreSpecies = (in_array("pegasus", $metadata["species"]) ? 100 : 0) + (in_array("unicorn", $metadata["species"]) ? 75 : 0) + (in_array("earth", $metadata["species"]) ? 50 : 0) + (in_array("alicorn", $metadata["species"]) ? 150 : 0) + (in_array("batpony", $metadata["species"]) ? 125 : 0) + (in_array("crystal", $metadata["species"]) ? 125 : 0); - $scoreName = strlen($name) * 5; - $relations = (count($metadata["marefriends"]) * ($metadata["little"] ? 1 : 2)) + count($metadata["sisters"]); - $scoreRelations = $relations * 50; - - $scoreLeader = $metadata["leader"] ? 10000 : 0; - $scorePersecutor = $metadata["persecutor"] ? -10000 : 0; - - $scoreAdd = 0; - if ($name === "Cloudy Dreams") $scoreAdd += 250; - if ($name === "Princess Celestia") $scoreAdd += 250; - if ($name === "Scootaloo") $scoreAdd -= 235; - - $score = $scoreLeader + $scorePersecutor + $scoreFictive + $scoreLittle + $scoreNotTalking + $scoreProtector + $scoreSharedMemory + $scoreRelations + $scoreSpecies + $scoreName + $scoreMedian + $scoreAdd; - - return [ - "leader" => $scoreLeader, - "fictive" => $scoreFictive, - "little" => $scoreLittle, - "median" => $scoreMedian, - "not_talking" => $scoreNotTalking, - "name" => $scoreName, - "protector" => $scoreProtector, - "shared_memory" => $scoreSharedMemory, - "relations" => $scoreRelations, - "species" => $scoreSpecies, - "persecutor" => $scorePersecutor, - "additional" => $scoreAdd, - "total" => $score - ]; -} - -function scoreOrder($members, $system) { +function scoreOrder($members, $system, $useDominant = false) { $ordered = []; foreach ($members as $member) { if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_starts_with($member["name"], "smol") && !str_ends_with($member["name"], "-travelling") && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json")) { + if (isset($member["color"])) { + if ($useDominant) { + $rgb = [ + hexdec(substr($member["dominant_color"] ?? $member["color"], 0, 2)), + hexdec(substr($member["dominant_color"] ?? $member["color"], 2, 2)), + hexdec(substr($member["dominant_color"] ?? $member["color"], 4, 2)) + ]; + } else { + $rgb = [ + hexdec(substr($member["color"], 0, 2)), + hexdec(substr($member["color"], 2, 2)), + hexdec(substr($member["color"], 4, 2)) + ]; + } + + $hsl = rgbToHsl( + $rgb[0], + $rgb[1], + $rgb[2] + ); + } else { + $rgb = [255, 255, 255]; + $hsl = rgbToHsl(255, 255, 255); + } + $systemID = $member["system"] ?? $system; $member["_system"] = $member["system"] = $systemID; $member["_metadata"] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)); - $member["_score"] = calculateScore(parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)), $member["display_name"] ?? $member["name"]); + $member["_score"] = $hsl[0]; $ordered[] = $member; } } uasort($ordered, function($a, $b) { - return $b["_score"]["total"] - $a["_score"]["total"]; + return $a["_score"] - $b["_score"]; }); return $ordered; @@ -66,20 +52,50 @@ function scoreOrderGlobal() { $ordered = []; foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true) as $member) { if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_starts_with($member["name"], "smol") && !str_ends_with($member["name"], "-travelling") && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json")) { + if (isset($member["color"])) { + $rgb = [ + hexdec(substr($member["color"], 0, 2)), + hexdec(substr($member["color"], 2, 2)), + hexdec(substr($member["color"], 4, 2)) + ]; + $hsl = rgbToHsl( + $rgb[0], + $rgb[1], + $rgb[2] + ); + } else { + $rgb = [255, 255, 255]; + $hsl = rgbToHsl(255, 255, 255); + } + $member["_score"] = $hsl[0]; $member["_system"] = "gdapd"; $member["system"] = "gdapd"; $member["_metadata"] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)); - $member["_score"] = calculateScore(parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)), $member["display_name"] ?? $member["name"]); $ordered[] = $member; } } foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true) as $member) { if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_starts_with($member["name"], "smol") && !str_ends_with($member["name"], "-travelling") && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json")) { + if (isset($member["color"])) { + $rgb = [ + hexdec(substr($member["color"], 0, 2)), + hexdec(substr($member["color"], 2, 2)), + hexdec(substr($member["color"], 4, 2)) + ]; + $hsl = rgbToHsl( + $rgb[0], + $rgb[1], + $rgb[2] + ); + } else { + $rgb = [255, 255, 255]; + $hsl = rgbToHsl(255, 255, 255); + } + $member["_score"] = $hsl[0]; $member["_system"] = "ynmuc"; $member["system"] = "ynmuc"; $member["_metadata"] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)); - $member["_score"] = calculateScore(parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)), $member["display_name"] ?? $member["name"]); $ordered[] = $member; } } @@ -88,17 +104,32 @@ function scoreOrderGlobal() { $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/members.json"), true) as $member) { if ($member["name"] !== "unknown" && $member["name"] !== "fusion" && $member["name"] !== "new" && !str_starts_with($member["name"], "smol") && !str_ends_with($member["name"], "-travelling") && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json")) { + if (isset($member["color"])) { + $rgb = [ + hexdec(substr($member["color"], 0, 2)), + hexdec(substr($member["color"], 2, 2)), + hexdec(substr($member["color"], 4, 2)) + ]; + $hsl = rgbToHsl( + $rgb[0], + $rgb[1], + $rgb[2] + ); + } else { + $rgb = [255, 255, 255]; + $hsl = rgbToHsl(255, 255, 255); + } + $member["_score"] = $hsl[0]; $member["_system"] = $app["other"]["id"]; $member["system"] = $app["other"]["id"]; $member["_metadata"] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)); - $member["_score"] = calculateScore(parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$member[id].json"), true)), $member["display_name"] ?? $member["name"]); $ordered[] = $member; } } } uasort($ordered, function($a, $b) { - return $b["_score"]["total"] - $a["_score"]["total"]; + return $a["_score"] - $b["_score"]; }); return array_values($ordered); diff --git a/pages/api/fronter.php b/pages/api/fronter.php index 51ee4ee..b380a56 100644 --- a/pages/api/fronter.php +++ b/pages/api/fronter.php @@ -12,14 +12,17 @@ $index = (int)$_GET['i'] ?? null; $type = $_GET['t'] ?? null; $date = $_GET['d'] ?? null; -if (!isset($system) || trim($system) === "" || strlen($system) !== 5 || !preg_match("/[a-z]/i", $system) || ($system !== "gdapd" && $system !== "ynmuc")) +if (!isset($system) || trim($system) === "" || strlen($system) !== 5 || !preg_match("/[a-z]/i", $system) || ($system !== "gdapd" && $system !== "ynmuc")) { peh_error("System not found", 404); +} -if (!isset($type) || trim($type) === "") +if (!isset($type) || trim($type) === "") { peh_error("Type not found", 404); +} -if (!isset($date) || trim($date) === "" || strlen($date) !== 10 || !preg_match("/[\d-]/i", $date)) +if (!isset($date) || trim($date) === "" || strlen($date) !== 10 || !preg_match("/[\d-]/i", $date)) { peh_error("Date not found", 404); +} $list = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/planner/$system.json"), true); @@ -30,36 +33,42 @@ function moveElement(&$array, $a, $b) { switch ($type) { case "add": - if (!isset($member) || trim($member) === "" || strlen($member) !== 5 || !preg_match("/[a-z]/i", $member)) + if (!isset($member) || trim($member) === "" || strlen($member) !== 5 || !preg_match("/[a-z]/i", $member)) { if ($member !== null && $member !== "null") peh_error("System member not found", 404); + } if (!isset($list[$date])) $list[$date] = []; $list[$date][] = [$member, null]; break; case "cofront": - if (!isset($index) || trim($index) === "" || is_integer($index)) - if ($index !== null && $index !== "null") peh_error("Invalid index", 400); + if (!isset($index) || trim($index) === "" || !is_integer($index)) { + if ($index !== null) peh_error("Invalid index", 400); + } $day = $list[$date]; - if (!isset($day[$index])) - if ($index !== null && $index !== "null") peh_error("Index not found", 404); + if (!isset($day[$index])) { + if ($index !== null) peh_error("Index not found", 404); + } - if (!isset($member) || trim($member) === "" || strlen($member) !== 5 || !preg_match("/[a-z]/i", $member)) + if (!isset($member) || trim($member) === "" || strlen($member) !== 5 || !preg_match("/[a-z]/i", $member)) { if ($member !== null && $member !== "null") peh_error("System member not found", 404); + } $list[$date][$index][1] = $member; break; case "delete": - if (!isset($index) || trim($index) === "" || is_integer($index)) - if ($index !== null && $index !== "null") peh_error("Invalid index", 400); + if (!isset($index) || trim($index) === "" || !is_integer($index)) { + if ($index !== null) peh_error("Invalid index", 400); + } $day = $list[$date]; - if (!isset($day[$index])) - if ($index !== null && $index !== "null") peh_error("Index not found", 404); + if (!isset($day[$index])) { + if ($index !== null) peh_error("Index not found", 404); + } unset($day[$index]); $list[$date] = array_values($day); @@ -67,38 +76,46 @@ switch ($type) { break; case "codelete": - if (!isset($index) || trim($index) === "" || is_integer($index)) - if ($index !== null && $index !== "null") peh_error("Invalid index", 400); + if (!isset($index) || trim($index) === "" || !is_integer($index)) { + if ($index !== null) peh_error("Invalid index", 400); + } $day = $list[$date]; - if (!isset($day[$index])) - if ($index !== null && $index !== "null") peh_error("Index not found", 404); + if (!isset($day[$index])) { + if ($index !== null) peh_error("Index not found", 404); + } $list[$date][$index][1] = null; break; case "down": - if (!isset($index) || trim($index) === "" || is_integer($index)) - if ($index !== null && $index !== "null") peh_error("Invalid index", 400); - - if (!isset($day[$index])) - if ($index !== null && $index !== "null") peh_error("Index not found", 404); + if (!isset($index) || trim($index) === "" || !is_integer($index)) { + if ($index !== null) peh_error("Invalid index", 400); + } $day = $list[$date]; + + if (!isset($day[$index])) { + if ($index !== null) peh_error("Index not found", 404); + } + moveElement($list[$date], $index, $index + 1 < count($list[$date]) ? $index + 1 : $index); break; case "up": - if (!isset($index) || trim($index) === "" || is_integer($index)) - if ($index !== null && $index !== "null") peh_error("Invalid index", 400); - - if (!isset($day[$index])) - if ($index !== null && $index !== "null") peh_error("Index not found", 404); + if (!isset($index) || trim($index) === "" || !is_integer($index)) { + if ($index !== null) peh_error("Invalid index", 400); + } $day = $list[$date]; + + if (!isset($day[$index])) { + if ($index !== null) peh_error("Index not found", 404); + } + moveElement($list[$date], $index, $index - 1 > -1 ? $index - 1 : $index); break; diff --git a/pages/home.inc b/pages/home.inc index 4249947..82ff3d5 100644 --- a/pages/home.inc +++ b/pages/home.inc @@ -25,9 +25,9 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SE <div style="text-align: center;"> <img alt="" src="/assets/logo/newlogo<?= $isLoggedIn || $isLowerLoggedIn ? "3" : "" ?>.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 data-bs-html="true" class="rainbow-item tooltip-nohelp" title="<b><?= $member["display_name"] ?? $member["name"] ?></b><br><?= ($travelling[$member['id']]["travelling"] ? $member["_system"] === "ynmuc" : $member["_system"] === "gdapd") ? "Raindrops System" : ($member["_system"] === "ynmuc" ? "Cloudburst System" : $app["other"]["name"]) ?>" data-bs-toggle="tooltip" style="overflow: hidden;" href="/<?= $member["name"] ?>"><img 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;"><img src="<?= getAsset($member["_system"], $member["id"], "heads") ?>" style="height:32px;position:absolute;z-index:99;"></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);"> + <div style="margin-top:-33px;margin-bottom:0;margin-left:-20px;margin-right:20px;height:32px;text-align: center;display:grid;grid-template-columns: repeat(<?= count($byColor) ?>, 1fr);position:relative;left:10px;"> <?php foreach ($byColor as $member): ?><div> <span style="display: inline-block;background: transparent;position:absolute;width: 0;height: 0;margin-top: 17px;box-shadow: 0 6px 20px 20px #<?= $member["color"] ?>;z-index: 9;margin-left: 8px;opacity: .75;"></span> </div><?php endforeach; ?> @@ -45,50 +45,37 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SE <?php endif; ?> </div> </div> - <hr style="border-color:rgba(255, 255, 255, .25);"> - <!--<?php global $isLoggedIn; if ($isLoggedIn && ((int)date('H') >= 20 || (int)date('H') < 6)): ?> - <a href="/-/emergency" style="text-decoration: none;margin-top:15px;display:block;"> - <div class="alert alert-danger"> - <b>Are you in need of help?</b> If you need immediate help from a loved one, you may want to enable the emergency alert by clicking here, even if that wakes up the <?= $_PROFILE['name'] === "Raindrops System" ? "Cloudburst System" : "Raindrops System" ?>. Use it as you need. - </div> - </a> - <?php endif; ?>--> - - <!--<div class="alert alert-info"> - <b>Coming soon:</b> Free hosting for Project Scout (the software powering Cold Haze), so you can have your own website for your system. If you are interested and/or want to pre-register, feel free to <a href="https://equestria.horse/contact" target="_blank">contact us</a>. - </div>--> - - <div id="homepage-desktop" style="margin-top:10px;"> + <div id="new-homepage" style="margin-top:20px;"> - <?php cloudburst(false); ?> - <?php raindrops(false); ?> - <?php if ($isLoggedIn || $isLowerLoggedIn) other(false); ?> + <div id="new-homepage-systems" <?php if ($isLoggedIn || $isLowerLoggedIn): ?>style="grid-template-columns: repeat(3, 1fr);"<?php endif; ?>> + <?php newHomepage("ynmuc", "cloudburst", true); ?> + <?php newHomepage("gdapd", "raindrops", true); ?> + <?php if ($isLoggedIn || $isLowerLoggedIn) newHomepage($app["other"]["id"], $app["other"]["slug"], true); ?> + </div> - <hr> + </div> - <div id="hpd-legacy" style="background:rgba(255, 255, 255, .1);border-radius:10px;padding:10px 10px 10px 20px;display:grid;grid-template-columns: 128px 1fr;margin-bottom:10px;"> - <a style="display:flex;margin: -10px -20px;align-items:center;justify-content:center;text-align:center;padding: 10px 20px;border-radius: 10px;background: #77777755;width: 148px;text-decoration:none;color:white;filter:none !important;" class="hpd-system"> - <div style="text-align:center;"><img src="/assets/icons/legacy.svg" style="width:64px;"><br>Pony Legacy</div> - </a> + <div id="hpd-legacy" style="margin-top: 20px; background:rgba(255, 255, 255, .1);border-radius:10px;padding:10px 10px 10px 20px;display:grid;grid-template-columns: 128px 1fr;margin-bottom:10px;"> + <a style="display:flex;margin: -10px -20px;align-items:center;justify-content:center;text-align:center;padding: 10px 20px;border-radius: 10px;background: #77777755;width: 148px;text-decoration:none;color:white;filter:none !important;" class="hpd-system"> + <div style="text-align:center;"><img src="/assets/icons/legacy.svg" style="width:64px;"><br>Pony Legacy</div> + </a> - <div style="display:grid;grid-template-columns:repeat(6, 1fr);padding-left:10px;grid-gap:10px;"> - <?php foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/legacy"), function ($i) { - return !str_starts_with($i, "."); - }) as $id): - $id = substr($id, 0, -5); - $member = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/legacy/" . $id . ".json"), true); + <div style="display:grid;grid-template-columns:repeat(6, 1fr);padding-left:10px;grid-gap:10px;"> + <?php foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/legacy"), function ($i) { + return !str_starts_with($i, "."); + }) as $id): + $id = substr($id, 0, -5); + $member = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/legacy/" . $id . ".json"), true); - echo('<a style="text-decoration:none !important;filter:none !important;"><div class="hpd-item-card" style="background-color:rgba(255, 255, 255, .1);border:1px solid ' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';outline-color:' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';border-radius:10px;text-align:center;display:flex;align-items:center;justify-content:center;padding:5px;opacity:5;"><div> + echo('<a style="text-decoration:none !important;filter:none !important;"><div class="hpd-item-card" style="background-color:rgba(255, 255, 255, .1);border:1px solid ' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';outline-color:' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';border-radius:10px;text-align:center;display:flex;align-items:center;justify-content:center;padding:5px;opacity:5;"><div> <img alt="" src="' . $member["avatar"] . '" style="border-radius:999px;background-color:rgba(0, 0, 0, .25);height:48px;display:block;margin-left:auto;margin-right:auto;"> <div style="text-decoration:none;color:white;margin-top:5px;">' . ($member['name'] ?? $id) . '</div> <div style="text-decoration:none !important;color:white !important;">' . date('j M Y', strtotime($member["date"])) . '</div> </div></div></a>'); - endforeach; ?> - </div> + endforeach; ?> </div> - </div> </div> diff --git a/pages/home.old.inc b/pages/home.old.inc new file mode 100644 index 0000000..4249947 --- /dev/null +++ b/pages/home.old.inc @@ -0,0 +1,95 @@ +<?php + +if (isset($_GET["ec"])) { + header("HTTP/1.1 " . $_GET["ec"] . " Error"); +} + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; global $readOnly; global $isNormallyLoggedIn; global $_PROFILE; global $lang; global $pages; global $isLowerLoggedIn; global $app; global $isLoggedIn; ?> + +<br> +<div class="container"> + <?php if (isset($_GET['em'])): ?> + <div class="alert alert-danger alert-dismissible"> + <button onclick='window.history.pushState({"html":null,"pageTitle":document.title},"", "/");' type="button" class="btn-close" data-bs-dismiss="alert"></button> + <b><?= $lang["home"]["error"] ?> </b><?= strip_tags(base64_decode($_GET['em'])) ?> + </div> + <?php endif; ?> + + <?php if ($readOnly && $isNormallyLoggedIn || $readOnly && $isLowerLoggedIn): ?> + <div class="alert alert-warning"> + <b>Notice: </b>This website is temporarily under maintenance and the administrators have locked the database. Although you are logged in as <?= $_PROFILE['name'] ?>, you cannot access any of the logged-in features while the website is under maintenance. <a href="/-/emergency">Alerts dispatching</a> remains possible in case of an emergency. + </div> + <?php endif; ?> + + <?php global $travelling; $byColor = getMembersByColor($_SERVER['HTTP_HOST'] === "fr.equestria.horse"); ?> + <div style="text-align: center;"> + <img alt="" src="/assets/logo/newlogo<?= $isLoggedIn || $isLowerLoggedIn ? "3" : "" ?>.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 data-bs-html="true" class="rainbow-item tooltip-nohelp" title="<b><?= $member["display_name"] ?? $member["name"] ?></b><br><?= ($travelling[$member['id']]["travelling"] ? $member["_system"] === "ynmuc" : $member["_system"] === "gdapd") ? "Raindrops System" : ($member["_system"] === "ynmuc" ? "Cloudburst System" : $app["other"]["name"]) ?>" data-bs-toggle="tooltip" style="overflow: hidden;" href="/<?= $member["name"] ?>"><img src="<?= getAsset($member["_system"], $member["id"], "heads") ?>" style="height:32px;position:absolute;z-index:99;"></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);"> + <?php foreach ($byColor as $member): ?><div> + <span style="display: inline-block;background: transparent;position:absolute;width: 0;height: 0;margin-top: 17px;box-shadow: 0 6px 20px 20px #<?= $member["color"] ?>;z-index: 9;margin-left: 8px;opacity: .75;"></span> + </div><?php endforeach; ?> + </div> + <div style="padding:5px 10px;background:#3332328a;border-bottom-left-radius: 10px;border-bottom-right-radius: 10px;position:relative;z-index: 999;backdrop-filter: blur(30px);"> + <h2 style="margin-top: 20px;">Cold Haze</h2> + <?php if ($_SERVER['HTTP_HOST'] === "fr.equestria.horse"): ?> + <p><?= count($byColor) ?> poneys dans une tête</p> + <?php else: ?> + <?php if ($isLoggedIn || $isLowerLoggedIn): ?> + <p><?= count($byColor) ?> ponies in 3 plural systems</p> + <?php else: ?> + <p><?= count($byColor) ?> <?= $lang["home"]["intro"] ?></p> + <?php endif; ?> + <?php endif; ?> + </div> + </div> + <hr style="border-color:rgba(255, 255, 255, .25);"> + + <!--<?php global $isLoggedIn; if ($isLoggedIn && ((int)date('H') >= 20 || (int)date('H') < 6)): ?> + <a href="/-/emergency" style="text-decoration: none;margin-top:15px;display:block;"> + <div class="alert alert-danger"> + <b>Are you in need of help?</b> If you need immediate help from a loved one, you may want to enable the emergency alert by clicking here, even if that wakes up the <?= $_PROFILE['name'] === "Raindrops System" ? "Cloudburst System" : "Raindrops System" ?>. Use it as you need. + </div> + </a> + <?php endif; ?>--> + + <!--<div class="alert alert-info"> + <b>Coming soon:</b> Free hosting for Project Scout (the software powering Cold Haze), so you can have your own website for your system. If you are interested and/or want to pre-register, feel free to <a href="https://equestria.horse/contact" target="_blank">contact us</a>. + </div>--> + + <div id="homepage-desktop" style="margin-top:10px;"> + + <?php cloudburst(false); ?> + <?php raindrops(false); ?> + <?php if ($isLoggedIn || $isLowerLoggedIn) other(false); ?> + + <hr> + + <div id="hpd-legacy" style="background:rgba(255, 255, 255, .1);border-radius:10px;padding:10px 10px 10px 20px;display:grid;grid-template-columns: 128px 1fr;margin-bottom:10px;"> + <a style="display:flex;margin: -10px -20px;align-items:center;justify-content:center;text-align:center;padding: 10px 20px;border-radius: 10px;background: #77777755;width: 148px;text-decoration:none;color:white;filter:none !important;" class="hpd-system"> + <div style="text-align:center;"><img src="/assets/icons/legacy.svg" style="width:64px;"><br>Pony Legacy</div> + </a> + + <div style="display:grid;grid-template-columns:repeat(6, 1fr);padding-left:10px;grid-gap:10px;"> + <?php foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/legacy"), function ($i) { + return !str_starts_with($i, "."); + }) as $id): + $id = substr($id, 0, -5); + $member = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/legacy/" . $id . ".json"), true); + + echo('<a style="text-decoration:none !important;filter:none !important;"><div class="hpd-item-card" style="background-color:rgba(255, 255, 255, .1);border:1px solid ' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';outline-color:' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';border-radius:10px;text-align:center;display:flex;align-items:center;justify-content:center;padding:5px;opacity:5;"><div> +<img alt="" src="' . $member["avatar"] . '" style="border-radius:999px;background-color:rgba(0, 0, 0, .25);height:48px;display:block;margin-left:auto;margin-right:auto;"> +<div style="text-decoration:none;color:white;margin-top:5px;">' . ($member['name'] ?? $id) . '</div> +<div style="text-decoration:none !important;color:white !important;">' . date('j M Y', strtotime($member["date"])) . '</div> +</div></div></a>'); + + endforeach; ?> + </div> + </div> + + </div> +</div> + +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?>
\ No newline at end of file diff --git a/pages/travelling.inc b/pages/travelling.inc index 2064ce1..e0fbfb1 100644 --- a/pages/travelling.inc +++ b/pages/travelling.inc @@ -165,7 +165,7 @@ global $travelling; Start travelling </button> <ul class="dropdown-menu"> - <li><a class="dropdown-item" href="?toggleTravel&member=<?= $member['id'] ?>"><img style="width:24px;border-radius:5px;" src="/assets/uploads/<?= $system === "gdapd" ? "cloudburst" : "raindrops" ?>.png"> <?= $system === "gdapd" ? "Cloudburst" : "Raindrops" ?> System</a></li> + <li><a class="dropdown-item" href="?toggleTravel&member=<?= $member['id'] ?>"><img style="width:24px;border-radius:5px;" src="<?= getAsset($system === "gdapd" ? "ynmuc" : "gdapd") ?>"> <?= $system === "gdapd" ? "Cloudburst" : "Raindrops" ?> System</a></li> <li><a class="dropdown-item" href="?toggleTravel&equestria&member=<?= $member['id'] ?>"><img style="width:24px;" src="/assets/logo/equestria.png"> Equestria</a></li> </ul> </div> |