provision_drupal_settings_8.tpl.php 7.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<?php
/**
 * @file
 * Template file for a settings.php.
 */
print '<?php' ?>

/**
 * @file Drupal's settings.php file
 *
 * This file was automatically generated by Aegir <?php print $this->version; ?>

 * on <?php print date('r'); ?>.
 *
 * If it is still managed by Aegir, changes to this file may be
 * lost. If it is not managed by aegir, you should remove this header
 * to avoid further confusion.
 */

omega8cc's avatar
omega8cc committed
20 21 22 23 24 25
<?php if ($subdirs_support_enabled): ?>
/**
 * Detecting subdirectory mode
 */
if (isset($_SERVER['SITE_SUBDIR']) && isset($_SERVER['RAW_HOST'])) {
  $base_url = 'http://' . $_SERVER['RAW_HOST'] . '/' . $_SERVER['SITE_SUBDIR'];
26
  ini_set('session.cookie_path', '/' . $_SERVER['SITE_SUBDIR'] . '/');
omega8cc's avatar
omega8cc committed
27 28 29
}
<?php endif; ?>

30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
<?php if ($this->cloaked): ?>
if (isset($_SERVER['db_name'])) {
  /**
   * The database credentials are stored in the Apache or Nginx vhost config
   * of the associated site with SetEnv (fastcgi_param in Nginx) parameters.
   * They are called here with $_SERVER environment variables to
   * prevent sensitive data from leaking to site administrators
   * with PHP access, that potentially might be of other sites in
   * Drupal's multisite set-up.
   * This is a security measure implemented by the Aegir project.
   */
  $databases['default']['default'] = array(
    'driver' => $_SERVER['db_type'],
    'database' => $_SERVER['db_name'],
    'username' => $_SERVER['db_user'],
    'password' => $_SERVER['db_passwd'],
    'host' => $_SERVER['db_host'],
    /* Drupal interprets $databases['db_port'] as a string, whereas Drush sees
     * it as an integer. To maintain consistency, we cast it to a string. This
     * should probably be fixed in Drush.
     */
    'port' => (string) $_SERVER['db_port'],
52 53
<?php if ($utf8mb4_is_configurable && $utf8mb4_is_supported): ?>
    'charset' => 'utf8mb4',
54
    'collation' => 'utf8mb4_general_ci',
55
<?php endif; ?>
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
  );
  $db_url['default'] = $_SERVER['db_type'] . '://' . $_SERVER['db_user'] . ':' . $_SERVER['db_passwd'] . '@' . $_SERVER['db_host'] . ':' . $_SERVER['db_port'] . '/' . $_SERVER['db_name'];
}

  /**
   * Now that we used the credentials from the apache environment, we
   * don't need them anymore. Clear them from apache and the _SERVER
   * array, otherwise they show up in phpinfo() and other friendly
   * places.
   */
  if (function_exists('apache_setenv')) {
    apache_setenv('db_type', null);
    apache_setenv('db_user', null);
    apache_setenv('db_passwd', null);
    apache_setenv('db_host', null);
    apache_setenv('db_port', null);
    apache_setenv('db_name', null);
    // no idea why they are also in REDIRECT_foo, but they are
    apache_setenv('REDIRECT_db_type', null);
    apache_setenv('REDIRECT_db_user', null);
    apache_setenv('REDIRECT_db_passwd', null);
    apache_setenv('REDIRECT_db_host', null);
    apache_setenv('REDIRECT_db_port', null);
    apache_setenv('REDIRECT_db_name', null);
  }
  unset($_SERVER['db_type']);
  unset($_SERVER['db_user']);
  unset($_SERVER['db_passwd']);
  unset($_SERVER['db_host']);
  unset($_SERVER['db_port']);
  unset($_SERVER['db_name']);
  unset($_SERVER['REDIRECT_db_type']);
  unset($_SERVER['REDIRECT_db_user']);
  unset($_SERVER['REDIRECT_db_passwd']);
  unset($_SERVER['REDIRECT_db_host']);
  unset($_SERVER['REDIRECT_db_port']);
  unset($_SERVER['REDIRECT_db_name']);

