Documentation is available at migrateur.php
- <?php
- // ----------------------------------------
- // start program
- // updated by Alain : Mon Dec 03 14:20:58 CET 2007
- // ----------------------------------------
- include "inc/config_inc.php";
- // --------------------------------------------------
- // treat config db
- // --------------------------------------------------
- if (
- $config_source_database != ''
- and $config_source_user != ''
- and $config_source_pw != ''
- and $config_target_database != ''
- and $config_target_user != ''
- and $config_target_pw != ''
- ) {
- $_SESSION['source_database'] = $config_source_database;
- $_SESSION['source_user'] = $config_source_user;
- $_SESSION['source_pw'] = $config_source_pw;
- $_SESSION['target_database'] = $config_target_database;
- $_SESSION['target_user'] = $config_target_user;
- $_SESSION['target_pw'] = $config_target_pw;
- $submit = 1;
- $correct = 1;
- $check_title = "Selon les données de /inc/config_inc.php";
- }
- else {
- // --------------------------------------------------
- // convert POST
- // --------------------------------------------------
- $source_database = $_POST['source_database'];
- $source_user = $_POST['source_user'];
- $source_pw = $_POST['source_pw'];
- $target_database = $_POST['target_database'];
- $target_user = $_POST['target_user'];
- $target_pw = $_POST['target_pw'];
- $submit = $_POST['submit'];
- $_SESSION['source_database'] = $source_database;
- $_SESSION['source_user'] = $source_user;
- $_SESSION['source_pw'] = $source_pw;
- $_SESSION['source_version'] = $source_version;
- $_SESSION['target_database'] = $target_database;
- $_SESSION['target_user'] = $target_user;
- $_SESSION['target_pw'] = $target_pw;
- $_SESSION['target_version'] = $target_version;
- $check_title = "Selon votre saisie";
- }
- // --------------------------------------------------
- // CHECK
- // --------------------------------------------------
- $correct = 1;
- if ($submit) {
- // --------------------------------------------------
- // source data
- // --------------------------------------------------
- if (!isset($source_database) or $source_database == '') {
- print "Base source manquante<br />";
- $correct = 0;
- }
- if (!isset($source_user) or $source_user == '') {
- print "Utilisateur source manquant<br />";
- $correct = 0;
- }
- if (!isset($source_pw) or $source_pw == '') {
- print "Mot de passe source manquant<br />";
- $correct = 0;
- }
- // --------------------------------------------------
- // target data
- // --------------------------------------------------
- if (!isset($target_database) or $target_database == '') {
- print "Base cible manquante<br />";
- $correct = 0;
- }
- if (!isset($target_user) or $target_user == '') {
- print "Utilisateur cible manquant<br />";
- $correct = 0;
- }
- if (!isset($target_pw) or $target_pw == '') {
- print "Mot de passe cible manquant<br />";
- $correct = 0;
- }
- }
- // --------------------------------------------------
- // CHECK DB CONNEXION
- // --------------------------------------------------
- if ($submit and $correct) {
- $source_connect_status = db_connection('source');
- if (!$source_connect_status['connection']) {
- $correct = 0;
- print "<span class=\"error\">" . $source_connect_status['connection_error'] . "</span><br />";
- }
- else {
- if (!$source_connect_status['db_selection']) {
- $correct = 0;
- print "<span class=\"error\">" . $source_connect_status['db_selection_error'] . "</span><br />";
- }
- }
- $target_connect_status = db_connection('target');
- if (!$target_connect_status['connection']) {
- $correct = 0;
- print "<span class=\"error\">" . $target_connect_status['connection_error'] . "</span><br />";
- }
- else {
- if (!$target_connect_status['db_selection']) {
- $correct = 0;
- print "<span class=\"error\">" . $target_connect_status['db_selection_error'] . "</span><br />";
- }
- }
- }
- // --------------------------------------------------
- // CHECK VERSION IN AGORA SPIP_META
- // --------------------------------------------------
- if ($submit and $correct) {
- /*
- // --------------------------------------------------
- // list source table
- // --------------------------------------------------
- $source_version = get_version('source', $source_database);
- // --------------------------------------------------
- // check version
- // --------------------------------------------------
- if ($source_version == '') {
- print "Impossible de déterminer la version d'Agora, merci de vérifier votre sélection <br />";
- $correct = 0;
- }
- elseif (!ereg('1.2|1.3|1.4', $source_version)) {
- print "$source_version ne correspond pas à une version d'Agora, merci de vérifier votre sélection <br />";
- $correct = 0;
- }
- // --------------------------------------------------
- // list target table
- // --------------------------------------------------
- $target_version = get_version('target', $target_database);
- // --------------------------------------------------
- // check version
- // --------------------------------------------------
- if ($target_version == '') {
- print "Impossible de déterminer la version de SPIP, merci de vérifier votre sélection <br />";
- $correct = 0;
- }
- elseif (!ereg('1.9', $target_version)) {
- print "$target_version ne correspond pas à une version cible de SPIP, merci de vérifier votre sélection <br />";
- $correct = 0;
- }
- */
- }
- // --------------------------------------------------
- // TREAT
- // --------------------------------------------------
- if ($submit and $correct) {
- go_to('confirm.php'); // v 1.0
- }
- // --------------------------------------------------
- // form
- // --------------------------------------------------
- if (!$submit or !$correct) {
- include "inc/header.html";
- print "<h2>Sélection des bases de données</h2>";
- print "<form name=\"form1\" method=\"post\" action=\"\">";
- print "<table width=\"60%\" border=\"0\" cellpadding=\"3\">";
- // --------------------------------------------------
- // source agora
- // --------------------------------------------------
- print "<tr>";
- print "<th colspan = \"2\">Source</th>";
- print "</tr>";
- print "<tr>";
- print "<td class=\"label\">";
- print "<label for=\"source_database\">Nom de la base de données </label></td>";
- print "<td width=\"59%\">";
- print "<input type=\"text\" name=\"source_database\" id=\"source_database\" value=\"$source_database\">";
- print "</td>";
- print "</tr>";
- print "<tr>";
- print "<td class=\"label\">";
- print "<label for=\"source_user\">Utilisateur</label></td>";
- print "<td><input type=\"text\" name=\"source_user\" id=\"source_user\" value=\"$source_user\">";
- print "</td>";
- print "</tr>";
- print "<tr>";
- print "<td class=\"label\">";
- print "<label for=\"source_pw\">Mot de passe</label></td>";
- print "<td><input type=\"text\" name=\"source_pw\" id=\"source_pw\" value=\"$source_pw\">";
- print "</td>";
- print "</tr>";
- print "<tr>";
- print "<td> </td>";
- print "<td> </td>";
- print "</tr>";
- print "<tr>";
- // --------------------------------------------------
- // target Spip
- // --------------------------------------------------
- print "<th colspan = \"2\">Cible</th>";
- print "</tr>";
- print "<tr>";
- print "<td class=\"label\">";
- print "<label for=\"target_database\">Nom de la base de données</label></td>";
- print "<td><input type=\"text\" name=\"target_database\" id=\"target_database\" value=\"$target_database\"></td>";
- print "</tr>";
- print "<tr>";
- print "<td class=\"label\">";
- print "<label for=\"target_user\">Utilisateur</label></td>";
- print "<td><input type=\"text\" name=\"target_user\" id=\"target_user\" value=\"$target_user\"></td>";
- print "</tr>";
- print "<tr>";
- print "<td class=\"label\">";
- print "<label for=\"target_pw\">Mot de passe</label></td>";
- print "<td><input type=\"text\" name=\"target_pw\" id=\"target_pw\" value=\"$target_pw\"></td>";
- print "</tr>";
- print "<tr>";
- print "<td colspan = \"2\"><label for=\"submit\"></label>";
- print "<input class=\"submit\" type=\"submit\" name=\"submit\" value=\"Valider\" id=\"submit\"></td>";
- print "</tr>";
- print "</table>";
- print "</form>";
- include "inc/footer.html";
- }
- ?>