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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /* See license terms in /dokeos_license.txt */
  3. /**
  4. ==============================================================================
  5. * Updates the Dokeos files from version 1.8.6 to version 1.8.6.1
  6. * This script operates only in the case of an update, and only to change the
  7. * active version number (and other things that might need a change) in the
  8. * current configuration file.
  9. * As of 1.8.6, the Dokeos version has been added to configuration.php to
  10. * allow for edition (inc/conf is one of the directories that needs write
  11. * permissions on upgrade).
  12. * Being in configuration.php, it benefits from the configuration.dist.php
  13. * advantages that a new version doesn't overwrite it, thus letting the old
  14. * version be available until the end of the installation.
  15. * @package dokeos.install
  16. ==============================================================================
  17. */
  18. require_once '../inc/lib/main_api.lib.php';
  19. require_once '../inc/lib/fileUpload.lib.php';
  20. require_once '../inc/lib/database.lib.php';
  21. if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) {
  22. // Edit the Dokeos config file
  23. $file = file('../inc/conf/configuration.php');
  24. $fh = fopen('../inc/conf/configuration.php', 'w');
  25. $found_version = false;
  26. $found_stable = false;
  27. foreach ($file as $line) {
  28. $ignore = false;
  29. if(stristr($line, '$_configuration[\'dokeos_version\']')) {
  30. $found_version = true;
  31. $line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
  32. } elseif(stristr($line, '$_configuration[\'dokeos_stable\']')) {
  33. $found_stable = true;
  34. $line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n";
  35. } elseif(stristr($line, '$userPasswordCrypted')) {
  36. $line = '$userPasswordCrypted = \''.($userPasswordCrypted).'\';'."\r\n";
  37. } elseif(stristr($line, '?>')) {
  38. //ignore the line
  39. $ignore = true;
  40. }
  41. if (!$ignore) {
  42. fwrite($fh, $line);
  43. }
  44. }
  45. if (!$found_version) {
  46. fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n");
  47. }
  48. if (!$found_stable) {
  49. fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");
  50. }
  51. fwrite($fh, '?>');
  52. fclose($fh);
  53. $perm = api_get_permissions_for_new_directories();
  54. //$old_umask = umask(0); // This function is not thread-safe.
  55. ////create a specific directory for global thumbails
  56. //home > default_platform_document > template_thumb
  57. if (!is_dir($pathForm.'home/default_platform_document/template_thumb')) {
  58. mkdir($pathForm.'home/default_platform_document/template_thumb', $perm);
  59. }
  60. } else {
  61. echo 'You are not allowed here !';
  62. }