Subversion Repositories Applications.papyrus

Rev

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

Rev 112 Rev 207
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) 2003 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// | Copyright (C) 2003 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
7
// +------------------------------------------------------------------------------------------------------+
8
// |                                                                                                      |
8
// |                                                                                                      |
9
// | This library is free software; you can redistribute it and/or                                        |
9
// | This library is free software; you can redistribute it and/or                                        |
10
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | modify it under the terms of the GNU Lesser General Public                                           |
11
// | License as published by the Free Software Foundation; either                                         |
11
// | License as published by the Free Software Foundation; either                                         |
12
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// | version 2.1 of the License, or (at your option) any later version.                                   |
13
// |                                                                                                      |
13
// |                                                                                                      |
14
// | This library is distributed in the hope that it will be useful,                                      |
14
// | This library is distributed in the hope that it will be useful,                                      |
15
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
16
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
17
// | Lesser General Public License for more details.                                                      |
17
// | Lesser General Public License for more details.                                                      |
18
// |                                                                                                      |
18
// |                                                                                                      |
19
// | You should have received a copy of the GNU Lesser General Public                                     |
19
// | You should have received a copy of the GNU Lesser General Public                                     |
20
// | License along with this library; if not, write to the Free Software                                  |
20
// | License along with this library; if not, write to the Free Software                                  |
21
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
22
// |                                                                                                      |
22
// |                                                                                                      |
23
// +------------------------------------------------------------------------------------------------------+
23
// +------------------------------------------------------------------------------------------------------+
24
// CVS : $Id: pap_initialise_auth.inc.php,v 1.4 2004-10-25 16:28:47 jpm Exp $
24
// CVS : $Id: pap_initialise_auth.inc.php,v 1.5 2004-12-06 12:12:28 jpm Exp $
25
/**
25
/**
26
* Initialisation de l'authentification.
26
* Initialisation de l'authentification.
27
*
27
*
28
* Suite à la recherche des informations depuis la base de données nous initialisons
28
* Suite à la recherche des informations depuis la base de données nous initialisons
29
* l'authentification des utilisateurs si le site l'utilise.
29
* l'authentification des utilisateurs si le site l'utilise.
30
* La page contient le code initialisant l'objet PEAR créé par Net_URL contenant l'url
30
* La page contient le code initialisant l'objet PEAR créé par Net_URL contenant l'url
31
* courante demandée par l'utilisateur.
31
* courante demandée par l'utilisateur.
32
* Nous initialisons aussi l'identification de l'utilisateur et le démarage de la session.
32
* Nous initialisons aussi l'identification de l'utilisateur et le démarage de la session.
33
*
33
*
34
*@package Papyrus
34
*@package Papyrus
35
//Auteur original :
35
//Auteur original :
36
*@author            Alexandre GRANIER <alex@tela-botanica.org>
36
*@author            Alexandre GRANIER <alex@tela-botanica.org>
37
//Autres auteurs :
37
//Autres auteurs :
38
*@author            Jean-Pascal MILCENT <jpm@tela-botanica.org>
38
*@author            Jean-Pascal MILCENT <jpm@tela-botanica.org>
39
*@copyright         Tela-Botanica 2000-2004
39
*@copyright         Tela-Botanica 2000-2004
40
*@version           $Revision: 1.4 $ $Date: 2004-10-25 16:28:47 $
40
*@version           $Revision: 1.5 $ $Date: 2004-12-06 12:12:28 $
41
// +------------------------------------------------------------------------------------------------------+
41
// +------------------------------------------------------------------------------------------------------+
42
*/
42
*/
43
 
43
 
44
// +------------------------------------------------------------------------------------------------------+
44
// +------------------------------------------------------------------------------------------------------+
45
// |                                            ENTÊTE du PROGRAMME                                       |
45
// |                                            ENTÊTE du PROGRAMME                                       |
46
// +------------------------------------------------------------------------------------------------------+
46
// +------------------------------------------------------------------------------------------------------+
47
 
47
 
48
/** <br> Inclusion de l'authentification de PEAR.*/
48
/** <br> Inclusion de l'authentification de PEAR.*/
49
include_once 'Auth/Auth.php';
49
include_once 'Auth/Auth.php';
50
 
50
 
