update-files-1.8.3-1.8.4.inc.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Chamilo LMS
  5. *
  6. * Updates the Dokeos files from version 1.8.3 to version 1.8.4
  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. * As of 1.8.4, the Dokeos version has been added to configuration.php to
  11. * allow for edition (inc/conf is one of the directories that needs write
  12. * permissions on upgrade).
  13. * Being in configuration.php, it benefits from the configuration.dist.php
  14. * advantages that a new version doesn't overwrite it, thus letting the old
  15. * version be available until the end of the installation.
  16. * @package chamilo.install
  17. */
  18. if (defined('SYSTEM_INSTALLATION')) {
  19. // Edit the configuration file
  20. $file = file('../inc/conf/configuration.php');
  21. $fh = fopen('../inc/conf/configuration.php', 'w');
  22. $found_version = false;
  23. $found_stable = false;
  24. foreach ($file as $line) {
  25. $ignore = false;
  26. if (stristr($line, '$_configuration[\'dokeos_version\']')) {
  27. $found_version = true;
  28. $line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
  29. } elseif (stristr($line, '$_configuration[\'dokeos_stable\']')) {
  30. $found_stable = true;
  31. $line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n";
  32. } elseif (stristr($line, '?>')) {
  33. // Ignore the line
  34. $ignore = true;
  35. }
  36. if (!$ignore) {
  37. fwrite($fh, $line);
  38. }
  39. }
  40. if (!$found_version) {
  41. fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n");
  42. }
  43. if (!$found_stable) {
  44. fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n");
  45. }
  46. fwrite($fh, '?>');
  47. fclose($fh);
  48. } else {
  49. echo 'You are not allowed here !';
  50. }