Skip to content

Commit 7c868cb

Browse files
committed
fixed first time visit bug (without cache)
1 parent e5702a2 commit 7c868cb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

index.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
} else {
4242
$donor_object = json_decode($local_donor, true);
4343
}
44+
} else {
45+
// Request for data
46+
$donor_data = @file_get_contents("https://api.foldingathome.org/user/".$donor, false, stream_context_create($arr_context_options)) or die("api failed");
47+
$donor_object = json_decode($donor_data, true);
48+
if (array_key_exists("status", $donor_object)) {
49+
exit("api failed");
50+
}
51+
if ($DEBUG) var_dump($donor_object);
4452
}
4553
if (file_exists("teams/".$team)) {
4654
$local_team = file_get_contents("teams/".$team);
@@ -55,6 +63,14 @@
5563
} else {
5664
$team_object = json_decode($local_donor, true);
5765
}
66+
} else {
67+
// Request for data
68+
$team_data = @file_get_contents("https://api.foldingathome.org/team/".$team, false, stream_context_create($arr_context_options)) or die("api failed");
69+
$team_object = json_decode($team_data, true);
70+
if (array_key_exists("status", $team_object)) {
71+
exit("api failed");
72+
}
73+
if ($DEBUG) var_dump($team_object);
5874
}
5975

6076
// Save record

0 commit comments

Comments
 (0)