function conf_path

Returns the appropriate configuration directory.

Returns the configuration path based on the site's hostname, port, and pathname. See default.settings.php for examples on how the URL is converted to a directory.

Parameters

bool $require_settings: Only configuration directories with an existing settings.php file will be recognized. Defaults to TRUE. During initial installation, this is set to FALSE so that Drupal can detect a matching directory, then create a new settings.php file in it.

bool $reset: Force a full search for matching directories even if one had been found previously. Defaults to FALSE.

Return value

The path of the matching directory.

See also

default.settings.php

24 calls to conf_path()
DatabaseTasks_sqlite::getFormOptions in drupal/includes/database/sqlite/install.inc
Return driver specific configuration options.
DrupalPublicStreamWrapper::getDirectoryPath in drupal/includes/stream_wrappers.inc
Implements abstract public function getDirectoryPath()
DrupalTestCase::run in drupal/modules/simpletest/drupal_web_test_case.php
Run all tests in this class.
DrupalUnitTestCase::setUp in drupal/modules/simpletest/drupal_web_test_case.php
Sets up unit test environment.
DrupalWebTestCase::drupalGetTestFiles in drupal/modules/simpletest/drupal_web_test_case.php
Get a list files that can be used in tests.

... See full list

3 string references to 'conf_path'
drupal_rewrite_settings in drupal/includes/install.inc
Replaces values in settings.php with values in the submitted array.
install_settings_form in drupal/includes/install.core.inc
Form constructor for a form to configure and rewrite settings.php.
install_verify_settings in drupal/includes/install.core.inc
Verifies the existing settings in settings.php.

File

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

Code

function conf_path($require_settings = TRUE, $reset = FALSE) {
  $conf =& drupal_static(__FUNCTION__, '');
  if ($conf && !$reset) {
    return $conf;
  }
  $confdir = 'sites';
  $sites = array();
  if (file_exists(DRUPAL_ROOT . '/' . $confdir . '/sites.php')) {

    // This will overwrite $sites with the desired mappings.
    include DRUPAL_ROOT . '/' . $confdir . '/sites.php';
  }
  $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 (isset($sites[$dir]) && file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $sites[$dir])) {
        $dir = $sites[$dir];
      }
      if (file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $dir . '/settings.php') || !$require_settings && file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $dir)) {
        $conf = "{$confdir}/{$dir}";
        return $conf;
      }
    }
  }
  $conf = "{$confdir}/default";
  return $conf;
}