update-files-1.8.8-1.9.0.inc.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Chamilo LMS
  5. *
  6. * Updates the Chamilo files from version 1.8.8 to version 1.9.0
  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. $conf_dir = api_get_path(CONFIGURATION_PATH);
  15. $portfolio_conf_dist = $conf_dir . 'portfolio.conf.dist.php';
  16. $portfolio_conf = $conf_dir . 'portfolio.conf.dist.php';
  17. if (!file_exists($portfolio_conf)) {
  18. copy($portfolio_conf_dist, $portfolio_conf);
  19. }
  20. // Edit the configuration file
  21. $file = file(api_get_path(CONFIGURATION_PATH) . 'configuration.php');
  22. $fh = fopen(api_get_path(CONFIGURATION_PATH) . 'configuration.php', 'w');
  23. $found_version_old = false;
  24. $found_stable_old = false;
  25. $found_version = false;
  26. $found_stable = false;
  27. $found_software_name = false;
  28. $found_software_url = false;
  29. foreach ($file as $line) {
  30. $ignore = false;
  31. if (stripos($line, '$userPasswordCrypted') !== false) {
  32. $line = '$_configuration[\'password_encryption\'] = \'' . ($userPasswordCrypted) . '\';' . "\r\n";
  33. } elseif (stripos($line, '?>') !== false) {
  34. $ignore = true;
  35. }
  36. if (!$ignore) {
  37. fwrite($fh, $line);
  38. }
  39. }
  40. if (!$found_version) {
  41. fwrite($fh, '$_configuration[\'system_version\'] = \'' . $new_version . '\';' . "\r\n");
  42. }
  43. if (!$found_stable) {
  44. fwrite($fh, '$_configuration[\'system_stable\'] = ' . ($new_version_stable ? 'true' : 'false') . ';' . "\r\n");
  45. }
  46. if (!$found_software_name) {
  47. fwrite($fh, '$_configuration[\'software_name\'] = \'' . $software_name . '\';' . "\r\n");
  48. }
  49. if (!$found_software_url) {
  50. fwrite($fh, '$_configuration[\'software_url\'] = \'' . $software_url . '\';' . "\r\n");
  51. }
  52. $string = "
  53. //===========================================================================\n
  54. // Hosting settings - Allows you to set limits to the Chamilo portal when\n
  55. // hosting it for a third party. These settings can be overwritten by an\n
  56. // optionally-loaded extension file with only the settings (no comments).\n
  57. //===========================================================================\n
  58. // Set a maximum number of users. Default (0) = no limit\n
  59. ".'$'."_configuration['hosting_limit_users'] = 0;\n
  60. // Set a maximum number of teachers. Default (0) = no limit\n
  61. ".'$'."_configuration['hosting_limit_teachers'] = 0;\n
  62. // Set a maximum number of courses. Default (0) = no limit\n
  63. ".'$'."_configuration['hosting_limit_courses'] = 0;\n
  64. // Set a maximum number of sessions. Default (0) = no limit\n
  65. ".'$'."_configuration['hosting_limit_sessions'] = 0;\n
  66. // Set a maximum disk space used, in MB (set to 1024 for 1GB, 5120 for 5GB).\n
  67. // Default (0) = no limit\n
  68. ".'$'."_configuration['hosting_limit_disk_space'] = 0;\n
  69. ";
  70. fwrite($fh, $string);
  71. fwrite($fh, '?>');
  72. fclose($fh);
  73. //Adds events.conf file
  74. if (! file_exists(api_get_path(CONFIGURATION_PATH).'events.conf.php')) {
  75. copy(api_get_path(CONFIGURATION_PATH).'events.conf.dist.php', api_get_path(CONFIGURATION_PATH).'events.conf.php');
  76. }
  77. } else {
  78. echo 'You are not allowed here !'. __FILE__;
  79. }