Exemplo n.º 1
0
 public function redirectToInstall()
 {
     // Redirect the user to the installation script if Drupal has not been
     // installed yet (i.e., if no $databases array has been defined in the
     // settings.php file) and we are not already installing.
     if (empty($GLOBALS['databases']) && !drupal_installation_attempted()) {
         include_once DRUPAL_ROOT . '/includes/install.inc';
         install_goto('install.php');
     }
 }
Exemplo n.º 2
0
/**
 * Form API submit for install_settings form.
 */
function install_settings_form_submit($form, &$form_state)
{
    global $profile, $install_locale;
    // Update global settings array and save
    $settings['db_url'] = array('value' => $form_state['values']['_db_url'], 'required' => TRUE);
    $settings['db_prefix'] = array('value' => $form_state['values']['db_prefix'], 'required' => TRUE);
    drupal_rewrite_settings($settings);
    // Continue to install profile step
    install_goto("install.php?profile={$profile}" . ($install_locale ? "&locale={$install_locale}" : ''));
}
Exemplo n.º 3
0
    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.
if ($update_access_allowed) {
    include_once DRUPAL_ROOT . '/includes/install.inc';
    include_once DRUPAL_ROOT . '/includes/batch.inc';
    drupal_load_updates();
    update_fix_d7_requirements();
    update_fix_compatibility();
    $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
    switch ($op) {
 */
if (isset($_ENV['PANTHEON_ENVIRONMENT']) && $is_installer_url && php_sapi_name() != "cli") {
    $GLOBALS['install_state']['settings_verified'] = TRUE;
}
/**
 * Allow Drupal 8 to Cleanly Redirect to Install.php For New Sites.
 *
 * Issue: https://github.com/pantheon-systems/drops-8/issues/3
 *
 * c.f. https://github.com/pantheon-systems/drops-8/pull/53
 *
 */
if (isset($_ENV['PANTHEON_ENVIRONMENT']) && !$is_installer_url && !is_dir(__DIR__ . '/files/styles') && empty($GLOBALS['install_state']) && php_sapi_name() != "cli") {
    include_once __DIR__ . '/../../core/includes/install.core.inc';
    include_once __DIR__ . '/../../core/includes/install.inc';
    install_goto('core/install.php');
}
/**
 * Override the $databases variable to pass the correct Database credentials
 * directly from Pantheon to Drupal.
 *
 * Issue: https://github.com/pantheon-systems/drops-8/issues/8
 *
 */
if (isset($_SERVER['PRESSFLOW_SETTINGS'])) {
    $pressflow_settings = json_decode($_SERVER['PRESSFLOW_SETTINGS'], TRUE);
    foreach ($pressflow_settings as $key => $value) {
        // One level of depth should be enough for $conf and $database.
        if ($key == 'conf') {
            foreach ($value as $conf_key => $conf_value) {
                $conf[$conf_key] = $conf_value;
Exemplo n.º 5
0
/**
 * Form API submit for install_settings form.
 */
function install_settings_form_submit($form, &$form_state)
{
    global $profile, $install_locale;
    $database = array_intersect_key($form_state['values']['_database'], array_flip(array('driver', 'database', 'username', 'password', 'host', 'port')));
    // Update global settings array and save
    $settings['databases'] = array('value' => array('default' => array('default' => $database)), 'required' => TRUE);
    $settings['db_prefix'] = array('value' => $form_state['values']['db_prefix'], 'required' => TRUE);
    drupal_rewrite_settings($settings);
    // Continue to install profile step
    install_goto("install.php?profile={$profile}" . ($install_locale ? "&locale={$install_locale}" : ''));
}
Exemplo n.º 6
0
/**
 * Install Drupal either interactively or via an array of passed-in settings.
 *
 * The Drupal installation happens in a series of steps, which may be spread
 * out over multiple page requests. Each request begins by trying to determine
 * the last completed installation step (also known as a "task"), if one is
 * available from a previous request. Control is then passed to the task
 * handler, which processes the remaining tasks that need to be run until (a)
 * an error is thrown, (b) a new page needs to be displayed, or (c) the
 * installation finishes (whichever happens first).
 *
 * @param $settings
 *   An optional array of installation settings. Leave this empty for a normal,
 *   interactive, browser-based installation intended to occur over multiple
 *   page requests. Alternatively, if an array of settings is passed in, the
 *   installer will attempt to use it to perform the installation in a single
 *   page request (optimized for the command line) and not send any output
 *   intended for the web browser. See install_state_defaults() for a list of
 *   elements that are allowed to appear in this array.
 *
 * @see install_state_defaults()
 */
function install_drupal($settings = array())
{
    global $install_state;
    // Initialize the installation state with the settings that were passed in,
    // as well as a boolean indicating whether or not this is an interactive
    // installation.
    $interactive = empty($settings);
    $install_state = $settings + array('interactive' => $interactive) + install_state_defaults();
    try {
        // Begin the page request. This adds information about the current state of
        // the Drupal installation to the passed-in array.
        install_begin_request($install_state);
        // Based on the installation state, run the remaining tasks for this page
        // request, and collect any output.
        $output = install_run_tasks($install_state);
    } catch (Exception $e) {
        // When an installation error occurs, either send the error to the web
        // browser or pass on the exception so the calling script can use it.
        if ($install_state['interactive']) {
            install_display_output($e->getMessage(), $install_state);
        } else {
            throw $e;
        }
    }
    // All available tasks for this page request are now complete. Interactive
    // installations can send output to the browser or redirect the user to the
    // next page.
    if ($install_state['interactive']) {
        if ($install_state['parameters_changed']) {
            // Redirect to the correct page if the URL parameters have changed.
            install_goto(install_redirect_url($install_state));
        } elseif (isset($output)) {
            // Display a page only if some output is available. Otherwise it is
            // possible that we are printing a JSON page and theme output should
            // not be shown.
            install_display_output($output, $install_state);
        }
    }
}
Exemplo n.º 7
0
}
// 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).
if (is_null($op) && update_access_allowed()) {
    require_once __DIR__ . '/includes/install.inc';
    require_once DRUPAL_ROOT . '/core/modules/system/system.install';
    // Set up theme system for the maintenance page.
    drupal_maintenance_theme();
    // Check the update requirements for Drupal. Only report on errors at this
    // stage, since the real requirements check happens further down.
    // The request will exit() if any requirement violations are reported in the
    // following function invocation.
    update_check_requirements(TRUE);
    // Redirect to the update information page if all requirements were met.
    install_goto('core/update.php?op=info');
}
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);
$regions = array();
// Only proceed with updates if the user is allowed to run them.
if (update_access_allowed()) {
    include_once __DIR__ . '/includes/install.inc';
    include_once __DIR__ . '/includes/batch.inc';
    drupal_load_updates();
    update_fix_compatibility();
    // Check the update requirements for all modules. If there are warnings, but
    // no errors, skip reporting them if the user has provided a URL parameter
    // acknowledging the warnings and indicating a desire to continue anyway. See
Exemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 public function redirectForm($form_state)
 {
     // Skip redirection for form submissions invoked via
     // \Drupal\Core\Form\FormBuilderInterface::submitForm().
     if (!empty($form_state['programmed'])) {
         return;
     }
     // Skip redirection if rebuild is activated.
     if (!empty($form_state['rebuild'])) {
         return;
     }
     // Skip redirection if it was explicitly disallowed.
     if (!empty($form_state['no_redirect'])) {
         return;
     }
     // Allow using redirect responses directly if needed.
     if (isset($form_state['redirect']) && $form_state['redirect'] instanceof RedirectResponse) {
         return $form_state['redirect'];
     }
     // Check for a route-based redirection.
     if (isset($form_state['redirect_route'])) {
         // @todo Remove once all redirects are converted to Url.
         if (!$form_state['redirect_route'] instanceof Url) {
             $form_state['redirect_route'] += array('route_parameters' => array(), 'options' => array());
             $form_state['redirect_route'] = new Url($form_state['redirect_route']['route_name'], $form_state['redirect_route']['route_parameters'], $form_state['redirect_route']['options']);
         }
         $form_state['redirect_route']->setAbsolute();
         // According to RFC 7231, 303 See Other status code must be used
         // to redirect user agent (and not default 302 Found).
         // @see http://tools.ietf.org/html/rfc7231#section-6.4.4
         return new RedirectResponse($form_state['redirect_route']->toString(), Response::HTTP_SEE_OTHER);
     }
     // Only invoke a redirection if redirect value was not set to FALSE.
     if (!isset($form_state['redirect']) || $form_state['redirect'] !== FALSE) {
         if (isset($form_state['redirect'])) {
             if (is_array($form_state['redirect'])) {
                 if (isset($form_state['redirect'][1])) {
                     $options = $form_state['redirect'][1];
                 } else {
                     $options = array();
                 }
                 // Redirections should always use absolute URLs.
                 $options['absolute'] = TRUE;
                 if (isset($form_state['redirect'][2])) {
                     $status_code = $form_state['redirect'][2];
                 } else {
                     $status_code = Response::HTTP_SEE_OTHER;
                 }
                 return new RedirectResponse($this->urlGenerator->generateFromPath($form_state['redirect'][0], $options), $status_code);
             } else {
                 // This function can be called from the installer, which guarantees
                 // that $redirect will always be a string, so catch that case here
                 // and use the appropriate redirect function.
                 if ($this->drupalInstallationAttempted()) {
                     install_goto($form_state['redirect']);
                 } else {
                     return new RedirectResponse($this->urlGenerator->generateFromPath($form_state['redirect'], array('absolute' => TRUE)), Response::HTTP_SEE_OTHER);
                 }
             }
         }
         $request = $this->requestStack->getCurrentRequest();
         // @todo Remove dependency on the internal _system_path attribute:
         //   https://www.drupal.org/node/2293521.
         $url = $this->urlGenerator->generateFromPath($request->attributes->get('_system_path'), array('query' => $request->query->all(), 'absolute' => TRUE));
         return new RedirectResponse($url, Response::HTTP_SEE_OTHER);
     }
 }
Exemplo n.º 9
0
<?php

/**
 * @file
 * The PHP page that serves all page requests on a Drupal installation.
 *
 * The routines here dispatch control to the appropriate handler, which then
 * prints the appropriate page.
 *
 * All Drupal code is released under the GNU General Public License.
 * See COPYRIGHT.txt and LICENSE.txt.
 */
/**
 * Root directory of Drupal installation.
 */
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
try {
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
} catch (PDOException $e) {
    // A PDO exception might mean that we are running on an empty database. In
    // that case, just redirect the user to install.php.
    if (!db_table_exists('variable')) {
        include_once DRUPAL_ROOT . '/includes/install.inc';
        install_goto('install.php');
    }
    throw $e;
}
menu_execute_active_handler();
Exemplo n.º 10
0
 /**
  * Metodo que carrega as configurações extras do banco de dados
  */
 private function LoadConfigDb()
 {
     //@todo fazer com que o load config carregue arrays do mysql com serealize, mas para isso precisa serializar so valores que ja estão no BD.
     $mysql = new MYSQL($this->cfg);
     if ($mysql->MysqlSelectDb($this->cfg['db_name'], $mysql->conexao)) {
         $result = $mysql->SqlSelect("SELECT * FROM {config}");
         while ($row = mysql_fetch_assoc($result)) {
             $this->cfg[$row['item']] = $row['valor'];
         }
     } else {
         /*
          * @TODO Não Existe banco de dados para instalação;
          **/
         install_goto('install.php');
     }
 }
Exemplo n.º 11
0
 /**
  * {@inheritdoc}
  */
 public function redirectForm(FormStateInterface $form_state)
 {
     // According to RFC 7231, 303 See Other status code must be used to redirect
     // user agent (and not default 302 Found).
     // @see http://tools.ietf.org/html/rfc7231#section-6.4.4
     $status_code = Response::HTTP_SEE_OTHER;
     $redirect = $form_state->getRedirect();
     // Allow using redirect responses directly if needed.
     if ($redirect instanceof RedirectResponse) {
         return $redirect;
     }
     $url = NULL;
     // Check for a route-based redirection.
     if ($redirect instanceof Url) {
         $url = $redirect->toString();
     } elseif (is_array($redirect)) {
         if (isset($redirect[1])) {
             $options = $redirect[1];
         } else {
             $options = array();
         }
         // Redirections should always use absolute URLs.
         $options['absolute'] = TRUE;
         if (isset($redirect[2])) {
             $status_code = $redirect[2];
         }
         $url = $this->urlGenerator->generateFromPath($redirect[0], $options);
     } elseif (is_string($redirect)) {
         // This function can be called from the installer, which guarantees
         // that $redirect will always be a string, so catch that case here
         // and use the appropriate redirect function.
         if ($this->drupalInstallationAttempted()) {
             install_goto($redirect);
         } else {
             $url = $this->urlGenerator->generateFromPath($redirect, array('absolute' => TRUE));
         }
     } elseif ($redirect === NULL) {
         $request = $this->requestStack->getCurrentRequest();
         // @todo Remove dependency on the internal _system_path attribute:
         //   https://www.drupal.org/node/2293521.
         $url = $this->urlGenerator->generateFromPath($request->attributes->get('_system_path'), array('query' => $request->query->all(), 'absolute' => TRUE));
     }
     if ($url) {
         return new RedirectResponse($url, $status_code);
     }
 }