summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-03-27 22:22:53 +0200
committerRaindropsSys <contact@minteck.org>2023-03-27 22:22:53 +0200
commite98e95d89939cdc1252d02df04ae8d91c6aa8c92 (patch)
treea5d5535f8058f1a7b45a31a1caf36ab7e24ff19d
parent6ab243c12f2514cd0f40e80504223664755a6da4 (diff)
downloadpluralconnect-e98e95d89939cdc1252d02df04ae8d91c6aa8c92.tar.gz
pluralconnect-e98e95d89939cdc1252d02df04ae8d91c6aa8c92.tar.bz2
pluralconnect-e98e95d89939cdc1252d02df04ae8d91c6aa8c92.zip
Updated 9 files, added 9 files, deleted 3 files and renamed includes/refresh/logo.inc (automated)
-rw-r--r--includes/components/footer.inc3
-rw-r--r--includes/components/planner.inc8
-rw-r--r--includes/external/jobs/index.js102
-rw-r--r--includes/jobs/CleanupDocs.php25
-rw-r--r--includes/jobs/FrontersNotification.php101
-rw-r--r--includes/jobs/PKFronters.php31
-rw-r--r--includes/jobs/PKMembers.php48
-rw-r--r--includes/jobs/PKSwitches.php77
-rw-r--r--includes/jobs/PKSystem.php31
-rw-r--r--includes/jobs/UpdateAssets.php99
-rw-r--r--includes/jobs/UpdateLogo.php (renamed from includes/refresh/logo.inc)5
-rw-r--r--includes/pages.json10
-rw-r--r--includes/refresh.php224
-rw-r--r--includes/refresh/assets.inc86
-rw-r--r--includes/refresh/cleanup.inc24
-rw-r--r--includes/util/functions.inc13
-rw-r--r--pages/api/docs.php4
-rw-r--r--pages/api/pluralkit-integration.php127
-rw-r--r--pages/api/ponytown.php4
-rw-r--r--pages/computers.inc13
-rw-r--r--pages/debug.inc117
-rw-r--r--pages/jobs.inc123
22 files changed, 735 insertions, 540 deletions
diff --git a/includes/components/footer.inc b/includes/components/footer.inc
index 2cef58f..d75b480 100644
--- a/includes/components/footer.inc
+++ b/includes/components/footer.inc
@@ -17,8 +17,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc";
global $lang; global $pages;
?>
- © <?= date("Y") ?> <a href="https://equestria.horse" target="_blank" class="text-muted"><?= $lang["footer"]["copyright"] ?></a> · build <?= $version["build"] ?>.<?= $version["revision"] ?><br>
- <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>
+ © <?= date("Y") ?> <a href="https://equestria.horse" target="_blank" class="text-muted"><?= $lang["footer"]["copyright"] ?></a> · build <?= $version["build"] ?>.<?= $version["revision"] ?>
<br><br><br><br><br>
</div>
</div>
diff --git a/includes/components/planner.inc b/includes/components/planner.inc
index a7ec44f..9be9cb7 100644
--- a/includes/components/planner.inc
+++ b/includes/components/planner.inc
@@ -122,11 +122,11 @@ function school($time, $first = false) {
if (isset($school[$day])) {
if (isset($school[$day]["wakeUp"]["timestamp"])) {
- $parts[] = "waking up at " . formatTime($school[$day]["wakeUp"][$_PROFILE["login"]]) . " (your time)";
+ $parts[] = "waking up at " . formatTime($school[$day]["wakeUp"][$_PROFILE["login"]]);
}
if (isset($school[$day]["sleep"]["timestamp"])) {
- $parts[] = "sleeping at " . formatTime($school[$day]["sleep"][$_PROFILE["login"]]) . " (your time)";
+ $parts[] = "sleeping at " . formatTime($school[$day]["sleep"][$_PROFILE["login"]]);
}
}
@@ -136,7 +136,7 @@ function school($time, $first = false) {
if ($first) {
return ucfirst(implode(", ", $parts));
} else {
- return " · " . implode(", ", $parts);
+ return "<br>" . ucfirst(implode(", ", $parts));
}
} else {
if ($first) {
@@ -278,7 +278,7 @@ function day($display, $diff): void { if ($diff < 0) $disabled = true; else $dis
<td colspan="10" style="padding: 0;border:none;">
<div style="padding: 5px 10px;border: 1px solid #404040;margin:-1px;border-bottom-left-radius: 10px;border-bottom-right-radius: 10px;">
<?php if (count($dayCloudburst) > 0 && count($dayRaindrops) > 0): ?>
- <?= getMiniName(getMemberWithoutSystem($dayCloudburst[count($dayCloudburst) - 1][0])["display_name"] ?? getMemberWithoutSystem($dayCloudburst[count($dayCloudburst) - 1][0])["name"]) ?> will sleep with <?= getMiniName(getMemberWithoutSystem($dayRaindrops[count($dayRaindrops) - 1][0])["display_name"] ?? getMemberWithoutSystem($dayRaindrops[count($dayRaindrops) - 1][0])["name"]) ?><?= school(time() + 86400 * $diff, false) ?>
+ <?= getMemberWithoutSystem($dayCloudburst[count($dayCloudburst) - 1][0])["display_name"] ?? getMemberWithoutSystem($dayCloudburst[count($dayCloudburst) - 1][0])["name"] ?> will sleep with <?= getMemberWithoutSystem($dayRaindrops[count($dayRaindrops) - 1][0])["display_name"] ?? getMemberWithoutSystem($dayRaindrops[count($dayRaindrops) - 1][0])["name"] ?><?= school(time() + 86400 * $diff, false) ?>
<?php else: ?>
<?= school(time() + 86400 * $diff, true) ?>
<?php endif; ?>
diff --git a/includes/external/jobs/index.js b/includes/external/jobs/index.js
new file mode 100644
index 0000000..aa84db9
--- /dev/null
+++ b/includes/external/jobs/index.js
@@ -0,0 +1,102 @@
+const fs = require('fs');
+const child_process = require('child_process');
+
+// TODO: Jobs history
+
+let jobs = require('../../data/jobs.json');
+let history = require('../../data/history.json');
+
+setInterval(() => {
+ if (JSON.stringify(JSON.parse(fs.readFileSync("../../data/jobs.json").toString())) !== JSON.stringify(jobs)) {
+ console.log("Updating the jobs list...");
+ jobs = JSON.parse(fs.readFileSync("../../data/jobs.json").toString());
+ }
+}, 1000);
+
+setTimeout(() => {
+ setInterval(() => {
+ if (jobs.length > 0) {
+ let pickup = new Date();
+
+ console.log(jobs.length + " job(s)");
+ console.log("\nRunning jobs:");
+
+ for (let job of jobs) {
+ console.log(" " + job.name);
+ let output;
+ let start;
+ let end;
+
+ try {
+ start = new Date();
+ output = child_process.execFileSync("php", [job.name + ".php", JSON.stringify(job.options)], { cwd: "../../jobs" });
+ end = new Date();
+
+ let runtime = end.getTime() - start.getTime();
+ let description = "";
+
+ for (let name of Object.keys(job.options)) {
+ description = "," + name + "=" + JSON.stringify(job.options[name]);
+ }
+
+ jobs.splice(jobs.indexOf(job), 1);
+ fs.writeFileSync("../../data/jobs.json", JSON.stringify(jobs));
+
+ history.unshift({
+ completed: true,
+ error: null,
+ options: job.options,
+ name: job.name + "(" + description.substring(1) + ")",
+ output: output.toString(),
+ time: runtime,
+ tracking: {
+ queue: new Date(job.date).toISOString(),
+ pickup: pickup.toISOString(),
+ start: start.toISOString(),
+ end: end.toISOString(),
+ logged: new Date().toISOString()
+ }
+ });
+
+ history = history.slice(0, 200);
+ fs.writeFileSync("../../data/history.json", JSON.stringify(history));
+ } catch (e) {
+ end = start ? new Date() : null;
+ console.log(" Failed to process job");
+ console.error(e);
+
+ let runtime = end ? (start ? end.getTime() - start.getTime() : null) : null;
+ let description = "";
+
+ for (let name of Object.keys(job.options)) {
+ description = "," + name + "=" + JSON.stringify(job.options[name]);
+ }
+
+ jobs.splice(jobs.indexOf(job), 1);
+ fs.writeFileSync("../../data/jobs.json", JSON.stringify(jobs));
+
+ history.unshift({
+ completed: false,
+ error: e.stack,
+ options: job.options,
+ name: job.name + "(" + description.substring(1) + ")",
+ output: (output ?? e.stdout ?? e.stderr).toString(),
+ time: runtime,
+ tracking: {
+ queue: new Date(job.date).toISOString(),
+ pickup: pickup.toISOString(),
+ start: start ? start.toISOString() : null,
+ end: end ? end.toISOString() : null,
+ logged: new Date().toISOString()
+ }
+ });
+
+ history = history.slice(0, 200);
+ fs.writeFileSync("../../data/history.json", JSON.stringify(history));
+ }
+ }
+
+ console.log("\nCompleted");
+ }
+ }, 1000);
+}, 500); \ No newline at end of file
diff --git a/includes/jobs/CleanupDocs.php b/includes/jobs/CleanupDocs.php
new file mode 100644
index 0000000..70f37b9
--- /dev/null
+++ b/includes/jobs/CleanupDocs.php
@@ -0,0 +1,25 @@
+<?php
+
+$options = json_decode($argv[1], true);
+$_SERVER['DOCUMENT_ROOT'] = "../..";
+require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/composer/vendor/autoload.php';
+use ColorThief\ColorThief;
+
+$documents = array_map(function ($i) {
+ return [
+ "id" => substr($i, 0, -5),
+ ...(json_decode(file_get_contents("./data/docs/" . $i), true) ?? [])
+ ];
+}, array_filter(scandir("./data/docs"), function ($i) {
+ return !str_starts_with($i, ".") && str_ends_with($i, ".json");
+}));
+
+$deletable = array_values(array_filter($documents, function ($i) {
+ return str_starts_with(strip_tags($i["contents"]), "/delete");
+}));
+
+foreach ($deletable as $item) {
+ if (time() - $item["last"]["date"] > 86400) {
+ unlink("./data/docs/" . $item["id"] . ".json");
+ }
+} \ No newline at end of file
diff --git a/includes/jobs/FrontersNotification.php b/includes/jobs/FrontersNotification.php
new file mode 100644
index 0000000..d95f273
--- /dev/null
+++ b/includes/jobs/FrontersNotification.php
@@ -0,0 +1,101 @@
+<?php
+
+$options = json_decode($argv[1], true);
+$_SERVER['DOCUMENT_ROOT'] = "../..";
+require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/composer/vendor/autoload.php';
+use ColorThief\ColorThief;
+
+$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
+$system = $options["system"];
+
+if ($system === "gdapd") {
+ $name = "Raindrops System";
+} elseif ($system === "ynmuc") {
+ $name = "Cloudburst System";
+} elseif (isset($app["other"]) && $system === $app["other"]["id"]) {
+ $name = $app["other"]["name"];
+} else {
+ die();
+}
+
+$fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true);
+$currentFronter = $fronters["members"][0]["id"];
+file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/last.json", json_encode($currentFronter));
+
+$ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"];
+
+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);
+
+ if (!isset($metadata["birth"])) {
+ showWarning($member["display_name"] ?? $member["name"], $member["name"], $system);
+ } else if (isset($metadata['birth']["age"]) && $metadata["birth"]["age"] === 0 && (!isset($metadata['birth']["year"]) || $metadata["birth"]["year"] < 1900)) {
+ showWarning($member["display_name"] ?? $member["name"], $member["name"], $system);
+ } else if (isset($metadata['birth']["year"]) && $metadata["birth"]["year"] < 1900) {
+ showWarning($member["display_name"] ?? $member["name"], $member["name"], $system);
+ } else if (!isset($metadata['birth']["year"]) && !isset($metadata['birth']["age"])) {
+ showWarning($member["display_name"] ?? $member["name"], $member["name"], $system);
+ }
+ }
+ }
+}
+
+if (count($fronters["members"]) > 1) {
+ $context = stream_context_create([
+ 'http' => [
+ 'method' => 'POST',
+ 'header' =>
+ "Content-Type: text/plain\r\n" .
+ "Title: 🐴 Switch occurred in $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 $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 $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"])) {
+ file_get_contents('https://' . $ntfy["server"] . '/public-switches', false, $context);
+}
+
+if ($system === "gdapd") {
+ $topic = "public-switches-raindrops";
+} else if ($system === "ynmuc") {
+ $topic = "public-switches-cloudburst";
+} else {
+ $topic = "main";
+}
+
+file_get_contents('https://' . $ntfy["server"] . '/' . $topic, false, $context); \ No newline at end of file
diff --git a/includes/jobs/PKFronters.php b/includes/jobs/PKFronters.php
new file mode 100644
index 0000000..2649b7d
--- /dev/null
+++ b/includes/jobs/PKFronters.php
@@ -0,0 +1,31 @@
+<?php
+
+$options = json_decode($argv[1], true);
+$_SERVER['DOCUMENT_ROOT'] = "../..";
+require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/composer/vendor/autoload.php';
+use ColorThief\ColorThief;
+
+$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
+$system = $options["system"];
+
+if ($app["other"]["id"] === $system) {
+ $ctx = stream_context_create([
+ 'http' => [
+ 'method' => 'GET',
+ 'header' =>
+ "Authorization: " . $app["other"]["token"] . "\r\n"
+ ]
+ ]);
+} else {
+ $ctx = stream_context_create([
+ 'http' => [
+ 'method' => 'GET'
+ ]
+ ]);
+}
+
+$data = file_get_contents("https://pluralkit.equestria.dev/v2/systems/$system/fronters", false, $ctx);
+
+if (trim($data) !== "" && $data !== false) {
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json", $data);
+} \ No newline at end of file
diff --git a/includes/jobs/PKMembers.php b/includes/jobs/PKMembers.php
new file mode 100644
index 0000000..529a820
--- /dev/null
+++ b/includes/jobs/PKMembers.php
@@ -0,0 +1,48 @@
+<?php
+
+$options = json_decode($argv[1], true);
+$_SERVER['DOCUMENT_ROOT'] = "../..";
+require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/composer/vendor/autoload.php';
+use ColorThief\ColorThief;
+
+$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
+$system = $options["system"];
+
+if ($app["other"]["id"] === $system) {
+ $ctx = stream_context_create([
+ 'http' => [
+ 'method' => 'GET',
+ 'header' =>
+ "Authorization: " . $app["other"]["token"] . "\r\n"
+ ]
+ ]);
+} else {
+ $ctx = stream_context_create([
+ 'http' => [
+ 'method' => 'GET'
+ ]
+ ]);
+}
+
+$data = file_get_contents("https://pluralkit.equestria.dev/v2/systems/$system/members", false, $ctx);
+
+if (trim($data) !== "" && $data !== false) {
+ $parsed = json_decode($data, true);
+
+ foreach ($parsed as $index => $member) {
+ 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;
+ }
+ }
+
+ $data = json_encode($parsed, JSON_PRETTY_PRINT);
+ file_put_contents("./data/$system/members.json", $data);
+} \ No newline at end of file
diff --git a/includes/jobs/PKSwitches.php b/includes/jobs/PKSwitches.php
new file mode 100644
index 0000000..eb7d897
--- /dev/null
+++ b/includes/jobs/PKSwitches.php
@@ -0,0 +1,77 @@
+<?php
+
+$options = json_decode($argv[1], true);
+$_SERVER['DOCUMENT_ROOT'] = "../..";
+require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/composer/vendor/autoload.php';
+use ColorThief\ColorThief;
+
+$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
+$system = $options["system"];
+
+if ($app["other"]["id"] === $system) {
+ $ctx = stream_context_create([
+ 'http' => [
+ 'method' => 'GET',
+ 'header' =>
+ "Authorization: " . $app["other"]["token"] . "\r\n"
+ ]
+ ]);
+} else {
+ $ctx = stream_context_create([
+ 'http' => [
+ 'method' => 'GET'
+ ]
+ ]);
+}
+
+echo(" Part 1/6\n");
+$switches1 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$system/switches", false, $ctx), true);
+
+if (count($switches1) > 0) {
+ $oldest = $switches1[count($switches1) - 1]["timestamp"];
+
+ echo(" Part 2/6\n");
+ $switches2 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$system/switches?before=$oldest", false, $ctx), true);
+
+ if (count($switches2) > 0) {
+ $oldest = $switches2[count($switches2) - 1]["timestamp"];
+
+ echo(" Part 3/6\n");
+ $switches3 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$system/switches?before=$oldest", false, $ctx), true);
+
+ if (count($switches3) > 0) {
+ $oldest = $switches3[count($switches3) - 1]["timestamp"];
+
+ echo(" Part 4/6\n");
+ $switches4 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$system/switches?before=$oldest", false, $ctx), true);
+
+ if (count($switches4) > 0) {
+ $oldest = $switches4[count($switches4) - 1]["timestamp"];
+
+ echo(" Part 5/6\n");
+ $switches5 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$system/switches?before=$oldest", false, $ctx), true);
+
+ if (count($switches5) > 0) {
+ $oldest = $switches5[count($switches5) - 1]["timestamp"];
+
+ echo(" Part 6/6\n");
+ $switches6 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$system/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 = [];
+}
+
+if ($switches1 !== null && $switches2 !== null && $switches3 !== null && $switches4 !== null && $switches5 !== null && $switches6 !== null) {
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json", json_encode([...$switches1, ...$switches2, ...$switches3, ...$switches4, ...$switches5, ...$switches6], JSON_PRETTY_PRINT));
+} \ No newline at end of file
diff --git a/includes/jobs/PKSystem.php b/includes/jobs/PKSystem.php
new file mode 100644
index 0000000..c3fce1b
--- /dev/null
+++ b/includes/jobs/PKSystem.php
@@ -0,0 +1,31 @@
+<?php
+
+$options = json_decode($argv[1], true);
+$_SERVER['DOCUMENT_ROOT'] = "../..";
+require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/composer/vendor/autoload.php';
+use ColorThief\ColorThief;
+
+$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
+$system = $options["system"];
+
+if ($app["other"]["id"] === $system) {
+ $ctx = stream_context_create([
+ 'http' => [
+ 'method' => 'GET',
+ 'header' =>
+ "Authorization: " . $app["other"]["token"] . "\r\n"
+ ]
+ ]);
+} else {
+ $ctx = stream_context_create([
+ 'http' => [
+ 'method' => 'GET'
+ ]
+ ]);
+}
+
+$data = file_get_contents("https://pluralkit.equestria.dev/v2/systems/$system", false, $ctx);
+
+if (trim($data) !== "" && $data !== false) {
+ file_put_contents("./data/$system/general.json", $data);
+} \ No newline at end of file
diff --git a/includes/jobs/UpdateAssets.php b/includes/jobs/UpdateAssets.php
new file mode 100644
index 0000000..8898b94
--- /dev/null
+++ b/includes/jobs/UpdateAssets.php
@@ -0,0 +1,99 @@
+<?php
+
+$options = json_decode($argv[1], true);
+$_SERVER['DOCUMENT_ROOT'] = "../..";
+require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/composer/vendor/autoload.php';
+use ColorThief\ColorThief;
+
+$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
+
+if (!file_exists("" . $_SERVER['DOCUMENT_ROOT'] . "/assets/avatars")) mkdir("" . $_SERVER['DOCUMENT_ROOT'] . "/assets/avatars");
+if (!file_exists("" . $_SERVER['DOCUMENT_ROOT'] . "/assets/banners")) mkdir("" . $_SERVER['DOCUMENT_ROOT'] . "/assets/banners");
+if (!file_exists("" . $_SERVER['DOCUMENT_ROOT'] . "/assets/heads")) mkdir("" . $_SERVER['DOCUMENT_ROOT'] . "/assets/heads");
+if (!file_exists("" . $_SERVER['DOCUMENT_ROOT'] . "/assets/bodies")) mkdir("" . $_SERVER['DOCUMENT_ROOT'] . "/assets/bodies");
+
+function downloadAssets($system, $path = null) {
+ global $options;
+
+ if (!isset($path)) {
+ $path = $system;
+ }
+
+ $general = json_decode(file_get_contents("./data/$path/general.json"), true);
+
+ if ($options["type"] === "system") {
+ 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"]);
+ echo(" /avatars/$id.webp\n");
+ file_put_contents("/tmp/img." . pathinfo($general['avatar_url'], PATHINFO_EXTENSION), file_get_contents($general['avatar_url']));
+ exec("convert -resize 512x512 \"" . "/tmp/img." . pathinfo($general['avatar_url'], PATHINFO_EXTENSION) . "\" " . $_SERVER['DOCUMENT_ROOT'] . "/assets/avatars/" . $id . ".webp");
+ unlink("/tmp/img." . pathinfo($general['avatar_url'], PATHINFO_EXTENSION));
+ }
+
+ if (isset($general["banner"])) {
+ $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"]);
+ echo(" /banners/$id.webp\n");
+ file_put_contents("/tmp/img." . pathinfo($general['banner'], PATHINFO_EXTENSION), file_get_contents($general['banner']));
+ exec("convert -resize 2048x2048 \"" . "/tmp/img." . pathinfo($general['banner'], PATHINFO_EXTENSION) ."\" " . $_SERVER['DOCUMENT_ROOT'] . "/assets/banners/" . $id . ".webp");
+ unlink("/tmp/img." . pathinfo($general['banner'], PATHINFO_EXTENSION));
+ }
+ }
+
+ $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"]);
+
+ if ($options["type"] === "members") {
+ if (isset($member["avatar_url"])) {
+ echo(" /avatars/$id.webp\n");
+ file_put_contents("/tmp/img." . pathinfo($member['avatar_url'], PATHINFO_EXTENSION), file_get_contents($member['avatar_url']));
+ exec("convert -resize 512x512 \"" . "/tmp/img." . pathinfo($member['avatar_url'], PATHINFO_EXTENSION) . "\" " . $_SERVER['DOCUMENT_ROOT'] . "/assets/avatars/" . $id . ".webp");
+ unlink("/tmp/img." . pathinfo($member['avatar_url'], PATHINFO_EXTENSION));
+ }
+
+ echo(" /banners/$id.webp\n");
+
+ if (isset($member["banner"])) {
+ file_put_contents("/tmp/img." . pathinfo($member['banner'], PATHINFO_EXTENSION), file_get_contents($member['banner']));
+ exec("convert -resize 2048x2048 \"" . "/tmp/img." . pathinfo($member['banner'], PATHINFO_EXTENSION) . "\" " . $_SERVER['DOCUMENT_ROOT'] . "/assets/banners/" . $id . ".webp");
+ unlink("/tmp/img." . pathinfo($member['banner'], PATHINFO_EXTENSION));
+ } else {
+ $img = imagecreate(2048, 1024);
+
+ if (isset($member["color"])) {
+ imagecolorallocate($img, hexdec(substr($member["color"], 0, 2)) / 2, hexdec(substr($member["color"], 2, 2)) / 2, hexdec(substr($member["color"], 4, 2)) / 2);
+ } else {
+ imagecolorallocate($img, 0, 0, 0);
+ }
+
+ imagejpeg($img, "/tmp/img.jpeg", 100);
+ imagedestroy($img);
+ exec("convert -resize 2048x2048 \"/tmp/img.jpeg\" " . $_SERVER['DOCUMENT_ROOT'] . "/assets/banners/" . $id . ".webp");
+ unlink("/tmp/img.jpeg");
+ }
+ }
+
+ if ($options["type"] === "ponytown") {
+ if (file_exists("" . $_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $member["name"] . ".png")) {
+ $url = "" . $_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $member["name"] . ".png";
+ } else {
+ $url = "" . $_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt.png";
+ }
+ echo(" /heads/$id.png\n");
+ exec("convert \"" . $url . "\" " . $_SERVER['DOCUMENT_ROOT'] . "/assets/heads/" . $id . ".png");
+
+ if (file_exists("" . $_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $member["id"] . ".png")) {
+ echo(" /bodies/$id.png\n");
+ exec("convert \"" . "" . $_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $member["id"] . ".png" . "\" " . $_SERVER['DOCUMENT_ROOT'] . "/assets/bodies/" . $id . ".png");
+ }
+ }
+ }
+}
+
+downloadAssets("gdapd");
+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/refresh/logo.inc b/includes/jobs/UpdateLogo.php
index 3e88140..add1fa9 100644
--- a/includes/refresh/logo.inc
+++ b/includes/jobs/UpdateLogo.php
@@ -1,5 +1,10 @@
<?php
+$options = json_decode($argv[1], true);
+$_SERVER['DOCUMENT_ROOT'] = "../..";
+require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/composer/vendor/autoload.php';
+use ColorThief\ColorThief;
+
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/bitset.inc";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/score.inc";
diff --git a/includes/pages.json b/includes/pages.json
index 60620d2..69aa00d 100644
--- a/includes/pages.json
+++ b/includes/pages.json
@@ -179,6 +179,16 @@
"limited": false,
"rail": false
},
+ "jobs": {
+ "name": {
+ "en": "Jobs history",
+ "fr": "Jobs history"
+ },
+ "short": null,
+ "admin": true,
+ "limited": true,
+ "rail": true
+ },
"login": {
"name": {
"en": "Login",
diff --git a/includes/refresh.php b/includes/refresh.php
index 77b51ff..9abe297 100644
--- a/includes/refresh.php
+++ b/includes/refresh.php
@@ -3,51 +3,11 @@
require_once './composer/vendor/autoload.php';
$_SERVER['DOCUMENT_ROOT'] = "..";
-use ColorThief\ColorThief;
-
$app = json_decode(file_get_contents("./app.json"), true);
-$start = microtime(true);
@mkdir("./data");
-$files = [];
-$restored = [];
-$times = [];
-
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/calendar.ics", file_get_contents($app["calendar"]));
-$currentOpStart = microtime(true);
-//file_put_contents("./data/actions/" . date('Y-m-d_H-i-s') . ".json", @file_get_contents("./data/actions/actions.json"));
-//file_put_contents("./data/toys/" . date('Y-m-d_H-i-s') . ".json", @file_get_contents("./data/toys/toys.json"));
-
-//exec('bash -c "cd /nas/web/ponies.equestria.horse/includes/data; ls -tp toys/20* | grep -v \'/$\' | tail -n +20 | xargs -I {} rm -- {}"');
-//exec('bash -c "cd /nas/web/ponies.equestria.horse/includes/data; ls -tp actions/20* | grep -v \'/$\' | tail -n +20 | xargs -I {} rm -- {}"');
-
-$times["important_backup"] = microtime(true) - $currentOpStart;
-
-$currentOpStart = microtime(true);
-$documents = array_map(function ($i) {
- return [
- "id" => substr($i, 0, -5),
- ...(json_decode(file_get_contents("./data/docs/" . $i), true) ?? [])
- ];
-}, array_filter(scandir("./data/docs"), function ($i) {
- return !str_starts_with($i, ".") && str_ends_with($i, ".json");
-}));
-
-$deletable = array_values(array_filter($documents, function ($i) {
- return str_starts_with(strip_tags($i["contents"]), "/delete");
-}));
-
-foreach ($deletable as $item) {
- if (time() - $item["last"]["date"] > 86400) {
- unlink("./data/docs/" . $item["id"] . ".json");
- }
-}
-$times["docs_cleanup"] = microtime(true) - $currentOpStart;
-
-require_once "./refresh/cleanup.inc";
-
-$currentOpStart = microtime(true);
$version = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/version.json"), true);
$ignore = [
@@ -62,6 +22,29 @@ $ignore = [
$_SERVER['DOCUMENT_ROOT'] . "/assets",
];
+$screens = array_values(array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/screens"), function ($i) {
+ return !str_starts_with($i, ".");
+}));
+
+$computers = array_values(array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata"), function ($i) {
+ return !str_starts_with($i, ".");
+}));
+
+foreach ($screens as $screen) {
+ $delete = true;
+ $id = explode(".", explode("-", $screen)[2])[0];
+
+ foreach ($computers as $file) {
+ $computer = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata/" . $file), true);
+
+ foreach ($computer["screens"] as $sel) {
+ if ($sel["id"] === $id) $delete = false;
+ }
+ }
+
+ if ($delete) unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/screens/" . $screen);
+}
+
function rscandir($dir) {
global $ignore;
$files = [];
@@ -109,139 +92,6 @@ if ($versionHash[0] !== $version["hash"]) {
}
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/version.json", json_encode($version));
-$times["version"] = microtime(true) - $currentOpStart;
-
-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", false, $ctx);
-
- if (trim($data) !== "" && $data !== false) {
- file_put_contents("./data/$fileName/general.json", $data);
- }
- $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", false, $ctx);
-
- if (trim($data) !== "" && $data !== false) {
- $parsed = json_decode($data, true);
-
- foreach ($parsed as $index => $member) {
- 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;
- }
- }
-
- $data = json_encode($parsed, JSON_PRETTY_PRINT);
- file_put_contents("./data/$fileName/members.json", $data);
- }
- $times["system-members-" . md5($id)] = microtime(true) - $currentOpStart;
-
- echo(" Fronters\n");
- $data = file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/fronters", false, $ctx);
-
- if (trim($data) !== "" && $data !== false) {
- file_put_contents("./data/$fileName/fronters.json", $data);
- }
- $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", false, $ctx), true);
-
- if (count($switches1) > 0) {
- $oldest = $switches1[count($switches1) - 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);
-
- if (count($switches2) > 0) {
- $oldest = $switches2[count($switches2) - 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);
-
- if (count($switches3) > 0) {
- $oldest = $switches3[count($switches3) - 1]["timestamp"];
-
- echo(" Part 4/6\n");
- $switches4 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/switches?before=$oldest", false, $ctx), true);
-
- if (count($switches4) > 0) {
- $oldest = $switches4[count($switches4) - 1]["timestamp"];
-
- echo(" Part 5/6\n");
- $switches5 = json_decode(file_get_contents("https://pluralkit.equestria.dev/v2/systems/$id/switches?before=$oldest", false, $ctx), true);
-
- if (count($switches5) > 0) {
- $oldest = $switches5[count($switches5) - 1]["timestamp"];
-
- 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 = [];
- }
-
- 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;
- }
-}
-
-getSystem("gdapd"); // Raindrops
-getSystem("ynmuc"); // Cloudburst
-
-if (isset($app["other"]) && isset($app["other"]["id"]) && isset($app["other"]["token"])) {
- getSystem($app["other"]["id"], "other", $app["other"]["token"]);
-}
if (!is_link($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $app["other"]["id"])) {
link($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other", $_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $app["other"]["id"]);
@@ -259,39 +109,13 @@ if (time() - $lastBackup >= 3600) {
echo("Backup skipped\n");
}
-echo("Generating logo...\n");
-
-$currentOpStart = microtime(true);
-require_once "./refresh/logo.inc";
-$times["logo"] = microtime(true) - $currentOpStart;
-
-echo("Generated logo\n");
-
echo("Fetching school information...\n");
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/school.json", "{}");
-$currentOpStart = microtime(true);
chdir("./external/school");
exec("node index.js");
chdir("../..");
-$times["school"] = microtime(true) - $currentOpStart;
echo("Fetched school information\n");
-echo("Downloading assets...\n");
-
-$currentOpStart = microtime(true);
-require_once "./refresh/assets.inc";
-$times["assets"] = microtime(true) - $currentOpStart;
-
-echo("Downloading assets\n");
-
-$time = array_sum($times);
-echo("Completed in " . $time . " seconds.\n");
-
-file_put_contents("./data/refresh.json", json_encode([
- "timestamp" => microtime(true),
- "duration" => $time,
- "restored" => $restored,
- "times" => $times
-])); \ No newline at end of file
+echo("Completed.\n"); \ No newline at end of file
diff --git a/includes/refresh/assets.inc b/includes/refresh/assets.inc
deleted file mode 100644
index b27840a..0000000
--- a/includes/refresh/assets.inc
+++ /dev/null
@@ -1,86 +0,0 @@
-<?php
-
-global $app;
-
-if (!file_exists("" . $_SERVER['DOCUMENT_ROOT'] . "/assets/avatars")) mkdir("" . $_SERVER['DOCUMENT_ROOT'] . "/assets/avatars");
-if (!file_exists("" . $_SERVER['DOCUMENT_ROOT'] . "/assets/banners")) mkdir("" . $_SERVER['DOCUMENT_ROOT'] . "/assets/banners");
-if (!file_exists("" . $_SERVER['DOCUMENT_ROOT'] . "/assets/heads")) mkdir("" . $_SERVER['DOCUMENT_ROOT'] . "/assets/heads");
-if (!file_exists("" . $_SERVER['DOCUMENT_ROOT'] . "/assets/bodies")) mkdir("" . $_SERVER['DOCUMENT_ROOT'] . "/assets/bodies");
-
-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"]);
- echo(" /avatars/$id.webp\n");
- file_put_contents("/tmp/img." . pathinfo($general['avatar_url'], PATHINFO_EXTENSION), file_get_contents($general['avatar_url']));
- exec("convert -resize 512x512 \"" . "/tmp/img." . pathinfo($general['avatar_url'], PATHINFO_EXTENSION) . "\" " . $_SERVER['DOCUMENT_ROOT'] . "/assets/avatars/" . $id . ".webp");
- unlink("/tmp/img." . pathinfo($general['avatar_url'], PATHINFO_EXTENSION));
- }
-
- if (isset($general["banner"])) {
- $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"]);
- echo(" /banners/$id.webp\n");
- file_put_contents("/tmp/img." . pathinfo($general['banner'], PATHINFO_EXTENSION), file_get_contents($general['banner']));
- exec("convert -resize 2048x2048 \"" . "/tmp/img." . pathinfo($general['banner'], PATHINFO_EXTENSION) ."\" " . $_SERVER['DOCUMENT_ROOT'] . "/assets/banners/" . $id . ".webp");
- unlink("/tmp/img." . pathinfo($general['banner'], PATHINFO_EXTENSION));
- }
-
- $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"]);
-
- if (isset($member["avatar_url"])) {
- echo(" /avatars/$id.webp\n");
- file_put_contents("/tmp/img." . pathinfo($member['avatar_url'], PATHINFO_EXTENSION), file_get_contents($member['avatar_url']));
- exec("convert -resize 512x512 \"" . "/tmp/img." . pathinfo($member['avatar_url'], PATHINFO_EXTENSION) . "\" " . $_SERVER['DOCUMENT_ROOT'] . "/assets/avatars/" . $id . ".webp");
- unlink("/tmp/img." . pathinfo($member['avatar_url'], PATHINFO_EXTENSION));
- }
-
- echo(" /banners/$id.webp\n");
-
- if (isset($member["banner"])) {
- file_put_contents("/tmp/img." . pathinfo($member['banner'], PATHINFO_EXTENSION), file_get_contents($member['banner']));
- exec("convert -resize 2048x2048 \"" . "/tmp/img." . pathinfo($member['banner'], PATHINFO_EXTENSION) . "\" " . $_SERVER['DOCUMENT_ROOT'] . "/assets/banners/" . $id . ".webp");
- unlink("/tmp/img." . pathinfo($member['banner'], PATHINFO_EXTENSION));
- } else {
- $img = imagecreate(2048, 1024);
-
- if (isset($member["color"])) {
- imagecolorallocate($img, hexdec(substr($member["color"], 0, 2)) / 2, hexdec(substr($member["color"], 2, 2)) / 2, hexdec(substr($member["color"], 4, 2)) / 2);
- } else {
- imagecolorallocate($img, 0, 0, 0);
- }
-
- imagejpeg($img, "/tmp/img.jpeg", 100);
- imagedestroy($img);
- exec("convert -resize 2048x2048 \"/tmp/img.jpeg\" " . $_SERVER['DOCUMENT_ROOT'] . "/assets/banners/" . $id . ".webp");
- unlink("/tmp/img.jpeg");
- }
-
- if (file_exists("" . $_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $member["name"] . ".png")) {
- $url = "" . $_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $member["name"] . ".png";
- } else {
- $url = "" . $_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt.png";
- }
- echo(" /heads/$id.png\n");
- exec("convert \"" . $url . "\" " . $_SERVER['DOCUMENT_ROOT'] . "/assets/heads/" . $id . ".png");
-
- if (file_exists("" . $_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $member["id"] . ".png")) {
- echo(" /bodies/$id.png\n");
- exec("convert \"" . "" . $_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $member["id"] . ".png" . "\" " . $_SERVER['DOCUMENT_ROOT'] . "/assets/bodies/" . $id . ".png");
- }
- }
-}
-
-downloadAssets("gdapd");
-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/refresh/cleanup.inc b/includes/refresh/cleanup.inc
deleted file mode 100644
index 39ec41a..0000000
--- a/includes/refresh/cleanup.inc
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-$screens = array_values(array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/screens"), function ($i) {
- return !str_starts_with($i, ".");
-}));
-
-$computers = array_values(array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata"), function ($i) {
- return !str_starts_with($i, ".");
-}));
-
-foreach ($screens as $screen) {
- $delete = true;
- $id = explode(".", explode("-", $screen)[2])[0];
-
- foreach ($computers as $file) {
- $computer = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata/" . $file), true);
-
- foreach ($computer["screens"] as $sel) {
- if ($sel["id"] === $id) $delete = false;
- }
- }
-
- if ($delete) unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/screens/" . $screen);
-} \ No newline at end of file
diff --git a/includes/util/functions.inc b/includes/util/functions.inc
index 1bfd341..5b5b6b5 100644
--- a/includes/util/functions.inc
+++ b/includes/util/functions.inc
@@ -4,6 +4,19 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/score.inc";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/bitset.inc";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/homepage.inc";
+if (!function_exists("createJob")) {
+ function createJob($title, $options) {
+ $jobs = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/jobs.json"), true);
+ $jobs[] = [
+ "name" => $title,
+ "options" => $options,
+ "date" => date('c')
+ ];
+
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/jobs.json", json_encode($jobs));
+ }
+}
+
if (!function_exists("peh_error")) {
function peh_error($message, $code = 500): void {
header("Location: /?em=" . urlencode(base64_encode($message)) . "&ec=" . $code);
diff --git a/pages/api/docs.php b/pages/api/docs.php
index d279765..51b92f5 100644
--- a/pages/api/docs.php
+++ b/pages/api/docs.php
@@ -1,6 +1,7 @@
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $_PROFILE;
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc";
if (!$isLoggedIn) header("Location: /-/login") and die();
$request_raw = file_get_contents('php://input');
@@ -26,4 +27,5 @@ if ($json_object["category"]) $data["category"] = trim($json_object["category"])
$data["last"]["date"] = time();
$data["last"]["author"] = $_PROFILE['login'];
-file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/docs/" . $select . ".json", utf8_encode(json_encode($data))); \ No newline at end of file
+file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/docs/" . $select . ".json", utf8_encode(json_encode($data)));
+createJob("CleanupDocs", []); \ No newline at end of file
diff --git a/pages/api/pluralkit-integration.php b/pages/api/pluralkit-integration.php
index b7abc6b..0efa8cb 100644
--- a/pages/api/pluralkit-integration.php
+++ b/pages/api/pluralkit-integration.php
@@ -41,106 +41,33 @@ if ($input['system_id'] === "7d9f543e-f742-40f6-9d07-86c3f2983124") {
$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") {
- 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"];
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/last.json", json_encode($currentFronter));
-
- $ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"];
-
- 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);
-
- if (!isset($metadata["birth"])) {
- showWarning($member["display_name"] ?? $member["name"], $member["name"], $system);
- } else if (isset($metadata['birth']["age"]) && $metadata["birth"]["age"] === 0 && (!isset($metadata['birth']["year"]) || $metadata["birth"]["year"] < 1900)) {
- showWarning($member["display_name"] ?? $member["name"], $member["name"], $system);
- } else if (isset($metadata['birth']["year"]) && $metadata["birth"]["year"] < 1900) {
- showWarning($member["display_name"] ?? $member["name"], $member["name"], $system);
- } else if (!isset($metadata['birth']["year"]) && !isset($metadata['birth']["age"])) {
- showWarning($member["display_name"] ?? $member["name"], $member["name"], $system);
- }
- }
- }
- }
-
- if (count($fronters["members"]) > 1) {
- $context = stream_context_create([
- 'http' => [
- 'method' => 'POST',
- 'header' =>
- "Content-Type: text/plain\r\n" .
- "Title: 🐴 Switch occurred in $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 $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 $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"])) {
- file_get_contents('https://' . $ntfy["server"] . '/public-switches', false, $context);
- }
+if ($input["type"] === "CREATE_MEMBER" || $input["type"] === "UPDATE_MEMBER" || $input["type"] === "DELETE_MEMBER") {
+ createJob("PKMembers", [
+ "system" => $system
+ ]);
+ createJob("UpdateAssets", [
+ "type" => "members"
+ ]);
+ createJob("UpdateLogo", []);
+}
- if ($system === "gdapd") {
- $topic = "public-switches-raindrops";
- } else if ($system === "ynmuc") {
- $topic = "public-switches-cloudburst";
- } else {
- $topic = "main";
- }
+if ($input["type"] === "UPDATE_SYSTEM") {
+ createJob("PKSystem", [
+ "system" => $system
+ ]);
+ createJob("UpdateAssets", [
+ "type" => "system"
+ ]);
+}
- file_get_contents('https://' . $ntfy["server"] . '/' . $topic, false, $context);
+if ($input["type"] === "CREATE_SWITCH" || $input["type"] === "UPDATE_SWITCH" || $input["type"] === "DELETE_SWITCH") {
+ createJob("PKFronters", [
+ "system" => $system
+ ]);
+ createJob("PKSwitches", [
+ "system" => $system
+ ]);
+ createJob("FrontersNotification", [
+ "system" => $system
+ ]);
} \ No newline at end of file
diff --git a/pages/api/ponytown.php b/pages/api/ponytown.php
index 99d755c..6deec43 100644
--- a/pages/api/ponytown.php
+++ b/pages/api/ponytown.php
@@ -111,6 +111,10 @@ if (count($errors) === 0 && isset($_GET["real"])) {
}
}
+createJob("UpdateAssets", [
+ "type" => "ponytown"
+]);
+
die(json_encode([
"success" => count($errors) === 0,
"errors" => $errors
diff --git a/pages/computers.inc b/pages/computers.inc
index 67cb6ef..cc2c396 100644
--- a/pages/computers.inc
+++ b/pages/computers.inc
@@ -158,7 +158,7 @@ if (str_ends_with($computer["os"], "unknown")) {
<?php if (timeAgo($computer["date"]) === "now"): ?>
<td>Online</td>
<?php else: ?>
- <td>Offline since <?= timeAgo($computer["date"]) ?>: <?= date('j M, g:ia (T)', strtotime($computer["date"])) ?></td>
+ <td>Last seen <?= timeAgo($computer["date"]) ?>: <?= date('j M, g:ia (T)', strtotime($computer["date"])) ?></td>
<?php endif; ?>
</tr>
</tbody>
@@ -192,11 +192,11 @@ if (str_ends_with($computer["os"], "unknown")) {
</tr>
<tr>
<td style="padding-right: 10px; text-align: right;"><b>Level 2 cache:</b></td>
- <td><?= isset($computer["cpu"]["cache"]["l2"]) ? round($computer["cpu"]["cache"]["l2"] / 1024**2, 2) . " MiB" : "Not supported" ?></td>
+ <td><?= isset($computer["cpu"]["cache"]["l2"]) && is_numeric($computer["cpu"]["cache"]["l2"]) ? round($computer["cpu"]["cache"]["l2"] / 1024**2, 2) . " MiB" : "Not supported" ?></td>
</tr>
<tr>
<td style="padding-right: 10px; text-align: right;"><b>Level 3 cache:</b></td>
- <td><?= isset($computer["cpu"]["cache"]["l3"]) ? round($computer["cpu"]["cache"]["l3"] / 1024**2, 2) . " MiB" : "Not supported" ?></td>
+ <td><?= isset($computer["cpu"]["cache"]["l3"]) && is_numeric($computer["cpu"]["cache"]["l3"]) ? round($computer["cpu"]["cache"]["l3"] / 1024**2, 2) . " MiB" : "Not supported" ?></td>
</tr>
<?php endif; ?>
<?php if (isset($computer["gpu"])): ?>
@@ -214,7 +214,7 @@ if (str_ends_with($computer["os"], "unknown")) {
<td>
<?php $index = 0; foreach ($computer["gpu"]["displays"] as $display): ?>
<?= $display["connection"] ?> <?= $display["vendor"] ?> <?= $display["model"] ?> (<?= $display["currentResX"] ?>x<?= $display["currentResY"] ?><?= $display["currentResX"] !== $display["resolutionX"] ? ", native " . $display["resolutionX"] . "x" . $display["resolutionY"] : "" ?>, <?= $display["currentRefreshRate"] ?> Hz)
- <?= $index < count($computer["gpu"]["controllers"]) - 1 ? "<br>" : "" ?>
+ <?= $index < count($computer["gpu"]["displays"]) - 1 ? "<br>" : "" ?>
<?php $index++; endforeach; ?>
</td>
</tr>
@@ -902,9 +902,10 @@ if (str_ends_with($computer["os"], "unknown")) {
</div>
<div style="display: flex; align-items: center;">
<div>
- <b><?= $computer["host"] ?></b> · <?= $computer["os"] ?><br>
+ <b><?= $computer["host"] ?></b><br>
+ <?= $computer["os"] ?><br>
Computer · Owned by <?= $owner === "raindrops" ? "Raindrops System" : "Cloudburst System"; ?><br>
- <?php if (timeAgo($computer["date"]) === "now"): ?>Online<?php else: ?>Offline since <?= timeAgo($computer["date"]) ?><?php endif; ?>
+ <?php if (timeAgo($computer["date"]) === "now"): ?>Online<?php else: ?>Last seen <?= timeAgo($computer["date"]) ?><?php endif; ?>
</div>
</div>
</a>
diff --git a/pages/debug.inc b/pages/debug.inc
deleted file mode 100644
index 6d2b4c9..0000000
--- a/pages/debug.inc
+++ /dev/null
@@ -1,117 +0,0 @@
-<?php
-
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages;
-require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc';
-
-function itemToName(string $item): string {
- global $lang; global $pages;
-
- if ($item === "docs_cleanup") return $lang["debug"]["docs_cleanup"];
- if ($item === "important_backup") return $lang["debug"]["important_backup"];
- if ($item === "restore") return $lang["debug"]["restore"];
- if ($item === "backups") return $lang["debug"]["backups"];
- if ($item === "calendar") return $lang["debug"]["calendar"];
- if ($item === "version") return $lang["debug"]["version"];
- if ($item === "logo") return $lang["debug"]["logo"];
- if ($item === "favicons") return $lang["debug"]["favicons"];
- if ($item === "assets") return $lang["debug"]["assets"];
-
- if (str_starts_with($item, "system-")) {
- $system = explode("-", $item)[2];
- $type = explode("-", $item)[1];
- $systemName = $system === "gdapd" ? "Raindrops System" : "Cloudburst System";
-
- return match ($type) {
- "general" => $lang["debug"]["general"] . " $systemName",
- "members" => $lang["debug"]["members"] . " $systemName",
- "fronters" => $lang["debug"]["fronters"] . " $systemName",
- "switches" => $lang["debug"]["switches"] . " $systemName",
- default => "$type " . $lang["debug"]["in"] . " $systemName",
- };
- }
-
- if (str_starts_with($item, "images-")) {
- $system = explode("-", $item)[1];
- $id = explode("-", $item)[2];
- $systemName = $system === "gdapd" ? "Raindrops" : "Cloudburst";
- $member = getSystemMember($system, $id) ?? [ "name" => $id, "display_name" => $id, "id" => $id ];
-
- if ($member["name"] === "unknown") {
- return str_replace("%1", $lang["debug"]["unknown"] . " (" . $systemName . ")", $lang["debug"]["images"]);
- } else {
- return str_replace("%1", getMiniName($member["display_name"] ?? $member["name"]), $lang["debug"]["images"]);
- }
- }
-
- return "<code>$item</code>";
-}
-
-?>
-
-<br>
-<div class="container">
- <?php $data = json_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/data/refresh.json"), true); ?>
-
- <div id="page-content">
- <h2><?= $pages["debug"]["name"][$lang["_name"]] ?></h2>
- <p><?= $lang["debug"]["description"] ?></p>
-
- <?php if (time() - $data["timestamp"] > 360): ?>
- <div class="alert alert-warning">
- <p>
- <b><?= $lang["debug"]["warning"]["title"] ?></b>
- </p>
- <?= $lang["debug"]["warning"]["intro"] ?>
- <ul>
- <li><?= $lang["debug"]["warning"]["list"][0] ?></li>
- <li><?= $lang["debug"]["warning"]["list"][1] ?></li>
- <li><?= $lang["debug"]["warning"]["list"][2] ?></li>
- </ul>
- <?= $lang["debug"]["warning"]["admin"] ?>
- </div>
- <?php endif; ?>
-
- <h4><?= $lang["debug"]["general_title"] ?></h4>
- <ul>
- <li><b><?= $lang["debug"]["time"] ?></b> <?php $dt = DateTime::createFromFormat('U.u', $data["timestamp"]); echo($dt->format("l j F Y, G:i:s.u T")); ?></li>
- <li><b><?= $lang["debug"]["duration"] ?></b> <?= round($data["duration"] * 1000) ?> ms</li>
- <li><b><?= $lang["debug"]["long"] ?></b> <?= itemToName(array_search(max(array_values($data["times"])), $data["times"])) ?? "-" ?> (<?= round(max(array_values($data["times"])) * 1000) ?> ms, <?= round((max(array_values($data["times"])) / $data["duration"]) * 100, 2) ?>%)</li>
- </ul>
-
- <h4 id="times"><?= $lang["debug"]["times"] ?></h4>
- <div>
- <?php foreach ($data["times"] as $item => $time): ?><span class="element tooltip-nohelp" title="<b><?= itemToName($item) ?></b><br>(<?= round($time * 1000) ?> ms)" data-bs-toggle="tooltip" data-bs-html="true" style="opacity:.75;display:inline-block;background:#<?= substr(md5($item), 0, 6) ?>;height:8px;margin:4px 0;width:<?= ($time / $data["duration"]) * 100 ?>%"></span><?php endforeach; ?>
- </div>
- <ul>
- <?php foreach ($data["times"] as $item => $time): ?>
- <li><b><?= itemToName($item) ?>:</b> <?= round($time * 1000) ?> ms</li>
- <?php endforeach; ?>
- </ul>
-
- <h4 id="failures"><?= $lang["debug"]["failures"] ?></h4>
- <?php if (count($data["restored"]) < 1): ?>
- <p><i><?= $lang["debug"]["no_failure"] ?></i></p>
- <?php else: ?>
- <p><?= $lang["debug"]["failure"] ?></p>
- <ul>
- <?php foreach ($data["restored"] as $item): ?>
- <li><code><?= $item ?></code></li>
- <?php endforeach; ?>
- </ul>
- <?php endif; ?>
- </div>
-</div>
-
-<style>
- .element:hover {
- margin: 0 !important;
- height: 16px !important;
- opacity: 1 !important;
- }
-
- .element {
- transition: margin 200ms, height 200ms, opacity 200ms;
- }
-</style>
-
-<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?>
diff --git a/pages/jobs.inc b/pages/jobs.inc
new file mode 100644
index 0000000..ae1405d
--- /dev/null
+++ b/pages/jobs.inc
@@ -0,0 +1,123 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages;
+require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc';
+
+$history = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history.json"), true);
+
+?>
+
+<style>
+ .list-group-item {
+ color: #fff;
+ background-color: #222;
+ border: 1px solid rgba(255, 255, 255, .125);
+ }
+
+ .list-group-item.disabled {
+ color: #fff;
+ background-color: #222;
+ border-color: rgba(255, 255, 255, .125);
+ opacity: .75;
+ }
+
+ .list-group-item:hover {
+ background-color: #252525;
+ color: #ddd;
+ }
+
+ .list-group-item:active, .list-group-item:focus {
+ background-color: #272727;
+ color: #bbb;
+ }
+
+ details[open] summary {
+ font-weight: bold;
+ }
+
+ pre {
+ background: #000000;
+ color: #ffffff;
+ padding: 10px 20px;
+ margin-top: 10px;
+ }
+
+ pre.last {
+ margin-bottom: 0;
+ }
+
+ .tracking li {
+ margin-bottom: 5px;
+ }
+
+ .tracking li:nth-last-child(1), .tracking {
+ margin-bottom: 0 !important;
+ }
+</style>
+
+<br>
+<div class="container">
+ <div id="page-content">
+ <h2>Jobs history</h2>
+
+ <div class="list-group">
+ <?php foreach ($history as $item): ?>
+ <details class="list-group-item">
+ <summary style="list-style: none; display: grid; grid-template-columns: 3fr repeat(2, 1fr);">
+ <div><?= $item["name"] ?></div>
+ <div><?= timeAgo($item["tracking"]["queue"]) ?></div>
+ <div><?php if ($item["completed"]): ?><span class="text-success" style="filter: invert(1) hue-rotate(180deg);">Completed</span><?php else: ?><span class="text-danger" style="filter: invert(1) hue-rotate(180deg);">Failed</span><?php endif; ?></div>
+ </summary>
+
+ <div class="list-group" style="margin-top: 10px;">
+ <div class="list-group-item">
+ <p>
+ <b>Duration:</b> <?= $item["time"] ?>ms
+ <b></b>
+ </p>
+
+ <b>Console output:</b>
+ <pre>​<?= $item["output"] ?></pre>
+
+ <?php if (isset($item["error"])): ?>
+ <b>Server error message:</b>
+ <pre>​<?= $item["error"] ?></pre>
+ <?php endif; ?>
+
+ <b>Job lifetime:</b>
+ <ul class="tracking">
+ <li><b>Queued by PHP</b><br><?php
+ $d = explode("|", substr(date('M jS Y, G:i|s.u', strtotime($item["tracking"]["queue"])), 0, -3));
+ $d[1] = (string)((float)$d[1]);
+ echo($d[0] . ":" . $d[1]);
+ ?></li>
+ <?php if (isset($item["tracking"]["pickup"])): ?><li><b>Picked up by the runner</b><br><?php
+ $d = explode("|", substr(date('M jS Y, G:i|s.u', strtotime($item["tracking"]["pickup"])), 0, -3));
+ $d[1] = (string)((float)$d[1]);
+ echo($d[0] . ":" . $d[1]);
+ ?></li><?php endif; ?>
+ <?php if (isset($item["tracking"]["start"])): ?><li><b>Started</b><br><?php
+ $d = explode("|", substr(date('M jS Y, G:i|s.u', strtotime($item["tracking"]["start"])), 0, -3));
+ $d[1] = (string)((float)$d[1]);
+ echo($d[0] . ":" . $d[1]);
+ ?></li><?php endif; ?>
+ <?php if (isset($item["tracking"]["end"])): ?><li><b><?= $item["completed"] ? "Finished" : "Failed" ?></b><br><?php
+ $d = explode("|", substr(date('M jS Y, G:i|s.u', strtotime($item["tracking"]["end"])), 0, -3));
+ $d[1] = (string)((float)$d[1]);
+ echo($d[0] . ":" . $d[1]);
+ ?></li><?php endif; ?>
+ <?php if (isset($item["tracking"]["logged"])): ?><li><b>Tracking logged</b><br><?php
+ $d = explode("|", substr(date('M jS Y, G:i|s.u', strtotime($item["tracking"]["logged"])), 0, -3));
+ $d[1] = (string)((float)$d[1]);
+ echo($d[0] . ":" . $d[1]);
+ ?></li><?php endif; ?>
+ </ul>
+ </div>
+ </div>
+ </details>
+ <?php endforeach; ?>
+ </div>
+ </div>
+</div>
+
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> \ No newline at end of file