function filter_init() { global $conf, $user; // Inject values into the $conf array - will apply to all sites. // This can be a useful place to apply generic development settings. $conf_inject = unserialize(urldecode(runserver_env('RUNSERVER_CONF'))); // Merge in the injected conf, overriding existing items. $conf = array_merge($conf, $conf_inject); // Log in user if needed. if (isset($_GET['login'])) { $uid = runserver_env('RUNSERVER_USER'); if (!empty($uid) && $user->uid !== $uid) { // If a user was provided, log in as this user. $user = user_load($uid); if (function_exists('drupal_session_regenerate')) { // Drupal 7 drupal_session_regenerate(); } else { // Drupal 6 sess_regenerate(); } } // Refresh the page (in case access denied has been called already). drupal_goto($_GET['q']); } }
function filter_init() { global $conf, $user; // Inject values into the $conf array - will apply to all sites. // This can be a useful place to apply generic development settings. $conf_inject = unserialize(urldecode(runserver_env('RUNSERVER_CONF'))); // Merge in the injected conf, overriding existing items. $conf = array_merge($conf, $conf_inject); }
<?php // Get a $_SERVER key, or equivalent environment variable // if it is not set in $_SERVER. function runserver_env($key) { if (isset($_SERVER[$key])) { return $_SERVER[$key]; } else { return getenv($key); } } $url = parse_url($_SERVER["REQUEST_URI"]); if (file_exists('.' . $url['path'])) { // Serve the requested resource as-is. return FALSE; } // Populate the "q" query key with the path, skip the leading slash. $_GET['q'] = $_REQUEST['q'] = substr($url['path'], 1); // We set the base_url so that Drupal generates correct URLs for runserver // (e.g. http://127.0.0.1:8888/...), but can still select and serve a specific // site in a multisite configuration (e.g. http://mysite.com/...). $base_url = runserver_env('RUNSERVER_BASE_URL'); // The built in webserver incorrectly sets $_SERVER['SCRIPT_NAME'] when URLs // contain multiple dots (such as config entity IDs) in the path. Since this is // a virtual resource, served by index.php set the script name explicitly. // See https://github.com/drush-ops/drush/issues/2033 for more information. $_SERVER['SCRIPT_NAME'] = '/index.php'; // Include the main index.php and let core take over. // n.b. Drush sets the cwd to the Drupal root during bootstrap. include 'index.php';