Subversion Repositories Applications.papyrus

Rev

Rev 232 | Rev 307 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 232 Rev 271
Line 19... Line 19...
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.12 2004-12-15 15:24:45 alex Exp $
24
// CVS : $Id: pap_initialise_auth.inc.php,v 1.13 2005-02-22 18:27:24 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.
Line 35... Line 35...
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.12 $ $Date: 2004-12-15 15:24:45 $
40
*@version           $Revision: 1.13 $ $Date: 2005-02-22 18:27:24 $
41
// +------------------------------------------------------------------------------------------------------+
41
// +------------------------------------------------------------------------------------------------------+
42
*/
42
*/
Line 43... Line 43...
43
 
43
 
44
// +------------------------------------------------------------------------------------------------------+
44
// +------------------------------------------------------------------------------------------------------+
Line 151... Line 151...
151
 
151
 
152
// Nour regardons à quel type d'identification nous avons à faire:
152
// Nour regardons à quel type d'identification nous avons à faire:
153
$auth_courante = $GLOBALS['_PAPYRUS_']['auth'][$_GEN_commun['info_site']->gs_ce_auth] ;
153
$auth_courante = $GLOBALS['_PAPYRUS_']['auth'][$_GEN_commun['info_site']->gs_ce_auth] ;
154
if ($auth_courante['gsa_ce_type_auth'] == 1) {
154
if ($auth_courante['gsa_ce_type_auth'] == 1) {
155
    // Authentification via une base de données
155
    // Authentification via une base de données
156
    $param_bdd = array ('dsn' => $auth_courante['gsab_dsn'],
156
    $GLOBALS['_PAPYRUS_']['auth']['param_bdd'] = array ('dsn' => $auth_courante['gsab_dsn'],
157
                        'table' => $auth_courante['gsab_nom_table'],
157
                        'table' => $auth_courante['gsab_nom_table'],
158
                        'usernamecol' => $auth_courante['gsab_nom_champ_login'],
158
                        'usernamecol' => $auth_courante['gsab_nom_champ_login'],
159
                        'passwordcol' => $auth_courante['gsab_nom_champ_mdp'],
159
                        'passwordcol' => $auth_courante['gsab_nom_champ_mdp'],
160
                        'cryptType' => $auth_courante['gsab_cryptage_mdp'],
160
                        'cryptType' => $auth_courante['gsab_cryptage_mdp'],
161
                        'db_fields' => '*');
161
                        'db_fields' => '*');
162
    // L'authentification courrante
162
    // L'authentification courrante
Line 163... Line 163...
163
    $_GEN_commun['pear_auth'] = new Auth('DB', $param_bdd, 'GEN_afficherInfoIdentification', 1);
163
    $_GEN_commun['pear_auth'] = new Auth('DB', $GLOBALS['_PAPYRUS_']['auth']['param_bdd'], 'GEN_afficherInfoIdentification', 1);
164
    
164
    
165
} else if ($auth_courante['gsa_ce_type_auth'] == 2) {
165
} else if ($auth_courante['gsa_ce_type_auth'] == 2) {
166
    // Authentification via LDAP
166
    // Authentification via LDAP
167
    $param_ldap = array (   'host' => $auth_courante['gsal_serveur'],
167
    $GLOBALS['_PAPYRUS_']['auth']['param_ldap'] = array (   'host' => $auth_courante['gsal_serveur'],
168
                            'port' => $auth_courante['gsal_port'],
168
                            'port' => $auth_courante['gsal_port'],
169
                            'basedn' => $auth_courante['gsal_base_dn'],
169
                            'basedn' => $auth_courante['gsal_base_dn'],
170
                            'userattr' => $auth_courante['gsal_uid']);
170
                            'userattr' => $auth_courante['gsal_uid']);
171
    $_GEN_commun['pear_auth'] = new Auth('LDAP', $param_ldap, 'GEN_afficherInfoIdentification', 1);
171
    $_GEN_commun['pear_auth'] = new Auth('LDAP', $GLOBALS['_PAPYRUS_']['auth']['param_ldap'], 'GEN_afficherInfoIdentification', 1);
172
} else {
172
} else {
173
    die('ERREUR Papyrus : type identification introuvable. <br />'.
173
    die('ERREUR Papyrus : type identification introuvable. <br />'.
174
        'Type identification : '.$auth_courante['gsa_ce_type_auth'].'<br />'.
174
        'Type identification : '.$auth_courante['gsa_ce_type_auth'].'<br />'.
Line 180... Line 180...
180
 
180
 
Line 181... Line 181...
181
$_GEN_commun['pear_auth']->setExpire(3600 * 24 * 30 * 6);// 6 mois
181
$_GEN_commun['pear_auth']->setExpire(3600 * 24 * 30 * 6);// 6 mois
Line -... Line 182...
-
 
182
 
-
 
183
$_GEN_commun['pear_auth']->start();
-
 
184
 
-
 
185
// +------------------------------------------------------------------------------------------------------+
-
 
186
// Gestion des sesssion WIKINI
-
 
187
if (isset ($auth_courante['type_site_externe']) && $auth_courante['type_site_externe'] == '201') {// 201 = site de type "WIKINI"
-
 
188
 
-
 
189
}
Line 182... Line 190...
182
 
190
 
183
$_GEN_commun['pear_auth']->start();
191
// +------------------------------------------------------------------------------------------------------+
184
 
192
// Gestion des sesssion SPIP
185
 
193
 
Line 193... Line 201...
193
            if ($tab_valeur[0] == 'coauth') $coauth= $tab_valeur[1] ;
201
            if ($tab_valeur[0] == 'coauth') $coauth= $tab_valeur[1] ;
194
            if ($tab_valeur[0] == 'chemin_cookie_spip') $chemin_cookie_spip = $tab_valeur[1] ;
202
            if ($tab_valeur[0] == 'chemin_cookie_spip') $chemin_cookie_spip = $tab_valeur[1] ;
195
        }
203
        }
196
    }
204
    }
