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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Chamilo LMS
  5. *
  6. * Updates the Dokeos files from version 1.8.6.1 to Chamilo version 1.8.6.2
  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. * @package chamilo.install
  11. */
  12. Log::notice('Entering file');
  13. if (defined('SYSTEM_INSTALLATION')) {
  14. // Edit the configuration file
  15. $file = file(api_get_path(CONFIGURATION_PATH) . 'configuration.php');
  16. $fh = fopen(api_get_path(CONFIGURATION_PATH) . 'configuration.php', 'w');
  17. $found_version = false;
  18. $found_stable = false;
  19. foreach ($file as $line) {
  20. $ignore = false;
  21. if (stripos($line, '$_configuration[\'dokeos_version\']') !== false) {
  22. $found_version = true;
  23. $line = '$_configuration[\'dokeos_version\'] = \'' . $new_version . '\';' . "\r\n";
  24. } elseif (stripos($line, '$_configuration[\'dokeos_stable\']') !== false) {
  25. $found_stable = true;
  26. $line = '$_configuration[\'dokeos_stable\'] = ' . ($new_version_stable ? 'true' : 'false') . ';' . "\r\n";
  27. } elseif (stripos($line, '$userPasswordCrypted') !== false) {
  28. $line = '$userPasswordCrypted = \'' . ($userPasswordCrypted) . '\';' . "\r\n";
  29. } elseif (stripos($line, '?>') !== false) {
  30. //ignore the line
  31. $ignore = true;
  32. }
  33. if (!$ignore) {
  34. fwrite($fh, $line);
  35. }
  36. }
  37. if (!$found_version) {
  38. fwrite($fh, '$_configuration[\'dokeos_version\'] = \'' . $new_version . '\';' . "\r\n");
  39. }
  40. if (!$found_stable) {
  41. fwrite($fh, '$_configuration[\'dokeos_stable\'] = ' . ($new_version_stable ? 'true' : 'false') . ';' . "\r\n");
  42. }
  43. fwrite($fh, '?>');
  44. fclose($fh);
  45. $sys_course_path = $pathForm . 'courses/';
  46. $perm = api_get_permissions_for_new_directories();
  47. // The following line is disabled, connection has been already done
  48. //$link = iDatabase::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
  49. //iDatabase::select_db($dbNameForm, $link);
  50. iDatabase::select_db($dbNameForm);
  51. $db_name = $dbNameForm;
  52. $sql = "SELECT * FROM $db_name.course";
  53. Log::notice('Getting courses for files updates: ' . $sql);
  54. $result = iDatabase::query($sql);
  55. if (iDatabase::num_rows($result) > 0) {
  56. while ($courses_directories = iDatabase::fetch_array($result)) {
  57. $currentCourseRepositorySys = $sys_course_path . $courses_directories['directory'] . '/';
  58. // upload > announcements
  59. $path = $currentCourseRepositorySys . "upload/announcements";
  60. if (!is_dir($path)) {
  61. $success = mkdir($path, $perm, true);
  62. if(!$success){
  63. $course_directory = $courses_directories['directory'];
  64. Log::error("Failed to create dir path: $path, course directory: $course_directory, sys course path: $sys_course_path, perm: , perm: $perm");
  65. }
  66. }
  67. // upload > announcements > images
  68. $path = $currentCourseRepositorySys . "upload/announcements/images";
  69. if (!is_dir($path)) {
  70. $success = mkdir($path, $perm, true);
  71. if(!$success){
  72. $course_directory = $courses_directories['directory'];
  73. Log::error("Failed to create dir path: $path, course directory: $course_directory, sys course path: $sys_course_path, perm: $perm");
  74. }
  75. }
  76. }
  77. }
  78. //// Create a specific directory for global thumbails
  79. // home > default_platform_document > template_thumb
  80. if (!is_dir($pathForm . 'home/default_platform_document/template_thumb')) {
  81. mkdir($pathForm . 'home/default_platform_document/template_thumb', $perm);
  82. }
  83. } else {
  84. echo 'You are not allowed here !' . __FILE__;
  85. }