Subversion Repositories Applications.papyrus

Rev

Rev 51 | Rev 246 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 51 Rev 228
1
<?php
1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
3
// +------------------------------------------------------------------------------------------------------+
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | License as published by the Free Software Foundation; either                                         |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | Lesser General Public License for more details.                                                      |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
19
// | License along with this library; if not, write to the Free Software                                  |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: identification.php,v 1.5 2004-09-23 14:31:12 jpm Exp $
22
// CVS : $Id: identification.php,v 1.6 2004-12-13 18:07:09 alex Exp $
23
/**
23
/**
24
* Applette : identification
24
* Applette : identification
25
*
25
*
26
* Génère un formulaire les champs nécessaires pour s'identifier.
26
* Génère un formulaire les champs nécessaires pour s'identifier.
27
* Nécessite :
27
* Nécessite :
28
* - Variable globale de Génésia.
28
* - Variable globale de Génésia.
29
* - Pear Auth
29
* - Pear Auth
30
* - Pear Net_URL
30
* - Pear Net_URL
31
*
31
*
32
* A faire : remplacer le formulaire par un QuickForm
32
* A faire : remplacer le formulaire par un QuickForm
33
*
33
*
34
*@package Applette
34
*@package Applette
35
*@subpackage Identification
35
*@subpackage Identification
36
//Auteur original :
36
//Auteur original :
37
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
37
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
38
//Autres auteurs :
38
//Autres auteurs :
39
*@author        Aucun
39
*@author        Aucun
40
*@copyright     Tela-Botanica 2000-2004
40
*@copyright     Tela-Botanica 2000-2004
41
*@version       $Revision: 1.5 $ $Date: 2004-09-23 14:31:12 $
41
*@version       $Revision: 1.6 $ $Date: 2004-12-13 18:07:09 $
42
// +------------------------------------------------------------------------------------------------------+
42
// +------------------------------------------------------------------------------------------------------+
43
*/
43
*/
44
 
44
 
45
// +------------------------------------------------------------------------------------------------------+
45
// +------------------------------------------------------------------------------------------------------+
46
// |                                            ENTÊTE du PROGRAMME                                       |
46
// |                                            ENTÊTE du PROGRAMME                                       |
47
// +------------------------------------------------------------------------------------------------------+
47
// +------------------------------------------------------------------------------------------------------+
48
$_GEN_commun['info_applette_nom_fonction'] = 'afficherFormIdentification';
48
$_GEN_commun['info_applette_nom_fonction'] = 'afficherFormIdentification';
49
$_GEN_commun['info_applette_balise'] = 'IDENTIFICATION';
49
$_GEN_commun['info_applette_balise'] = 'IDENTIFICATION';
50
 
50
 
51
// +------------------------------------------------------------------------------------------------------+
51
// +------------------------------------------------------------------------------------------------------+
52
// |                                            CORPS du PROGRAMME                                        |
52
// |                                            CORPS du PROGRAMME                                        |
53
// +------------------------------------------------------------------------------------------------------+
53
// +------------------------------------------------------------------------------------------------------+
54
 
54
 
