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) --- assets/logo/custom.css | 46 +++++++++++++- assets/logo/newlogo3-template.png | Bin 40569 -> 38736 bytes assets/logo/newlogo3.png | Bin 5606 -> 5653 bytes 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 ++++++++++++++++++++++++-------------- pages/api/fronter.php | 71 +++++++++++++--------- pages/home.inc | 55 +++++++---------- pages/home.old.inc | 95 +++++++++++++++++++++++++++++ pages/travelling.inc | 2 +- 18 files changed, 328 insertions(+), 160 deletions(-) create mode 100644 includes/homepage.inc create mode 100644 pages/home.old.inc 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 index a462f45..bec8d1b 100644 Binary files a/assets/logo/newlogo3-template.png and b/assets/logo/newlogo3-template.png differ diff --git a/assets/logo/newlogo3.png b/assets/logo/newlogo3.png index 502543b..28ff3e1 100644 Binary files a/assets/logo/newlogo3.png and b/assets/logo/newlogo3.png differ 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); 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
    .png" style="width:128px;">

    -
    " data-bs-toggle="tooltip" style="overflow: hidden;" href="/">" style="height:32px;position:absolute;z-index:99;">
    + " style="height:32px;position:absolute;z-index:99;">

    -
    +
    ;z-index: 9;margin-left: 8px;opacity: .75;">
    @@ -45,50 +45,37 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; require_once $_SE
    -
    - - - - -
    +
    - - - +
    style="grid-template-columns: repeat(3, 1fr);"> + + + +
    -
    +
    -
    - -

    Pony Legacy
    -
    + 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 @@ + + +
    +
    + +
    + + +
    + + + +
    + 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. +
    + + + +
    + .png" style="width:128px;"> +

    +
    " data-bs-toggle="tooltip" style="overflow: hidden;" href="/">" style="height:32px;position:absolute;z-index:99;">
    +

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

    Cold Haze

    + +

    poneys dans une tête

    + + +

    ponies in 3 plural systems

    + +

    + + +
    +
    +
    + + + + + +
    + + + + + +
    + +
    + +

    Pony Legacy
    +
    + +
    +
    + +
    ' . ($member['name'] ?? $id) . '
    +
    ' . date('j M Y', strtotime($member["date"])) . '
    +
    '); + + endforeach; ?> +
    +
    + +
    +
    + + \ 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
    -- cgit