chamilo /
chamilo-lms
| 1 | <?php |
||||
| 2 | /* For licensing terms, see /license.txt */ |
||||
| 3 | |||||
| 4 | /** |
||||
| 5 | * Chamilo LMS. |
||||
| 6 | * |
||||
| 7 | * Only updates the main/inc/conf/configuration.php |
||||
| 8 | * |
||||
| 9 | * @package chamilo.install |
||||
| 10 | */ |
||||
| 11 | if (defined('SYSTEM_INSTALLATION')) { |
||||
| 12 | error_log("Starting ".basename(__FILE__)); |
||||
| 13 | $perm = api_get_permissions_for_new_files(); |
||||
| 14 | |||||
| 15 | $newConfFile = api_get_path(CONFIGURATION_PATH).'configuration.php'; |
||||
| 16 | // Check $fromVersionShort, defined in install.lib.php, in the switch |
||||
| 17 | // on full version numbers, to know from which version we are upgrading |
||||
| 18 | if ($fromVersionShort == '1.9') { |
||||
| 19 | $oldConfFile = api_get_path(SYS_CODE_PATH).'inc/conf/configuration.php'; |
||||
| 20 | |||||
| 21 | if (file_exists($oldConfFile)) { |
||||
| 22 | copy($oldConfFile, $newConfFile); |
||||
| 23 | @chmod($newConfFile, $perm); |
||||
|
0 ignored issues
–
show
|
|||||
| 24 | @rmdir($oldConfFile); |
||||
|
0 ignored issues
–
show
It seems like you do not handle an error condition for
rmdir(). This can introduce security issues, and is generally not recommended.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
|
|||||
| 25 | } |
||||
| 26 | } |
||||
| 27 | |||||
| 28 | // Edit the configuration file. |
||||
| 29 | $file = file($newConfFile); |
||||
| 30 | $fh = fopen($newConfFile, 'w'); |
||||
| 31 | |||||
| 32 | $found_version_old = false; |
||||
| 33 | $found_stable_old = false; |
||||
| 34 | $found_version = false; |
||||
| 35 | $found_stable = false; |
||||
| 36 | $found_software_name = false; |
||||
| 37 | $found_software_url = false; |
||||
| 38 | |||||
| 39 | foreach ($file as $line) { |
||||
| 40 | $ignore = false; |
||||
| 41 | if (stripos($line, '$_configuration[\'system_version\']') !== false) { |
||||
| 42 | $found_version = true; |
||||
| 43 | $line = '$_configuration[\'system_version\'] = \''.$GLOBALS['new_version'].'\';'."\r\n"; |
||||
| 44 | } elseif (stripos($line, '$_configuration[\'system_stable\']') !== false) { |
||||
| 45 | $found_stable = true; |
||||
| 46 | $line = '$_configuration[\'system_stable\'] = '.($GLOBALS['new_version_stable'] ? 'true' : 'false').';'."\r\n"; |
||||
| 47 | } elseif (stripos($line, '$_configuration[\'software_name\']') !== false) { |
||||
| 48 | $found_software_name = true; |
||||
| 49 | $line = '$_configuration[\'software_name\'] = \''.$GLOBALS['software_name'].'\';'."\r\n"; |
||||
| 50 | } elseif (stripos($line, '$_configuration[\'software_url\']') !== false) { |
||||
| 51 | $found_software_url = true; |
||||
| 52 | $line = '$_configuration[\'software_url\'] = \''.$GLOBALS['software_url'].'\';'."\r\n"; |
||||
| 53 | } elseif (stripos($line, '$userPasswordCrypted') !== false) { |
||||
| 54 | $line = '$_configuration[\'password_encryption\'] = \''.$userPasswordCrypted.'\';'."\r\n"; |
||||
| 55 | } elseif (stripos($line, '?>') !== false) { |
||||
| 56 | $ignore = true; |
||||
| 57 | } |
||||
| 58 | if (!$ignore) { |
||||
| 59 | fwrite($fh, $line); |
||||
| 60 | } |
||||
| 61 | } |
||||
| 62 | |||||
| 63 | if (!$found_version) { |
||||
| 64 | fwrite($fh, '$_configuration[\'system_version\'] = \''.$new_version.'\';'."\r\n"); |
||||
| 65 | } |
||||
| 66 | if (!$found_stable) { |
||||
| 67 | fwrite($fh, '$_configuration[\'system_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n"); |
||||
| 68 | } |
||||
| 69 | if (!$found_software_name) { |
||||
| 70 | fwrite($fh, '$_configuration[\'software_name\'] = \''.$software_name.'\';'."\r\n"); |
||||
| 71 | } |
||||
| 72 | if (!$found_software_url) { |
||||
| 73 | fwrite($fh, '$_configuration[\'software_url\'] = \''.$software_url.'\';'."\r\n"); |
||||
| 74 | } |
||||
| 75 | fclose($fh); |
||||
| 76 | |||||
| 77 | error_log("configuration.php file updated."); |
||||
| 78 | } else { |
||||
| 79 | echo 'You are not allowed here !'.__FILE__; |
||||
| 80 | } |
||||
| 81 |
If you suppress an error, we recommend checking for the error condition explicitly: