From 7c868cb510d3a8706ad59eebba0415501aa2d074 Mon Sep 17 00:00:00 2001 From: bigsk Date: Sat, 20 Aug 2022 17:42:46 +0000 Subject: [PATCH] fixed first time visit bug (without cache) --- index.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/index.php b/index.php index ff3f51a..118922c 100644 --- a/index.php +++ b/index.php @@ -41,6 +41,14 @@ if (file_exists("donors/".$donor)) { } else { $donor_object = json_decode($local_donor, true); } +} else { + // Request for data + $donor_data = @file_get_contents("https://api.foldingathome.org/user/".$donor, false, stream_context_create($arr_context_options)) or die("api failed"); + $donor_object = json_decode($donor_data, true); + if (array_key_exists("status", $donor_object)) { + exit("api failed"); + } + if ($DEBUG) var_dump($donor_object); } if (file_exists("teams/".$team)) { $local_team = file_get_contents("teams/".$team); @@ -55,6 +63,14 @@ if (file_exists("teams/".$team)) { } else { $team_object = json_decode($local_donor, true); } +} else { + // Request for data + $team_data = @file_get_contents("https://api.foldingathome.org/team/".$team, false, stream_context_create($arr_context_options)) or die("api failed"); + $team_object = json_decode($team_data, true); + if (array_key_exists("status", $team_object)) { + exit("api failed"); + } + if ($DEBUG) var_dump($team_object); } // Save record