You are here

function conf_path in Drupal 5

Same name and namespace in other branches
  1. 4 includes/bootstrap.inc \conf_path()
  2. 6 includes/bootstrap.inc \conf_path()
  3. 7 includes/bootstrap.inc \conf_path()

Find the appropriate configuration directory.

Try finding a matching configuration directory by stripping the website's hostname from left to right and pathname from right to left. The first configuration file found will be used; the remaining will ignored. If no configuration file is found, return a default value '$confdir/default'.

Example for a fictitious site installed at http://www.drupal.org:8080/mysite/test/ the 'settings.php' is searched in the following directories:

1. $confdir/8080.www.drupal.org.mysite.test 2. $confdir/www.drupal.org.mysite.test 3. $confdir/drupal.org.mysite.test 4. $confdir/org.mysite.test

5. $confdir/8080.www.drupal.org.mysite 6. $confdir/www.drupal.org.mysite 7. $confdir/drupal.org.mysite 8. $confdir/org.mysite

9. $confdir/8080.www.drupal.org 10. $confdir/www.drupal.org 11. $confdir/drupal.org 12. $confdir/org

13. $confdir/default

8 calls to conf_path()
conf_init in includes/bootstrap.inc
Loads the configuration and sets the base URL, cookie domain, and session name correctly.
drupal_get_filename in includes/bootstrap.inc
Returns and optionally sets the filename for a system item (module, theme, etc.). The filename, whether provided, cached, or retrieved from the database, is only returned if the file exists.
drupal_rewrite_settings in includes/install.inc
Read settings.php into a buffer line by line, changing values specified in $settings array, then over-writing the old settings.php file.
drupal_system_listing in includes/common.inc
Returns an array of files objects of the given type from the site-wide directory (i.e. modules/), the all-sites directory (i.e. sites/all/modules/), the profiles directory, and site-specific directory (i.e. sites/somesite/modules/). The returned array…
install_change_settings in ./install.php
Configure and rewrite settings.php.

... See full list

File

includes/bootstrap.inc, line 194
Functions that need to be loaded on every Drupal request.

Code

function conf_path() {
  static $conf = '';
  if ($conf) {
    return $conf;
  }
  $confdir = 'sites';
  $uri = explode('/', $_SERVER['SCRIPT_NAME'] ? $_SERVER['SCRIPT_NAME'] : $_SERVER['SCRIPT_FILENAME']);
  $server = explode('.', implode('.', array_reverse(explode(':', rtrim($_SERVER['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")) {
        $conf = "{$confdir}/{$dir}";
        return $conf;
      }
    }
  }
  $conf = "{$confdir}/default";
  return $conf;
}