Subversion Repositories Applications.papyrus

Rev

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

Rev 307 Rev 313
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.14 2005-03-15 14:20:01 jpm Exp $
24
// CVS : $Id: pap_initialise_auth.inc.php,v 1.15 2005-03-24 15:04:26 alex 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.14 $ $Date: 2005-03-15 14:20:01 $
40
*@version           $Revision: 1.15 $ $Date: 2005-03-24 15:04:26 $
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
include_once GEN_CHEMIN_PAP.'bibliotheque/fonctions/pap_site.fonct.php' ;
56
include_once GEN_CHEMIN_PAP.'bibliotheque/fonctions/pap_site.fonct.php' ;
57
 
57
 
58
// +------------------------------------------------------------------------------------------------------+
58
// +------------------------------------------------------------------------------------------------------+
59
// |                                            CORPS du PROGRAMME                                        |
59
// |                                            CORPS du PROGRAMME                                        |
60
// +------------------------------------------------------------------------------------------------------+
60
// +------------------------------------------------------------------------------------------------------+
61
 
61
 
62
// +------------------------------------------------------------------------------------------------------+
62
// +------------------------------------------------------------------------------------------------------+
63
// Gestion de l'identification des utilisateurs et des sessions
63
// Gestion de l'identification des utilisateurs et des sessions
64
 
64
 
65
// +------------------------------------------------------------------------------------------------------+
65
// +------------------------------------------------------------------------------------------------------+
66
// Récupération des informations d'identification pour le site courant
66
// Récupération des informations d'identification pour le site courant
67
 
67
 
68
// Récupération des informations sur le site
68
// Récupération des informations sur le site
69
$requete_auth = 'SELECT gen_site_auth.*, gs_id_site '.
69
$requete_auth = 'SELECT gen_site_auth.*, gs_id_site '.
70
                'FROM gen_site_auth, gen_site '.
70
                'FROM gen_site_auth, gen_site '.
71
                'WHERE gs_ce_auth <> 0 '.
71
                'WHERE gs_ce_auth <> 0 '.
72
                'AND gs_ce_auth = gsa_id_auth';
72
                'AND gs_ce_auth = gsa_id_auth';
73
 
73
 
74
$resultat_auth = $db->query($requete_auth);
74
$resultat_auth = $db->query($requete_auth);
75
(DB::isError($resultat_auth))
75
(DB::isError($resultat_auth))
76
    ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_auth->getMessage(), $requete_auth))
76
    ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_auth->getMessage(), $requete_auth))
77
    : '';
77
    : '';
78
 
78
 
79
while ($ligne_auth = $resultat_auth->fetchRow(DB_FETCHMODE_OBJECT)) {
79
while ($ligne_auth = $resultat_auth->fetchRow(DB_FETCHMODE_OBJECT)) {
80
    // Ajout des valeurs communes aux différents type d'auth
80
    // Ajout des valeurs communes aux différents type d'auth
81
    $GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth]['gsa_nom'] = $ligne_auth->gsa_nom;
81
    $GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth]['gsa_nom'] = $ligne_auth->gsa_nom;
82
    $GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth]['gsa_abreviation'] = $ligne_auth->gsa_abreviation;
82
    $GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth]['gsa_abreviation'] = $ligne_auth->gsa_abreviation;
83
    $GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth]['gsa_ce_type_auth'] = $ligne_auth->gsa_ce_type_auth;
83
    $GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth]['gsa_ce_type_auth'] = $ligne_auth->gsa_ce_type_auth;
84
    
84
    
85
    if ($ligne_auth->gsa_id_auth == $_GEN_commun['info_site']->gs_ce_auth) {
85
    if ($ligne_auth->gsa_id_auth == $_GEN_commun['info_site']->gs_ce_auth) {
86
        $_GEN_commun['info_auth'] = $ligne_auth;
86
        $_GEN_commun['info_auth'] = $ligne_auth;
87
    }
87
    }
