You are here

function _drd_server_read_settings in Drupal Remote Dashboard Server 6.2

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

Safely read the settings.php file and return the relevant variables.

Parameters

string $shortname:

string $file:

Return value

array

2 calls to _drd_server_read_settings()
drd_server_key_remote in ./drd_server.module
This is called to update encryption keys on all domains.
drd_server_read_sites in ./drd_server.module
Determines all available sites/domains in the current Drupal installation.

File

./drd_server.module, line 585

Code

function _drd_server_read_settings($shortname, $file) {
  $drd_db_url = '';
  $drd_db_prefix = '';
  try {
    $php = php_strip_whitespace($file);
    $php = str_replace('<?php', '', $php);
    $php = str_replace('<?', '', $php);
    $php = str_replace('?>', '', $php);
    $php = str_replace('ini_set', '@ini_set', $php);
    $php = str_replace('@@ini_set', '@ini_set', $php);
    $php = str_replace('$db_url', '$drd_db_url', $php);
    $php = str_replace('$db_prefix', '$drd_db_prefix', $php);
    eval($php);
  } catch (Exception $e) {

    // Ignore it
    _drd_server_watchdog('Read Settings - Exception occured:<pre>@exception</pre>', array(
      '@exception' => print_r($e, TRUE),
    ), WATCHDOG_ERROR);
    return array(
      '',
      '',
    );
  }
  $db_url = is_array($drd_db_url) ? $drd_db_url['default'] : $drd_db_url;
  $db_prefix = is_array($drd_db_prefix) ? $drd_db_prefix['default'] : $drd_db_prefix;
  if (empty($base_url)) {
    if ($shortname == 'default') {
      $base_url = $GLOBALS['base_url'];
    }
    else {
      $base_url = $shortname;
    }
  }
  return array(
    $base_url,
    $db_url,
    $db_prefix,
  );
}