Subversion Repositories Applications.papyrus

Rev

Rev 76 | Rev 91 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
66 jpm 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | Copyright (c) 2002, Hendrik Mans <hendrik@mans.de>                                                   |
9
// | Copyright 2002, 2003 David DELON                                                                     |
10
// | Copyright 2002 Patrick PAUL                                                                          |
11
// | Copyright  2003  Eric FELDSTEIN                                                                      |
12
// | All rights reserved.                                                                                 |
13
// | Redistribution and use in source and binary forms, with or without                                   |
14
// | modification, are permitted provided that the following conditions                                   |
15
// | are met:                                                                                             |
16
// | 1. Redistributions of source code must retain the above copyright                                    |
17
// | notice, this list of conditions and the following disclaimer.                                        |
18
// | 2. Redistributions in binary form must reproduce the above copyright                                 |
19
// | notice, this list of conditions and the following disclaimer in the                                  |
20
// | documentation and/or other materials provided with the distribution.                                 |
21
// | 3. The name of the author may not be used to endorse or promote products                             |
22
// | derived from this software without specific prior written permission.                                |
23
// |                                                                                                      |
24
// | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR                                 |
25
// | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES                            |
26
// | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.                              |
27
// | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,                                     |
28
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT                             |
29
// | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,                            |
30
// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY                                |
31
// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT                                  |
32
// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF                             |
33
// | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                                    |
34
// +------------------------------------------------------------------------------------------------------+
79 jpm 35
// CVS : $Id: instal_base_de_donnees.inc.php,v 1.3 2004-10-19 16:47:28 jpm Exp $
66 jpm 36
/**
37
* Page de création de la base de données de Papyrus.
38
*
39
* Page permettant de créer la base de données de Papyrus.
40
*
41
*@package Installateur
42
//Auteur original :
43
*@author        Hendrik MANS <hendrik@mans.de>
44
//Autres auteurs :
45
*@author        David DELON
46
*@author        Patrick PAUL
47
*@author        Eric FELDSTEIN
48
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
49
*@copyright     Tela-Botanica 2000-2004
79 jpm 50
*@version       $Revision: 1.3 $ $Date: 2004-10-19 16:47:28 $
66 jpm 51
// +------------------------------------------------------------------------------------------------------+
52
**/
53
 
54
// +------------------------------------------------------------------------------------------------------+
55
// |                                            ENTÊTE du PROGRAMME                                       |
56
// +------------------------------------------------------------------------------------------------------+
57
// Récupération des paramêtres de configuration du formulaire précédent
58
if (isset($_POST['config'])) {
59
    $config = $_POST['config'];
60
} else if (isset($_POST['config_serial'])) {
61
    $config = unserialize(stripslashes($_POST['config_serial']));
62
}
76 jpm 63
if (isset($_POST['bdd'])) {
64
    $bdd = $_POST['bdd'];
65
} else if (isset($_POST['bdd_serial'])) {
66
    $bdd = unserialize(stripslashes($_POST['bdd_serial']));
67
}
66 jpm 68
// +------------------------------------------------------------------------------------------------------+
69
// |                                          CORPS du PROGRAMME                                          |
70
// +------------------------------------------------------------------------------------------------------+
71
$sortie .= '    <h1>Installation de Papyrus</h1></h1>'."\n";
72
 
73
// Test de la configuration
76 jpm 74
$sortie .= '    <h2>Test de la configuration de la base de données</h2>'."\n";
79 jpm 75
$erreur = testerConfig($sortie, 'Test connexion MySQL ...', $dblink = @mysql_connect($config['PAP_BDD_SERVEUR'], $config['PAP_BDD_UTILISATEUR'], $config['PAP_BDD_MOT_DE_PASSE']), '', 1, 0);
76
$erreur = testerConfig($sortie, 'Recherche base de donn&eacute;es ...', @mysql_select_db($config['PAP_BDD_NOM'], $dblink),
66 jpm 77
                'La base de donn&eacute;es que vous avez choisie n\'existe pas, vous devez la cr&eacute;er avant d\'installer Papyrus !', 1, $erreur);
78
$sortie .= '<br />'."\n";
79
 