88
    
88
    
89
    if ($ligne_auth->gsa_ce_auth_bdd != 0) {
89
    if ($ligne_auth->gsa_ce_auth_bdd != 0) {
90
        //Identification via une base de donnée :
90
        //Identification via une base de donnée :
91
        $requete_auth_bdd = 'SELECT * '.
91
        $requete_auth_bdd = 'SELECT * '.
92
                            'FROM gen_site_auth_bdd '.
92
                            'FROM gen_site_auth_bdd '.
93
                            'WHERE gsab_id_auth_bdd = '.$ligne_auth->gsa_ce_auth_bdd;
93
                            'WHERE gsab_id_auth_bdd = '.$ligne_auth->gsa_ce_auth_bdd;
94
        
94
        
95
        $resultat_auth_bdd = $db->query($requete_auth_bdd);
95
        $resultat_auth_bdd = $db->query($requete_auth_bdd);
96
        (DB::isError($resultat_auth_bdd))
96
        (DB::isError($resultat_auth_bdd))
97
            ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_auth_bdd->getMessage(), $requete_auth_bdd))
97
            ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_auth_bdd->getMessage(), $requete_auth_bdd))
98
            : '';
98
            : '';
99
        $tab_auth_bdd = $resultat_auth_bdd->fetchRow(DB_FETCHMODE_OBJECT) ;
99
        $tab_auth_bdd = $resultat_auth_bdd->fetchRow(DB_FETCHMODE_OBJECT) ;
100
        if ($ligne_auth->gsa_id_auth == $_GEN_commun['info_site']->gs_ce_auth) {
100
        if ($ligne_auth->gsa_id_auth == $_GEN_commun['info_site']->gs_ce_auth) {
101
            $_GEN_commun['info_auth_bdd'] = $tab_auth_bdd ;
101
            $_GEN_commun['info_auth_bdd'] = $tab_auth_bdd ;
102
        }
102
        }
103
        $GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth] = array_merge($GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth], $tab_auth_bdd);
103
        $GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth] = array_merge($GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth], $tab_auth_bdd);
104
        $resultat_auth_bdd->free();
104
        $resultat_auth_bdd->free();
105
        
105
        
106
        // Gestion des arguments de l'authentification
106
        // Gestion des arguments de l'authentification
107
        if (isset($GLOBALS['_GEN_commun']['info_auth_bdd']->gsab_parametres)) {
107
        if (isset($GLOBALS['_GEN_commun']['info_auth_bdd']->gsab_parametres)) {
108
            $arguments = explode(' ', $GLOBALS['_GEN_commun']['info_auth_bdd']->gsab_parametres);
108
            $arguments = explode(' ', $GLOBALS['_GEN_commun']['info_auth_bdd']->gsab_parametres);
109
            for ($i = 0; $i < count($arguments); $i++) {
109
            for ($i = 0; $i < count($arguments); $i++) {
110
                $attr = explode('=', $arguments[$i]);
110
                $attr = explode('=', $arguments[$i]);
111
                if ($attr[0] != '') {
111
                if ($attr[0] != '') {
112
                    $GLOBALS['_GEN_commun']['info_auth_bdd']->$attr[0] = (isset($attr[1]) ? $attr[1] : '');
112
                    $GLOBALS['_GEN_commun']['info_auth_bdd']->$attr[0] = (isset($attr[1]) ? $attr[1] : '');
113
                }
113
                }
114
            }
114
            }
115
        }
115
        }
