aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaZderMind2014-11-29 19:31:21 +0100
committerMaZderMind2014-11-29 19:31:21 +0100
commit6fea306ab914287bc2e6ec242f440e31e440110f (patch)
tree21c308f2fc31999ff9c8a31491c5ecddd9b8bf0b
parenta3f189df339781c6aa4177b03cc1175a6bc53efe (diff)
move url rewriting into php
for better compatibility with nginx
-rw-r--r--.htaccess38
-rw-r--r--index.php77
-rw-r--r--pages/404.php (renamed from 404.php)0
-rw-r--r--pages/about.php (renamed from about.php)2
-rw-r--r--pages/party.php (renamed from party.php)0
-rw-r--r--pages/program-json.php (renamed from program-json.php)0
-rw-r--r--pages/room.php (renamed from room.php)2
-rw-r--r--pages/rooms.php10
8 files changed, 84 insertions, 45 deletions
diff --git a/.htaccess b/.htaccess
index 14e9703..431bbb1 100644
--- a/.htaccess
+++ b/.htaccess
@@ -5,40 +5,4 @@ RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
-# / -> index.php - room/streams list
-DirectoryIndex index.php
-
-# /room/ -> room.php - native av-player in sd (with format switcher included)
-RewriteRule ^(saal1|saal2|saalg|saal6)/?$ room.php?room=$1&format=sd&language=native [L]
-
-# /room/translated -> room.php - translated av-player in sd (with format switcher included)
-RewriteRule ^(saal1|saal2|saalg|saal6)/translated/?$ room.php?room=$1&format=sd&language=translated [L]
-
-# /room/format/ -> room.php - native av-player in $format (with format switcher included)
-RewriteRule ^(saal1|saal2|saalg|saal6)/(hd|audio|slides)/?$ room.php?room=$1&format=$2&language=native [L]
-
-# /room/format/translated -> room.php - translated av-player in $format (with format switcher included)
-RewriteRule ^(saal1|saal2|saalg|saal6)/(hd|audio|slides)/translated/?$ room.php?room=$1&format=$2&language=translated [L]
-
-
-# /miniroom/ -> room.php - native av-player in sd
-RewriteRule ^(sendezentrum)/?$ room.php?room=$1&format=sd&language=native [L]
-
-# /miniroom/format/ -> room.php - native av-player in $format (no hd, no slides)
-RewriteRule ^(sendezentrum)/(audio)/?$ room.php?room=$1&format=$2&language=native [L]
-
-
-# /party/ -> player.php - simple audio-player for party
-RewriteRule ^(lounge|ambient)/?$ party.php?room=$1&format=audio [L]
-
-
-# /about/ -> about.php
-RewriteRule ^about/?$ about.php [L]
-
-# /program.json -> program-json.php
-RewriteRule ^program.json?$ program-json.php [L]
-
-
-# Show a known page in case of as miss
-RewriteRule ^404.html$ 404.php [L]
-ErrorDocument 404 /~peter/voc-frontends/31c3/404.php
+RewriteRule (.*) index.php?route=$1 [L]
diff --git a/index.php b/index.php
index 4faff27..def4f7c 100644
--- a/index.php
+++ b/index.php
@@ -1,10 +1,75 @@
<?php
-require_once('lib/bootstrap.php');
+$route = @$_GET['route'];
+$route = rtrim($route, '/');
-echo $tpl->render(array(
- 'page' => 'rooms',
- 'title' => 'Overview',
- 'rooms' => $GLOBALS['CONFIG']['ROOMS'],
-));
+
+if($route == '')
+{
+ include('pages/rooms.php');
+}
+
+else if(preg_match('@^(saal1|saal2|saalg|saal6|sendezentrum)$@', $route, $m))
+{
+ $_GET = array(
+ 'room' => $m[1],
+ 'format' => 'sd',
+ 'language' => 'native',
+ );
+ include('pages/room.php');
+}
+
+else if(preg_match('@^(saal1|saal2|saalg|saal6)/translated$@', $route, $m))
+{
+ $_GET = array(
+ 'room' => $m[1],
+ 'format' => 'sd',
+ 'language' => 'translated',
+ );
+ include('pages/room.php');
+}
+
+else if(preg_match('@^(saal1|saal2|saalg|saal6|sendezentrum)/(hd|audio|slides)$@', $route, $m))
+{
+ $_GET = array(
+ 'room' => $m[1],
+ 'format' => $m[2],
+ 'language' => 'native',
+ );
+ include('pages/room.php');
+}
+
+else if(preg_match('@^(saal1|saal2|saalg|saal6)/(hd|audio|slides)/translated$@', $route, $m))
+{
+ $_GET = array(
+ 'room' => $m[1],
+ 'format' => $m[2],
+ 'language' => 'translated',
+ );
+ include('pages/room.php');
+}
+
+else if(preg_match('@^(lounge|ambient)$@', $route, $m))
+{
+ $_GET = array(
+ 'room' => $m[1],
+ 'format' => 'audio',
+ );
+ include('pages/party.php');
+}
+
+else if(preg_match('@^about$@', $route, $m))
+{
+ include('pages/about.php');
+}
+
+else if(preg_match('@^program.json$@', $route, $m))
+{
+ include('pages/program-json.php');
+}
+
+else
+{
+ include('pages/404.php');
+}
diff --git a/404.php b/pages/404.php
index 4eee2f2..4eee2f2 100644
--- a/404.php
+++ b/pages/404.php
diff --git a/about.php b/pages/about.php
index 9d0cd75..9586e73 100644
--- a/about.php
+++ b/pages/about.php
@@ -4,5 +4,5 @@ require_once('lib/bootstrap.php');
echo $tpl->render(array(
'page' => 'about',
- 'title' => 'About these awsome streams',
+ 'title' => 'About the Streams',
));
diff --git a/party.php b/pages/party.php
index a095df3..a095df3 100644
--- a/party.php
+++ b/pages/party.php
diff --git a/program-json.php b/pages/program-json.php
index 2b5e38b..2b5e38b 100644
--- a/program-json.php
+++ b/pages/program-json.php
diff --git a/room.php b/pages/room.php
index 478484b..96b8f18 100644
--- a/room.php
+++ b/pages/room.php
@@ -48,7 +48,7 @@ echo $tpl->render(array(
'translated' => ($language == 'translated'),
'format' => $format,
- // miniroom = no hd, no translation, no slides, no irc, no program
+ // miniroom = no translation, no slides, no irc, no program
// -> sendezentrum, workshops
'miniroom' => in_array($room, array('sendezentrum')),
));
diff --git a/pages/rooms.php b/pages/rooms.php
new file mode 100644
index 0000000..4faff27
--- /dev/null
+++ b/pages/rooms.php
@@ -0,0 +1,10 @@
+<?php
+
+require_once('lib/bootstrap.php');
+
+echo $tpl->render(array(
+ 'page' => 'rooms',
+ 'title' => 'Overview',
+
+ 'rooms' => $GLOBALS['CONFIG']['ROOMS'],
+));