Subversion Repositories Applications.papyrus

Rev

Rev 100 | Rev 328 | 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
// | All rights reserved.                                                                                 |
12
// | Redistribution and use in source and binary forms, with or without                                   |
13
// | modification, are permitted provided that the following conditions                                   |
14
// | are met:                                                                                             |
15
// | 1. Redistributions of source code must retain the above copyright                                    |
16
// | notice, this list of conditions and the following disclaimer.                                        |
17
// | 2. Redistributions in binary form must reproduce the above copyright                                 |
18
// | notice, this list of conditions and the following disclaimer in the                                  |
19
// | documentation and/or other materials provided with the distribution.                                 |
20
// | 3. The name of the author may not be used to endorse or promote products                             |
21
// | derived from this software without specific prior written permission.                                |
22
// |                                                                                                      |
23
// | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR                                 |
24
// | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES                            |
25
// | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.                              |
26
// | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,                                     |
27
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT                             |
28
// | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,                            |
29
// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY                                |
30
// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT                                  |
31
// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF                             |
32
// | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                                    |
33
// +------------------------------------------------------------------------------------------------------+
119 jpm 34
// CVS : $Id: instal_preference.inc.php,v 1.8 2004-10-27 11:43:32 jpm Exp $
66 jpm 35
/**
36
* Page d'initialisation de l'installation de Papyrus.
37
*
38
* Contenu de la page par défaut de l'installation de Papyrus.
39
*
40
*@package Installateur
41
//Auteur original :
42
*@author        Hendrik MANS <hendrik@mans.de>
43
//Autres auteurs :
44
*@author        David DELON
45
*@author        Patrick PAUL
46
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
47
*@copyright     Tela-Botanica 2000-2004
119 jpm 48
*@version       $Revision: 1.8 $ $Date: 2004-10-27 11:43:32 $
66 jpm 49
// +------------------------------------------------------------------------------------------------------+
50
**/
51
 
52
// +------------------------------------------------------------------------------------------------------+
53
// |                                            ENTÊTE du PROGRAMME                                       |
54
// +------------------------------------------------------------------------------------------------------+
91 jpm 55
// Numéro de l'étape d'installation :
56
$num_etape = 1;
57
 
58
// Initialisation du tableau contenant les valeurs de configuration de la base de données
59
$tableau = array('ADMIN_PRENOM' => '', 'ADMIN_NOM' => '', 'ADMIN_LOGIN' => '', 'ADMIN_MAIL' => '', 'ADMIN_MDP_01' => '',
60
                'ADMIN_MDP_02' => '', 'ADMIN_I18N' => '', 'PAP_URL' => '', 'PAP_CHEMIN_RACINE' => '', 'PAP_URL_REECRITURE' => '');
61
foreach ($tableau as $cle => $val) {
62
    if (!empty($_POST['pref'][$cle])) {
63
        $pref[$cle] = $_POST['pref'][$cle];
64
    } else if (defined($cle)) {
65
        $pref[$cle] = constant($cle);
76 jpm 66
    } else {
91 jpm 67
        if ($cle == 'PAP_URL') {
68
            $pref[$cle] =   'http://'.$_SERVER['SERVER_NAME'].
69
                            ($_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : '').
70
                            $_SERVER['REQUEST_URI'];
71
        } else if ($cle == 'PAP_CHEMIN_RACINE') {
72
            $pref[$cle] = INSTAL_CHEMIN_ABSOLU;
73
        } else {
74
            $pref[$cle] = '';
75
        }
76 jpm 76
    }
66 jpm 77
}
91 jpm 78
 
79
// +------------------------------------------------------------------------------------------------------+
80
// |                                          CORPS du PROGRAMME                                          |
81
// +------------------------------------------------------------------------------------------------------+
82
 
83
// Affichage d'informations...
100 jpm 84
$sortie .= '<p class="etape_numero"><strong>Etape n°'.$num_etape.' sur '.INSTAL_NBRE_ETAPE.'.</strong></p>'."\n";
91 jpm 85
$sortie .= '<p>NOTE: Ce programme d\'installation va essayer de modifier les options de configurations dans le '.
86
                'fichier <tt>pap_config.inc.php</tt>, situ&eacute; dans le r&eacute;pertoire <tt>configuration</tt> du réportoire '.
