/** * The Drupal installation happens in a series of steps. We begin by verifying * that the current environment meets our minimum requirements. We then go * on to verify that settings.php is properly configured. From there we * connect to the configured database and verify that it meets our minimum * requirements. Finally we can allow the user to select an installation * profile and complete the installation process. * * @param $phase * The installation phase we should proceed to. */ function install_main() { require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION); // 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; } // This must go after drupal_bootstrap(), which unsets globals! global $profile, $install_locale, $conf; require_once './modules/system/system.install'; require_once './includes/file.inc'; // Ensure correct page headers are sent (e.g. caching) drupal_page_header(); // Set up $language, so t() caller functions will still work. drupal_init_language(); // Load module basics (needed for hook invokes). include_once './includes/module.inc'; $module_list['system']['filename'] = 'modules/system/system.module'; $module_list['filter']['filename'] = 'modules/filter/filter.module'; module_list(TRUE, FALSE, FALSE, $module_list); drupal_load('module', 'system'); drupal_load('module', 'filter'); // Install profile chosen, set the global immediately. // This needs to be done before the theme cache gets // initialized in drupal_maintenance_theme(). if (!empty($_GET['profile'])) { $profile = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['profile']); } // Set up theme system for the maintenance page. drupal_maintenance_theme(); // Check existing settings.php. $verify = install_verify_settings(); if ($verify) { // 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. require_once './includes/cache.inc'; $conf['cache_inc'] = './includes/cache.inc'; // Establish a connection to the database. require_once './includes/database.inc'; db_set_active(); // Check if Drupal is installed. $task = install_verify_drupal(); if ($task == 'done') { install_already_done_error(); } } else { // Since no persistent storage is available yet, and functions that check // for cached data will fail, we temporarily replace the normal cache // system with a stubbed-out version that short-circuits the actual // caching process and avoids any errors. require_once './includes/cache-install.inc'; $conf['cache_inc'] = './includes/cache-install.inc'; $task = NULL; } // No profile was passed in GET, ask the user. if (empty($_GET['profile'])) { if ($profile = install_select_profile()) { install_goto("install.php?profile={$profile}"); } else { install_no_profile_error(); } } // Load the profile. require_once "./profiles/{$profile}/{$profile}.profile"; // Locale selection if (!empty($_GET['locale'])) { $install_locale = preg_replace('/[^a-zA-Z_0-9\\-]/', '', $_GET['locale']); } elseif (($install_locale = install_select_locale($profile)) !== FALSE) { install_goto("install.php?profile={$profile}&locale={$install_locale}"); } // Tasks come after the database is set up if (!$task) { global $db_url; if (!$verify && !empty($db_url)) { // Do not install over a configured settings.php. install_already_done_error(); } // Check the installation requirements for Drupal and this profile. install_check_requirements($profile, $verify); // Verify existence of all required modules. $modules = drupal_verify_profile($profile, $install_locale); // If any error messages are set now, it means a requirement problem. $messages = drupal_set_message(); if (!empty($messages['error'])) { install_task_list('requirements'); drupal_set_title(st('Requirements problem')); print theme('install_page', ''); exit; } // Change the settings.php information if verification failed earlier. // Note: will trigger a redirect if database credentials change. if (!$verify) { install_change_settings($profile, $install_locale); } // Install system.module. drupal_install_system(); // Save the list of other modules to install for the 'profile-install' // task. variable_set() can be used now that system.module is installed // and drupal is bootstrapped. variable_set('install_profile_modules', array_diff($modules, array('system'))); } // The database is set up, turn to further tasks. install_tasks($profile, $task); }
$update_access_allowed = !empty($update_free_access) || $user->uid == 1; // Only allow the requirements check to proceed if the current user has access // to run updates (since it may expose sensitive information about the site's // configuration). $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : ''; if (empty($op) && $update_access_allowed) { require_once DRUPAL_ROOT . '/includes/install.inc'; require_once DRUPAL_ROOT . '/includes/file.inc'; require_once DRUPAL_ROOT . '/modules/system/system.install'; // Load module basics. include_once DRUPAL_ROOT . '/includes/module.inc'; $module_list['system']['filename'] = 'modules/system/system.module'; $module_list['filter']['filename'] = 'modules/filter/filter.module'; module_list(TRUE, FALSE, $module_list); drupal_load('module', 'system'); drupal_load('module', 'filter'); // Set up $language, since the installer components require it. drupal_init_language(); // Set up theme system for the maintenance page. drupal_maintenance_theme(); // Check the update requirements for Drupal. update_check_requirements(); // Redirect to the update information page if all requirements were met. install_goto('update.php?op=info'); } drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); drupal_maintenance_theme(); // Turn error reporting back on. From now on, only fatal errors (which are // not passed through the error handler) will cause a message to be printed. ini_set('display_errors', TRUE); // Only proceed with updates if the user is allowed to run them.
/** * Constructor for this authentication source. * * @param array $info Information about this authentication source. * @param array $config Configuration. */ public function __construct($info, $config) { assert('is_array($info)'); assert('is_array($config)'); /* Call the parent constructor first, as required by the interface. */ parent::__construct($info, $config); /* Get the configuration for this module */ $drupalAuthConfig = new sspmod_drupalauth_ConfigHelper($config, 'Authentication source ' . var_export($this->authId, TRUE)); $this->debug = $drupalAuthConfig->getDebug(); $this->attributes = $drupalAuthConfig->getAttributes(); $this->cookie_name = $drupalAuthConfig->getCookieName(); $this->drupal_logout_url = $drupalAuthConfig->getDrupalLogoutURL(); $this->drupal_login_url = $drupalAuthConfig->getDrupalLoginURL(); if (!defined('DRUPAL_ROOT')) { define('DRUPAL_ROOT', $drupalAuthConfig->getDrupalroot()); } $ssp_config = SimpleSAML_Configuration::getInstance(); $this->cookie_path = '/' . $ssp_config->getValue('baseurlpath'); $this->cookie_salt = $ssp_config->getValue('secretsalt'); $a = getcwd(); chdir(DRUPAL_ROOT); /* Include the Drupal bootstrap */ //require_once(DRUPAL_ROOT.'/includes/common.inc'); require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; require_once DRUPAL_ROOT . '/includes/file.inc'; /* Using DRUPAL_BOOTSTRAP_FULL means that SimpleSAMLphp must use an session storage * mechanism other than phpsession (see: store.type in config.php). However, this trade-off * prevents the need for hackery here and makes this module work better in different environments. */ drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); // we need to be able to call Drupal user function so we load some required modules drupal_load('module', 'system'); drupal_load('module', 'user'); drupal_load('module', 'field'); chdir($a); }
function synlogin($get, $post) { $uid = $get['uid']; $username = $get['username']; //echo $uid.'/'.$username; if (!API_SYNLOGIN) { return API_RETURN_FORBIDDEN; } // drupal user login chdir(DRUPAL_ROOT_PATH); require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); drupal_load('module', 'user'); watchdog(t('user'), t('synlogin:start username:@username uid:@uid', array('@username' => $GLOBALS['user']->name, '@uid' => $GLOBALS['user']->uid))); $user = user_load(array('name' => $username)); //user_external_login_register($username, 'ucenter'); //sess_regenerate(); //$state ['values'] = array('name'=>$username); //user_authenticate_finalize($state ['values']); //echo $username.'/ucenter'; watchdog(t('user'), t('synlogin:end username:@username uid:@uid', array('@username' => $GLOBALS['user']->name, '@uid' => $GLOBALS['user']->uid))); return API_RETURN_SUCCEED; }
require_once DRUPAL_ROOT . '/includes/unicode.inc'; update_prepare_d7_bootstrap(); // Determine if the current user has access to run update.php. drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION); // Only allow the requirements check to proceed if the current user has access // to run updates (since it may expose sensitive information about the site's // configuration). $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : ''; if (empty($op) && update_access_allowed()) { require_once DRUPAL_ROOT . '/includes/install.inc'; require_once DRUPAL_ROOT . '/modules/system/system.install'; // Load module basics. include_once DRUPAL_ROOT . '/includes/module.inc'; $module_list['system']['filename'] = 'modules/system/system.module'; module_list(TRUE, FALSE, FALSE, $module_list); drupal_load('module', 'system'); // Reset the module_implements() cache so that any new hook implementations // in updated code are picked up. module_implements('', FALSE, TRUE); // Set up $language, since the installer components require it. drupal_language_initialize(); // Set up theme system for the maintenance page. drupal_maintenance_theme(); // Check the update requirements for Drupal. update_check_requirements(); // Redirect to the update information page if all requirements were met. install_goto('update.php?op=info'); } // update_fix_d7_requirements() needs to run before bootstrapping beyond path. // So bootstrap to DRUPAL_BOOTSTRAP_LANGUAGE then include unicode.inc. drupal_bootstrap(DRUPAL_BOOTSTRAP_LANGUAGE);
/** * The Drupal installation happens in a series of steps. We begin by verifying * that the current environment meets our minimum requirements. We then go * on to verify that settings.php is properly configured. From there we * connect to the configured database and verify that it meets our minimum * requirements. Finally we can allow the user to select an installation * profile and complete the installation process. * * @param $phase * The installation phase we should proceed to. */ function install_main() { require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION); // This must go after drupal_bootstrap(), which unsets globals! global $profile, $install_locale; require_once './modules/system/system.install'; require_once './includes/file.inc'; // Ensure correct page headers are sent (e.g. caching) drupal_page_header(); // Check existing settings.php. $verify = install_verify_settings(); // Drupal may already be installed. if ($verify) { // Establish a connection to the database. require_once './includes/database.inc'; db_set_active(); // Check if Drupal is installed. if (install_verify_drupal()) { install_already_done_error(); } } // Load module basics (needed for hook invokes). include_once './includes/module.inc'; $module_list['system']['filename'] = 'modules/system/system.module'; $module_list['filter']['filename'] = 'modules/filter/filter.module'; module_list(TRUE, FALSE, FALSE, $module_list); drupal_load('module', 'system'); drupal_load('module', 'filter'); // Decide which profile to use. if (!empty($_GET['profile'])) { $profile = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['profile']); } elseif ($profile = install_select_profile()) { install_goto("install.php?profile={$profile}"); } else { install_no_profile_error(); } // Locale selection if (!empty($_GET['locale'])) { $install_locale = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['locale']); } elseif (($install_locale = install_select_locale($profile)) !== FALSE) { install_goto("install.php?profile={$profile}&locale={$install_locale}"); } // Load the profile. require_once "./profiles/{$profile}/{$profile}.profile"; // Check the installation requirements for Drupal and this profile. install_check_requirements($profile); // Change the settings.php information if verification failed earlier. // Note: will trigger a redirect if database credentials change. if (!$verify) { install_change_settings($profile, $install_locale); } // Verify existence of all required modules. $modules = drupal_verify_profile($profile, $install_locale); if (!$modules) { install_missing_modules_error($profile); } // Perform actual installation defined in the profile. drupal_install_profile($profile, $modules); // Warn about settings.php permissions risk $settings_file = './' . conf_path() . '/settings.php'; if (!drupal_verify_install_file($settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE)) { drupal_set_message(st('All necessary changes to %file have been made, so you should now remove write permissions to this file. Failure to remove write permissions to this file is a security risk.', array('%file' => $settings_file)), 'error'); } else { drupal_set_message(st('All necessary changes to %file have been made. It has been set to read-only for security.', array('%file' => $settings_file))); } // Show end page. install_complete($profile); }
/** * Perform setup tasks for all page requests. * * This hook is run at the beginning of the page request. It is typically * used to set up global parameters that are needed later in the request. * * Only use this hook if your code must run even for cached page views. This * hook is called before the theme, modules, or most include files are loaded * into memory. It happens while Drupal is still in bootstrap mode. * * @see hook_init() */ function hook_boot() { // We need user_access() in the shutdown function. Make sure it gets loaded. drupal_load('module', 'user'); drupal_register_shutdown_function('devel_shutdown'); }
/** * Loads the requested module and executes the requested callback. * * @return * The callback function's return value or one of the JS_* constants. */ function js_execute_callback() { $args = explode('/', $_GET['q']); // If i18n is enabled and therefore the js module should boot // to DRUPAL_BOOTSTRAP_LANGUAGE. $i18n = FALSE; // Validate if there is a language prefix in the path. if (!empty($args[0]) && !empty($args[1]) && $args[1] == 'js_callback') { // Language string detected, strip off the language code. $language_code = array_shift($args); // Enable language detection to make sure i18n is enabled. $i18n = TRUE; } // Strip first argument 'js_callback'. if (!empty($args[0]) && $args[0] == 'js_callback') { array_shift($args); } // Determine module to load. $module = check_plain(array_shift($args)); if (!$module || !drupal_load('module', $module)) { return JS_MENU_ACCESS_DENIED; } // Get info hook function name. $function = $module . '_js'; if (!function_exists($function)) { return JS_MENU_NOT_FOUND; } // Get valid callbacks. $valid_callbacks = $function(); // Get the callback. $callback = check_plain(array_shift($args)); // Validate the callback. if (!isset($valid_callbacks[$callback])) { return JS_MENU_NOT_FOUND; } // If the callback function is located in another file, load that file now. if (isset($valid_callbacks[$callback]['file']) && ($filepath = drupal_get_path('module', $module) . '/' . $valid_callbacks[$callback]['file']) && file_exists($filepath)) { require_once $filepath; } // Validate the existance of the defined callback. if (!function_exists($valid_callbacks[$callback]['callback'])) { return JS_MENU_NOT_FOUND; } // Bootstrap to required level. $full_boostrap = FALSE; if (!empty($valid_callbacks[$callback]['bootstrap'])) { drupal_bootstrap($valid_callbacks[$callback]['bootstrap']); $full_boostrap = $valid_callbacks[$callback]['bootstrap'] == DRUPAL_BOOTSTRAP_FULL; } // Validate if the callback uses i18n. if (isset($valid_callbacks[$callback]['i18n'])) { $i18n = $valid_callbacks[$callback]['i18n']; } if (!$full_boostrap) { // The following mimics the behavior of _drupal_bootstrap_full(). // The difference is that not all modules and includes are loaded. // @see _drupal_bootstrap_full(). // If i18n is enabled, boot to the language phase and make // sure the required modules are enabled. if ($i18n) { // First boot to the variables to make sure drupal_multilingual() works. drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES); // As the variables bootstrap phase loads all core modules, we have to // add the user module and the path include as a dependencies because they // are required by some core modules. if (empty($valid_callbacks[$callback]['dependencies'])) { $valid_callbacks[$callback]['dependencies'] = array(); } if (empty($valid_callbacks[$callback]['includes'])) { $valid_callbacks[$callback]['includes'] = array(); } if (!in_array('user', $valid_callbacks[$callback]['dependencies'])) { $valid_callbacks[$callback]['dependencies'][] = 'user'; } if (!in_array('path', $valid_callbacks[$callback]['includes'])) { $valid_callbacks[$callback]['includes'][] = 'path'; } // Then check if it's a multilingual site. If so, boot to the language // phase. if (drupal_multilingual()) { drupal_bootstrap(DRUPAL_BOOTSTRAP_LANGUAGE); } } // Load required include files based on the callback. if (isset($valid_callbacks[$callback]['includes']) && is_array($valid_callbacks[$callback]['includes'])) { foreach ($valid_callbacks[$callback]['includes'] as $include) { if (file_exists("./includes/{$include}.inc")) { require_once "./includes/{$include}.inc"; } } } // Detect string handling method. unicode_check(); // Undo magic quotes. fix_gpc_magic(); // Make sure all stream wrappers are registered. file_get_stream_wrappers(); // Load required modules. $modules = array($module => 0); if (isset($valid_callbacks[$callback]['dependencies']) && is_array($valid_callbacks[$callback]['dependencies'])) { foreach ($valid_callbacks[$callback]['dependencies'] as $dependency) { if (!drupal_load('module', $dependency)) { // Do a boot up till SESSION to be sure the drupal_set_message() // function works. drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION); // Create an error message with information for the user to be able // to fix the dependency. $error = t('The dependency :dependency for the callback :callback in :module is not installed.', array(':dependency' => $dependency, ':callback' => $callback, ':module' => $module)); // Let the user know what's wrong and throw an exception to stop the // callback. drupal_set_message($error, 'error'); throw new Exception($error); } $modules[$dependency] = 0; } } // Reset module list. module_list(FALSE, TRUE, FALSE, $modules); // Ensure the language variable is set, if not it might cause problems (e.g. // entity info). global $language; if (!isset($language)) { $language = language_default(); } // If access arguments are passed, boot to SESSION and validate if the user // has access to this callback. if (!empty($valid_callbacks[$callback]['access arguments']) || !empty($valid_callbacks[$callback]['access callback'])) { drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION); // If no callback is provided, default to user_access. if (!isset($valid_callbacks[$callback]['access callback'])) { $valid_callbacks[$callback]['access callback'] = 'user_access'; } if ($valid_callbacks[$callback]['access callback'] == 'user_access') { // Ensure the user module is available. drupal_load('module', 'user'); } if (!call_user_func_array($valid_callbacks[$callback]['access callback'], !empty($valid_callbacks[$callback]['access arguments']) ? $valid_callbacks[$callback]['access arguments'] : array())) { return JS_MENU_ACCESS_DENIED; } } // Invoke implementations of hook_init() if the callback doesn't indicate it // should be skipped. if (!isset($valid_callbacks[$callback]['skip_hook_init']) || $valid_callbacks[$callback]['skip_hook_init'] == FALSE) { module_invoke_all('init'); } } // If there are page arguments defined add them to the callback call. if (isset($valid_callbacks[$callback]['page arguments'])) { // Get the original args again and strip first arguments 'js_callback' and 'module'. $args = array_slice(explode('/', $_GET['q']), 2); // Overwrite the arguments $args = array_intersect_key($args, array_flip($valid_callbacks[$callback]['page arguments'])); } // Invoke callback function. return call_user_func_array($valid_callbacks[$callback]['callback'], $args); }
require_once DRUPAL_ROOT . '/includes/common.inc'; require_once DRUPAL_ROOT . '/includes/file.inc'; require_once DRUPAL_ROOT . '/includes/module.inc'; require_once DRUPAL_ROOT . '/includes/ajax.inc'; // We prepare only a minimal bootstrap. This includes the database and // variables, however, so we have access to the class autoloader registry. drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION); // This must go after drupal_bootstrap(), which unsets globals! global $conf; // We have to enable the user and system modules, even to check access and // display errors via the maintainence theme. $module_list['system']['filename'] = 'modules/system/system.module'; $module_list['user']['filename'] = 'modules/user/user.module'; module_list(TRUE, FALSE, FALSE, $module_list); drupal_load('module', 'system'); drupal_load('module', 'user'); // We also want to have the language system available, but we do *NOT* want to // actually call drupal_bootstrap(DRUPAL_BOOTSTRAP_LANGUAGE), since that would // also force us through the DRUPAL_BOOTSTRAP_PAGE_HEADER phase, which loads // all the modules, and that's exactly what we're trying to avoid. drupal_language_initialize(); // Initialize the maintenance theme for this administrative script. drupal_maintenance_theme(); $output = ''; $show_messages = TRUE; if (authorize_access_allowed()) { // Load both the Form API and Batch API. require_once DRUPAL_ROOT . '/includes/form.inc'; require_once DRUPAL_ROOT . '/includes/batch.inc'; // Load the code that drives the authorize process. require_once DRUPAL_ROOT . '/includes/authorize.inc';
/** * 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']); } }
/** * Includes a file with the provided type and name. * * This prevents including a theme, engine, module, etc., more than once. * * @param $type * The type of item to load (i.e. theme, theme_engine, module). * @param $name * The name of the item to load. * * @return bool * TRUE if the item is loaded or has already been loaded. */ public function drupal_load($type, $name) { return drupal_load($type, $name); }
<?php /** * @file * An optimized page execution used for ELMSLN API calls for a * minimally bootstrapped Drupal installation. */ /** * Root directory of Drupal installation. */ define('DRUPAL_ROOT', getcwd()); /** * Required core files needed to run any request. */ require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; require_once DRUPAL_ROOT . '/includes/common.inc'; require_once DRUPAL_ROOT . '/includes/module.inc'; require_once DRUPAL_ROOT . '/includes/unicode.inc'; require_once DRUPAL_ROOT . '/includes/file.inc'; // Bootstrap Drupal to at least the database level so it can be accessed. drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE); // Load the ELMSLN API module and execute request. drupal_load('module', 'elmsln_api'); elmsln_api_execute_request();
/** * The Drupal installation happens in a series of steps. We begin by verifying * that the current environment meets our minimum requirements. We then go * on to verify that settings.php is properly configured. From there we * connect to the configured database and verify that it meets our minimum * requirements. Finally we can allow the user to select an installation * profile and complete the installation process. * * @param $phase * The installation phase we should proceed to. */ function install_main() { require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION); // 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; } // This must go after drupal_bootstrap(), which unsets globals! global $profile, $install_locale, $conf; require_once DRUPAL_ROOT . '/modules/system/system.install'; require_once DRUPAL_ROOT . '/includes/file.inc'; // Ensure correct page headers are sent (e.g. caching) drupal_page_header(); // Set up $language, so t() caller functions will still work. drupal_init_language(); // Load module basics (needed for hook invokes). include_once DRUPAL_ROOT . '/includes/module.inc'; $module_list['system']['filename'] = 'modules/system/system.module'; $module_list['filter']['filename'] = 'modules/filter/filter.module'; module_list(TRUE, FALSE, FALSE, $module_list); drupal_load('module', 'system'); drupal_load('module', 'filter'); // Load the cache infrastructure using a "fake" cache implementation that // does not attempt to write to the database. We need this during the initial // part of the installer because the database is not available yet. We // continue to use it even when the database does become available, in order // to preserve consistency between interactive and command-line installations // (the latter complete in one page request and therefore are forced to // continue using the cache implementation they started with) and also // because any data put in the cache during the installer is inherently // suspect, due to the fact that Drupal is not fully set up yet. require_once DRUPAL_ROOT . '/includes/cache-install.inc'; $conf['cache_inc'] = './includes/cache-install.inc'; // Install profile chosen, set the global immediately. // This needs to be done before the theme cache gets // initialized in drupal_maintenance_theme(). if (!empty($_GET['profile'])) { $profile = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['profile']); } // Set up theme system for the maintenance page. drupal_maintenance_theme(); // Check existing settings.php. $verify = install_verify_settings(); if ($verify) { // Establish a connection to the database. require_once DRUPAL_ROOT . '/includes/database.inc'; db_set_active(); // Check if Drupal is installed. $task = install_verify_drupal(); if ($task == 'done') { install_already_done_error(); } } else { $task = NULL; } // No profile was passed in GET, ask the user. if (empty($_GET['profile'])) { if ($profile = install_select_profile()) { install_goto("install.php?profile={$profile}"); } else { install_no_profile_error(); } } // Load the profile. require_once DRUPAL_ROOT . "/profiles/{$profile}/{$profile}.profile"; // Locale selection if (!empty($_GET['locale'])) { $install_locale = preg_replace('/[^a-zA-Z_0-9\\-]/', '', $_GET['locale']); } elseif (($install_locale = install_select_locale($profile)) !== FALSE) { install_goto("install.php?profile={$profile}&locale={$install_locale}"); } // Tasks come after the database is set up if (!$task) { global $db_url; if (!$verify && !empty($db_url)) { // Do not install over a configured settings.php. install_already_done_error(); } // Check the installation requirements for Drupal and this profile. install_check_requirements($profile, $verify); // Verify existence of all required modules. $modules = drupal_verify_profile($profile, $install_locale); // If any error messages are set now, it means a requirement problem. $messages = drupal_set_message(); if (!empty($messages['error'])) { install_task_list('requirements'); drupal_set_title(st('Requirements problem')); print theme('install_page', ''); exit; } // Change the settings.php information if verification failed earlier. // Note: will trigger a redirect if database credentials change. if (!$verify) { install_change_settings($profile, $install_locale); } // The default lock implementation uses a database table, // so we cannot use it for install, but we still need // the API functions available. require_once './includes/lock-install.inc'; $conf['lock_inc'] = './includes/lock-install.inc'; lock_init(); // Install system.module. drupal_install_system(); // Ensure that all of Drupal's standard directories have appropriate // .htaccess files. These directories will have already been created by // this point in the installer, since Drupal creates them during the // install_check_requirements() task. Note that we cannot create them any // earlier than this, since the code below relies on system.module in order // to work. file_create_htaccess(file_directory_path()); file_create_htaccess(file_directory_temp()); // Save the list of other modules to install for the 'profile-install' // task. variable_set() can be used now that system.module is installed // and drupal is bootstrapped. variable_set('install_profile_modules', array_diff($modules, array('system'))); } // The database is set up, turn to further tasks. install_tasks($profile, $task); }
<?php /** * @file * An optimized page execution used to serve JavaScript AJAX requests using a * minimally bootstrapped Drupal installation. */ /** * Root directory of Drupal installation. */ define('DRUPAL_ROOT', getcwd()); /** * Required core files needed to run any AJAX request. */ require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; require_once DRUPAL_ROOT . '/includes/common.inc'; require_once DRUPAL_ROOT . '/includes/module.inc'; require_once DRUPAL_ROOT . '/includes/unicode.inc'; require_once DRUPAL_ROOT . '/includes/file.inc'; // Bootstrap Drupal to at least the database level so it can be accessed. drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE); // Load the JS module and execute request. drupal_load('module', 'js'); js_execute_request();