51
/** Inclusion de la bibliothèque de fonctions d'identification.
51
/** Inclusion de la bibliothèque de fonctions d'identification.
52
* Contient entre autre la fonction founissant le formulaire d'identification pour Auth de Pear.
52
* Contient entre autre la fonction founissant le formulaire d'identification pour Auth de Pear.
53
* Cette inclusion n'a lieu que si le site utilise l'identification.
53
* Cette inclusion n'a lieu que si le site utilise l'identification.
54
*/
54
*/
55
include_once GEN_CHEMIN_PAP.'bibliotheque/fonctions/pap_identification.fonct.php' ;
55
include_once GEN_CHEMIN_PAP.'bibliotheque/fonctions/pap_identification.fonct.php' ;
56
 
56
 
57
// +------------------------------------------------------------------------------------------------------+
57
// +------------------------------------------------------------------------------------------------------+
58
// |                                            CORPS du PROGRAMME                                        |
58
// |                                            CORPS du PROGRAMME                                        |
59
// +------------------------------------------------------------------------------------------------------+
59
// +------------------------------------------------------------------------------------------------------+
60
 
60
 
61
// +------------------------------------------------------------------------------------------------------+
61
// +------------------------------------------------------------------------------------------------------+
62
// Gestion de l'identification des utilisateurs et des sessions
62
// Gestion de l'identification des utilisateurs et des sessions
-
 
63
 
-
 
64
// +------------------------------------------------------------------------------------------------------+
-
 
65
// Récupération des informations d'identification pour le site courant
-
 
66
 
-
 
67
// Récupération des informations sur le site
-
 
68
$requete_auth = 'SELECT gen_site_auth.* '.
-
 
69
                'FROM gen_site_auth, gen_site '.
-
 
70
                'WHERE gs_ce_auth <> 0 '
-
 
71
                'AND gs_ce_auth = gsa_id_auth';
-
 
72
 
-
 
73
$resultat_auth = $db->query($requete_auth);
-
 
74
(DB::isError($resultat_auth))
-
 
75
    ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_auth->getMessage(), $requete_auth))
-
 
76
    : '';
-
 
77
 
-
 
78
while ($ligne_auth = $resultat_auth->fetchRow(DB_FETCHMODE_OBJECT)) {
-
 
79
    // Ajout des valeurs communes aux différents type d'auth
-
 
80
    $GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth]['gsa_nom'] = $ligne_auth->gsa_nom;
-
 
81
    $GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth]['gsa_abreviation'] = $ligne_auth->gsa_abreviation;
-
 
82
    
-
 
83
    if ($ligne_auth->gsa_id_auth == $_GEN_commun['info_site']->gs_ce_auth) {
-
 
84
        $_GEN_commun['info_auth'] = $ligne_auth;
-
 
85
    }
-
 
86
    
-
 
87
    if ($ligne_auth->gsa_ce_auth_bdd != 0) {
-
 
88
        //Identification via une base de donnée :
-
 
89
        $requete_auth_bdd = 'SELECT * '.
-
 
90
                            'FROM gen_site_auth_bdd '.
-
 
91
                            'WHERE gsab_id_auth_bdd = '.$ligne_auth->gsa_ce_auth_bdd;
-
 
92
        
-
 
93
        $resultat_auth_bdd = $db->query($requete_auth_bdd);
-
 
94
        (DB::isError($resultat_auth_bdd))
-
 
95
            ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_auth_bdd->getMessage(), $requete_auth_bdd))
-
 
96
            : '';
-
 
97
        if ($ligne_auth->gsa_id_auth == $_GEN_commun['info_site']->gs_ce_auth) {
-
 
98
            $_GEN_commun['info_auth_bdd'] = $resultat_auth_bdd->fetchRow(DB_FETCHMODE_OBJECT);
-
 
99
        }
-
 
100
        $GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth] = $resultat_auth_bdd->fetchRow(DB_FETCHMODE_ASSOC);
-
 
101
        $resultat_auth_bdd->free();
-
 
102
    
-
 
103
    } else if ($ligne_auth->gsa_ce_auth_ldap != 0) {
-
 
104
        //Identification via LDAP :
-
 
105
        $requete_auth_ldap =    'SELECT * '.
-
 
106
                                'FROM gen_site_auth_ldap '.
-
 
107
                                'WHERE gsal_id_auth_ldap = '.$ligne_auth->gsa_ce_auth_ldap;
-
 
108
        
-
 
109
        $resultat_auth_ldap = $db->query($requete_auth_ldap);
-
 
110
        (DB::isError($resultat_auth_ldap))
-
 
111
            ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_auth_ldap->getMessage(), $requete_auth_ldap))
