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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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('../inc/conf/configuration.php');
  15. $fh = fopen('../inc/conf/configuration.php', 'w');
  16. $found_version = false;
  17. $found_stable = false;
  18. foreach ($file as $line) {
  19. $ignore = false;
  20. if (stristr($line, '$_configuration[\'dokeos_version\']')) {
  21. $found_version = true;
  22. $line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
  23. } elseif(stristr($line, '$_configuration[\'dokeos_stable\']')) {
  24. $found_stable = true;
  25. $line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n";
  26. } elseif(stristr($line,'$userPasswordCrypted')) {
  27. $line = '$userPasswordCrypted = \''.($userPasswordCrypted).'\';'."\r\n";
  28. } elseif(stristr($line, '?>')) {
  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 = Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
  48. //Database::select_db($dbNameForm, $link);
  49. Database::select_db($dbNameForm);
  50. $db_name = $dbNameForm;
  51. $sql = "SELECT * FROM $db_name.course";
  52. error_log('Getting courses for files updates: '.$sql, 0);
  53. $result = Database::query($sql);
  54. if (Database::num_rows($result) > 0) {
  55. while ($courses_directories = Database::fetch_array($result)) {
  56. $currentCourseRepositorySys = $sys_course_path.$courses_directories['directory'].'/';
  57. // upload > announcements
  58. if (!is_dir($currentCourseRepositorySys."upload/announcements")){
  59. mkdir($currentCourseRepositorySys."upload/announcements", $perm);
  60. }
  61. // upload > announcements > images
  62. if (!is_dir($currentCourseRepositorySys."upload/announcements/images")) {
  63. mkdir($currentCourseRepositorySys."upload/announcements/images", $perm);
  64. }
  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. }