aboutsummaryrefslogtreecommitdiff
path: root/lib/program.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/program.php')
-rw-r--r--lib/program.php37
1 files changed, 28 insertions, 9 deletions
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;
}