55
// Si le site utilise une authentification.
55
// Si le site utilise une authentification.
56
if ($_GEN_commun['info_auth']->gsa_ce_type_auth == 1) {
56
if ($_GEN_commun['info_auth']->gsa_ce_type_auth == 1) {
57
    // Si un formulaire nous renvoie en POST une variable "deconnexion", nous délogons l'utilisateur.
57
    // Si un formulaire nous renvoie en POST une variable "deconnexion", nous délogons l'utilisateur.
58
    if (isset($_POST['deconnexion'])) {
58
    if (isset($_POST['deconnexion'])) {
59
        $_GEN_commun['pear_auth']->logout();
59
        $_GEN_commun['pear_auth']->logout();
-
 
60
        // Le test suivant vérifie si une authentification SPIP est en cour, vois pap_initialise_auth.inc.php
-
 
61
        if (isset ($chemin_spip) && isset ($coauth) && $coauth == $auth_courante['gsab_id_auth_bdd']) {
-
 
62
            // On place un cookie avec une duré dépassée
-
 
63
            setcookie("spip_session", $id_session, time() - 3600*24, "/$chemin_cookie_spip/") ;
-
 
64
            setcookie("spip_admin", "@".$login, time() -3600*24, "/$chemin_cookie_spip/") ;
-
 
65
    
-
 
66
            $dirname = $GLOBALS['flag_ecrire'] ? "data/" : "ecrire/data/";
-
 
67
            $dirname = $chemin_spip."/".$dirname ;
-
 
68
             // ne pas se zapper soi-meme
-
 
69
            if ($s = $GLOBALS['spip_session'])
-
 
70
                   $fichier_session = fichier_session($s, lire_meta('alea_ephemere'));
-
 
71
                $fichier_session = $chemin_spip."/ecrire/".$fichier_session ;
-
 
72
            $dir = opendir($dirname);
-
 
73
            $t = time();
-
 
74
            while(($item = readdir($dir)) != '') {
-
 
75
                $chemin = "$dirname$item";
-
 
76
                if (ereg("^session_([0-9]+_)?([a-z0-9]+)\.php3$", $item, $regs)) {
-
 
77
                // Si c'est une vieille session, on jette
-
 
78
                    if (($t - filemtime($chemin)) > 48 * 3600) unlink($chemin);
-
 
79
                    // sinon voir si c'est une session du meme auteur
-
 
80
                        else if ($regs[1] == $id_auteur.'_') {
-
 
81
                            $zap_num ++;
-
 
82
                    if ($zap) unlink($chemin);
-
 
83
                    }
-
 
84
                }
-
 
85
            }
-
 
86
        }
60
        $_GEN_commun['pear_auth']->start();
87
        $_GEN_commun['pear_auth']->start();
61
    }
88
    }
62
    // Si un formulaire nous renvoie en POST une variable "connexion", nous logons l'utilisateur.
89
    // Si un formulaire nous renvoie en POST une variable "connexion", nous logons l'utilisateur.
63
    if (isset($_POST['connexion'])) {
90
    if (isset($_POST['connexion'])) {
64
        $_GEN_commun['pear_auth']->login();
91
        $_GEN_commun['pear_auth']->login();
65
        $_SESSION['username'] = $username;
92
        $_SESSION['username'] = $username;
66
    }
93
    }
67
}
94
}
68
 
95
 
69
// +------------------------------------------------------------------------------------------------------+
96
// +------------------------------------------------------------------------------------------------------+
70
// |                                           LISTE de FONCTIONS                                         |
97
// |                                           LISTE de FONCTIONS                                         |
71
// +------------------------------------------------------------------------------------------------------+
98
// +------------------------------------------------------------------------------------------------------+
72
 
99
 