-
 
112
            : '';
-
 
113
        if ($ligne_auth->gsa_id_auth == $_GEN_commun['info_site']->gs_ce_auth) {
-
 
114
            $_GEN_commun['info_auth_ldap'] = $resultat_auth_ldap->fetchRow(DB_FETCHMODE_OBJECT);
-
 
115
        }
-
 
116
        $GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth] = $resultat_auth_ldap->fetchRow(DB_FETCHMODE_ASSOC);
-
 
117
        $resultat_auth_ldap->free();
-
 
118
    } else {
-
 
119
        die('ERREUR Papyrus : impossible de trouver les information authentification. <br />'.
-
 
120
            'Identifiant auth : '.$ligne_auth->gs_ce_auth.'<br />'.
-
 
121
            'Ligne n° : '. __LINE__ .'<br />'.
-
 
122
            'Fichier : '. __FILE__ );
-
 
123
    }
-
 
124
}
-
 
125
$resultat_auth->free();
63
 
126
 
64
// Nour regardons à quel type d'identification nous avons à faire:
127
// Nour regardons à quel type d'identification nous avons à faire:
65
if ($_GEN_commun['info_auth']->gsa_ce_type_auth == 1) {
128
if ($_GEN_commun['info_auth']->gsa_ce_type_auth == 1) {
66
    // Authentification via une base de données
129
    // Authentification via une base de données
67
    $param_bdd = array ('dsn' => PAP_DSN,
130
    $param_bdd = array ('dsn' => PAP_DSN,
68
                        'table' => $_GEN_commun['info_auth_bdd']->gsab_nom_table,
131
                        'table' => $_GEN_commun['info_auth_bdd']->gsab_nom_table,
69
                        'usernamecol' => $_GEN_commun['info_auth_bdd']->gsab_nom_champ_login,
132
                        'usernamecol' => $_GEN_commun['info_auth_bdd']->gsab_nom_champ_login,
70
                        'passwordcol' => $_GEN_commun['info_auth_bdd']->gsab_nom_champ_mdp,
133
                        'passwordcol' => $_GEN_commun['info_auth_bdd']->gsab_nom_champ_mdp,
71
                        'cryptType' => $_GEN_commun['info_auth_bdd']->gsab_cryptage_mdp,
134
                        'cryptType' => $_GEN_commun['info_auth_bdd']->gsab_cryptage_mdp,
72
                        'db_fields' => '*');
135
                        'db_fields' => '*');
73
    $_GEN_commun['pear_auth'] = new Auth('DB', $param_bdd, 'GEN_afficherInfoIdentification', 1);
136
    $_GEN_commun['pear_auth'] = new Auth('DB', $param_bdd, 'GEN_afficherInfoIdentification', 1);
74
} else if ($_GEN_commun['info_auth']->gsa_ce_type_auth == 2) {
137
} else if ($_GEN_commun['info_auth']->gsa_ce_type_auth == 2) {
75
    // Authentification via LDAP
138
    // Authentification via LDAP
76
    $param_ldap = array (   'host' => $_GEN_commun['info_auth_ldap']->gsal_serveur,
139
    $param_ldap = array (   'host' => $_GEN_commun['info_auth_ldap']->gsal_serveur,
77
                            'port' => $_GEN_commun['info_auth_ldap']->gsal_port,
140
                            'port' => $_GEN_commun['info_auth_ldap']->gsal_port,
78
                            'basedn' => $_GEN_commun['info_auth_ldap']->gsal_base_dn,
141
                            'basedn' => $_GEN_commun['info_auth_ldap']->gsal_base_dn,
79
                            'userattr' => $_GEN_commun['info_auth_ldap']->gsal_uid);
142
                            'userattr' => $_GEN_commun['info_auth_ldap']->gsal_uid);
80
    $_GEN_commun['pear_auth'] = new Auth('LDAP', $param_ldap, 'GEN_afficherInfoIdentification', 1);
143
    $_GEN_commun['pear_auth'] = new Auth('LDAP', $param_ldap, 'GEN_afficherInfoIdentification', 1);
81
} else {
144
} else {
82
    die('ERREUR Génésia : type identification introuvable. <br />'.
145
    die('ERREUR Génésia : type identification introuvable. <br />'.
83
        'Type identification : '.$_GEN_commun['info_auth']->gsa_ce_type_auth.'<br />'.
146
        'Type identification : '.$_GEN_commun['info_auth']->gsa_ce_type_auth.'<br />'.
84
        'Ligne n° : '. __LINE__ . '<br />'.
147
        'Ligne n° : '. __LINE__ . '<br />'.
85
        'Fichier : '. __FILE__ . '<br />');
148
        'Fichier : '. __FILE__ . '<br />');
86
}
149
}
87
 
