update-files-1.8.3-1.8.4.inc.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php //$Id: update-files-1.8.3-1.8.4.inc.php 19996 2009-04-22 22:11:14Z cvargas1 $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2007 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. For a full list of contributors, see "credits.txt".
  9. The full license can be read in "license.txt".
  10. This program is free software; you can redistribute it and/or
  11. modify it under the terms of the GNU General Public License
  12. as published by the Free Software Foundation; either version 2
  13. of the License, or (at your option) any later version.
  14. See the GNU General Public License for more details.
  15. Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
  16. Mail: info@dokeos.com
  17. ==============================================================================
  18. */
  19. /**
  20. ==============================================================================
  21. * Updates the Dokeos files from version 1.8.3 to version 1.8.4
  22. * This script operates only in the case of an update, and only to change the
  23. * active version number (and other things that might need a change) in the
  24. * current configuration file.
  25. * As of 1.8.4, the Dokeos version has been added to configuration.php to
  26. * allow for edition (inc/conf is one of the directories that needs write
  27. * permissions on upgrade).
  28. * Being in configuration.php, it benefits from the configuration.dist.php
  29. * advantages that a new version doesn't overwrite it, thus letting the old
  30. * version be available until the end of the installation.
  31. * @package chamilo.install
  32. ==============================================================================
  33. */
  34. require_once '../inc/lib/main_api.lib.php';
  35. require_once '../inc/lib/fileUpload.lib.php';
  36. require_once '../inc/lib/database.lib.php';
  37. if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
  38. // Edit the Dokeos config file
  39. $file = file('../inc/conf/configuration.php');
  40. $fh = fopen('../inc/conf/configuration.php', 'w');
  41. $found_version = false;
  42. $found_stable = false;
  43. foreach ($file as $line) {
  44. $ignore = false;
  45. if (stristr($line, '$_configuration[\'dokeos_version\']')) {
  46. $found_version = true;
  47. $line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
  48. } elseif (stristr($line, '$_configuration[\'dokeos_stable\']')) {
  49. $found_stable = true;
  50. $line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n";
  51. } elseif (stristr($line, '?>')) {
  52. //ignore the line
  53. $ignore = true;
  54. }
  55. if (!$ignore) {
  56. fwrite($fh, $line);
  57. }
  58. }
  59. if (!$found_version) {
  60. fwrite($fh, '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n");
  61. }
  62. if (!$found_stable) {
  63. fwrite($fh, '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n");
  64. }
  65. fwrite($fh, '?>');
  66. fclose($fh);
  67. } else {
  68. echo 'You are not allowed here !';
  69. }