update-files-1.8.6-1.8.6.1.inc.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Chamilo LMS
  5. *
  6. * Updates the Dokeos files from version 1.8.6 to version 1.8.6.1
  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.6, 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, '$userPasswordCrypted') !== false) {
  34. $line = '$userPasswordCrypted = \''.($userPasswordCrypted).'\';'."\r\n";
  35. } elseif (stripos($line, '?>') !== false) {
  36. //ignore the line
  37. $ignore = true;
  38. }
  39. if (!$ignore) {
  40. fwrite($fh, $line);
  41. }
  42. }
  43. if (!$found_version) {
  44. fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n");
  45. }
  46. if (!$found_stable) {
  47. fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n");
  48. }
  49. fwrite($fh, '?>');
  50. fclose($fh);
  51. //// Ccreate a specific directory for global thumbails
  52. // home > default_platform_document > template_thumb
  53. if (!is_dir($pathForm.'home/default_platform_document/template_thumb')) {
  54. mkdir($pathForm.'home/default_platform_document/template_thumb', $perm);
  55. }
  56. } else {
  57. echo 'You are not allowed here !' . __FILE__;
  58. }