You are here

function drd_server_read_sites in Drupal Remote Dashboard Server 6.2

Same name and namespace in other branches
  1. 7.2 drd_server.module \drd_server_read_sites()

Determines all available sites/domains in the current Drupal installation.

Return value

array

4 calls to drd_server_read_sites()
drd_server_key in ./drd_server.module
This is called to update the excryption keys for this server and all it's domains hosted in the same Drupal installation.
drd_server_server_domains in ./drd_server.server.inc
DRD Server Action to find out all domains on thsi Drupal installation.
drd_server_settings_keys_submit in ./drd_server.admin.inc
Submit handler for the AES key settings form.
drd_server_settings_submit in ./drd_server.admin.inc
Submit handler for the settings form.

File

./drd_server.module, line 676

Code

function drd_server_read_sites() {
  $sites = array();
  if (file_exists(DRUPAL_ROOT . '/sites/sites.php')) {
    try {
      include DRUPAL_ROOT . '/sites/sites.php';
    } catch (Exception $e) {

      //Ignore
    }
  }
  if (empty($sites)) {
    foreach (scandir(DRUPAL_ROOT . '/sites') as $shortname) {
      if (is_dir(DRUPAL_ROOT . '/sites/' . $shortname) && !in_array($shortname, array(
        '.',
        '..',
        'all',
      ))) {
        $file = DRUPAL_ROOT . '/sites/' . $shortname . '/settings.php';
        if (file_exists($file)) {
          list($base_url, $db_url, $db_prefix) = _drd_server_read_settings($shortname, $file);
          if (empty($base_url)) {
            _drd_server_watchdog('Reading Sites - Failed as url is empty: @shortname', array(
              '@shortname' => $shortname,
            ), WATCHDOG_ERROR);
            continue;
          }
          $pos = strpos($base_url, '://');
          if ($pos > 0) {
            $base_url = substr($base_url, $pos + 3);
          }
          $sites[$base_url] = $shortname;
        }
      }
    }
  }
  return $sites;
}