@@ -11,98 +11,98 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('auth/ldap'); |
| 18 | 18 | |
| 19 | 19 | // https://code.spip.net/@install_etape_ldap4_dist |
| 20 | 20 | function install_etape_ldap4_dist() { |
| 21 | - $adresse_ldap = _request('adresse_ldap'); |
|
| 22 | - $login_ldap = _request('login_ldap'); |
|
| 23 | - $pass_ldap = _request('pass_ldap'); |
|
| 24 | - $port_ldap = _request('port_ldap'); |
|
| 25 | - $base_ldap = _request('base_ldap'); |
|
| 26 | - $base_ldap_text = _request('base_ldap_text'); |
|
| 27 | - if (!$base_ldap) { |
|
| 28 | - $base_ldap = $base_ldap_text; |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 32 | - |
|
| 33 | - $ldap_link = ldap_connect($adresse_ldap, $port_ldap); |
|
| 34 | - @ldap_bind($ldap_link, $login_ldap, $pass_ldap); |
|
| 35 | - |
|
| 36 | - // Essayer de verifier le chemin fourni |
|
| 37 | - $r = @ldap_compare($ldap_link, $base_ldap, 'objectClass', ''); |
|
| 38 | - $fail = (ldap_errno($ldap_link) == 32); |
|
| 39 | - |
|
| 40 | - if ($fail) { |
|
| 41 | - echo info_etape(_T('info_chemin_acces_annuaire')), |
|
| 42 | - info_progression_etape(3, 'etape_ldap', 'install/', true), |
|
| 43 | - "<div class='error'><p><b>" . _T('avis_operation_echec') . '</b></p><p>' . _T('avis_chemin_invalide_1'), |
|
| 44 | - ' (<tt>' . spip_htmlspecialchars($base_ldap) . '</tt>) ' . _T('avis_chemin_invalide_2') . '</p></div>'; |
|
| 45 | - } else { |
|
| 46 | - info_etape(_T('info_reglage_ldap')); |
|
| 47 | - echo info_progression_etape(4, 'etape_ldap', 'install/'); |
|
| 48 | - |
|
| 49 | - $statuts = liste_statuts_ldap(); |
|
| 50 | - $statut_ldap = defined('_INSTALL_STATUT_LDAP') |
|
| 51 | - ? _INSTALL_STATUT_LDAP |
|
| 52 | - : $GLOBALS['liste_des_statuts']['info_redacteurs']; |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - $res = install_propager(array('adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap')) |
|
| 56 | - . "<input type='hidden' name='etape' value='ldap5' />" |
|
| 57 | - . "<input type='hidden' name='base_ldap' value='" . spip_htmlentities($base_ldap) . "' />" |
|
| 58 | - . fieldset( |
|
| 59 | - _T('info_statut_utilisateurs_1'), |
|
| 60 | - array( |
|
| 61 | - 'statut_ldap' => array( |
|
| 62 | - 'label' => _T('info_statut_utilisateurs_2') . '<br />', |
|
| 63 | - 'valeur' => $statut_ldap, |
|
| 64 | - 'alternatives' => $statuts |
|
| 65 | - ) |
|
| 66 | - ) |
|
| 67 | - ) |
|
| 68 | - . install_ldap_correspondances() |
|
| 69 | - . bouton_suivant(); |
|
| 70 | - |
|
| 71 | - echo generer_form_ecrire('install', $res); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - echo install_fin_html(); |
|
| 21 | + $adresse_ldap = _request('adresse_ldap'); |
|
| 22 | + $login_ldap = _request('login_ldap'); |
|
| 23 | + $pass_ldap = _request('pass_ldap'); |
|
| 24 | + $port_ldap = _request('port_ldap'); |
|
| 25 | + $base_ldap = _request('base_ldap'); |
|
| 26 | + $base_ldap_text = _request('base_ldap_text'); |
|
| 27 | + if (!$base_ldap) { |
|
| 28 | + $base_ldap = $base_ldap_text; |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 32 | + |
|
| 33 | + $ldap_link = ldap_connect($adresse_ldap, $port_ldap); |
|
| 34 | + @ldap_bind($ldap_link, $login_ldap, $pass_ldap); |
|
| 35 | + |
|
| 36 | + // Essayer de verifier le chemin fourni |
|
| 37 | + $r = @ldap_compare($ldap_link, $base_ldap, 'objectClass', ''); |
|
| 38 | + $fail = (ldap_errno($ldap_link) == 32); |
|
| 39 | + |
|
| 40 | + if ($fail) { |
|
| 41 | + echo info_etape(_T('info_chemin_acces_annuaire')), |
|
| 42 | + info_progression_etape(3, 'etape_ldap', 'install/', true), |
|
| 43 | + "<div class='error'><p><b>" . _T('avis_operation_echec') . '</b></p><p>' . _T('avis_chemin_invalide_1'), |
|
| 44 | + ' (<tt>' . spip_htmlspecialchars($base_ldap) . '</tt>) ' . _T('avis_chemin_invalide_2') . '</p></div>'; |
|
| 45 | + } else { |
|
| 46 | + info_etape(_T('info_reglage_ldap')); |
|
| 47 | + echo info_progression_etape(4, 'etape_ldap', 'install/'); |
|
| 48 | + |
|
| 49 | + $statuts = liste_statuts_ldap(); |
|
| 50 | + $statut_ldap = defined('_INSTALL_STATUT_LDAP') |
|
| 51 | + ? _INSTALL_STATUT_LDAP |
|
| 52 | + : $GLOBALS['liste_des_statuts']['info_redacteurs']; |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + $res = install_propager(array('adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap')) |
|
| 56 | + . "<input type='hidden' name='etape' value='ldap5' />" |
|
| 57 | + . "<input type='hidden' name='base_ldap' value='" . spip_htmlentities($base_ldap) . "' />" |
|
| 58 | + . fieldset( |
|
| 59 | + _T('info_statut_utilisateurs_1'), |
|
| 60 | + array( |
|
| 61 | + 'statut_ldap' => array( |
|
| 62 | + 'label' => _T('info_statut_utilisateurs_2') . '<br />', |
|
| 63 | + 'valeur' => $statut_ldap, |
|
| 64 | + 'alternatives' => $statuts |
|
| 65 | + ) |
|
| 66 | + ) |
|
| 67 | + ) |
|
| 68 | + . install_ldap_correspondances() |
|
| 69 | + . bouton_suivant(); |
|
| 70 | + |
|
| 71 | + echo generer_form_ecrire('install', $res); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + echo install_fin_html(); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // https://code.spip.net/@liste_statuts_ldap |
| 78 | 78 | function liste_statuts_ldap() { |
| 79 | - $recom = array( |
|
| 80 | - 'info_administrateurs' => ('<b>' . _T('info_administrateur_1') . '</b> ' . _T('info_administrateur_2') . '<br />'), |
|
| 81 | - 'info_redacteurs' => ('<b>' . _T('info_redacteur_1') . '</b> ' . _T('info_redacteur_2') . '<br />'), |
|
| 82 | - 'info_visiteurs' => ('<b>' . _T('info_visiteur_1') . '</b> ' . _T('info_visiteur_2') . '<br />') |
|
| 83 | - ); |
|
| 84 | - |
|
| 85 | - $res = array(); |
|
| 86 | - foreach ($GLOBALS['liste_des_statuts'] as $k => $v) { |
|
| 87 | - if (isset($recom[$k])) { |
|
| 88 | - $res[$v] = $recom[$k]; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - return $res; |
|
| 79 | + $recom = array( |
|
| 80 | + 'info_administrateurs' => ('<b>' . _T('info_administrateur_1') . '</b> ' . _T('info_administrateur_2') . '<br />'), |
|
| 81 | + 'info_redacteurs' => ('<b>' . _T('info_redacteur_1') . '</b> ' . _T('info_redacteur_2') . '<br />'), |
|
| 82 | + 'info_visiteurs' => ('<b>' . _T('info_visiteur_1') . '</b> ' . _T('info_visiteur_2') . '<br />') |
|
| 83 | + ); |
|
| 84 | + |
|
| 85 | + $res = array(); |
|
| 86 | + foreach ($GLOBALS['liste_des_statuts'] as $k => $v) { |
|
| 87 | + if (isset($recom[$k])) { |
|
| 88 | + $res[$v] = $recom[$k]; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + return $res; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | function install_ldap_correspondances() { |
| 96 | - $champs = array(); |
|
| 97 | - foreach (is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : array() as $champ => $v) { |
|
| 98 | - $nom = 'ldap_' . $champ; |
|
| 99 | - $val = is_array($v) ? join(',', $v) : strval($v); |
|
| 100 | - $champs[$nom] = array( |
|
| 101 | - 'label' => _T('ldap_correspondance', array('champ' => "<tt>$champ</tt>")) . '<br />', |
|
| 102 | - 'valeur' => $val |
|
| 103 | - ); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - return !$champs ? |
|
| 107 | - '' : fieldset(_T('ldap_correspondance_1'), $champs, '', _T('ldap_correspondance_2') . '<br /><br />'); |
|
| 96 | + $champs = array(); |
|
| 97 | + foreach (is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : array() as $champ => $v) { |
|
| 98 | + $nom = 'ldap_' . $champ; |
|
| 99 | + $val = is_array($v) ? join(',', $v) : strval($v); |
|
| 100 | + $champs[$nom] = array( |
|
| 101 | + 'label' => _T('ldap_correspondance', array('champ' => "<tt>$champ</tt>")) . '<br />', |
|
| 102 | + 'valeur' => $val |
|
| 103 | + ); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + return !$champs ? |
|
| 107 | + '' : fieldset(_T('ldap_correspondance_1'), $champs, '', _T('ldap_correspondance_2') . '<br /><br />'); |
|
| 108 | 108 | } |
@@ -11,90 +11,90 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // https://code.spip.net/@install_etape_ldap1_dist |
| 18 | 18 | function install_etape_ldap1_dist() { |
| 19 | - $adresse_ldap = defined('_INSTALL_HOST_LDAP') |
|
| 20 | - ? _INSTALL_HOST_LDAP |
|
| 21 | - : 'localhost'; |
|
| 19 | + $adresse_ldap = defined('_INSTALL_HOST_LDAP') |
|
| 20 | + ? _INSTALL_HOST_LDAP |
|
| 21 | + : 'localhost'; |
|
| 22 | 22 | |
| 23 | - $port_ldap = defined('_INSTALL_PORT_LDAP') |
|
| 24 | - ? _INSTALL_PORT_LDAP |
|
| 25 | - : 389; |
|
| 23 | + $port_ldap = defined('_INSTALL_PORT_LDAP') |
|
| 24 | + ? _INSTALL_PORT_LDAP |
|
| 25 | + : 389; |
|
| 26 | 26 | |
| 27 | - $tls_ldap = defined('_INSTALL_TLS_LDAP') |
|
| 28 | - ? _INSTALL_TLS_LDAP |
|
| 29 | - : 'non'; |
|
| 27 | + $tls_ldap = defined('_INSTALL_TLS_LDAP') |
|
| 28 | + ? _INSTALL_TLS_LDAP |
|
| 29 | + : 'non'; |
|
| 30 | 30 | |
| 31 | - $protocole_ldap = defined('_INSTALL_PROTOCOLE_LDAP') |
|
| 32 | - ? _INSTALL_PROTOCOLE_LDAP |
|
| 33 | - : 3; // on essaie 2 en cas d'echec |
|
| 31 | + $protocole_ldap = defined('_INSTALL_PROTOCOLE_LDAP') |
|
| 32 | + ? _INSTALL_PROTOCOLE_LDAP |
|
| 33 | + : 3; // on essaie 2 en cas d'echec |
|
| 34 | 34 | |
| 35 | - $login_ldap = defined('_INSTALL_USER_LDAP') |
|
| 36 | - ? _INSTALL_USER_LDAP |
|
| 37 | - : ''; |
|
| 35 | + $login_ldap = defined('_INSTALL_USER_LDAP') |
|
| 36 | + ? _INSTALL_USER_LDAP |
|
| 37 | + : ''; |
|
| 38 | 38 | |
| 39 | - $pass_ldap = defined('_INSTALL_PASS_LDAP') |
|
| 40 | - ? _INSTALL_PASS_LDAP |
|
| 41 | - : ''; |
|
| 39 | + $pass_ldap = defined('_INSTALL_PASS_LDAP') |
|
| 40 | + ? _INSTALL_PASS_LDAP |
|
| 41 | + : ''; |
|
| 42 | 42 | |
| 43 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 43 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 44 | 44 | |
| 45 | - echo info_etape( |
|
| 46 | - _T('titre_connexion_ldap'), |
|
| 47 | - info_progression_etape(1, 'etape_ldap', 'install/'), |
|
| 48 | - _T('entree_informations_connexion_ldap') |
|
| 49 | - ); |
|
| 45 | + echo info_etape( |
|
| 46 | + _T('titre_connexion_ldap'), |
|
| 47 | + info_progression_etape(1, 'etape_ldap', 'install/'), |
|
| 48 | + _T('entree_informations_connexion_ldap') |
|
| 49 | + ); |
|
| 50 | 50 | |
| 51 | - echo generer_form_ecrire('install', ( |
|
| 52 | - "\n<input type='hidden' name='etape' value='ldap2' />" |
|
| 53 | - . fieldset( |
|
| 54 | - _T('entree_adresse_annuaire'), |
|
| 55 | - array( |
|
| 56 | - 'adresse_ldap' => array( |
|
| 57 | - 'label' => _T('texte_adresse_annuaire_1'), |
|
| 58 | - 'valeur' => $adresse_ldap |
|
| 59 | - ), |
|
| 60 | - 'port_ldap' => array( |
|
| 61 | - 'label' => _T('entree_port_annuaire') . '<br />' . _T('texte_port_annuaire'), |
|
| 62 | - 'valeur' => $port_ldap |
|
| 63 | - ), |
|
| 64 | - 'tls_ldap' => array( |
|
| 65 | - 'label' => '<b>' . _T('tls_ldap') . '</b>', |
|
| 66 | - 'valeur' => $tls_ldap, |
|
| 67 | - 'alternatives' => array( |
|
| 68 | - 'non' => _T('item_non'), |
|
| 69 | - 'oui' => _T('item_oui') |
|
| 70 | - ) |
|
| 71 | - ), |
|
| 72 | - 'protocole_ldap' => array( |
|
| 73 | - 'label' => _T('protocole_ldap'), |
|
| 74 | - 'valeur' => $protocole_ldap, |
|
| 75 | - 'alternatives' => array( |
|
| 76 | - '3' => '3', |
|
| 77 | - '2' => '2' |
|
| 78 | - ) |
|
| 79 | - ) |
|
| 80 | - ) |
|
| 81 | - ) |
|
| 51 | + echo generer_form_ecrire('install', ( |
|
| 52 | + "\n<input type='hidden' name='etape' value='ldap2' />" |
|
| 53 | + . fieldset( |
|
| 54 | + _T('entree_adresse_annuaire'), |
|
| 55 | + array( |
|
| 56 | + 'adresse_ldap' => array( |
|
| 57 | + 'label' => _T('texte_adresse_annuaire_1'), |
|
| 58 | + 'valeur' => $adresse_ldap |
|
| 59 | + ), |
|
| 60 | + 'port_ldap' => array( |
|
| 61 | + 'label' => _T('entree_port_annuaire') . '<br />' . _T('texte_port_annuaire'), |
|
| 62 | + 'valeur' => $port_ldap |
|
| 63 | + ), |
|
| 64 | + 'tls_ldap' => array( |
|
| 65 | + 'label' => '<b>' . _T('tls_ldap') . '</b>', |
|
| 66 | + 'valeur' => $tls_ldap, |
|
| 67 | + 'alternatives' => array( |
|
| 68 | + 'non' => _T('item_non'), |
|
| 69 | + 'oui' => _T('item_oui') |
|
| 70 | + ) |
|
| 71 | + ), |
|
| 72 | + 'protocole_ldap' => array( |
|
| 73 | + 'label' => _T('protocole_ldap'), |
|
| 74 | + 'valeur' => $protocole_ldap, |
|
| 75 | + 'alternatives' => array( |
|
| 76 | + '3' => '3', |
|
| 77 | + '2' => '2' |
|
| 78 | + ) |
|
| 79 | + ) |
|
| 80 | + ) |
|
| 81 | + ) |
|
| 82 | 82 | |
| 83 | - . "\n<p>" . _T('texte_acces_ldap_anonyme_1') . '</p>' |
|
| 84 | - . fieldset( |
|
| 85 | - _T('connexion_ldap'), |
|
| 86 | - array( |
|
| 87 | - 'login_ldap' => array( |
|
| 88 | - 'label' => _T('texte_login_ldap_1'), |
|
| 89 | - 'valeur' => $login_ldap |
|
| 90 | - ), |
|
| 91 | - 'pass_ldap' => array( |
|
| 92 | - 'label' => _T('entree_passe_ldap'), |
|
| 93 | - 'valeur' => $pass_ldap |
|
| 94 | - ) |
|
| 95 | - ) |
|
| 96 | - ) |
|
| 97 | - . bouton_suivant())); |
|
| 83 | + . "\n<p>" . _T('texte_acces_ldap_anonyme_1') . '</p>' |
|
| 84 | + . fieldset( |
|
| 85 | + _T('connexion_ldap'), |
|
| 86 | + array( |
|
| 87 | + 'login_ldap' => array( |
|
| 88 | + 'label' => _T('texte_login_ldap_1'), |
|
| 89 | + 'valeur' => $login_ldap |
|
| 90 | + ), |
|
| 91 | + 'pass_ldap' => array( |
|
| 92 | + 'label' => _T('entree_passe_ldap'), |
|
| 93 | + 'valeur' => $pass_ldap |
|
| 94 | + ) |
|
| 95 | + ) |
|
| 96 | + ) |
|
| 97 | + . bouton_suivant())); |
|
| 98 | 98 | |
| 99 | - echo install_fin_html(); |
|
| 99 | + echo install_fin_html(); |
|
| 100 | 100 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/headers'); |
@@ -19,55 +19,55 @@ discard block |
||
| 19 | 19 | // https://code.spip.net/@install_etape_4_dist |
| 20 | 20 | function install_etape_4_dist() { |
| 21 | 21 | |
| 22 | - // creer le repertoire cache, qui sert partout ! |
|
| 23 | - if (!@file_exists(_DIR_CACHE)) { |
|
| 24 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 25 | - $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 26 | - } |
|
| 22 | + // creer le repertoire cache, qui sert partout ! |
|
| 23 | + if (!@file_exists(_DIR_CACHE)) { |
|
| 24 | + $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 25 | + $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 30 | - echo info_progression_etape(4, 'etape_', 'install/'); |
|
| 29 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 30 | + echo info_progression_etape(4, 'etape_', 'install/'); |
|
| 31 | 31 | |
| 32 | - echo "<div class='success'><b>" |
|
| 33 | - . _T('info_derniere_etape') |
|
| 34 | - . '</b><p>' |
|
| 35 | - . _T('info_utilisation_spip') |
|
| 36 | - . '</p></div>'; |
|
| 32 | + echo "<div class='success'><b>" |
|
| 33 | + . _T('info_derniere_etape') |
|
| 34 | + . '</b><p>' |
|
| 35 | + . _T('info_utilisation_spip') |
|
| 36 | + . '</p></div>'; |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | - echo '<p>' |
|
| 40 | - . _T( |
|
| 41 | - 'plugin_info_plugins_dist_1', |
|
| 42 | - array('plugins_dist' => '<tt>' . joli_repertoire(_DIR_PLUGINS_DIST) . '</tt>') |
|
| 43 | - ) |
|
| 44 | - . '</p>'; |
|
| 39 | + echo '<p>' |
|
| 40 | + . _T( |
|
| 41 | + 'plugin_info_plugins_dist_1', |
|
| 42 | + array('plugins_dist' => '<tt>' . joli_repertoire(_DIR_PLUGINS_DIST) . '</tt>') |
|
| 43 | + ) |
|
| 44 | + . '</p>'; |
|
| 45 | 45 | |
| 46 | - // installer les extensions |
|
| 47 | - include_spip('inc/plugin'); |
|
| 48 | - $afficher = charger_fonction('afficher_liste', 'plugins'); |
|
| 49 | - echo $afficher(self(), liste_plugin_files(_DIR_PLUGINS_DIST), array(), array(), _DIR_PLUGINS_DIST, |
|
| 50 | - 'afficher_nom_plugin'); |
|
| 46 | + // installer les extensions |
|
| 47 | + include_spip('inc/plugin'); |
|
| 48 | + $afficher = charger_fonction('afficher_liste', 'plugins'); |
|
| 49 | + echo $afficher(self(), liste_plugin_files(_DIR_PLUGINS_DIST), array(), array(), _DIR_PLUGINS_DIST, |
|
| 50 | + 'afficher_nom_plugin'); |
|
| 51 | 51 | |
| 52 | - // si la base de SPIP est up, on peut installer les plugins, sinon on passe cette etape |
|
| 53 | - // car les plugins supposent que la base de SPIP est dans son etat normal (mise a jour) |
|
| 54 | - // au premier passage dans l'espace prive on aura une demande d'upgrade qui se poursuit sur la page plugin |
|
| 55 | - // et procede alors a l'installation |
|
| 56 | - if (!isset($GLOBALS['meta']['version_installee']) |
|
| 57 | - or ($GLOBALS['spip_version_base'] == (str_replace(',', '.', $GLOBALS['meta']['version_installee']))) |
|
| 58 | - ) { |
|
| 59 | - plugin_installes_meta(); |
|
| 60 | - } |
|
| 52 | + // si la base de SPIP est up, on peut installer les plugins, sinon on passe cette etape |
|
| 53 | + // car les plugins supposent que la base de SPIP est dans son etat normal (mise a jour) |
|
| 54 | + // au premier passage dans l'espace prive on aura une demande d'upgrade qui se poursuit sur la page plugin |
|
| 55 | + // et procede alors a l'installation |
|
| 56 | + if (!isset($GLOBALS['meta']['version_installee']) |
|
| 57 | + or ($GLOBALS['spip_version_base'] == (str_replace(',', '.', $GLOBALS['meta']['version_installee']))) |
|
| 58 | + ) { |
|
| 59 | + plugin_installes_meta(); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - // mettre a jour si necessaire l'adresse du site |
|
| 63 | - // securite si on arrive plus a se loger |
|
| 64 | - include_spip('inc/config'); |
|
| 65 | - appliquer_adresse_site(''); |
|
| 62 | + // mettre a jour si necessaire l'adresse du site |
|
| 63 | + // securite si on arrive plus a se loger |
|
| 64 | + include_spip('inc/config'); |
|
| 65 | + appliquer_adresse_site(''); |
|
| 66 | 66 | |
| 67 | - // aller a la derniere etape qui clos l'install et redirige |
|
| 68 | - $suite = "\n<input type='hidden' name='etape' value='fin' />" |
|
| 69 | - . bouton_suivant(_T('login_espace_prive')); |
|
| 67 | + // aller a la derniere etape qui clos l'install et redirige |
|
| 68 | + $suite = "\n<input type='hidden' name='etape' value='fin' />" |
|
| 69 | + . bouton_suivant(_T('login_espace_prive')); |
|
| 70 | 70 | |
| 71 | - echo generer_form_ecrire('install', $suite); |
|
| 72 | - echo install_fin_html(); |
|
| 71 | + echo generer_form_ecrire('install', $suite); |
|
| 72 | + echo install_fin_html(); |
|
| 73 | 73 | } |
@@ -12,77 +12,77 @@ |
||
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | // https://code.spip.net/@install_etape_ldap2_dist |
| 19 | 19 | function install_etape_ldap2_dist() { |
| 20 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 21 | - |
|
| 22 | - $adresse_ldap = _request('adresse_ldap'); |
|
| 23 | - |
|
| 24 | - $port_ldap = _request('port_ldap'); |
|
| 25 | - |
|
| 26 | - $tls_ldap = _request('tls_ldap'); |
|
| 27 | - |
|
| 28 | - $protocole_ldap = _request('protocole_ldap'); |
|
| 29 | - |
|
| 30 | - $login_ldap = _request('login_ldap'); |
|
| 31 | - |
|
| 32 | - $pass_ldap = _request('pass_ldap'); |
|
| 33 | - |
|
| 34 | - $port_ldap = intval($port_ldap); |
|
| 35 | - |
|
| 36 | - $tls = false; |
|
| 37 | - |
|
| 38 | - if ($tls_ldap == 'oui') { |
|
| 39 | - if ($port_ldap == 636) { |
|
| 40 | - $adresse_ldap = "ldaps://$adresse_ldap"; |
|
| 41 | - } else { |
|
| 42 | - $tls = true; |
|
| 43 | - } |
|
| 44 | - } |
|
| 45 | - $ldap_link = ldap_connect($adresse_ldap, $port_ldap); |
|
| 46 | - $erreur = "ldap_connect($adresse_ldap, $port_ldap)"; |
|
| 47 | - |
|
| 48 | - if ($ldap_link) { |
|
| 49 | - if (!ldap_set_option($ldap_link, LDAP_OPT_PROTOCOL_VERSION, $protocole_ldap)) { |
|
| 50 | - $protocole_ldap = 2; |
|
| 51 | - ldap_set_option($ldap_link, LDAP_OPT_PROTOCOL_VERSION, $protocole_ldap); |
|
| 52 | - } |
|
| 53 | - if ($tls === true) { |
|
| 54 | - if (!ldap_start_tls($ldap_link)) { |
|
| 55 | - $erreur = "ldap_start_tls($ldap_link) $adresse_ldap, $port_ldap"; |
|
| 56 | - $ldap_link = false; |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - if ($ldap_link) { |
|
| 60 | - $ldap_link = ldap_bind($ldap_link, $login_ldap, $pass_ldap); |
|
| 61 | - $erreur = "ldap_bind('$ldap_link', '$login_ldap', '$pass_ldap'): $adresse_ldap, $port_ldap"; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - if ($ldap_link) { |
|
| 66 | - echo info_etape( |
|
| 67 | - _T('titre_connexion_ldap'), |
|
| 68 | - info_progression_etape(2, 'etape_ldap', 'install/') |
|
| 69 | - ), _T('info_connexion_ldap_ok'); |
|
| 70 | - echo generer_form_ecrire('install', ( |
|
| 71 | - "\n<input type='hidden' name='etape' value='ldap3' />" |
|
| 72 | - . "\n<input type='hidden' name='adresse_ldap' value=\"$adresse_ldap\" />" |
|
| 73 | - . "\n<input type='hidden' name='port_ldap' value=\"$port_ldap\" />" |
|
| 74 | - . "\n<input type='hidden' name='login_ldap' value=\"$login_ldap\" />" |
|
| 75 | - . "\n<input type='hidden' name='pass_ldap' value=\"$pass_ldap\" />" |
|
| 76 | - . "\n<input type='hidden' name='protocole_ldap' value=\"$protocole_ldap\" />" |
|
| 77 | - . "\n<input type='hidden' name='tls_ldap' value=\"$tls_ldap\" />" |
|
| 78 | - . bouton_suivant())); |
|
| 79 | - } else { |
|
| 80 | - echo info_etape(_T('titre_connexion_ldap')), info_progression_etape(1, 'etape_ldap', 'install/', true), |
|
| 81 | - "<div class='error'><p>" . _T('avis_connexion_ldap_echec_1') . '</p>', |
|
| 82 | - '<p>' . _T('avis_connexion_ldap_echec_2') . |
|
| 83 | - "<br />\n" . _T('avis_connexion_ldap_echec_3') . |
|
| 84 | - '<br /><br />' . $erreur . '<b> ?</b></p></div>'; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - echo install_fin_html(); |
|
| 20 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 21 | + |
|
| 22 | + $adresse_ldap = _request('adresse_ldap'); |
|
| 23 | + |
|
| 24 | + $port_ldap = _request('port_ldap'); |
|
| 25 | + |
|
| 26 | + $tls_ldap = _request('tls_ldap'); |
|
| 27 | + |
|
| 28 | + $protocole_ldap = _request('protocole_ldap'); |
|
| 29 | + |
|
| 30 | + $login_ldap = _request('login_ldap'); |
|
| 31 | + |
|
| 32 | + $pass_ldap = _request('pass_ldap'); |
|
| 33 | + |
|
| 34 | + $port_ldap = intval($port_ldap); |
|
| 35 | + |
|
| 36 | + $tls = false; |
|
| 37 | + |
|
| 38 | + if ($tls_ldap == 'oui') { |
|
| 39 | + if ($port_ldap == 636) { |
|
| 40 | + $adresse_ldap = "ldaps://$adresse_ldap"; |
|
| 41 | + } else { |
|
| 42 | + $tls = true; |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | + $ldap_link = ldap_connect($adresse_ldap, $port_ldap); |
|
| 46 | + $erreur = "ldap_connect($adresse_ldap, $port_ldap)"; |
|
| 47 | + |
|
| 48 | + if ($ldap_link) { |
|
| 49 | + if (!ldap_set_option($ldap_link, LDAP_OPT_PROTOCOL_VERSION, $protocole_ldap)) { |
|
| 50 | + $protocole_ldap = 2; |
|
| 51 | + ldap_set_option($ldap_link, LDAP_OPT_PROTOCOL_VERSION, $protocole_ldap); |
|
| 52 | + } |
|
| 53 | + if ($tls === true) { |
|
| 54 | + if (!ldap_start_tls($ldap_link)) { |
|
| 55 | + $erreur = "ldap_start_tls($ldap_link) $adresse_ldap, $port_ldap"; |
|
| 56 | + $ldap_link = false; |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + if ($ldap_link) { |
|
| 60 | + $ldap_link = ldap_bind($ldap_link, $login_ldap, $pass_ldap); |
|
| 61 | + $erreur = "ldap_bind('$ldap_link', '$login_ldap', '$pass_ldap'): $adresse_ldap, $port_ldap"; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + if ($ldap_link) { |
|
| 66 | + echo info_etape( |
|
| 67 | + _T('titre_connexion_ldap'), |
|
| 68 | + info_progression_etape(2, 'etape_ldap', 'install/') |
|
| 69 | + ), _T('info_connexion_ldap_ok'); |
|
| 70 | + echo generer_form_ecrire('install', ( |
|
| 71 | + "\n<input type='hidden' name='etape' value='ldap3' />" |
|
| 72 | + . "\n<input type='hidden' name='adresse_ldap' value=\"$adresse_ldap\" />" |
|
| 73 | + . "\n<input type='hidden' name='port_ldap' value=\"$port_ldap\" />" |
|
| 74 | + . "\n<input type='hidden' name='login_ldap' value=\"$login_ldap\" />" |
|
| 75 | + . "\n<input type='hidden' name='pass_ldap' value=\"$pass_ldap\" />" |
|
| 76 | + . "\n<input type='hidden' name='protocole_ldap' value=\"$protocole_ldap\" />" |
|
| 77 | + . "\n<input type='hidden' name='tls_ldap' value=\"$tls_ldap\" />" |
|
| 78 | + . bouton_suivant())); |
|
| 79 | + } else { |
|
| 80 | + echo info_etape(_T('titre_connexion_ldap')), info_progression_etape(1, 'etape_ldap', 'install/', true), |
|
| 81 | + "<div class='error'><p>" . _T('avis_connexion_ldap_echec_1') . '</p>', |
|
| 82 | + '<p>' . _T('avis_connexion_ldap_echec_2') . |
|
| 83 | + "<br />\n" . _T('avis_connexion_ldap_echec_3') . |
|
| 84 | + '<br /><br />' . $erreur . '<b> ?</b></p></div>'; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + echo install_fin_html(); |
|
| 88 | 88 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/headers'); |
@@ -21,64 +21,64 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | // https://code.spip.net/@install_etape_fin_dist |
| 23 | 23 | function install_etape_fin_dist() { |
| 24 | - ecrire_acces(); |
|
| 24 | + ecrire_acces(); |
|
| 25 | 25 | |
| 26 | - $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CHMOD_TMP); |
|
| 27 | - if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 28 | - if (!@rename(_FILE_CHMOD_TMP, $f)) { |
|
| 29 | - if (@copy(_FILE_CHMOD_TMP, $f)) { |
|
| 30 | - spip_unlink(_FILE_CHMOD_TMP); |
|
| 31 | - } |
|
| 32 | - } |
|
| 33 | - } |
|
| 26 | + $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CHMOD_TMP); |
|
| 27 | + if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 28 | + if (!@rename(_FILE_CHMOD_TMP, $f)) { |
|
| 29 | + if (@copy(_FILE_CHMOD_TMP, $f)) { |
|
| 30 | + spip_unlink(_FILE_CHMOD_TMP); |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CONNECT_TMP); |
|
| 36 | - if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 37 | - spip_log("renomme $f"); |
|
| 38 | - if (!@rename(_FILE_CONNECT_TMP, $f)) { |
|
| 39 | - if (@copy(_FILE_CONNECT_TMP, $f)) { |
|
| 40 | - @spip_unlink(_FILE_CONNECT_TMP); |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - } |
|
| 35 | + $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CONNECT_TMP); |
|
| 36 | + if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 37 | + spip_log("renomme $f"); |
|
| 38 | + if (!@rename(_FILE_CONNECT_TMP, $f)) { |
|
| 39 | + if (@copy(_FILE_CONNECT_TMP, $f)) { |
|
| 40 | + @spip_unlink(_FILE_CONNECT_TMP); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - // creer le repertoire cache, qui sert partout ! |
|
| 46 | - // deja fait en etape 4 en principe, on garde au cas ou |
|
| 47 | - if (!@file_exists(_DIR_CACHE)) { |
|
| 48 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 49 | - $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 50 | - } |
|
| 45 | + // creer le repertoire cache, qui sert partout ! |
|
| 46 | + // deja fait en etape 4 en principe, on garde au cas ou |
|
| 47 | + if (!@file_exists(_DIR_CACHE)) { |
|
| 48 | + $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 49 | + $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - // Verifier la securite des htaccess |
|
| 53 | - // Si elle ne fonctionne pas, prevenir |
|
| 54 | - $msg = install_verifier_htaccess(); |
|
| 55 | - if ($msg) { |
|
| 56 | - $cible = _T('public:accueil_site'); |
|
| 57 | - $cible = generer_form_ecrire('accueil', '', '', $cible); |
|
| 58 | - echo minipres('AUTO', $msg . $cible); |
|
| 59 | - // ok, deboucher dans l'espace prive |
|
| 60 | - } else { |
|
| 61 | - redirige_url_ecrire('accueil'); |
|
| 62 | - } |
|
| 52 | + // Verifier la securite des htaccess |
|
| 53 | + // Si elle ne fonctionne pas, prevenir |
|
| 54 | + $msg = install_verifier_htaccess(); |
|
| 55 | + if ($msg) { |
|
| 56 | + $cible = _T('public:accueil_site'); |
|
| 57 | + $cible = generer_form_ecrire('accueil', '', '', $cible); |
|
| 58 | + echo minipres('AUTO', $msg . $cible); |
|
| 59 | + // ok, deboucher dans l'espace prive |
|
| 60 | + } else { |
|
| 61 | + redirige_url_ecrire('accueil'); |
|
| 62 | + } |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | function install_verifier_htaccess() { |
| 66 | - if (verifier_htaccess(_DIR_TMP, true) |
|
| 67 | - and verifier_htaccess(_DIR_CONNECT, true) |
|
| 68 | - ) { |
|
| 69 | - return ''; |
|
| 70 | - } |
|
| 66 | + if (verifier_htaccess(_DIR_TMP, true) |
|
| 67 | + and verifier_htaccess(_DIR_CONNECT, true) |
|
| 68 | + ) { |
|
| 69 | + return ''; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - $titre = _T('htaccess_inoperant'); |
|
| 72 | + $titre = _T('htaccess_inoperant'); |
|
| 73 | 73 | |
| 74 | - $averti = _T( |
|
| 75 | - 'htaccess_a_simuler', |
|
| 76 | - array( |
|
| 77 | - 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 78 | - 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
|
| 79 | - 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 80 | - ) |
|
| 81 | - ); |
|
| 74 | + $averti = _T( |
|
| 75 | + 'htaccess_a_simuler', |
|
| 76 | + array( |
|
| 77 | + 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 78 | + 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
|
| 79 | + 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 80 | + ) |
|
| 81 | + ); |
|
| 82 | 82 | |
| 83 | - return "<div class='error'><h3>$titre</h3><p>$averti</p></div>"; |
|
| 83 | + return "<div class='error'><h3>$titre</h3><p>$averti</p></div>"; |
|
| 84 | 84 | } |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | if (defined('_TEST_DIRS')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | define('_TEST_DIRS', '1'); |
| 21 | 21 | |
@@ -27,42 +27,42 @@ discard block |
||
| 27 | 27 | // |
| 28 | 28 | // https://code.spip.net/@test_ecrire |
| 29 | 29 | function test_ecrire($my_dir) { |
| 30 | - static $chmod = 0; |
|
| 31 | - |
|
| 32 | - $ok = false; |
|
| 33 | - $script = @file_exists('spip_loader.php') ? 'spip_loader.php' : $_SERVER['PHP_SELF']; |
|
| 34 | - $self = basename($script); |
|
| 35 | - $uid = @fileowner('.'); |
|
| 36 | - $uid2 = @fileowner($self); |
|
| 37 | - $gid = @filegroup('.'); |
|
| 38 | - $gid2 = @filegroup($self); |
|
| 39 | - $perms = @fileperms($self); |
|
| 40 | - |
|
| 41 | - // Comparer l'appartenance d'un fichier cree par PHP |
|
| 42 | - // avec celle du script et du repertoire courant |
|
| 43 | - if (!$chmod) { |
|
| 44 | - @rmdir('test'); |
|
| 45 | - spip_unlink('test'); // effacer au cas ou |
|
| 46 | - @touch('test'); |
|
| 47 | - if ($uid > 0 && $uid == $uid2 && @fileowner('test') == $uid) { |
|
| 48 | - $chmod = 0700; |
|
| 49 | - } else { |
|
| 50 | - if ($gid > 0 && $gid == $gid2 && @filegroup('test') == $gid) { |
|
| 51 | - $chmod = 0770; |
|
| 52 | - } else { |
|
| 53 | - $chmod = 0777; |
|
| 54 | - } |
|
| 55 | - } |
|
| 56 | - // Appliquer de plus les droits d'acces du script |
|
| 57 | - if ($perms > 0) { |
|
| 58 | - $perms = ($perms & 0777) | (($perms & 0444) >> 2); |
|
| 59 | - $chmod |= $perms; |
|
| 60 | - } |
|
| 61 | - spip_unlink('test'); |
|
| 62 | - } |
|
| 63 | - $ok = is_dir($my_dir) && is_writable($my_dir); |
|
| 64 | - |
|
| 65 | - return $ok ? $chmod : false; |
|
| 30 | + static $chmod = 0; |
|
| 31 | + |
|
| 32 | + $ok = false; |
|
| 33 | + $script = @file_exists('spip_loader.php') ? 'spip_loader.php' : $_SERVER['PHP_SELF']; |
|
| 34 | + $self = basename($script); |
|
| 35 | + $uid = @fileowner('.'); |
|
| 36 | + $uid2 = @fileowner($self); |
|
| 37 | + $gid = @filegroup('.'); |
|
| 38 | + $gid2 = @filegroup($self); |
|
| 39 | + $perms = @fileperms($self); |
|
| 40 | + |
|
| 41 | + // Comparer l'appartenance d'un fichier cree par PHP |
|
| 42 | + // avec celle du script et du repertoire courant |
|
| 43 | + if (!$chmod) { |
|
| 44 | + @rmdir('test'); |
|
| 45 | + spip_unlink('test'); // effacer au cas ou |
|
| 46 | + @touch('test'); |
|
| 47 | + if ($uid > 0 && $uid == $uid2 && @fileowner('test') == $uid) { |
|
| 48 | + $chmod = 0700; |
|
| 49 | + } else { |
|
| 50 | + if ($gid > 0 && $gid == $gid2 && @filegroup('test') == $gid) { |
|
| 51 | + $chmod = 0770; |
|
| 52 | + } else { |
|
| 53 | + $chmod = 0777; |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | + // Appliquer de plus les droits d'acces du script |
|
| 57 | + if ($perms > 0) { |
|
| 58 | + $perms = ($perms & 0777) | (($perms & 0444) >> 2); |
|
| 59 | + $chmod |= $perms; |
|
| 60 | + } |
|
| 61 | + spip_unlink('test'); |
|
| 62 | + } |
|
| 63 | + $ok = is_dir($my_dir) && is_writable($my_dir); |
|
| 64 | + |
|
| 65 | + return $ok ? $chmod : false; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // |
@@ -73,83 +73,83 @@ discard block |
||
| 73 | 73 | // https://code.spip.net/@install_etape_chmod_dist |
| 74 | 74 | function install_etape_chmod_dist() { |
| 75 | 75 | |
| 76 | - $test_dir = _request('test_dir'); |
|
| 77 | - $chmod = 0; |
|
| 78 | - |
|
| 79 | - if ($test_dir) { |
|
| 80 | - if (substr($test_dir, -1) !== '/') { |
|
| 81 | - $test_dir .= '/'; |
|
| 82 | - } |
|
| 83 | - if (!in_array($test_dir, $GLOBALS['test_dirs'])) { |
|
| 84 | - $GLOBALS['test_dirs'][] = _DIR_RACINE . $test_dir; |
|
| 85 | - } |
|
| 86 | - } else { |
|
| 87 | - if (!_FILE_CONNECT) { |
|
| 88 | - $GLOBALS['test_dirs'][] = _DIR_CONNECT; |
|
| 89 | - $GLOBALS['test_dirs'][] = _DIR_CHMOD; |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - $bad_dirs = array(); |
|
| 94 | - $absent_dirs = array(); |
|
| 95 | - |
|
| 96 | - foreach ($GLOBALS['test_dirs'] as $i => $my_dir) { |
|
| 97 | - $test = test_ecrire($my_dir); |
|
| 98 | - if (!$test) { |
|
| 99 | - $m = preg_replace(',^' . _DIR_RACINE . ',', '', $my_dir); |
|
| 100 | - if (@file_exists($my_dir)) { |
|
| 101 | - $bad_dirs['<li>' . $m . '</li>'] = 1; |
|
| 102 | - } else { |
|
| 103 | - $absent_dirs['<li>' . $m . '</li>'] = 1; |
|
| 104 | - } |
|
| 105 | - } else { |
|
| 106 | - $chmod = max($chmod, $test); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - if ($bad_dirs or $absent_dirs) { |
|
| 111 | - if (!_FILE_CONNECT) { |
|
| 112 | - $titre = _T('dirs_preliminaire'); |
|
| 113 | - $continuer = ' ' . _T('dirs_commencer') . '.'; |
|
| 114 | - } else { |
|
| 115 | - $titre = _T('dirs_probleme_droits'); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - $res = "<div align='right'>" . menu_langues('var_lang_ecrire') . "</div>\n"; |
|
| 120 | - |
|
| 121 | - if ($bad_dirs) { |
|
| 122 | - $res .= |
|
| 123 | - _T( |
|
| 124 | - 'dirs_repertoires_suivants', |
|
| 125 | - array('bad_dirs' => join("\n", array_keys($bad_dirs))) |
|
| 126 | - ) . |
|
| 127 | - '<b>' . _T('login_recharger') . '</b>.'; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - if ($absent_dirs) { |
|
| 131 | - $res .= |
|
| 132 | - _T( |
|
| 133 | - 'dirs_repertoires_absents', |
|
| 134 | - array('bad_dirs' => join("\n", array_keys($absent_dirs))) |
|
| 135 | - ) . |
|
| 136 | - '<b>' . _T('login_recharger') . '</b>.'; |
|
| 137 | - } |
|
| 138 | - $res = '<p>' . $continuer . $res . aider('install0', true) . '</p>'; |
|
| 139 | - |
|
| 140 | - $t = _T('login_recharger'); |
|
| 141 | - $t = (!$test_dir ? '' : |
|
| 142 | - "<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />") |
|
| 143 | - . "<input type='hidden' name='etape' value='chmod' />" |
|
| 144 | - . "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>"; |
|
| 145 | - |
|
| 146 | - echo minipres($titre, $res . generer_form_ecrire('install', $t)); |
|
| 147 | - } else { |
|
| 148 | - $deja = (_FILE_CONNECT and analyse_fichier_connection(_FILE_CONNECT)); |
|
| 149 | - if (!$deja) { |
|
| 150 | - redirige_url_ecrire('install', 'etape=1&chmod=' . $chmod); |
|
| 151 | - } else { |
|
| 152 | - redirige_url_ecrire(); |
|
| 153 | - } |
|
| 154 | - } |
|
| 76 | + $test_dir = _request('test_dir'); |
|
| 77 | + $chmod = 0; |
|
| 78 | + |
|
| 79 | + if ($test_dir) { |
|
| 80 | + if (substr($test_dir, -1) !== '/') { |
|
| 81 | + $test_dir .= '/'; |
|
| 82 | + } |
|
| 83 | + if (!in_array($test_dir, $GLOBALS['test_dirs'])) { |
|
| 84 | + $GLOBALS['test_dirs'][] = _DIR_RACINE . $test_dir; |
|
| 85 | + } |
|
| 86 | + } else { |
|
| 87 | + if (!_FILE_CONNECT) { |
|
| 88 | + $GLOBALS['test_dirs'][] = _DIR_CONNECT; |
|
| 89 | + $GLOBALS['test_dirs'][] = _DIR_CHMOD; |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + $bad_dirs = array(); |
|
| 94 | + $absent_dirs = array(); |
|
| 95 | + |
|
| 96 | + foreach ($GLOBALS['test_dirs'] as $i => $my_dir) { |
|
| 97 | + $test = test_ecrire($my_dir); |
|
| 98 | + if (!$test) { |
|
| 99 | + $m = preg_replace(',^' . _DIR_RACINE . ',', '', $my_dir); |
|
| 100 | + if (@file_exists($my_dir)) { |
|
| 101 | + $bad_dirs['<li>' . $m . '</li>'] = 1; |
|
| 102 | + } else { |
|
| 103 | + $absent_dirs['<li>' . $m . '</li>'] = 1; |
|
| 104 | + } |
|
| 105 | + } else { |
|
| 106 | + $chmod = max($chmod, $test); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + if ($bad_dirs or $absent_dirs) { |
|
| 111 | + if (!_FILE_CONNECT) { |
|
| 112 | + $titre = _T('dirs_preliminaire'); |
|
| 113 | + $continuer = ' ' . _T('dirs_commencer') . '.'; |
|
| 114 | + } else { |
|
| 115 | + $titre = _T('dirs_probleme_droits'); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + $res = "<div align='right'>" . menu_langues('var_lang_ecrire') . "</div>\n"; |
|
| 120 | + |
|
| 121 | + if ($bad_dirs) { |
|
| 122 | + $res .= |
|
| 123 | + _T( |
|
| 124 | + 'dirs_repertoires_suivants', |
|
| 125 | + array('bad_dirs' => join("\n", array_keys($bad_dirs))) |
|
| 126 | + ) . |
|
| 127 | + '<b>' . _T('login_recharger') . '</b>.'; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + if ($absent_dirs) { |
|
| 131 | + $res .= |
|
| 132 | + _T( |
|
| 133 | + 'dirs_repertoires_absents', |
|
| 134 | + array('bad_dirs' => join("\n", array_keys($absent_dirs))) |
|
| 135 | + ) . |
|
| 136 | + '<b>' . _T('login_recharger') . '</b>.'; |
|
| 137 | + } |
|
| 138 | + $res = '<p>' . $continuer . $res . aider('install0', true) . '</p>'; |
|
| 139 | + |
|
| 140 | + $t = _T('login_recharger'); |
|
| 141 | + $t = (!$test_dir ? '' : |
|
| 142 | + "<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />") |
|
| 143 | + . "<input type='hidden' name='etape' value='chmod' />" |
|
| 144 | + . "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>"; |
|
| 145 | + |
|
| 146 | + echo minipres($titre, $res . generer_form_ecrire('install', $t)); |
|
| 147 | + } else { |
|
| 148 | + $deja = (_FILE_CONNECT and analyse_fichier_connection(_FILE_CONNECT)); |
|
| 149 | + if (!$deja) { |
|
| 150 | + redirige_url_ecrire('install', 'etape=1&chmod=' . $chmod); |
|
| 151 | + } else { |
|
| 152 | + redirige_url_ecrire(); |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | 155 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Installation |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/acces'); |
@@ -33,18 +33,18 @@ discard block |
||
| 33 | 33 | * @return bool |
| 34 | 34 | */ |
| 35 | 35 | function base_determine_autoinc($table, $desc = array()) { |
| 36 | - if ($t = lister_tables_principales() and isset($t[$table])) { |
|
| 37 | - $autoinc = true; |
|
| 38 | - } elseif ($t = lister_tables_auxiliaires() and isset($t[$table])) { |
|
| 39 | - $autoinc = false; |
|
| 40 | - } else { |
|
| 41 | - // essayer de faire au mieux ! |
|
| 42 | - $autoinc = (isset($desc['key']['PRIMARY KEY']) |
|
| 43 | - and strpos($desc['key']['PRIMARY KEY'], ',') === false |
|
| 44 | - and strpos($desc['field'][$desc['key']['PRIMARY KEY']], 'default') === false); |
|
| 45 | - } |
|
| 36 | + if ($t = lister_tables_principales() and isset($t[$table])) { |
|
| 37 | + $autoinc = true; |
|
| 38 | + } elseif ($t = lister_tables_auxiliaires() and isset($t[$table])) { |
|
| 39 | + $autoinc = false; |
|
| 40 | + } else { |
|
| 41 | + // essayer de faire au mieux ! |
|
| 42 | + $autoinc = (isset($desc['key']['PRIMARY KEY']) |
|
| 43 | + and strpos($desc['key']['PRIMARY KEY'], ',') === false |
|
| 44 | + and strpos($desc['field'][$desc['key']['PRIMARY KEY']], 'default') === false); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - return $autoinc; |
|
| 47 | + return $autoinc; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -61,59 +61,59 @@ discard block |
||
| 61 | 61 | * @return void |
| 62 | 62 | */ |
| 63 | 63 | function creer_ou_upgrader_table($table, $desc, $autoinc, $upgrade = false, $serveur = '') { |
| 64 | - #spip_log("creer_ou_upgrader_table table=$table autoinc=$autoinc upgrade=$upgrade","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 65 | - $sql_desc = $upgrade ? sql_showtable($table, true, $serveur) : false; |
|
| 66 | - #if (!$sql_desc) $sql_desc = false; |
|
| 67 | - #spip_log("table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 68 | - if (!$sql_desc) { |
|
| 69 | - if ($autoinc === 'auto') { |
|
| 70 | - $autoinc = base_determine_autoinc($table, $desc); |
|
| 71 | - } |
|
| 72 | - #spip_log("sql_create $table autoinc=$autoinc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 73 | - if (isset($desc['field']) and isset($desc['key'])) { |
|
| 74 | - sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 75 | - } |
|
| 76 | - // verifier la bonne installation de la table (php-fpm es-tu la ?) |
|
| 77 | - $sql_desc = sql_showtable($table, true, $serveur); |
|
| 78 | - #if (!$sql_desc) $sql_desc = false; |
|
| 79 | - #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 80 | - if (!$sql_desc) { |
|
| 81 | - // on retente avec un sleep ? |
|
| 82 | - sleep(1); |
|
| 83 | - sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 84 | - $sql_desc = sql_showtable($table, true, $serveur); |
|
| 85 | - #if (!$sql_desc) $sql_desc = false; |
|
| 86 | - #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 87 | - if (!$sql_desc) { |
|
| 88 | - spip_log("Echec creation table $table", "maj" . _LOG_CRITIQUE); |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - } else { |
|
| 92 | - #spip_log("sql_alter $table ... (on s'en fiche)","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 93 | - // ajouter les champs manquants |
|
| 94 | - // on ne supprime jamais les champs, car c'est dangereux |
|
| 95 | - // c'est toujours a faire manuellement |
|
| 96 | - $last = ''; |
|
| 97 | - if (isset($desc['field'])) { |
|
| 98 | - foreach ($desc['field'] as $field => $type) { |
|
| 99 | - if (!isset($sql_desc['field'][$field])) { |
|
| 100 | - sql_alter("TABLE $table ADD $field $type" . ($last ? " AFTER $last" : ""), $serveur); |
|
| 101 | - } |
|
| 102 | - $last = $field; |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - if (isset($desc['key'])) { |
|
| 106 | - foreach ($desc['key'] as $key => $type) { |
|
| 107 | - // Ne pas oublier les cas des cles non nommees dans la declaration et qui sont retournees |
|
| 108 | - // par le showtable sous la forme d'un index de tableau "KEY $type" et non "KEY" |
|
| 109 | - if (!isset($sql_desc['key'][$key]) and !isset($sql_desc['key']["$key $type"])) { |
|
| 110 | - sql_alter("TABLE $table ADD $key ($type)", $serveur); |
|
| 111 | - } |
|
| 112 | - $last = $field; |
|
| 113 | - } |
|
| 114 | - } |
|
| 64 | + #spip_log("creer_ou_upgrader_table table=$table autoinc=$autoinc upgrade=$upgrade","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 65 | + $sql_desc = $upgrade ? sql_showtable($table, true, $serveur) : false; |
|
| 66 | + #if (!$sql_desc) $sql_desc = false; |
|
| 67 | + #spip_log("table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 68 | + if (!$sql_desc) { |
|
| 69 | + if ($autoinc === 'auto') { |
|
| 70 | + $autoinc = base_determine_autoinc($table, $desc); |
|
| 71 | + } |
|
| 72 | + #spip_log("sql_create $table autoinc=$autoinc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 73 | + if (isset($desc['field']) and isset($desc['key'])) { |
|
| 74 | + sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 75 | + } |
|
| 76 | + // verifier la bonne installation de la table (php-fpm es-tu la ?) |
|
| 77 | + $sql_desc = sql_showtable($table, true, $serveur); |
|
| 78 | + #if (!$sql_desc) $sql_desc = false; |
|
| 79 | + #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 80 | + if (!$sql_desc) { |
|
| 81 | + // on retente avec un sleep ? |
|
| 82 | + sleep(1); |
|
| 83 | + sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 84 | + $sql_desc = sql_showtable($table, true, $serveur); |
|
| 85 | + #if (!$sql_desc) $sql_desc = false; |
|
| 86 | + #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 87 | + if (!$sql_desc) { |
|
| 88 | + spip_log("Echec creation table $table", "maj" . _LOG_CRITIQUE); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + } else { |
|
| 92 | + #spip_log("sql_alter $table ... (on s'en fiche)","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 93 | + // ajouter les champs manquants |
|
| 94 | + // on ne supprime jamais les champs, car c'est dangereux |
|
| 95 | + // c'est toujours a faire manuellement |
|
| 96 | + $last = ''; |
|
| 97 | + if (isset($desc['field'])) { |
|
| 98 | + foreach ($desc['field'] as $field => $type) { |
|
| 99 | + if (!isset($sql_desc['field'][$field])) { |
|
| 100 | + sql_alter("TABLE $table ADD $field $type" . ($last ? " AFTER $last" : ""), $serveur); |
|
| 101 | + } |
|
| 102 | + $last = $field; |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + if (isset($desc['key'])) { |
|
| 106 | + foreach ($desc['key'] as $key => $type) { |
|
| 107 | + // Ne pas oublier les cas des cles non nommees dans la declaration et qui sont retournees |
|
| 108 | + // par le showtable sous la forme d'un index de tableau "KEY $type" et non "KEY" |
|
| 109 | + if (!isset($sql_desc['key'][$key]) and !isset($sql_desc['key']["$key $type"])) { |
|
| 110 | + sql_alter("TABLE $table ADD $key ($type)", $serveur); |
|
| 111 | + } |
|
| 112 | + $last = $field; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - } |
|
| 116 | + } |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -135,26 +135,26 @@ discard block |
||
| 135 | 135 | * @return void |
| 136 | 136 | */ |
| 137 | 137 | function alterer_base($tables_inc, $tables_noinc, $up = false, $serveur = '') { |
| 138 | - if ($up === false) { |
|
| 139 | - $old = false; |
|
| 140 | - $up = array(); |
|
| 141 | - } else { |
|
| 142 | - $old = true; |
|
| 143 | - if (!is_array($up)) { |
|
| 144 | - $up = array($up); |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - foreach ($tables_inc as $k => $v) { |
|
| 148 | - if (!$old or in_array($k, $up)) { |
|
| 149 | - creer_ou_upgrader_table($k, $v, true, $old, $serveur); |
|
| 150 | - } |
|
| 151 | - } |
|
| 138 | + if ($up === false) { |
|
| 139 | + $old = false; |
|
| 140 | + $up = array(); |
|
| 141 | + } else { |
|
| 142 | + $old = true; |
|
| 143 | + if (!is_array($up)) { |
|
| 144 | + $up = array($up); |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + foreach ($tables_inc as $k => $v) { |
|
| 148 | + if (!$old or in_array($k, $up)) { |
|
| 149 | + creer_ou_upgrader_table($k, $v, true, $old, $serveur); |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - foreach ($tables_noinc as $k => $v) { |
|
| 154 | - if (!$old or in_array($k, $up)) { |
|
| 155 | - creer_ou_upgrader_table($k, $v, false, $old, $serveur); |
|
| 156 | - } |
|
| 157 | - } |
|
| 153 | + foreach ($tables_noinc as $k => $v) { |
|
| 154 | + if (!$old or in_array($k, $up)) { |
|
| 155 | + creer_ou_upgrader_table($k, $v, false, $old, $serveur); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -174,16 +174,16 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | function creer_base($serveur = '') { |
| 176 | 176 | |
| 177 | - // Note: les mises a jour reexecutent ce code pour s'assurer |
|
| 178 | - // de la conformite de la base |
|
| 179 | - // pas de panique sur "already exists" et "duplicate entry" donc. |
|
| 177 | + // Note: les mises a jour reexecutent ce code pour s'assurer |
|
| 178 | + // de la conformite de la base |
|
| 179 | + // pas de panique sur "already exists" et "duplicate entry" donc. |
|
| 180 | 180 | |
| 181 | - alterer_base( |
|
| 182 | - lister_tables_principales(), |
|
| 183 | - lister_tables_auxiliaires(), |
|
| 184 | - false, |
|
| 185 | - $serveur |
|
| 186 | - ); |
|
| 181 | + alterer_base( |
|
| 182 | + lister_tables_principales(), |
|
| 183 | + lister_tables_auxiliaires(), |
|
| 184 | + false, |
|
| 185 | + $serveur |
|
| 186 | + ); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | /** |
@@ -203,10 +203,10 @@ discard block |
||
| 203 | 203 | * @return void |
| 204 | 204 | */ |
| 205 | 205 | function maj_tables($upgrade_tables = array(), $serveur = '') { |
| 206 | - alterer_base( |
|
| 207 | - lister_tables_principales(), |
|
| 208 | - lister_tables_auxiliaires(), |
|
| 209 | - $upgrade_tables, |
|
| 210 | - $serveur |
|
| 211 | - ); |
|
| 206 | + alterer_base( |
|
| 207 | + lister_tables_principales(), |
|
| 208 | + lister_tables_auxiliaires(), |
|
| 209 | + $upgrade_tables, |
|
| 210 | + $serveur |
|
| 211 | + ); |
|
| 212 | 212 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/actions'); |
@@ -29,22 +29,22 @@ discard block |
||
| 29 | 29 | * @return void |
| 30 | 30 | */ |
| 31 | 31 | function action_etre_webmestre_dist() { |
| 32 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 33 | - $time = $securiser_action(); |
|
| 34 | - |
|
| 35 | - if (time() - $time < 15 * 60 |
|
| 36 | - and $GLOBALS['visiteur_session']['statut'] == '0minirezo' |
|
| 37 | - and $GLOBALS['visiteur_session']['webmestre'] !== 'oui' |
|
| 38 | - ) { |
|
| 39 | - $action = _T('info_admin_etre_webmestre'); |
|
| 40 | - $admin = charger_fonction('admin', 'inc'); |
|
| 41 | - // lance la verif par ftp et l'appel |
|
| 42 | - // a base_etre_webmestre_dist quand c'est OK |
|
| 43 | - if ($r = $admin('etre_webmestre', $action)) { |
|
| 44 | - echo $r; |
|
| 45 | - exit; |
|
| 46 | - } |
|
| 47 | - } |
|
| 32 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 33 | + $time = $securiser_action(); |
|
| 34 | + |
|
| 35 | + if (time() - $time < 15 * 60 |
|
| 36 | + and $GLOBALS['visiteur_session']['statut'] == '0minirezo' |
|
| 37 | + and $GLOBALS['visiteur_session']['webmestre'] !== 'oui' |
|
| 38 | + ) { |
|
| 39 | + $action = _T('info_admin_etre_webmestre'); |
|
| 40 | + $admin = charger_fonction('admin', 'inc'); |
|
| 41 | + // lance la verif par ftp et l'appel |
|
| 42 | + // a base_etre_webmestre_dist quand c'est OK |
|
| 43 | + if ($r = $admin('etre_webmestre', $action)) { |
|
| 44 | + echo $r; |
|
| 45 | + exit; |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | } |
| 50 | 50 | |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | * @return void |
| 55 | 55 | */ |
| 56 | 56 | function base_etre_webmestre_dist() { |
| 57 | - if ($GLOBALS['visiteur_session']['statut'] == '0minirezo' and $GLOBALS['visiteur_session']['webmestre'] !== 'oui') { |
|
| 58 | - include_spip('action/editer_auteur'); |
|
| 59 | - auteur_instituer($GLOBALS['visiteur_session']['id_auteur'], array('webmestre' => 'oui'), true); |
|
| 60 | - } |
|
| 57 | + if ($GLOBALS['visiteur_session']['statut'] == '0minirezo' and $GLOBALS['visiteur_session']['webmestre'] !== 'oui') { |
|
| 58 | + include_spip('action/editer_auteur'); |
|
| 59 | + auteur_instituer($GLOBALS['visiteur_session']['id_auteur'], array('webmestre' => 'oui'), true); |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | include_spip('inc/charsets'); |
| 23 | 23 | include_spip('inc/texte'); |
@@ -25,189 +25,189 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | // https://code.spip.net/@ligne_plug |
| 27 | 27 | function plugins_afficher_plugin_dist( |
| 28 | - $url_page, |
|
| 29 | - $plug_file, |
|
| 30 | - $checked, |
|
| 31 | - $actif, |
|
| 32 | - $expose = false, |
|
| 33 | - $class_li = "item", |
|
| 34 | - $dir_plugins = _DIR_PLUGINS |
|
| 28 | + $url_page, |
|
| 29 | + $plug_file, |
|
| 30 | + $checked, |
|
| 31 | + $actif, |
|
| 32 | + $expose = false, |
|
| 33 | + $class_li = "item", |
|
| 34 | + $dir_plugins = _DIR_PLUGINS |
|
| 35 | 35 | ) { |
| 36 | 36 | |
| 37 | - static $id_input = 0; |
|
| 38 | - static $versions = array(); |
|
| 39 | - |
|
| 40 | - $force_reload = (_request('var_mode') == 'recalcul'); |
|
| 41 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 42 | - $info = $get_infos($plug_file, $force_reload, $dir_plugins); |
|
| 43 | - $prefix = $info['prefix']; |
|
| 44 | - $cfg = ""; |
|
| 45 | - $checkable = ($dir_plugins !== _DIR_PLUGINS_DIST); |
|
| 46 | - $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 47 | - $erreur = ""; |
|
| 48 | - |
|
| 49 | - if (!plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 50 | - $info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 51 | - $erreur = http_img_pack("plugin-dis-32.png", _T('plugin_info_non_compatible_spip'), " class='picto_err'", |
|
| 52 | - _T('plugin_info_non_compatible_spip')); |
|
| 53 | - $class_li .= " disabled"; |
|
| 54 | - $checkable = false; |
|
| 55 | - } elseif (isset($info['erreur'])) { |
|
| 56 | - $class_li .= " error"; |
|
| 57 | - $erreur = http_img_pack("plugin-err-32.png", _T('plugin_info_erreur_xml'), " class='picto_err'", |
|
| 58 | - _T('plugin_info_erreur_xml')) |
|
| 59 | - . "<div class='erreur'>" . join('<br >', $info['erreur']) . "</div>"; |
|
| 60 | - $checkable = false; |
|
| 61 | - } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) { |
|
| 62 | - $class_li .= " error"; |
|
| 63 | - $erreur = http_img_pack("plugin-err-32.png", _T('plugin_impossible_activer', array('plugin' => $nom)), |
|
| 64 | - " class='picto_err'", _T('plugin_impossible_activer', array('plugin' => $nom))) |
|
| 65 | - . "<div class='erreur'>" . implode("<br />", |
|
| 66 | - $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file]) . "</div>"; |
|
| 67 | - } else { |
|
| 68 | - $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : ""; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - // numerotons les occurrences d'un meme prefix |
|
| 72 | - $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : ''; |
|
| 73 | - |
|
| 74 | - $class_li .= ($actif ? " actif" : "") . ($expose ? " on" : ""); |
|
| 75 | - |
|
| 76 | - return "<li id='$prefix$id' class='$class_li'>" |
|
| 77 | - . ((!$checkable and !$checked) |
|
| 78 | - ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked)) |
|
| 79 | - . plugin_resume($info, $dir_plugins, $plug_file, $url_page) |
|
| 80 | - . $cfg |
|
| 81 | - . $erreur |
|
| 82 | - . (($dir_plugins !== _DIR_PLUGINS_DIST and plugin_est_installe($plug_file)) |
|
| 83 | - ? plugin_desintalle($plug_file, $nom, $dir_plugins) : '') |
|
| 84 | - . "<div class='details'>" // pour l'ajax de exec/info_plugin |
|
| 85 | - . (!$expose ? '' : affiche_bloc_plugin($plug_file, $info, $dir_plugins)) |
|
| 86 | - . "</div>" |
|
| 87 | - . "</li>"; |
|
| 37 | + static $id_input = 0; |
|
| 38 | + static $versions = array(); |
|
| 39 | + |
|
| 40 | + $force_reload = (_request('var_mode') == 'recalcul'); |
|
| 41 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 42 | + $info = $get_infos($plug_file, $force_reload, $dir_plugins); |
|
| 43 | + $prefix = $info['prefix']; |
|
| 44 | + $cfg = ""; |
|
| 45 | + $checkable = ($dir_plugins !== _DIR_PLUGINS_DIST); |
|
| 46 | + $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 47 | + $erreur = ""; |
|
| 48 | + |
|
| 49 | + if (!plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 50 | + $info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 51 | + $erreur = http_img_pack("plugin-dis-32.png", _T('plugin_info_non_compatible_spip'), " class='picto_err'", |
|
| 52 | + _T('plugin_info_non_compatible_spip')); |
|
| 53 | + $class_li .= " disabled"; |
|
| 54 | + $checkable = false; |
|
| 55 | + } elseif (isset($info['erreur'])) { |
|
| 56 | + $class_li .= " error"; |
|
| 57 | + $erreur = http_img_pack("plugin-err-32.png", _T('plugin_info_erreur_xml'), " class='picto_err'", |
|
| 58 | + _T('plugin_info_erreur_xml')) |
|
| 59 | + . "<div class='erreur'>" . join('<br >', $info['erreur']) . "</div>"; |
|
| 60 | + $checkable = false; |
|
| 61 | + } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) { |
|
| 62 | + $class_li .= " error"; |
|
| 63 | + $erreur = http_img_pack("plugin-err-32.png", _T('plugin_impossible_activer', array('plugin' => $nom)), |
|
| 64 | + " class='picto_err'", _T('plugin_impossible_activer', array('plugin' => $nom))) |
|
| 65 | + . "<div class='erreur'>" . implode("<br />", |
|
| 66 | + $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file]) . "</div>"; |
|
| 67 | + } else { |
|
| 68 | + $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : ""; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + // numerotons les occurrences d'un meme prefix |
|
| 72 | + $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : ''; |
|
| 73 | + |
|
| 74 | + $class_li .= ($actif ? " actif" : "") . ($expose ? " on" : ""); |
|
| 75 | + |
|
| 76 | + return "<li id='$prefix$id' class='$class_li'>" |
|
| 77 | + . ((!$checkable and !$checked) |
|
| 78 | + ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked)) |
|
| 79 | + . plugin_resume($info, $dir_plugins, $plug_file, $url_page) |
|
| 80 | + . $cfg |
|
| 81 | + . $erreur |
|
| 82 | + . (($dir_plugins !== _DIR_PLUGINS_DIST and plugin_est_installe($plug_file)) |
|
| 83 | + ? plugin_desintalle($plug_file, $nom, $dir_plugins) : '') |
|
| 84 | + . "<div class='details'>" // pour l'ajax de exec/info_plugin |
|
| 85 | + . (!$expose ? '' : affiche_bloc_plugin($plug_file, $info, $dir_plugins)) |
|
| 86 | + . "</div>" |
|
| 87 | + . "</li>"; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | function plugin_bouton_config($nom, $infos, $dir) { |
| 91 | - // la verification se base sur le filesystem |
|
| 92 | - // il faut donc n'utiliser que des minuscules, par convention |
|
| 93 | - $prefix = strtolower($infos['prefix']); |
|
| 94 | - // si paquet.xml fournit un squelette, le prendre |
|
| 95 | - if (isset($infos['config']) and $infos['config']) { |
|
| 96 | - return recuperer_fond("$dir$nom/" . $infos['config'], |
|
| 97 | - array( |
|
| 98 | - 'script' => 'configurer_' . $prefix, |
|
| 99 | - 'nom' => $nom |
|
| 100 | - )); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - // si le plugin CFG est la, l'essayer |
|
| 104 | - if (defined('_DIR_PLUGIN_CFG')) { |
|
| 105 | - if (include_spip('inc/cfg')) // test CFG version >= 1.0.5 |
|
| 106 | - { |
|
| 107 | - if ($cfg = icone_lien_cfg("$dir$nom", "cfg")) { |
|
| 108 | - return "<div class='cfg_link'>$cfg</div>"; |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - // sinon prendre le squelette std sur le nom std |
|
| 114 | - return recuperer_fond("prive/squelettes/inclure/cfg", |
|
| 115 | - array( |
|
| 116 | - 'script' => 'configurer_' . $prefix, |
|
| 117 | - 'nom' => $nom |
|
| 118 | - )); |
|
| 91 | + // la verification se base sur le filesystem |
|
| 92 | + // il faut donc n'utiliser que des minuscules, par convention |
|
| 93 | + $prefix = strtolower($infos['prefix']); |
|
| 94 | + // si paquet.xml fournit un squelette, le prendre |
|
| 95 | + if (isset($infos['config']) and $infos['config']) { |
|
| 96 | + return recuperer_fond("$dir$nom/" . $infos['config'], |
|
| 97 | + array( |
|
| 98 | + 'script' => 'configurer_' . $prefix, |
|
| 99 | + 'nom' => $nom |
|
| 100 | + )); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + // si le plugin CFG est la, l'essayer |
|
| 104 | + if (defined('_DIR_PLUGIN_CFG')) { |
|
| 105 | + if (include_spip('inc/cfg')) // test CFG version >= 1.0.5 |
|
| 106 | + { |
|
| 107 | + if ($cfg = icone_lien_cfg("$dir$nom", "cfg")) { |
|
| 108 | + return "<div class='cfg_link'>$cfg</div>"; |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + // sinon prendre le squelette std sur le nom std |
|
| 114 | + return recuperer_fond("prive/squelettes/inclure/cfg", |
|
| 115 | + array( |
|
| 116 | + 'script' => 'configurer_' . $prefix, |
|
| 117 | + 'nom' => $nom |
|
| 118 | + )); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | // checkbox pour activer ou desactiver |
| 122 | 122 | // si ce n'est pas une extension |
| 123 | 123 | |
| 124 | 124 | function plugin_checkbox($id_input, $file, $actif) { |
| 125 | - $name = substr(md5($file), 0, 16); |
|
| 126 | - |
|
| 127 | - return "<div class='check'>\n" |
|
| 128 | - . "<input type='checkbox' name='s$name' id='label_$id_input'" |
|
| 129 | - . ($actif ? " checked='checked'" : "") |
|
| 130 | - . " class='checkbox' value='O' />" |
|
| 131 | - . "\n<label for='label_$id_input'>" . _T('activer_plugin') . "</label>" |
|
| 132 | - . "</div>"; |
|
| 125 | + $name = substr(md5($file), 0, 16); |
|
| 126 | + |
|
| 127 | + return "<div class='check'>\n" |
|
| 128 | + . "<input type='checkbox' name='s$name' id='label_$id_input'" |
|
| 129 | + . ($actif ? " checked='checked'" : "") |
|
| 130 | + . " class='checkbox' value='O' />" |
|
| 131 | + . "\n<label for='label_$id_input'>" . _T('activer_plugin') . "</label>" |
|
| 132 | + . "</div>"; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | function plugin_nom($info, $dir_plugins, $plug_file) { |
| 136 | - $prefix = $info['prefix']; |
|
| 137 | - $dir = "$dir_plugins$plug_file"; |
|
| 138 | - // Si dtd paquet, on traite le nom soit par son item de langue soit par sa valeur immediate a l'index "nom" |
|
| 139 | - if ($info['dtd'] == "paquet") { |
|
| 140 | - $nom = plugin_typo("{$prefix}_nom", "$dir/lang/paquet-$prefix"); |
|
| 141 | - if (!$nom) { |
|
| 142 | - $nom = typo($info['nom']); |
|
| 143 | - } |
|
| 144 | - } else { |
|
| 145 | - $nom = typo(attribut_html($info['nom'])); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - return trim($nom); |
|
| 136 | + $prefix = $info['prefix']; |
|
| 137 | + $dir = "$dir_plugins$plug_file"; |
|
| 138 | + // Si dtd paquet, on traite le nom soit par son item de langue soit par sa valeur immediate a l'index "nom" |
|
| 139 | + if ($info['dtd'] == "paquet") { |
|
| 140 | + $nom = plugin_typo("{$prefix}_nom", "$dir/lang/paquet-$prefix"); |
|
| 141 | + if (!$nom) { |
|
| 142 | + $nom = typo($info['nom']); |
|
| 143 | + } |
|
| 144 | + } else { |
|
| 145 | + $nom = typo(attribut_html($info['nom'])); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + return trim($nom); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Cartouche Resume |
| 152 | 152 | function plugin_resume($info, $dir_plugins, $plug_file, $url_page) { |
| 153 | - $prefix = $info['prefix']; |
|
| 154 | - $dir = "$dir_plugins$plug_file"; |
|
| 155 | - $slogan = PtoBR(plugin_propre($info['slogan'], "$dir/lang/paquet-$prefix")); |
|
| 156 | - // une seule ligne dans le slogan : couper si besoin |
|
| 157 | - if (($p = strpos($slogan, "<br />")) !== false) { |
|
| 158 | - $slogan = substr($slogan, 0, $p); |
|
| 159 | - } |
|
| 160 | - // couper par securite |
|
| 161 | - $slogan = couper($slogan, 80); |
|
| 162 | - |
|
| 163 | - $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 164 | - |
|
| 165 | - $url = parametre_url($url_page, "plugin", substr($dir, strlen(_DIR_RACINE))); |
|
| 166 | - |
|
| 167 | - $icon_class = 'icon'; |
|
| 168 | - $img = ''; |
|
| 169 | - if (isset($info['logo']) and $i = trim($info['logo'])) { |
|
| 170 | - if ($img = chemin_image("$dir/$i")) { |
|
| 171 | - $img = http_img_pack($img, '', " width='32' height='32'", '', ['variante_svg_si_possible' => true, 'chemin_image' => false]); |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - if (!$img) { |
|
| 175 | - $img = http_img_pack("plugin-xx.svg", '', " width='32' height='32'"); |
|
| 176 | - $icon_class .= ' no-logo'; |
|
| 177 | - } |
|
| 178 | - else { |
|
| 153 | + $prefix = $info['prefix']; |
|
| 154 | + $dir = "$dir_plugins$plug_file"; |
|
| 155 | + $slogan = PtoBR(plugin_propre($info['slogan'], "$dir/lang/paquet-$prefix")); |
|
| 156 | + // une seule ligne dans le slogan : couper si besoin |
|
| 157 | + if (($p = strpos($slogan, "<br />")) !== false) { |
|
| 158 | + $slogan = substr($slogan, 0, $p); |
|
| 159 | + } |
|
| 160 | + // couper par securite |
|
| 161 | + $slogan = couper($slogan, 80); |
|
| 162 | + |
|
| 163 | + $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 164 | + |
|
| 165 | + $url = parametre_url($url_page, "plugin", substr($dir, strlen(_DIR_RACINE))); |
|
| 166 | + |
|
| 167 | + $icon_class = 'icon'; |
|
| 168 | + $img = ''; |
|
| 169 | + if (isset($info['logo']) and $i = trim($info['logo'])) { |
|
| 170 | + if ($img = chemin_image("$dir/$i")) { |
|
| 171 | + $img = http_img_pack($img, '', " width='32' height='32'", '', ['variante_svg_si_possible' => true, 'chemin_image' => false]); |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + if (!$img) { |
|
| 175 | + $img = http_img_pack("plugin-xx.svg", '', " width='32' height='32'"); |
|
| 176 | + $icon_class .= ' no-logo'; |
|
| 177 | + } |
|
| 178 | + else { |
|
| 179 | 179 | # $img = "<img src='$img' width='32' height='32' alt='' />"; |
| 180 | - } |
|
| 181 | - $i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>"; |
|
| 182 | - |
|
| 183 | - return "<div class='resume'>" |
|
| 184 | - . "<h3><a href='$url' rel='info'>" |
|
| 185 | - . $nom |
|
| 186 | - . "</a></h3>" |
|
| 187 | - . " <span class='version'>" . $info['version'] . "</span>" |
|
| 188 | - . " <span class='etat'> - " |
|
| 189 | - . plugin_etat_en_clair($info['etat']) |
|
| 190 | - . "</span>" |
|
| 191 | - . "<div class='short'>" . $slogan . "</div>" |
|
| 192 | - . $i |
|
| 193 | - . "</div>"; |
|
| 180 | + } |
|
| 181 | + $i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>"; |
|
| 182 | + |
|
| 183 | + return "<div class='resume'>" |
|
| 184 | + . "<h3><a href='$url' rel='info'>" |
|
| 185 | + . $nom |
|
| 186 | + . "</a></h3>" |
|
| 187 | + . " <span class='version'>" . $info['version'] . "</span>" |
|
| 188 | + . " <span class='etat'> - " |
|
| 189 | + . plugin_etat_en_clair($info['etat']) |
|
| 190 | + . "</span>" |
|
| 191 | + . "<div class='short'>" . $slogan . "</div>" |
|
| 192 | + . $i |
|
| 193 | + . "</div>"; |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | function plugin_desintalle($plug_file, $nom, $dir_plugins = null) { |
| 197 | - if (!$dir_plugins) { |
|
| 198 | - $dir_plugins = _DIR_PLUGINS; |
|
| 199 | - } |
|
| 197 | + if (!$dir_plugins) { |
|
| 198 | + $dir_plugins = _DIR_PLUGINS; |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - $action = redirige_action_auteur('desinstaller_plugin', "$dir_plugins::$plug_file", 'admin_plugin'); |
|
| 202 | - $text = _T('bouton_desinstaller'); |
|
| 203 | - $text2 = _T('info_desinstaller_plugin'); |
|
| 204 | - $file = basename($plug_file); |
|
| 201 | + $action = redirige_action_auteur('desinstaller_plugin', "$dir_plugins::$plug_file", 'admin_plugin'); |
|
| 202 | + $text = _T('bouton_desinstaller'); |
|
| 203 | + $text2 = _T('info_desinstaller_plugin'); |
|
| 204 | + $file = basename($plug_file); |
|
| 205 | 205 | |
| 206 | - return "<div class='actions'>[" . |
|
| 207 | - "<a href='$action' |
|
| 206 | + return "<div class='actions'>[" . |
|
| 207 | + "<a href='$action' |
|
| 208 | 208 | onclick='return confirm(\"$text $nom ?\\n$text2\")'>" |
| 209 | - . $text |
|
| 210 | - . "</a>]</div>"; |
|
| 209 | + . $text |
|
| 210 | + . "</a>]</div>"; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -221,137 +221,137 @@ discard block |
||
| 221 | 221 | * Traduction de l'état dans la langue en cours |
| 222 | 222 | **/ |
| 223 | 223 | function plugin_etat_en_clair($etat) { |
| 224 | - if (!in_array($etat, array('stable', 'test', 'experimental'))) { |
|
| 225 | - $etat = 'developpement'; |
|
| 226 | - } |
|
| 224 | + if (!in_array($etat, array('stable', 'test', 'experimental'))) { |
|
| 225 | + $etat = 'developpement'; |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | - return _T('plugin_etat_' . $etat); |
|
| 228 | + return _T('plugin_etat_' . $etat); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | // https://code.spip.net/@plugin_propre |
| 232 | 232 | function plugin_propre($texte, $module = '',$propre='propre') { |
| 233 | - // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine |
|
| 234 | - if (_DIR_RACINE and strncmp($module, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) { |
|
| 235 | - $module = substr($module, strlen(_DIR_RACINE)); |
|
| 236 | - } |
|
| 237 | - if (preg_match("|^\w+_[\w_]+$|", $texte)) { |
|
| 238 | - $texte = _T(($module ? "$module:" : '') . $texte, array(), array('force' => false)); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - return $propre($texte); |
|
| 233 | + // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine |
|
| 234 | + if (_DIR_RACINE and strncmp($module, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) { |
|
| 235 | + $module = substr($module, strlen(_DIR_RACINE)); |
|
| 236 | + } |
|
| 237 | + if (preg_match("|^\w+_[\w_]+$|", $texte)) { |
|
| 238 | + $texte = _T(($module ? "$module:" : '') . $texte, array(), array('force' => false)); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + return $propre($texte); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | function plugin_typo($texte, $module = '') { |
| 245 | - return plugin_propre($texte, $module, 'typo'); |
|
| 245 | + return plugin_propre($texte, $module, 'typo'); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
| 249 | 249 | // https://code.spip.net/@affiche_bloc_plugin |
| 250 | 250 | function affiche_bloc_plugin($plug_file, $info, $dir_plugins = null) { |
| 251 | - if (!$dir_plugins) { |
|
| 252 | - $dir_plugins = _DIR_PLUGINS; |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - $prefix = $info['prefix']; |
|
| 256 | - $dir = "$dir_plugins$plug_file/lang/paquet-$prefix"; |
|
| 257 | - |
|
| 258 | - $s = ""; |
|
| 259 | - // TODO: le traiter_multi ici n'est pas beau |
|
| 260 | - // cf. description du plugin/_stable_/ortho/plugin.xml |
|
| 261 | - // concerne les anciens plugin.xml donc on devrait plus en avoir besoin |
|
| 262 | - $description = ""; |
|
| 263 | - if (isset($info['description'])) { |
|
| 264 | - $description = plugin_propre($info['description'], $dir); |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - if (isset($info['documentation']) |
|
| 268 | - and $lien = $info['documentation'] |
|
| 269 | - ) { |
|
| 270 | - $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>'; |
|
| 271 | - } |
|
| 272 | - $s .= "<dd class='desc'>" . $description . "</dd>\n"; |
|
| 273 | - |
|
| 274 | - if (isset($info['auteur'])) { |
|
| 275 | - if (is_array($info['auteur'])) { |
|
| 276 | - $a = formater_credits($info['auteur'], ', '); |
|
| 277 | - } // pour compat mais ne doit plus arriver |
|
| 278 | - else { |
|
| 279 | - $a = trim($info['auteur']); |
|
| 280 | - } |
|
| 281 | - if ($a) { |
|
| 282 | - $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre($a, |
|
| 283 | - $dir)) . "</dd>\n"; |
|
| 284 | - } |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - if (isset($info['credit'])) { |
|
| 288 | - if ($a = formater_credits($info['credit'], ', ')) { |
|
| 289 | - $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre($a, |
|
| 290 | - $dir)) . "</dd>\n"; |
|
| 291 | - } |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - if (isset($info['licence'])) { |
|
| 295 | - if (is_array($info['licence'])) { |
|
| 296 | - $a = formater_credits($info['licence'], ', '); |
|
| 297 | - } // pour compat mais ne doit plus arriver |
|
| 298 | - else { |
|
| 299 | - $a = trim($info['licence']); |
|
| 300 | - } |
|
| 301 | - if ($a) { |
|
| 302 | - $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre($a, |
|
| 303 | - $dir)) . "</dd>\n"; |
|
| 304 | - } |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - $s = "<dl class='description'>$s</dl>"; |
|
| 308 | - |
|
| 309 | - // |
|
| 310 | - // Ajouter les infos techniques |
|
| 311 | - // |
|
| 312 | - $infotech = array(); |
|
| 313 | - |
|
| 314 | - $version = "<dt>" . _T('version') . "</dt><dd>" . $info['version']; |
|
| 315 | - // Version VCS |
|
| 316 | - if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) { |
|
| 317 | - $version .= ' ' . $vcs; |
|
| 318 | - } |
|
| 319 | - $version .= "</dd>"; |
|
| 320 | - $infotech[] = $version; |
|
| 321 | - $infotech[] = "<dt>" . _T('repertoire_plugins') . "</dt><dd>" . joli_repertoire("$dir_plugins$plug_file") . "</dd>"; |
|
| 322 | - // source zip le cas echeant |
|
| 323 | - $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log) |
|
| 324 | - and preg_match(',^source:(.*)$,m', $log, $r)) |
|
| 325 | - ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . "</dd>" |
|
| 326 | - : ''; |
|
| 327 | - |
|
| 328 | - $infotech[] = !$info['necessite'] ? '' : |
|
| 329 | - ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join(' ', |
|
| 330 | - array_map('array_shift', $info['necessite'])) . '</dd>'); |
|
| 331 | - |
|
| 332 | - $s .= "<dl class='tech'>" |
|
| 333 | - . join('', $infotech) |
|
| 334 | - . "</dl>"; |
|
| 335 | - |
|
| 336 | - |
|
| 337 | - return $s; |
|
| 251 | + if (!$dir_plugins) { |
|
| 252 | + $dir_plugins = _DIR_PLUGINS; |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + $prefix = $info['prefix']; |
|
| 256 | + $dir = "$dir_plugins$plug_file/lang/paquet-$prefix"; |
|
| 257 | + |
|
| 258 | + $s = ""; |
|
| 259 | + // TODO: le traiter_multi ici n'est pas beau |
|
| 260 | + // cf. description du plugin/_stable_/ortho/plugin.xml |
|
| 261 | + // concerne les anciens plugin.xml donc on devrait plus en avoir besoin |
|
| 262 | + $description = ""; |
|
| 263 | + if (isset($info['description'])) { |
|
| 264 | + $description = plugin_propre($info['description'], $dir); |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + if (isset($info['documentation']) |
|
| 268 | + and $lien = $info['documentation'] |
|
| 269 | + ) { |
|
| 270 | + $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>'; |
|
| 271 | + } |
|
| 272 | + $s .= "<dd class='desc'>" . $description . "</dd>\n"; |
|
| 273 | + |
|
| 274 | + if (isset($info['auteur'])) { |
|
| 275 | + if (is_array($info['auteur'])) { |
|
| 276 | + $a = formater_credits($info['auteur'], ', '); |
|
| 277 | + } // pour compat mais ne doit plus arriver |
|
| 278 | + else { |
|
| 279 | + $a = trim($info['auteur']); |
|
| 280 | + } |
|
| 281 | + if ($a) { |
|
| 282 | + $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre($a, |
|
| 283 | + $dir)) . "</dd>\n"; |
|
| 284 | + } |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + if (isset($info['credit'])) { |
|
| 288 | + if ($a = formater_credits($info['credit'], ', ')) { |
|
| 289 | + $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre($a, |
|
| 290 | + $dir)) . "</dd>\n"; |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + if (isset($info['licence'])) { |
|
| 295 | + if (is_array($info['licence'])) { |
|
| 296 | + $a = formater_credits($info['licence'], ', '); |
|
| 297 | + } // pour compat mais ne doit plus arriver |
|
| 298 | + else { |
|
| 299 | + $a = trim($info['licence']); |
|
| 300 | + } |
|
| 301 | + if ($a) { |
|
| 302 | + $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre($a, |
|
| 303 | + $dir)) . "</dd>\n"; |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + $s = "<dl class='description'>$s</dl>"; |
|
| 308 | + |
|
| 309 | + // |
|
| 310 | + // Ajouter les infos techniques |
|
| 311 | + // |
|
| 312 | + $infotech = array(); |
|
| 313 | + |
|
| 314 | + $version = "<dt>" . _T('version') . "</dt><dd>" . $info['version']; |
|
| 315 | + // Version VCS |
|
| 316 | + if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) { |
|
| 317 | + $version .= ' ' . $vcs; |
|
| 318 | + } |
|
| 319 | + $version .= "</dd>"; |
|
| 320 | + $infotech[] = $version; |
|
| 321 | + $infotech[] = "<dt>" . _T('repertoire_plugins') . "</dt><dd>" . joli_repertoire("$dir_plugins$plug_file") . "</dd>"; |
|
| 322 | + // source zip le cas echeant |
|
| 323 | + $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log) |
|
| 324 | + and preg_match(',^source:(.*)$,m', $log, $r)) |
|
| 325 | + ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . "</dd>" |
|
| 326 | + : ''; |
|
| 327 | + |
|
| 328 | + $infotech[] = !$info['necessite'] ? '' : |
|
| 329 | + ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join(' ', |
|
| 330 | + array_map('array_shift', $info['necessite'])) . '</dd>'); |
|
| 331 | + |
|
| 332 | + $s .= "<dl class='tech'>" |
|
| 333 | + . join('', $infotech) |
|
| 334 | + . "</dl>"; |
|
| 335 | + |
|
| 336 | + |
|
| 337 | + return $s; |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | function formater_credits($infos, $sep = ', ') { |
| 341 | - $texte = ''; |
|
| 342 | - |
|
| 343 | - foreach ($infos as $_credit) { |
|
| 344 | - if ($texte) { |
|
| 345 | - $texte .= $sep; |
|
| 346 | - } |
|
| 347 | - // Si le credit en cours n'est pas un array c'est donc un copyright |
|
| 348 | - $texte .= |
|
| 349 | - (!is_array($_credit)) |
|
| 350 | - ? PtoBR(propre($_credit)) |
|
| 351 | - : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') . |
|
| 352 | - $_credit['nom'] . |
|
| 353 | - ($_credit['url'] ? '</a>' : ''); |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - return $texte; |
|
| 341 | + $texte = ''; |
|
| 342 | + |
|
| 343 | + foreach ($infos as $_credit) { |
|
| 344 | + if ($texte) { |
|
| 345 | + $texte .= $sep; |
|
| 346 | + } |
|
| 347 | + // Si le credit en cours n'est pas un array c'est donc un copyright |
|
| 348 | + $texte .= |
|
| 349 | + (!is_array($_credit)) |
|
| 350 | + ? PtoBR(propre($_credit)) |
|
| 351 | + : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') . |
|
| 352 | + $_credit['nom'] . |
|
| 353 | + ($_credit['url'] ? '</a>' : ''); |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + return $texte; |
|
| 357 | 357 | } |