function find_conf_path in Mail MIME 6
Same name and namespace in other branches
- 8.2 url_to_path.inc \find_conf_path()
 - 6.2 url_to_path.inc \find_conf_path()
 - 7.2 url_to_path.inc \find_conf_path()
 - 7 url_to_path.inc \find_conf_path()
 
Find the appropriate configuration directory for a given host and path.
Parameters
$http_host: The hostname and optional port number, e.g. "www.example.com" or "www.example.com:8080".
$script_name: The part of the url following the hostname, including the leading slash.
Return value
The path of the matching configuration directory.
See also
1 call to find_conf_path()
- url_to_path in ./
url_to_path.inc  - Returns the local relative path corresponding to a given URL, if possible.
 
File
- ./
url_to_path.inc, line 24  - Provide a url_to_path() function by refactoring and repurposing conf_path().
 
Code
function find_conf_path($http_host, $script_name, $require_settings = TRUE) {
  $confdir = 'sites';
  $uri = explode('/', $script_name);
  $server = explode('.', implode('.', array_reverse(explode(':', rtrim($http_host, '.')))));
  for ($i = count($uri) - 1; $i > 0; $i--) {
    for ($j = count($server); $j > 0; $j--) {
      $dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i));
      if (file_exists("{$confdir}/{$dir}/settings.php") || !$require_settings && file_exists("{$confdir}/{$dir}")) {
        $conf = "{$confdir}/{$dir}";
        return $conf;
      }
    }
  }
  $conf = "{$confdir}/default";
  return $conf;
}