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

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