Subversion Repositories Applications.papyrus

Rev

Rev 1021 | 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
// +------------------------------------------------------------------------------------------------------+
1021 florian 34
// CVS : $Id: instal_preference.inc.php,v 1.12 2006-10-06 15:23:00 florian 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
1021 florian 48
*@version       $Revision: 1.12 $ $Date: 2006-10-06 15:23:00 $
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
458 florian 59
$tableau = array('ADMIN_PRENOM' => '', 'ADMIN_NOM' => '', 'ADMIN_MAIL' => '', 'ADMIN_MDP_01' => '',
328 jpm 60
                'ADMIN_MDP_02' => '', 'ADMIN_I18N' => '', 'PAP_URL' => '', 'PAP_CHEMIN_RACINE' => '', 'PAP_URL_REECRITURE' => '0');
91 jpm 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);
991 alexandre_ 66
        if ($cle == 'PAP_CHEMIN_RACINE') $pref[$cle] = INSTAL_CHEMIN_ABSOLU;
76 jpm 67
    } else {
91 jpm 68
        if ($cle == 'PAP_URL') {
69
            $pref[$cle] =   'http://'.$_SERVER['SERVER_NAME'].
70
                            ($_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : '').
71
                            $_SERVER['REQUEST_URI'];
72
        } else if ($cle == 'PAP_CHEMIN_RACINE') {
73
            $pref[$cle] = INSTAL_CHEMIN_ABSOLU;
74
        } else {
75
            $pref[$cle] = '';
76
        }
76 jpm 77
    }
66 jpm 78
}
91 jpm 79
 
80
// +------------------------------------------------------------------------------------------------------+
81
// |                                          CORPS du PROGRAMME                                          |
82
// +------------------------------------------------------------------------------------------------------+
83
 
84
// Affichage d'informations...
458 florian 85
$sortie .= '<br /><h1>Etape n°'.$num_etape.' sur '.INSTAL_NBRE_ETAPE.'.</h1>'."\n";
91 jpm 86
$sortie .= '<p>NOTE: Ce programme d\'installation va essayer de modifier les options de configurations dans le '.
87
                'fichier <tt>pap_config.inc.php</tt>, situ&eacute; dans le r&eacute;pertoire <tt>configuration</tt> du réportoire '.
88
                '<tt>papyrus</tt>. Pour que cela fonctionne, veuillez vous assurez que votre serveur a les droits d\'acc&egrave;s '.
89
                'en &eacute;criture pour ce fichier. Si pour une raison quelconque vous ne pouvez pas faire &ccedil;a vous '.
458 florian 90
                'devrez modifier ce fichier manuellement (ce programme d\'installation vous dira comment).</p><br />'."\n";
91 jpm 91
 
92
// Nous vérifions si nous sommes en phase de test du formulaire de config des préférences
119 jpm 93
if ($_GET['installation'] == 'verif_pref' ) {
91 jpm 94
    $sortie_verif = '';
95
    $sortie_verif .= testerPresenceExtension();
119 jpm 96
    // En mise à jour, nous n'affichons pas les champs pour saisir un administrateur
97
    if (!defined(INSTAL_VERSION_NOUVELLE_NOM)) {
98
        // Nous vérifions que l'utilisateur à bien saisie les infos dans les champs du formulaire
99
        if(empty($_POST['pref']['ADMIN_PRENOM'])) {
100
            $sortie_verif .= '<p class="erreur">Le champ "Prénom" ne doit pas être vide!</p>'."\n";
101
        }
102
        if(empty($_POST['pref']['ADMIN_NOM'])) {
103
            $sortie_verif .= '<p class="erreur">Le champ "Nom" ne doit pas être vide!</p>'."\n";
104
        }
105
        if(empty($_POST['pref']['ADMIN_MAIL'])) {
106
            $sortie_verif .= '<p class="erreur">Le champ "Courriel" ne doit pas être vide!</p>'."\n";
107
        }
108
        if(empty($_POST['pref']['ADMIN_MDP_01'])) {
109
            $sortie_verif .= '<p class="erreur">Le champ "Mot de passe" ne doit pas être vide!</p>'."\n";
110
        }
111
        if($_POST['pref']['ADMIN_MDP_01'] != $_POST['pref']['ADMIN_MDP_02']) {
112
            $sortie_verif .= '<p class="erreur">Le deux mots de passes saisis pour le compte administrateur sont différents!</p>'."\n";
113
        }
76 jpm 114
    }
66 jpm 115
}
91 jpm 116
 