87
                '<tt>papyrus</tt>. Pour que cela fonctionne, veuillez vous assurez que votre serveur a les droits d\'acc&egrave;s '.
88
                'en &eacute;criture pour ce fichier. Si pour une raison quelconque vous ne pouvez pas faire &ccedil;a vous '.
89
                'devrez modifier ce fichier manuellement (ce programme d\'installation vous dira comment).</p>'."\n";
90
 
91
// Nous vérifions si nous sommes en phase de test du formulaire de config des préférences
119 jpm 92
if ($_GET['installation'] == 'verif_pref' ) {
91 jpm 93
    $sortie_verif = '';
94
    $sortie_verif .= testerPresenceExtension();
119 jpm 95
    // En mise à jour, nous n'affichons pas les champs pour saisir un administrateur
96
    if (!defined(INSTAL_VERSION_NOUVELLE_NOM)) {
97
        // Nous vérifions que l'utilisateur à bien saisie les infos dans les champs du formulaire
98
        if(empty($_POST['pref']['ADMIN_PRENOM'])) {
99
            $sortie_verif .= '<p class="erreur">Le champ "Prénom" ne doit pas être vide!</p>'."\n";
100
        }
101
        if(empty($_POST['pref']['ADMIN_NOM'])) {
102
            $sortie_verif .= '<p class="erreur">Le champ "Nom" ne doit pas être vide!</p>'."\n";
103
        }
104
        if(empty($_POST['pref']['ADMIN_LOGIN'])) {
105
            $sortie_verif .= '<p class="erreur">Le champ "Login" ne doit pas être vide!</p>'."\n";
106
        }
107
        if(empty($_POST['pref']['ADMIN_MAIL'])) {
108
            $sortie_verif .= '<p class="erreur">Le champ "Courriel" ne doit pas être vide!</p>'."\n";
109
        }
110
        if(empty($_POST['pref']['ADMIN_MDP_01'])) {
111
            $sortie_verif .= '<p class="erreur">Le champ "Mot de passe" ne doit pas être vide!</p>'."\n";
112
        }
113
        if($_POST['pref']['ADMIN_MDP_01'] != $_POST['pref']['ADMIN_MDP_02']) {
114
            $sortie_verif .= '<p class="erreur">Le deux mots de passes saisis pour le compte administrateur sont différents!</p>'."\n";
115
        }
76 jpm 116
    }
66 jpm 117
}
91 jpm 118
 
119
// Gestion de l'affichage de sortie
120
if (!isset($sortie_verif) && empty($sortie_verif)) {
121
    // Premier appel du fichier...
122
    $sortie .= creerFormulaire($pref);
123
    $sortie .= '<li><input type="submit" value="Tester" /></li>'."\n";
124
    $sortie .= '      </ul>'."\n";
125
    $sortie .= '    </form>';
126
} else if (isset($sortie_verif) && !empty($sortie_verif)) {
127
    // Vérification du fichier avec interuption...
128
    $sortie .= $sortie_verif;
129
    $sortie .= creerFormulaire($pref);
130
    $sortie .= '<li><input type="submit" value="Tester à nouveau" /></li>'."\n";
131
    $sortie .= '      </ul>'."\n";
132
    $sortie .= '    </form>';
133
} else if (isset($sortie_verif) && empty($sortie_verif)) {
134
    // Vérification du fichier sans interuption... passage à l'étape suivante
135
    $sortie .= creerFormulaire($pref, true);
136
    $sortie .= '      </ul>'."\n";
137
    $sortie .= '    </form>';
100 jpm 138
    $sortie .= '    <p class="etape_info">A l\'&eacute;tape suivante, le programme d\'installation va essayer de configurer '.
91 jpm 139
                    'et créer la base de données.</p>'."\n";
140
    $sortie .= '    <form action="'.donnerUrlCourante().'?installation=form_bdd" method="POST" />'."\n";
141
    $sortie .= '      <input type="hidden" name="pref_serial" value="'.htmlentities(serialize($pref)).'" />'."\n";
142
    $sortie .= '      <input type="submit" value="Continuer" />'."\n";
143
    $sortie .= '    </form>'."\n";
144
}
66 jpm 145
// +------------------------------------------------------------------------------------------------------+
91 jpm 146
// |                                            LISTE DES FONCTIONS                                       |
66 jpm 147
// +------------------------------------------------------------------------------------------------------+
148
 
