From cfd96cf9966b95d604a24b11f64a33c00ac27b35 Mon Sep 17 00:00:00 2001 From: "Committo,Ergo:sum" <esj@rezo.net> Date: Sun, 3 Jun 2007 05:29:32 +0000 Subject: [PATCH] =?UTF-8?q?Dans=20la=20lign=C3=A9e=20de=20[9310]=20(bonne?= =?UTF-8?q?=20id=C3=A9e,=20Fil),=20les=20scripts=20d'installation=20avec?= =?UTF-8?q?=20LDAP=20tiennent=20compte=20de=20constantes=20donn=C3=A9es=20?= =?UTF-8?q?dans=20mes=5Foptions:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit define('_INSTALL_HOST_LDAP', "truc.ldap.pi"); define('_INSTALL_PORT_LDAP', "389"); define('_INSTALL_PROTOCOLE_LDAP', '3'); define('_INSTALL_TLS_LDAP', 'oui'); define('_INSTALL_BASE_LDAP', "ou=XX,dc=NN"); De plus, à la fin de la séquence de configuration du LDAP, SPIP repropose l'authentification standard (sans plus montrer le choix LDAP) pour pouvoir définir un administrateur qui pourra se connecter meme en cas de défaillance du LDAP. Un peu de tache #587 au passage (d'autant que des 302 après echo, fallait pas y compter) et de #877 (bilan actuel: 509, 951, 1289). --- ecrire/install/etape_3.php | 193 ++++++++++++++++----------------- ecrire/install/etape_ldap1.php | 29 ++++- ecrire/install/etape_ldap2.php | 14 ++- ecrire/install/etape_ldap3.php | 9 +- ecrire/install/etape_ldap4.php | 8 +- ecrire/install/etape_ldap5.php | 3 +- 6 files changed, 147 insertions(+), 109 deletions(-) diff --git a/ecrire/install/etape_3.php b/ecrire/install/etape_3.php index 90f3ba719b..07731cd521 100644 --- a/ecrire/install/etape_3.php +++ b/ecrire/install/etape_3.php @@ -14,7 +14,6 @@ if (!defined("_ECRIRE_INC_VERSION")) return; #securite include_spip('inc/headers'); function install_bases(){ - global $spip_lang_right, $spip_version; $adresse_db = defined('_INSTALL_HOST_DB') ? _INSTALL_HOST_DB @@ -58,9 +57,6 @@ function install_bases(){ $link = mysql_connect($adresse_db, $login_db, $pass_db); - echo "<"."!-- $link "; - echo "(".$GLOBALS['table_prefix'].")"; - if ($choix_db == "new_spip") { $sel_db = _request('table_new'); if (preg_match(',^[a-z_0-9-]+$,i', $sel_db)) @@ -69,8 +65,6 @@ function install_bases(){ else { $sel_db = $choix_db; } - echo "$sel_db "; - mysql_select_db($sel_db); spip_query("SELECT COUNT(*) FROM spip_meta"); $nouvelle = spip_sql_errno(); @@ -87,17 +81,18 @@ function install_bases(){ creer_base(); include_spip('base/upgrade'); maj_base(); - + // Tester $mysql_rappel_nom_base $GLOBALS['mysql_rappel_nom_base'] = true; $GLOBALS['spip_mysql_db'] = $sel_db; $ok_rappel_nom = spip_query("INSERT INTO spip_meta (nom,valeur) VALUES ('mysql_rappel_nom_base', 'test')"); if ($ok_rappel_nom) { - echo " (ok rappel nom base `$sel_db`.spip_meta) "; + $res =''; $ligne_rappel = ''; spip_query("DELETE FROM spip_meta WHERE nom='mysql_rappel_nom_base'"); } else { - echo " (erreur rappel nom base `$sel_db`.spip_meta $nouvelle) "; + $res = " $link (". $GLOBALS['table_prefix'] + . ") $sel_db (erreur rappel nom base `$sel_db`.spip_meta $nouvelle) "; $GLOBALS['mysql_rappel_nom_base'] = false; $ligne_rappel = "\$GLOBALS['mysql_rappel_nom_base'] = false; ". "/* echec du test sur `$sel_db`.spip_meta lors de l'installation. */\n"; @@ -116,25 +111,25 @@ function install_bases(){ spip_query("INSERT INTO spip_meta (nom, valeur, impt) VALUES ('charset_sql_connexion', '".$GLOBALS['meta']['charset_sql_connexion']."', 'non')"); spip_query("INSERT INTO spip_meta (nom, valeur) VALUES ('nouvelle_install', '1')"); - $result_ok = !spip_sql_errno(); + $result_ko = spip_sql_errno(); } else { // en cas de reinstall sur mise a jour mal passee - spip_query("DELETE FROM spip_meta WHERE nom='import_all'"); + spip_query("DELETE FROM spip_meta WHERE nom='import_all'"); $result = spip_query("SELECT COUNT(*) FROM spip_articles"); - $result_ok = (spip_num_rows($result) > 0); + $result_ko = (spip_num_rows($result) == 0); } - echo "($result_ok) -->"; - if($chmod) { - $conn = "<"."?php\n"; - $conn .= "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"; - $conn .= "@define('_SPIP_CHMOD', ". sprintf('0%3o',$chmod).");\n"; - $conn .= "?".">"; - if (!ecrire_fichier(_FILE_CHMOD_INS . _FILE_TMP . '.php', + if (!$result_ko) { + if($chmod) { + $conn = "<"."?php\n"; + $conn .= "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"; + $conn .= "@define('_SPIP_CHMOD', ". sprintf('0%3o',$chmod).");\n"; + $conn .= "?".">"; + if (!ecrire_fichier(_FILE_CHMOD_INS . _FILE_TMP . '.php', $conn)) - redirige_par_entete(generer_url_ecrire('install')); - } - if ($result_ok) { + redirige_par_entete(generer_url_ecrire('install')); + } + if (preg_match(',(.*):(.*),', $adresse_db, $r)) list(,$adresse_db, $port) = $r; else @@ -152,75 +147,12 @@ function install_bases(){ $conn)) redirige_par_entete(generer_url_ecrire('install')); } - return $result_ok; + return $result_ko ? "<!--\n$res\n-->" : ''; } - -function install_etape_3_dist() +function install_propose_ldap() { - global $email, $ldap_present, $login, $nom, $pass, $spip_lang_right; - - echo install_debut_html(); - $result_ok = install_bases(); - if ($result_ok) { - echo "<p class='resultat'><b>"._T('info_base_installee')."</b></p>"; - - if (@file_exists(_FILE_CONNECT_INS . _FILE_TMP . '.php')) - include(_FILE_CONNECT_INS . _FILE_TMP . '.php'); - else - redirige_par_entete(generer_url_ecrire('install')); - - if (@file_exists(_FILE_CHMOD_INS . _FILE_TMP . '.php')) - include(_FILE_CHMOD_INS . _FILE_TMP . '.php'); - else - redirige_par_entete(generer_url_ecrire('install')); - - echo info_etape(_T('info_informations_personnelles'), - "<b>"._T('texte_informations_personnelles_1')."</b>" . - aide ("install5") . - "</p><p>" . - _T('texte_informations_personnelles_2') . " " . - _T('info_laisser_champs_vides') - ); - - echo generer_form_ecrire('install', ( - - "\n<input type='hidden' name='etape' value='4' />" - - . fieldset(_T('info_identification_publique'), - array( - 'nom' => array( - 'label' => "<b>"._T('entree_signature')."</b><br />\n"._T('entree_nom_pseudo_1')."\n", - 'valeur' => $nom - ), - 'email' => array( - 'label' => "<b>"._T('entree_adresse_email')."</b>\n", - 'valeur' => $email - ) - ) - ) - - . fieldset(_T('entree_identifiants_connexion'), - array( - 'login' => array( - 'label' => "<b>"._T('entree_login')."</b><br />\n"._T('info_plus_trois_car')."\n", - 'valeur' => $login - ), - 'pass' => array( - 'label' => "<b>"._T('entree_mot_passe')."</b><br />\n"._T('info_plus_cinq_car_2')."\n", - 'valeur' => $pass - ), - 'pass_verif' => array( - 'label' => "<b>"._T('info_confirmer_passe')."</b><br />\n", - 'valeur' => $pass - ) - ) - ) - - . bouton_suivant())); - - if (function_exists('ldap_connect') AND !$ldap_present) { - echo generer_form_ecrire('install', ( + return generer_form_ecrire('install', ( fieldset(_T('info_authentification_externe'), array( 'etape' => array( @@ -230,17 +162,84 @@ function install_etape_3_dist() )), bouton_suivant(_T('bouton_acces_ldap')) ))); - } - } - else if ($result_ok) { - echo _T('alerte_maj_impossible', array('version' => $spip_version)); - } - else { - echo "<p class='resultat'><b>"._T('avis_operation_echec')."</b></p>"._T('texte_operation_echec'); - } +} + + +function install_premier_auteur($email, $login, $nom, $pass) +{ + if (file_exists(_FILE_CONNECT_INS . _FILE_TMP . '.php')) + include(_FILE_CONNECT_INS . _FILE_TMP . '.php'); + else + redirige_par_entete(generer_url_ecrire('install', 'connect=1')); + + if (file_exists(_FILE_CHMOD_INS . _FILE_TMP . '.php')) + include(_FILE_CHMOD_INS . _FILE_TMP . '.php'); + else + redirige_par_entete(generer_url_ecrire('install', 'chmod=1')); + + return "<p class='resultat'><b>" + . _T('info_base_installee') + . "</b></p>" + . info_etape(_T('info_informations_personnelles'), + "<b>"._T('texte_informations_personnelles_1')."</b>" . + aide ("install5") . + "</p><p>" . + _T('texte_informations_personnelles_2') . " " . + _T('info_laisser_champs_vides') + ) + . generer_form_ecrire('install', ( + "\n<input type='hidden' name='etape' value='4' />" + . fieldset(_T('info_identification_publique'), + array( + 'nom' => array( + 'label' => "<b>"._T('entree_signature')."</b><br />\n"._T('entree_nom_pseudo_1')."\n", + 'valeur' => $nom + ), + 'email' => array( + 'label' => "<b>"._T('entree_adresse_email')."</b>\n", + 'valeur' => $email + ) + ) + ) + + . fieldset(_T('entree_identifiants_connexion'), + array( + 'login' => array( + 'label' => "<b>"._T('entree_login')."</b><br />\n"._T('info_plus_trois_car')."\n", + 'valeur' => $login + ), + 'pass' => array( + 'label' => "<b>"._T('entree_mot_passe')."</b><br />\n"._T('info_plus_cinq_car_2')."\n", + 'valeur' => $pass + ), + 'pass_verif' => array( + 'label' => "<b>"._T('info_confirmer_passe')."</b><br />\n", + 'valeur' => $pass + ) + ) + ) + . bouton_suivant())); +} + +function install_etape_3_dist() +{ + $ldap_present = _request('ldap_present'); + $res = $ldap_present ? '' : install_bases(); + if (!function_exists('ldap_connect')) $ldap_present = true; + + if ($res) + $res .= "<p class='resultat'><b>"._T('avis_operation_echec')."</b></p>"._T('texte_operation_echec'); + + else $res = install_premier_auteur(_request('email'), + _request('login'), + _request('nom'), + _request('pass')) + . ($ldap_present ? '' : install_propose_ldap()); + + echo install_debut_html(); + echo $res; echo info_progression_etape(3,'etape_','install/'); echo install_fin_html(); } - ?> diff --git a/ecrire/install/etape_ldap1.php b/ecrire/install/etape_ldap1.php index cd4d6a5c3d..0ffa351a61 100644 --- a/ecrire/install/etape_ldap1.php +++ b/ecrire/install/etape_ldap1.php @@ -13,11 +13,30 @@ // http://doc.spip.org/@inc_install_ldap1 function install_etape_ldap1_dist() { - global $spip_lang_right; + $adresse_ldap = defined('_INSTALL_HOST_LDAP') + ? _INSTALL_HOST_LDAP + : 'localhost'; + + $port_ldap = defined('_INSTALL_PORT_LDAP') + ? _INSTALL_PORT_LDAP + : 389; + + $tls_ldap = defined('_INSTALL_TLS_LDAP') + ? _INSTALL_TLS_LDAP + : 'non'; + + $protocole_ldap = defined('_INSTALL_PROTOCOLE_LDAP') + ? _INSTALL_PROTOCOLE_LDAP + : 3 ; // on essaie 2 en cas d'echec + + $login_ldap = defined('_INSTALL_USER_LDAP') + ? _INSTALL_USER_LDAP + : ''; + + $pass_ldap = defined('_INSTALL_PASS_LDAP') + ? _INSTALL_PASS_LDAP + : ''; - $protocole_ldap = 3; // on essaie 2 en cas d'echec - $adresse_ldap = 'localhost'; - $port_ldap = 389; // Recuperer les anciennes donnees (si presentes) if (@file_exists(_FILE_CONNECT_INS . _FILE_TMP . '.php')) { @@ -46,7 +65,7 @@ function install_etape_ldap1_dist() ), 'tls_ldap' => array( 'label' => '<b>'._T('tls_ldap').'</b>', - 'valeur' => 'non', + 'valeur' => $tls_ldap, 'alternatives' => array( 'non' => _T('item_non'), 'oui' => _T('item_oui') diff --git a/ecrire/install/etape_ldap2.php b/ecrire/install/etape_ldap2.php index 6b9877b869..69608b39b4 100644 --- a/ecrire/install/etape_ldap2.php +++ b/ecrire/install/etape_ldap2.php @@ -14,10 +14,20 @@ // http://doc.spip.org/@inc_install_ldap2 function install_etape_ldap2_dist() { - global $adresse_ldap, $login_ldap, $pass_ldap, $port_ldap, $tls_ldap, $protocole_ldap, $spip_lang_right; - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); + $adresse_ldap = _request('adresse_ldap'); + + $port_ldap = _request('port_ldap'); + + $tls_ldap = _request('tls_ldap'); + + $protocole_ldap = _request('protocole_ldap'); + + $login_ldap = _request('login_ldap'); + + $pass_ldap = _request('pass_ldap'); + $port_ldap = intval($port_ldap); $ldap_link = @ldap_connect($adresse_ldap, $port_ldap); $erreur = "ldap_connect($adresse_ldap, $port_ldap)"; diff --git a/ecrire/install/etape_ldap3.php b/ecrire/install/etape_ldap3.php index 85df259c9b..75858f3c29 100644 --- a/ecrire/install/etape_ldap3.php +++ b/ecrire/install/etape_ldap3.php @@ -14,7 +14,12 @@ // http://doc.spip.org/@inc_install_ldap3 function install_etape_ldap3_dist() { - global $adresse_ldap, $login_ldap, $pass_ldap, $port_ldap, $tls_ldap, $protocole_ldap, $spip_lang_right; + global $adresse_ldap, $login_ldap, $pass_ldap, $port_ldap, $tls_ldap, $protocole_ldap; + + + $base_ldap_text = defined('_INSTALL_BASE_LDAP') + ? _INSTALL_BASE_LDAP + : "ou=users, dc=mon-domaine, dc=com"; echo install_debut_html(); @@ -68,7 +73,7 @@ function install_etape_ldap3_dist() . "\n<input type='hidden' name='tls_ldap' value=\"$tls_ldap\" />" . "\n<fieldset>" - . "<input type='text' name='base_ldap_text' class='formo' value=\"ou=users, dc=mon-domaine, dc=com\" size='40' />" + . "<input type='text' name='base_ldap_text' class='formo' value=\"$base_ldap_text\" size='40' />" . "\n</fieldset>" . bouton_suivant())); diff --git a/ecrire/install/etape_ldap4.php b/ecrire/install/etape_ldap4.php index b8a5236eb3..775b9c8a23 100644 --- a/ecrire/install/etape_ldap4.php +++ b/ecrire/install/etape_ldap4.php @@ -13,10 +13,14 @@ // http://doc.spip.org/@inc_install_ldap4 function install_etape_ldap4_dist() { - global $adresse_ldap, $login_ldap, $pass_ldap, $port_ldap, $tls_ldap, $protocole_ldap, $base_ldap, $base_ldap_text, $spip_lang_right; + global $adresse_ldap, $login_ldap, $pass_ldap, $port_ldap, $tls_ldap, $protocole_ldap, $base_ldap, $base_ldap_text; echo install_debut_html(); + $statut_ldap = defined('_INSTALL_STATUT_LDAP') + ? _INSTALL_STATUT_LDAP + : '1comite'; + if (!$base_ldap) $base_ldap = $base_ldap_text; $ldap_link = @ldap_connect("$adresse_ldap", "$port_ldap"); @@ -61,7 +65,7 @@ function install_etape_ldap4_dist() array( 'statut_ldap' => array( 'label' => _T('info_statut_utilisateurs_2').'<br />', - 'valeur' => '1comite', + 'valeur' => $statut_ldap, 'alternatives' => liste_statuts_ldap() ) ) diff --git a/ecrire/install/etape_ldap5.php b/ecrire/install/etape_ldap5.php index aa5b088860..159f2a8f24 100644 --- a/ecrire/install/etape_ldap5.php +++ b/ecrire/install/etape_ldap5.php @@ -34,7 +34,8 @@ function install_etape_ldap5_dist() echo info_etape(_T('info_ldap_ok'), _T('info_terminer_installation')); echo generer_form_ecrire('install', ( - "<input type='hidden' name='etape' value='4' />" + "<input type='hidden' name='etape' value='3' />" . + "<input type='hidden' name='ldap_present' value='true' />" . bouton_suivant())); echo info_progression_etape(5,'etape_ldap','install/'); -- GitLab