197
}
205
}
198
 
-
 
199
 
-
 
200
 
-
 
201
if (isset ($auth_courante['type_site_externe']) && $auth_courante['type_site_externe'] == '201') {// 201 = site de type "WIKINI"
206
// Début initialisation de la gestion SPIP
202
 
-
 
203
}
-
 
204
 
-
 
205
if (isset ($chemin_spip) && isset ($coauth) && $coauth == $auth_courante['gsab_id_auth_bdd']&& $_GEN_commun['pear_auth']->getAuth()) {
207
if (isset ($chemin_spip) && isset ($coauth) && $coauth == $auth_courante['gsab_id_auth_bdd']&& $_GEN_commun['pear_auth']->getAuth()) {
206
    $login = $_GEN_commun['pear_auth']->getUsername() ;
208
    $login = $_GEN_commun['pear_auth']->getUsername() ;
Line 207... Line 209...
207
    
209
    
Line 208... Line 210...
208
    setcookie("spip_admin", "@".$login, time()+3600*24*30, "/$chemin_cookie_spip/") ;
210
    setcookie('spip_admin', '@'.$login, time()+3600*24*30, '/'.$chemin_cookie_spip.'/');
209
 
211
 
210
    $query = "SELECT * FROM spip_auteurs WHERE login='".$login."'";
212
    $query = 'SELECT * FROM spip_auteurs WHERE login = "'.$login.'"';
211
    $result = $db->query($query);
213
    $result = $db->query($query);
212
    $GLOBALS['auteur_session'] = $result->fetchRow(DB_FETCHMODE_ASSOC) ;
214
    $GLOBALS['auteur_session'] = $result->fetchRow(DB_FETCHMODE_ASSOC);
Line 213... Line 215...
213
    $GLOBALS['auteur_session']['statut'] = "1comite" ;
215
    $GLOBALS['auteur_session']['statut'] = '1comite';
214
    $GLOBALS['auteur_session']['lang'] = "fr" ;
216
    $GLOBALS['auteur_session']['lang'] = 'fr';
215
 
217
 
216
    $userid = $GLOBALS['auteur_session']['id_auteur'] ;
218
    $userid = $GLOBALS['auteur_session']['id_auteur'];
217
    $GLOBALS['__auteur_session__'] = $GLOBALS['auteur_session'] ;
219
    $GLOBALS['__auteur_session__'] = $GLOBALS['auteur_session'];
Line 218... Line 220...
218
    if (!$HTTP_COOKIE_VARS["spip_session"]) {
220
    if (!$HTTP_COOKIE_VARS["spip_session"]) {
Line 232... Line 234...
232
    ob_flush() ;    // Nécessaire car spip utilise un ob_start() et cela cause un plantage
234
    ob_flush() ;    // Nécessaire car spip utilise un ob_start() et cela cause un plantage
Line 233... Line 235...
233
    
235
    
234
    include_ecrire ("inc_meta.php3");
236
    include_ecrire ("inc_meta.php3");
Line 235... Line -...
235
    include_ecrire ("inc_session.php3");
-
 
236
    
-
 
237
 
237
    include_ecrire ("inc_session.php3");
238
 
238
    
239
    $fichier_session = fichier_session($id_session, lire_meta('alea_ephemere'));
239
    $fichier_session = fichier_session($id_session, lire_meta('alea_ephemere'));
240
    $fichier_session = $chemin_spip."/ecrire/".$fichier_session ;
240
    $fichier_session = $chemin_spip."/ecrire/".$fichier_session ;
Line 241... Line 241...
241
 
241
    
242
    $vars = array('id_auteur', 'nom', 'login', 'email', 'statut', 'lang', 'ip_change', 'hash_env');
242
    $vars = array('id_auteur', 'nom', 'login', 'email', 'statut', 'lang', 'ip_change', 'hash_env');
243
    
243
    
244
    $texte = "<"."?php\n";
244
    $texte = "<"."?php\n";
Line 245... Line 245...
245
    foreach ($vars as $var) {
245
    foreach ($vars as $var) {
246
        $texte .= "\$GLOBALS['auteur_session']['$var'] = '".addslashes($GLOBALS['__auteur_session__'][$var])."';\n";
246
        $texte .= "\$GLOBALS['auteur_session']['$var'] = '".addslashes($GLOBALS['__auteur_session__'][$var])."';\n";
247
    }
247
    }
248
    
248
    
249
    $texte .= "?".">\n";
249
    $texte .= "?".">\n";
250
 
250
    
251
    if ($f = fopen($fichier_session, "wb")) {
251
    if ($f = fopen($fichier_session, "wb")) {
252
        fputs($f, $texte);
252
        fputs($f, $texte);
253
        fclose($f);
-
 
254
    } else {
253
        fclose($f);
255
        echo 'erreur dans l ecriture de la session SPIP' ;
-
 
256
    }
254
    } else {
Line 257... Line 255...
257
 
255
        echo 'erreur dans l ecriture de la session SPIP' ;
258
        //ajouter_session($GLOBALS['auteur_session'], $id_session) ;
256
    }
-
 
257
    //ajouter_session($GLOBALS['auteur_session'], $id_session) ;
-
 
258
}
-
 
259
 
259
 
260
 
260
}
261
/* +--Fin du code ---------------------------------------------------------------------------------------+
261
 
262
* $Log: not supported by cvs2svn $
262
 
263
* Revision 1.12  2004/12/15 15:24:45  alex
263
/* +--Fin du code ---------------------------------------------------------------------------------------+
264
* suppression d'un notice