summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-08-22 18:51:40 +0000
committerDries Buytaert <dries@buytaert.net>2001-08-22 18:51:40 +0000
commit36b199a0d0e244e8dee67f8420a9c6b1fb76a585 (patch)
treece6cec2acf6b14049927a8008c3320fe6ae845f4
parent40467c7dd76e61e13ab02602a04c368adfbc3f45 (diff)
downloadbrdo-36b199a0d0e244e8dee67f8420a9c6b1fb76a585.tar.gz
brdo-36b199a0d0e244e8dee67f8420a9c6b1fb76a585.tar.bz2
- Fixed bug in conf_init() not returning the default 'conf' when no
matching configuration file is found.
-rw-r--r--includes/common.inc20
1 files changed, 18 insertions, 2 deletions
diff --git a/includes/common.inc b/includes/common.inc
index d347cc64f..b7c382893 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -2,9 +2,25 @@
function conf_init() {
global $HTTP_HOST, $REQUEST_URI;
+
+ /*
+ ** Try finding a matching configuration file by stripping the website's
+ ** URI from left to right. If no configuration file is found, return a
+ ** default value 'conf'.
+ */
+
$file = strtolower(strtr($HTTP_HOST ."". substr($REQUEST_URI, 0, strrpos($REQUEST_URI, "/")), "/:", ".."));
- while (strpos($file, '.') && !file_exists("includes/$file.php")) $file = substr($file, strpos($file, ".") + 1);
- return $file ? $file : "conf";
+
+ while (strlen($file) > 4) {
+ if (file_exists("includes/$file.php")) {
+ return $file;
+ }
+ else {
+ $file = substr($file, strpos($file, ".") + 1);
+ }
+ }
+
+ return "conf";
}
function error_handler($errno, $message, $filename, $line, $variables) {