73
/** Fonction afficherFormIdentification() - Retourne une formulaire pour s'identifier.
100
/** Fonction afficherFormIdentification() - Retourne une formulaire pour s'identifier.
74
*
101
*
75
* Retourne un formulaire d'identificatin ou de déconnexion suivant que l'utilisateur est
102
* Retourne un formulaire d'identificatin ou de déconnexion suivant que l'utilisateur est
76
* identifié ou pas.
103
* identifié ou pas.
77
*
104
*
78
* @param  array  tableau d'éventuel arguments présent dans la balise transmis à la fonction. 
105
* @param  array  tableau d'éventuel arguments présent dans la balise transmis à la fonction. 
79
* @param  array  tableau global de Papyrus.
106
* @param  array  tableau global de Papyrus.
80
* @return string formulaire de connexion ou de déconnexion.
107
* @return string formulaire de connexion ou de déconnexion.
81
*/
108
*/
82
function afficherFormIdentification($tab_arguments, $_GEN_commun)
109
function afficherFormIdentification($tab_arguments, $_GEN_commun)
83
{
110
{
84
    // Initialisation de variable.
111
    // Initialisation de variable.
85
    $objet_pear_auth = $_GEN_commun['pear_auth'];
112
    $objet_pear_auth = $_GEN_commun['pear_auth'];
86
    $objet_pear_db = $_GEN_commun['pear_db'];
113
    $objet_pear_db = $_GEN_commun['pear_db'];
87
    $url = $_GEN_commun['url']->getUrl();
114
    $url = $_GEN_commun['url']->getURL();
88
    // Récupération des valeurs pour le login et le mot de passe
115
    // Récupération des valeurs pour le login et le mot de passe
89
    $mot_de_passe = (! isset($_POST['password']))    ? '' : $_POST['password'];
116
    $mot_de_passe = (! isset($_POST['password']))    ? '' : $_POST['password'];
90
    $login        = (! isset($_POST['username']))    ? '' : $_POST['username'];
117
    $login        = (! isset($_POST['username']))    ? '' : $_POST['username'];
91
    
118
    
92
    // ATTENTION : Partie à supprimer une fois les mise à jour effectué dans l'annuaire de Tela Botanica
119
    // ATTENTION : Partie à supprimer une fois les mise à jour effectué dans l'annuaire de Tela Botanica
93
    // Devrait être déplacer dans l'appli inscription de Tela.
120
    // Devrait être déplacer dans l'appli inscription de Tela.
94
    if (isset($_GEN_commun['info_auth_bdd']->gsab_nom_table) && $_GEN_commun['info_auth_bdd']->gsab_nom_table == 'annuaire_tela') {
121
    if (isset($_GEN_commun['info_auth_bdd']->gsab_nom_table) && $_GEN_commun['info_auth_bdd']->gsab_nom_table == 'annuaire_tela') {
95
        verification_mot_de_passe($objet_pear_db, $mot_de_passe, $login);
122
        verification_mot_de_passe($objet_pear_db, $mot_de_passe, $login);
96
        if (isset($_POST['connexion'])) {
123
        if (isset($_POST['connexion'])) {
97
            $_GEN_commun['pear_auth']->login();
124
            $_GEN_commun['pear_auth']->login();
98
        }
125
        }
99
    }
126
    }
100
    
127
    
101
    if (! $objet_pear_auth->getAuth()) {
128
    if (! $objet_pear_auth->getAuth()) {
102
        // L'utilisateur n'est pas identifié:
129
        // L'utilisateur n'est pas identifié:
103
        $res  = str_repeat(' ', 16).'<form id="form_connexion" action="'.$url.'" method="post">'."\n";
130
        $res  = str_repeat(' ', 16).'<form id="form_connexion" action="'.$url.'" method="post">'."\n";
104
        $res .= str_repeat(' ', 16).'<fieldset>'."\n";
131
        $res .= str_repeat(' ', 16).'<fieldset>'."\n";
105
        $res .= str_repeat(' ', 20).'<legend>'.'Identification'.'</legend>'."\n";
132
        $res .= str_repeat(' ', 20).'<legend>'.'Identification'.'</legend>'."\n";
106
        $res .= str_repeat(' ', 20).''."\n";
133
        $res .= str_repeat(' ', 20).''."\n";
107
        $res .= str_repeat(' ', 24).'<label for="username">'.'Courriel :'.'</label>'."\n";
134
        $res .= str_repeat(' ', 24).'<label for="username">'.'Courriel :'.'</label>'."\n";
108
        $res .= str_repeat(' ', 24).'<input type="text" id="username" name="username" maxlength="80" tabindex="1" value="'.'courriel'.'" />'."\n";
135
        $res .= str_repeat(' ', 24).'<input type="text" id="username" name="username" maxlength="80" tabindex="1" value="'.'courriel'.'" />'."\n";
109
        $res .= str_repeat(' ', 20).''."\n";
136
        $res .= str_repeat(' ', 20).''."\n";
110
        $res .= str_repeat(' ', 20).''."\n";
137
        $res .= str_repeat(' ', 20).''."\n";
111
        $res .= str_repeat(' ', 24).'<label for="password">'.'Mot de passe :'.'</label>'."\n";
138
        $res .= str_repeat(' ', 24).'<label for="password">'.'Mot de passe :'.'</label>'."\n";
112
        $res .= str_repeat(' ', 24).'<input type="password" id="password" name="password" maxlength="80" tabindex="2" value="'.'mot de passe'.'" />'."\n";
139
        $res .= str_repeat(' ', 24).'<input type="password" id="password" name="password" maxlength="80" tabindex="2" value="'.'mot de passe'.'" />'."\n";
113
        $res .= str_repeat(' ', 20).''."\n";
140
        $res .= str_repeat(' ', 20).''."\n";
114
        $res .= str_repeat(' ', 20).''."\n";
141
        $res .= str_repeat(' ', 20).''."\n";
115
        $res .= str_repeat(' ', 24).'<input type="submit" id="connexion" name="connexion" tabindex="3" value="'.'ok'.'" />'."\n";
142
        $res .= str_repeat(' ', 24).'<input type="submit" id="connexion" name="connexion" tabindex="3" value="'.'ok'.'" />'."\n";
116
        $res .= str_repeat(' ', 20).''."\n";
143
        $res .= str_repeat(' ', 20).''."\n";
117
        $res .= str_repeat(' ', 16).'</fieldset>'."\n";
144
        $res .= str_repeat(' ', 16).'</fieldset>'."\n";
118
        $res .= str_repeat(' ', 16).'</form>';
145
        $res .= str_repeat(' ', 16).'</form>';
119
    } else {
146
    } else {
120
        // L'utilisateur est identifié. Nous affichons ses informations.
147
        // L'utilisateur est identifié. Nous affichons ses informations.
121
        // Amélioré la récupération des informations sur l'utilisateur.
148
        // Amélioré la récupération des informations sur l'utilisateur.
122
        //$nom_utilisateur = $objet_pear_auth->getAuthData($champ_nom);
149
        //$nom_utilisateur = $objet_pear_auth->getAuthData($champ_nom);
123
        
150
        
124
        $res  = str_repeat(' ', 16).'<form id="form_deconnexion" action="'.$url.'" method="post">'."\n";
151
        $res  = str_repeat(' ', 16).'<form id="form_deconnexion" action="'.$url.'&logout=1" method="post">'."\n";
125
        $res .= str_repeat(' ', 16).'<fieldset>'."\n";
152
        $res .= str_repeat(' ', 16).'<fieldset>'."\n";
126
        $res .= str_repeat(' ', 20).'<legend>'.'Identification'.'</legend>'."\n";
153
        $res .= str_repeat(' ', 20).'<legend>'.'Identification'.'</legend>'."\n";
127
        // Il faudrait mettre dans la base de données le prénom et le nom ou chercher comment définir ces champs en fonction
154
        // Il faudrait mettre dans la base de données le prénom et le nom ou chercher comment définir ces champs en fonction
128
        // de l'annuaire utilisé, si on veut les afficher après le message de bienvenue.
155
        // de l'annuaire utilisé, si on veut les afficher après le message de bienvenue.
129
        $res .= str_repeat(' ', 20).'<p>'.'Bienvenue!'.'</p>'."\n";
156
        $res .= str_repeat(' ', 20).'<p>'.'Bienvenue!'.'</p>'."\n";
130
        $res .= str_repeat(' ', 20).'<p>'."\n";
157
        $res .= str_repeat(' ', 20).'<p>'."\n";
131
        $res .= str_repeat(' ', 24).'<input type="submit" id="deconnexion" name="deconnexion" tabindex="1" value="'.'d&eacute;connexion'.'" />'."\n";
158
        $res .= str_repeat(' ', 24).'<input type="submit" id="deconnexion" name="deconnexion" tabindex="1" value="'.'d&eacute;connexion'.'" />'."\n";
132
        $res .= str_repeat(' ', 20).'</p>'."\n";
159
        $res .= str_repeat(' ', 20).'</p>'."\n";
133
        $res .= str_repeat(' ', 16).'</fieldset>'."\n";
160
        $res .= str_repeat(' ', 16).'</fieldset>'."\n";
134
        $res .= str_repeat(' ', 16).'</form>';
161
        $res .= str_repeat(' ', 16).'</form>';
135
    }
162
    }
136
    return $res ;
163
    return $res ;
137
}
164
}
138
 
