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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php //$Id: update-files-1.8.3-1.8.4.inc.php 13094 2007-09-19 17:21:14Z yannoo $
  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. if(stristr($line,'$_configuration[\'dokeos_version\']'))
  47. {
  48. $found_version = true;
  49. $line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
  50. }
  51. elseif(stristr($line,'$_configuration[\'dokeos_stable\']'))
  52. {
  53. $found_stable = true;
  54. $line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n";
  55. }
  56. elseif(stristr($line,'?>'))
  57. {
  58. //ignore the line
  59. }
  60. fwrite($fh,$line);
  61. }
  62. if(!$found_version)
  63. {
  64. fwrite($fh,'$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n");
  65. }
  66. if(!$found_stable)
  67. {
  68. fwrite($fh,'$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");
  69. }
  70. fwrite($fh,'?>');
  71. fclose($fh);
  72. }
  73. else
  74. {
  75. echo 'You are not allowed here !';
  76. }
  77. ?>