diff options
author | Minteck <contact@minteck.org> | 2023-02-22 20:45:15 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2023-02-22 20:45:15 +0100 |
commit | 737f5008f8a4a011c832e83f6b2019d3dc27dbd0 (patch) | |
tree | 1039c5acc74159587f48fe1c513b796b9c6abbfb | |
parent | 1ff917767cca089a87f4e06a676c48ed132c2a73 (diff) | |
download | pluralconnect-737f5008f8a4a011c832e83f6b2019d3dc27dbd0.tar.gz pluralconnect-737f5008f8a4a011c832e83f6b2019d3dc27dbd0.tar.bz2 pluralconnect-737f5008f8a4a011c832e83f6b2019d3dc27dbd0.zip |
Updated 8 files (automated)
-rw-r--r-- | api/pluralkit-integration.php | 125 | ||||
-rw-r--r-- | includes/assets.inc | 18 | ||||
-rw-r--r-- | includes/flags.json | 20 | ||||
-rw-r--r-- | includes/functions.inc | 23 | ||||
-rw-r--r-- | includes/metadata.inc | 4 | ||||
-rw-r--r-- | includes/navigation.inc | 8 | ||||
-rw-r--r-- | includes/refresh.php | 149 | ||||
-rw-r--r-- | pages/home.inc | 3 |
8 files changed, 207 insertions, 143 deletions
diff --git a/api/pluralkit-integration.php b/api/pluralkit-integration.php index a0368e4..0793873 100644 --- a/api/pluralkit-integration.php +++ b/api/pluralkit-integration.php @@ -2,6 +2,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/agewarning.inc"; +$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); $user = $_GET['user'] ?? null; $inputJSON = file_get_contents('php://input'); $input = json_decode($inputJSON, true); @@ -28,16 +29,38 @@ if ($input["signing_token"] !== $data[$user]) { if ($input['system_id'] === "7d9f543e-f742-40f6-9d07-86c3f2983124") { $system = "gdapd"; $name = "Raindrops System"; -} else { +} elseif ($input['system_id'] === "ade46823-206b-4b0c-ad3c-caae934a5f3b") { $system = "ynmuc"; $name = "Cloudburst System"; +} elseif (isset($app["other"]) && $input["system_id"] === $app["other"]["uuid"]) { + $system = $app["other"]["id"]; + $name = $app["other"]["name"]; +} else { + die(); } $lastFronter = json_decode(@file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/last.json"), true) ?? ""; if ($input["type"] === "CREATE_SWITCH" || $input["type"] === "UPDATE_SWITCH" || $input["type"] === "DELETE_SWITCH") { - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json", file_get_contents("https://pluralkit.equestria.dev/v2/systems/$input[system_id]/fronters")); - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json", file_get_contents("https://pluralkit.equestria.dev/v2/systems/$input[system_id]/switches")); + if ($system === $app["other"]["id"]) { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json", file_get_contents("https://pluralkit.equestria.dev/v2/systems/$input[system_id]/fronters"), false, stream_context_create([ + 'http' => [ + 'method' => 'GET', + 'header' => + "Authorization: " . $app["other"]["token"] . "\r\n" + ] + ])); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json", file_get_contents("https://pluralkit.equestria.dev/v2/systems/$input[system_id]/switches"), false, stream_context_create([ + 'http' => [ + 'method' => 'GET', + 'header' => + "Authorization: " . $app["other"]["token"] . "\r\n" + ] + ])); + } else { + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json", file_get_contents("https://pluralkit.equestria.dev/v2/systems/$input[system_id]/fronters")); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json", file_get_contents("https://pluralkit.equestria.dev/v2/systems/$input[system_id]/switches")); + } $fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true); $currentFronter = $fronters["members"][0]["id"]; @@ -45,7 +68,7 @@ if ($input["type"] === "CREATE_SWITCH" || $input["type"] === "UPDATE_SWITCH" || $ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"]; - if (count($fronters["members"]) > 0) { + if (count($fronters["members"]) > 0 && ($system !== $app["other"]["id"] || !isset($app["other"]))) { foreach ($fronters["members"] as $member) { if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member["id"] . ".json")) { $metadata = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member["id"] . ".json"), true); @@ -63,51 +86,53 @@ if ($input["type"] === "CREATE_SWITCH" || $input["type"] === "UPDATE_SWITCH" || } } - if (count($fronters["members"]) > 1) { - $context = stream_context_create([ - 'http' => [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: 🐴 Switch occurred in the $name\r\n" . - "Priority: default\r\n" . - "Tags: switch\r\n" . - "Actions: view, Open " . $fronters["members"][0]["display_name"] . " on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][0]["name"] . "/, clear=true;view, Open " . $fronters["members"][1]["display_name"] . " on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][1]["name"] . "/, clear=true\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => ($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " and " . ($fronters["members"][1]["display_name"] ?? $fronters["members"][1]["name"]) . " switched in just now" - ] - ]); - } else if (count($fronters["members"]) > 0) { - $context = stream_context_create([ - 'http' => [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: 🐴 Switch occurred in the $name\r\n" . - "Priority: default\r\n" . - "Tags: switch\r\n" . - "Actions: view, Open on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][0]["name"] . "/, clear=true\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => ($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " switched in just now" - ] - ]); - } else { - $context = stream_context_create([ - 'http' => [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: 🐴 Switch occurred in the $name\r\n" . - "Priority: default\r\n" . - "Tags: switch\r\n" . - "Actions: view, Open on Cold Haze, https://ponies.equestria.horse/, clear=true\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => "The fallback pony switched in just now" - ] - ]); - } + if ($system !== $app["other"]["id"] || !isset($app["other"])) { + if (count($fronters["members"]) > 1) { + $context = stream_context_create([ + 'http' => [ + 'method' => 'POST', + 'header' => + "Content-Type: text/plain\r\n" . + "Title: 🐴 Switch occurred in the $name\r\n" . + "Priority: default\r\n" . + "Tags: switch\r\n" . + "Actions: view, Open " . $fronters["members"][0]["display_name"] . " on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][0]["name"] . "/, clear=true;view, Open " . $fronters["members"][1]["display_name"] . " on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][1]["name"] . "/, clear=true\r\n" . + "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), + 'content' => ($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " and " . ($fronters["members"][1]["display_name"] ?? $fronters["members"][1]["name"]) . " switched in just now" + ] + ]); + } else if (count($fronters["members"]) > 0) { + $context = stream_context_create([ + 'http' => [ + 'method' => 'POST', + 'header' => + "Content-Type: text/plain\r\n" . + "Title: 🐴 Switch occurred in the $name\r\n" . + "Priority: default\r\n" . + "Tags: switch\r\n" . + "Actions: view, Open on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][0]["name"] . "/, clear=true\r\n" . + "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), + 'content' => ($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " switched in just now" + ] + ]); + } else { + $context = stream_context_create([ + 'http' => [ + 'method' => 'POST', + 'header' => + "Content-Type: text/plain\r\n" . + "Title: 🐴 Switch occurred in the $name\r\n" . + "Priority: default\r\n" . + "Tags: switch\r\n" . + "Actions: view, Open on Cold Haze, https://ponies.equestria.horse/, clear=true\r\n" . + "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), + 'content' => "The fallback pony switched in just now" + ] + ]); + } - file_get_contents('https://' . $ntfy["server"] . '/public-switches', false, $context); + file_get_contents('https://' . $ntfy["server"] . '/public-switches', false, $context); + } if ($system === "gdapd") { $topic = "public-switches-raindrops"; @@ -141,8 +166,10 @@ if ($input["type"] === "CREATE_SWITCH" || $input["type"] === "UPDATE_SWITCH" || ] ])); } - } else { + } else if ($system === "ynmuc") { $topic = "public-switches-cloudburst"; + } else { + $topic = "main"; } file_get_contents('https://' . $ntfy["server"] . '/' . $topic, false, $context); 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")); diff --git a/pages/home.inc b/pages/home.inc index 464900f..44c8d7e 100644 --- a/pages/home.inc +++ b/pages/home.inc @@ -1,4 +1,4 @@ -<?php if (isset($_GET['error'])) header("HTTP/1.1 404 Not Found"); require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; global $readOnly; global $isNormallyLoggedIn; global $_PROFILE; global $lang; global $pages; ?> +<?php if (isset($_GET['error'])) header("HTTP/1.1 404 Not Found"); require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; global $readOnly; global $isNormallyLoggedIn; global $_PROFILE; global $lang; global $pages; global $isLowerLoggedIn; ?> <br> <div class="container"> @@ -53,6 +53,7 @@ <?php if ($_SERVER['HTTP_HOST'] !== "fr.equestria.horse") cloudburst(false); ?> <?php raindrops(false); ?> + <?php if ($isLoggedIn || $isLowerLoggedIn) other(false); ?> <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"> |