store a local copy of the schedule in case the source goes down

i head this could possibly happen *gg
This commit is contained in:
MaZderMind 2014-12-14 00:53:28 +01:00
parent 1d40a77dfe
commit c9c977461b

View file

@ -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)