From 3d77712a9ab014635c75a33ea0f491bbda6aead3 Mon Sep 17 00:00:00 2001 From: Minteck Date: Sat, 25 Feb 2023 19:59:31 +0100 Subject: Updated 16 files and added 2 files (automated) --- includes/backup.inc | 4 +- includes/external/school/index.js | 2 +- includes/footer.inc | 2 +- includes/functions.inc | 2 + includes/homepage.inc | 28 +++++++++ includes/member.inc | 32 +--------- includes/pane.inc | 2 +- includes/planner.inc | 2 +- includes/rainbow.inc | 8 --- includes/refresh.php | 14 +++-- includes/score.inc | 123 ++++++++++++++++++++++++-------------- 11 files changed, 124 insertions(+), 95 deletions(-) create mode 100644 includes/homepage.inc (limited to 'includes') 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"; ?> © · build .
- ( 360): ?>; ; ms, 0 ? (count($refresh["restored"]) > 1 ? $lang["footer"]["failures"][0] . count($refresh["restored"]) . $lang["footer"]["failures"][1] : $lang["footer"]["failure"]) : $lang["footer"]["no_failure"] ?>) +  ( 360): ?>; ; sec)




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 @@ + +
+ + 55" class="new-homepage-system-title" id="new-homepage-system--title"> +
+ +
+
+ + + +
+Protector: ()
  • Little: ()
  • Relations count:
  • - +
  • - Score breakdown: -
  • + Score breakdown: - + 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) { } ?>)"> - + .png" alt="" style="width:32px;vertical-align: middle;margin-right:5px;"> Cold Haze 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 ""; } 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 @@ $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); -- cgit