X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=install%2Findex.php;h=5774078cc50a4f9ea3d83cc3ca804f8504127097;hb=e0b29e269a57b020d2212c16b4562f32f2274b63;hp=f23c6b4a60b564d23d6f94e031516ccec8971fa7;hpb=5eed9fbb25ff3f738df7ac6ae07ad2b5f1a6ee30;p=civicrm-core.git diff --git a/install/index.php b/install/index.php index f23c6b4a60..5774078cc5 100644 --- a/install/index.php +++ b/install/index.php @@ -54,35 +54,25 @@ else { define('CIVICRM_WINDOWS', 0); } -// set installation type - drupal -if (!session_id()) { - if (defined('PANTHEON_ENVIRONMENT')) { - ini_set('session.save_handler', 'files'); - } - session_start(); -} - -// unset civicrm session if any -if (array_key_exists('CiviCRM', $_SESSION)) { - unset($_SESSION['CiviCRM']); -} - -if (isset($_GET['civicrm_install_type'])) { - $_SESSION['civicrm_install_type'] = $_GET['civicrm_install_type']; -} -else { - if (!isset($_SESSION['civicrm_install_type'])) { - $_SESSION['civicrm_install_type'] = "drupal"; - } -} - global $installType; global $crmPath; global $pkgPath; global $installDirPath; global $installURLPath; -$installType = strtolower($_SESSION['civicrm_install_type']); +// Set the install type +// this is sent as a query string when the page is first loaded +// and subsequently posted to the page as a hidden field +if (isset($_POST['civicrm_install_type'])) { + $installType = $_POST['civicrm_install_type']; +} +elseif (isset($_GET['civicrm_install_type'])) { + $installType = strtolower($_GET['civicrm_install_type']); +} +else { + // default value if not set + $installType = "drupal"; +} if ($installType == 'drupal' || $installType == 'backdrop') { $crmPath = dirname(dirname($_SERVER['SCRIPT_FILENAME'])); @@ -233,7 +223,7 @@ if ($alreadyInstalled) { } $docLink = CRM_Utils_System::docURL2('Installation and Upgrades', FALSE, ts('Installation Guide'), NULL, NULL, "wiki"); - $errorMsg = ts("CiviCRM has already been installed. ", array(1 => $settings_directory, 2 => $docLink)); + $errorMsg = ts("CiviCRM has already been installed. ", array(1 => $settings_directory, 2 => $docLink)); errorDisplayPage($errorTitle, $errorMsg, FALSE); } @@ -267,8 +257,20 @@ if ($installType == 'drupal') { } } - // Bootstrap Drupal to get settings - drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION); + // Bootstrap Drupal to get settings and user + $base_root = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http'; + $base_root .= '://' . $_SERVER['HTTP_HOST']; + $base_url = $base_root; + drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); + + // Check that user is logged in and has administrative permissions + // This is necessary because the script exposes the database settings in the form and these could be viewed by unauthorised users + if ((!function_exists('user_access')) || (!user_access('administer site configuration'))) { + $errorTitle = ts("You don't have permission to access this page"); + $errorMsg = ts("The installer can only be run by a user with the permission to administer site configuration."); + errorDisplayPage($errorTitle, $errorMsg); + exit(); + } if (!defined('VERSION') or version_compare(VERSION, '6.0') < 0) { $errorTitle = ts("Oops! Incorrect Drupal version"); @@ -313,18 +315,10 @@ elseif ($installType == 'wordpress') { } } -// Load civicrm database config +// Load CiviCRM database config if (isset($_POST['mysql'])) { $databaseConfig = $_POST['mysql']; } -else { - $databaseConfig = array( - "server" => "localhost", - "username" => "civicrm", - "password" => "", - "database" => "civicrm", - ); -} if ($installType == 'wordpress') { // Load WP database config @@ -347,8 +341,12 @@ if ($installType == 'drupal') { $drupalConfig = $_POST['drupal']; } else { + $dbServer = $databases['default']['default']['host']; + if (!empty($databases['default']['default']['port'])) { + $dbServer .= ':' . $databases['default']['default']['port']; + } $drupalConfig = array( - "server" => $databases['default']['default']['host'] . ':' . $databases['default']['default']['port'], + "server" => $dbServer, "username" => $databases['default']['default']['username'], "password" => $databases['default']['default']['password'], "database" => $databases['default']['default']['database'], @@ -371,6 +369,16 @@ if ($installType == 'backdrop') { } } +// By default set CiviCRM database to be same as CMS database +if (!isset($databaseConfig)) { + if (($installType == 'drupal') && (isset($drupalConfig))) { + $databaseConfig = $drupalConfig; + } + if (($installType == 'backdrop') && (isset($backdropConfig))) { + $databaseConfig = $backdropConfig; + } +} + // Check requirements $req = new InstallRequirements(); $req->check(); @@ -1700,12 +1708,13 @@ class Installer extends InstallRequirements { $output .= "
  • " . ts("Use the Configuration Checklist to review and configure settings for your new site", array(1 => "target='_blank' href='$cmsURL'")) . "
  • "; $output .= $commonOutputMessage; - echo ''; - echo ''; + $output .= ''; + $output .= ''; + echo $output; $c = CRM_Core_Config::singleton(FALSE); $c->free(); - $wpInstallRedirect = admin_url("?page=CiviCRM&q=civicrm&reset=1"); + $wpInstallRedirect = admin_url('admin.php?page=CiviCRM&q=civicrm&reset=1'); echo ""; @@ -1831,14 +1840,18 @@ function getSiteDir($cmsPath, $str) { * @param $showRefer */ function errorDisplayPage($errorTitle, $errorMsg, $showRefer = TRUE) { + + // Add a link to the documentation if ($showRefer) { - $docLink = CRM_Utils_System::docURL2('Installation and Upgrades', FALSE, 'Installation Guide', NULL, NULL, "wiki"); + if (is_callable(array('CRM_Utils_System', 'docURL2'))) { + $docLink = CRM_Utils_System::docURL2('Installation and Upgrades', FALSE, 'Installation Guide', NULL, NULL, "wiki"); + } if (function_exists('ts')) { - $errorMsg .= '

    ' . ts("Refer to the online documentation for more information", array(1 => "href='$docLink'")) . '

    '; + $errorMsg .= '

    ' . ts("Refer to the online documentation for more information: ") . $docLink . '

    '; } else { - $errorMsg .= '

    ' . sprintf("Refer to the online documentation for more information", "href='$docLink'") . '

    '; + $errorMsg .= '

    ' . 'Refer to the online documentation for more information: ' . $docLink . '

    '; } }