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>
This commit is contained in:
Lukas Fleischer 2014-10-24 08:31:47 +02:00
parent a0a5230708
commit 76343fb915
24 changed files with 200 additions and 216 deletions

View file

@ -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);