summaryrefslogtreecommitdiffstats
path: root/web/lib/routing.inc.php
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2012-07-13 22:49:37 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2012-07-15 18:16:26 +0200
commiteb22bcc7548d1b1025a3832aa4555792729d11b0 (patch)
treef0d4dfdcb1ae977c4eb7f4e8e359dbc4b07cf8c3 /web/lib/routing.inc.php
parentf3ce74c714e3460bb3e3e786f626e397d3139062 (diff)
downloadaurweb-eb22bcc7548d1b1025a3832aa4555792729d11b0.tar.xz
Add routing front/back ends
This adds a URL mapping library that can be used to implement virtual paths. Also, "web/html/index.php" is moved to "web/html/home.php" and "web/html/index.php" becomes a routing front end that maps virtual paths to corresponding files. To enable the virtual path feature, all requests need to be redirected to the "index.php" routing script. If you use lighttpd, following rewrite rule can be used: url.rewrite = ( "^(.*)$" => "/index.php/$1" ) A similar rule can be used for Apache (using mod_rewrite). Note that the current routing front end only works if PATH_INFO is provided. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib/routing.inc.php')
-rw-r--r--web/lib/routing.inc.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/web/lib/routing.inc.php b/web/lib/routing.inc.php
new file mode 100644
index 0000000..0d940a2
--- /dev/null
+++ b/web/lib/routing.inc.php
@@ -0,0 +1,39 @@
+<?php
+
+$ROUTES = array(
+ '' => 'home.php',
+ '/index.php' => 'home.php',
+ '/packages' => 'packages.php',
+ '/register' => 'account.php',
+ '/accounts' => 'account.php',
+ '/login' => 'login.php',
+ '/logout' => 'logout.php',
+ '/passreset' => 'passreset.php',
+ '/rpc' => 'rpc.php',
+ '/rss' => 'rss.php',
+ '/submit' => 'pkgsubmit.php',
+ '/tu' => 'tu.php',
+ '/voters' => 'voters.php',
+ '/addvote' => 'addvote.php',
+);
+
+function get_route($path) {
+ global $ROUTES;
+
+ if (isset($ROUTES[$path])) {
+ return $ROUTES[$path];
+ } else {
+ return NULL;
+ }
+}
+
+function get_uri($path) {
+ global $USE_VIRTUAL_URLS;
+ global $ROUTES;
+
+ if ($USE_VIRTUAL_URLS) {
+ return $path;
+ } else {
+ return get_route($path);
+ }
+}