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']));
}
$docLink = CRM_Utils_System::docURL2('Installation and Upgrades', FALSE, ts('Installation Guide'), NULL, NULL, "wiki");
- $errorMsg = ts("CiviCRM has already been installed. <ul><li>To <strong>start over</strong>, you must delete or rename the existing CiviCRM settings file - <strong>civicrm.settings.php</strong> - from <strong>%1</strong>.</li><li>To <strong>upgrade an existing installation</strong>, <a href='%2'>refer to the online documentation</a>.</li></ul>", array(1 => $settings_directory, 2 => $docLink));
+ $errorMsg = ts("CiviCRM has already been installed. <ul><li>To <strong>start over</strong>, you must delete or rename the existing CiviCRM settings file - <strong>civicrm.settings.php</strong> - from <strong>%1</strong>.</li><li>To <strong>upgrade an existing installation</strong>, refer to the online documentation: %2.</li></ul>", array(1 => $settings_directory, 2 => $docLink));
errorDisplayPage($errorTitle, $errorMsg, FALSE);
}
}
}
- // 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");
$this->errors = NULL;
- // See also: CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER
- $this->requirePHPVersion('5.3.4', array(
+ $this->requirePHPVersion(array(
ts("PHP Configuration"),
ts("PHP5 installed"),
- NULL,
- ts("PHP version %1", array(1 => phpversion())),
));
// Check that we can identify the root folder successfully
}
/**
- * @param $minVersion
- * @param $testDetails
- * @param null $maxVersion
+ * @param array $testDetails
+ * @return bool
*/
- public function requirePHPVersion($minVersion, $testDetails, $maxVersion = NULL) {
+ public function requirePHPVersion($testDetails) {
$this->testing($testDetails);
$phpVersion = phpversion();
- $aboveMinVersion = version_compare($phpVersion, $minVersion) >= 0;
- $belowMaxVersion = $maxVersion ? version_compare($phpVersion, $maxVersion) < 0 : TRUE;
+ $aboveMinVersion = version_compare($phpVersion, CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER) >= 0;
- if ($aboveMinVersion && $belowMaxVersion) {
- if (version_compare(phpversion(), CRM_Upgrade_Incremental_General::MIN_RECOMMENDED_PHP_VER) < 0) {
- $testDetails[2] = ts('This webserver is running an outdated version of PHP (%1). It is strongly recommended to upgrade to PHP %2 or later, as older versions can present a security risk.', array(
- 1 => phpversion(),
+ if ($aboveMinVersion) {
+ if (version_compare($phpVersion, CRM_Upgrade_Incremental_General::MIN_RECOMMENDED_PHP_VER) < 0) {
+ $testDetails[2] = ts('This webserver is running an outdated version of PHP (%1). It is strongly recommended to upgrade to PHP %2 or later, as older versions can present a security risk. The preferred version is %3.', array(
+ 1 => $phpVersion,
2 => CRM_Upgrade_Incremental_General::MIN_RECOMMENDED_PHP_VER,
+ 3 => CRM_Upgrade_Incremental_General::RECOMMENDED_PHP_VER,
));
$this->warning($testDetails);
}
return TRUE;
}
- if (!$testDetails[2]) {
- if (!$aboveMinVersion) {
- $testDetails[2] = ts("You need PHP version %1 or later, only %2 is installed. Please upgrade your server, or ask your web-host to do so.", array(1 => $minVersion, 2 => $phpVersion));
- }
- else {
- $testDetails[2] = ts("PHP version %1 is not supported. PHP version earlier than %2 is required. You might want to downgrade your server, or ask your web-host to do so.", array(1 => $maxVersion, 2 => $phpVersion));
- }
+ if (empty($testDetails[2])) {
+ $testDetails[2] = ts("You need PHP version %1 or later, only %2 is installed. Please upgrade your server, or ask your web-host to do so.", array(1 => CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER, 2 => $phpVersion));
}
$this->error($testDetails);
$output .= "<li>" . ts("Use the <a %1>Configuration Checklist</a> to review and configure settings for your new site", array(1 => "target='_blank' href='$cmsURL'")) . "</li>";
$output .= $commonOutputMessage;
- echo '</ul>';
- echo '</div>';
+ $output .= '</ul>';
+ $output .= '</div>';
+ 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 "<script>
window.location = '$wpInstallRedirect';
</script>";
* @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");
+ }
+ else {
+ $docLink = '';
+ }
if (function_exists('ts')) {
- $errorMsg .= '<p>' . ts("<a %1>Refer to the online documentation for more information</a>", array(1 => "href='$docLink'")) . '</p>';
+ $errorMsg .= '<p>' . ts("Refer to the online documentation for more information: ") . $docLink . '</p>';
}
else {
- $errorMsg .= '<p>' . sprintf("<a %s>Refer to the online documentation for more information</a>", "href='$docLink'") . '</p>';
+ $errorMsg .= '<p>' . 'Refer to the online documentation for more information: ' . $docLink . '</p>';
}
}