116
    } else if ($ligne_auth->gsa_ce_auth_ldap != 0) {
116
    } else if ($ligne_auth->gsa_ce_auth_ldap != 0) {
117
        //Identification via LDAP :
117
        //Identification via LDAP :
118
        $requete_auth_ldap =    'SELECT * '.
118
        $requete_auth_ldap =    'SELECT * '.
119
                                'FROM gen_site_auth_ldap '.
119
                                'FROM gen_site_auth_ldap '.
120
                                'WHERE gsal_id_auth_ldap = '.$ligne_auth->gsa_ce_auth_ldap;
120
                                'WHERE gsal_id_auth_ldap = '.$ligne_auth->gsa_ce_auth_ldap;
121
        
121
        
122
        $resultat_auth_ldap = $db->query($requete_auth_ldap);
122
        $resultat_auth_ldap = $db->query($requete_auth_ldap);
123
        (DB::isError($resultat_auth_ldap))
123
        (DB::isError($resultat_auth_ldap))
124
            ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_auth_ldap->getMessage(), $requete_auth_ldap))
124
            ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_auth_ldap->getMessage(), $requete_auth_ldap))
125
            : '';
125
            : '';
126
        $tab_auth_ldap = $resultat_auth_ldap->fetchRow(DB_FETCHMODE_OBJECT);
126
        $tab_auth_ldap = $resultat_auth_ldap->fetchRow(DB_FETCHMODE_OBJECT);
127
        if ($ligne_auth->gsa_id_auth == $_GEN_commun['info_site']->gs_ce_auth) {
127
        if ($ligne_auth->gsa_id_auth == $_GEN_commun['info_site']->gs_ce_auth) {
128
            $_GEN_commun['info_auth_ldap'] = $tab_auth_ldap;
128
            $_GEN_commun['info_auth_ldap'] = $tab_auth_ldap;
129
        }
129
        }
130
        $GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth] = array_merge($GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth], $tab_auth_ldap);
130
        $GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth] = array_merge($GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth], $tab_auth_ldap);
131
        $resultat_auth_ldap->free();
131
        $resultat_auth_ldap->free();
132
    } else {
132
    } else {
133
        die('ERREUR Papyrus : impossible de trouver les information authentification. <br />'.
133
        die('ERREUR Papyrus : impossible de trouver les information authentification. <br />'.
134
            'Identifiant auth : '.$ligne_auth->gs_ce_auth.'<br />'.
134
            'Identifiant auth : '.$ligne_auth->gs_ce_auth.'<br />'.
135
            'Ligne n° : '. __LINE__ .'<br />'.
135
            'Ligne n° : '. __LINE__ .'<br />'.
136
            'Fichier : '. __FILE__ );
136
            'Fichier : '. __FILE__ );
137
    }
137
    }
138
    
138
    
139
    // On teste le type d'authentification
139
    // On teste le type d'authentification
140
    $tab_type_site = GEN_retournerTableauTypeSiteExterne($db);
140
    $tab_type_site = GEN_retournerTableauTypeSiteExterne($db);
141
    $types_site = '';
141
    $types_site = '';
142
    foreach ($tab_type_site as $val) {
142
    foreach ($tab_type_site as $val) {
143
        $types_site .= $val['id'].', ';
143
        $types_site .= $val['id'].', ';
144
    }
144
    }
145
    $types_site = substr($types_site, 0, -2);
145
    $types_site = substr($types_site, 0, -2);
146
    $requete =  'SELECT gsr_id_valeur '.
146
    $requete =  'SELECT gsr_id_valeur '.
147
                'FROM gen_site_relation '.
147
                'FROM gen_site_relation '.
148
                'WHERE gsr_id_site_01 = '.$ligne_auth->gs_id_site.' '.
148
                'WHERE gsr_id_site_01 = '.$ligne_auth->gs_id_site.' '.
149
                'AND gsr_id_site_01 = gsr_id_site_02 '.
149
                'AND gsr_id_site_01 = gsr_id_site_02 '.
150
                'AND gsr_id_valeur IN ('.$types_site.')';
150
                'AND gsr_id_valeur IN ('.$types_site.')';
151
    $type_site_externe = $db->getOne($requete);
151
    $type_site_externe = $db->getOne($requete);
152
    (DB::isError($type_site_externe))
152
    (DB::isError($type_site_externe))
153
            ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $type_site_externe->getMessage(), $requete))
