update_courses.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 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. * GOAL: Updates courses separately
  22. *
  23. * After upgrading a previous version to Dokeos 1.6, there are only
  24. * MAX_COURSE_TRANSFER courses converted to the new format - with
  25. * MAX_COURSE_TRANSFER in install/index.php being 100 as default.
  26. *
  27. * To update the rest of the courses you need to run this script.
  28. *
  29. * @package dokeos.install
  30. * @todo remove duplication: MAX_COURSE_TRANSFER is defined here and
  31. * also in install.index.php
  32. ==============================================================================
  33. */
  34. /*
  35. ==============================================================================
  36. INIT SECTION
  37. ==============================================================================
  38. */
  39. require('../inc/installedVersion.inc.php');
  40. require('../inc/lib/main_api.lib.php');
  41. require('../lang/english/trad4all.inc.php');
  42. require('../lang/english/install.inc.php');
  43. //load for get_config_param()
  44. require_once('install_functions.inc.php');
  45. define('DOKEOS_COURSE_UPDATE',1);
  46. define('MAX_COURSE_TRANSFER',100);
  47. error_reporting(E_COMPILE_ERROR | E_ERROR | E_CORE_ERROR);
  48. @set_time_limit(0);
  49. $update_path=trim(stripslashes($_GET['update_path']));
  50. $update_from_version=array('1.5','1.5.4','1.5.5');
  51. /*
  52. ==============================================================================
  53. INITIALISE FORM VARIABLES
  54. (If this is the first visit to this script.)
  55. Variables are read from the configuration file
  56. of the old Dokeos version (configuration.php).
  57. ==============================================================================
  58. */
  59. $updateFromConfigFile=''; // leave empty
  60. $badUpdatePath=false;
  61. if($_POST['step2'])
  62. {
  63. if(empty($_POST['updatePath']))
  64. {
  65. $_POST['step1']=1;
  66. }
  67. else
  68. {
  69. if($_POST['updatePath'][strlen($_POST['updatePath'])-1] != '/')
  70. {
  71. $_POST['updatePath'].='/';
  72. }
  73. if(!file_exists($_POST['updatePath']))
  74. {
  75. $badUpdatePath=true;
  76. $_POST['step2']=0;
  77. }
  78. elseif(!in_array(get_config_param('clarolineVersion'),$update_from_version))
  79. {
  80. $badUpdatePath=true;
  81. $_POST['step2']=0;
  82. }
  83. else
  84. {
  85. $urlAppendPath=str_replace('/main/install/update_courses.php','',api_get_self());
  86. $urlForm='http://'.$_SERVER['HTTP_HOST'].$urlAppendPath.'/';
  87. $singleDbForm=get_config_param('singleDbEnabled');
  88. $dbNameForm=get_config_param('mainDbName');
  89. $dbHostForm=get_config_param('dbHost');
  90. $dbUsernameForm=get_config_param('dbLogin');
  91. $dbPassForm=get_config_param('dbPass');
  92. }
  93. }
  94. }
  95. elseif($_POST['step1'])
  96. {
  97. $_POST['updatePath']='';
  98. }
  99. ?>
  100. <html>
  101. <head>
  102. <title>-- Dokeos course update -- version <?php echo $dokeos_version; ?></title>
  103. <link rel="stylesheet" href="../css/public_admin/default.css" type="text/css">
  104. </head>
  105. <body bgcolor="white" dir="<?php echo $text_dir ?>">
  106. <form method="post" action="<?php echo api_get_self(); ?>">
  107. <table cellpadding="6" cellspacing="0" border="0" width="650" bgcolor="#E6E6E6" align="center">
  108. <tr bgcolor="#4171B5"">
  109. <td valign="top">
  110. <big><font color="white">Dokeos course update - version <?php echo $dokeos_version; ?></font></big>
  111. </td>
  112. </tr>
  113. <tr bgcolor="#E6E6E6">
  114. <td>
  115. <img src="../img/bluelogo.gif" align="right" hspace="10" vspace="10">
  116. <?php
  117. /*
  118. ==============================================================================
  119. STEP 2 - COURSE UPDATE PROCESS
  120. the included files, update_db.inc.php and update_files.inc.php
  121. do the actual work of converting the course database
  122. and the files, respectively
  123. ==============================================================================
  124. */
  125. if($_POST['step2'])
  126. {
  127. include('update_db.inc.php');
  128. include('update_files.inc.php');
  129. ?>
  130. <h2>Step 2 of 2 &ndash; Course Update</h2>
  131. <?php echo sizeof($coursePath); ?> courses have been successfully updated.
  132. <br /><br />
  133. <?php if($nbr_courses > MAX_COURSE_TRANSFER): ?>
  134. <font color="red"><b>Warning:</b> You have more than <?php echo MAX_COURSE_TRANSFER; ?> courses on your Dokeos platform ! Only <?php echo MAX_COURSE_TRANSFER; ?> courses have been updated. To update the other courses, <a href="update_courses.php?update_path=<?php echo urlencode($updatePath); ?>"><font color="red">click here</font></a>.</font>
  135. <?php else: ?>
  136. <br /><br />
  137. <?php endif; ?>
  138. <br /><br /><br /><br />
  139. </form>
  140. <form method="get" action="../../">
  141. <p align="right"><input type="submit" value="Go to your Dokeos portal" /></p>
  142. <?php
  143. }
  144. /*
  145. ==============================================================================
  146. STEP 1 : CONFIGURATION
  147. ==============================================================================
  148. */
  149. else
  150. {
  151. ?>
  152. <h2>Step 1 of 2 &ndash; Configuration</h2>
  153. Please enter the path where the older version of Dokeos is installed (<?php echo implode('&nbsp;|&nbsp;',$update_from_version); ?>). The courses will be moved from that location to the Dokeos path.
  154. <br /><br />
  155. <b>Notice:</b> Please run this update script only if you've just updated (incompletely) Dokeos <?php echo implode('&nbsp;|&nbsp;',$update_from_version); ?> to Dokeos <?php echo $dokeos_version; ?>!
  156. <br /><br />
  157. <?php
  158. if($badUpdatePath)
  159. {
  160. ?>
  161. <br /><br />
  162. <div style="background-color:white; color:red; text-align:center; font-weight:bold;">
  163. Error!<br />
  164. Dokeos <?php echo implode('|',$update_from_version); ?> has not been found in that directory.
  165. </div>
  166. <?php
  167. }
  168. else
  169. {
  170. echo '<br />';
  171. }
  172. ?>
  173. <table border="0" cellpadding="5" width="100%" align="center">
  174. <tr>
  175. <td>Where are the courses to be updated: </td>
  176. <td><input type="text" name="updatePath" size="50" value="<?php echo empty($update_path)?($badUpdatePath?htmlentities($_POST['updatePath']):$_SERVER['DOCUMENT_ROOT'].'/old_version/'):htmlentities($update_path); ?>" /></td>
  177. </tr>
  178. </table>
  179. <p align="center">
  180. <input type="submit" name="step2" value="Update courses" onclick="javascript:if(this.value == 'Please Wait...') return false; else this.value='Please Wait...';" />
  181. </p>
  182. <?php
  183. }
  184. ?>
  185. </td>
  186. </tr>
  187. </table>
  188. </form>
  189. </body>
  190. </html>