summaryrefslogtreecommitdiff
path: root/includes/jobs/PKMembers.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/jobs/PKMembers.php')
-rw-r--r--includes/jobs/PKMembers.php9
1 files changed, 9 insertions, 0 deletions
diff --git a/includes/jobs/PKMembers.php b/includes/jobs/PKMembers.php
index 536853d..7bcb242 100644
--- a/includes/jobs/PKMembers.php
+++ b/includes/jobs/PKMembers.php
@@ -5,10 +5,13 @@ $_SERVER['DOCUMENT_ROOT'] = "../..";
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/composer/vendor/autoload.php';
use ColorThief\ColorThief;
+echo("Loading...\n");
+
$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
$system = $options["system"];
if ($app["other"]["id"] === $system) {
+ echo("Using authentication\n");
$ctx = stream_context_create([
'http' => [
'method' => 'GET',
@@ -17,6 +20,7 @@ if ($app["other"]["id"] === $system) {
]
]);
} else {
+ echo("Not using authentication\n");
$ctx = stream_context_create([
'http' => [
'method' => 'GET'
@@ -24,9 +28,11 @@ if ($app["other"]["id"] === $system) {
]);
}
+echo("Fetching...\n");
$data = file_get_contents("https://pluralkit.equestria.dev/v2/systems/$system/members", false, $ctx);
if (trim($data) !== "" && $data !== false) {
+ echo("Data is valid, saved it\n");
$parsed = json_decode($data, true);
foreach ($parsed as $index => $member) {
@@ -47,7 +53,10 @@ if (trim($data) !== "" && $data !== false) {
$data = json_encode($parsed, JSON_PRETTY_PRINT);
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/members.json", $data);
+} else {
+ echo("Data is invalid\n");
}
+echo("Cleared cache\n");
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/navigation.json", "{}");
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/home.json", "{}"); \ No newline at end of file