80
if (!$version = GEN_VERSION) $version = '0.1';
81
switch ($version) {
82
    case '0.1':// Nouvelle installation de Papyrus 0.1
76 jpm 83
        //Insertion des requêtes présentes dans le fichier sql
84
        $sortie .= '<h2>Insertion des données du fichier sql dans la base</h2>';
85
        $sortie .= '<div class="zone_requete">';
66 jpm 86
        $sql_contenu = PMA_readFile(INSTAL_CHEMIN_SQL.'papyrus_v'.$version.'.sql');
87
        $tab_requete_sql = array();
88
        PMA_splitSqlFile($tab_requete_sql, $sql_contenu, '');
89
        foreach ($tab_requete_sql as $value) {
90
            $table_nom = '';
91
            if (!empty($value['table_nom'])) {
92
                $table_nom = $value['table_nom'];
93
            }
94
            $requete_type = '';
95
            if (!empty($value['type'])) {
96
                $requete_type = $value['type'];
97
            }
98
            if ($requete_type == 'create') {
79 jpm 99
                $erreur = testerConfig($sortie, 'Creation table '.$table_nom.'...', @mysql_query($value['query'], $dblink),
66 jpm 100
                                            'D&eacute;j&agrave; cr&eacute;&eacute;e ?', 0, $erreur);
101
            } else if ($requete_type == 'insert') {
79 jpm 102
                $erreur = testerConfig($sortie, 'Insertion table '.$table_nom.'...', @mysql_query($value['query'], $dblink),
66 jpm 103
                                            'Donn&eacute;es d&eacute;j&agrave; pr&eacute;sente ?', 0, $erreur);
104
            }
105
        }
76 jpm 106
        $sortie .= '</div>';
107
        //Insertion des requêtes dépendant du formulaire d'installation
108
        $sortie .= '<h2>Insertion des données dépendant du formulaire précédent</h2>';
109
        $requete_admin =    'INSERT INTO gen_annuaire VALUES (1, "'.$bdd['ADMIN_I18N'].'", "'.$bdd['ADMIN_NOM'].
110
                            '", "'.$bdd['ADMIN_PRENOM'].'", "'.md5($bdd['ADMIN_MDP_01']).'", "'.
111
                            $bdd['ADMIN_MAIL'].'");';
79 jpm 112
        $erreur = testerConfig($sortie, 'Insertion de l\'administrateur...', @mysql_query($requete_admin, $dblink),
76 jpm 113
                                'Donn&eacute;es d&eacute;j&agrave; pr&eacute;sente ?', 0, $erreur);
66 jpm 114
    break;
115
    case '0.2':// Installation de Papyrus 0.2
116
 
117
    break;
118
}
119
 
120
if ($erreur == 0 || $erreur == 1) {
121
    $sortie .= '    <p>A l\'&eacute;tape suivante, le programme d\'installation va essayer d\'&eacute;crire le fichier de '.
122
                'configuration <tt>'.INSTAL_CHEMIN_CONFIG.'</tt>. Assurez vous que le serveur web a bien le '.
123
                'droit d\'&eacute;crire dans ce fichier, sinon vous devrez le modifier manuellement.</p>'."\n";
124
 
125
    $sortie .= '    <form action="'.donnerUrlCourante().'?installation=config" method="POST" />'."\n";
126
    $sortie .= '      <input type="hidden" name="config" value="'.htmlentities(serialize($config)).'" />'."\n";
76 jpm 127
    $sortie .= '      <input type="hidden" name="bdd" value="'.htmlentities(serialize($bdd)).'" />'."\n";
66 jpm 128
    $sortie .= '      <input type="submit" value="Continuer" />'."\n";
129
    $sortie .= '    </form>'."\n";
130
} else {
131
    $sortie .= '    <form action="'.donnerUrlCourante().'?installation=bdd" method="POST" />'."\n";
132
    $sortie .= '      <input type="hidden" name="config_serial" value="'.htmlentities(serialize($config)).'" />'."\n";
76 jpm 133
    $sortie .= '      <input type="hidden" name="bdd_serial" value="'.htmlentities(serialize($bdd)).'" />'."\n";
66 jpm 134
    $sortie .= '      <input type="submit" value="Essayer &agrave; nouveau" />'."\n";
135
    $sortie .= '    </form>'."\n";
136
}
137
// +------------------------------------------------------------------------------------------------------+
138
// |                                            PIED du PROGRAMME                                         |
139
// +------------------------------------------------------------------------------------------------------+
140
 
141
 
142
/* +--Fin du code ----------------------------------------------------------------------------------------+
143
*
144
* $Log: not supported by cvs2svn $
79 jpm 145
* Revision 1.2  2004/10/19 15:59:18  jpm
146
* Ajout de la gestion des valeurs propre à Papyrus à insérer dans la base de données.
147
* Ajout des constantes FTP.
148
*
76 jpm 149
* Revision 1.1  2004/10/15 18:28:59  jpm
150
* Début appli installateur de Papyrus.
66 jpm 151
*
76 jpm 152
*
66 jpm 153
* +-- Fin du code ----------------------------------------------------------------------------------------+
154
*/
155
?>