update-files-1.8.4-1.8.5.inc.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php //$Id: update-files-1.8.4-1.8.5.inc.php 16083 2008-08-27 20:33:01Z juliomontoya $
  2. /* See license terms in /dokeos_license.txt */
  3. /**
  4. ==============================================================================
  5. * Updates the Dokeos files from version 1.8.4 to version 1.8.5
  6. * This script operates only in the case of an update, and only to change the
  7. * active version number (and other things that might need a change) in the
  8. * current configuration file.
  9. * As of 1.8.5, the Dokeos version has been added to configuration.php to
  10. * allow for edition (inc/conf is one of the directories that needs write
  11. * permissions on upgrade).
  12. * Being in configuration.php, it benefits from the configuration.dist.php
  13. * advantages that a new version doesn't overwrite it, thus letting the old
  14. * version be available until the end of the installation.
  15. * @package dokeos.install
  16. ==============================================================================
  17. */
  18. require_once("../inc/lib/main_api.lib.php");
  19. require_once("../inc/lib/fileUpload.lib.php");
  20. require_once('../inc/lib/database.lib.php');
  21. if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE'))
  22. {
  23. // Edit the Dokeos config file
  24. $file = file('../inc/conf/configuration.php');
  25. $fh = fopen('../inc/conf/configuration.php','w');
  26. $found_version = false;
  27. $found_stable = false;
  28. foreach($file as $line)
  29. {
  30. $ignore = false;
  31. if(stristr($line,'$_configuration[\'dokeos_version\']'))
  32. {
  33. $found_version = true;
  34. $line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
  35. }
  36. elseif(stristr($line,'$_configuration[\'dokeos_stable\']'))
  37. {
  38. $found_stable = true;
  39. $line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n";
  40. }
  41. elseif(stristr($line,'?>'))
  42. {
  43. //ignore the line
  44. $ignore = true;
  45. }
  46. if(!$ignore)
  47. {
  48. fwrite($fh,$line);
  49. }
  50. }
  51. if(!$found_version)
  52. {
  53. fwrite($fh,'$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n");
  54. }
  55. if(!$found_stable)
  56. {
  57. fwrite($fh,'$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");
  58. }
  59. fwrite($fh,'?>');
  60. fclose($fh);
  61. }
  62. else
  63. {
  64. echo 'You are not allowed here !';
  65. }
  66. ?>