summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/assets.inc18
-rw-r--r--includes/flags.json20
-rw-r--r--includes/functions.inc23
-rw-r--r--includes/metadata.inc4
-rw-r--r--includes/navigation.inc8
-rw-r--r--includes/refresh.php149
6 files changed, 129 insertions, 93 deletions
diff --git a/includes/assets.inc b/includes/assets.inc
index 05296ce..4f74a6e 100644
--- a/includes/assets.inc
+++ b/includes/assets.inc
@@ -1,12 +1,18 @@
<?php
+global $app;
+
if (!file_exists("../assets/avatars")) mkdir("../assets/avatars");
if (!file_exists("../assets/banners")) mkdir("../assets/banners");
if (!file_exists("../assets/heads")) mkdir("../assets/heads");
if (!file_exists("../assets/bodies")) mkdir("../assets/bodies");
-function downloadAssets($system) {
- $general = json_decode(file_get_contents("./data/$system/general.json"), true);
+function downloadAssets($system, $path = null) {
+ if (!isset($path)) {
+ $path = $system;
+ }
+
+ $general = json_decode(file_get_contents("./data/$path/general.json"), true);
if (isset($general["avatar_url"])) {
$id = preg_replace("/^([\da-f]{8})-([\da-f]{4})-([\da-f]{4})-([\da-f]{4})-([\da-f]{12})$/", "$1$2$3$4$5", $general["uuid"]);
@@ -24,7 +30,7 @@ function downloadAssets($system) {
unlink("/tmp/img." . pathinfo($general['banner'], PATHINFO_EXTENSION));
}
- $members = json_decode(file_get_contents("./data/$system/members.json"), true);
+ $members = json_decode(file_get_contents("./data/$path/members.json"), true);
foreach ($members as $member) {
$id = preg_replace("/^([\da-f]{8})-([\da-f]{4})-([\da-f]{4})-([\da-f]{4})-([\da-f]{12})$/", "$1$2$3$4$5", $general["uuid"]) . preg_replace("/^([\da-f]{8})-([\da-f]{4})-([\da-f]{4})-([\da-f]{4})-([\da-f]{12})$/", "$1$2$3$4$5", $member["uuid"]);
@@ -73,4 +79,8 @@ function downloadAssets($system) {
}
downloadAssets("gdapd");
-downloadAssets("ynmuc"); \ No newline at end of file
+downloadAssets("ynmuc");
+
+if (isset($app["other"]) && isset($app["other"]["id"]) && isset($app["other"]["token"])) {
+ downloadAssets($app["other"]["id"], "other");
+} \ No newline at end of file
diff --git a/includes/flags.json b/includes/flags.json
index c4ccfce..5bb9a91 100644
--- a/includes/flags.json
+++ b/includes/flags.json
@@ -5,20 +5,20 @@
"not_talking": null,
"median": null,
- "protector": "Protector",
- "leader": "Leader",
- "fictive": "Fictive",
+ "protector": "!!Protector",
+ "leader": "!!Leader",
+ "fictive": "!!Fictive",
"sexual_features": "Enable sexual features (for ponies below 16)",
"sexually_active": "Preemptive sexual consent",
- "robot": "Robot",
- "plush": "Plush",
+ "robot": "!!Robot",
+ "plush": "!!Plush",
"polyamorous": {
"romantic": "Polyamorous (romantic)",
"sexual": "Polyamorous (sexual)"
},
- "non_verbal": "Non verbal in real life",
- "less_frequent": "Fronts less frequently",
- "persecutor": "Persecutor",
- "pacifier": "Sleeps with pacifier",
- "not_fronting": "Not fronting regularly"
+ "non_verbal": "!!Non verbal in real life",
+ "less_frequent": "!!Fronts less frequently",
+ "not_fronting": "!!Doesn't front evenly",
+ "persecutor": "!!Persecutor",
+ "pacifier": "Sleeps with pacifier"
} \ No newline at end of file
diff --git a/includes/functions.inc b/includes/functions.inc
index 924bfae..1345db1 100644
--- a/includes/functions.inc
+++ b/includes/functions.inc
@@ -5,11 +5,14 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/bitset.inc";
if (!function_exists("getAsset")) {
function getAsset($systemID, $memberID = null, $type = "avatars") {
- if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/general.json")) {
- $id1 = preg_replace("/^([\da-f]{8})-([\da-f]{4})-([\da-f]{4})-([\da-f]{4})-([\da-f]{12})$/", "$1$2$3$4$5", json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/general.json"), true)["uuid"]);
+ $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
+ $systemFile = (isset($app["other"]) && $systemID === $app["other"]["id"]) ? "other" : $systemID;
+
+ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemFile/general.json")) {
+ $id1 = preg_replace("/^([\da-f]{8})-([\da-f]{4})-([\da-f]{4})-([\da-f]{4})-([\da-f]{12})$/", "$1$2$3$4$5", json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemFile/general.json"), true)["uuid"]);
if (isset($memberID)) {
- $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/members.json"), true);
+ $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemFile/members.json"), true);
$list = array_map(function ($i) {
return $i["id"];
}, $members);
@@ -272,16 +275,17 @@ if (!function_exists("showSubsystem")) {
if (!function_exists("showSystem")) {
function showSystem(string $id, string $name, string $color, bool $hideTitle) {
+ $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
global $travelling;
- $global = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$id/general.json"), true);
+ $global = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . (isset($app["other"]) && $id === $app["other"]["id"] ? "other" : $id) . "/general.json"), true);
if ($hideTitle) {
echo('<!-- ' . $name . ' -->
-<div id="hpd-' . ($id === "gdapd" ? "raindrops" : "cloudburst") . '" style="background:rgba(255, 255, 255, .1);border-radius:10px;padding:10px;display:grid;grid-template-columns: 1fr;margin-bottom:10px;">');
+<div id="hpd-' . ($id === "gdapd" ? "raindrops" : ($id === "ynmuc" ? "cloudburst" : "other")) . '" style="background:rgba(255, 255, 255, .1);border-radius:10px;padding:10px;display:grid;grid-template-columns: 1fr;margin-bottom:10px;">');
} else {
echo('<!-- ' . $name . ' -->
-<div id="hpd-' . ($id === "gdapd" ? "raindrops" : "cloudburst") . '" 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;">');
+<div id="hpd-' . ($id === "gdapd" ? "raindrops" : ($id === "ynmuc" ? "cloudburst" : "other")) . '" 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;">');
}
if (!$hideTitle) echo('<!-- System Name -->
<a style="display:flex;margin: -10px -20px;align-items:center;justify-content:center;text-align:center;padding: 10px 20px;border-radius: 10px;background: #' . $global['color'] . '55;width: 148px;text-decoration:none;color:white;filter:none !important;" href="/' . ($id === "gdapd" ? "raindrops" : "cloudburst") . '" class="hpd-system">
@@ -327,6 +331,13 @@ if (!function_exists("raindrops")) {
}
}
+if (!function_exists("other")) {
+ function other(bool $hideTitle): void {
+ $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
+ showSystem($app["other"]["id"], $app["other"]["name"], "#" . $app["other"]["color"] . "a6", $hideTitle);
+ }
+}
+
if (!function_exists("getMember")) {
function getMember(string $id) {
global $systemID;
diff --git a/includes/metadata.inc b/includes/metadata.inc
index d7875c5..2e009cd 100644
--- a/includes/metadata.inc
+++ b/includes/metadata.inc
@@ -144,12 +144,12 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member
foreach ($flags as $id => $name): if (!is_array($name) && !is_null($name)): ?>
<label style="margin-bottom:5px;">
<input <?= $metadata[$id] ? "checked" : "" ?> class="form-check-input" type="checkbox" name="flags[<?= $id ?>]">
- <?= $name ?>
+ <?= str_starts_with($name, "!!") ? substr($name, 2) : $name ?>
</label><br>
<?php else: foreach ($name as $id2 => $name2): ?>
<label style="margin-bottom:5px;">
<input <?= $metadata[$id][$id2] ? "checked" : "" ?> class="form-check-input" type="checkbox" name="flags[<?= $id ?>][<?= $id2 ?>]">
- <?= $name2 ?>
+ <?= str_starts_with($name2, "!!") ? substr($name2, 2) : $name2 ?>
</label><br>
<?php endforeach; endif; endforeach; ?>
diff --git a/includes/navigation.inc b/includes/navigation.inc
index 82b6046..ac40ae6 100644
--- a/includes/navigation.inc
+++ b/includes/navigation.inc
@@ -119,6 +119,14 @@ $navigation_admin = [
"link" => "/-/stats",
"stepped" => null,
"private" => true
+ ],
+ [
+ "name" => $pages["logout"]["name"][$lang["_name"]],
+ "icon" => "/assets/icons/logout.svg",
+ "invert" => true,
+ "link" => "/-/logout",
+ "stepped" => null,
+ "private" => false
]
]
],
diff --git a/includes/refresh.php b/includes/refresh.php
index ecf724a..c4eac83 100644
--- a/includes/refresh.php
+++ b/includes/refresh.php
@@ -128,119 +128,126 @@ foreach ($files as $file) {
copy("./data/" . $file, "./data/backup/" . $file);
}
-function getSystem(string $id) {
+function getSystem(string $id, string $fileName = null, string $token = null) {
global $times;
+
+ if (!isset($fileName)) {
+ $fileName = $id;
+ }
+
+ if (isset($token)) {
+ $ctx = stream_context_create([
+ 'http' => [
+ 'method' => 'GET',
+ 'header' =>
+ "Authorization: " . $token . "\r\n"
+ ]
+ ]);
+ } else {
+ $ctx = stream_context_create([
+ 'http' => [
+ 'method' => 'GET'
+ ]
+ ]);
+ }
+
echo("System: $id\n");
echo(" Base system info\n");
$currentOpStart = microtime(true);
- $data = file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id");
+ $data = file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id", false, $ctx);
if (trim($data) !== "" && $data !== false) {
- file_put_contents("./data/$id/general.json", $data);
+ file_put_contents("./data/$fileName/general.json", $data);
}
- $times["system-general-$id"] = microtime(true) - $currentOpStart;
+ $times["system-general-" . md5($id)] = microtime(true) - $currentOpStart;
echo(" System members\n");
$currentOpStart = microtime(true);
- $data = file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/members");
+ $data = file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/members", false, $ctx);
if (trim($data) !== "" && $data !== false) {
- file_put_contents("./data/$id/members.json", $data);
+ file_put_contents("./data/$fileName/members.json", $data);
}
- $times["system-members-$id"] = microtime(true) - $currentOpStart;
+ $times["system-members-" . md5($id)] = microtime(true) - $currentOpStart;
echo(" Fronters\n");
- $data = file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/fronters");
+ $data = file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/fronters", false, $ctx);
if (trim($data) !== "" && $data !== false) {
- file_put_contents("./data/$id/fronters.json", $data);
+ file_put_contents("./data/$fileName/fronters.json", $data);
}
- $times["system-fronters-$id"] = microtime(true) - $currentOpStart;
+ $times["system-fronters-" . md5($id)] = microtime(true) - $currentOpStart;
echo(" Switches\n");
$currentOpStart = microtime(true);
echo(" Part 1/6\n");
- $switches1 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/switches"), true);
- $oldest = $switches1[count($switches1) - 1]["timestamp"];
+ $switches1 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/switches", false, $ctx), true);
- echo(" Part 2/6\n");
- $switches2 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/switches?before=$oldest"), true);
- $oldest = $switches2[count($switches2) - 1]["timestamp"];
+ if (count($switches1) > 0) {
+ $oldest = $switches1[count($switches1) - 1]["timestamp"];
- echo(" Part 3/6\n");
- $switches3 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/switches?before=$oldest"), true);
- $oldest = $switches3[count($switches3) - 1]["timestamp"];
+ echo(" Part 2/6\n");
+ $switches2 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/switches?before=$oldest", false, $ctx), true);
- echo(" Part 4/6\n");
- $switches4 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/switches?before=$oldest"), true);
- $oldest = $switches4[count($switches4) - 1]["timestamp"];
+ if (count($switches2) > 0) {
+ $oldest = $switches2[count($switches2) - 1]["timestamp"];
- echo(" Part 5/6\n");
- $switches5 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/switches?before=$oldest"), true);
- $oldest = $switches5[count($switches5) - 1]["timestamp"];
+ echo(" Part 3/6\n");
+ $switches3 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/switches?before=$oldest", false, $ctx), true);
- echo(" Part 6/6\n");
- $switches6 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/switches?before=$oldest"), true);
-
- if ($switches1 !== null && $switches2 !== null && $switches3 !== null && $switches4 !== null && $switches5 !== null && $switches6 !== null) {
- file_put_contents("./data/$id/switches.json", json_encode([...$switches1, ...$switches2, ...$switches3, ...$switches4, ...$switches5, ...$switches6], JSON_PRETTY_PRINT));
- $times["system-switches-$id"] = microtime(true) - $currentOpStart;
- }
-}
+ if (count($switches3) > 0) {
+ $oldest = $switches3[count($switches3) - 1]["timestamp"];
-getSystem("gdapd"); // Raindrops
-getSystem("ynmuc"); // Cloudburst
+ echo(" Part 4/6\n");
+ $switches4 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/switches?before=$oldest", false, $ctx), true);
-echo("Calendar\n");
-$currentOpStart = microtime(true);
-file_put_contents("./data/calendar/calendar.ics", file_get_contents($app["calendar"]));
-$times["calendar"] = microtime(true) - $currentOpStart;
+ if (count($switches4) > 0) {
+ $oldest = $switches4[count($switches4) - 1]["timestamp"];
-echo("Downloading images.\n");
-if (!file_exists("./data/images")) mkdir("./data/images");
+ echo(" Part 5/6\n");
+ $switches5 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/switches?before=$oldest", false, $ctx), true);
-foreach (json_decode(file_get_contents("./data/gdapd/members.json"), true) as $member) {
- $currentOpStart2 = microtime(true);
- echo(" " . $member['id'] . "\n");
+ if (count($switches5) > 0) {
+ $oldest = $switches5[count($switches5) - 1]["timestamp"];
- if (isset($member['avatar_url'])) {
- echo(" Profile picture\n");
- file_put_contents("/tmp/img." . pathinfo($member['avatar_url'], PATHINFO_EXTENSION), file_get_contents($member['avatar_url']));
- exec("convert -resize 128x128 -quality 50 \"" . "/tmp/img." . pathinfo($member['avatar_url'], PATHINFO_EXTENSION) . "\" \"./data/images/pf-gdapd-" . $member['id'] . ".webp\"");
- unlink("/tmp/img." . pathinfo($member['avatar_url'], PATHINFO_EXTENSION));
+ echo(" Part 6/6\n");
+ $switches6 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/switches?before=$oldest", false, $ctx), true);
+ } else {
+ $switches6 = [];
+ }
+ } else {
+ $switches5 = $switches6 = [];
+ }
+ } else {
+ $switches4 = $switches5 = $switches6 = [];
+ }
+ } else {
+ $switches3 = $switches4 = $switches5 = $switches6 = [];
+ }
+ } else {
+ $switches2 = $switches3 = $switches4 = $switches5 = $switches6 = [];
}
- echo(" Pony Town character\n");
- if (file_exists("../assets/uploads/pt-" . $member['name'] . ".png")) {
- exec("convert -resize 64x64 -quality 50 \"../assets/uploads/pt-" . $member['name'] . ".png\" \"./data/images/pt-gdapd-" . $member['id'] . ".png\"");
- } else {
- exec("convert -resize 64x64 -quality 50 \"../assets/uploads/pt.png\" \"./data/images/pt-gdapd-" . $member['id'] . ".png\"");
+ if ($switches1 !== null && $switches2 !== null && $switches3 !== null && $switches4 !== null && $switches5 !== null && $switches6 !== null) {
+ file_put_contents("./data/$fileName/switches.json", json_encode([...$switches1, ...$switches2, ...$switches3, ...$switches4, ...$switches5, ...$switches6], JSON_PRETTY_PRINT));
+ $times["system-switches-" . md5($id)] = microtime(true) - $currentOpStart;
}
- $times["images-gdapd-" . $member['id']] = microtime(true) - $currentOpStart2;
}
-foreach (json_decode(file_get_contents("./data/ynmuc/members.json"), true) as $member) {
- $currentOpStart2 = microtime(true);
- echo(" " . $member['id'] . "\n");
-
- if (isset($member['avatar_url'])) {
- echo(" Profile picture\n");
- file_put_contents("/tmp/img." . pathinfo($member['avatar_url'], PATHINFO_EXTENSION), file_get_contents($member['avatar_url']));
- exec("convert -resize 128x128 -quality 50 \"" . "/tmp/img." . pathinfo($member['avatar_url'], PATHINFO_EXTENSION) . "\" \"./data/images/pf-ynmuc-" . $member['id'] . ".webp\"");
- unlink("/tmp/img." . pathinfo($member['avatar_url'], PATHINFO_EXTENSION));
- }
+getSystem("gdapd"); // Raindrops
+getSystem("ynmuc"); // Cloudburst
- echo(" Pony Town character\n");
- if (file_exists("../assets/uploads/pt-" . $member['name'] . ".png")) {
- exec("convert -resize 64x64 -quality 50 \"../assets/uploads/pt-" . $member['name'] . ".png\" \"./data/images/pt-ynmuc-" . $member['id'] . ".png\"");
- } else {
- exec("convert -resize 64x64 -quality 50 \"../assets/uploads/pt.png\" \"./data/images/pt-ynmuc-" . $member['id'] . ".png\"");
- }
- $times["images-ynmuc-" . $member['id']] = microtime(true) - $currentOpStart2;
+if (isset($app["other"]) && isset($app["other"]["id"]) && isset($app["other"]["token"])) {
+ getSystem($app["other"]["id"], "other", $app["other"]["token"]);
}
+echo("Calendar\n");
+$currentOpStart = microtime(true);
+file_put_contents("./data/calendar/calendar.ics", file_get_contents($app["calendar"]));
+$times["calendar"] = microtime(true) - $currentOpStart;
+
echo("Backing up...\n");
$lastBackup = (int)trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/backup.txt"));