aboutsummaryrefslogtreecommitdiff
path: root/lib/program.php
diff options
context:
space:
mode:
authorMaZderMind2015-02-27 17:21:51 +0100
committerMaZderMind2015-02-27 17:21:51 +0100
commit18031079f5ca57cdac6aa4ab4c236182329bc1f7 (patch)
tree0a63e5861033f3a689af1da4d20ddcf519afee59 /lib/program.php
parentea0e8de1c5d132103010ba5aaf98ecb162f66358 (diff)
Work on Room-Page
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;
}