Files
Chamilo/main/install/update-configuration.inc.php
Xes 73154ae174
Behat tests 1.11.x 🐞 / PHP 7.4 Test on ubuntu-latest (push) Canceled after 0s
PHP-CS-Fixer / composer_install (7.4) (push) Canceled after 0s
Chamilo 1.11.40 (ZIP oficial v1.11.40)
Fuente: https://github.com/chamilo/chamilo-lms/releases/download/v1.11.40/chamilo-1.11.40.zip
sha256: 1cf4bf2cc7bae1ef1a1eff643235db1d552f78ddf4b6dd1e2d2dac9868679439
Snapshot independiente (rama huerfana); diffable vs 1.11.38. vendor incluido.
2026-08-06 17:59:45 +02:00

86 lines
3.2 KiB
PHP

<?php
/* For licensing terms, see /license.txt */
/**
* Chamilo LMS.
*
* Only updates the main/inc/conf/configuration.php
*
* @package chamilo.install
*/
if (defined('SYSTEM_INSTALLATION')) {
error_log("Starting ".basename(__FILE__));
$perm = api_get_permissions_for_new_files();
$newConfFile = api_get_path(CONFIGURATION_PATH).'configuration.php';
// Check $fromVersionShort, defined in install.lib.php, in the switch
// on full version numbers, to know from which version we are upgrading
if ($fromVersionShort == '1.9') {
$oldConfFile = api_get_path(SYS_CODE_PATH).'inc/conf/configuration.php';
if (file_exists($oldConfFile)) {
copy($oldConfFile, $newConfFile);
@chmod($newConfFile, $perm);
@rmdir($oldConfFile);
}
}
// Edit the configuration file.
$file = file($newConfFile);
$fh = fopen($newConfFile, 'w');
$found_version_old = false;
$found_stable_old = false;
$found_version = false;
$found_stable = false;
$found_software_name = false;
$found_software_url = false;
// Escape values before writing into PHP config to prevent code injection.
$safe = function ($value) {
return addcslashes((string) $value, "'\\");
};
foreach ($file as $line) {
$ignore = false;
if (stripos($line, '$_configuration[\'system_version\']') !== false) {
$found_version = true;
$line = '$_configuration[\'system_version\'] = \''.$safe($GLOBALS['new_version']).'\';'."\r\n";
} elseif (stripos($line, '$_configuration[\'system_stable\']') !== false) {
$found_stable = true;
$line = '$_configuration[\'system_stable\'] = '.($GLOBALS['new_version_stable'] ? 'true' : 'false').';'."\r\n";
} elseif (stripos($line, '$_configuration[\'software_name\']') !== false) {
$found_software_name = true;
$line = '$_configuration[\'software_name\'] = \''.$safe($GLOBALS['software_name']).'\';'."\r\n";
} elseif (stripos($line, '$_configuration[\'software_url\']') !== false) {
$found_software_url = true;
$line = '$_configuration[\'software_url\'] = \''.$safe($GLOBALS['software_url']).'\';'."\r\n";
} elseif (stripos($line, '$userPasswordCrypted') !== false) {
$line = '$_configuration[\'password_encryption\'] = \''.$safe($userPasswordCrypted).'\';'."\r\n";
} elseif (stripos($line, '?>') !== false) {
$ignore = true;
}
if (!$ignore) {
fwrite($fh, $line);
}
}
if (!$found_version) {
fwrite($fh, '$_configuration[\'system_version\'] = \''.$safe($new_version).'\';'."\r\n");
}
if (!$found_stable) {
fwrite($fh, '$_configuration[\'system_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n");
}
if (!$found_software_name) {
fwrite($fh, '$_configuration[\'software_name\'] = \''.$safe($software_name).'\';'."\r\n");
}
if (!$found_software_url) {
fwrite($fh, '$_configuration[\'software_url\'] = \''.$safe($software_url).'\';'."\r\n");
}
fclose($fh);
error_log("configuration.php file updated.");
} else {
echo 'You are not allowed here !'.__FILE__;
}