diff options
author | Lukas Fleischer <archlinux@cryptocrack.de> | 2014-10-24 08:31:47 +0200 |
---|---|---|
committer | Lukas Fleischer <archlinux@cryptocrack.de> | 2014-10-24 10:03:54 +0200 |
commit | 76343fb91511b9f53e58b6c01b258bfe00ddb4c6 (patch) | |
tree | 60eb4d3727bae159a1807915a58348b210ead206 /web/lib/routing.inc.php | |
parent | a0a523070847230565c2ad5993ee058ff475a8e1 (diff) | |
download | aur-76343fb91511b9f53e58b6c01b258bfe00ddb4c6.tar.gz aur-76343fb91511b9f53e58b6c01b258bfe00ddb4c6.tar.xz |
Use an INI-style configuration file
Replace web/lib/config.inc.php with an INI-style configuration file.
This allows us to get rid of several globals and makes it easier to use
the same configuration file in external scripts.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib/routing.inc.php')
-rw-r--r-- | web/lib/routing.inc.php | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/web/lib/routing.inc.php b/web/lib/routing.inc.php index 2fa3e1f7..95853041 100644 --- a/web/lib/routing.inc.php +++ b/web/lib/routing.inc.php @@ -1,5 +1,7 @@ <?php +include_once("confparser.inc.php"); + $ROUTES = array( '' => 'home.php', '/index.php' => 'home.php', @@ -24,6 +26,10 @@ $PKGBASE_PATH = '/pkgbase'; $PKGREQ_PATH = '/requests'; $USER_PATH = '/account'; +function use_virtual_urls() { + return config_get_bool('options', 'use_virtual_urls'); +} + function get_route($path) { global $ROUTES; @@ -36,10 +42,9 @@ function get_route($path) { } function get_uri($path) { - global $USE_VIRTUAL_URLS; global $ROUTES; - if ($USE_VIRTUAL_URLS) { + if (use_virtual_urls()) { return $path; } else { return get_route($path); @@ -62,10 +67,9 @@ function get_pkgreq_route() { } function get_pkg_uri($pkgname) { - global $USE_VIRTUAL_URLS; global $PKG_PATH; - if ($USE_VIRTUAL_URLS) { + if (use_virtual_urls()) { return $PKG_PATH . '/' . urlencode($pkgname) . '/'; } else { return '/' . get_route($PKG_PATH) . '?N=' . urlencode($pkgname); @@ -73,10 +77,9 @@ function get_pkg_uri($pkgname) { } function get_pkgbase_uri($pkgbase_name) { - global $USE_VIRTUAL_URLS; global $PKGBASE_PATH; - if ($USE_VIRTUAL_URLS) { + if (use_virtual_urls()) { return $PKGBASE_PATH . '/' . urlencode($pkgbase_name) . '/'; } else { return '/' . get_route($PKGBASE_PATH) . '?N=' . urlencode($pkgbase_name); @@ -89,10 +92,9 @@ function get_user_route() { } function get_user_uri($username) { - global $USE_VIRTUAL_URLS; global $USER_PATH; - if ($USE_VIRTUAL_URLS) { + if (use_virtual_urls()) { return $USER_PATH . '/' . urlencode($username) . '/'; } else { return '/' . get_route($USER_PATH) . '?U=' . urlencode($username); |