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.15 2005-03-24 15:04:26 alex Exp $
|
24 |
// CVS : $Id: pap_initialise_auth.inc.php,v 1.16 2005-03-25 13:08:20 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.15 $ $Date: 2005-03-24 15:04:26 $
|
40 |
*@version $Revision: 1.16 $ $Date: 2005-03-25 13:08:20 $
|
41 |
// +------------------------------------------------------------------------------------------------------+
|
41 |
// +------------------------------------------------------------------------------------------------------+
|
42 |
*/
|
42 |
*/
|
Line 43... |
Line 43... |
43 |
|
43 |
|
44 |
// +------------------------------------------------------------------------------------------------------+
|
44 |
// +------------------------------------------------------------------------------------------------------+
|
Line 80... |
Line 80... |
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;
|
Line 84... |
Line 84... |
84 |
|
84 |
|
85 |
if ($ligne_auth->gsa_id_auth == $_GEN_commun['info_site']->gs_ce_auth) {
|
85 |
if ($ligne_auth->gsa_id_auth == $GLOBALS['_GEN_commun']['info_site']->gs_ce_auth) {
|
86 |
$_GEN_commun['info_auth'] = $ligne_auth;
|
86 |
$GLOBALS['_GEN_commun']['info_auth'] = $ligne_auth;
|
Line 87... |
Line 87... |
87 |
}
|
87 |
}
|
88 |
|
88 |
|
89 |
if ($ligne_auth->gsa_ce_auth_bdd != 0) {
|
89 |
if ($ligne_auth->gsa_ce_auth_bdd != 0) {
|
Line 95... |
Line 95... |
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 == $GLOBALS['_GEN_commun']['info_site']->gs_ce_auth) {
|
101 |
$_GEN_commun['info_auth_bdd'] = $tab_auth_bdd ;
|
101 |
$GLOBALS['_GEN_commun']['info_auth_bdd'] = $tab_auth_bdd ;
|
102 |
}
|
- |
|
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();
|
- |
|
105 |
|
- |
|
106 |
// Gestion des arguments de l'authentification
|
102 |
// Gestion des arguments de l'authentification
|
107 |
if (isset($GLOBALS['_GEN_commun']['info_auth_bdd']->gsab_parametres)) {
|
103 |
if (isset($GLOBALS['_GEN_commun']['info_auth_bdd']->gsab_parametres)) {
|
108 |
$arguments = explode(' ', $GLOBALS['_GEN_commun']['info_auth_bdd']->gsab_parametres);
|
104 |
$arguments = explode(' ', $GLOBALS['_GEN_commun']['info_auth_bdd']->gsab_parametres);
|
109 |
for ($i = 0; $i < count($arguments); $i++) {
|
105 |
for ($i = 0; $i < count($arguments); $i++) {
|
110 |
$attr = explode('=', $arguments[$i]);
|
106 |
$attr = explode('=', $arguments[$i]);
|
111 |
if ($attr[0] != '') {
|
107 |
if ($attr[0] != '') {
|
112 |
$GLOBALS['_GEN_commun']['info_auth_bdd']->$attr[0] = (isset($attr[1]) ? $attr[1] : '');
|
108 |
$GLOBALS['_GEN_commun']['info_auth_bdd']->$attr[0] = (isset($attr[1]) ? $attr[1] : '');
|
- |
|
109 |
}
|
113 |
}
|
110 |
}
|
114 |
}
|
111 |
}
|
115 |
}
|
112 |
}
|
- |
|
113 |
$GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth] = array_merge($GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth], $tab_auth_bdd);
|
- |
|
114 |
$resultat_auth_bdd->free();
|
116 |
} else if ($ligne_auth->gsa_ce_auth_ldap != 0) {
|
115 |
} else if ($ligne_auth->gsa_ce_auth_ldap != 0) {
|
117 |
//Identification via LDAP :
|
116 |
//Identification via LDAP :
|
118 |
$requete_auth_ldap = 'SELECT * '.
|
117 |
$requete_auth_ldap = 'SELECT * '.
|
119 |
'FROM gen_site_auth_ldap '.
|
118 |
'FROM gen_site_auth_ldap '.
|
120 |
'WHERE gsal_id_auth_ldap = '.$ligne_auth->gsa_ce_auth_ldap;
|
119 |
'WHERE gsal_id_auth_ldap = '.$ligne_auth->gsa_ce_auth_ldap;
|
Line 123... |
Line 122... |
123 |
(DB::isError($resultat_auth_ldap))
|
122 |
(DB::isError($resultat_auth_ldap))
|
124 |
? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_auth_ldap->getMessage(), $requete_auth_ldap))
|
123 |
? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_auth_ldap->getMessage(), $requete_auth_ldap))
|
125 |
: '';
|
124 |
: '';
|
126 |
$tab_auth_ldap = $resultat_auth_ldap->fetchRow(DB_FETCHMODE_OBJECT);
|
125 |
$tab_auth_ldap = $resultat_auth_ldap->fetchRow(DB_FETCHMODE_OBJECT);
|
127 |
if ($ligne_auth->gsa_id_auth == $_GEN_commun['info_site']->gs_ce_auth) {
|
126 |
if ($ligne_auth->gsa_id_auth == $_GEN_commun['info_site']->gs_ce_auth) {
|
128 |
$_GEN_commun['info_auth_ldap'] = $tab_auth_ldap;
|
127 |
$GLOBALS['_GEN_commun']['info_auth_ldap'] = $tab_auth_ldap;
|
129 |
}
|
128 |
}
|
130 |
$GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth] = array_merge($GLOBALS['_PAPYRUS_']['auth'][$ligne_auth->gsa_id_auth], $tab_auth_ldap);
|
129 |
$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();
|
130 |
$resultat_auth_ldap->free();
|
132 |
} else {
|
131 |
} else {
|
133 |
die('ERREUR Papyrus : impossible de trouver les information authentification. <br />'.
|
132 |
die('ERREUR Papyrus : impossible de trouver les information authentification. <br />'.
|
Line 158... |
Line 157... |
158 |
}
|
157 |
}
|
159 |
}
|
158 |
}
|
160 |
$resultat_auth->free();
|
159 |
$resultat_auth->free();
|
Line 161... |
Line 160... |
161 |
|
160 |
|
162 |
// Nour regardons à quel type d'identification nous avons à faire:
|
161 |
// Nour regardons à quel type d'identification nous avons à faire:
|
163 |
$auth_courante = $GLOBALS['_PAPYRUS_']['auth'][$_GEN_commun['info_site']->gs_ce_auth] ;
|
162 |
$auth_courante = $GLOBALS['_PAPYRUS_']['auth'][$GLOBALS['_GEN_commun']['info_site']->gs_ce_auth] ;
|
164 |
if ($auth_courante['gsa_ce_type_auth'] == 1) {
|
163 |
if ($auth_courante['gsa_ce_type_auth'] == 1) {
|
165 |
// Authentification via une base de données
|
164 |
// Authentification via une base de données
|
166 |
$GLOBALS['_PAPYRUS_']['auth']['param_bdd'] = array ('dsn' => $auth_courante['gsab_dsn'],
|
165 |
$GLOBALS['_PAPYRUS_']['auth']['param_bdd'] = array ('dsn' => $auth_courante['gsab_dsn'],
|
167 |
'table' => $auth_courante['gsab_nom_table'],
|
166 |
'table' => $auth_courante['gsab_nom_table'],
|
168 |
'usernamecol' => $auth_courante['gsab_nom_champ_login'],
|
167 |
'usernamecol' => $auth_courante['gsab_nom_champ_login'],
|
169 |
'passwordcol' => $auth_courante['gsab_nom_champ_mdp'],
|
168 |
'passwordcol' => $auth_courante['gsab_nom_champ_mdp'],
|
170 |
'cryptType' => $auth_courante['gsab_cryptage_mdp'],
|
169 |
'cryptType' => $auth_courante['gsab_cryptage_mdp'],
|
171 |
'db_fields' => '*');
|
170 |
'db_fields' => '*');
|
172 |
// L'authentification courrante
|
171 |
// L'authentification courrante
|
Line 173... |
Line 172... |
173 |
$_GEN_commun['pear_auth'] = new Auth('DB', $GLOBALS['_PAPYRUS_']['auth']['param_bdd'], 'GEN_afficherInfoIdentification', 1);
|
172 |
$GLOBALS['_GEN_commun']['pear_auth'] = new Auth('DB', $GLOBALS['_PAPYRUS_']['auth']['param_bdd'], 'GEN_afficherInfoIdentification', 1);
|
174 |
|
173 |
|
175 |
} else if ($auth_courante['gsa_ce_type_auth'] == 2) {
|
174 |
} else if ($auth_courante['gsa_ce_type_auth'] == 2) {
|
176 |
// Authentification via LDAP
|
175 |
// Authentification via LDAP
|
177 |
$GLOBALS['_PAPYRUS_']['auth']['param_ldap'] = array ( 'host' => $auth_courante['gsal_serveur'],
|
176 |
$GLOBALS['_PAPYRUS_']['auth']['param_ldap'] = array ( 'host' => $auth_courante['gsal_serveur'],
|
178 |
'port' => $auth_courante['gsal_port'],
|
177 |
'port' => $auth_courante['gsal_port'],
|
179 |
'basedn' => $auth_courante['gsal_base_dn'],
|
178 |
'basedn' => $auth_courante['gsal_base_dn'],
|
180 |
'userattr' => $auth_courante['gsal_uid']);
|
179 |
'userattr' => $auth_courante['gsal_uid']);
|
181 |
$_GEN_commun['pear_auth'] = new Auth('LDAP', $GLOBALS['_PAPYRUS_']['auth']['param_ldap'], 'GEN_afficherInfoIdentification', 1);
|
180 |
$GLOBALS['_GEN_commun']['pear_auth'] = new Auth('LDAP', $GLOBALS['_PAPYRUS_']['auth']['param_ldap'], 'GEN_afficherInfoIdentification', 1);
|
182 |
} else {
|
181 |
} else {
|
183 |
die('ERREUR Papyrus : type identification introuvable. <br />'.
|
182 |
die('ERREUR Papyrus : type identification introuvable. <br />'.
|
184 |
'Type identification : '.$auth_courante['gsa_ce_type_auth'].'<br />'.
|
183 |
'Type identification : '.$auth_courante['gsa_ce_type_auth'].'<br />'.
|
185 |
'Ligne n° : '. __LINE__ . '<br />'.
|
184 |
'Ligne n° : '. __LINE__ . '<br />'.
|
Line 186... |
Line 185... |
186 |
'Fichier : '. __FILE__ . '<br />');
|
185 |
'Fichier : '. __FILE__ . '<br />');
|
Line 187... |
Line 186... |
187 |
}
|
186 |
}
|
188 |
|
187 |
|
Line 189... |
Line 188... |
189 |
$_GEN_commun['pear_auth']->setSessionname( 'gen_'.$_GEN_commun['info_auth']->gsa_abreviation);
|
188 |
$GLOBALS['_GEN_commun']['pear_auth']->setSessionname( 'gen_'.$GLOBALS['_GEN_commun']['info_auth']->gsa_abreviation);
|
190 |
|
189 |
|
Line 191... |
Line 190... |
191 |
// Pour que la session dure même après avoir refermer son navigateur
|
190 |
// Pour que la session dure même après avoir refermer son navigateur
|
Line 192... |
Line 191... |
192 |
session_set_cookie_params(3600 * 24 * 30 * 6);
|
191 |
session_set_cookie_params(3600 * 24 * 30 * 6);
|
193 |
|
192 |
|
194 |
// Expiration si l'utilisateur ne referme pas son navigateur
|
193 |
// Expiration si l'utilisateur ne referme pas son navigateur
|
Line 216... |
Line 215... |
216 |
if ($tab_valeur[0] == 'chemin_cookie_spip') $chemin_cookie_spip = $tab_valeur[1] ;
|
215 |
if ($tab_valeur[0] == 'chemin_cookie_spip') $chemin_cookie_spip = $tab_valeur[1] ;
|
217 |
}
|
216 |
}
|
218 |
}
|
217 |
}
|
219 |
}
|
218 |
}
|
220 |
// Début initialisation de la gestion SPIP
|
219 |
// Début initialisation de la gestion SPIP
|
221 |
if (isset ($chemin_spip) && isset ($coauth) && $coauth == $auth_courante['gsab_id_auth_bdd']&& $_GEN_commun['pear_auth']->getAuth()) {
|
220 |
if (isset ($chemin_spip) && isset ($coauth) && $coauth == $auth_courante['gsab_id_auth_bdd']&& $GLOBALS['_GEN_commun']['pear_auth']->getAuth()) {
|
222 |
$login = $_GEN_commun['pear_auth']->getUsername() ;
|
221 |
$login = $GLOBALS['_GEN_commun']['pear_auth']->getUsername() ;
|
- |
|
222 |
|
- |
|
223 |
setcookie('spip_admin', '@'.$login, time() + 3600 * 24 * 30, '/'.$chemin_cookie_spip.'/');
|
Line 223... |
Line -... |
223 |
|
- |
|
224 |
setcookie('spip_admin', '@'.$login, time()+3600*24*30, '/'.$chemin_cookie_spip.'/');
|
- |
|
225 |
|
224 |
|
226 |
$query = 'SELECT * FROM spip_auteurs WHERE login = "'.$login.'"';
|
225 |
$query = 'SELECT * FROM spip_auteurs WHERE login = "'.$login.'"';
|
227 |
$result = $db->query($query);
|
226 |
$result = $db->query($query);
|
228 |
$GLOBALS['auteur_session'] = $result->fetchRow(DB_FETCHMODE_ASSOC);
|
227 |
$GLOBALS['auteur_session'] = $result->fetchRow(DB_FETCHMODE_ASSOC);
|
229 |
$GLOBALS['auteur_session']['statut'] = '1comite';
|
228 |
$GLOBALS['auteur_session']['statut'] = '1comite';
|
230 |
$GLOBALS['auteur_session']['lang'] = 'fr';
|
229 |
$GLOBALS['auteur_session']['lang'] = 'fr';
|
231 |
|
230 |
|
232 |
$userid = $GLOBALS['auteur_session']['id_auteur'];
|
231 |
$userid = $GLOBALS['auteur_session']['id_auteur'];
|
233 |
$GLOBALS['__auteur_session__'] = $GLOBALS['auteur_session'];
|
232 |
$GLOBALS['__auteur_session__'] = $GLOBALS['auteur_session'];
|
234 |
if (!$HTTP_COOKIE_VARS["spip_session"]) {
|
233 |
if (!$HTTP_COOKIE_VARS["spip_session"]) {
|
235 |
$id_session = $GLOBALS['auteur_session']['id_auteur']."_".(md5 (uniqid (rand ())));
|
234 |
$id_session = $GLOBALS['auteur_session']['id_auteur']."_".(md5 (uniqid (rand ())));
|
236 |
setcookie("spip_session", $id_session, time()+3600*24*30, "/$chemin_cookie_spip/") ;
|
235 |
setcookie("spip_session", $id_session, time() + 3600 * 24 * 30, "/$chemin_cookie_spip/") ;
|
237 |
|
236 |
|
238 |
} else {
|
237 |
} else {
|
239 |
$id_session = preg_replace("/[0-9]+_/", $userid."_", $HTTP_COOKIE_VARS["spip_session"]) ;
|
238 |
$id_session = preg_replace("/[0-9]+_/", $userid."_", $HTTP_COOKIE_VARS["spip_session"]) ;
|
240 |
setcookie("spip_session", $id_session, time()+3600*24*30, "/$chemin_cookie_spip/") ;
|
239 |
setcookie('spip_session', $id_session, time() + 3600 * 24 * 30, "/$chemin_cookie_spip/") ;
|
Line 241... |
Line 240... |
241 |
}
|
240 |
}
|
242 |
|
- |
|
243 |
set_include_path(get_include_path().":".$chemin_spip) ;
|
- |
|
Line -... |
Line 241... |
- |
|
241 |
|
244 |
|
242 |
set_include_path(get_include_path().':'.$chemin_spip);
|
245 |
include_once 'ecrire/inc_db_mysql.php3' ;
|
243 |
|
Line 246... |
Line 244... |
246 |
|
244 |
include_once 'ecrire/inc_db_mysql.php3';
|
247 |
include_once ("ecrire/inc_version.php3");
|
245 |
include_once 'ecrire/inc_version.php3';
|
Line 248... |
Line 246... |
248 |
ob_flush() ; // Nécessaire car spip utilise un ob_start() et cela cause un plantage
|
246 |
ob_flush();// Nécessaire car spip utilise un ob_start() et cela cause un plantage
|
249 |
|
247 |
|
Line 250... |
Line 248... |
250 |
include_ecrire ("inc_meta.php3");
|
248 |
include_ecrire ('inc_meta.php3');
|
Line 251... |
Line 249... |
251 |
include_ecrire ("inc_session.php3");
|
249 |
include_ecrire ('inc_session.php3');
|
252 |
|
250 |
|
Line 272... |
Line 270... |
272 |
}
|
270 |
}
|
Line 273... |
Line 271... |
273 |
|
271 |
|
274 |
|
272 |
|
- |
|
273 |
/* +--Fin du code ---------------------------------------------------------------------------------------+
|
- |
|
274 |
* $Log: not supported by cvs2svn $
|
- |
|
275 |
* Revision 1.15 2005/03/24 15:04:26 alex
|
275 |
/* +--Fin du code ---------------------------------------------------------------------------------------+
|
276 |
* ajout d'un appel à session_set_cookie_params pour allonger la durée de la session
|
276 |
* $Log: not supported by cvs2svn $
|
277 |
*
|
277 |
* Revision 1.14 2005/03/15 14:20:01 jpm
|
278 |
* Revision 1.14 2005/03/15 14:20:01 jpm
|
278 |
* Gestion des arguments de l'identification courante.
|
279 |
* Gestion des arguments de l'identification courante.
|
279 |
*
|
280 |
*
|