153
            ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $type_site_externe->getMessage(), $requete))
154
            : '';
154
            : '';
155
    // Type du site de l'authentification
155
    // Type du site de l'authentification
156
    if ($type_site_externe != '') {
156
    if ($type_site_externe != '') {
157
        $GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth]['type_site_externe'] = $type_site_externe;
157
        $GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth]['type_site_externe'] = $type_site_externe;
158
    }
158
    }
159
}
159
}
160
$resultat_auth->free();
160
$resultat_auth->free();
161
 
161
 
162
// Nour regardons à quel type d'identification nous avons à faire:
162
// Nour regardons à quel type d'identification nous avons à faire:
163
$auth_courante = $GLOBALS['_PAPYRUS_']['auth'][$_GEN_commun['info_site']->gs_ce_auth] ;
163
$auth_courante = $GLOBALS['_PAPYRUS_']['auth'][$_GEN_commun['info_site']->gs_ce_auth] ;
164
if ($auth_courante['gsa_ce_type_auth'] == 1) {
164
if ($auth_courante['gsa_ce_type_auth'] == 1) {
165
    // Authentification via une base de données
165
    // Authentification via une base de données
166
    $GLOBALS['_PAPYRUS_']['auth']['param_bdd'] = array ('dsn' => $auth_courante['gsab_dsn'],
166
    $GLOBALS['_PAPYRUS_']['auth']['param_bdd'] = array ('dsn' => $auth_courante['gsab_dsn'],
167
                        'table' => $auth_courante['gsab_nom_table'],
167
                        'table' => $auth_courante['gsab_nom_table'],
168
                        'usernamecol' => $auth_courante['gsab_nom_champ_login'],
168
                        'usernamecol' => $auth_courante['gsab_nom_champ_login'],
169
                        'passwordcol' => $auth_courante['gsab_nom_champ_mdp'],
169
                        'passwordcol' => $auth_courante['gsab_nom_champ_mdp'],
170
                        'cryptType' => $auth_courante['gsab_cryptage_mdp'],
170
                        'cryptType' => $auth_courante['gsab_cryptage_mdp'],
171
                        'db_fields' => '*');
171
                        'db_fields' => '*');
172
    // L'authentification courrante
172
    // L'authentification courrante
173
    $_GEN_commun['pear_auth'] = new Auth('DB', $GLOBALS['_PAPYRUS_']['auth']['param_bdd'], 'GEN_afficherInfoIdentification', 1);
173
    $_GEN_commun['pear_auth'] = new Auth('DB', $GLOBALS['_PAPYRUS_']['auth']['param_bdd'], 'GEN_afficherInfoIdentification', 1);
174
    
174
    
175
} else if ($auth_courante['gsa_ce_type_auth'] == 2) {
175
} else if ($auth_courante['gsa_ce_type_auth'] == 2) {
176
    // Authentification via LDAP
176
    // Authentification via LDAP
177
    $GLOBALS['_PAPYRUS_']['auth']['param_ldap'] = array (   'host' => $auth_courante['gsal_serveur'],
177
    $GLOBALS['_PAPYRUS_']['auth']['param_ldap'] = array (   'host' => $auth_courante['gsal_serveur'],
178
                            'port' => $auth_courante['gsal_port'],
178
                            'port' => $auth_courante['gsal_port'],
179
                            'basedn' => $auth_courante['gsal_base_dn'],
179
                            'basedn' => $auth_courante['gsal_base_dn'],
180
                            'userattr' => $auth_courante['gsal_uid']);
180
                            'userattr' => $auth_courante['gsal_uid']);
181
    $_GEN_commun['pear_auth'] = new Auth('LDAP', $GLOBALS['_PAPYRUS_']['auth']['param_ldap'], 'GEN_afficherInfoIdentification', 1);
181
    $_GEN_commun['pear_auth'] = new Auth('LDAP', $GLOBALS['_PAPYRUS_']['auth']['param_ldap'], 'GEN_afficherInfoIdentification', 1);
182
} else {
182
} else {
183
    die('ERREUR Papyrus : type identification introuvable. <br />'.
183
    die('ERREUR Papyrus : type identification introuvable. <br />'.
184
        'Type identification : '.$auth_courante['gsa_ce_type_auth'].'<br />'.
184
        'Type identification : '.$auth_courante['gsa_ce_type_auth'].'<br />'.
185
        'Ligne n° : '. __LINE__ . '<br />'.
185
        'Ligne n° : '. __LINE__ . '<br />'.
186
        'Fichier : '. __FILE__ . '<br />');
186
        'Fichier : '. __FILE__ . '<br />');
187
}
187
}
188
 
