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

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