117
// Gestion de l'affichage de sortie
118
if (!isset($sortie_verif) && empty($sortie_verif)) {
119
    // Premier appel du fichier...
120
    $sortie .= creerFormulaire($pref);
121
    $sortie .= '      </ul>'."\n";
458 florian 122
    $sortie .= '<input type="submit" value="Passer à l\'étape suivante" />'."\n";
123
    $sortie .= '</form>';
91 jpm 124
} else if (isset($sortie_verif) && !empty($sortie_verif)) {
125
    // Vérification du fichier avec interuption...
126
    $sortie .= $sortie_verif;
127
    $sortie .= creerFormulaire($pref);
128
    $sortie .= '      </ul>'."\n";
458 florian 129
    $sortie .= '<input type="submit" value="Tester à nouveau" />'."\n";
91 jpm 130
    $sortie .= '    </form>';
131
} else if (isset($sortie_verif) && empty($sortie_verif)) {
132
    // Vérification du fichier sans interuption... passage à l'étape suivante
133
    $sortie .= creerFormulaire($pref, true);
134
    $sortie .= '      </ul>'."\n";
135
    $sortie .= '    </form>';
1021 florian 136
    $sortie .= '    <br /><p class="etape_info">La configuration est OK. A l\'&eacute;tape suivante, le programme d\'installation va essayer de configurer '.
91 jpm 137
                    'et créer la base de données.</p>'."\n";
1021 florian 138
    $sortie .= '    <form style="clear:both;" action="'.donnerUrlCourante().'?installation=form_bdd" method="post">'."\n";
91 jpm 139
    $sortie .= '      <input type="hidden" name="pref_serial" value="'.htmlentities(serialize($pref)).'" />'."\n";
140
    $sortie .= '      <input type="submit" value="Continuer" />'."\n";
141
    $sortie .= '    </form>'."\n";
142
}
66 jpm 143
// +------------------------------------------------------------------------------------------------------+
91 jpm 144
// |                                            LISTE DES FONCTIONS                                       |
66 jpm 145
// +------------------------------------------------------------------------------------------------------+
146
 
91 jpm 147
// Création du formulaire de configuration de la base de donneés
148
function creerFormulaire($pref, $bln_lecture = false) {
149
    $disabled = '';
150
    if ($bln_lecture) {
151
        $disabled = ' disabled="disabled" ';
152
    }
153
    $sortie_form = '';
458 florian 154
    $sortie_form .= '    <form action="'.donnerUrlCourante().'?installation=verif_pref" method="post">'."\n";
155
    $sortie_form .= '<ul>'."\n";
119 jpm 156
    // En mise à jour, nous n'affichons pas les champs pour saisir un administrateur
157
    if (!defined(INSTAL_VERSION_NOUVELLE_NOM)) {
458 florian 158
        $sortie_form .= '<li><h2>Configuration d\'un administrateur de Papyrus</h2></li>'."\n";
159
	$sortie_form .=  '<li>Tous les champs ci-dessous sont obligatoires.</li>'."\n";
119 jpm 160
        $sortie_form .=  '<li>'."\n".
161
                    '<label for="admin_prenom">Prénom :</label>'.
162
                    '<input id="admin_prenom"'.$disabled.'type="text" size="30" name="pref[ADMIN_PRENOM]" value="'.$pref['ADMIN_PRENOM'].'" />'.
163
                    '</li>'."\n";
164
        $sortie_form .=  '<li>'."\n".
165
                    '<label for="admin_nom">Nom :</label>'.
166
                    '<input id="admin_nom"'.$disabled.'type="text" size="30" name="pref[ADMIN_NOM]" value="'.$pref['ADMIN_NOM'].'" />'.
167
                    '</li>'."\n";
168
        $sortie_form .=  '<li>'."\n".
169
                    '<label for="admin_mail">Courriel :</label>'.
170
                    '<input id="admin_mail"'.$disabled.'type="text" size="30" name="pref[ADMIN_MAIL]" value="'.$pref['ADMIN_MAIL'].'" />'.
171
                    '</li>'."\n";
172
        $sortie_form .=  '<li>'."\n".
173
                    '<label for="admin_mdp_01">Mot de passe :</label>'.
174
                    '<input id="admin_mdp_01"'.$disabled.'type="password" size="10" name="pref[ADMIN_MDP_01]" value="'.$pref['ADMIN_MDP_01'].'" />'.
175
                    '</li>'."\n";
176
        $sortie_form .=  '<li>'."\n".
177
                    '<label for="admin_mdp_02">Taper à nouveau votre mot de passe :</label>'.
178
                    '<input id="admin_mdp_02"'.$disabled.'type="password" size="10" name="pref[ADMIN_MDP_02]" value="'.$pref['ADMIN_MDP_02'].'" />'.
179
                    '</li>'."\n";
180
        $sortie_form .=  '<li>'."\n".
181
                    '<label for="admin_i18n">Langue :</label>'.
182
                    '<select id="admin_i18n"'.$disabled.'name="pref[ADMIN_I18N]">'.
183
                        '<option value="fr-FR" selected="selected">français</option>'.
184
                    '</select>'.
185
                    '</li>'."\n";
186
    }
458 florian 187
    $sortie_form .=  '<li>&nbsp;</li>'."\n".'<li><h2>Configuration de l\'URL</h2></li>'."\n";
91 jpm 188
    $sortie_form .=  '<li>L\'URL courante dans la barre d\'adresse de votre navigateur devrait correspondre à la valeur '.
189
                'présente dans le champ ci-dessous. Si ce n\'est pas le cas, veuillez corriger la valeur ci-dessous.'."\n";
190
    $sortie_form .=  '<li>'."\n".
191
                '<label for="url_courante">URL courante :</label>'.
192
                '<input id="url_courante"'.$disabled.'type="text" size="60" name="pref[PAP_URL]" value="'.$pref['PAP_URL'].'" />'.
193
                '</li>'."\n";
194
    $sortie_form .= '<li>Le mode "redirection automatique" doit &ecirc;tre s&eacute;lectionn&eacute; uniquement si '.
100 jpm 195
                    'vous utilisez Papyrus avec la redirection d\'URL (si vous ne savez pas ce qu\'est la redirection d\'URL '.
91 jpm 196
                    'n\'activez pas cette option).</li>'."\n";
197
    $sortie_form .=  '<li>'."\n".
198
                '<label for="rewrite_mode">Mode "redirection" :</label>'.
328 jpm 199
                '<input id="rewrite_mode"'.$disabled.'type="checkbox" name="pref[PAP_URL_REECRITURE]" value="1" />'.
200
                'Activation'.'</li>'."\n";
100 jpm 201
    $sortie_form .= '<li>Le champ suivant devrait contenir le chemin d\'accès absolu vers le fichier <tt>papyrus.php</tt> '.
91 jpm 202
                    'sur le serveur où sont déposés les fichiers de Papyrus.</li>'."\n";
203
    $sortie_form .=  '<li>'."\n".
204
                '<label for="web_racine">Dossier de <tt>papyrus.php</tt> :</label>'.
205
                '<input id="web_racine"'.$disabled.'type="text" size="60" name="pref[PAP_CHEMIN_RACINE]" value="'.$pref['PAP_CHEMIN_RACINE'].'" />'.
206
                '</li>'."\n";
207
 
208
    return $sortie_form;
66 jpm 209
}
210
 
