diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-08-22 18:51:40 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-08-22 18:51:40 +0000 |
commit | 36b199a0d0e244e8dee67f8420a9c6b1fb76a585 (patch) | |
tree | ce6cec2acf6b14049927a8008c3320fe6ae845f4 | |
parent | 40467c7dd76e61e13ab02602a04c368adfbc3f45 (diff) | |
download | brdo-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.inc | 20 |
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) { |