188
 
189
$_GEN_commun['pear_auth']->setSessionname( 'gen_'.$_GEN_commun['info_auth']->gsa_abreviation);
189
$_GEN_commun['pear_auth']->setSessionname( 'gen_'.$_GEN_commun['info_auth']->gsa_abreviation);
-
 
190
 
-
 
191
// Pour que la session dure même après avoir refermer son navigateur
-
 
192
session_set_cookie_params(3600 * 24 * 30 * 6);
-
 
193
 
190
 
194
// Expiration si l'utilisateur ne referme pas son navigateur
191
$_GEN_commun['pear_auth']->setExpire(3600 * 24 * 30 * 6);// 6 mois
195
$_GEN_commun['pear_auth']->setExpire(3600 * 24 * 30 * 6);// 6 mois
192
 
196
 
193
$_GEN_commun['pear_auth']->start();
197
$_GEN_commun['pear_auth']->start();
194
 
198
 
195
// +------------------------------------------------------------------------------------------------------+
199
// +------------------------------------------------------------------------------------------------------+
196
// Gestion des sesssion WIKINI
200
// Gestion des sesssion WIKINI
197
if (isset ($auth_courante['type_site_externe']) && $auth_courante['type_site_externe'] == '201') {// 201 = site de type "WIKINI"
201
if (isset ($auth_courante['type_site_externe']) && $auth_courante['type_site_externe'] == '201') {// 201 = site de type "WIKINI"
198
 
202
 
199
}
203
}
200
 
204
 
201
// +------------------------------------------------------------------------------------------------------+
205
// +------------------------------------------------------------------------------------------------------+
202
// Gestion des sesssion SPIP
206
// Gestion des sesssion SPIP
203
 
207
 
