From c9c977461b2fa1cfdbb1285ddea1c56d78439885 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sun, 14 Dec 2014 00:53:28 +0100 Subject: store a local copy of the schedule in case the source goes down i head this could possibly happen *gg --- lib/program.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lib/program.php') diff --git a/lib/program.php b/lib/program.php index 5507442..721abea 100644 --- a/lib/program.php +++ b/lib/program.php @@ -3,8 +3,19 @@ function program() { $program = array(); - $schedule = simplexml_load_file($GLOBALS['CONFIG']['SCHEDULE']); + $schedule = file_get_contents($GLOBALS['CONFIG']['SCHEDULE']); + // loading failed, try tmp-file + if(!$schedule) + $schedule = file_get_contents('/tmp/website-schedule-fallback.xml'); + + // failed, too, give up + if(!$schedule) + return array(); + + // save tmp-file (for when uplink goes down or such) + file_put_contents('/tmp/website-schedule-fallback.xml', $schedule); + $schedule = simplexml_load_string($schedule); // re-calculate day-ends // some schedules have long gaps before the first talk or talks that expand beyond the dayend // (fiffkon, i look at you) -- cgit v1.2.3