function drd_server_read_sites in Drupal Remote Dashboard Server 7.2
Same name and namespace in other branches
- 6.2 drd_server.module \drd_server_read_sites()
Determines all available sites/domains in the current Drupal installation.
Return value
array An array with key/value pairs where key is the domain name and value the shortname of a directory in DRUPAL_ROOT/sites/ for where to find the settings.php file for that domain.
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 Action to find out all domains on this 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 871 - Provides XMLRPC implementation to respond to requests from DRD.
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',
))) {
$sites[$shortname] = $shortname;
}
}
}
if (!empty($sites)) {
foreach ($sites as $key => $shortname) {
if (is_dir(DRUPAL_ROOT . '/sites/' . $shortname)) {
$file = DRUPAL_ROOT . '/sites/' . $shortname . '/settings.php';
if (file_exists($file)) {
list($base_url, $databases) = _drd_server_read_settings($shortname, $file);
if (empty($base_url) && $key == $shortname) {
_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);
}
// If we have a more accurate base_url go by that
if ($base_url != $key && $base_url != $shortname) {
$sites[$base_url] = $shortname;
unset($sites[$key]);
}
}
}
}
}
_drd_server_watchdog('Reading Sites - Found @n entries: <pre>@list</pre>', array(
'@n' => count($sites),
'@list' => print_r($sites, TRUE),
));
return $sites;
}