From 36b199a0d0e244e8dee67f8420a9c6b1fb76a585 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 22 Aug 2001 18:51:40 +0000 Subject: - Fixed bug in conf_init() not returning the default 'conf' when no matching configuration file is found. --- includes/common.inc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'includes/common.inc') 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) { -- cgit v1.2.3