summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/backup.inc4
-rw-r--r--includes/external/school/index.js2
-rw-r--r--includes/footer.inc2
-rw-r--r--includes/functions.inc2
-rw-r--r--includes/homepage.inc28
-rw-r--r--includes/member.inc32
-rw-r--r--includes/pane.inc2
-rw-r--r--includes/planner.inc2
-rw-r--r--includes/rainbow.inc8
-rw-r--r--includes/refresh.php14
-rw-r--r--includes/score.inc123
11 files changed, 124 insertions, 95 deletions
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">&nbsp;(<?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);