Rev 309 | Rev 369 | 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.12 2005-03-25 14:40:51 jpm 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.12 $ $Date: 2005-03-25 14:40:51 $// +------------------------------------------------------------------------------------------------------+*/// +------------------------------------------------------------------------------------------------------+// | ENTÊTE du PROGRAMME |// +------------------------------------------------------------------------------------------------------+$_GEN_commun['info_applette_nom_fonction'] = 'afficherFormIdentification';$_GEN_commun['info_applette_balise'] = 'IDENTIFICATION';/** Inclusion du fichier de configuration de cette applette.*/require_once GEN_CHEMIN_APPLETTE.'identification/configuration/iden_config.inc.php';// Inclusion des fichiers de traduction de l'applette.if (file_exists(IDEN_CHEMIN_LANGUE.'iden_langue_'.$_GEN_commun['i18n'].'.inc.php')) {/** Inclusion du fichier de traduction suite à la transaction avec le navigateur.*/require_once IDEN_CHEMIN_LANGUE.'iden_langue_'.$_GEN_commun['i18n'].'.inc.php';} else {/** Inclusion du fichier de traduction par défaut.*/require_once IDEN_CHEMIN_LANGUE.'iden_langue_'.IDEN_I18N_DEFAUT.'.inc.php';}// +------------------------------------------------------------------------------------------------------+// | 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($_REQUEST['deconnexion']) || isset($_REQUEST['logout'])) {$_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($_REQUEST['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.$retour = '';$objet_pear_auth =& $GLOBALS['_GEN_commun']['pear_auth'];$objet_pear_db =& $GLOBALS['_GEN_commun']['pear_db'];$url = $GLOBALS['_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($GLOBALS['_GEN_commun']['info_auth_bdd']->gsab_nom_table) && $GLOBALS['_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'])) {$objet_pear_auth->login();}}if (! $objet_pear_auth->getAuth()) {// L'utilisateur n'est pas identifié:// Si l'url de la page d'inscription est stockée dans les paramêtres, nous l'affichonsif (isset($GLOBALS['_GEN_commun']['info_auth_bdd']->url_inscription)) {$retour .= '<div><a id="lien_inscription" href="'.$GLOBALS['_GEN_commun']['info_auth_bdd']->url_inscription.'">'.IDEN_LG_INSCRIPTION_URL.'</a></div>';}$retour .= str_repeat(' ', 16).'<form id="form_connexion" class="form_identification" action="'.$url.'" method="post">'."\n";$retour .= str_repeat(' ', 16).'<fieldset>'."\n";$retour .= str_repeat(' ', 20).'<legend>'.'Identification'.'</legend>'."\n";$retour .= str_repeat(' ', 20).''."\n";$retour .= str_repeat(' ', 24).'<label for="username">'.'Courriel :'.'</label>'."\n";$retour .= str_repeat(' ', 24).'<input type="text" size="12" id="username" name="username" maxlength="80" tabindex="1" value="'.'courriel'.'" />'."\n";$retour .= str_repeat(' ', 20).''."\n";$retour .= str_repeat(' ', 20).''."\n";$retour .= str_repeat(' ', 24).'<label for="password">'.'Mot de passe :'.'</label>'."\n";$retour .= str_repeat(' ', 24).'<input type="password" size="12" id="password" name="password" maxlength="80" tabindex="2" value="'.'mot de passe'.'" />'."\n";$retour .= str_repeat(' ', 20).''."\n";$retour .= str_repeat(' ', 20).''."\n";$retour .= str_repeat(' ', 24).'<input type="submit" id="connexion" name="connexion" tabindex="3" value="'.'ok'.'" />'."\n";$retour .= str_repeat(' ', 20).''."\n";$retour .= str_repeat(' ', 16).'</fieldset>'."\n";$retour .= str_repeat(' ', 16).'</form>';} else {// L'utilisateur est identifié. Nous affichons ses informations.// Affichage du prénom et nom d'une personne ou du nom de la structure en fonction des paramêtres// de l'annuaire utilisé$retour = str_repeat(' ', 16).'<p id="identification_info"><span id="identification_message">'.IDEN_LG_MESSAGE.'</span> ';// Si les intitulés des champs nom et prénoms d'une personne ou le nom d'une structure sont indiqués nous les affichonsif (isset($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_prenom) && isset($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_nom)) {$retour .= '<span id="identification_prenom">'.$objet_pear_auth->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_prenom).'</span> '.'<span id="identification_nom">'.$objet_pear_auth->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_nom).'</span>';} elseif (isset($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_structure_nom)) {$retour .= '<span id="identification_structure">'.$objet_pear_auth->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_structure_nom).'</span>';}$retour .= '</p>'."\n";// Affichage du bouton de déconnexion$retour .= str_repeat(' ', 16).'<p id="deconnexion">'."\n";$retour .= str_repeat(' ', 20).'<a href="'.$url.'&logout=1">'.'Déconnexion'.'</a>'."\n";$retour .= str_repeat(' ', 16).'</p>'."\n";}return $retour;}// +------------------------------------------------------------------------------------------------------+// | PIED du PROGRAMME |// +------------------------------------------------------------------------------------------------------+/* +--Fin du code ----------------------------------------------------------------------------------------+** $Log: not supported by cvs2svn $* Revision 1.11 2005/03/17 15:52:17 jpm* Suppression d'un / causant un bogue.** Revision 1.10 2005/03/15 14:47:14 jpm* Utilisation d'un lien à la place d'un formulaire pour la déconnexion.** Revision 1.9 2005/03/15 14:17:46 jpm* Ajout d'un fichier de config et de traduction.* Début gestion des constantes de langue.** Revision 1.8 2005/03/10 12:50:44 alex* remplacement de & par &** Revision 1.7 2005/01/07 12:43:03 alex* réauction de la taille des champs texte à 12** Revision 1.6 2004/12/13 18:07:09 alex* désauthentification spip presque parfaite** 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 ----------------------------------------------------------------------------------------+*/?>