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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. Log::notice('Entering file');
  19. if (defined('SYSTEM_INSTALLATION')) {
  20. // Edit the configuration file
  21. $file = file(api_get_path(CONFIGURATION_PATH).'configuration.php');
  22. $fh = fopen(api_get_path(CONFIGURATION_PATH).'configuration.php', 'w');
  23. $found_version = false;
  24. $found_stable = false;
  25. foreach ($file as $line) {
  26. $ignore = false;
  27. if (stripos($line, '$_configuration[\'dokeos_version\']') !== false) {
  28. $found_version = true;
  29. $line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
  30. } elseif (stripos($line, '$_configuration[\'dokeos_stable\']') !== false) {
  31. $found_stable = true;
  32. $line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n";
  33. } elseif (stripos($line, '?>') !== false) {
  34. // Ignore the line
  35. $ignore = true;
  36. }
  37. if (!$ignore) {
  38. fwrite($fh, $line);
  39. }
  40. }
  41. if (!$found_version) {
  42. fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n");
  43. }
  44. if (!$found_stable) {
  45. fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n");
  46. }
  47. fwrite($fh, '?>');
  48. fclose($fh);
  49. } else {
  50. echo 'You are not allowed here !' . __FILE__;
  51. }