You are here

function adserve_include_drupal in Advertisement 5

Same name and namespace in other branches
  1. 5.2 adserve.inc \adserve_include_drupal()
  2. 6.3 adserve.inc \adserve_include_drupal()
  3. 6 adserve.inc \adserve_include_drupal()
  4. 6.2 adserve.inc \adserve_include_drupal()
  5. 7 adserve.inc \adserve_include_drupal()

Include Drupal's bootstrap.inc.

1 call to adserve_include_drupal()
adserve_bootstrap in ./adserve.inc
Include the necessary files and call the Drupal bootstrap.

File

./adserve.inc, line 586

Code

function adserve_include_drupal() {

  // For optimal performance set DRUPAL_ROOT at the top of this file.
  if (defined('DRUPAL_ROOT')) {
    if (is_dir(DRUPAL_ROOT) && file_exists(DRUPAL_ROOT . '/includes/bootstrap.inc')) {
      chdir(DRUPAL_ROOT);
    }
    else {
      echo 'Invalid DRUPAL_ROOT (' . DRUPAL_ROOT . ') defined in adserve.inc';
    }
  }
  else {
    $path = explode('/', adserve_variable('ad_dir'));
    while (!empty($path)) {

      // Search for top level Drupal directory to perform bootstrap.
      chdir(implode('/', $path));
      if (file_exists('./includes/bootstrap.inc')) {
        break;
      }
      array_pop($path);
    }
  }
  adserve_variable('root_dir', getcwd());
  require_once adserve_variable('root_dir') . '/includes/bootstrap.inc';
}