204
// Recherche des paramètres de SPIP
208
// Recherche des paramètres de SPIP
205
foreach ($GLOBALS['_PAPYRUS_']['auth'] as $cle => $valeur) {
209
foreach ($GLOBALS['_PAPYRUS_']['auth'] as $cle => $valeur) {
206
    if (isset($valeur['type_site_externe']) && $valeur['type_site_externe'] == 200) {  // 200 = site de type "SPIP"
210
    if (isset($valeur['type_site_externe']) && $valeur['type_site_externe'] == 200) {  // 200 = site de type "SPIP"
207
        $tab_parametre = explode (" ", $valeur['gsab_parametres']) ;
211
        $tab_parametre = explode (" ", $valeur['gsab_parametres']) ;
208
        foreach ($tab_parametre as $cle_param => $valeur_param) {
212
        foreach ($tab_parametre as $cle_param => $valeur_param) {
209
            $tab_valeur = explode ('=', $valeur_param) ;
213
            $tab_valeur = explode ('=', $valeur_param) ;
210
            if ($tab_valeur[0] == 'chemin_spip') $chemin_spip = $tab_valeur[1] ;
214
            if ($tab_valeur[0] == 'chemin_spip') $chemin_spip = $tab_valeur[1] ;
211
            if ($tab_valeur[0] == 'coauth') $coauth= $tab_valeur[1] ;
215
            if ($tab_valeur[0] == 'coauth') $coauth= $tab_valeur[1] ;
212
            if ($tab_valeur[0] == 'chemin_cookie_spip') $chemin_cookie_spip = $tab_valeur[1] ;
216
            if ($tab_valeur[0] == 'chemin_cookie_spip') $chemin_cookie_spip = $tab_valeur[1] ;
213
        }
217
        }
214
    }
218
    }
215
}
219
}
216
// Début initialisation de la gestion SPIP
220
// Début initialisation de la gestion SPIP
217
if (isset ($chemin_spip) && isset ($coauth) && $coauth == $auth_courante['gsab_id_auth_bdd']&& $_GEN_commun['pear_auth']->getAuth()) {
221
if (isset ($chemin_spip) && isset ($coauth) && $coauth == $auth_courante['gsab_id_auth_bdd']&& $_GEN_commun['pear_auth']->getAuth()) {
218
    $login = $_GEN_commun['pear_auth']->getUsername() ;
222
    $login = $_GEN_commun['pear_auth']->getUsername() ;
219
    
223
    
220
    setcookie('spip_admin', '@'.$login, time()+3600*24*30, '/'.$chemin_cookie_spip.'/');
224
    setcookie('spip_admin', '@'.$login, time()+3600*24*30, '/'.$chemin_cookie_spip.'/');
221
 
225
 
222
    $query = 'SELECT * FROM spip_auteurs WHERE login = "'.$login.'"';
226
    $query = 'SELECT * FROM spip_auteurs WHERE login = "'.$login.'"';
223
    $result = $db->query($query);
227
    $result = $db->query($query);
224
    $GLOBALS['auteur_session'] = $result->fetchRow(DB_FETCHMODE_ASSOC);
228
    $GLOBALS['auteur_session'] = $result->fetchRow(DB_FETCHMODE_ASSOC);
225
    $GLOBALS['auteur_session']['statut'] = '1comite';
229
    $GLOBALS['auteur_session']['statut'] = '1comite';
226
    $GLOBALS['auteur_session']['lang'] = 'fr';
230
    $GLOBALS['auteur_session']['lang'] = 'fr';
227
 
231
 
228
    $userid = $GLOBALS['auteur_session']['id_auteur'];
232
    $userid = $GLOBALS['auteur_session']['id_auteur'];
229
    $GLOBALS['__auteur_session__'] = $GLOBALS['auteur_session'];
233
    $GLOBALS['__auteur_session__'] = $GLOBALS['auteur_session'];
230
    if (!$HTTP_COOKIE_VARS["spip_session"]) {
234
    if (!$HTTP_COOKIE_VARS["spip_session"]) {
231
        $id_session = $GLOBALS['auteur_session']['id_auteur']."_".(md5 (uniqid (rand ())));
235
        $id_session = $GLOBALS['auteur_session']['id_auteur']."_".(md5 (uniqid (rand ())));
232
        setcookie("spip_session", $id_session, time()+3600*24*30, "/$chemin_cookie_spip/") ;
236
        setcookie("spip_session", $id_session, time()+3600*24*30, "/$chemin_cookie_spip/") ;
233
 
237
 
234
    } else {
238
    } else {
235
        $id_session = preg_replace("/[0-9]+_/", $userid."_", $HTTP_COOKIE_VARS["spip_session"]) ;
239
        $id_session = preg_replace("/[0-9]+_/", $userid."_", $HTTP_COOKIE_VARS["spip_session"]) ;
236
        setcookie("spip_session", $id_session, time()+3600*24*30, "/$chemin_cookie_spip/") ;
240
        setcookie("spip_session", $id_session, time()+3600*24*30, "/$chemin_cookie_spip/") ;
237
    }
241
    }
238
    
242
    
239
    set_include_path(get_include_path().":".$chemin_spip) ;
243
    set_include_path(get_include_path().":".$chemin_spip) ;
240
 
244
 
241
    include_once 'ecrire/inc_db_mysql.php3' ;
245
    include_once 'ecrire/inc_db_mysql.php3' ;
242
    
246
    
243
    include_once ("ecrire/inc_version.php3");
247
    include_once ("ecrire/inc_version.php3");
244
    ob_flush() ;    // Nécessaire car spip utilise un ob_start() et cela cause un plantage
248
    ob_flush() ;    // Nécessaire car spip utilise un ob_start() et cela cause un plantage
245
    
249
    
246
    include_ecrire ("inc_meta.php3");
250
    include_ecrire ("inc_meta.php3");
247
    include_ecrire ("inc_session.php3");
251
    include_ecrire ("inc_session.php3");
248
    
252
    
249
    $fichier_session = fichier_session($id_session, lire_meta('alea_ephemere'));
253
    $fichier_session = fichier_session($id_session, lire_meta('alea_ephemere'));
250
    $fichier_session = $chemin_spip."/ecrire/".$fichier_session ;
254
    $fichier_session = $chemin_spip."/ecrire/".$fichier_session ;
251
    
255
    
252
    $vars = array('id_auteur', 'nom', 'login', 'email', 'statut', 'lang', 'ip_change', 'hash_env');
256
    $vars = array('id_auteur', 'nom', 'login', 'email', 'statut', 'lang', 'ip_change', 'hash_env');
253
    
257
    
254
    $texte = "<"."?php\n";
258
    $texte = "<"."?php\n";
255
    foreach ($vars as $var) {
259
    foreach ($vars as $var) {
256
        $texte .= "\$GLOBALS['auteur_session']['$var'] = '".addslashes($GLOBALS['__auteur_session__'][$var])."';\n";
260
        $texte .= "\$GLOBALS['auteur_session']['$var'] = '".addslashes($GLOBALS['__auteur_session__'][$var])."';\n";
257
    }
261
    }
258
    
262
    
259
    $texte .= "?".">\n";
263
    $texte .= "?".">\n";
260
    
264
    
261
    if ($f = fopen($fichier_session, "wb")) {
265
    if ($f = fopen($fichier_session, "wb")) {
262
        fputs($f, $texte);
266
        fputs($f, $texte);
263
        fclose($f);
267
        fclose($f);
264
    } else {
268
    } else {
265
        echo 'erreur dans l ecriture de la session SPIP' ;
269
        echo 'erreur dans l ecriture de la session SPIP' ;
266
    }
270
    }
267
    //ajouter_session($GLOBALS['auteur_session'], $id_session) ;
271
    //ajouter_session($GLOBALS['auteur_session'], $id_session) ;
268
}
272
}
269
 
