update-configuration.inc.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. // Edit the configuration file
  12. $file = file(api_get_path(CONFIGURATION_PATH).'configuration.php');
  13. $fh = fopen(api_get_path(CONFIGURATION_PATH).'configuration.php', 'w');
  14. $found_version_old = false;
  15. $found_stable_old = false;
  16. $found_version = false;
  17. $found_stable = false;
  18. $found_software_name = false;
  19. $found_software_url = false;
  20. foreach ($file as $line) {
  21. $ignore = false;
  22. if (stripos($line, '$_configuration[\'dokeos_version\']') !== false) {
  23. $found_version_old = true;
  24. $line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
  25. $ignore = true;
  26. } elseif (stripos($line, '$_configuration[\'system_version\']') !== false) {
  27. $found_version = true;
  28. $line = '$_configuration[\'system_version\'] = \''.$new_version.'\';'."\r\n";
  29. } elseif (stripos($line, '$_configuration[\'dokeos_stable\']') !== false) {
  30. $found_stable_old = true;
  31. $line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n";
  32. $ignore = true;
  33. } elseif (stripos($line, '$_configuration[\'system_stable\']') !== false) {
  34. $found_stable = true;
  35. $line = '$_configuration[\'system_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n";
  36. } elseif (stripos($line, '$_configuration[\'software_name\']') !== false) {
  37. $found_software_name = true;
  38. $line = '$_configuration[\'software_name\'] = \''.$software_name.'\';'."\r\n";
  39. } elseif (stripos($line, '$_configuration[\'software_url\']') !== false) {
  40. $found_software_url = true;
  41. $line = '$_configuration[\'software_url\'] = \''.$software_url.'\';'."\r\n";
  42. } elseif (stripos($line,'$userPasswordCrypted') !== false) {
  43. $line = '$userPasswordCrypted = \''.($userPasswordCrypted).'\';'."\r\n";
  44. } elseif (stripos($line, '?>') !== false) {
  45. $ignore = true;
  46. }
  47. if (!$ignore) {
  48. fwrite($fh, $line);
  49. }
  50. }
  51. if (!$found_version) {
  52. fwrite($fh, '$_configuration[\'system_version\'] = \''.$new_version.'\';'."\r\n");
  53. }
  54. if (!$found_stable) {
  55. fwrite($fh, '$_configuration[\'system_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");
  56. }
  57. if (!$found_software_name) {
  58. fwrite($fh, '$_configuration[\'software_name\'] = \''.$software_name.'\';'."\r\n");
  59. }
  60. if (!$found_software_url) {
  61. fwrite($fh, '$_configuration[\'software_url\'] = \''.$software_url.'\';'."\r\n");
  62. }
  63. fwrite($fh, '?>');
  64. fclose($fh);
  65. } else {
  66. echo 'You are not allowed here !';
  67. }