From 76343fb91511b9f53e58b6c01b258bfe00ddb4c6 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Fri, 24 Oct 2014 08:31:47 +0200 Subject: 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 --- web/lib/routing.inc.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'web/lib/routing.inc.php') diff --git a/web/lib/routing.inc.php b/web/lib/routing.inc.php index 2fa3e1f..9585304 100644 --- a/web/lib/routing.inc.php +++ b/web/lib/routing.inc.php @@ -1,5 +1,7 @@ '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); -- cgit v1.2.3-70-g09d2