update-files-1.8.7-1.8.8.inc.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Chamilo LMS
  5. *
  6. * Updates the Chamilo files from version 1.8.7 to version 1.8.8
  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. if (defined('SYSTEM_INSTALLATION')) {
  13. // Edit the configuration file
  14. $file = file(api_get_path(CONFIGURATION_PATH).'configuration.php');
  15. $fh = fopen(api_get_path(CONFIGURATION_PATH).'configuration.php', 'w');
  16. $found_version_old = false;
  17. $found_stable_old = false;
  18. $found_version = false;
  19. $found_stable = false;
  20. $found_software_name = false;
  21. $found_software_url = false;
  22. foreach ($file as $line) {
  23. $ignore = false;
  24. if (stripos($line, '$_configuration[\'dokeos_version\']') !== false) {
  25. $found_version_old = true;
  26. $line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
  27. $ignore = true;
  28. } elseif (stripos($line, '$_configuration[\'system_version\']') !== false) {
  29. $found_version = true;
  30. $line = '$_configuration[\'system_version\'] = \''.$new_version.'\';'."\r\n";
  31. } elseif (stripos($line, '$_configuration[\'dokeos_stable\']') !== false) {
  32. $found_stable_old = true;
  33. $line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n";
  34. $ignore = true;
  35. } elseif (stripos($line, '$_configuration[\'system_stable\']') !== false) {
  36. $found_stable = true;
  37. $line = '$_configuration[\'system_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n";
  38. } elseif (stripos($line, '$_configuration[\'software_name\']') !== false) {
  39. $found_software_name = true;
  40. $line = '$_configuration[\'software_name\'] = \''.$software_name.'\';'."\r\n";
  41. } elseif (stripos($line, '$_configuration[\'software_url\']') !== false) {
  42. $found_software_url = true;
  43. $line = '$_configuration[\'software_url\'] = \''.$software_url.'\';'."\r\n";
  44. } elseif (stripos($line,'$userPasswordCrypted') !== false) {
  45. $line = '$userPasswordCrypted = \''.($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 !';
  69. }