summaryrefslogtreecommitdiff
path: root/includes/external/next
diff options
context:
space:
mode:
authorRaindropsSys <raindrops@equestria.dev>2024-03-30 23:40:33 +0100
committerRaindropsSys <raindrops@equestria.dev>2024-03-30 23:40:33 +0100
commit6b796258d413f00e498ce7f80f73a9f6c061f29c (patch)
tree49e64a5dd4cde2acff7f0a93ed3f8e20e1cb2dc8 /includes/external/next
parent5860551daa0f60103ad24e93da29f401a653f144 (diff)
downloadpluralconnect-6b796258d413f00e498ce7f80f73a9f6c061f29c.tar.gz
pluralconnect-6b796258d413f00e498ce7f80f73a9f6c061f29c.tar.bz2
pluralconnect-6b796258d413f00e498ce7f80f73a9f6c061f29c.zip
Updated 5 files, added 2 files, deleted 495 files and renamed 7 files (automated)
Diffstat (limited to 'includes/external/next')
-rw-r--r--includes/external/next/index.php139
1 files changed, 0 insertions, 139 deletions
diff --git a/includes/external/next/index.php b/includes/external/next/index.php
deleted file mode 100644
index f35a96f..0000000
--- a/includes/external/next/index.php
+++ /dev/null
@@ -1,139 +0,0 @@
-<?php
-
-$_SERVER['DOCUMENT_ROOT'] = "../../..";
-
-$ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"];
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc";
-$pairs = [];
-
-$pairs2 = [
- ["lqolg"],
- ["tfbob"],
- ["zajrk"],
- ["ktrdb"],
- ["hpwyq"],
- ["qbzxm"],
- ["qraku"],
- ["mhnqy"],
- ["ztfjz"],
- ["ufadt"],
- ["ckqsw"]
-];
-
-$special = ["ckqsw"];
-
-// --------------------
-
-function getRelativeDay($offset) {
- if ($offset === 0) return "Today";
- if ($offset === 1) return "Tomorrow";
- return "On " . date('l', time() + ($offset * 86400)) . " (in $offset days, " . date('j M', time() + ($offset * 86400)) . ")";
-}
-
-$members = array_map(function ($i) {
- $system = "gdapd";
- $i["_lastFronted"] = -1;
- $id = $i["id"];
- $memberData = $i;
-
- $fronters = array_map(function ($item) {
- return $item["id"];
- }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["members"]);
-
- if (in_array($id, $fronters)) {
- $i["_lastFronted"] = time();
- } else {
- $switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json"), true);
-
- $thisMember = array_filter($switches, function ($item) use ($memberData) {
- return in_array($memberData["id"], $item["members"]);
- });
-
- $thisMember = array_values($thisMember);
- $frontingEnd = null;
-
- if (count($thisMember) > 0) {
- $thisIndex = array_search($thisMember[0], $switches);
-
- $frontingStart = $thisMember[0];
- $frontingEnd = $switches[$thisIndex - 1];
- }
-
- if ($frontingEnd !== null && isset($frontingStart)) {
- $i["_lastFronted"] = strtotime($frontingEnd["timestamp"]);
- }
- }
-
- return $i;
-}, array_values(array_filter(scoreOrderGlobal(), function ($i) {
- return $i["_system"] === "gdapd";
-})));
-
-$requested = []; foreach ([...$pairs, ...$pairs2] as $pair) {
- array_push($requested, ...$pair);
-} $requested = array_unique($requested);
-
-usort($pairs2, function ($a, $b) use ($members) {
- $times = [];
-
- foreach ($a as $id) {
- if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id);
- }
-
- $timeA = time() - min($times);
- $times = [];
-
- foreach ($b as $id) {
- if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id);
- }
-
- $timeB = time() - min($times);
-
- if ($timeA < 5 || $timeB < 5) {
- return -INF;
- } else {
- return $timeB - $timeA;
- }
-}); $pairsM = array_values($pairs2);
-
-$requested = array_map(function ($i) { return $i[0]; }, $pairsM);
-
-$fronters = array_map(function ($i) {
- return $i["id"];
-}, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/fronters.json"), true)["members"]);
-
-$requested = array_values(array_filter(array_unique($requested), function ($i) use ($fronters) {
- return !in_array($i, $fronters);
-}));
-
-$i = 0;
-$list = [$requested[$i]];
-while (in_array($list[count($list) - 1], $special)) {
- $i++;
- $list[] = $requested[$i];
-}
-
-if (count($list) > 1) {
- $str = implode(" or ", array_map(function ($i) {
- return (getMemberWithoutSystem($i)["display_name"] ?? getMemberWithoutSystem($i)["name"]);
- }, $list)) . " is fronting today.";
-} elseif (count($list) > 0) {
- $str = (getMemberWithoutSystem($list[0])["display_name"] ?? getMemberWithoutSystem($list[0])["name"]) . " is fronting today.";
-} else {
- $str = "We couldn't tell who will front today, sorry.";
-}
-
-$context = stream_context_create([
- 'http' => [
- 'method' => 'POST',
- 'header' =>
- "Content-Type: text/plain\r\n" .
- "Title: " . formatPonypush("🎠 Pony fronting today") . "\r\n" .
- "Priority: high\r\n" .
- "Tags: schedule\r\n" .
- "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]),
- 'content' => formatPonypush($str)
- ]
-]);
-
-file_get_contents('https://' . $ntfy["server"] . '/main', false, $context);