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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. $sys_course_path = $pathForm.'courses/';
  60. $perm = api_get_setting('permissions_for_new_directories');
  61. $perm = octdec(!empty($perm)?$perm:'0770');
  62. $old_umask = umask(0);
  63. $link = mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
  64. mysql_select_db($dbNameForm,$link);
  65. $db_name = $dbNameForm;
  66. $sql = "SELECT * FROM $db_name.course";
  67. error_log('Getting courses for files updates: '.$sql,0);
  68. $result=mysql_query($sql);
  69. while ($courses_directories=mysql_fetch_array($result)) {
  70. $currentCourseRepositorySys = $sys_course_path.$courses_directories['directory'].'/';
  71. //upload > announcements
  72. if(!is_dir($currentCourseRepositorySys."upload/announcements")){
  73. mkdir($currentCourseRepositorySys."upload/announcements",$perm);
  74. }
  75. //upload > announcements > images
  76. if(!is_dir($currentCourseRepositorySys."upload/announcements/images")){
  77. mkdir($currentCourseRepositorySys."upload/announcements/images",$perm);
  78. }
  79. }
  80. ////create a specific directory for global thumbails
  81. //home > default_platform_document > template_thumb
  82. if(!is_dir($pathForm.'home/default_platform_document/template_thumb')){
  83. mkdir($pathForm.'home/default_platform_document/template_thumb',$perm);
  84. }
  85. }
  86. else
  87. {
  88. echo 'You are not allowed here !';
  89. }
  90. ?>