91 jpm 211
// Vérification des variables d'environnement de PHP.
212
function testerPresenceExtension() {
213
    $message = '';
214
    $phrase_deb = '<p class="erreur">Pour fonctionner Papyrus à besoin que l\'extension PHP : ';
215
    $phrase_fin = 'soit installée sur le serveur.<br /> Sans cette extension vous ne pourrez pas installer Papyrus !</p>';
216
    // Nous avons besoin de quelques extensions
217
    if (! extension_loaded('mysql')) {
218
        $message .= $phrase_deb.'MYSQL'.$phrase_fin;
219
    }
220
    if (! extension_loaded('ftp')) {
221
        $message .= $phrase_deb.'FTP'.$phrase_fin;
222
    }
223
    if (! extension_loaded('gd')) {
224
        $message .= $phrase_deb.'GD'.$phrase_fin;
225
    }
226
    return $message;
227
}
66 jpm 228
// +------------------------------------------------------------------------------------------------------+
229
// |                                            PIED du PROGRAMME                                         |
230
// +------------------------------------------------------------------------------------------------------+
231
 
232
 
233
/* +--Fin du code ----------------------------------------------------------------------------------------+
234
*
2150 mathias 235
* $Log: instal_preference.inc.php,v $
236
* Revision 1.12  2006-10-06 15:23:00  florian
237
* amelioration graphique de l'installateur
238
*
1021 florian 239
* Revision 1.11  2006/10/05 15:14:18  alexandre_tb
240
* Mise en place du chemin par défaut
241
*
991 alexandre_ 242
* Revision 1.10  2005/09/23 14:20:23  florian
243
* nouvel habillage installateur, plus correction de quelques bugs
244
*
458 florian 245
* Revision 1.9  2005/04/12 16:09:45  jpm
246
* Amélioration de la gestion de la constante de redirection des urls et de la gestion des constantes de type entier et booléen.
247
*
328 jpm 248
* Revision 1.8  2004/10/27 11:43:32  jpm
249
* Correction bogues diff mise à jour / installation.
250
*
119 jpm 251
* Revision 1.7  2004/10/25 10:22:48  jpm
252
* Correction de quelques bogues, ajouts d'explications pour l'utilisateur et modification des styles CSS.
253
*
100 jpm 254
* Revision 1.6  2004/10/22 17:23:04  jpm
255
* Simplification del'installation de Papyrus.
256
*
91 jpm 257
* Revision 1.5  2004/10/22 09:07:18  jpm
258
* Début simplification installateur.
259
*
87 jpm 260
* Revision 1.4  2004/10/19 17:01:12  jpm
261
* Correction bogues.
262
*
80 jpm 263
* Revision 1.3  2004/10/19 16:47:28  jpm
264
* Transformation en fonction de l'appel de l'application.
265
*
79 jpm 266
* Revision 1.2  2004/10/19 15:59:18  jpm
267
* Ajout de la gestion des valeurs propre à Papyrus à insérer dans la base de données.
268
* Ajout des constantes FTP.
269
*
76 jpm 270
* Revision 1.1  2004/10/15 18:28:59  jpm
271
* Début appli installateur de Papyrus.
66 jpm 272
*
76 jpm 273
*
66 jpm 274
* +-- Fin du code ----------------------------------------------------------------------------------------+
275
*/
276
?>