update-files-1.8.6.2-1.8.7.inc.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Chamilo LMS
  5. *
  6. * Updates the Chamilo files from version 1.8.6.2 to version 1.8.7
  7. * This script operates only in the case of an update, and only to change the
  8. * active version number (and other things that might need a change) in the
  9. * current configuration file.
  10. * @package chamilo.install
  11. */
  12. Log::notice('Entering file');
  13. if (defined('SYSTEM_INSTALLATION')) {
  14. // Edit the configuration file
  15. $file = file(api_get_path(CONFIGURATION_PATH).'configuration.php');
  16. $fh = fopen(api_get_path(CONFIGURATION_PATH).'configuration.php', 'w');
  17. $found_version_old = false;
  18. $found_stable_old = false;
  19. $found_version = false;
  20. $found_stable = false;
  21. $found_software_name = false;
  22. $found_software_url = false;
  23. foreach ($file as $line) {
  24. $ignore = false;
  25. if (stripos($line, '$_configuration[\'dokeos_version\']') !== false) {
  26. $found_version_old = true;
  27. $line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
  28. $ignore = true;
  29. } elseif (stripos($line, '$_configuration[\'system_version\']') !== false) {
  30. $found_version = true;
  31. $line = '$_configuration[\'system_version\'] = \''.$new_version.'\';'."\r\n";
  32. } elseif (stripos($line, '$_configuration[\'dokeos_stable\']') !== false) {
  33. $found_stable_old = true;
  34. $line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n";
  35. $ignore = true;
  36. } elseif (stripos($line, '$_configuration[\'system_stable\']') !== false) {
  37. $found_stable = true;
  38. $line = '$_configuration[\'system_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n";
  39. } elseif (stripos($line, '$_configuration[\'software_name\']') !== false) {
  40. $found_software_name = true;
  41. $line = '$_configuration[\'software_name\'] = \''.$software_name.'\';'."\r\n";
  42. } elseif (stripos($line, '$_configuration[\'software_url\']') !== false) {
  43. $found_software_url = true;
  44. $line = '$_configuration[\'software_url\'] = \''.$software_url.'\';'."\r\n";
  45. } elseif (stripos($line,'$userPasswordCrypted') !== false) {
  46. $line = '$userPasswordCrypted = \''.($userPasswordCrypted).'\';'."\r\n";
  47. } elseif (stripos($line, '?>') !== false) {
  48. $ignore = true;
  49. }
  50. if (!$ignore) {
  51. fwrite($fh, $line);
  52. }
  53. }
  54. if (!$found_version) {
  55. fwrite($fh, '$_configuration[\'system_version\'] = \''.$new_version.'\';'."\r\n");
  56. }
  57. if (!$found_stable) {
  58. fwrite($fh, '$_configuration[\'system_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");
  59. }
  60. if (!$found_software_name) {
  61. fwrite($fh, '$_configuration[\'software_name\'] = \''.$software_name.'\';'."\r\n");
  62. }
  63. if (!$found_software_url) {
  64. fwrite($fh, '$_configuration[\'software_url\'] = \''.$software_url.'\';'."\r\n");
  65. }
  66. fwrite($fh, '?>');
  67. fclose($fh);
  68. } else {
  69. echo 'You are not allowed here !' . __FILE__;
  70. }