<?php else: ?>

  $databases['default']['default'] = array(
    'driver' => "<?php print $this->creds['db_type']; ?>",
    'database' => "<?php print $this->creds['db_name']; ?>",
    'username' => "<?php print $this->creds['db_user']; ?>",
    'password' => "<?php print $this->creds['db_passwd']; ?>",
    'host' => "<?php print $this->creds['db_host']; ?>",
    'port' => "<?php print $this->creds['db_port']; ?>",
   );
  $db_url['default'] = "<?php print strtr("%db_type://%db_user:%db_passwd@%db_host:%db_port/%db_name", array(
    '%db_type' => $this->creds['db_type'],
    '%db_user' => $this->creds['db_user'],
    '%db_passwd' => $this->creds['db_passwd'],
    '%db_host' => $this->creds['db_host'],
    '%db_port' => $this->creds['db_port'],
    '%db_name' => $this->creds['db_name'])); ?>";

<?php endif; ?>

  /**
  * PHP settings:
  *
  * To see what PHP settings are possible, including whether they can
  * be set at runtime (ie., when ini_set() occurs), read the PHP
  * documentation at http://www.php.net/manual/en/ini.php#ini.list
  * and take a look at the .htaccess file to see which non-runtime
  * settings are used there. Settings defined here should not be
  * duplicated there so as to avoid conflict issues.
  */
omega8cc's avatar
omega8cc committed
124 125 126 127
  ini_set('session.gc_probability', 1);
  ini_set('session.gc_divisor', 100);
  ini_set('session.gc_maxlifetime', 200000);
  ini_set('session.cookie_lifetime', 2000000);
128 129 130 131 132 133

  /**
  * Set the umask so that new directories created by Drupal have the correct permissions
  */
  umask(0002);

134 135 136 137
  $settings['file_public_path'] = 'sites/<?php print $this->uri ?>/files';
  $settings['file_private_path'] = 'sites/<?php print $this->uri ?>/private/files';
  $config['system.file']['path']['temporary'] = 'sites/<?php print $this->uri ?>/private/temp';
  $config_directories[CONFIG_SYNC_DIRECTORY] = 'sites/<?php print $this->uri ?>/private/config/sync';
138
  $settings['hash_salt'] = '<?php print $drupal_hash_salt_var ?>';
139
  $settings['aegir_api'] = <?php print $this->api_version ? $this->api_version : 0 ?>;
140 141
  $settings['allow_authorize_operations'] = FALSE;

142 143 144 145 146 147 148 149 150 151 152
  /**
   * Useless currently, because it is not used in Drupal 8 anyway.
   * Instead, Drupal 8 is trying to set the clean URLs mode on the fly,
   * depending on the request, so we should force this by redirecting
   * non-clean to clean URLs on the web server level - Nginx example:
   *
   *   rewrite ^/index.php/(.*)$ $scheme://$host/$1 permanent;
   *
   */
  $settings['clean_url'] = 1;

omega8cc's avatar
omega8cc committed
153
<?php if (!$this->site_enabled) : ?>
154 155 156 157 158
  /**
   * Useless currently, because it is ignored in Drupal 8 anyway.
   */
  $settings['maintenance_mode'] = 1;
<?php endif; ?>
159

160 161 162
  /**
   * Load services definition file.
   */
163
  $settings['container_yamls'][] = __DIR__ . '/aegir.services.yml';
164 165
  $settings['container_yamls'][] = __DIR__ . '/services.yml';

166 167 168 169 170 171 172 173
  /**
   * Trusted Host Settings support.
   */
  $settings['trusted_host_patterns'] = array(
<?php
  $esc_uri = str_replace('.', '\.', $this->uri);
  print "    '^{$esc_uri}\$',\n";
  foreach ($this->aliases as $alias_url) {
174
    $esc_alias = preg_replace(['/\./', '/\/.+/'], ['\.', ''], $alias_url);
175 176 177 178 179 180 181 182
    print "    '^{$esc_alias}\$',\n";
  }
?>
    '^localhost$',
    '^localhost\.*',
    '\.local$',
  );

183 184 185 186 187
  /**
   * Set the Syslog identity to the site name so it's not always "drupal".
   */
  $config['syslog.settings']['identity'] = '<?php print $this->uri ?>';

188 189 190 191
<?php print $extra_config; ?>

  # Additional host wide configuration settings. Useful for safely specifying configuration settings.
  if (is_readable('<?php print $this->platform->server->include_path  ?>/global.inc')) {
192
    include('<?php print $this->platform->server->include_path  ?>/global.inc');
193 194
  }

195
  # Additional platform wide configuration settings.
196 197
  if (is_readable('<?php print $this->platform->root  ?>/sites/all/platform.settings.php')) {
    include('<?php print $this->platform->root ?>/sites/all/platform.settings.php');
198 199
  }

200 201
  # Additional site configuration settings.
  if (is_readable('<?php print $this->site_path  ?>/local.settings.php')) {
202
    include('<?php print $this->site_path  ?>/local.settings.php');
203
  }