From 18031079f5ca57cdac6aa4ab4c236182329bc1f7 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Fri, 27 Feb 2015 17:21:51 +0100 Subject: Work on Room-Page --- lib/program.php | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'lib/program.php') diff --git a/lib/program.php b/lib/program.php index e85143b..effb63e 100644 --- a/lib/program.php +++ b/lib/program.php @@ -2,22 +2,32 @@ function program() { + if(!has('SCHEDULE')) + return; + + if(has('SCHEDULE.CACHE')) + { + $program = apc_fetch('SCHEDULE.CACHE'); + if($program) return $program; + } + + $program = array(); - $opts = array('http' => array('timeout' => 2, 'user_agent' => 'Fahrplan')); + $opts = array( + 'http' => array( + 'timeout' => 2, + 'user_agent' => 'C3Voc Universal Streaming-Website Backend @ '.$_SERVER['HTTP_HOST'], + ) + ); $context = stream_context_create($opts); - $schedule = file_get_contents('http://fahrplan-31c3.mkswap.net/fahrplan?a=1', false, $context); + $schedule = file_get_contents(get('SCHEDULE.URL'), false, $context); - // loading failed, try tmp-file - if(!$schedule) - $schedule = file_get_contents('/tmp/website-schedule-fallback.xml'); - - // failed, too, give up + // failed, 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) @@ -145,5 +155,14 @@ function program() } } + if(has('SCHEDULE.CACHE')) + { + apc_store( + 'SCHEDULE.CACHE', + $program, + get('SCHEDULE.CACHE') + ); + } + return $program; } -- cgit v1.2.3