91 jpm 149
// Création du formulaire de configuration de la base de donneés
150
function creerFormulaire($pref, $bln_lecture = false) {
151
    $disabled = '';
152
    if ($bln_lecture) {
153
        $disabled = ' disabled="disabled" ';
154
    }
155
    $sortie_form = '';
156
    $sortie_form .= '    <form action="'.donnerUrlCourante().'?installation=verif_pref" method="post">';
157
    $sortie_form .= '      <ul>'."\n";
119 jpm 158
    // En mise à jour, nous n'affichons pas les champs pour saisir un administrateur
159
    if (!defined(INSTAL_VERSION_NOUVELLE_NOM)) {
160
        $sortie_form .=  '<li><h2>Configuration d\'un administrateur de Papyrus</h2></li>'."\n";
161
        $sortie_form .=  '<li>Tous les champs ci-dessous sont obligatoires.</li>'."\n";
162
        $sortie_form .=  '<li>'."\n".
163
                    '<label for="admin_prenom">Prénom :</label>'.
164
                    '<input id="admin_prenom"'.$disabled.'type="text" size="30" name="pref[ADMIN_PRENOM]" value="'.$pref['ADMIN_PRENOM'].'" />'.
165
                    '</li>'."\n";
166
        $sortie_form .=  '<li>'."\n".
167
                    '<label for="admin_nom">Nom :</label>'.
168
                    '<input id="admin_nom"'.$disabled.'type="text" size="30" name="pref[ADMIN_NOM]" value="'.$pref['ADMIN_NOM'].'" />'.
169
                    '</li>'."\n";
170
        $sortie_form .=  '<li>'."\n".
171
                    '<label for="admin_login">Login :</label>'.
172
                    '<input id="admin_login"'.$disabled.'type="text" size="30" name="pref[ADMIN_LOGIN]" value="'.$pref['ADMIN_LOGIN'].'" />'.
173
                    '</li>'."\n";
174
        $sortie_form .=  '<li>'."\n".
175
                    '<label for="admin_mail">Courriel :</label>'.
176
                    '<input id="admin_mail"'.$disabled.'type="text" size="30" name="pref[ADMIN_MAIL]" value="'.$pref['ADMIN_MAIL'].'" />'.
177
                    '</li>'."\n";
178
        $sortie_form .=  '<li>'."\n".
179
                    '<label for="admin_mdp_01">Mot de passe :</label>'.
180
                    '<input id="admin_mdp_01"'.$disabled.'type="password" size="10" name="pref[ADMIN_MDP_01]" value="'.$pref['ADMIN_MDP_01'].'" />'.
181
                    '</li>'."\n";
182
        $sortie_form .=  '<li>'."\n".
183
                    '<label for="admin_mdp_02">Taper à nouveau votre mot de passe :</label>'.
184
                    '<input id="admin_mdp_02"'.$disabled.'type="password" size="10" name="pref[ADMIN_MDP_02]" value="'.$pref['ADMIN_MDP_02'].'" />'.
185
                    '</li>'."\n";
186
        $sortie_form .=  '<li>'."\n".
187
                    '<label for="admin_i18n">Langue :</label>'.
188
                    '<select id="admin_i18n"'.$disabled.'name="pref[ADMIN_I18N]">'.
189
                        '<option value="fr-FR" selected="selected">français</option>'.
190
                    '</select>'.
191
                    '</li>'."\n";
192
    }
91 jpm 193
    $sortie_form .=  '<li><h2>Configuration de l\'URL</h2></li>'."\n";
194
    $sortie_form .=  '<li>L\'URL courante dans la barre d\'adresse de votre navigateur devrait correspondre à la valeur '.
195
                'présente dans le champ ci-dessous. Si ce n\'est pas le cas, veuillez corriger la valeur ci-dessous.'."\n";
196
    $sortie_form .=  '<li>'."\n".
197
                '<label for="url_courante">URL courante :</label>'.
198
                '<input id="url_courante"'.$disabled.'type="text" size="60" name="pref[PAP_URL]" value="'.$pref['PAP_URL'].'" />'.
199
                '</li>'."\n";
200
    $sortie_form .= '<li>Le mode "redirection automatique" doit &ecirc;tre s&eacute;lectionn&eacute; uniquement si '.
100 jpm 201
                    'vous utilisez Papyrus avec la redirection d\'URL (si vous ne savez pas ce qu\'est la redirection d\'URL '.
91 jpm 202
                    'n\'activez pas cette option).</li>'."\n";
203
    $sortie_form .=  '<li>'."\n".
204
                '<label for="rewrite_mode">Mode "redirection" :</label>'.
205
                '<input id="rewrite_mode"'.$disabled.'type="checkbox" name="pref[PAP_URL_REECRITURE]" value="'.$pref['PAP_URL_REECRITURE'].'" />'.
206
                'Activation'.
207
                '<input type="hidden" name="pref[PAP_URL_REECRITURE]" value="0" />'.
208
                '</li>'."\n";
100 jpm 209
    $sortie_form .= '<li>Le champ suivant devrait contenir le chemin d\'accès absolu vers le fichier <tt>papyrus.php</tt> '.
91 jpm 210
                    'sur le serveur où sont déposés les fichiers de Papyrus.</li>'."\n";
211
    $sortie_form .=  '<li>'."\n".
212
                '<label for="web_racine">Dossier de <tt>papyrus.php</tt> :</label>'.
213
                '<input id="web_racine"'.$disabled.'type="text" size="60" name="pref[PAP_CHEMIN_RACINE]" value="'.$pref['PAP_CHEMIN_RACINE'].'" />'.
214
                '</li>'."\n";
215
 
216
    return $sortie_form;
66 jpm 217
}
218
 
