public function initialize(\Boris\Boris $boris, $dir) { parent::initialize($boris, $dir); chdir($dir); define('DRUPAL_ROOT', $dir); require_once "{$dir}/includes/bootstrap.inc"; drupal_override_server_variables(); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); }
/** * { @inheritdoc } */ public function bootstrapDrupal() { $this->config['root'] = $this->getDrupalRoot(); $this->validateDrupalRoot($this->config['root']); // Do a Drush-style bootstrap. define('DRUPAL_ROOT', $this->config['root']); require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; drupal_override_server_variables(); // Bootstrap Drupal. drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); }
/** * Setup a consistent PHP environment. * * This method sets PHP environment options we want to be sure are set * correctly for security or just saneness. */ private static function prepareEnvironment($root, $serverVars) { if (static::$isEnvironmentInitialized) { return; } chdir($root); define('DRUPAL_ROOT', getcwd()); require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; drupal_override_server_variables($serverVars); static::$isEnvironmentInitialized = true; }
public function generate_file($database, $db_user, $db_pass, $project_domain) { // Generate settings for the database $settings['databases'] = array('value' => array('default' => array('default' => array('prefix' => '', 'host' => 'localhost', 'driver' => 'mysql', 'database' => $database, 'username' => $db_user, 'password' => $db_pass))), 'required' => TRUE); try { require_once DRUPAL_ROOT . '/includes/install.inc'; $variables['url'] = "http://" . $project_domain . '/index.php'; // Override variables since this is obviously run from CLI // We do this to confuse the cat... err. conf_path() drupal_override_server_variables($variables); // Rewrite the settings file in its' correct place drupal_rewrite_settings($settings); } catch (Exception $e) { throw new RumCouldNotCreateSettingsFileException($e->getMessage()); } return TRUE; }
* Handles incoming requests to fire off regularly-scheduled tasks (cron jobs). */ if (!file_exists('includes/bootstrap.inc')) { if (!empty($_SERVER['DOCUMENT_ROOT']) && file_exists($_SERVER['DOCUMENT_ROOT'] . '/includes/bootstrap.inc')) { chdir($_SERVER['DOCUMENT_ROOT']); } elseif (preg_match('@^(.*)[\\\\/]sites[\\\\/][^\\\\/]+[\\\\/]modules[\\\\/]([^\\\\/]+[\\\\/])?elysia(_cron)?$@', getcwd(), $r) && file_exists($r[1] . '/includes/bootstrap.inc')) { chdir($r[1]); } else { die("Cron Fatal Error: Can't locate bootstrap.inc. Check cron.php position."); } } /** * Root directory of Drupal installation. */ define('DRUPAL_ROOT', getcwd()); include_once DRUPAL_ROOT . '/includes/bootstrap.inc'; drupal_override_server_variables(array('SCRIPT_NAME' => '/cron.php')); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); if (!isset($_GET['cron_key']) || variable_get('cron_key', 'drupal') != $_GET['cron_key']) { watchdog('cron', 'Cron could not run because an invalid key was used.', array(), WATCHDOG_NOTICE); drupal_access_denied(); } elseif (variable_get('maintenance_mode', 0)) { watchdog('cron', 'Cron could not run because the site is in maintenance mode.', array(), WATCHDOG_NOTICE); drupal_access_denied(); } else { if (function_exists('elysia_cron_run')) { elysia_cron_run(); } else { drupal_cron_run(); } }
header('HTTP/1.0 500 Internal Server Error'); die('HTTP/1.0 500 Internal Server Error'); } // Definitions define('_DEXEC', true); define('DS', DIRECTORY_SEPARATOR); define('DRUPAL_ROOT', $base_path); define('WBSITEMANAGER_ROOT', __DIR__); define('STDIN', fopen('php://input', 'r')); define('STDOUT', fopen('php://output', 'w')); // Change to Root chdir(DRUPAL_ROOT); // Drupal Initialization if (is_readable(DRUPAL_ROOT . '/includes/bootstrap.inc')) { require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; drupal_override_server_variables(); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); } else { die('Drupal Failed to Initialize'); } // Import Configuration if (is_readable(__DIR__ . '/connect.config.php')) { include __DIR__ . '/connect.config.php'; } else { /** * Load User Configured */ /* $ipFilter = array_filter(explode("\n", $plugin_params->remote_ip_filter), 'strlen'); $userFilter = array_filter(explode("\n", $plugin_params->remote_user_filter), 'strlen'); */
/** * Begin an installation request, modifying the installation state as needed. * * This function performs commands that must run at the beginning of every page * request. It throws an exception if the installation should not proceed. * * @param $install_state * An array of information about the current installation state. This is * modified with information gleaned from the beginning of the page request. */ function install_begin_request(&$install_state) { // Allow command line scripts to override server variables used by Drupal. require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; if (!$install_state['interactive']) { drupal_override_server_variables($install_state['server']); } // The user agent header is used to pass a database prefix in the request when // running tests. However, for security reasons, it is imperative that no // installation be permitted using such a prefix. if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], "simpletest") !== FALSE) { header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden'); exit; } drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION); // This must go after drupal_bootstrap(), which unsets globals! global $conf; require_once DRUPAL_ROOT . '/modules/system/system.install'; require_once DRUPAL_ROOT . '/includes/common.inc'; require_once DRUPAL_ROOT . '/includes/file.inc'; require_once DRUPAL_ROOT . '/includes/path.inc'; // Set up $language, so t() caller functions will still work. drupal_language_initialize(); // Load module basics (needed for hook invokes). include_once DRUPAL_ROOT . '/includes/module.inc'; include_once DRUPAL_ROOT . '/includes/session.inc'; include_once DRUPAL_ROOT . '/includes/entity.inc'; $module_list['system']['filename'] = 'modules/system/system.module'; $module_list['filter']['filename'] = 'modules/filter/filter.module'; $module_list['user']['filename'] = 'modules/user/user.module'; module_list(TRUE, FALSE, FALSE, $module_list); drupal_load('module', 'system'); drupal_load('module', 'filter'); drupal_load('module', 'user'); // Load the cache infrastructure with the Fake Cache. Switch to the database cache // later if possible. require_once DRUPAL_ROOT . '/includes/cache.inc'; require_once DRUPAL_ROOT . '/includes/cache-install.inc'; $conf['cache_inc'] = 'includes/cache.inc'; $conf['cache_default_class'] = 'DrupalFakeCache'; // Prepare for themed output, if necessary. We need to run this at the // beginning of the page request to avoid a different theme accidentally // getting set. if ($install_state['interactive']) { drupal_maintenance_theme(); } // Check existing settings.php. $install_state['settings_verified'] = install_verify_settings(); if ($install_state['settings_verified']) { // Since we have a database connection, we use the normal cache system. // This is important, as the installer calls into the Drupal system for // the clean URL checks, so we should maintain the cache properly. unset($conf['cache_default_class']); // Initialize the database system. Note that the connection // won't be initialized until it is actually requested. require_once DRUPAL_ROOT . '/includes/database/database.inc'; // Verify the last completed task in the database, if there is one. $task = install_verify_completed_task(); } else { $task = NULL; // Since previous versions of Drupal stored database connection information // in the 'db_url' variable, we should never let an installation proceed if // this variable is defined and the settings file was not verified above // (otherwise we risk installing over an existing site whose settings file // has not yet been updated). if (!empty($GLOBALS['db_url'])) { throw new Exception(install_already_done_error()); } } // Modify the installation state as appropriate. $install_state['completed_task'] = $task; $install_state['database_tables_exist'] = !empty($task); // Add any installation parameters passed in via the URL. $install_state['parameters'] += $_GET; // Validate certain core settings that are used throughout the installation. if (!empty($install_state['parameters']['profile'])) { $install_state['parameters']['profile'] = preg_replace('/[^a-zA-Z_0-9]/', '', $install_state['parameters']['profile']); } if (!empty($install_state['parameters']['locale'])) { $install_state['parameters']['locale'] = preg_replace('/[^a-zA-Z_0-9\\-]/', '', $install_state['parameters']['locale']); } }
<?php print "\n" . $_SERVER['DOCUMENT_ROOT']; // display all errors error_reporting(E_ALL); ini_set("display_errors", 1); ini_set('memory_limit', '500M'); // adjust for your needs set_time_limit(4600); // adjust for your needs define('DRUPAL_ROOT', '/cygdrive/c/www/wyc.intranet.uw.edu/washyacht'); require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; //require_once DRUPAL_ROOT . '...'; // include required module files to work with here // you might need to define some of these if the script is not called from a webpage $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; // required, else drupal will complain $_SERVER['HTTP_HOST'] = 'local.wyc.com'; // optional but required for multi site configs $_SERVER['REQUEST_METHOD'] = 'GET'; // optional $_SERVER['SCRIPT_NAME'] = '/' . basename(__FILE__); // optional // Load Drupal drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); //drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE); drupal_override_server_variables(array('url' => 'http://local.wyc.com'));
/** * Listener prepares Drupal bootstrap environment. * * @param Event $event */ public function onPreConfiguration(Event $event) { drupal_override_server_variables(array('url' => $this->kernel->getUri())); }