update-files-1.8.6-1.8.6.1.inc.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /* See license terms in /dokeos_license.txt */
  3. /**
  4. ==============================================================================
  5. * Updates the Dokeos files from version 1.8.6 to version 1.8.6.1
  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.6, 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,'$userPasswordCrypted'))
  42. {
  43. $line = '$userPasswordCrypted = \''.($userPasswordCrypted).'\';'."\r\n";
  44. }
  45. elseif(stristr($line,'?>'))
  46. {
  47. //ignore the line
  48. $ignore = true;
  49. }
  50. if(!$ignore)
  51. {
  52. fwrite($fh,$line);
  53. }
  54. }
  55. if(!$found_version)
  56. {
  57. fwrite($fh,'$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n");
  58. }
  59. if(!$found_stable)
  60. {
  61. fwrite($fh,'$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n");
  62. }
  63. fwrite($fh,'?>');
  64. fclose($fh);
  65. $perm = api_get_setting('permissions_for_new_directories');
  66. $perm = octdec(!empty($perm)?$perm:'0770');
  67. $old_umask = umask(0);
  68. ////create a specific directory for global thumbails
  69. //home > default_platform_document > template_thumb
  70. if(!is_dir($pathForm.'home/default_platform_document/template_thumb')){
  71. mkdir($pathForm.'home/default_platform_document/template_thumb',$perm);
  72. }
  73. }
  74. else
  75. {
  76. echo 'You are not allowed here !';
  77. }
  78. ?>