Source for file migrateur.php

Documentation is available at migrateur.php

  1. <?php
  2. // ----------------------------------------
  3. // start program
  4. // updated by Alain : Mon Dec 03 14:20:58 CET 2007
  5. // ----------------------------------------
  6.  
  7. include "inc/config_inc.php";
  8.  
  9.  
  10.  
  11. // --------------------------------------------------
  12. // treat config db
  13. // --------------------------------------------------
  14.  
  15. if (
  16. $config_source_database != ''
  17. and $config_source_user != ''
  18. and $config_source_pw != ''
  19. and $config_target_database != ''
  20. and $config_target_user != ''
  21. and $config_target_pw != ''
  22. ) {
  23. $_SESSION['source_database'] = $config_source_database;
  24. $_SESSION['source_user'] = $config_source_user;
  25. $_SESSION['source_pw'] = $config_source_pw;
  26.  
  27. $_SESSION['target_database'] = $config_target_database;
  28. $_SESSION['target_user'] = $config_target_user;
  29. $_SESSION['target_pw'] = $config_target_pw;
  30.  
  31. $submit = 1;
  32. $correct = 1;
  33. $check_title = "Selon les données de /inc/config_inc.php";
  34.  
  35. }
  36. else {
  37.  
  38. // --------------------------------------------------
  39. // convert POST
  40. // --------------------------------------------------
  41. $source_database = $_POST['source_database'];
  42. $source_user = $_POST['source_user'];
  43. $source_pw = $_POST['source_pw'];
  44.  
  45. $target_database = $_POST['target_database'];
  46. $target_user = $_POST['target_user'];
  47. $target_pw = $_POST['target_pw'];
  48. $submit = $_POST['submit'];
  49.  
  50. $_SESSION['source_database'] = $source_database;
  51. $_SESSION['source_user'] = $source_user;
  52. $_SESSION['source_pw'] = $source_pw;
  53. $_SESSION['source_version'] = $source_version;
  54.  
  55. $_SESSION['target_database'] = $target_database;
  56. $_SESSION['target_user'] = $target_user;
  57. $_SESSION['target_pw'] = $target_pw;
  58. $_SESSION['target_version'] = $target_version;
  59.  
  60. $check_title = "Selon votre saisie";
  61. }
  62.  
  63.  
  64. // --------------------------------------------------
  65. // CHECK
  66. // --------------------------------------------------
  67.  
  68. $correct = 1;
  69. if ($submit) {
  70. // --------------------------------------------------
  71. // source data
  72. // --------------------------------------------------
  73. if (!isset($source_database) or $source_database == '') {
  74. print "Base source manquante<br />";
  75. $correct = 0;
  76. }
  77.  
  78. if (!isset($source_user) or $source_user == '') {
  79. print "Utilisateur source manquant<br />";
  80. $correct = 0;
  81. }
  82.  
  83. if (!isset($source_pw) or $source_pw == '') {
  84. print "Mot de passe source manquant<br />";
  85. $correct = 0;
  86. }
  87.  
  88. // --------------------------------------------------
  89. // target data
  90. // --------------------------------------------------
  91. if (!isset($target_database) or $target_database == '') {
  92. print "Base cible manquante<br />";
  93. $correct = 0;
  94. }
  95.  
  96. if (!isset($target_user) or $target_user == '') {
  97. print "Utilisateur cible manquant<br />";
  98. $correct = 0;
  99. }
  100.  
  101. if (!isset($target_pw) or $target_pw == '') {
  102. print "Mot de passe cible manquant<br />";
  103. $correct = 0;
  104. }
  105. }
  106.  
  107. // --------------------------------------------------
  108. // CHECK DB CONNEXION
  109. // --------------------------------------------------
  110.  
  111. if ($submit and $correct) {
  112.  
  113. $source_connect_status = db_connection('source');
  114. if (!$source_connect_status['connection']) {
  115. $correct = 0;
  116. print "<span class=\"error\">" . $source_connect_status['connection_error'] . "</span><br />";
  117. }
  118. else {
  119. if (!$source_connect_status['db_selection']) {
  120. $correct = 0;
  121. print "<span class=\"error\">" . $source_connect_status['db_selection_error'] . "</span><br />";
  122. }
  123. }
  124.  
  125. $target_connect_status = db_connection('target');
  126. if (!$target_connect_status['connection']) {
  127. $correct = 0;
  128. print "<span class=\"error\">" . $target_connect_status['connection_error'] . "</span><br />";
  129. }
  130. else {
  131. if (!$target_connect_status['db_selection']) {
  132. $correct = 0;
  133. print "<span class=\"error\">" . $target_connect_status['db_selection_error'] . "</span><br />";
  134. }
  135. }
  136.  
  137. }
  138.  
  139. // --------------------------------------------------
  140. // CHECK VERSION IN AGORA SPIP_META
  141. // --------------------------------------------------
  142.  
  143. if ($submit and $correct) {
  144. /*
  145. // --------------------------------------------------
  146. // list source table
  147. // --------------------------------------------------
  148. $source_version = get_version('source', $source_database);
  149.  
  150. // --------------------------------------------------
  151. // check version
  152. // --------------------------------------------------
  153. if ($source_version == '') {
  154. print "Impossible de déterminer la version d'Agora, merci de vérifier votre sélection <br />";
  155. $correct = 0;
  156. }
  157. elseif (!ereg('1.2|1.3|1.4', $source_version)) {
  158. print "$source_version ne correspond pas à  une version d'Agora, merci de vérifier votre sélection <br />";
  159. $correct = 0;
  160. }
  161.  
  162.  
  163. // --------------------------------------------------
  164. // list target table
  165. // --------------------------------------------------
  166. $target_version = get_version('target', $target_database);
  167.  
  168. // --------------------------------------------------
  169. // check version
  170. // --------------------------------------------------
  171. if ($target_version == '') {
  172. print "Impossible de déterminer la version de SPIP, merci de vérifier votre sélection <br />";
  173. $correct = 0;
  174. }
  175. elseif (!ereg('1.9', $target_version)) {
  176. print "$target_version ne correspond pas à  une version cible de SPIP, merci de vérifier votre sélection <br />";
  177. $correct = 0;
  178. }
  179. */
  180.  
  181. }
  182.  
  183.  
  184. // --------------------------------------------------
  185. // TREAT
  186. // --------------------------------------------------
  187.  
  188. if ($submit and $correct) {
  189. go_to('confirm.php'); // v 1.0
  190. }
  191.  
  192. // --------------------------------------------------
  193. // form
  194. // --------------------------------------------------
  195.  
  196.  
  197.  
  198. if (!$submit or !$correct) {
  199. include "inc/header.html";
  200. print "<h2>Sélection des bases de données</h2>";
  201.  
  202. print "<form name=\"form1\" method=\"post\" action=\"\">";
  203. print "<table width=\"60%\" border=\"0\" cellpadding=\"3\">";
  204.  
  205. // --------------------------------------------------
  206. // source agora
  207. // --------------------------------------------------
  208. print "<tr>";
  209. print "<th colspan = \"2\">Source</th>";
  210. print "</tr>";
  211.  
  212. print "<tr>";
  213. print "<td class=\"label\">";
  214. print "<label for=\"source_database\">Nom de la base de données </label></td>";
  215. print "<td width=\"59%\">";
  216. print "<input type=\"text\" name=\"source_database\" id=\"source_database\" value=\"$source_database\">";
  217. print "</td>";
  218. print "</tr>";
  219.  
  220. print "<tr>";
  221. print "<td class=\"label\">";
  222. print "<label for=\"source_user\">Utilisateur</label></td>";
  223. print "<td><input type=\"text\" name=\"source_user\" id=\"source_user\" value=\"$source_user\">";
  224. print "</td>";
  225. print "</tr>";
  226.  
  227. print "<tr>";
  228. print "<td class=\"label\">";
  229. print "<label for=\"source_pw\">Mot de passe</label></td>";
  230. print "<td><input type=\"text\" name=\"source_pw\" id=\"source_pw\" value=\"$source_pw\">";
  231. print "</td>";
  232. print "</tr>";
  233.  
  234. print "<tr>";
  235. print "<td>&nbsp;</td>";
  236. print "<td>&nbsp;</td>";
  237. print "</tr>";
  238. print "<tr>";
  239.  
  240. // --------------------------------------------------
  241. // target Spip
  242. // --------------------------------------------------
  243. print "<th colspan = \"2\">Cible</th>";
  244. print "</tr>";
  245.  
  246. print "<tr>";
  247. print "<td class=\"label\">";
  248. print "<label for=\"target_database\">Nom de la base de données</label></td>";
  249. print "<td><input type=\"text\" name=\"target_database\" id=\"target_database\" value=\"$target_database\"></td>";
  250. print "</tr>";
  251.  
  252. print "<tr>";
  253. print "<td class=\"label\">";
  254. print "<label for=\"target_user\">Utilisateur</label></td>";
  255. print "<td><input type=\"text\" name=\"target_user\" id=\"target_user\" value=\"$target_user\"></td>";
  256. print "</tr>";
  257.  
  258. print "<tr>";
  259. print "<td class=\"label\">";
  260. print "<label for=\"target_pw\">Mot de passe</label></td>";
  261. print "<td><input type=\"text\" name=\"target_pw\" id=\"target_pw\" value=\"$target_pw\"></td>";
  262. print "</tr>";
  263.  
  264. print "<tr>";
  265. print "<td colspan = \"2\"><label for=\"submit\"></label>";
  266. print "<input class=\"submit\" type=\"submit\" name=\"submit\" value=\"Valider\" id=\"submit\"></td>";
  267. print "</tr>";
  268.  
  269. print "</table>";
  270. print "</form>";
  271.  
  272. include "inc/footer.html";
  273.  
  274. }
  275.  
  276. ?>

Documentation generated on Mon, 31 Mar 2008 18:08:47 +0200 by phpDocumentor 1.3.0RC3