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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. if (defined('SYSTEM_INSTALLATION')) {
  19. // Edit the configuration file
  20. $file = file(api_get_path(CONFIGURATION_PATH).'configuration.php');
  21. $fh = fopen(api_get_path(CONFIGURATION_PATH).'configuration.php', 'w');
  22. $found_version = false;
  23. $found_stable = false;
  24. foreach ($file as $line) {
  25. $ignore = false;
  26. if (stripos($line, '$_configuration[\'dokeos_version\']') !== false) {
  27. $found_version = true;
  28. $line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
  29. } elseif (stripos($line, '$_configuration[\'dokeos_stable\']') !== false) {
  30. $found_stable = true;
  31. $line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n";
  32. } elseif (stripos($line, '$userPasswordCrypted') !== false) {
  33. $line = '$userPasswordCrypted = \''.($userPasswordCrypted).'\';'."\r\n";
  34. } elseif (stripos($line, '?>') !== false) {
  35. //ignore the line
  36. $ignore = true;
  37. }
  38. if (!$ignore) {
  39. fwrite($fh, $line);
  40. }
  41. }
  42. if (!$found_version) {
  43. fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n");
  44. }
  45. if (!$found_stable) {
  46. fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n");
  47. }
  48. fwrite($fh, '?>');
  49. fclose($fh);
  50. //// Ccreate a specific directory for global thumbails
  51. // home > default_platform_document > template_thumb
  52. if (!is_dir($pathForm.'home/default_platform_document/template_thumb')) {
  53. mkdir($pathForm.'home/default_platform_document/template_thumb', $perm);
  54. }
  55. } else {
  56. echo 'You are not allowed here !' . __FILE__;
  57. }