From dba0114bd5db41669e1d6fce466df5e100a3c4f8 Mon Sep 17 00:00:00 2001 From: "Committo,Ergo:sum" <esj@rezo.net> Date: Mon, 15 Oct 2007 16:29:20 +0000 Subject: [PATCH] =?UTF-8?q?Pb=20pour=20le=20multi-base=20de=202=20sites=20?= =?UTF-8?q?sous=20LDAP:=20on=20ne=20peut=20charger=20le=20connect.php=20du?= =?UTF-8?q?=202e=20site,=20car=20=C3=A7a=20d=C3=A9finit=20=C3=A0=20nouveau?= =?UTF-8?q?=20la=20fonction=20spip=5Fconnect=5Fldap.=20En=20cons=C3=A9quen?= =?UTF-8?q?ce,=20cette=20d=C3=A9finition=20et=20informations=20connexes=20?= =?UTF-8?q?migrent=20dans=20un=20nouveau=20fichier,=20par=20d=C3=A9faut=20?= =?UTF-8?q?confif/ldap.php.=20Ne=20reste=20dans=20connect.php=20que=20l'af?= =?UTF-8?q?fectation=20de=20la=20globale=20'''ldap=5Fpresent''',=20pour=20?= =?UTF-8?q?pr=C3=A9venir=20que=20ce=202e=20fichier=20est=20=C3=A0=20charge?= =?UTF-8?q?r.=20Ca=20r=C3=A8gle=20le=20probl=C3=A8me=20=20pour=202=20sites?= =?UTF-8?q?=20sous=20le=20m=C3=AAme=20LDAP,=20=C3=A7a=20ne=20fera=20que=20?= =?UTF-8?q?le=20rendre=20moins=20voyant=20pour=20les=20autres.=20A=20suivr?= =?UTF-8?q?e=20donc.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecrire/inc/admin.php | 8 ++++---- ecrire/inc/auth_ldap.php | 1 + ecrire/inc/utils.php | 2 ++ ecrire/install/etape_ldap1.php | 5 ++--- ecrire/install/etape_ldap4.php | 32 ++++++++++++++++---------------- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/ecrire/inc/admin.php b/ecrire/inc/admin.php index 3d48d4503b..125d32f9ce 100644 --- a/ecrire/inc/admin.php +++ b/ecrire/inc/admin.php @@ -59,12 +59,12 @@ function admin_verifie_session($script) { include_spip('base/abstract_sql'); $pref = sprintf("_%d_",$GLOBALS['auteur_session']['id_auteur']); $signal = fichier_admin($script, "$script$pref"); - $row = sql_fetsel('valeur', 'spip_meta', "nom='admin'"); - if (!$row) { + $valeur = sql_getfetsel('valeur', 'spip_meta', "nom='admin'"); + if ($valeur === NULL) { ecrire_meta('admin', $signal,'non'); } else { - if (($s = $row['valeur']) != $signal) { - if (intval(substr($s, strpos($s,'_')+1))<> + if ($valeur != $signal) { + if (intval(substr($valeur, strpos($valeur,'_')+1))<> $GLOBALS['auteur_session']['id_auteur']) { include_spip('inc/minipres'); echo minipres(_T('info_travaux_texte')); diff --git a/ecrire/inc/auth_ldap.php b/ecrire/inc/auth_ldap.php index 6fb8a02b22..81917ab99d 100644 --- a/ecrire/inc/auth_ldap.php +++ b/ecrire/inc/auth_ldap.php @@ -11,6 +11,7 @@ \***************************************************************************/ if (!defined("_ECRIRE_INC_VERSION")) return; +include_once(_DIR_CONNECT . 'ldap.php'); // Authentifie via LDAP et retourne la ligne SQL decrivant l'utilisateur si ok diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php index 08bb4914fa..52dda9166e 100644 --- a/ecrire/inc/utils.php +++ b/ecrire/inc/utils.php @@ -1224,6 +1224,8 @@ function spip_initialisation($pi=NULL, $pa=NULL, $ti=NULL, $ta=NULL) { (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f : false)); + define('_FILE_LDAP', _DIR_CONNECT . 'ldap' . '.php'); + define('_FILE_TMP_SUFFIX', '.tmp.php'); define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); diff --git a/ecrire/install/etape_ldap1.php b/ecrire/install/etape_ldap1.php index 0ffa351a61..aab4a1aabf 100644 --- a/ecrire/install/etape_ldap1.php +++ b/ecrire/install/etape_ldap1.php @@ -37,10 +37,9 @@ function install_etape_ldap1_dist() ? _INSTALL_PASS_LDAP : ''; - // Recuperer les anciennes donnees (si presentes) - if (@file_exists(_FILE_CONNECT_INS . _FILE_TMP . '.php')) { - $s = @join('', @file(_FILE_CONNECT_INS . _FILE_TMP . '.php')); + if (@file_exists(_FILE_LDAP)) { + $s = @join('', @file(_FILE_LDAP)); if (preg_match('#ldap_connect\("(.*)","(.*)"\)#', $s, $regs)) { $adresse_ldap = $regs[1]; $port_ldap = $regs[2]; diff --git a/ecrire/install/etape_ldap4.php b/ecrire/install/etape_ldap4.php index 74029bc090..6a97d7ed80 100644 --- a/ecrire/install/etape_ldap4.php +++ b/ecrire/install/etape_ldap4.php @@ -42,24 +42,24 @@ function install_etape_ldap4_dist() info_etape(_T('info_reglage_ldap')); lire_fichier(_FILE_CONNECT_TMP, $conn); - if ($p = strpos($conn, '?'.'>')) - $conn = substr($conn, 0, $p); if (!strpos($conn, 'spip_connect_ldap')) { - $conn .= "function spip_connect_ldap() {\n"; - $conn .= "\t\$GLOBALS['ldap_link'] = @ldap_connect(\"$adresse_ldap\",\"$port_ldap\");\n"; - $conn .= "\t@ldap_set_option(\$GLOBALS['ldap_link'],LDAP_OPT_PROTOCOL_VERSION,\"$protocole_ldap\");\n"; - if ($tls_ldap == 'oui') - $conn .= "\t@ldap_start_tls(\$GLOBALS['ldap_link']);\n"; - - - $conn .= "\t@ldap_bind(\$GLOBALS['ldap_link'],\"$login_ldap\",\"$pass_ldap\");\n"; - $conn .= "\treturn \$GLOBALS['ldap_link'];\n"; - $conn .= "}\n"; - $conn .= "\$GLOBALS['ldap_base'] = \"$base_ldap\";\n"; - $conn .= "\$GLOBALS['ldap_present'] = true;\n"; + $p = strpos($conn, '?'.'>'); + $conn = substr($conn, 0, $p) + . "\$GLOBALS['ldap_present'] = true;\n" + . '?'.'>'; + ecrire_fichier(_FILE_CONNECT_TMP, $conn); } - $conn .= "?".">"; - ecrire_fichier(_FILE_CONNECT_TMP, $conn); + $conn = "function spip_connect_ldap() {\n" + . "\t\$GLOBALS['ldap_link'] = @ldap_connect(\"$adresse_ldap\",\"$port_ldap\");\n" + . "\t@ldap_set_option(\$GLOBALS['ldap_link'],LDAP_OPT_PROTOCOL_VERSION,\"$protocole_ldap\");\n" + . (($tls_ldap != 'oui') ? '' : + "\t@ldap_start_tls(\$GLOBALS['ldap_link']);\n") + . "\t@ldap_bind(\$GLOBALS['ldap_link'],\"$login_ldap\",\"$pass_ldap\");\n" + . "\treturn \$GLOBALS['ldap_link'];\n" + . "}\n" + . "\$GLOBALS['ldap_base'] = \"$base_ldap\";\n"; + + install_fichier_connexion(_FILE_LDAP, $conn); $statuts = liste_statuts_ldap(); $statut_ldap = defined('_INSTALL_STATUT_LDAP') ? _INSTALL_STATUT_LDAP -- GitLab