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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /* See license terms in /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 chamilo.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('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
  16. // Edit the Dokeos config file
  17. $file = file('../inc/conf/configuration.php');
  18. $fh = fopen('../inc/conf/configuration.php', 'w');
  19. $found_version = false;
  20. $found_stable = false;
  21. foreach ($file as $line) {
  22. $ignore = false;
  23. if (stristr($line, '$_configuration[\'dokeos_version\']')) {
  24. $found_version = true;
  25. $line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
  26. } elseif(stristr($line, '$_configuration[\'dokeos_stable\']')) {
  27. $found_stable = true;
  28. $line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n";
  29. } elseif(stristr($line,'$userPasswordCrypted')) {
  30. $line = '$userPasswordCrypted = \''.($userPasswordCrypted).'\';'."\r\n";
  31. } elseif(stristr($line, '?>')) {
  32. //ignore the line
  33. $ignore = true;
  34. }
  35. if (!$ignore) {
  36. fwrite($fh, $line);
  37. }
  38. }
  39. if (!$found_version) {
  40. fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n");
  41. }
  42. if (!$found_stable) {
  43. fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");
  44. }
  45. fwrite($fh, '?>');
  46. fclose($fh);
  47. $sys_course_path = $pathForm.'courses/';
  48. $perm = api_get_permissions_for_new_directories();
  49. //$old_umask = umask(0); // This function is not thread-safe.
  50. $link = Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
  51. Database::select_db($dbNameForm, $link);
  52. $db_name = $dbNameForm;
  53. $sql = "SELECT * FROM $db_name.course";
  54. error_log('Getting courses for files updates: '.$sql, 0);
  55. $result = Database::query($sql);
  56. while ($courses_directories = Database::fetch_array($result)) {
  57. $currentCourseRepositorySys = $sys_course_path.$courses_directories['directory'].'/';
  58. //upload > announcements
  59. if (!is_dir($currentCourseRepositorySys."upload/announcements")){
  60. mkdir($currentCourseRepositorySys."upload/announcements", $perm);
  61. }
  62. //upload > announcements > images
  63. if (!is_dir($currentCourseRepositorySys."upload/announcements/images")) {
  64. mkdir($currentCourseRepositorySys."upload/announcements/images", $perm);
  65. }
  66. }
  67. ////create a specific directory for global thumbails
  68. //home > default_platform_document > template_thumb
  69. if (!is_dir($pathForm.'home/default_platform_document/template_thumb')) {
  70. mkdir($pathForm.'home/default_platform_document/template_thumb', $perm);
  71. }
  72. } else {
  73. echo 'You are not allowed here !';
  74. }