165
 
139
// +------------------------------------------------------------------------------------------------------+
166
// +------------------------------------------------------------------------------------------------------+
140
// |                                            PIED du PROGRAMME                                         |
167
// |                                            PIED du PROGRAMME                                         |
141
// +------------------------------------------------------------------------------------------------------+
168
// +------------------------------------------------------------------------------------------------------+
142
 
169
 
143
 
170
 
144
 
171
 
145
/* +--Fin du code ----------------------------------------------------------------------------------------+
172
/* +--Fin du code ----------------------------------------------------------------------------------------+
146
*
173
*
147
* $Log: not supported by cvs2svn $
174
* $Log: not supported by cvs2svn $
-
 
175
* Revision 1.5  2004/09/23 14:31:12  jpm
-
 
176
* Correction bogue sur l'identification de l'annuaire_tela.
-
 
177
*
148
* Revision 1.4  2004/09/23 10:53:44  jpm
178
* Revision 1.4  2004/09/23 10:53:44  jpm
149
* Suppression de l'attribut size. Gestion via les css.
179
* Suppression de l'attribut size. Gestion via les css.
150
*
180
*
151
* Revision 1.3  2004/06/28 10:18:48  alex
181
* Revision 1.3  2004/06/28 10:18:48  alex
152
* suppression de balises <p>
182
* suppression de balises <p>
153
*
183
*
154
* Revision 1.2  2004/06/21 07:37:30  alex
184
* Revision 1.2  2004/06/21 07:37:30  alex
155
* Modification d'un label
185
* Modification d'un label
156
*
186
*
157
* Revision 1.1  2004/06/15 15:01:41  jpm
187
* Revision 1.1  2004/06/15 15:01:41  jpm
158
* Changement de nom et d'arborescence de Genesia en Papyrus.
188
* Changement de nom et d'arborescence de Genesia en Papyrus.
159
*
189
*
160
* Revision 1.5  2004/05/05 06:44:15  jpm
190
* Revision 1.5  2004/05/05 06:44:15  jpm
161
* Complément des commentaires indiquant les paquetages nécessaire à l'applette.
191
* Complément des commentaires indiquant les paquetages nécessaire à l'applette.
162
*
192
*
163
* Revision 1.4  2004/05/03 11:18:55  jpm
193
* Revision 1.4  2004/05/03 11:18:55  jpm
164
* Intégration de la variable globale de Génésia dans les arguments de la fonction de l'applette.
194
* Intégration de la variable globale de Génésia dans les arguments de la fonction de l'applette.
165
*
195
*
166
* Revision 1.3  2004/05/01 17:21:16  jpm
196
* Revision 1.3  2004/05/01 17:21:16  jpm
167
* Ajout d'un fieldset et d'une légende au formulaire.
197
* Ajout d'un fieldset et d'une légende au formulaire.
168
*
198
*
169
* Revision 1.2  2004/05/01 16:13:07  jpm
199
* Revision 1.2  2004/05/01 16:13:07  jpm
170
* Ajout du nom de la balise de l'applette dans le code de l'applette.
200
* Ajout du nom de la balise de l'applette dans le code de l'applette.
171
*
201
*
172
* Revision 1.1  2004/05/01 11:42:01  jpm
202
* Revision 1.1  2004/05/01 11:42:01  jpm
173
* Ajout de l'applette identification.
203
* Ajout de l'applette identification.
174
*
204
*
175
*
205
*
176
* +-- Fin du code ----------------------------------------------------------------------------------------+
206
* +-- Fin du code ----------------------------------------------------------------------------------------+
177
*/
207
*/
178
?>
208
?>