Feature #272 - Adding a simple protection against re-installing the system.

skala
Ivan Tcholakov 15 years ago
parent bec8a11769
commit 2c07499a83
  1. 11
      main/inc/global_error_message.inc.php
  2. 8
      main/install/index.php
  3. 30
      main/install/install.lib.php

@ -23,6 +23,7 @@ $SectionSystemRequirementsProblem = 'System requirements problem';
$SectionInstallation = 'Installation';
$SectionDatabaseUnavailable = 'Database is unavailable';
$SectionTechnicalIssues = 'Technical issues';
$SectionProtection = 'Protection measure';
// Error code.
$ErrorCode = 'Error code';
@ -41,6 +42,10 @@ $InstallationDescription = 'Click to INSTALL Chamilo %s or read the installation
$DatabaseUnavailableTitle = 'Database is unavailable';
$DatabaseUnavailableDescription = 'This portal is currently experiencing database issues. Please report this to the portal administrator. Thank you for your help.';
// Error code 6.
$AlreadyInstalledTitle = 'Chamilo has already been installed';
$AlreadyInstalledDescription = 'The system has already been installed. In order its content to be protected you are not allowed to start the installation script again.';
// Unspecified error.
$TechnicalIssuesTitle = 'Technical issues';
$TechnicalIssuesDescription = 'This portal is currently experiencing technical issues. Please report this to the portal administrator. Thank you for your help.';
@ -128,6 +133,12 @@ if (is_int($global_error_code) && $global_error_code > 0) {
$global_error_message['description'] = $DatabaseUnavailableDescription;
break;
case 6:
$global_error_message['section'] = $SectionProtection;
$global_error_message['title'] = $AlreadyInstalledTitle;
$global_error_message['description'] = $AlreadyInstalledDescription;
break;
default:
$global_error_message['section'] = $SectionTechnicalIssues;
$global_error_message['title'] = $TechnicalIssuesTitle;

@ -132,6 +132,14 @@ $new_version = '1.8.7';
$new_version_stable = false;
$new_version_major = true;
// A protection measure for already installed systems.
if (is_already_installed_system()) {
// The system has already been installed, so block re-installation.
$global_error_code = 6;
require '../inc/global_error_message.inc.php';
die();
}
/*
==============================================================================
STEP 1 : INITIALIZES FORM VARIABLES IF IT IS THE FIRST VISIT

@ -29,6 +29,32 @@ define('SYSTEM_CONFIG_FILENAME', 'configuration.dist.php');
==============================================================================
*/
/**
* This function detects whether the system has been already installed.
* It should be used for prevention from second running the installation
* script and as a result - destroying a production system.
* @return bool The detected result;
* @author Ivan Tcholakov, 2010;
*/
function is_already_installed_system() {
global $new_version;
if (empty($new_version)) {
return true;
}
$current_config_file = str_replace('\\', '/', realpath('../inc/conf/configuration.php'));
if (!file_exists($current_config_file)) {
return false;
}
require $current_config_file;
// Careful, if/when the name 'dokeos_version' is changed. Check this then.
$current_version = $_configuration['dokeos_version'];
return empty($current_version) ? false : ($new_version == $current_version);
}
/**
* This function checks if a php extension exists or not and returns an HTML status string.
*
@ -396,7 +422,7 @@ function get_config_param($param, $updatePath = '') {
if (empty($updatePath) && !empty($_POST['updatePath'])) {
$updatePath = $_POST['updatePath'];
}
$updatePath = realpath($updatePath).'/';
$updatePath = api_add_trailing_slash(str_replace('\\', '/', realpath($updatePath)));
$updateFromInstalledVersionFile = '';
if (empty($updateFromConfigFile)) {
@ -1696,7 +1722,7 @@ function display_after_install_message($installType, $nbr_courses) {
<?php echo get_lang('FirstUseTip'); ?>
<?php if ($installType == 'update' && $nbr_courses > MAX_COURSE_TRANSFER): ?>
<?php if (false && $installType == 'update' && $nbr_courses > MAX_COURSE_TRANSFER): ?>
<br /><br />
<font color="red"><strong><?php echo get_lang('Warning'); ?> :</strong> <?php printf(get_lang('YouHaveMoreThanXCourses'), MAX_COURSE_TRANSFER, MAX_COURSE_TRANSFER,'<a href="update_courses.php"><font color="red">', '</font></a>'); ?></font>
<?php endif; ?>

Loading…
Cancel
Save