273
 
270
 
274
 
271
/* +--Fin du code ---------------------------------------------------------------------------------------+
275
/* +--Fin du code ---------------------------------------------------------------------------------------+
272
* $Log: not supported by cvs2svn $
276
* $Log: not supported by cvs2svn $
-
 
277
* Revision 1.14  2005/03/15 14:20:01  jpm
-
 
278
* Gestion des arguments de l'identification courante.
-
 
279
*
273
* Revision 1.13  2005/02/22 18:27:24  jpm
280
* Revision 1.13  2005/02/22 18:27:24  jpm
274
* Changement de nom de variables.
281
* Changement de nom de variables.
275
*
282
*
276
* Revision 1.12  2004/12/15 15:24:45  alex
283
* Revision 1.12  2004/12/15 15:24:45  alex
277
* suppression d'un notice
284
* suppression d'un notice
278
*
285
*
279
* Revision 1.11  2004/12/13 18:06:52  alex
286
* Revision 1.11  2004/12/13 18:06:52  alex
280
* authentification spip presque parfaite
287
* authentification spip presque parfaite
281
*
288
*
282
* Revision 1.10  2004/12/07 19:13:51  alex
289
* Revision 1.10  2004/12/07 19:13:51  alex
283
* authentification spip
290
* authentification spip
284
*
291
*
285
* Revision 1.7  2004/12/07 10:26:27  jpm
292
* Revision 1.7  2004/12/07 10:26:27  jpm
286
* Correction for en foreach.
293
* Correction for en foreach.
287
*
294
*
288
* Revision 1.6  2004/12/06 12:42:02  alex
295
* Revision 1.6  2004/12/06 12:42:02  alex
289
* en cours
296
* en cours
290
*
297
*
291
* Revision 1.5  2004/12/06 12:12:28  jpm
298
* Revision 1.5  2004/12/06 12:12:28  jpm
292
* Début de gestion des auth multiples.
299
* Début de gestion des auth multiples.
293
*
300
*
294
* Revision 1.4  2004/10/25 16:28:47  jpm
301
* Revision 1.4  2004/10/25 16:28:47  jpm
295
* Ajout de nouvelles balises Papyrus, ajout vérification mise à jour de Papyrus, meilleure gestion des sessions...
302
* Ajout de nouvelles balises Papyrus, ajout vérification mise à jour de Papyrus, meilleure gestion des sessions...
296
*
303
*
297
* Revision 1.3  2004/10/15 18:29:19  jpm
304
* Revision 1.3  2004/10/15 18:29:19  jpm
298
* Modif pour gérer l'appli installateur de Papyrus.
305
* Modif pour gérer l'appli installateur de Papyrus.
299
*
306
*
300
* Revision 1.2  2004/06/30 07:23:36  jpm
307
* Revision 1.2  2004/06/30 07:23:36  jpm
301
* Ajout d'un commentaire.
308
* Ajout d'un commentaire.
302
*
309
*
303
* Revision 1.1  2004/06/16 08:12:01  jpm
310
* Revision 1.1  2004/06/16 08:12:01  jpm
304
* Changement de nom de Génésia en Papyrus.
311
* Changement de nom de Génésia en Papyrus.
305
* Changement de l'arborescence.
312
* Changement de l'arborescence.
306
*
313
*
307
* Revision 1.6  2004/05/01 11:40:21  jpm
314
* Revision 1.6  2004/05/01 11:40:21  jpm
308
* Suppression de code intégré dans le fichier de l'applette Identification.
315
* Suppression de code intégré dans le fichier de l'applette Identification.
309
*
316
*
310
* Revision 1.5  2004/04/28 12:04:31  jpm
317
* Revision 1.5  2004/04/28 12:04:31  jpm
311
* Changement du modèle de la base de données.
318
* Changement du modèle de la base de données.
312
*
319
*
313
* Revision 1.4  2004/04/22 08:29:11  jpm
320
* Revision 1.4  2004/04/22 08:29:11  jpm
314
* Transformation de $GS_GLOBAL en $_GEN_commun.
321
* Transformation de $GS_GLOBAL en $_GEN_commun.
315
*
322
*
316
* Revision 1.3  2004/04/09 16:20:33  jpm
323
* Revision 1.3  2004/04/09 16:20:33  jpm
317
* Gestion de l'authentification uniquement.
324
* Gestion de l'authentification uniquement.
318
* Gestion des tables i18n.
325
* Gestion des tables i18n.
319
*
326
*
320
* Revision 1.2  2004/04/02 16:29:58  jpm
327
* Revision 1.2  2004/04/02 16:29:58  jpm
321
* Ajout de la gestion de la déconnexion et reconnexion.
328
* Ajout de la gestion de la déconnexion et reconnexion.
322
*
329
*
323
* Revision 1.1  2004/04/02 08:54:58  jpm
330
* Revision 1.1  2004/04/02 08:54:58  jpm
324
* Création du fichier qui contient l'initialisation des objets Pear, hormis la base de données.
331
* Création du fichier qui contient l'initialisation des objets Pear, hormis la base de données.
325
*
332
*
326
* +--Fin du code ----------------------------------------------------------------------------------------+
333
* +--Fin du code ----------------------------------------------------------------------------------------+
327
*/
334
*/
328
?>
335
?>