environment_type = SS_ENVIRONMENT_TYPE; } global $database; // No database provided if (!isset($database) || !$database) { if (defined('SS_DATABASE_NAME')) { $database = SS_DATABASE_NAME; } elseif (defined('SS_DATABASE_CHOOSE_NAME') && SS_DATABASE_CHOOSE_NAME) { $loopCount = (int)SS_DATABASE_CHOOSE_NAME; $databaseDir = BASE_PATH; for ($i=0; $i<$loopCount-1; $i++) { $databaseDir = dirname($databaseDir); } $database = "SS_" . basename($databaseDir); $database = str_replace('.', '', $database); } } if (defined('SS_DATABASE_USERNAME') && defined('SS_DATABASE_PASSWORD')) { global $databaseConfig; /** @skipUpgrade */ $databaseConfig = array( "type" => defined('SS_DATABASE_CLASS') ? SS_DATABASE_CLASS : 'MySQLDatabase', "server" => defined('SS_DATABASE_SERVER') ? SS_DATABASE_SERVER : 'localhost', "username" => SS_DATABASE_USERNAME, "password" => SS_DATABASE_PASSWORD, "database" => (defined('SS_DATABASE_PREFIX') ? SS_DATABASE_PREFIX : '') . $database . (defined('SS_DATABASE_SUFFIX') ? SS_DATABASE_SUFFIX : ''), ); // Set the port if called for if (defined('SS_DATABASE_PORT')) { $databaseConfig['port'] = SS_DATABASE_PORT; } // Set the timezone if called for if (defined('SS_DATABASE_TIMEZONE')) { $databaseConfig['timezone'] = SS_DATABASE_TIMEZONE; } // For schema enabled drivers: if (defined('SS_DATABASE_SCHEMA')) { $databaseConfig["schema"] = SS_DATABASE_SCHEMA; } // For SQlite3 memory databases (mainly for testing purposes) if (defined('SS_DATABASE_MEMORY')) { $databaseConfig["memory"] = SS_DATABASE_MEMORY; } } if (defined('SS_SEND_ALL_EMAILS_TO')) { Email::config()->send_all_emails_to = SS_SEND_ALL_EMAILS_TO; } if (defined('SS_SEND_ALL_EMAILS_FROM')) { Email::config()->send_all_emails_from = SS_SEND_ALL_EMAILS_FROM; } if (defined('SS_DEFAULT_ADMIN_USERNAME')) { if (!defined('SS_DEFAULT_ADMIN_PASSWORD')) { user_error( "SS_DEFAULT_ADMIN_PASSWORD must be defined in your _ss_environment.php," . "if SS_DEFAULT_ADMIN_USERNAME is defined. See " . "http://doc.silverstripe.org/framework/en/topics/environment-management for more information", E_USER_ERROR ); } else { Security::setDefaultAdmin(SS_DEFAULT_ADMIN_USERNAME, SS_DEFAULT_ADMIN_PASSWORD); } } if (defined('SS_USE_BASIC_AUTH') && SS_USE_BASIC_AUTH) { BasicAuth::config()->entire_site_protected = SS_USE_BASIC_AUTH; } if (defined('SS_ERROR_LOG')) { $logger = Injector::inst()->get('Logger'); if ($logger instanceof Logger) { $logger->pushHandler(new StreamHandler(BASE_PATH . '/' . SS_ERROR_LOG, Logger::WARNING)); } else { user_error("SS_ERROR_LOG setting only works with Monolog, you are using another logger", E_USER_WARNING); } } // Allow database adapters to handle their own configuration DatabaseAdapterRegistry::autoconfigure();