150
 
88
$_GEN_commun['pear_auth']->setSessionname( 'gen_'.$_GEN_commun['info_auth']->gsa_abreviation);
151
$_GEN_commun['pear_auth']->setSessionname( 'gen_'.$_GEN_commun['info_auth']->gsa_abreviation);
89
 
152
 
90
$_GEN_commun['pear_auth']->setExpire(3600 * 24 * 30 * 6);// 6 mois
153
$_GEN_commun['pear_auth']->setExpire(3600 * 24 * 30 * 6);// 6 mois
91
 
154
 
92
$_GEN_commun['pear_auth']->start();
155
$_GEN_commun['pear_auth']->start();
93
 
156
 
94
/* +--Fin du code ---------------------------------------------------------------------------------------+
157
/* +--Fin du code ---------------------------------------------------------------------------------------+
95
* $Log: not supported by cvs2svn $
158
* $Log: not supported by cvs2svn $
-
 
159
* Revision 1.4  2004/10/25 16:28:47  jpm
-
 
160
* Ajout de nouvelles balises Papyrus, ajout vérification mise à jour de Papyrus, meilleure gestion des sessions...
-
 
161
*
96
* Revision 1.3  2004/10/15 18:29:19  jpm
162
* Revision 1.3  2004/10/15 18:29:19  jpm
97
* Modif pour gérer l'appli installateur de Papyrus.
163
* Modif pour gérer l'appli installateur de Papyrus.
98
*
164
*
99
* Revision 1.2  2004/06/30 07:23:36  jpm
165
* Revision 1.2  2004/06/30 07:23:36  jpm
100
* Ajout d'un commentaire.
166
* Ajout d'un commentaire.
101
*
167
*
102
* Revision 1.1  2004/06/16 08:12:01  jpm
168
* Revision 1.1  2004/06/16 08:12:01  jpm
103
* Changement de nom de Génésia en Papyrus.
169
* Changement de nom de Génésia en Papyrus.
104
* Changement de l'arborescence.
170
* Changement de l'arborescence.
105
*
171
*
106
* Revision 1.6  2004/05/01 11:40:21  jpm
172
* Revision 1.6  2004/05/01 11:40:21  jpm
107
* Suppression de code intégré dans le fichier de l'applette Identification.
173
* Suppression de code intégré dans le fichier de l'applette Identification.
108
*
174
*
109
* Revision 1.5  2004/04/28 12:04:31  jpm
175
* Revision 1.5  2004/04/28 12:04:31  jpm
110
* Changement du modèle de la base de données.
176
* Changement du modèle de la base de données.
111
*
177
*
112
* Revision 1.4  2004/04/22 08:29:11  jpm
178
* Revision 1.4  2004/04/22 08:29:11  jpm
113
* Transformation de $GS_GLOBAL en $_GEN_commun.
179
* Transformation de $GS_GLOBAL en $_GEN_commun.
114
*
180
*
115
* Revision 1.3  2004/04/09 16:20:33  jpm
181
* Revision 1.3  2004/04/09 16:20:33  jpm
116
* Gestion de l'authentification uniquement.
182
* Gestion de l'authentification uniquement.
117
* Gestion des tables i18n.
183
* Gestion des tables i18n.
118
*
184
*
119
* Revision 1.2  2004/04/02 16:29:58  jpm
185
* Revision 1.2  2004/04/02 16:29:58  jpm
120
* Ajout de la gestion de la déconnexion et reconnexion.
186
* Ajout de la gestion de la déconnexion et reconnexion.
121
*
187
*
122
* Revision 1.1  2004/04/02 08:54:58  jpm
188
* Revision 1.1  2004/04/02 08:54:58  jpm
123
* Création du fichier qui contient l'initialisation des objets Pear, hormis la base de données.
189
* Création du fichier qui contient l'initialisation des objets Pear, hormis la base de données.
124
*
190
*
125
* +--Fin du code ----------------------------------------------------------------------------------------+
191
* +--Fin du code ----------------------------------------------------------------------------------------+
126
*/
192
*/
127
?>
193
?>