4 |
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 |
// | This library is free software; you can redistribute it and/or |
|
|
|
9 |
// | modify it under the terms of the GNU Lesser General Public |
|
|
|
10 |
// | License as published by the Free Software Foundation; either |
|
|
|
11 |
// | version 2.1 of the License, or (at your option) any later version. |
|
|
|
12 |
// | |
|
|
|
13 |
// | This library is distributed in the hope that it will be useful, |
|
|
|
14 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
15 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
16 |
// | Lesser General Public License for more details. |
|
|
|
17 |
// | |
|
|
|
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 |
|
|
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
303 |
alex |
22 |
// CVS : $Id: identification.php,v 1.8 2005-03-10 12:50:44 alex Exp $
|
4 |
jpm |
23 |
/**
|
|
|
24 |
* Applette : identification
|
|
|
25 |
*
|
|
|
26 |
* Génère un formulaire les champs nécessaires pour s'identifier.
|
|
|
27 |
* Nécessite :
|
|
|
28 |
* - Variable globale de Génésia.
|
|
|
29 |
* - Pear Auth
|
|
|
30 |
* - Pear Net_URL
|
17 |
alex |
31 |
*
|
|
|
32 |
* A faire : remplacer le formulaire par un QuickForm
|
4 |
jpm |
33 |
*
|
|
|
34 |
*@package Applette
|
|
|
35 |
*@subpackage Identification
|
|
|
36 |
//Auteur original :
|
|
|
37 |
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
|
|
38 |
//Autres auteurs :
|
|
|
39 |
*@author Aucun
|
|
|
40 |
*@copyright Tela-Botanica 2000-2004
|
303 |
alex |
41 |
*@version $Revision: 1.8 $ $Date: 2005-03-10 12:50:44 $
|
4 |
jpm |
42 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
43 |
*/
|
|
|
44 |
|
|
|
45 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
46 |
// | ENTÊTE du PROGRAMME |
|
|
|
47 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
48 |
$_GEN_commun['info_applette_nom_fonction'] = 'afficherFormIdentification';
|
|
|
49 |
$_GEN_commun['info_applette_balise'] = 'IDENTIFICATION';
|
|
|
50 |
|
|
|
51 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
52 |
// | CORPS du PROGRAMME |
|
|
|
53 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
54 |
|
|
|
55 |
// Si le site utilise une authentification.
|
|
|
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.
|
|
|
58 |
if (isset($_POST['deconnexion'])) {
|
228 |
alex |
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 |
}
|
4 |
jpm |
87 |
$_GEN_commun['pear_auth']->start();
|
|
|
88 |
}
|
|
|
89 |
// Si un formulaire nous renvoie en POST une variable "connexion", nous logons l'utilisateur.
|
|
|
90 |
if (isset($_POST['connexion'])) {
|
|
|
91 |
$_GEN_commun['pear_auth']->login();
|
|
|
92 |
$_SESSION['username'] = $username;
|
|
|
93 |
}
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
97 |
// | LISTE de FONCTIONS |
|
|
|
98 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
99 |
|
|
|
100 |
/** Fonction afficherFormIdentification() - Retourne une formulaire pour s'identifier.
|
|
|
101 |
*
|
|
|
102 |
* Retourne un formulaire d'identificatin ou de déconnexion suivant que l'utilisateur est
|
|
|
103 |
* identifié ou pas.
|
|
|
104 |
*
|
|
|
105 |
* @param array tableau d'éventuel arguments présent dans la balise transmis à la fonction.
|
|
|
106 |
* @param array tableau global de Papyrus.
|
|
|
107 |
* @return string formulaire de connexion ou de déconnexion.
|
|
|
108 |
*/
|
|
|
109 |
function afficherFormIdentification($tab_arguments, $_GEN_commun)
|
|
|
110 |
{
|
|
|
111 |
// Initialisation de variable.
|
51 |
jpm |
112 |
$objet_pear_auth = $_GEN_commun['pear_auth'];
|
|
|
113 |
$objet_pear_db = $_GEN_commun['pear_db'];
|
228 |
alex |
114 |
$url = $_GEN_commun['url']->getURL();
|
4 |
jpm |
115 |
// Récupération des valeurs pour le login et le mot de passe
|
|
|
116 |
$mot_de_passe = (! isset($_POST['password'])) ? '' : $_POST['password'];
|
|
|
117 |
$login = (! isset($_POST['username'])) ? '' : $_POST['username'];
|
|
|
118 |
|
|
|
119 |
// ATTENTION : Partie à supprimer une fois les mise à jour effectué dans l'annuaire de Tela Botanica
|
|
|
120 |
// Devrait être déplacer dans l'appli inscription de Tela.
|
51 |
jpm |
121 |
if (isset($_GEN_commun['info_auth_bdd']->gsab_nom_table) && $_GEN_commun['info_auth_bdd']->gsab_nom_table == 'annuaire_tela') {
|
|
|
122 |
verification_mot_de_passe($objet_pear_db, $mot_de_passe, $login);
|
|
|
123 |
if (isset($_POST['connexion'])) {
|
|
|
124 |
$_GEN_commun['pear_auth']->login();
|
|
|
125 |
}
|
4 |
jpm |
126 |
}
|
|
|
127 |
|
|
|
128 |
if (! $objet_pear_auth->getAuth()) {
|
|
|
129 |
// L'utilisateur n'est pas identifié:
|
|
|
130 |
$res = str_repeat(' ', 16).'<form id="form_connexion" action="'.$url.'" method="post">'."\n";
|
|
|
131 |
$res .= str_repeat(' ', 16).'<fieldset>'."\n";
|
|
|
132 |
$res .= str_repeat(' ', 20).'<legend>'.'Identification'.'</legend>'."\n";
|
20 |
alex |
133 |
$res .= str_repeat(' ', 20).''."\n";
|
4 |
jpm |
134 |
$res .= str_repeat(' ', 24).'<label for="username">'.'Courriel :'.'</label>'."\n";
|
246 |
alex |
135 |
$res .= str_repeat(' ', 24).'<input type="text" size="12" id="username" name="username" maxlength="80" tabindex="1" value="'.'courriel'.'" />'."\n";
|
20 |
alex |
136 |
$res .= str_repeat(' ', 20).''."\n";
|
|
|
137 |
$res .= str_repeat(' ', 20).''."\n";
|
4 |
jpm |
138 |
$res .= str_repeat(' ', 24).'<label for="password">'.'Mot de passe :'.'</label>'."\n";
|
246 |
alex |
139 |
$res .= str_repeat(' ', 24).'<input type="password" size="12" id="password" name="password" maxlength="80" tabindex="2" value="'.'mot de passe'.'" />'."\n";
|
20 |
alex |
140 |
$res .= str_repeat(' ', 20).''."\n";
|
|
|
141 |
$res .= str_repeat(' ', 20).''."\n";
|
17 |
alex |
142 |
$res .= str_repeat(' ', 24).'<input type="submit" id="connexion" name="connexion" tabindex="3" value="'.'ok'.'" />'."\n";
|
20 |
alex |
143 |
$res .= str_repeat(' ', 20).''."\n";
|
4 |
jpm |
144 |
$res .= str_repeat(' ', 16).'</fieldset>'."\n";
|
|
|
145 |
$res .= str_repeat(' ', 16).'</form>';
|
|
|
146 |
} else {
|
|
|
147 |
// L'utilisateur est identifié. Nous affichons ses informations.
|
|
|
148 |
// Amélioré la récupération des informations sur l'utilisateur.
|
|
|
149 |
//$nom_utilisateur = $objet_pear_auth->getAuthData($champ_nom);
|
|
|
150 |
|
303 |
alex |
151 |
$res = str_repeat(' ', 16).'<form id="form_deconnexion" action="'.$url.'&logout=1" method="post">'."\n";
|
4 |
jpm |
152 |
$res .= str_repeat(' ', 16).'<fieldset>'."\n";
|
|
|
153 |
$res .= str_repeat(' ', 20).'<legend>'.'Identification'.'</legend>'."\n";
|
|
|
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
|
|
|
155 |
// de l'annuaire utilisé, si on veut les afficher après le message de bienvenue.
|
|
|
156 |
$res .= str_repeat(' ', 20).'<p>'.'Bienvenue!'.'</p>'."\n";
|
|
|
157 |
$res .= str_repeat(' ', 20).'<p>'."\n";
|
17 |
alex |
158 |
$res .= str_repeat(' ', 24).'<input type="submit" id="deconnexion" name="deconnexion" tabindex="1" value="'.'déconnexion'.'" />'."\n";
|
4 |
jpm |
159 |
$res .= str_repeat(' ', 20).'</p>'."\n";
|
|
|
160 |
$res .= str_repeat(' ', 16).'</fieldset>'."\n";
|
|
|
161 |
$res .= str_repeat(' ', 16).'</form>';
|
|
|
162 |
}
|
|
|
163 |
return $res ;
|
|
|
164 |
}
|
|
|
165 |
|
|
|
166 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
167 |
// | PIED du PROGRAMME |
|
|
|
168 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
|
172 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
|
|
173 |
*
|
|
|
174 |
* $Log: not supported by cvs2svn $
|
303 |
alex |
175 |
* Revision 1.7 2005/01/07 12:43:03 alex
|
|
|
176 |
* réauction de la taille des champs texte à 12
|
|
|
177 |
*
|
246 |
alex |
178 |
* Revision 1.6 2004/12/13 18:07:09 alex
|
|
|
179 |
* désauthentification spip presque parfaite
|
|
|
180 |
*
|
228 |
alex |
181 |
* Revision 1.5 2004/09/23 14:31:12 jpm
|
|
|
182 |
* Correction bogue sur l'identification de l'annuaire_tela.
|
|
|
183 |
*
|
51 |
jpm |
184 |
* Revision 1.4 2004/09/23 10:53:44 jpm
|
|
|
185 |
* Suppression de l'attribut size. Gestion via les css.
|
|
|
186 |
*
|
49 |
jpm |
187 |
* Revision 1.3 2004/06/28 10:18:48 alex
|
|
|
188 |
* suppression de balises <p>
|
|
|
189 |
*
|
20 |
alex |
190 |
* Revision 1.2 2004/06/21 07:37:30 alex
|
|
|
191 |
* Modification d'un label
|
|
|
192 |
*
|
17 |
alex |
193 |
* Revision 1.1 2004/06/15 15:01:41 jpm
|
|
|
194 |
* Changement de nom et d'arborescence de Genesia en Papyrus.
|
|
|
195 |
*
|
4 |
jpm |
196 |
* Revision 1.5 2004/05/05 06:44:15 jpm
|
|
|
197 |
* Complément des commentaires indiquant les paquetages nécessaire à l'applette.
|
|
|
198 |
*
|
|
|
199 |
* Revision 1.4 2004/05/03 11:18:55 jpm
|
|
|
200 |
* Intégration de la variable globale de Génésia dans les arguments de la fonction de l'applette.
|
|
|
201 |
*
|
|
|
202 |
* Revision 1.3 2004/05/01 17:21:16 jpm
|
|
|
203 |
* Ajout d'un fieldset et d'une légende au formulaire.
|
|
|
204 |
*
|
|
|
205 |
* Revision 1.2 2004/05/01 16:13:07 jpm
|
|
|
206 |
* Ajout du nom de la balise de l'applette dans le code de l'applette.
|
|
|
207 |
*
|
|
|
208 |
* Revision 1.1 2004/05/01 11:42:01 jpm
|
|
|
209 |
* Ajout de l'applette identification.
|
|
|
210 |
*
|
|
|
211 |
*
|
|
|
212 |
* +-- Fin du code ----------------------------------------------------------------------------------------+
|
|
|
213 |
*/
|
|
|
214 |
?>
|