Rev 51 | Rev 303 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php/*vim: set expandtab tabstop=4 shiftwidth=4: */// +------------------------------------------------------------------------------------------------------+// | PHP version 4.1 |// +------------------------------------------------------------------------------------------------------+// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |// +------------------------------------------------------------------------------------------------------+// | This library is free software; you can redistribute it and/or |// | modify it under the terms of the GNU Lesser General Public |// | License as published by the Free Software Foundation; either |// | version 2.1 of the License, or (at your option) any later version. |// | |// | This library is distributed in the hope that it will be useful, |// | but WITHOUT ANY WARRANTY; without even the implied warranty of |// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |// | Lesser General Public License for more details. |// | |// | You should have received a copy of the GNU Lesser General Public |// | License along with this library; if not, write to the Free Software |// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |// +------------------------------------------------------------------------------------------------------+// CVS : $Id: identification.php,v 1.6 2004-12-13 18:07:09 alex Exp $/*** Applette : identification** Génère un formulaire les champs nécessaires pour s'identifier.* Nécessite :* - Variable globale de Génésia.* - Pear Auth* - Pear Net_URL** A faire : remplacer le formulaire par un QuickForm**@package Applette*@subpackage Identification//Auteur original :*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>//Autres auteurs :*@author Aucun*@copyright Tela-Botanica 2000-2004*@version $Revision: 1.6 $ $Date: 2004-12-13 18:07:09 $// +------------------------------------------------------------------------------------------------------+*/// +------------------------------------------------------------------------------------------------------+// | ENTÊTE du PROGRAMME |// +------------------------------------------------------------------------------------------------------+$_GEN_commun['info_applette_nom_fonction'] = 'afficherFormIdentification';$_GEN_commun['info_applette_balise'] = 'IDENTIFICATION';// +------------------------------------------------------------------------------------------------------+// | CORPS du PROGRAMME |// +------------------------------------------------------------------------------------------------------+// Si le site utilise une authentification.if ($_GEN_commun['info_auth']->gsa_ce_type_auth == 1) {// Si un formulaire nous renvoie en POST une variable "deconnexion", nous délogons l'utilisateur.if (isset($_POST['deconnexion'])) {$_GEN_commun['pear_auth']->logout();// Le test suivant vérifie si une authentification SPIP est en cour, vois pap_initialise_auth.inc.phpif (isset ($chemin_spip) && isset ($coauth) && $coauth == $auth_courante['gsab_id_auth_bdd']) {// On place un cookie avec une duré dépasséesetcookie("spip_session", $id_session, time() - 3600*24, "/$chemin_cookie_spip/") ;setcookie("spip_admin", "@".$login, time() -3600*24, "/$chemin_cookie_spip/") ;$dirname = $GLOBALS['flag_ecrire'] ? "data/" : "ecrire/data/";$dirname = $chemin_spip."/".$dirname ;// ne pas se zapper soi-memeif ($s = $GLOBALS['spip_session'])$fichier_session = fichier_session($s, lire_meta('alea_ephemere'));$fichier_session = $chemin_spip."/ecrire/".$fichier_session ;$dir = opendir($dirname);$t = time();while(($item = readdir($dir)) != '') {$chemin = "$dirname$item";if (ereg("^session_([0-9]+_)?([a-z0-9]+)\.php3$", $item, $regs)) {// Si c'est une vieille session, on jetteif (($t - filemtime($chemin)) > 48 * 3600) unlink($chemin);// sinon voir si c'est une session du meme auteurelse if ($regs[1] == $id_auteur.'_') {$zap_num ++;if ($zap) unlink($chemin);}}}}$_GEN_commun['pear_auth']->start();}// Si un formulaire nous renvoie en POST une variable "connexion", nous logons l'utilisateur.if (isset($_POST['connexion'])) {$_GEN_commun['pear_auth']->login();$_SESSION['username'] = $username;}}// +------------------------------------------------------------------------------------------------------+// | LISTE de FONCTIONS |// +------------------------------------------------------------------------------------------------------+/** Fonction afficherFormIdentification() - Retourne une formulaire pour s'identifier.** Retourne un formulaire d'identificatin ou de déconnexion suivant que l'utilisateur est* identifié ou pas.** @param array tableau d'éventuel arguments présent dans la balise transmis à la fonction.* @param array tableau global de Papyrus.* @return string formulaire de connexion ou de déconnexion.*/function afficherFormIdentification($tab_arguments, $_GEN_commun){// Initialisation de variable.$objet_pear_auth = $_GEN_commun['pear_auth'];$objet_pear_db = $_GEN_commun['pear_db'];$url = $_GEN_commun['url']->getURL();// Récupération des valeurs pour le login et le mot de passe$mot_de_passe = (! isset($_POST['password'])) ? '' : $_POST['password'];$login = (! isset($_POST['username'])) ? '' : $_POST['username'];// ATTENTION : Partie à supprimer une fois les mise à jour effectué dans l'annuaire de Tela Botanica// Devrait être déplacer dans l'appli inscription de Tela.if (isset($_GEN_commun['info_auth_bdd']->gsab_nom_table) && $_GEN_commun['info_auth_bdd']->gsab_nom_table == 'annuaire_tela') {verification_mot_de_passe($objet_pear_db, $mot_de_passe, $login);if (isset($_POST['connexion'])) {$_GEN_commun['pear_auth']->login();}}if (! $objet_pear_auth->getAuth()) {// L'utilisateur n'est pas identifié:$res = str_repeat(' ', 16).'<form id="form_connexion" action="'.$url.'" method="post">'."\n";$res .= str_repeat(' ', 16).'<fieldset>'."\n";$res .= str_repeat(' ', 20).'<legend>'.'Identification'.'</legend>'."\n";$res .= str_repeat(' ', 20).''."\n";$res .= str_repeat(' ', 24).'<label for="username">'.'Courriel :'.'</label>'."\n";$res .= str_repeat(' ', 24).'<input type="text" id="username" name="username" maxlength="80" tabindex="1" value="'.'courriel'.'" />'."\n";$res .= str_repeat(' ', 20).''."\n";$res .= str_repeat(' ', 20).''."\n";$res .= str_repeat(' ', 24).'<label for="password">'.'Mot de passe :'.'</label>'."\n";$res .= str_repeat(' ', 24).'<input type="password" id="password" name="password" maxlength="80" tabindex="2" value="'.'mot de passe'.'" />'."\n";$res .= str_repeat(' ', 20).''."\n";$res .= str_repeat(' ', 20).''."\n";$res .= str_repeat(' ', 24).'<input type="submit" id="connexion" name="connexion" tabindex="3" value="'.'ok'.'" />'."\n";$res .= str_repeat(' ', 20).''."\n";$res .= str_repeat(' ', 16).'</fieldset>'."\n";$res .= str_repeat(' ', 16).'</form>';} else {// L'utilisateur est identifié. Nous affichons ses informations.// Amélioré la récupération des informations sur l'utilisateur.//$nom_utilisateur = $objet_pear_auth->getAuthData($champ_nom);$res = str_repeat(' ', 16).'<form id="form_deconnexion" action="'.$url.'&logout=1" method="post">'."\n";$res .= str_repeat(' ', 16).'<fieldset>'."\n";$res .= str_repeat(' ', 20).'<legend>'.'Identification'.'</legend>'."\n";// Il faudrait mettre dans la base de données le prénom et le nom ou chercher comment définir ces champs en fonction// de l'annuaire utilisé, si on veut les afficher après le message de bienvenue.$res .= str_repeat(' ', 20).'<p>'.'Bienvenue!'.'</p>'."\n";$res .= str_repeat(' ', 20).'<p>'."\n";$res .= str_repeat(' ', 24).'<input type="submit" id="deconnexion" name="deconnexion" tabindex="1" value="'.'déconnexion'.'" />'."\n";$res .= str_repeat(' ', 20).'</p>'."\n";$res .= str_repeat(' ', 16).'</fieldset>'."\n";$res .= str_repeat(' ', 16).'</form>';}return $res ;}// +------------------------------------------------------------------------------------------------------+// | PIED du PROGRAMME |// +------------------------------------------------------------------------------------------------------+/* +--Fin du code ----------------------------------------------------------------------------------------+** $Log: not supported by cvs2svn $* Revision 1.5 2004/09/23 14:31:12 jpm* Correction bogue sur l'identification de l'annuaire_tela.** Revision 1.4 2004/09/23 10:53:44 jpm* Suppression de l'attribut size. Gestion via les css.** Revision 1.3 2004/06/28 10:18:48 alex* suppression de balises <p>** Revision 1.2 2004/06/21 07:37:30 alex* Modification d'un label** Revision 1.1 2004/06/15 15:01:41 jpm* Changement de nom et d'arborescence de Genesia en Papyrus.** Revision 1.5 2004/05/05 06:44:15 jpm* Complément des commentaires indiquant les paquetages nécessaire à l'applette.** Revision 1.4 2004/05/03 11:18:55 jpm* Intégration de la variable globale de Génésia dans les arguments de la fonction de l'applette.** Revision 1.3 2004/05/01 17:21:16 jpm* Ajout d'un fieldset et d'une légende au formulaire.** Revision 1.2 2004/05/01 16:13:07 jpm* Ajout du nom de la balise de l'applette dans le code de l'applette.** Revision 1.1 2004/05/01 11:42:01 jpm* Ajout de l'applette identification.*** +-- Fin du code ----------------------------------------------------------------------------------------+*/?>