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; }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/gdapd/members.json"), true)); $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); } if (count($times) === 0) { $times[] = INF; } $timeA = time() - min($times); $times = []; foreach ($b as $id) { if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id); } if (count($times) === 0) { $times[] = INF; } $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'] . "/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]]; if (count($list) > 1) { $str = implode(" or ", array_map(function ($i) { return (getMemberWithoutSystem($i)["display_name"] ?? getMemberWithoutSystem($i)["name"]); }, $list)) . " is fronting this week."; } elseif (count($list) > 0) { $str = (getMemberWithoutSystem($list[0])["display_name"] ?? getMemberWithoutSystem($list[0])["name"]) . " is fronting this week."; } else { $str = "We couldn't tell who will front this week, sorry."; } $context = stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: text/plain\r\n" . "Title: " . formatPonypush("🎛️ Pony fronting this week") . "\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);