91 jpm 219
// Vérification des variables d'environnement de PHP.
220
function testerPresenceExtension() {
221
    $message = '';
222
    $phrase_deb = '<p class="erreur">Pour fonctionner Papyrus à besoin que l\'extension PHP : ';
223
    $phrase_fin = 'soit installée sur le serveur.<br /> Sans cette extension vous ne pourrez pas installer Papyrus !</p>';
224
    // Nous avons besoin de quelques extensions
225
    if (! extension_loaded('mysql')) {
226
        $message .= $phrase_deb.'MYSQL'.$phrase_fin;
227
    }
228
    if (! extension_loaded('ftp')) {
229
        $message .= $phrase_deb.'FTP'.$phrase_fin;
230
    }
231
    if (! extension_loaded('gd')) {
232
        $message .= $phrase_deb.'GD'.$phrase_fin;
233
    }
234
    return $message;
235
}
66 jpm 236
// +------------------------------------------------------------------------------------------------------+
237
// |                                            PIED du PROGRAMME                                         |
238
// +------------------------------------------------------------------------------------------------------+
239
 
240
 
241
/* +--Fin du code ----------------------------------------------------------------------------------------+
242
*
243
* $Log: not supported by cvs2svn $
119 jpm 244
* Revision 1.7  2004/10/25 10:22:48  jpm
245
* Correction de quelques bogues, ajouts d'explications pour l'utilisateur et modification des styles CSS.
246
*
100 jpm 247
* Revision 1.6  2004/10/22 17:23:04  jpm
248
* Simplification del'installation de Papyrus.
249
*
91 jpm 250
* Revision 1.5  2004/10/22 09:07:18  jpm
251
* Début simplification installateur.
252
*
87 jpm 253
* Revision 1.4  2004/10/19 17:01:12  jpm
254
* Correction bogues.
255
*
80 jpm 256
* Revision 1.3  2004/10/19 16:47:28  jpm
257
* Transformation en fonction de l'appel de l'application.
258
*
79 jpm 259
* Revision 1.2  2004/10/19 15:59:18  jpm
260
* Ajout de la gestion des valeurs propre à Papyrus à insérer dans la base de données.
261
* Ajout des constantes FTP.
262
*
76 jpm 263
* Revision 1.1  2004/10/15 18:28:59  jpm
264
* Début appli installateur de Papyrus.
66 jpm 265
*
76 jpm 266
*
66 jpm 267
* +-- Fin du code ----------------------------------------------------------------------------------------+
268
*/
269
?>