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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 dokeos.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('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
  38. {
  39. // Edit the Dokeos config file
  40. $file = file('../inc/conf/configuration.php');
  41. $fh = fopen('../inc/conf/configuration.php','w');
  42. $found_version = false;
  43. $found_stable = false;
  44. foreach($file as $line)
  45. {
  46. $ignore = false;
  47. if(stristr($line,'$_configuration[\'dokeos_version\']'))
  48. {
  49. $found_version = true;
  50. $line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
  51. }
  52. elseif(stristr($line,'$_configuration[\'dokeos_stable\']'))
  53. {
  54. $found_stable = true;
  55. $line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n";
  56. }
  57. elseif(stristr($line,'?>'))
  58. {
  59. //ignore the line
  60. $ignore = true;
  61. }
  62. if(!$ignore)
  63. {
  64. fwrite($fh,$line);
  65. }
  66. }
  67. if(!$found_version)
  68. {
  69. fwrite($fh,'$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n");
  70. }
  71. if(!$found_stable)
  72. {
  73. fwrite($fh,'$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");
  74. }
  75. fwrite($fh,'?>');
  76. fclose($fh);
  77. }
  78. else
  79. {
  80. echo 'You are not allowed here !';
  81. }
  82. ?>