diff options
author | MaZderMind | 2015-02-27 17:21:51 +0100 |
---|---|---|
committer | MaZderMind | 2015-02-27 17:21:51 +0100 |
commit | 18031079f5ca57cdac6aa4ab4c236182329bc1f7 (patch) | |
tree | 0a63e5861033f3a689af1da4d20ddcf519afee59 /lib | |
parent | ea0e8de1c5d132103010ba5aaf98ecb162f66358 (diff) |
Work on Room-Page
Diffstat (limited to 'lib')
-rw-r--r-- | lib/helper.php | 4 | ||||
-rw-r--r-- | lib/program.php | 37 |
2 files changed, 30 insertions, 11 deletions
diff --git a/lib/helper.php b/lib/helper.php index 98397e4..deea2c1 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -12,9 +12,9 @@ function link_room($room) return rawurlencode($room).'/'; } -function link_player($room, $format = 'sd', $translated = false) +function link_player($room, $format = 'hd', $translated = false) { - $isDefaultFormat = in_array($format, array('sd', 'video')); + $isDefaultFormat = in_array($format, array('hd', 'video')); return rawurlencode($room).'/'.($isDefaultFormat ? '' : rawurlencode($format).'/').($translated ? 'translated/' : ''); } 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; } |