update-configuration.inc.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. *
  5. * Chamilo LMS
  6. *
  7. * Only updates the main/inc/conf/configuration.php file with the new version use only from 1.8.8.1 to 1.8.8.2 (with no DB changes)
  8. * @package chamilo.install
  9. */
  10. if (defined('SYSTEM_INSTALLATION')) {
  11. $app['monolog']->addInfo("Starting " . basename(__FILE__));
  12. // Edit the configuration file
  13. $file = file(api_get_path(CONFIGURATION_PATH) . 'configuration.php');
  14. $fh = fopen(api_get_path(CONFIGURATION_PATH) . 'configuration.php', 'w');
  15. $found_version_old = false;
  16. $found_stable_old = false;
  17. $found_version = false;
  18. $found_stable = false;
  19. $found_software_name = false;
  20. $found_software_url = false;
  21. foreach ($file as $line) {
  22. $ignore = false;
  23. if (stripos($line, '$_configuration[\'dokeos_version\']') !== false) {
  24. $found_version_old = true;
  25. $line = '$_configuration[\'dokeos_version\'] = \'' . $new_version . '\';' . "\r\n";
  26. $ignore = true;
  27. } elseif (stripos($line, '$_configuration[\'system_version\']') !== false) {
  28. $found_version = true;
  29. $line = '$_configuration[\'system_version\'] = \'' . $new_version . '\';' . "\r\n";
  30. } elseif (stripos($line, '$_configuration[\'dokeos_stable\']') !== false) {
  31. $found_stable_old = true;
  32. $line = '$_configuration[\'dokeos_stable\'] = ' . ($new_version_stable ? 'true' : 'false') . ';' . "\r\n";
  33. $ignore = true;
  34. } elseif (stripos($line, '$_configuration[\'system_stable\']') !== false) {
  35. $found_stable = true;
  36. $line = '$_configuration[\'system_stable\'] = ' . ($new_version_stable ? 'true' : 'false') . ';' . "\r\n";
  37. } elseif (stripos($line, '$_configuration[\'software_name\']') !== false) {
  38. $found_software_name = true;
  39. $line = '$_configuration[\'software_name\'] = \'' . $software_name . '\';' . "\r\n";
  40. } elseif (stripos($line, '$_configuration[\'software_url\']') !== false) {
  41. $found_software_url = true;
  42. $line = '$_configuration[\'software_url\'] = \'' . $software_url . '\';' . "\r\n";
  43. } elseif (stripos($line, '$userPasswordCrypted') !== false) {
  44. //$line = '$userPasswordCrypted = \'' . ($userPasswordCrypted) . '\';' . "\r\n";
  45. $line = '$_configuration[\'password_encryption\'] = \'' .$userPasswordCrypted.'\';' . "\r\n";
  46. } elseif (stripos($line, '?>') !== false) {
  47. $ignore = true;
  48. }
  49. if (!$ignore) {
  50. fwrite($fh, $line);
  51. }
  52. }
  53. if (!$found_version) {
  54. fwrite($fh, '$_configuration[\'system_version\'] = \'' . $new_version . '\';' . "\r\n");
  55. }
  56. if (!$found_stable) {
  57. fwrite($fh, '$_configuration[\'system_stable\'] = ' . ($new_version_stable ? 'true' : 'false') . ';' . "\r\n");
  58. }
  59. if (!$found_software_name) {
  60. fwrite($fh, '$_configuration[\'software_name\'] = \'' . $software_name . '\';' . "\r\n");
  61. }
  62. if (!$found_software_url) {
  63. fwrite($fh, '$_configuration[\'software_url\'] = \'' . $software_url . '\';' . "\r\n");
  64. }
  65. fwrite($fh, '?>');
  66. fclose($fh);
  67. } else {
  68. echo 'You are not allowed here !'. __FILE__;
  69. }