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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /* See license terms in /dokeos_license.txt */
  3. /**
  4. ==============================================================================
  5. * Updates the Dokeos files from version 1.8.6.1 to version 1.8.6.2
  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. * @package dokeos.install
  10. ==============================================================================
  11. */
  12. require_once("../inc/lib/main_api.lib.php");
  13. require_once("../inc/lib/fileUpload.lib.php");
  14. require_once('../inc/lib/database.lib.php');
  15. if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
  16. {
  17. // Edit the Dokeos config file
  18. $file = file('../inc/conf/configuration.php');
  19. $fh = fopen('../inc/conf/configuration.php','w');
  20. $found_version = false;
  21. $found_stable = false;
  22. foreach($file as $line)
  23. {
  24. $ignore = false;
  25. if(stristr($line,'$_configuration[\'dokeos_version\']'))
  26. {
  27. $found_version = true;
  28. $line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
  29. }
  30. elseif(stristr($line,'$_configuration[\'dokeos_stable\']'))
  31. {
  32. $found_stable = true;
  33. $line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n";
  34. }
  35. elseif(stristr($line,'$userPasswordCrypted'))
  36. {
  37. $line = '$userPasswordCrypted = \''.($userPasswordCrypted).'\';'."\r\n";
  38. }
  39. elseif(stristr($line,'?>'))
  40. {
  41. //ignore the line
  42. $ignore = true;
  43. }
  44. if(!$ignore)
  45. {
  46. fwrite($fh,$line);
  47. }
  48. }
  49. if(!$found_version)
  50. {
  51. fwrite($fh,'$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n");
  52. }
  53. if(!$found_stable)
  54. {
  55. fwrite($fh,'$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");
  56. }
  57. fwrite($fh,'?>');
  58. fclose($fh);
  59. $perm = api_get_setting('permissions_for_new_directories');
  60. $perm = octdec(!empty($perm)?$perm:'0770');
  61. $old_umask = umask(0);
  62. ////create a specific directory for global thumbails
  63. //home > default_platform_document > template_thumb
  64. if(!is_dir($pathForm.'home/default_platform_document/template_thumb')){
  65. mkdir($pathForm.'home/default_platform_document/template_thumb',$perm);
  66. }
  67. //upload > announcements
  68. if(!is_dir($currentCourseRepositorySys."upload/announcements")){
  69. mkdir($currentCourseRepositorySys."upload/announcements",$perm);
  70. }
  71. //upload > announcements > images
  72. if(!is_dir($currentCourseRepositorySys."upload/announcements/images")){
  73. mkdir($currentCourseRepositorySys."upload/announcements/images",$perm);
  74. }
  75. }
  76. else
  77. {
  78. echo 'You are not allowed here !';
  79. }
  80. ?>