@@ -51,29 +51,28 @@ discard block |
||
| 51 | 51 | $conn = "\$GLOBALS['ldap_base'] = '$base_ldap';\n" |
| 52 | 52 | . "\$GLOBALS['ldap_link'] = @ldap_connect('$adresse_ldap','$port_ldap');\n" |
| 53 | 53 | . "@ldap_set_option(\$GLOBALS['ldap_link'],LDAP_OPT_PROTOCOL_VERSION,'$protocole_ldap');\n" |
| 54 | - . (($tls_ldap != 'oui') ? '' : |
|
| 55 | - "@ldap_start_tls(\$GLOBALS['ldap_link']);\n") |
|
| 54 | + . (($tls_ldap != 'oui') ? '' : "@ldap_start_tls(\$GLOBALS['ldap_link']);\n") |
|
| 56 | 55 | . "@ldap_bind(\$GLOBALS['ldap_link'],'$login_ldap','$pass_ldap');\n"; |
| 57 | 56 | |
| 58 | 57 | $champs = is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : []; |
| 59 | 58 | $res = ''; |
| 60 | 59 | foreach (array_keys($champs) as $champ) { |
| 61 | - $nom = 'ldap_' . $champ; |
|
| 60 | + $nom = 'ldap_'.$champ; |
|
| 62 | 61 | $val = trim((string) _request($nom)); |
| 63 | 62 | if (preg_match('/^\w*$/', $val)) { |
| 64 | 63 | if ($val) { |
| 65 | 64 | $val = _q($val); |
| 66 | 65 | } |
| 67 | 66 | } else { |
| 68 | - $val = 'array(' . _q(preg_split('/\W+/', $val)) . ')'; |
|
| 67 | + $val = 'array('._q(preg_split('/\W+/', $val)).')'; |
|
| 69 | 68 | }; |
| 70 | 69 | if ($val) { |
| 71 | - $res .= "'$champ' => " . $val . ','; |
|
| 70 | + $res .= "'$champ' => ".$val.','; |
|
| 72 | 71 | } |
| 73 | 72 | } |
| 74 | 73 | $conn .= "\$GLOBALS['ldap_champs'] = array($res);\n"; |
| 75 | 74 | |
| 76 | - install_fichier_connexion(_DIR_CONNECT . _FILE_LDAP, $conn); |
|
| 75 | + install_fichier_connexion(_DIR_CONNECT._FILE_LDAP, $conn); |
|
| 77 | 76 | } |
| 78 | 77 | |
| 79 | 78 | function etape_ldap5_suite() { |
@@ -86,7 +85,7 @@ discard block |
||
| 86 | 85 | ); |
| 87 | 86 | |
| 88 | 87 | echo generer_form_ecrire('install', ( |
| 89 | - "<input type='hidden' name='etape' value='3' />" . |
|
| 88 | + "<input type='hidden' name='etape' value='3' />". |
|
| 90 | 89 | "<input type='hidden' name='ldap_present' value='true' />" |
| 91 | 90 | . bouton_suivant())); |
| 92 | 91 | |
@@ -12,85 +12,85 @@ |
||
| 12 | 12 | \***************************************************************************/ |
| 13 | 13 | |
| 14 | 14 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | } |
| 17 | 17 | include_spip('inc/headers'); |
| 18 | 18 | include_spip('auth/ldap'); |
| 19 | 19 | |
| 20 | 20 | function install_etape_ldap5_dist() { |
| 21 | - etape_ldap5_save(); |
|
| 22 | - etape_ldap5_suite(); |
|
| 21 | + etape_ldap5_save(); |
|
| 22 | + etape_ldap5_suite(); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | function etape_ldap5_save() { |
| 26 | - $conn = null; |
|
| 27 | - if (!@file_exists(_FILE_CONNECT_TMP)) { |
|
| 28 | - redirige_url_ecrire('install'); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - ecrire_meta('ldap_statut_import', _request('statut_ldap')); |
|
| 32 | - |
|
| 33 | - lire_fichier(_FILE_CONNECT_TMP, $conn); |
|
| 34 | - |
|
| 35 | - if ($p = strpos((string) $conn, "'');")) { |
|
| 36 | - ecrire_fichier( |
|
| 37 | - _FILE_CONNECT_TMP, |
|
| 38 | - substr((string) $conn, 0, $p + 1) |
|
| 39 | - . _FILE_LDAP |
|
| 40 | - . substr((string) $conn, $p + 1) |
|
| 41 | - ); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - $adresse_ldap = addcslashes((string) _request('adresse_ldap'), "'\\"); |
|
| 45 | - $login_ldap = addcslashes((string) _request('login_ldap'), "'\\"); |
|
| 46 | - $pass_ldap = addcslashes((string) _request('pass_ldap'), "'\\"); |
|
| 47 | - $port_ldap = addcslashes((string) _request('port_ldap'), "'\\"); |
|
| 48 | - $tls_ldap = addcslashes((string) _request('tls_ldap'), "'\\"); |
|
| 49 | - $protocole_ldap = addcslashes((string) _request('protocole_ldap'), "'\\"); |
|
| 50 | - $base_ldap = addcslashes((string) _request('base_ldap'), "'\\"); |
|
| 51 | - $base_ldap_text = addcslashes((string) _request('base_ldap_text'), "'\\"); |
|
| 52 | - |
|
| 53 | - $conn = "\$GLOBALS['ldap_base'] = '$base_ldap';\n" |
|
| 54 | - . "\$GLOBALS['ldap_link'] = @ldap_connect('$adresse_ldap','$port_ldap');\n" |
|
| 55 | - . "@ldap_set_option(\$GLOBALS['ldap_link'],LDAP_OPT_PROTOCOL_VERSION,'$protocole_ldap');\n" |
|
| 56 | - . (($tls_ldap != 'oui') ? '' : |
|
| 57 | - "@ldap_start_tls(\$GLOBALS['ldap_link']);\n") |
|
| 58 | - . "@ldap_bind(\$GLOBALS['ldap_link'],'$login_ldap','$pass_ldap');\n"; |
|
| 59 | - |
|
| 60 | - $champs = is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : []; |
|
| 61 | - $res = ''; |
|
| 62 | - foreach (array_keys($champs) as $champ) { |
|
| 63 | - $nom = 'ldap_' . $champ; |
|
| 64 | - $val = trim((string) _request($nom)); |
|
| 65 | - if (preg_match('/^\w*$/', $val)) { |
|
| 66 | - if ($val) { |
|
| 67 | - $val = _q($val); |
|
| 68 | - } |
|
| 69 | - } else { |
|
| 70 | - $val = 'array(' . _q(preg_split('/\W+/', $val)) . ')'; |
|
| 71 | - }; |
|
| 72 | - if ($val) { |
|
| 73 | - $res .= "'$champ' => " . $val . ','; |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - $conn .= "\$GLOBALS['ldap_champs'] = array($res);\n"; |
|
| 77 | - |
|
| 78 | - install_fichier_connexion(_DIR_CONNECT . _FILE_LDAP, $conn); |
|
| 26 | + $conn = null; |
|
| 27 | + if (!@file_exists(_FILE_CONNECT_TMP)) { |
|
| 28 | + redirige_url_ecrire('install'); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + ecrire_meta('ldap_statut_import', _request('statut_ldap')); |
|
| 32 | + |
|
| 33 | + lire_fichier(_FILE_CONNECT_TMP, $conn); |
|
| 34 | + |
|
| 35 | + if ($p = strpos((string) $conn, "'');")) { |
|
| 36 | + ecrire_fichier( |
|
| 37 | + _FILE_CONNECT_TMP, |
|
| 38 | + substr((string) $conn, 0, $p + 1) |
|
| 39 | + . _FILE_LDAP |
|
| 40 | + . substr((string) $conn, $p + 1) |
|
| 41 | + ); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + $adresse_ldap = addcslashes((string) _request('adresse_ldap'), "'\\"); |
|
| 45 | + $login_ldap = addcslashes((string) _request('login_ldap'), "'\\"); |
|
| 46 | + $pass_ldap = addcslashes((string) _request('pass_ldap'), "'\\"); |
|
| 47 | + $port_ldap = addcslashes((string) _request('port_ldap'), "'\\"); |
|
| 48 | + $tls_ldap = addcslashes((string) _request('tls_ldap'), "'\\"); |
|
| 49 | + $protocole_ldap = addcslashes((string) _request('protocole_ldap'), "'\\"); |
|
| 50 | + $base_ldap = addcslashes((string) _request('base_ldap'), "'\\"); |
|
| 51 | + $base_ldap_text = addcslashes((string) _request('base_ldap_text'), "'\\"); |
|
| 52 | + |
|
| 53 | + $conn = "\$GLOBALS['ldap_base'] = '$base_ldap';\n" |
|
| 54 | + . "\$GLOBALS['ldap_link'] = @ldap_connect('$adresse_ldap','$port_ldap');\n" |
|
| 55 | + . "@ldap_set_option(\$GLOBALS['ldap_link'],LDAP_OPT_PROTOCOL_VERSION,'$protocole_ldap');\n" |
|
| 56 | + . (($tls_ldap != 'oui') ? '' : |
|
| 57 | + "@ldap_start_tls(\$GLOBALS['ldap_link']);\n") |
|
| 58 | + . "@ldap_bind(\$GLOBALS['ldap_link'],'$login_ldap','$pass_ldap');\n"; |
|
| 59 | + |
|
| 60 | + $champs = is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : []; |
|
| 61 | + $res = ''; |
|
| 62 | + foreach (array_keys($champs) as $champ) { |
|
| 63 | + $nom = 'ldap_' . $champ; |
|
| 64 | + $val = trim((string) _request($nom)); |
|
| 65 | + if (preg_match('/^\w*$/', $val)) { |
|
| 66 | + if ($val) { |
|
| 67 | + $val = _q($val); |
|
| 68 | + } |
|
| 69 | + } else { |
|
| 70 | + $val = 'array(' . _q(preg_split('/\W+/', $val)) . ')'; |
|
| 71 | + }; |
|
| 72 | + if ($val) { |
|
| 73 | + $res .= "'$champ' => " . $val . ','; |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + $conn .= "\$GLOBALS['ldap_champs'] = array($res);\n"; |
|
| 77 | + |
|
| 78 | + install_fichier_connexion(_DIR_CONNECT . _FILE_LDAP, $conn); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | function etape_ldap5_suite() { |
| 82 | - $minipage = new Installation(); |
|
| 83 | - echo $minipage->installDebutPage(['onload' => 'document.getElementById(\'suivant\').focus();return false;']); |
|
| 82 | + $minipage = new Installation(); |
|
| 83 | + echo $minipage->installDebutPage(['onload' => 'document.getElementById(\'suivant\').focus();return false;']); |
|
| 84 | 84 | |
| 85 | - echo info_etape( |
|
| 86 | - _T('info_ldap_ok'), |
|
| 87 | - info_progression_etape(5, 'etape_ldap', 'install/') |
|
| 88 | - ); |
|
| 85 | + echo info_etape( |
|
| 86 | + _T('info_ldap_ok'), |
|
| 87 | + info_progression_etape(5, 'etape_ldap', 'install/') |
|
| 88 | + ); |
|
| 89 | 89 | |
| 90 | - echo generer_form_ecrire('install', ( |
|
| 91 | - "<input type='hidden' name='etape' value='3' />" . |
|
| 92 | - "<input type='hidden' name='ldap_present' value='true' />" |
|
| 93 | - . bouton_suivant())); |
|
| 90 | + echo generer_form_ecrire('install', ( |
|
| 91 | + "<input type='hidden' name='etape' value='3' />" . |
|
| 92 | + "<input type='hidden' name='ldap_present' value='true' />" |
|
| 93 | + . bouton_suivant())); |
|
| 94 | 94 | |
| 95 | - echo $minipage->installFinPage(); |
|
| 95 | + echo $minipage->installFinPage(); |
|
| 96 | 96 | } |
@@ -86,17 +86,17 @@ discard block |
||
| 86 | 86 | $cles = \Spip\Chiffrer\SpipCles::instance(); |
| 87 | 87 | $secret = $cles->getSecretAuth(); |
| 88 | 88 | |
| 89 | - $id_auteur = sql_getfetsel('id_auteur', 'spip_auteurs', 'login=' . sql_quote($login)); |
|
| 89 | + $id_auteur = sql_getfetsel('id_auteur', 'spip_auteurs', 'login='.sql_quote($login)); |
|
| 90 | 90 | if ($id_auteur !== null) { |
| 91 | 91 | // c'est un auteur connu : si on a pas de secret il faut absolument qu'il se reconnecte avec le meme mot de passe |
| 92 | 92 | // pour restaurer la copie des cles |
| 93 | 93 | if (!$secret && !auth_spip_initialiser_secret()) { |
| 94 | - $row = sql_fetsel('backup_cles, pass', 'spip_auteurs', 'id_auteur=' . (int) $id_auteur); |
|
| 94 | + $row = sql_fetsel('backup_cles, pass', 'spip_auteurs', 'id_auteur='.(int) $id_auteur); |
|
| 95 | 95 | if (empty($row['backup_cles']) || !$cles->restore($row['backup_cles'], $pass, $row['pass'], $id_auteur)) { |
| 96 | 96 | $echec = _T('avis_connexion_erreur_fichier_cle_manquant_1'); |
| 97 | 97 | echouer_etape_3b($echec); |
| 98 | 98 | } |
| 99 | - spip_log("Les cles secretes ont ete restaurées avec le backup du webmestre #$id_auteur", 'auth' . _LOG_INFO_IMPORTANTE); |
|
| 99 | + spip_log("Les cles secretes ont ete restaurées avec le backup du webmestre #$id_auteur", 'auth'._LOG_INFO_IMPORTANTE); |
|
| 100 | 100 | $cles->save(); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | 'email' => $email, |
| 106 | 106 | 'login' => $login, |
| 107 | 107 | 'statut' => '0minirezo' |
| 108 | - ], 'id_auteur=' . (int) $id_auteur); |
|
| 108 | + ], 'id_auteur='.(int) $id_auteur); |
|
| 109 | 109 | // le passer webmestre separement du reste, au cas ou l'alter n'aurait pas fonctionne |
| 110 | 110 | @sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur"); |
| 111 | 111 | if (!auth_spip_modifier_pass($login, $pass, $id_auteur)) { |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | include_spip('inc/auth'); |
| 146 | 146 | $auteur = auth_identifier_login($login, $pass); |
| 147 | 147 | if (!$auteur || !auth_loger($auteur)) { |
| 148 | - spip_log("login automatique impossible $auth_spip $session" . (is_countable($row) ? count($row) : 0)); |
|
| 148 | + spip_log("login automatique impossible $auth_spip $session".(is_countable($row) ? count($row) : 0)); |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
@@ -167,9 +167,9 @@ discard block |
||
| 167 | 167 | function echouer_etape_3b($echec): never { |
| 168 | 168 | echo minipres( |
| 169 | 169 | 'AUTO', |
| 170 | - info_progression_etape(3, 'etape_', 'install/', true) . |
|
| 171 | - "<div class='error'><h3>$echec</h3>\n" . |
|
| 172 | - '<p>' . _T('avis_connexion_echec_2') . '</p>' . |
|
| 170 | + info_progression_etape(3, 'etape_', 'install/', true). |
|
| 171 | + "<div class='error'><h3>$echec</h3>\n". |
|
| 172 | + '<p>'._T('avis_connexion_echec_2').'</p>'. |
|
| 173 | 173 | '</div>' |
| 174 | 174 | ); |
| 175 | 175 | exit; |
@@ -10,170 +10,170 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | include_spip('inc/headers'); |
| 17 | 17 | |
| 18 | 18 | function install_etape_3b_dist() { |
| 19 | - $auth_spip = null; |
|
| 20 | - $session = null; |
|
| 21 | - $row = null; |
|
| 22 | - $login = _request('login'); |
|
| 23 | - $email = _request('email'); |
|
| 24 | - $nom = _request('nom'); |
|
| 25 | - $pass = _request('pass'); |
|
| 26 | - $pass_verif = _request('pass_verif'); |
|
| 27 | - |
|
| 28 | - $server_db = defined('_INSTALL_SERVER_DB') |
|
| 29 | - ? _INSTALL_SERVER_DB |
|
| 30 | - : _request('server_db'); |
|
| 31 | - |
|
| 32 | - if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 33 | - define('_PASS_LONGUEUR_MINI', 6); |
|
| 34 | - } |
|
| 35 | - if (!defined('_LOGIN_TROP_COURT')) { |
|
| 36 | - define('_LOGIN_TROP_COURT', 4); |
|
| 37 | - } |
|
| 38 | - if ($login) { |
|
| 39 | - $echec = ($pass != $pass_verif) ? |
|
| 40 | - _T('info_passes_identiques') |
|
| 41 | - : ((strlen((string) $pass) < _PASS_LONGUEUR_MINI) ? |
|
| 42 | - _T('info_passe_trop_court_car_pluriel', ['nb' => _PASS_LONGUEUR_MINI]) |
|
| 43 | - : ((strlen((string) $login) < _LOGIN_TROP_COURT) ? |
|
| 44 | - _T('info_login_trop_court') |
|
| 45 | - : '')); |
|
| 46 | - include_spip('inc/filtres'); |
|
| 47 | - if (!$echec && $email && !email_valide($email)) { |
|
| 48 | - $echec = _T('form_email_non_valide'); |
|
| 49 | - } |
|
| 50 | - if ($echec) { |
|
| 51 | - echouer_etape_3b($echec); |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - if (@file_exists(_FILE_CHMOD_TMP)) { |
|
| 56 | - include(_FILE_CHMOD_TMP); |
|
| 57 | - } else { |
|
| 58 | - redirige_url_ecrire('install'); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - if (!@file_exists(_FILE_CONNECT_TMP)) { |
|
| 62 | - redirige_url_ecrire('install'); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - # maintenant on connait le vrai charset du site s'il est deja configure |
|
| 66 | - # sinon par defaut lire_meta reglera _DEFAULT_CHARSET |
|
| 67 | - # (les donnees arrivent de toute facon postees en _DEFAULT_CHARSET) |
|
| 68 | - |
|
| 69 | - lire_metas(); |
|
| 70 | - if ($login) { |
|
| 71 | - include_spip('inc/charsets'); |
|
| 72 | - |
|
| 73 | - $nom = (importer_charset($nom, _DEFAULT_CHARSET)); |
|
| 74 | - $login = (importer_charset($login, _DEFAULT_CHARSET)); |
|
| 75 | - $email = (importer_charset($email, _DEFAULT_CHARSET)); |
|
| 76 | - |
|
| 77 | - include_spip('auth/spip'); |
|
| 78 | - // prelablement, creer le champ webmestre si il n'existe pas (install neuve sur une vieille base) |
|
| 79 | - $t = sql_showtable('spip_auteurs', true); |
|
| 80 | - if (!isset($t['field']['webmestre'])) { |
|
| 81 | - @sql_alter("TABLE spip_auteurs ADD webmestre varchar(3) DEFAULT 'non' NOT NULL"); |
|
| 82 | - } |
|
| 83 | - // prelablement, creer le champ backup_cles si il n'existe pas (install neuve sur une vieille base) |
|
| 84 | - if (!isset($t['field']['backup_cles'])) { |
|
| 85 | - @sql_alter("TABLE spip_auteurs ADD backup_cles mediumtext DEFAULT '' NOT NULL"); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - // il faut avoir une cle des auth valide pour creer un nouvel auteur webmestre |
|
| 89 | - $cles = \Spip\Chiffrer\SpipCles::instance(); |
|
| 90 | - $secret = $cles->getSecretAuth(); |
|
| 91 | - |
|
| 92 | - $id_auteur = sql_getfetsel('id_auteur', 'spip_auteurs', 'login=' . sql_quote($login)); |
|
| 93 | - if ($id_auteur !== null) { |
|
| 94 | - // c'est un auteur connu : si on a pas de secret il faut absolument qu'il se reconnecte avec le meme mot de passe |
|
| 95 | - // pour restaurer la copie des cles |
|
| 96 | - if (!$secret && !auth_spip_initialiser_secret()) { |
|
| 97 | - $row = sql_fetsel('backup_cles, pass', 'spip_auteurs', 'id_auteur=' . (int) $id_auteur); |
|
| 98 | - if (empty($row['backup_cles']) || !$cles->restore($row['backup_cles'], $pass, $row['pass'], $id_auteur)) { |
|
| 99 | - $echec = _T('avis_connexion_erreur_fichier_cle_manquant_1'); |
|
| 100 | - echouer_etape_3b($echec); |
|
| 101 | - } |
|
| 102 | - spip_log("Les cles secretes ont ete restaurées avec le backup du webmestre #$id_auteur", 'auth' . _LOG_INFO_IMPORTANTE); |
|
| 103 | - $cles->save(); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - sql_updateq('spip_auteurs', [ |
|
| 107 | - 'nom' => $nom, |
|
| 108 | - 'email' => $email, |
|
| 109 | - 'login' => $login, |
|
| 110 | - 'statut' => '0minirezo' |
|
| 111 | - ], 'id_auteur=' . (int) $id_auteur); |
|
| 112 | - // le passer webmestre separement du reste, au cas ou l'alter n'aurait pas fonctionne |
|
| 113 | - @sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur"); |
|
| 114 | - if (!auth_spip_modifier_pass($login, $pass, $id_auteur)) { |
|
| 115 | - $echec = _T('avis_erreur_creation_compte'); |
|
| 116 | - echouer_etape_3b($echec); |
|
| 117 | - } |
|
| 118 | - } else { |
|
| 119 | - // Si on a pas de cle et qu'on ne sait pas la creer, on ne peut pas creer de nouveau compte : |
|
| 120 | - // il faut qu'un webmestre avec un backup fasse l'install |
|
| 121 | - if (!$secret && !auth_spip_initialiser_secret()) { |
|
| 122 | - $echec = _T('avis_connexion_erreur_fichier_cle_manquant_2'); |
|
| 123 | - echouer_etape_3b($echec); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - $id_auteur = sql_insertq('spip_auteurs', [ |
|
| 127 | - 'nom' => $nom, |
|
| 128 | - 'email' => $email, |
|
| 129 | - 'login' => $login, |
|
| 130 | - 'statut' => '0minirezo' |
|
| 131 | - ]); |
|
| 132 | - // le passer webmestre separrement du reste, au cas ou l'alter n'aurait pas fonctionne |
|
| 133 | - @sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur"); |
|
| 134 | - if (!auth_spip_modifier_pass($login, $pass, $id_auteur)) { |
|
| 135 | - $echec = _T('avis_erreur_creation_compte'); |
|
| 136 | - echouer_etape_3b($echec); |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - // inserer email comme email webmaster principal |
|
| 141 | - // (sauf s'il est vide: cas de la re-installation) |
|
| 142 | - if ($email) { |
|
| 143 | - ecrire_meta('email_webmaster', $email); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - // Connecter directement celui qui vient de (re)donner son login |
|
| 147 | - // mais sans cookie d'admin ni connexion longue |
|
| 148 | - include_spip('inc/auth'); |
|
| 149 | - $auteur = auth_identifier_login($login, $pass); |
|
| 150 | - if (!$auteur || !auth_loger($auteur)) { |
|
| 151 | - spip_log("login automatique impossible $auth_spip $session" . (is_countable($row) ? count($row) : 0)); |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - // installer les metas |
|
| 156 | - $config = charger_fonction('config', 'inc'); |
|
| 157 | - $config(); |
|
| 158 | - |
|
| 159 | - // activer les plugins |
|
| 160 | - // leur installation ne peut pas se faire sur le meme hit, il faudra donc |
|
| 161 | - // poursuivre au hit suivant |
|
| 162 | - include_spip('inc/plugin'); |
|
| 163 | - actualise_plugins_actifs(); |
|
| 164 | - |
|
| 165 | - |
|
| 166 | - include_spip('inc/distant'); |
|
| 167 | - redirige_par_entete(parametre_url(self(), 'etape', '4', '&')); |
|
| 19 | + $auth_spip = null; |
|
| 20 | + $session = null; |
|
| 21 | + $row = null; |
|
| 22 | + $login = _request('login'); |
|
| 23 | + $email = _request('email'); |
|
| 24 | + $nom = _request('nom'); |
|
| 25 | + $pass = _request('pass'); |
|
| 26 | + $pass_verif = _request('pass_verif'); |
|
| 27 | + |
|
| 28 | + $server_db = defined('_INSTALL_SERVER_DB') |
|
| 29 | + ? _INSTALL_SERVER_DB |
|
| 30 | + : _request('server_db'); |
|
| 31 | + |
|
| 32 | + if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 33 | + define('_PASS_LONGUEUR_MINI', 6); |
|
| 34 | + } |
|
| 35 | + if (!defined('_LOGIN_TROP_COURT')) { |
|
| 36 | + define('_LOGIN_TROP_COURT', 4); |
|
| 37 | + } |
|
| 38 | + if ($login) { |
|
| 39 | + $echec = ($pass != $pass_verif) ? |
|
| 40 | + _T('info_passes_identiques') |
|
| 41 | + : ((strlen((string) $pass) < _PASS_LONGUEUR_MINI) ? |
|
| 42 | + _T('info_passe_trop_court_car_pluriel', ['nb' => _PASS_LONGUEUR_MINI]) |
|
| 43 | + : ((strlen((string) $login) < _LOGIN_TROP_COURT) ? |
|
| 44 | + _T('info_login_trop_court') |
|
| 45 | + : '')); |
|
| 46 | + include_spip('inc/filtres'); |
|
| 47 | + if (!$echec && $email && !email_valide($email)) { |
|
| 48 | + $echec = _T('form_email_non_valide'); |
|
| 49 | + } |
|
| 50 | + if ($echec) { |
|
| 51 | + echouer_etape_3b($echec); |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + if (@file_exists(_FILE_CHMOD_TMP)) { |
|
| 56 | + include(_FILE_CHMOD_TMP); |
|
| 57 | + } else { |
|
| 58 | + redirige_url_ecrire('install'); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + if (!@file_exists(_FILE_CONNECT_TMP)) { |
|
| 62 | + redirige_url_ecrire('install'); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + # maintenant on connait le vrai charset du site s'il est deja configure |
|
| 66 | + # sinon par defaut lire_meta reglera _DEFAULT_CHARSET |
|
| 67 | + # (les donnees arrivent de toute facon postees en _DEFAULT_CHARSET) |
|
| 68 | + |
|
| 69 | + lire_metas(); |
|
| 70 | + if ($login) { |
|
| 71 | + include_spip('inc/charsets'); |
|
| 72 | + |
|
| 73 | + $nom = (importer_charset($nom, _DEFAULT_CHARSET)); |
|
| 74 | + $login = (importer_charset($login, _DEFAULT_CHARSET)); |
|
| 75 | + $email = (importer_charset($email, _DEFAULT_CHARSET)); |
|
| 76 | + |
|
| 77 | + include_spip('auth/spip'); |
|
| 78 | + // prelablement, creer le champ webmestre si il n'existe pas (install neuve sur une vieille base) |
|
| 79 | + $t = sql_showtable('spip_auteurs', true); |
|
| 80 | + if (!isset($t['field']['webmestre'])) { |
|
| 81 | + @sql_alter("TABLE spip_auteurs ADD webmestre varchar(3) DEFAULT 'non' NOT NULL"); |
|
| 82 | + } |
|
| 83 | + // prelablement, creer le champ backup_cles si il n'existe pas (install neuve sur une vieille base) |
|
| 84 | + if (!isset($t['field']['backup_cles'])) { |
|
| 85 | + @sql_alter("TABLE spip_auteurs ADD backup_cles mediumtext DEFAULT '' NOT NULL"); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + // il faut avoir une cle des auth valide pour creer un nouvel auteur webmestre |
|
| 89 | + $cles = \Spip\Chiffrer\SpipCles::instance(); |
|
| 90 | + $secret = $cles->getSecretAuth(); |
|
| 91 | + |
|
| 92 | + $id_auteur = sql_getfetsel('id_auteur', 'spip_auteurs', 'login=' . sql_quote($login)); |
|
| 93 | + if ($id_auteur !== null) { |
|
| 94 | + // c'est un auteur connu : si on a pas de secret il faut absolument qu'il se reconnecte avec le meme mot de passe |
|
| 95 | + // pour restaurer la copie des cles |
|
| 96 | + if (!$secret && !auth_spip_initialiser_secret()) { |
|
| 97 | + $row = sql_fetsel('backup_cles, pass', 'spip_auteurs', 'id_auteur=' . (int) $id_auteur); |
|
| 98 | + if (empty($row['backup_cles']) || !$cles->restore($row['backup_cles'], $pass, $row['pass'], $id_auteur)) { |
|
| 99 | + $echec = _T('avis_connexion_erreur_fichier_cle_manquant_1'); |
|
| 100 | + echouer_etape_3b($echec); |
|
| 101 | + } |
|
| 102 | + spip_log("Les cles secretes ont ete restaurées avec le backup du webmestre #$id_auteur", 'auth' . _LOG_INFO_IMPORTANTE); |
|
| 103 | + $cles->save(); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + sql_updateq('spip_auteurs', [ |
|
| 107 | + 'nom' => $nom, |
|
| 108 | + 'email' => $email, |
|
| 109 | + 'login' => $login, |
|
| 110 | + 'statut' => '0minirezo' |
|
| 111 | + ], 'id_auteur=' . (int) $id_auteur); |
|
| 112 | + // le passer webmestre separement du reste, au cas ou l'alter n'aurait pas fonctionne |
|
| 113 | + @sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur"); |
|
| 114 | + if (!auth_spip_modifier_pass($login, $pass, $id_auteur)) { |
|
| 115 | + $echec = _T('avis_erreur_creation_compte'); |
|
| 116 | + echouer_etape_3b($echec); |
|
| 117 | + } |
|
| 118 | + } else { |
|
| 119 | + // Si on a pas de cle et qu'on ne sait pas la creer, on ne peut pas creer de nouveau compte : |
|
| 120 | + // il faut qu'un webmestre avec un backup fasse l'install |
|
| 121 | + if (!$secret && !auth_spip_initialiser_secret()) { |
|
| 122 | + $echec = _T('avis_connexion_erreur_fichier_cle_manquant_2'); |
|
| 123 | + echouer_etape_3b($echec); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + $id_auteur = sql_insertq('spip_auteurs', [ |
|
| 127 | + 'nom' => $nom, |
|
| 128 | + 'email' => $email, |
|
| 129 | + 'login' => $login, |
|
| 130 | + 'statut' => '0minirezo' |
|
| 131 | + ]); |
|
| 132 | + // le passer webmestre separrement du reste, au cas ou l'alter n'aurait pas fonctionne |
|
| 133 | + @sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur"); |
|
| 134 | + if (!auth_spip_modifier_pass($login, $pass, $id_auteur)) { |
|
| 135 | + $echec = _T('avis_erreur_creation_compte'); |
|
| 136 | + echouer_etape_3b($echec); |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + // inserer email comme email webmaster principal |
|
| 141 | + // (sauf s'il est vide: cas de la re-installation) |
|
| 142 | + if ($email) { |
|
| 143 | + ecrire_meta('email_webmaster', $email); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + // Connecter directement celui qui vient de (re)donner son login |
|
| 147 | + // mais sans cookie d'admin ni connexion longue |
|
| 148 | + include_spip('inc/auth'); |
|
| 149 | + $auteur = auth_identifier_login($login, $pass); |
|
| 150 | + if (!$auteur || !auth_loger($auteur)) { |
|
| 151 | + spip_log("login automatique impossible $auth_spip $session" . (is_countable($row) ? count($row) : 0)); |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + // installer les metas |
|
| 156 | + $config = charger_fonction('config', 'inc'); |
|
| 157 | + $config(); |
|
| 158 | + |
|
| 159 | + // activer les plugins |
|
| 160 | + // leur installation ne peut pas se faire sur le meme hit, il faudra donc |
|
| 161 | + // poursuivre au hit suivant |
|
| 162 | + include_spip('inc/plugin'); |
|
| 163 | + actualise_plugins_actifs(); |
|
| 164 | + |
|
| 165 | + |
|
| 166 | + include_spip('inc/distant'); |
|
| 167 | + redirige_par_entete(parametre_url(self(), 'etape', '4', '&')); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | function echouer_etape_3b($echec): never { |
| 171 | - echo minipres( |
|
| 172 | - 'AUTO', |
|
| 173 | - info_progression_etape(3, 'etape_', 'install/', true) . |
|
| 174 | - "<div class='error'><h3>$echec</h3>\n" . |
|
| 175 | - '<p>' . _T('avis_connexion_echec_2') . '</p>' . |
|
| 176 | - '</div>' |
|
| 177 | - ); |
|
| 178 | - exit; |
|
| 171 | + echo minipres( |
|
| 172 | + 'AUTO', |
|
| 173 | + info_progression_etape(3, 'etape_', 'install/', true) . |
|
| 174 | + "<div class='error'><h3>$echec</h3>\n" . |
|
| 175 | + '<p>' . _T('avis_connexion_echec_2') . '</p>' . |
|
| 176 | + '</div>' |
|
| 177 | + ); |
|
| 178 | + exit; |
|
| 179 | 179 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | // creer le repertoire cache, qui sert partout ! |
| 21 | 21 | if (!@file_exists(_DIR_CACHE)) { |
| 22 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', (string) _DIR_CACHE); |
|
| 22 | + $rep = preg_replace(','._DIR_TMP.',', '', (string) _DIR_CACHE); |
|
| 23 | 23 | $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
| 24 | 24 | } |
| 25 | 25 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | echo '<p>' |
| 39 | 39 | . _T( |
| 40 | 40 | 'plugin_info_plugins_dist_1', |
| 41 | - ['plugins_dist' => '<tt>' . joli_repertoire(_DIR_PLUGINS_DIST) . '</tt>'] |
|
| 41 | + ['plugins_dist' => '<tt>'.joli_repertoire(_DIR_PLUGINS_DIST).'</tt>'] |
|
| 42 | 42 | ) |
| 43 | 43 | . '</p>'; |
| 44 | 44 | |
@@ -12,70 +12,70 @@ |
||
| 12 | 12 | \***************************************************************************/ |
| 13 | 13 | |
| 14 | 14 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | include_spip('inc/headers'); |
| 19 | 19 | |
| 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 . ',', '', (string) _DIR_CACHE); |
|
| 25 | - $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - $minipage = new Installation(); |
|
| 29 | - echo $minipage->installDebutPage(['onload' => 'document.getElementById(\'suivant\').focus();return false;']); |
|
| 30 | - |
|
| 31 | - echo info_progression_etape(4, 'etape_', 'install/'); |
|
| 32 | - |
|
| 33 | - echo "<div class='success'><b>" |
|
| 34 | - . _T('info_derniere_etape') |
|
| 35 | - . '</b><p>' |
|
| 36 | - . _T('info_utilisation_spip') |
|
| 37 | - . '</p></div>'; |
|
| 38 | - |
|
| 39 | - |
|
| 40 | - echo '<p>' |
|
| 41 | - . _T( |
|
| 42 | - 'plugin_info_plugins_dist_1', |
|
| 43 | - ['plugins_dist' => '<tt>' . joli_repertoire(_DIR_PLUGINS_DIST) . '</tt>'] |
|
| 44 | - ) |
|
| 45 | - . '</p>'; |
|
| 46 | - |
|
| 47 | - // installer les extensions |
|
| 48 | - include_spip('inc/plugin'); |
|
| 49 | - $afficher = charger_fonction('afficher_liste', 'plugins'); |
|
| 50 | - echo $afficher( |
|
| 51 | - self(), |
|
| 52 | - liste_plugin_files(_DIR_PLUGINS_DIST), |
|
| 53 | - [], |
|
| 54 | - [], |
|
| 55 | - _DIR_PLUGINS_DIST, |
|
| 56 | - 'afficher_nom_plugin' |
|
| 57 | - ); |
|
| 58 | - |
|
| 59 | - // si la base de SPIP est up, on peut installer les plugins, sinon on passe cette etape |
|
| 60 | - // car les plugins supposent que la base de SPIP est dans son etat normal (mise a jour) |
|
| 61 | - // au premier passage dans l'espace prive on aura une demande d'upgrade qui se poursuit sur la page plugin |
|
| 62 | - // et procede alors a l'installation |
|
| 63 | - if ( |
|
| 64 | - !isset($GLOBALS['meta']['version_installee']) |
|
| 65 | - || $GLOBALS['spip_version_base'] == (str_replace(',', '.', (string) $GLOBALS['meta']['version_installee'])) |
|
| 66 | - ) { |
|
| 67 | - plugin_installes_meta(); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - // mettre a jour si necessaire l'adresse du site |
|
| 71 | - // securite si on arrive plus a se loger |
|
| 72 | - include_spip('inc/config'); |
|
| 73 | - appliquer_adresse_site(''); |
|
| 74 | - |
|
| 75 | - // aller a la derniere etape qui clos l'install et redirige |
|
| 76 | - $suite = "\n<input type='hidden' name='etape' value='fin' />" |
|
| 77 | - . bouton_suivant(_T('login_espace_prive')); |
|
| 78 | - |
|
| 79 | - echo generer_form_ecrire('install', $suite); |
|
| 80 | - echo $minipage->installFinPage(); |
|
| 22 | + // creer le repertoire cache, qui sert partout ! |
|
| 23 | + if (!@file_exists(_DIR_CACHE)) { |
|
| 24 | + $rep = preg_replace(',' . _DIR_TMP . ',', '', (string) _DIR_CACHE); |
|
| 25 | + $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + $minipage = new Installation(); |
|
| 29 | + echo $minipage->installDebutPage(['onload' => 'document.getElementById(\'suivant\').focus();return false;']); |
|
| 30 | + |
|
| 31 | + echo info_progression_etape(4, 'etape_', 'install/'); |
|
| 32 | + |
|
| 33 | + echo "<div class='success'><b>" |
|
| 34 | + . _T('info_derniere_etape') |
|
| 35 | + . '</b><p>' |
|
| 36 | + . _T('info_utilisation_spip') |
|
| 37 | + . '</p></div>'; |
|
| 38 | + |
|
| 39 | + |
|
| 40 | + echo '<p>' |
|
| 41 | + . _T( |
|
| 42 | + 'plugin_info_plugins_dist_1', |
|
| 43 | + ['plugins_dist' => '<tt>' . joli_repertoire(_DIR_PLUGINS_DIST) . '</tt>'] |
|
| 44 | + ) |
|
| 45 | + . '</p>'; |
|
| 46 | + |
|
| 47 | + // installer les extensions |
|
| 48 | + include_spip('inc/plugin'); |
|
| 49 | + $afficher = charger_fonction('afficher_liste', 'plugins'); |
|
| 50 | + echo $afficher( |
|
| 51 | + self(), |
|
| 52 | + liste_plugin_files(_DIR_PLUGINS_DIST), |
|
| 53 | + [], |
|
| 54 | + [], |
|
| 55 | + _DIR_PLUGINS_DIST, |
|
| 56 | + 'afficher_nom_plugin' |
|
| 57 | + ); |
|
| 58 | + |
|
| 59 | + // si la base de SPIP est up, on peut installer les plugins, sinon on passe cette etape |
|
| 60 | + // car les plugins supposent que la base de SPIP est dans son etat normal (mise a jour) |
|
| 61 | + // au premier passage dans l'espace prive on aura une demande d'upgrade qui se poursuit sur la page plugin |
|
| 62 | + // et procede alors a l'installation |
|
| 63 | + if ( |
|
| 64 | + !isset($GLOBALS['meta']['version_installee']) |
|
| 65 | + || $GLOBALS['spip_version_base'] == (str_replace(',', '.', (string) $GLOBALS['meta']['version_installee'])) |
|
| 66 | + ) { |
|
| 67 | + plugin_installes_meta(); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + // mettre a jour si necessaire l'adresse du site |
|
| 71 | + // securite si on arrive plus a se loger |
|
| 72 | + include_spip('inc/config'); |
|
| 73 | + appliquer_adresse_site(''); |
|
| 74 | + |
|
| 75 | + // aller a la derniere etape qui clos l'install et redirige |
|
| 76 | + $suite = "\n<input type='hidden' name='etape' value='fin' />" |
|
| 77 | + . bouton_suivant(_T('login_espace_prive')); |
|
| 78 | + |
|
| 79 | + echo generer_form_ecrire('install', $suite); |
|
| 80 | + echo $minipage->installFinPage(); |
|
| 81 | 81 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | |
@@ -20,28 +20,28 @@ discard block |
||
| 20 | 20 | * @param array $arbre |
| 21 | 21 | */ |
| 22 | 22 | function plugins_extraire_pipelines_dist(&$arbre) { |
| 23 | - $pipes = null; |
|
| 24 | - $tag = null; |
|
| 25 | - $pipeline = []; |
|
| 26 | - if (spip_xml_match_nodes(',^pipeline,', $arbre, $pipes)) { |
|
| 27 | - foreach ($pipes as $tag => $p) { |
|
| 28 | - if (!is_array($p[0])) { |
|
| 29 | - [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 30 | - $pipeline[] = $att; |
|
| 31 | - } else { |
|
| 32 | - foreach ($p as $pipe) { |
|
| 33 | - $att = []; |
|
| 34 | - if (is_array($pipe)) { |
|
| 35 | - foreach ($pipe as $k => $t) { |
|
| 36 | - $att[$k] = trim((string) end($t)); |
|
| 37 | - } |
|
| 38 | - } |
|
| 39 | - $pipeline[] = $att; |
|
| 40 | - } |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - unset($arbre[$tag]); |
|
| 44 | - } |
|
| 23 | + $pipes = null; |
|
| 24 | + $tag = null; |
|
| 25 | + $pipeline = []; |
|
| 26 | + if (spip_xml_match_nodes(',^pipeline,', $arbre, $pipes)) { |
|
| 27 | + foreach ($pipes as $tag => $p) { |
|
| 28 | + if (!is_array($p[0])) { |
|
| 29 | + [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 30 | + $pipeline[] = $att; |
|
| 31 | + } else { |
|
| 32 | + foreach ($p as $pipe) { |
|
| 33 | + $att = []; |
|
| 34 | + if (is_array($pipe)) { |
|
| 35 | + foreach ($pipe as $k => $t) { |
|
| 36 | + $att[$k] = trim((string) end($t)); |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | + $pipeline[] = $att; |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + unset($arbre[$tag]); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - return $pipeline; |
|
| 46 | + return $pipeline; |
|
| 47 | 47 | } |
@@ -10,207 +10,207 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | include_spip('inc/xml'); |
| 17 | 17 | include_spip('inc/plugin'); |
| 18 | 18 | |
| 19 | 19 | function plugins_verifie_conformite_dist($plug, &$arbre, $dir_plugins = _DIR_PLUGINS) { |
| 20 | - $needs = null; |
|
| 21 | - $compat_spip = null; |
|
| 22 | - $uses = null; |
|
| 23 | - $paths = null; |
|
| 24 | - $trads = null; |
|
| 25 | - static $etats = ['dev', 'experimental', 'test', 'stable']; |
|
| 20 | + $needs = null; |
|
| 21 | + $compat_spip = null; |
|
| 22 | + $uses = null; |
|
| 23 | + $paths = null; |
|
| 24 | + $trads = null; |
|
| 25 | + static $etats = ['dev', 'experimental', 'test', 'stable']; |
|
| 26 | 26 | |
| 27 | - $matches = []; |
|
| 28 | - $silence = false; |
|
| 29 | - $p = null; |
|
| 30 | - // chercher la declaration <plugin spip='...'> a prendre pour cette version de SPIP |
|
| 31 | - if ($n = spip_xml_match_nodes(',^plugin(\s|$),', $arbre, $matches)) { |
|
| 32 | - // version de SPIP |
|
| 33 | - $vspip = $GLOBALS['spip_version_branche']; |
|
| 34 | - foreach ($matches as $tag => $sous) { |
|
| 35 | - [$tagname, $atts] = spip_xml_decompose_tag($tag); |
|
| 36 | - // On rajoute la condition sur $n : |
|
| 37 | - // -- en effet si $n==1 on a pas plus a choisir la balise que l'on ait |
|
| 38 | - // un attribut spip ou pas. Cela permet de traiter tous les cas mono-balise |
|
| 39 | - // de la meme facon. |
|
| 40 | - if ( |
|
| 41 | - $tagname == 'plugin' |
|
| 42 | - && is_array($sous) |
|
| 43 | - && (!isset($atts['spip']) || $n == 1 || plugin_version_compatible($atts['spip'], $vspip, 'spip')) |
|
| 44 | - ) { |
|
| 45 | - // on prend la derniere declaration avec ce nom |
|
| 46 | - $p = end($sous); |
|
| 47 | - $compat_spip = $atts['spip'] ?? ''; |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - } |
|
| 51 | - if (is_null($p)) { |
|
| 52 | - $arbre = ['erreur' => [_T('erreur_plugin_tag_plugin_absent') . " : $plug"]]; |
|
| 53 | - $silence = true; |
|
| 54 | - } else { |
|
| 55 | - $arbre = $p; |
|
| 56 | - } |
|
| 57 | - if (!is_array($arbre)) { |
|
| 58 | - $arbre = []; |
|
| 59 | - } |
|
| 60 | - // verification de la conformite du plugin avec quelques |
|
| 61 | - // precautions elementaires |
|
| 62 | - if (!isset($arbre['nom'])) { |
|
| 63 | - if (!$silence) { |
|
| 64 | - $arbre['erreur'][] = _T('erreur_plugin_nom_manquant'); |
|
| 65 | - } |
|
| 66 | - $arbre['nom'] = ['']; |
|
| 67 | - } |
|
| 68 | - if (!isset($arbre['version'])) { |
|
| 69 | - if (!$silence) { |
|
| 70 | - $arbre['erreur'][] = _T('erreur_plugin_version_manquant'); |
|
| 71 | - } |
|
| 72 | - $arbre['version'] = ['']; |
|
| 73 | - } |
|
| 74 | - if (!isset($arbre['prefix'])) { |
|
| 75 | - if (!$silence) { |
|
| 76 | - $arbre['erreur'][] = _T('erreur_plugin_prefix_manquant'); |
|
| 77 | - } |
|
| 78 | - $arbre['prefix'] = ['']; |
|
| 79 | - } else { |
|
| 80 | - $prefix = trim((string) end($arbre['prefix'])); |
|
| 81 | - if (strtoupper($prefix) == 'SPIP' && $plug != './') { |
|
| 82 | - $arbre['erreur'][] = _T('erreur_plugin_prefix_interdit'); |
|
| 83 | - } |
|
| 84 | - if (isset($arbre['etat'])) { |
|
| 85 | - $etat = trim((string) end($arbre['etat'])); |
|
| 86 | - if (!in_array($etat, $etats)) { |
|
| 87 | - $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'"; |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - if (isset($arbre['options'])) { |
|
| 91 | - foreach ($arbre['options'] as $optfile) { |
|
| 92 | - $optfile = trim((string) $optfile); |
|
| 93 | - if (!@is_readable($dir_plugins . "$plug/$optfile") && !$silence) { |
|
| 94 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - if (isset($arbre['fonctions'])) { |
|
| 99 | - foreach ($arbre['fonctions'] as $optfile) { |
|
| 100 | - $optfile = trim((string) $optfile); |
|
| 101 | - if (!@is_readable($dir_plugins . "$plug/$optfile") && !$silence) { |
|
| 102 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - $fonctions = []; |
|
| 107 | - if (isset($arbre['fonctions'])) { |
|
| 108 | - $fonctions = $arbre['fonctions']; |
|
| 109 | - } |
|
| 110 | - $liste_methodes_reservees = [ |
|
| 111 | - '__construct', |
|
| 112 | - '__destruct', |
|
| 113 | - 'plugin', |
|
| 114 | - 'install', |
|
| 115 | - 'uninstall', |
|
| 116 | - strtolower($prefix) |
|
| 117 | - ]; |
|
| 27 | + $matches = []; |
|
| 28 | + $silence = false; |
|
| 29 | + $p = null; |
|
| 30 | + // chercher la declaration <plugin spip='...'> a prendre pour cette version de SPIP |
|
| 31 | + if ($n = spip_xml_match_nodes(',^plugin(\s|$),', $arbre, $matches)) { |
|
| 32 | + // version de SPIP |
|
| 33 | + $vspip = $GLOBALS['spip_version_branche']; |
|
| 34 | + foreach ($matches as $tag => $sous) { |
|
| 35 | + [$tagname, $atts] = spip_xml_decompose_tag($tag); |
|
| 36 | + // On rajoute la condition sur $n : |
|
| 37 | + // -- en effet si $n==1 on a pas plus a choisir la balise que l'on ait |
|
| 38 | + // un attribut spip ou pas. Cela permet de traiter tous les cas mono-balise |
|
| 39 | + // de la meme facon. |
|
| 40 | + if ( |
|
| 41 | + $tagname == 'plugin' |
|
| 42 | + && is_array($sous) |
|
| 43 | + && (!isset($atts['spip']) || $n == 1 || plugin_version_compatible($atts['spip'], $vspip, 'spip')) |
|
| 44 | + ) { |
|
| 45 | + // on prend la derniere declaration avec ce nom |
|
| 46 | + $p = end($sous); |
|
| 47 | + $compat_spip = $atts['spip'] ?? ''; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | + if (is_null($p)) { |
|
| 52 | + $arbre = ['erreur' => [_T('erreur_plugin_tag_plugin_absent') . " : $plug"]]; |
|
| 53 | + $silence = true; |
|
| 54 | + } else { |
|
| 55 | + $arbre = $p; |
|
| 56 | + } |
|
| 57 | + if (!is_array($arbre)) { |
|
| 58 | + $arbre = []; |
|
| 59 | + } |
|
| 60 | + // verification de la conformite du plugin avec quelques |
|
| 61 | + // precautions elementaires |
|
| 62 | + if (!isset($arbre['nom'])) { |
|
| 63 | + if (!$silence) { |
|
| 64 | + $arbre['erreur'][] = _T('erreur_plugin_nom_manquant'); |
|
| 65 | + } |
|
| 66 | + $arbre['nom'] = ['']; |
|
| 67 | + } |
|
| 68 | + if (!isset($arbre['version'])) { |
|
| 69 | + if (!$silence) { |
|
| 70 | + $arbre['erreur'][] = _T('erreur_plugin_version_manquant'); |
|
| 71 | + } |
|
| 72 | + $arbre['version'] = ['']; |
|
| 73 | + } |
|
| 74 | + if (!isset($arbre['prefix'])) { |
|
| 75 | + if (!$silence) { |
|
| 76 | + $arbre['erreur'][] = _T('erreur_plugin_prefix_manquant'); |
|
| 77 | + } |
|
| 78 | + $arbre['prefix'] = ['']; |
|
| 79 | + } else { |
|
| 80 | + $prefix = trim((string) end($arbre['prefix'])); |
|
| 81 | + if (strtoupper($prefix) == 'SPIP' && $plug != './') { |
|
| 82 | + $arbre['erreur'][] = _T('erreur_plugin_prefix_interdit'); |
|
| 83 | + } |
|
| 84 | + if (isset($arbre['etat'])) { |
|
| 85 | + $etat = trim((string) end($arbre['etat'])); |
|
| 86 | + if (!in_array($etat, $etats)) { |
|
| 87 | + $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'"; |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + if (isset($arbre['options'])) { |
|
| 91 | + foreach ($arbre['options'] as $optfile) { |
|
| 92 | + $optfile = trim((string) $optfile); |
|
| 93 | + if (!@is_readable($dir_plugins . "$plug/$optfile") && !$silence) { |
|
| 94 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + if (isset($arbre['fonctions'])) { |
|
| 99 | + foreach ($arbre['fonctions'] as $optfile) { |
|
| 100 | + $optfile = trim((string) $optfile); |
|
| 101 | + if (!@is_readable($dir_plugins . "$plug/$optfile") && !$silence) { |
|
| 102 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + $fonctions = []; |
|
| 107 | + if (isset($arbre['fonctions'])) { |
|
| 108 | + $fonctions = $arbre['fonctions']; |
|
| 109 | + } |
|
| 110 | + $liste_methodes_reservees = [ |
|
| 111 | + '__construct', |
|
| 112 | + '__destruct', |
|
| 113 | + 'plugin', |
|
| 114 | + 'install', |
|
| 115 | + 'uninstall', |
|
| 116 | + strtolower($prefix) |
|
| 117 | + ]; |
|
| 118 | 118 | |
| 119 | - $extraire_pipelines = charger_fonction('extraire_pipelines', 'plugins'); |
|
| 120 | - $arbre['pipeline'] = $extraire_pipelines($arbre); |
|
| 121 | - foreach ($arbre['pipeline'] as $pipe) { |
|
| 122 | - if (!isset($pipe['nom']) && !$silence) { |
|
| 123 | - $arbre['erreur'][] = _T('erreur_plugin_nom_pipeline_non_defini'); |
|
| 124 | - } |
|
| 125 | - $action = $pipe['action'] ?? $pipe['nom']; |
|
| 126 | - // verif que la methode a un nom autorise |
|
| 127 | - if (in_array(strtolower((string) $action), $liste_methodes_reservees) && !$silence) { |
|
| 128 | - $arbre['erreur'][] = _T('erreur_plugin_nom_fonction_interdit') . " : $action"; |
|
| 129 | - } |
|
| 130 | - if (isset($pipe['inclure'])) { |
|
| 131 | - $inclure = $dir_plugins . "$plug/" . $pipe['inclure']; |
|
| 132 | - if (!@is_readable($inclure) && !$silence) { |
|
| 133 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure"; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - $necessite = []; |
|
| 138 | - $spip_trouve = false; |
|
| 139 | - if (spip_xml_match_nodes(',^necessite,', $arbre, $needs)) { |
|
| 140 | - foreach (array_keys($needs) as $tag) { |
|
| 141 | - [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 142 | - if (!isset($att['id'])) { |
|
| 143 | - if (!$silence) { |
|
| 144 | - $arbre['erreur'][] = _T( |
|
| 145 | - 'erreur_plugin_attribut_balise_manquant', |
|
| 146 | - ['attribut' => 'id', 'balise' => $att] |
|
| 147 | - ); |
|
| 148 | - } |
|
| 149 | - } else { |
|
| 150 | - $necessite[] = $att; |
|
| 151 | - } |
|
| 152 | - if (strtolower((string) $att['id']) == 'spip') { |
|
| 153 | - $spip_trouve = true; |
|
| 154 | - } |
|
| 155 | - } |
|
| 156 | - } |
|
| 157 | - if ($compat_spip && !$spip_trouve) { |
|
| 158 | - $necessite[] = ['id' => 'spip', 'version' => $compat_spip]; |
|
| 159 | - } |
|
| 160 | - $arbre['necessite'] = $necessite; |
|
| 161 | - $utilise = []; |
|
| 162 | - if (spip_xml_match_nodes(',^utilise,', $arbre, $uses)) { |
|
| 163 | - foreach (array_keys($uses) as $tag) { |
|
| 164 | - [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 165 | - if (!isset($att['id'])) { |
|
| 166 | - if (!$silence) { |
|
| 167 | - $arbre['erreur'][] = _T( |
|
| 168 | - 'erreur_plugin_attribut_balise_manquant', |
|
| 169 | - ['attribut' => 'id', 'balise' => $att] |
|
| 170 | - ); |
|
| 171 | - } |
|
| 172 | - } else { |
|
| 173 | - $utilise[] = $att; |
|
| 174 | - } |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - $arbre['utilise'] = $utilise; |
|
| 178 | - $procure = []; |
|
| 179 | - if (spip_xml_match_nodes(',^procure,', $arbre, $uses)) { |
|
| 180 | - foreach (array_keys($uses) as $tag) { |
|
| 181 | - [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 182 | - $procure[] = $att; |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - $arbre['procure'] = $procure; |
|
| 186 | - $path = []; |
|
| 187 | - if (spip_xml_match_nodes(',^chemin,', $arbre, $paths)) { |
|
| 188 | - foreach (array_keys($paths) as $tag) { |
|
| 189 | - [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 190 | - $att['path'] = $att['dir']; // ancienne syntaxe |
|
| 191 | - $path[] = $att; |
|
| 192 | - } |
|
| 193 | - } else { |
|
| 194 | - $path = [['dir' => '']]; |
|
| 195 | - } // initialiser par defaut |
|
| 196 | - $arbre['path'] = $path; |
|
| 197 | - // exposer les noisettes |
|
| 198 | - if (isset($arbre['noisette'])) { |
|
| 199 | - foreach ($arbre['noisette'] as $k => $nut) { |
|
| 200 | - $nut = preg_replace(',[.]html$,uims', '', trim((string) $nut)); |
|
| 201 | - $arbre['noisette'][$k] = $nut; |
|
| 202 | - if (!@is_readable($dir_plugins . "$plug/$nut.html") && !$silence) { |
|
| 203 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut"; |
|
| 204 | - } |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - $traduire = []; |
|
| 208 | - if (spip_xml_match_nodes(',^traduire,', $arbre, $trads)) { |
|
| 209 | - foreach (array_keys($trads) as $tag) { |
|
| 210 | - [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 211 | - $traduire[] = $att; |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - $arbre['traduire'] = $traduire; |
|
| 215 | - } |
|
| 119 | + $extraire_pipelines = charger_fonction('extraire_pipelines', 'plugins'); |
|
| 120 | + $arbre['pipeline'] = $extraire_pipelines($arbre); |
|
| 121 | + foreach ($arbre['pipeline'] as $pipe) { |
|
| 122 | + if (!isset($pipe['nom']) && !$silence) { |
|
| 123 | + $arbre['erreur'][] = _T('erreur_plugin_nom_pipeline_non_defini'); |
|
| 124 | + } |
|
| 125 | + $action = $pipe['action'] ?? $pipe['nom']; |
|
| 126 | + // verif que la methode a un nom autorise |
|
| 127 | + if (in_array(strtolower((string) $action), $liste_methodes_reservees) && !$silence) { |
|
| 128 | + $arbre['erreur'][] = _T('erreur_plugin_nom_fonction_interdit') . " : $action"; |
|
| 129 | + } |
|
| 130 | + if (isset($pipe['inclure'])) { |
|
| 131 | + $inclure = $dir_plugins . "$plug/" . $pipe['inclure']; |
|
| 132 | + if (!@is_readable($inclure) && !$silence) { |
|
| 133 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure"; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + $necessite = []; |
|
| 138 | + $spip_trouve = false; |
|
| 139 | + if (spip_xml_match_nodes(',^necessite,', $arbre, $needs)) { |
|
| 140 | + foreach (array_keys($needs) as $tag) { |
|
| 141 | + [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 142 | + if (!isset($att['id'])) { |
|
| 143 | + if (!$silence) { |
|
| 144 | + $arbre['erreur'][] = _T( |
|
| 145 | + 'erreur_plugin_attribut_balise_manquant', |
|
| 146 | + ['attribut' => 'id', 'balise' => $att] |
|
| 147 | + ); |
|
| 148 | + } |
|
| 149 | + } else { |
|
| 150 | + $necessite[] = $att; |
|
| 151 | + } |
|
| 152 | + if (strtolower((string) $att['id']) == 'spip') { |
|
| 153 | + $spip_trouve = true; |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | + if ($compat_spip && !$spip_trouve) { |
|
| 158 | + $necessite[] = ['id' => 'spip', 'version' => $compat_spip]; |
|
| 159 | + } |
|
| 160 | + $arbre['necessite'] = $necessite; |
|
| 161 | + $utilise = []; |
|
| 162 | + if (spip_xml_match_nodes(',^utilise,', $arbre, $uses)) { |
|
| 163 | + foreach (array_keys($uses) as $tag) { |
|
| 164 | + [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 165 | + if (!isset($att['id'])) { |
|
| 166 | + if (!$silence) { |
|
| 167 | + $arbre['erreur'][] = _T( |
|
| 168 | + 'erreur_plugin_attribut_balise_manquant', |
|
| 169 | + ['attribut' => 'id', 'balise' => $att] |
|
| 170 | + ); |
|
| 171 | + } |
|
| 172 | + } else { |
|
| 173 | + $utilise[] = $att; |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + $arbre['utilise'] = $utilise; |
|
| 178 | + $procure = []; |
|
| 179 | + if (spip_xml_match_nodes(',^procure,', $arbre, $uses)) { |
|
| 180 | + foreach (array_keys($uses) as $tag) { |
|
| 181 | + [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 182 | + $procure[] = $att; |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + $arbre['procure'] = $procure; |
|
| 186 | + $path = []; |
|
| 187 | + if (spip_xml_match_nodes(',^chemin,', $arbre, $paths)) { |
|
| 188 | + foreach (array_keys($paths) as $tag) { |
|
| 189 | + [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 190 | + $att['path'] = $att['dir']; // ancienne syntaxe |
|
| 191 | + $path[] = $att; |
|
| 192 | + } |
|
| 193 | + } else { |
|
| 194 | + $path = [['dir' => '']]; |
|
| 195 | + } // initialiser par defaut |
|
| 196 | + $arbre['path'] = $path; |
|
| 197 | + // exposer les noisettes |
|
| 198 | + if (isset($arbre['noisette'])) { |
|
| 199 | + foreach ($arbre['noisette'] as $k => $nut) { |
|
| 200 | + $nut = preg_replace(',[.]html$,uims', '', trim((string) $nut)); |
|
| 201 | + $arbre['noisette'][$k] = $nut; |
|
| 202 | + if (!@is_readable($dir_plugins . "$plug/$nut.html") && !$silence) { |
|
| 203 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut"; |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + $traduire = []; |
|
| 208 | + if (spip_xml_match_nodes(',^traduire,', $arbre, $trads)) { |
|
| 209 | + foreach (array_keys($trads) as $tag) { |
|
| 210 | + [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 211 | + $traduire[] = $att; |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + $arbre['traduire'] = $traduire; |
|
| 215 | + } |
|
| 216 | 216 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | if (is_null($p)) { |
| 52 | - $arbre = ['erreur' => [_T('erreur_plugin_tag_plugin_absent') . " : $plug"]]; |
|
| 52 | + $arbre = ['erreur' => [_T('erreur_plugin_tag_plugin_absent')." : $plug"]]; |
|
| 53 | 53 | $silence = true; |
| 54 | 54 | } else { |
| 55 | 55 | $arbre = $p; |
@@ -84,22 +84,22 @@ discard block |
||
| 84 | 84 | if (isset($arbre['etat'])) { |
| 85 | 85 | $etat = trim((string) end($arbre['etat'])); |
| 86 | 86 | if (!in_array($etat, $etats)) { |
| 87 | - $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'"; |
|
| 87 | + $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu')." : '$etat'"; |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | if (isset($arbre['options'])) { |
| 91 | 91 | foreach ($arbre['options'] as $optfile) { |
| 92 | 92 | $optfile = trim((string) $optfile); |
| 93 | - if (!@is_readable($dir_plugins . "$plug/$optfile") && !$silence) { |
|
| 94 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 93 | + if (!@is_readable($dir_plugins."$plug/$optfile") && !$silence) { |
|
| 94 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $optfile"; |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | if (isset($arbre['fonctions'])) { |
| 99 | 99 | foreach ($arbre['fonctions'] as $optfile) { |
| 100 | 100 | $optfile = trim((string) $optfile); |
| 101 | - if (!@is_readable($dir_plugins . "$plug/$optfile") && !$silence) { |
|
| 102 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 101 | + if (!@is_readable($dir_plugins."$plug/$optfile") && !$silence) { |
|
| 102 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $optfile"; |
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -125,12 +125,12 @@ discard block |
||
| 125 | 125 | $action = $pipe['action'] ?? $pipe['nom']; |
| 126 | 126 | // verif que la methode a un nom autorise |
| 127 | 127 | if (in_array(strtolower((string) $action), $liste_methodes_reservees) && !$silence) { |
| 128 | - $arbre['erreur'][] = _T('erreur_plugin_nom_fonction_interdit') . " : $action"; |
|
| 128 | + $arbre['erreur'][] = _T('erreur_plugin_nom_fonction_interdit')." : $action"; |
|
| 129 | 129 | } |
| 130 | 130 | if (isset($pipe['inclure'])) { |
| 131 | - $inclure = $dir_plugins . "$plug/" . $pipe['inclure']; |
|
| 131 | + $inclure = $dir_plugins."$plug/".$pipe['inclure']; |
|
| 132 | 132 | if (!@is_readable($inclure) && !$silence) { |
| 133 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure"; |
|
| 133 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $inclure"; |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | } |
@@ -199,8 +199,8 @@ discard block |
||
| 199 | 199 | foreach ($arbre['noisette'] as $k => $nut) { |
| 200 | 200 | $nut = preg_replace(',[.]html$,uims', '', trim((string) $nut)); |
| 201 | 201 | $arbre['noisette'][$k] = $nut; |
| 202 | - if (!@is_readable($dir_plugins . "$plug/$nut.html") && !$silence) { |
|
| 203 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut"; |
|
| 202 | + if (!@is_readable($dir_plugins."$plug/$nut.html") && !$silence) { |
|
| 203 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $nut"; |
|
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | } |
@@ -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 | /** |
@@ -53,92 +53,92 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | function plugins_installer_dist($plug, $action, $dir_type = '_DIR_PLUGINS') { |
| 55 | 55 | |
| 56 | - // Charger les informations du XML du plugin et vérification de l'existence d'une installation |
|
| 57 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 58 | - $infos = $get_infos($plug, false, constant($dir_type)); |
|
| 59 | - if (!isset($infos['install']) || !$infos['install']) { |
|
| 60 | - return false; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - // Passer en chemin absolu si possible, c'est plus efficace |
|
| 64 | - $dir = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 65 | - if (!defined($dir)) { |
|
| 66 | - $dir = $dir_type; |
|
| 67 | - } |
|
| 68 | - $dir = constant($dir); |
|
| 69 | - foreach ($infos['install'] as $file) { |
|
| 70 | - $file = $dir . $plug . '/' . trim((string) $file); |
|
| 71 | - if (file_exists($file)) { |
|
| 72 | - include_once($file); |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - // Détermination de la table meta et du nom de la meta plugin |
|
| 77 | - $table = 'meta'; |
|
| 78 | - if (isset($infos['meta']) && $infos['meta'] !== 'meta') { |
|
| 79 | - $table = $infos['meta']; |
|
| 80 | - // S'assurer que les metas de la table spécifique sont bien accessibles dans la globale |
|
| 81 | - lire_metas($table); |
|
| 82 | - } |
|
| 83 | - $nom_meta = $infos['prefix'] . '_base_version'; |
|
| 84 | - |
|
| 85 | - // Détermination de la fonction à appeler et de ses arguments |
|
| 86 | - $f = $infos['prefix'] . '_install'; |
|
| 87 | - if (!function_exists($f)) { |
|
| 88 | - $f = isset($infos['schema']) ? 'spip_plugin_install' : ''; |
|
| 89 | - $arg = $infos; |
|
| 90 | - // On passe la table et la meta pour éviter de les recalculer dans la fonction appelée |
|
| 91 | - $arg['meta'] = $table; |
|
| 92 | - $arg['nom_meta'] = $nom_meta; |
|
| 93 | - } else { |
|
| 94 | - // Ancienne méthode d'installation - TODO à supprimer à terme |
|
| 95 | - // stupide: info deja dans le nom |
|
| 96 | - $arg = $infos['prefix']; |
|
| 97 | - } |
|
| 98 | - $version = $infos['schema'] ?? ''; |
|
| 99 | - |
|
| 100 | - if (!$f) { |
|
| 101 | - // installation sans operation particuliere |
|
| 102 | - $infos['install_test'] = [true, '']; |
|
| 103 | - return $infos; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - // Tester si l'action demandée est nécessaire ou pas. |
|
| 107 | - $test = $f('test', $arg, $version); |
|
| 108 | - if ($action == 'uninstall') { |
|
| 109 | - $test = !$test; |
|
| 110 | - } |
|
| 111 | - // Si deja fait, on ne fait rien et on ne dit rien |
|
| 112 | - if ($test) { |
|
| 113 | - return true; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - // Si install et que l'on a la meta d'installation, c'est un upgrade. On le consigne dans $infos |
|
| 117 | - // pour renvoyer le bon message en retour de la fonction. |
|
| 118 | - if ($action == 'install' && !empty($GLOBALS[$table][$nom_meta])) { |
|
| 119 | - $infos['upgrade'] = true; |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - // executer l'installation ou l'inverse |
|
| 123 | - // et renvoyer la trace (mais il faudrait passer en AJAX plutot) |
|
| 124 | - ob_start(); |
|
| 125 | - $f($action, $arg, $version); |
|
| 126 | - $aff = ob_get_contents(); |
|
| 127 | - ob_end_clean(); |
|
| 128 | - |
|
| 129 | - // vider le cache des descriptions de tables a chaque (de)installation |
|
| 130 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 131 | - $trouver_table(''); |
|
| 132 | - $infos['install_test'] = [$f('test', $arg, $version), $aff]; |
|
| 133 | - |
|
| 134 | - // Si la table meta n'est pas spip_meta et qu'on est dans la première installation du plugin |
|
| 135 | - // on force la création du fichier cache à la date du moment. |
|
| 136 | - // On relit les metas de la table pour être sur que la globale soit à jour pour touch_meta. |
|
| 137 | - if ($table !== 'meta' && $action == 'install' && empty($infos['upgrade'])) { |
|
| 138 | - touch_meta(false, $table); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - return $infos; |
|
| 56 | + // Charger les informations du XML du plugin et vérification de l'existence d'une installation |
|
| 57 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 58 | + $infos = $get_infos($plug, false, constant($dir_type)); |
|
| 59 | + if (!isset($infos['install']) || !$infos['install']) { |
|
| 60 | + return false; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + // Passer en chemin absolu si possible, c'est plus efficace |
|
| 64 | + $dir = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 65 | + if (!defined($dir)) { |
|
| 66 | + $dir = $dir_type; |
|
| 67 | + } |
|
| 68 | + $dir = constant($dir); |
|
| 69 | + foreach ($infos['install'] as $file) { |
|
| 70 | + $file = $dir . $plug . '/' . trim((string) $file); |
|
| 71 | + if (file_exists($file)) { |
|
| 72 | + include_once($file); |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + // Détermination de la table meta et du nom de la meta plugin |
|
| 77 | + $table = 'meta'; |
|
| 78 | + if (isset($infos['meta']) && $infos['meta'] !== 'meta') { |
|
| 79 | + $table = $infos['meta']; |
|
| 80 | + // S'assurer que les metas de la table spécifique sont bien accessibles dans la globale |
|
| 81 | + lire_metas($table); |
|
| 82 | + } |
|
| 83 | + $nom_meta = $infos['prefix'] . '_base_version'; |
|
| 84 | + |
|
| 85 | + // Détermination de la fonction à appeler et de ses arguments |
|
| 86 | + $f = $infos['prefix'] . '_install'; |
|
| 87 | + if (!function_exists($f)) { |
|
| 88 | + $f = isset($infos['schema']) ? 'spip_plugin_install' : ''; |
|
| 89 | + $arg = $infos; |
|
| 90 | + // On passe la table et la meta pour éviter de les recalculer dans la fonction appelée |
|
| 91 | + $arg['meta'] = $table; |
|
| 92 | + $arg['nom_meta'] = $nom_meta; |
|
| 93 | + } else { |
|
| 94 | + // Ancienne méthode d'installation - TODO à supprimer à terme |
|
| 95 | + // stupide: info deja dans le nom |
|
| 96 | + $arg = $infos['prefix']; |
|
| 97 | + } |
|
| 98 | + $version = $infos['schema'] ?? ''; |
|
| 99 | + |
|
| 100 | + if (!$f) { |
|
| 101 | + // installation sans operation particuliere |
|
| 102 | + $infos['install_test'] = [true, '']; |
|
| 103 | + return $infos; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + // Tester si l'action demandée est nécessaire ou pas. |
|
| 107 | + $test = $f('test', $arg, $version); |
|
| 108 | + if ($action == 'uninstall') { |
|
| 109 | + $test = !$test; |
|
| 110 | + } |
|
| 111 | + // Si deja fait, on ne fait rien et on ne dit rien |
|
| 112 | + if ($test) { |
|
| 113 | + return true; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + // Si install et que l'on a la meta d'installation, c'est un upgrade. On le consigne dans $infos |
|
| 117 | + // pour renvoyer le bon message en retour de la fonction. |
|
| 118 | + if ($action == 'install' && !empty($GLOBALS[$table][$nom_meta])) { |
|
| 119 | + $infos['upgrade'] = true; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + // executer l'installation ou l'inverse |
|
| 123 | + // et renvoyer la trace (mais il faudrait passer en AJAX plutot) |
|
| 124 | + ob_start(); |
|
| 125 | + $f($action, $arg, $version); |
|
| 126 | + $aff = ob_get_contents(); |
|
| 127 | + ob_end_clean(); |
|
| 128 | + |
|
| 129 | + // vider le cache des descriptions de tables a chaque (de)installation |
|
| 130 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 131 | + $trouver_table(''); |
|
| 132 | + $infos['install_test'] = [$f('test', $arg, $version), $aff]; |
|
| 133 | + |
|
| 134 | + // Si la table meta n'est pas spip_meta et qu'on est dans la première installation du plugin |
|
| 135 | + // on force la création du fichier cache à la date du moment. |
|
| 136 | + // On relit les metas de la table pour être sur que la globale soit à jour pour touch_meta. |
|
| 137 | + if ($table !== 'meta' && $action == 'install' && empty($infos['upgrade'])) { |
|
| 138 | + touch_meta(false, $table); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + return $infos; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -154,24 +154,24 @@ discard block |
||
| 154 | 154 | * @return bool|void |
| 155 | 155 | */ |
| 156 | 156 | function spip_plugin_install($action, $infos, $version_cible) { |
| 157 | - $nom_meta = $infos['nom_meta']; |
|
| 158 | - $table = $infos['meta']; |
|
| 159 | - switch ($action) { |
|
| 160 | - case 'test': |
|
| 161 | - return (isset($GLOBALS[$table]) |
|
| 162 | - && isset($GLOBALS[$table][$nom_meta]) |
|
| 163 | - && spip_version_compare($GLOBALS[$table][$nom_meta], $version_cible, '>=')); |
|
| 164 | - case 'install': |
|
| 165 | - if (function_exists($upgrade = $infos['prefix'] . '_upgrade')) { |
|
| 166 | - $upgrade($nom_meta, $version_cible, $table); |
|
| 167 | - } |
|
| 168 | - break; |
|
| 169 | - case 'uninstall': |
|
| 170 | - if (function_exists($vider_tables = $infos['prefix'] . '_vider_tables')) { |
|
| 171 | - $vider_tables($nom_meta, $table); |
|
| 172 | - } |
|
| 173 | - break; |
|
| 174 | - } |
|
| 157 | + $nom_meta = $infos['nom_meta']; |
|
| 158 | + $table = $infos['meta']; |
|
| 159 | + switch ($action) { |
|
| 160 | + case 'test': |
|
| 161 | + return (isset($GLOBALS[$table]) |
|
| 162 | + && isset($GLOBALS[$table][$nom_meta]) |
|
| 163 | + && spip_version_compare($GLOBALS[$table][$nom_meta], $version_cible, '>=')); |
|
| 164 | + case 'install': |
|
| 165 | + if (function_exists($upgrade = $infos['prefix'] . '_upgrade')) { |
|
| 166 | + $upgrade($nom_meta, $version_cible, $table); |
|
| 167 | + } |
|
| 168 | + break; |
|
| 169 | + case 'uninstall': |
|
| 170 | + if (function_exists($vider_tables = $infos['prefix'] . '_vider_tables')) { |
|
| 171 | + $vider_tables($nom_meta, $table); |
|
| 172 | + } |
|
| 173 | + break; |
|
| 174 | + } |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | |
@@ -190,29 +190,29 @@ discard block |
||
| 190 | 190 | * @return array Tableau des plugins actifs |
| 191 | 191 | **/ |
| 192 | 192 | function liste_plugin_actifs() { |
| 193 | - $liste = $GLOBALS['meta']['plugin'] ?? ''; |
|
| 194 | - if (!$liste) { |
|
| 195 | - return []; |
|
| 196 | - } |
|
| 197 | - if (!is_array($liste = unserialize($liste))) { |
|
| 198 | - // compatibilite pre 1.9.2, mettre a jour la meta |
|
| 199 | - spip_log("MAJ meta plugin vieille version : $liste", 'plugin'); |
|
| 200 | - $new = true; |
|
| 201 | - [, $liste] = liste_plugin_valides(explode(',', (string) $liste)); |
|
| 202 | - } else { |
|
| 203 | - $new = false; |
|
| 204 | - // compat au moment d'une migration depuis version anterieure |
|
| 205 | - // si pas de dir_type, alors c'est _DIR_PLUGINS |
|
| 206 | - foreach ($liste as $prefix => $infos) { |
|
| 207 | - if (!isset($infos['dir_type'])) { |
|
| 208 | - $liste[$prefix]['dir_type'] = '_DIR_PLUGINS'; |
|
| 209 | - $new = true; |
|
| 210 | - } |
|
| 211 | - } |
|
| 212 | - } |
|
| 213 | - if ($new) { |
|
| 214 | - ecrire_meta('plugin', serialize($liste)); |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - return $liste; |
|
| 193 | + $liste = $GLOBALS['meta']['plugin'] ?? ''; |
|
| 194 | + if (!$liste) { |
|
| 195 | + return []; |
|
| 196 | + } |
|
| 197 | + if (!is_array($liste = unserialize($liste))) { |
|
| 198 | + // compatibilite pre 1.9.2, mettre a jour la meta |
|
| 199 | + spip_log("MAJ meta plugin vieille version : $liste", 'plugin'); |
|
| 200 | + $new = true; |
|
| 201 | + [, $liste] = liste_plugin_valides(explode(',', (string) $liste)); |
|
| 202 | + } else { |
|
| 203 | + $new = false; |
|
| 204 | + // compat au moment d'une migration depuis version anterieure |
|
| 205 | + // si pas de dir_type, alors c'est _DIR_PLUGINS |
|
| 206 | + foreach ($liste as $prefix => $infos) { |
|
| 207 | + if (!isset($infos['dir_type'])) { |
|
| 208 | + $liste[$prefix]['dir_type'] = '_DIR_PLUGINS'; |
|
| 209 | + $new = true; |
|
| 210 | + } |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | + if ($new) { |
|
| 214 | + ecrire_meta('plugin', serialize($liste)); |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + return $liste; |
|
| 218 | 218 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | $dir = constant($dir); |
| 69 | 69 | foreach ($infos['install'] as $file) { |
| 70 | - $file = $dir . $plug . '/' . trim((string) $file); |
|
| 70 | + $file = $dir.$plug.'/'.trim((string) $file); |
|
| 71 | 71 | if (file_exists($file)) { |
| 72 | 72 | include_once($file); |
| 73 | 73 | } |
@@ -80,10 +80,10 @@ discard block |
||
| 80 | 80 | // S'assurer que les metas de la table spécifique sont bien accessibles dans la globale |
| 81 | 81 | lire_metas($table); |
| 82 | 82 | } |
| 83 | - $nom_meta = $infos['prefix'] . '_base_version'; |
|
| 83 | + $nom_meta = $infos['prefix'].'_base_version'; |
|
| 84 | 84 | |
| 85 | 85 | // Détermination de la fonction à appeler et de ses arguments |
| 86 | - $f = $infos['prefix'] . '_install'; |
|
| 86 | + $f = $infos['prefix'].'_install'; |
|
| 87 | 87 | if (!function_exists($f)) { |
| 88 | 88 | $f = isset($infos['schema']) ? 'spip_plugin_install' : ''; |
| 89 | 89 | $arg = $infos; |
@@ -162,12 +162,12 @@ discard block |
||
| 162 | 162 | && isset($GLOBALS[$table][$nom_meta]) |
| 163 | 163 | && spip_version_compare($GLOBALS[$table][$nom_meta], $version_cible, '>=')); |
| 164 | 164 | case 'install': |
| 165 | - if (function_exists($upgrade = $infos['prefix'] . '_upgrade')) { |
|
| 165 | + if (function_exists($upgrade = $infos['prefix'].'_upgrade')) { |
|
| 166 | 166 | $upgrade($nom_meta, $version_cible, $table); |
| 167 | 167 | } |
| 168 | 168 | break; |
| 169 | 169 | case 'uninstall': |
| 170 | - if (function_exists($vider_tables = $infos['prefix'] . '_vider_tables')) { |
|
| 170 | + if (function_exists($vider_tables = $infos['prefix'].'_vider_tables')) { |
|
| 171 | 171 | $vider_tables($nom_meta, $table); |
| 172 | 172 | } |
| 173 | 173 | break; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | /** |
@@ -24,64 +24,64 @@ discard block |
||
| 24 | 24 | * @return array |
| 25 | 25 | */ |
| 26 | 26 | function plugins_infos_paquet($desc, $plug = '', $dir_plugins = _DIR_PLUGINS) { |
| 27 | - static $process = [ // tableau constant |
|
| 28 | - 'debut' => 'paquet_debutElement', |
|
| 29 | - 'fin' => 'paquet_finElement', |
|
| 30 | - 'text' => 'paquet_textElement' |
|
| 31 | - ]; |
|
| 32 | - |
|
| 33 | - $valider_xml = charger_fonction('valider', 'xml'); |
|
| 34 | - $vxml = $valider_xml($desc, false, $process, 'paquet.dtd', 'utf-8'); |
|
| 35 | - if (!$vxml->err) { |
|
| 36 | - // On veut toutes les variantes selon la version de SPIP |
|
| 37 | - if (!$plug) { |
|
| 38 | - return $vxml->versions; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - // compatibilite avec l'existant: |
|
| 42 | - $tree = $vxml->versions['0']; |
|
| 43 | - |
|
| 44 | - // l'arbre renvoie parfois un tag vide... etrange. Pas la peine de garder ca. |
|
| 45 | - if (isset($tree['']) && !strlen((string) $tree[''])) { |
|
| 46 | - unset($tree['']); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - $tree['slogan'] = $tree['prefix'] . '_slogan'; |
|
| 50 | - $tree['description'] = $tree['prefix'] . '_description'; |
|
| 51 | - paquet_readable_files($tree, "$dir_plugins$plug/"); |
|
| 52 | - if (!$tree['chemin']) { |
|
| 53 | - $tree['chemin'] = []; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - // On verifie qu'il existe des balises spip qu'il faudrait rajouter dans |
|
| 57 | - // la structure d'infos du paquet en fonction de la version spip courante |
|
| 58 | - if ((is_countable($vxml->versions) ? count($vxml->versions) : 0) > 1) { |
|
| 59 | - $vspip = $GLOBALS['spip_version_branche']; |
|
| 60 | - foreach ($vxml->versions as $_compatibilite => $_version) { |
|
| 61 | - if ( |
|
| 62 | - $_version['balise'] == 'spip' |
|
| 63 | - && plugin_version_compatible($_compatibilite, $vspip, 'spip') |
|
| 64 | - ) { |
|
| 65 | - // on merge les sous-balises de la balise spip compatible avec celles de la |
|
| 66 | - // balise paquet |
|
| 67 | - foreach ($_version as $_index => $_balise) { |
|
| 68 | - if ($_index && $_index != 'balise') { |
|
| 69 | - $tree[$_index] = array_merge($tree[$_index], $_balise); |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - return $tree; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - // Prendre les messages d'erreur sans les numeros de lignes |
|
| 80 | - $msg = array_column($vxml->err, 0); |
|
| 81 | - $t = _T('plugins_erreur', ['plugins' => $plug]); |
|
| 82 | - array_unshift($msg, $t . " <ul class='erreur_xml'><li>" . reset($msg) . '</li></ul>'); |
|
| 83 | - |
|
| 84 | - return ['erreur' => $msg]; |
|
| 27 | + static $process = [ // tableau constant |
|
| 28 | + 'debut' => 'paquet_debutElement', |
|
| 29 | + 'fin' => 'paquet_finElement', |
|
| 30 | + 'text' => 'paquet_textElement' |
|
| 31 | + ]; |
|
| 32 | + |
|
| 33 | + $valider_xml = charger_fonction('valider', 'xml'); |
|
| 34 | + $vxml = $valider_xml($desc, false, $process, 'paquet.dtd', 'utf-8'); |
|
| 35 | + if (!$vxml->err) { |
|
| 36 | + // On veut toutes les variantes selon la version de SPIP |
|
| 37 | + if (!$plug) { |
|
| 38 | + return $vxml->versions; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + // compatibilite avec l'existant: |
|
| 42 | + $tree = $vxml->versions['0']; |
|
| 43 | + |
|
| 44 | + // l'arbre renvoie parfois un tag vide... etrange. Pas la peine de garder ca. |
|
| 45 | + if (isset($tree['']) && !strlen((string) $tree[''])) { |
|
| 46 | + unset($tree['']); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + $tree['slogan'] = $tree['prefix'] . '_slogan'; |
|
| 50 | + $tree['description'] = $tree['prefix'] . '_description'; |
|
| 51 | + paquet_readable_files($tree, "$dir_plugins$plug/"); |
|
| 52 | + if (!$tree['chemin']) { |
|
| 53 | + $tree['chemin'] = []; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + // On verifie qu'il existe des balises spip qu'il faudrait rajouter dans |
|
| 57 | + // la structure d'infos du paquet en fonction de la version spip courante |
|
| 58 | + if ((is_countable($vxml->versions) ? count($vxml->versions) : 0) > 1) { |
|
| 59 | + $vspip = $GLOBALS['spip_version_branche']; |
|
| 60 | + foreach ($vxml->versions as $_compatibilite => $_version) { |
|
| 61 | + if ( |
|
| 62 | + $_version['balise'] == 'spip' |
|
| 63 | + && plugin_version_compatible($_compatibilite, $vspip, 'spip') |
|
| 64 | + ) { |
|
| 65 | + // on merge les sous-balises de la balise spip compatible avec celles de la |
|
| 66 | + // balise paquet |
|
| 67 | + foreach ($_version as $_index => $_balise) { |
|
| 68 | + if ($_index && $_index != 'balise') { |
|
| 69 | + $tree[$_index] = array_merge($tree[$_index], $_balise); |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + return $tree; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + // Prendre les messages d'erreur sans les numeros de lignes |
|
| 80 | + $msg = array_column($vxml->err, 0); |
|
| 81 | + $t = _T('plugins_erreur', ['plugins' => $plug]); |
|
| 82 | + array_unshift($msg, $t . " <ul class='erreur_xml'><li>" . reset($msg) . '</li></ul>'); |
|
| 83 | + |
|
| 84 | + return ['erreur' => $msg]; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | * @return void |
| 94 | 94 | */ |
| 95 | 95 | function paquet_readable_files(&$tree, $dir) { |
| 96 | - $prefix = strtolower((string) $tree['prefix']); |
|
| 96 | + $prefix = strtolower((string) $tree['prefix']); |
|
| 97 | 97 | |
| 98 | - $tree['options'] = (is_readable($dir . $f = ($prefix . '_options.php'))) ? [$f] : []; |
|
| 99 | - $tree['fonctions'] = (is_readable($dir . $f = ($prefix . '_fonctions.php'))) ? [$f] : []; |
|
| 100 | - $tree['install'] = (is_readable($dir . $f = ($prefix . '_administrations.php'))) ? [$f] : []; |
|
| 98 | + $tree['options'] = (is_readable($dir . $f = ($prefix . '_options.php'))) ? [$f] : []; |
|
| 99 | + $tree['fonctions'] = (is_readable($dir . $f = ($prefix . '_fonctions.php'))) ? [$f] : []; |
|
| 100 | + $tree['install'] = (is_readable($dir . $f = ($prefix . '_administrations.php'))) ? [$f] : []; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -114,35 +114,35 @@ discard block |
||
| 114 | 114 | * @param array $attrs |
| 115 | 115 | */ |
| 116 | 116 | function paquet_debutElement($phraseur, $name, $attrs) { |
| 117 | - xml_debutElement($phraseur, $name, $attrs); |
|
| 118 | - if ($phraseur->err) { |
|
| 119 | - return; |
|
| 120 | - } |
|
| 121 | - if ($name == 'paquet' || $name == 'spip') { |
|
| 122 | - if ($name == 'spip') { |
|
| 123 | - $n = $attrs['compatibilite']; |
|
| 124 | - $attrs = []; |
|
| 125 | - } else { |
|
| 126 | - $n = '0'; |
|
| 127 | - $phraseur->contenu['paquet'] = $attrs; |
|
| 128 | - $attrs['menu'] = []; |
|
| 129 | - $attrs['chemin'] = []; |
|
| 130 | - $attrs['necessite'] = []; |
|
| 131 | - $attrs['lib'] = []; |
|
| 132 | - $attrs['onglet'] = []; |
|
| 133 | - $attrs['procure'] = []; |
|
| 134 | - $attrs['pipeline'] = []; |
|
| 135 | - $attrs['utilise'] = []; |
|
| 136 | - $attrs['style'] = []; |
|
| 137 | - $attrs['script'] = []; |
|
| 138 | - $attrs['genie'] = []; |
|
| 139 | - } |
|
| 140 | - $phraseur->contenu['compatible'] = $n; |
|
| 141 | - $phraseur->versions[$phraseur->contenu['compatible']] = $attrs; |
|
| 142 | - } else { |
|
| 143 | - $phraseur->versions[$phraseur->contenu['compatible']][$name][0] = $attrs; |
|
| 144 | - } |
|
| 145 | - $phraseur->versions[$phraseur->contenu['compatible']][''] = ''; |
|
| 117 | + xml_debutElement($phraseur, $name, $attrs); |
|
| 118 | + if ($phraseur->err) { |
|
| 119 | + return; |
|
| 120 | + } |
|
| 121 | + if ($name == 'paquet' || $name == 'spip') { |
|
| 122 | + if ($name == 'spip') { |
|
| 123 | + $n = $attrs['compatibilite']; |
|
| 124 | + $attrs = []; |
|
| 125 | + } else { |
|
| 126 | + $n = '0'; |
|
| 127 | + $phraseur->contenu['paquet'] = $attrs; |
|
| 128 | + $attrs['menu'] = []; |
|
| 129 | + $attrs['chemin'] = []; |
|
| 130 | + $attrs['necessite'] = []; |
|
| 131 | + $attrs['lib'] = []; |
|
| 132 | + $attrs['onglet'] = []; |
|
| 133 | + $attrs['procure'] = []; |
|
| 134 | + $attrs['pipeline'] = []; |
|
| 135 | + $attrs['utilise'] = []; |
|
| 136 | + $attrs['style'] = []; |
|
| 137 | + $attrs['script'] = []; |
|
| 138 | + $attrs['genie'] = []; |
|
| 139 | + } |
|
| 140 | + $phraseur->contenu['compatible'] = $n; |
|
| 141 | + $phraseur->versions[$phraseur->contenu['compatible']] = $attrs; |
|
| 142 | + } else { |
|
| 143 | + $phraseur->versions[$phraseur->contenu['compatible']][$name][0] = $attrs; |
|
| 144 | + } |
|
| 145 | + $phraseur->versions[$phraseur->contenu['compatible']][''] = ''; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | * @param string $data |
| 155 | 155 | */ |
| 156 | 156 | function paquet_textElement($phraseur, $data) { |
| 157 | - xml_textElement($phraseur, $data); |
|
| 158 | - if ($phraseur->err || !(trim($data))) { |
|
| 159 | - return; |
|
| 160 | - } |
|
| 161 | - $phraseur->versions[$phraseur->contenu['compatible']][''] .= $data; |
|
| 157 | + xml_textElement($phraseur, $data); |
|
| 158 | + if ($phraseur->err || !(trim($data))) { |
|
| 159 | + return; |
|
| 160 | + } |
|
| 161 | + $phraseur->versions[$phraseur->contenu['compatible']][''] .= $data; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -170,32 +170,32 @@ discard block |
||
| 170 | 170 | * @param string $name |
| 171 | 171 | */ |
| 172 | 172 | function paquet_finElement($phraseur, $name) { |
| 173 | - if ($phraseur->err) { |
|
| 174 | - return; |
|
| 175 | - } |
|
| 176 | - $n = $phraseur->contenu['compatible']; |
|
| 177 | - |
|
| 178 | - if (isset($phraseur->versions[$n][$name][0]) && is_array($phraseur->versions[$n][$name][0])) { |
|
| 179 | - $attrs = $phraseur->versions[$n][$name][0]; |
|
| 180 | - unset($phraseur->versions[$n][$name][0]); |
|
| 181 | - } else { |
|
| 182 | - $attrs = []; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - $texte = trim((string) $phraseur->versions[$n]['']); |
|
| 186 | - $phraseur->versions[$n][''] = ''; |
|
| 187 | - |
|
| 188 | - $f = 'info_paquet_' . $name; |
|
| 189 | - if (function_exists($f)) { |
|
| 190 | - $f($phraseur, $attrs, $texte); |
|
| 191 | - } elseif (!$attrs) { |
|
| 192 | - $phraseur->versions[$n][$name] = $texte; |
|
| 193 | - } else { |
|
| 194 | - // Traitement generique. Si $attrs['nom'] n'existe pas, ce n'est pas normal ici |
|
| 195 | - $phraseur->versions[$n][$name][$attrs['nom']] = $attrs; |
|
| 196 | - # echo("<br>pour $name $n " . $attrs['nom']); var_dump($phraseur->versions[$n]); |
|
| 197 | - } |
|
| 198 | - xml_finElement($phraseur, $name, $attrs); |
|
| 173 | + if ($phraseur->err) { |
|
| 174 | + return; |
|
| 175 | + } |
|
| 176 | + $n = $phraseur->contenu['compatible']; |
|
| 177 | + |
|
| 178 | + if (isset($phraseur->versions[$n][$name][0]) && is_array($phraseur->versions[$n][$name][0])) { |
|
| 179 | + $attrs = $phraseur->versions[$n][$name][0]; |
|
| 180 | + unset($phraseur->versions[$n][$name][0]); |
|
| 181 | + } else { |
|
| 182 | + $attrs = []; |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + $texte = trim((string) $phraseur->versions[$n]['']); |
|
| 186 | + $phraseur->versions[$n][''] = ''; |
|
| 187 | + |
|
| 188 | + $f = 'info_paquet_' . $name; |
|
| 189 | + if (function_exists($f)) { |
|
| 190 | + $f($phraseur, $attrs, $texte); |
|
| 191 | + } elseif (!$attrs) { |
|
| 192 | + $phraseur->versions[$n][$name] = $texte; |
|
| 193 | + } else { |
|
| 194 | + // Traitement generique. Si $attrs['nom'] n'existe pas, ce n'est pas normal ici |
|
| 195 | + $phraseur->versions[$n][$name][$attrs['nom']] = $attrs; |
|
| 196 | + # echo("<br>pour $name $n " . $attrs['nom']); var_dump($phraseur->versions[$n]); |
|
| 197 | + } |
|
| 198 | + xml_finElement($phraseur, $name, $attrs); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -207,9 +207,9 @@ discard block |
||
| 207 | 207 | * @param string $texte |
| 208 | 208 | */ |
| 209 | 209 | function info_paquet_licence($phraseur, $attrs, $texte) { |
| 210 | - $lien = $attrs['lien'] ?? ''; |
|
| 211 | - $n = $phraseur->contenu['compatible']; |
|
| 212 | - $phraseur->versions[$n]['licence'][] = ['nom' => $texte, 'url' => $lien]; |
|
| 210 | + $lien = $attrs['lien'] ?? ''; |
|
| 211 | + $n = $phraseur->contenu['compatible']; |
|
| 212 | + $phraseur->versions[$n]['licence'][] = ['nom' => $texte, 'url' => $lien]; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -221,14 +221,14 @@ discard block |
||
| 221 | 221 | * @param string $texte |
| 222 | 222 | */ |
| 223 | 223 | function info_paquet_chemin($phraseur, $attrs, $texte) { |
| 224 | - $n = $phraseur->contenu['compatible']; |
|
| 225 | - if (isset($attrs['path'])) { |
|
| 226 | - if (isset($attrs['type'])) { |
|
| 227 | - $phraseur->versions[$n]['chemin'][] = ['path' => $attrs['path'], 'type' => $attrs['type']]; |
|
| 228 | - } else { |
|
| 229 | - $phraseur->versions[$n]['chemin'][] = ['path' => $attrs['path']]; |
|
| 230 | - } |
|
| 231 | - } |
|
| 224 | + $n = $phraseur->contenu['compatible']; |
|
| 225 | + if (isset($attrs['path'])) { |
|
| 226 | + if (isset($attrs['type'])) { |
|
| 227 | + $phraseur->versions[$n]['chemin'][] = ['path' => $attrs['path'], 'type' => $attrs['type']]; |
|
| 228 | + } else { |
|
| 229 | + $phraseur->versions[$n]['chemin'][] = ['path' => $attrs['path']]; |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | |
@@ -242,20 +242,20 @@ discard block |
||
| 242 | 242 | * @param string $texte |
| 243 | 243 | */ |
| 244 | 244 | function info_paquet_auteur($phraseur, $attrs, $texte) { |
| 245 | - # echo 'auteur ', $texte; var_dump($attrs); |
|
| 246 | - if (isset($attrs['mail'])) { |
|
| 247 | - if (strpos((string) $attrs['mail'], '@')) { |
|
| 248 | - $attrs['mail'] = str_replace('@', ' AT ', (string) $attrs['mail']); |
|
| 249 | - } |
|
| 250 | - $mail = $attrs['mail']; |
|
| 251 | - } else { |
|
| 252 | - $mail = ''; |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - $lien = $attrs['lien'] ?? ''; |
|
| 256 | - |
|
| 257 | - $n = $phraseur->contenu['compatible']; |
|
| 258 | - $phraseur->versions[$n]['auteur'][] = ['nom' => $texte, 'url' => $lien, 'mail' => $mail]; |
|
| 245 | + # echo 'auteur ', $texte; var_dump($attrs); |
|
| 246 | + if (isset($attrs['mail'])) { |
|
| 247 | + if (strpos((string) $attrs['mail'], '@')) { |
|
| 248 | + $attrs['mail'] = str_replace('@', ' AT ', (string) $attrs['mail']); |
|
| 249 | + } |
|
| 250 | + $mail = $attrs['mail']; |
|
| 251 | + } else { |
|
| 252 | + $mail = ''; |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + $lien = $attrs['lien'] ?? ''; |
|
| 256 | + |
|
| 257 | + $n = $phraseur->contenu['compatible']; |
|
| 258 | + $phraseur->versions[$n]['auteur'][] = ['nom' => $texte, 'url' => $lien, 'mail' => $mail]; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** |
@@ -268,10 +268,10 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | function info_paquet_credit($phraseur, $attrs, $texte) { |
| 270 | 270 | |
| 271 | - $lien = $attrs['lien'] ?? ''; |
|
| 271 | + $lien = $attrs['lien'] ?? ''; |
|
| 272 | 272 | |
| 273 | - $n = $phraseur->contenu['compatible']; |
|
| 274 | - $phraseur->versions[$n]['credit'][] = ['nom' => $texte, 'url' => $lien]; |
|
| 273 | + $n = $phraseur->contenu['compatible']; |
|
| 274 | + $phraseur->versions[$n]['credit'][] = ['nom' => $texte, 'url' => $lien]; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -283,8 +283,8 @@ discard block |
||
| 283 | 283 | * @param string $texte |
| 284 | 284 | */ |
| 285 | 285 | function info_paquet_copyright($phraseur, $attrs, $texte) { |
| 286 | - $n = $phraseur->contenu['compatible']; |
|
| 287 | - $phraseur->versions[$n]['copyright'][] = $texte; |
|
| 286 | + $n = $phraseur->contenu['compatible']; |
|
| 287 | + $phraseur->versions[$n]['copyright'][] = $texte; |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
@@ -296,9 +296,9 @@ discard block |
||
| 296 | 296 | * @param string $texte |
| 297 | 297 | */ |
| 298 | 298 | function info_paquet_paquet($phraseur, $attrs, $texte) { |
| 299 | - $n = 0; |
|
| 300 | - $phraseur->versions[$n]['dtd'] = 'paquet'; |
|
| 301 | - $phraseur->versions[$n]['balise'] = 'paquet'; |
|
| 299 | + $n = 0; |
|
| 300 | + $phraseur->versions[$n]['dtd'] = 'paquet'; |
|
| 301 | + $phraseur->versions[$n]['balise'] = 'paquet'; |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
@@ -310,8 +310,8 @@ discard block |
||
| 310 | 310 | * @param string $texte |
| 311 | 311 | **/ |
| 312 | 312 | function info_paquet_traduire($phraseur, $attrs, $texte) { |
| 313 | - $n = $phraseur->contenu['compatible']; |
|
| 314 | - $phraseur->versions[$n]['traduire'][] = $attrs; |
|
| 313 | + $n = $phraseur->contenu['compatible']; |
|
| 314 | + $phraseur->versions[$n]['traduire'][] = $attrs; |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | /** |
@@ -323,8 +323,8 @@ discard block |
||
| 323 | 323 | * @param string $texte |
| 324 | 324 | */ |
| 325 | 325 | function info_paquet_spip($phraseur, $attrs, $texte) { |
| 326 | - $n = $phraseur->contenu['compatible']; |
|
| 327 | - $phraseur->versions[$n]['balise'] = 'spip'; |
|
| 326 | + $n = $phraseur->contenu['compatible']; |
|
| 327 | + $phraseur->versions[$n]['balise'] = 'spip'; |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | |
@@ -336,8 +336,8 @@ discard block |
||
| 336 | 336 | * @param string $texte |
| 337 | 337 | */ |
| 338 | 338 | function info_paquet_pipeline($phraseur, $attrs, $texte) { |
| 339 | - $n = $phraseur->contenu['compatible']; |
|
| 340 | - $phraseur->versions[$n]['pipeline'][] = $attrs; |
|
| 339 | + $n = $phraseur->contenu['compatible']; |
|
| 340 | + $phraseur->versions[$n]['pipeline'][] = $attrs; |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | |
@@ -350,23 +350,23 @@ discard block |
||
| 350 | 350 | * @param string $texte |
| 351 | 351 | */ |
| 352 | 352 | function info_paquet_style($phraseur, $attrs, $texte) { |
| 353 | - $lien = $chemin = $type = $media = ''; |
|
| 354 | - |
|
| 355 | - include_spip('inc/utils'); |
|
| 356 | - if (tester_url_absolue($attrs['source'])) { |
|
| 357 | - $lien = $attrs['source']; |
|
| 358 | - } else { |
|
| 359 | - $chemin = $attrs['source']; |
|
| 360 | - } |
|
| 361 | - if (isset($attrs['type'])) { |
|
| 362 | - $type = $attrs['type']; |
|
| 363 | - } |
|
| 364 | - if (isset($attrs['media'])) { |
|
| 365 | - $media = $attrs['media']; |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - $n = $phraseur->contenu['compatible']; |
|
| 369 | - $phraseur->versions[$n]['style'][] = ['url' => $lien, 'path' => $chemin, 'type' => $type, 'media' => $media]; |
|
| 353 | + $lien = $chemin = $type = $media = ''; |
|
| 354 | + |
|
| 355 | + include_spip('inc/utils'); |
|
| 356 | + if (tester_url_absolue($attrs['source'])) { |
|
| 357 | + $lien = $attrs['source']; |
|
| 358 | + } else { |
|
| 359 | + $chemin = $attrs['source']; |
|
| 360 | + } |
|
| 361 | + if (isset($attrs['type'])) { |
|
| 362 | + $type = $attrs['type']; |
|
| 363 | + } |
|
| 364 | + if (isset($attrs['media'])) { |
|
| 365 | + $media = $attrs['media']; |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + $n = $phraseur->contenu['compatible']; |
|
| 369 | + $phraseur->versions[$n]['style'][] = ['url' => $lien, 'path' => $chemin, 'type' => $type, 'media' => $media]; |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | |
@@ -379,20 +379,20 @@ discard block |
||
| 379 | 379 | * @param string $texte |
| 380 | 380 | */ |
| 381 | 381 | function info_paquet_script($phraseur, $attrs, $texte) { |
| 382 | - $lien = $chemin = $type = $media = ''; |
|
| 383 | - |
|
| 384 | - include_spip('inc/utils'); |
|
| 385 | - if (tester_url_absolue($attrs['source'])) { |
|
| 386 | - $lien = $attrs['source']; |
|
| 387 | - } else { |
|
| 388 | - $chemin = $attrs['source']; |
|
| 389 | - } |
|
| 390 | - if (isset($attrs['type'])) { |
|
| 391 | - $type = $attrs['type']; |
|
| 392 | - } |
|
| 393 | - |
|
| 394 | - $n = $phraseur->contenu['compatible']; |
|
| 395 | - $phraseur->versions[$n]['script'][] = ['url' => $lien, 'path' => $chemin, 'type' => $type]; |
|
| 382 | + $lien = $chemin = $type = $media = ''; |
|
| 383 | + |
|
| 384 | + include_spip('inc/utils'); |
|
| 385 | + if (tester_url_absolue($attrs['source'])) { |
|
| 386 | + $lien = $attrs['source']; |
|
| 387 | + } else { |
|
| 388 | + $chemin = $attrs['source']; |
|
| 389 | + } |
|
| 390 | + if (isset($attrs['type'])) { |
|
| 391 | + $type = $attrs['type']; |
|
| 392 | + } |
|
| 393 | + |
|
| 394 | + $n = $phraseur->contenu['compatible']; |
|
| 395 | + $phraseur->versions[$n]['script'][] = ['url' => $lien, 'path' => $chemin, 'type' => $type]; |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | /** |
@@ -403,6 +403,6 @@ discard block |
||
| 403 | 403 | * @param string $texte |
| 404 | 404 | */ |
| 405 | 405 | function info_paquet_genie($phraseur, $attrs, $texte) { |
| 406 | - $n = $phraseur->contenu['compatible']; |
|
| 407 | - $phraseur->versions[$n]['genie'][] = $attrs; |
|
| 406 | + $n = $phraseur->contenu['compatible']; |
|
| 407 | + $phraseur->versions[$n]['genie'][] = $attrs; |
|
| 408 | 408 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * @return array |
| 25 | 25 | */ |
| 26 | 26 | function plugins_infos_paquet($desc, $plug = '', $dir_plugins = _DIR_PLUGINS) { |
| 27 | - static $process = [ // tableau constant |
|
| 27 | + static $process = [// tableau constant |
|
| 28 | 28 | 'debut' => 'paquet_debutElement', |
| 29 | 29 | 'fin' => 'paquet_finElement', |
| 30 | 30 | 'text' => 'paquet_textElement' |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | unset($tree['']); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - $tree['slogan'] = $tree['prefix'] . '_slogan'; |
|
| 50 | - $tree['description'] = $tree['prefix'] . '_description'; |
|
| 49 | + $tree['slogan'] = $tree['prefix'].'_slogan'; |
|
| 50 | + $tree['description'] = $tree['prefix'].'_description'; |
|
| 51 | 51 | paquet_readable_files($tree, "$dir_plugins$plug/"); |
| 52 | 52 | if (!$tree['chemin']) { |
| 53 | 53 | $tree['chemin'] = []; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | // Prendre les messages d'erreur sans les numeros de lignes |
| 80 | 80 | $msg = array_column($vxml->err, 0); |
| 81 | 81 | $t = _T('plugins_erreur', ['plugins' => $plug]); |
| 82 | - array_unshift($msg, $t . " <ul class='erreur_xml'><li>" . reset($msg) . '</li></ul>'); |
|
| 82 | + array_unshift($msg, $t." <ul class='erreur_xml'><li>".reset($msg).'</li></ul>'); |
|
| 83 | 83 | |
| 84 | 84 | return ['erreur' => $msg]; |
| 85 | 85 | } |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | function paquet_readable_files(&$tree, $dir) { |
| 96 | 96 | $prefix = strtolower((string) $tree['prefix']); |
| 97 | 97 | |
| 98 | - $tree['options'] = (is_readable($dir . $f = ($prefix . '_options.php'))) ? [$f] : []; |
|
| 99 | - $tree['fonctions'] = (is_readable($dir . $f = ($prefix . '_fonctions.php'))) ? [$f] : []; |
|
| 100 | - $tree['install'] = (is_readable($dir . $f = ($prefix . '_administrations.php'))) ? [$f] : []; |
|
| 98 | + $tree['options'] = (is_readable($dir.$f = ($prefix.'_options.php'))) ? [$f] : []; |
|
| 99 | + $tree['fonctions'] = (is_readable($dir.$f = ($prefix.'_fonctions.php'))) ? [$f] : []; |
|
| 100 | + $tree['install'] = (is_readable($dir.$f = ($prefix.'_administrations.php'))) ? [$f] : []; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | $texte = trim((string) $phraseur->versions[$n]['']); |
| 186 | 186 | $phraseur->versions[$n][''] = ''; |
| 187 | 187 | |
| 188 | - $f = 'info_paquet_' . $name; |
|
| 188 | + $f = 'info_paquet_'.$name; |
|
| 189 | 189 | if (function_exists($f)) { |
| 190 | 190 | $f($phraseur, $attrs, $texte); |
| 191 | 191 | } elseif (!$attrs) { |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | /** |
@@ -20,31 +20,31 @@ discard block |
||
| 20 | 20 | * @return array |
| 21 | 21 | */ |
| 22 | 22 | function plugins_extraire_boutons_dist($arbre) { |
| 23 | - $les_boutons = null; |
|
| 24 | - $ret = ['bouton' => [], 'onglet' => []]; |
|
| 25 | - // recuperer les boutons et onglets si necessaire |
|
| 26 | - spip_xml_match_nodes(',^(bouton|onglet)\s,', $arbre, $les_boutons); |
|
| 27 | - if (is_array($les_boutons) && count($les_boutons)) { |
|
| 28 | - $ret['bouton'] = []; |
|
| 29 | - $ret['onglet'] = []; |
|
| 30 | - foreach ($les_boutons as $bouton => $val) { |
|
| 31 | - $bouton = spip_xml_decompose_tag($bouton); |
|
| 32 | - $type = reset($bouton); |
|
| 33 | - $bouton = end($bouton); |
|
| 34 | - if (isset($bouton['id'])) { |
|
| 35 | - $id = $bouton['id']; |
|
| 36 | - $val = reset($val); |
|
| 37 | - if (is_array($val)) { |
|
| 38 | - $ret[$type][$id]['parent'] = $bouton['parent'] ?? ''; |
|
| 39 | - $ret[$type][$id]['position'] = $bouton['position'] ?? ''; |
|
| 40 | - $ret[$type][$id]['titre'] = isset($val['titre']) ? trim((string) spip_xml_aplatit($val['titre'])) : ''; |
|
| 41 | - $ret[$type][$id]['icone'] = isset($val['icone']) ? trim((string) end($val['icone'])) : ''; |
|
| 42 | - $ret[$type][$id]['action'] = isset($val['url']) ? trim((string) end($val['url'])) : ''; |
|
| 43 | - $ret[$type][$id]['parametres'] = isset($val['args']) ? trim((string) end($val['args'])) : ''; |
|
| 44 | - } |
|
| 45 | - } |
|
| 46 | - } |
|
| 47 | - } |
|
| 23 | + $les_boutons = null; |
|
| 24 | + $ret = ['bouton' => [], 'onglet' => []]; |
|
| 25 | + // recuperer les boutons et onglets si necessaire |
|
| 26 | + spip_xml_match_nodes(',^(bouton|onglet)\s,', $arbre, $les_boutons); |
|
| 27 | + if (is_array($les_boutons) && count($les_boutons)) { |
|
| 28 | + $ret['bouton'] = []; |
|
| 29 | + $ret['onglet'] = []; |
|
| 30 | + foreach ($les_boutons as $bouton => $val) { |
|
| 31 | + $bouton = spip_xml_decompose_tag($bouton); |
|
| 32 | + $type = reset($bouton); |
|
| 33 | + $bouton = end($bouton); |
|
| 34 | + if (isset($bouton['id'])) { |
|
| 35 | + $id = $bouton['id']; |
|
| 36 | + $val = reset($val); |
|
| 37 | + if (is_array($val)) { |
|
| 38 | + $ret[$type][$id]['parent'] = $bouton['parent'] ?? ''; |
|
| 39 | + $ret[$type][$id]['position'] = $bouton['position'] ?? ''; |
|
| 40 | + $ret[$type][$id]['titre'] = isset($val['titre']) ? trim((string) spip_xml_aplatit($val['titre'])) : ''; |
|
| 41 | + $ret[$type][$id]['icone'] = isset($val['icone']) ? trim((string) end($val['icone'])) : ''; |
|
| 42 | + $ret[$type][$id]['action'] = isset($val['url']) ? trim((string) end($val['url'])) : ''; |
|
| 43 | + $ret[$type][$id]['parametres'] = isset($val['args']) ? trim((string) end($val['args'])) : ''; |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - return $ret; |
|
| 49 | + return $ret; |
|
| 50 | 50 | } |
@@ -10,110 +10,110 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | function plugins_afficher_repertoires_dist($url_page, $liste_plugins, $liste_plugins_actifs) { |
| 17 | - $ligne_plug = charger_fonction('afficher_plugin', 'plugins'); |
|
| 18 | - $racine = basename((string) _DIR_PLUGINS); |
|
| 19 | - $init_dir = $current_dir = ''; |
|
| 20 | - // liste des repertoires deplies : construit en remontant l'arbo de chaque plugin actif |
|
| 21 | - // des qu'un path est deja note deplie on s'arrete |
|
| 22 | - $deplie = [$racine => true]; |
|
| 23 | - $fast_liste_plugins_actifs = []; |
|
| 24 | - foreach ($liste_plugins_actifs as $key => $plug) { |
|
| 25 | - $chemin_plug = chemin_plug($racine, $plug); |
|
| 26 | - $fast_liste_plugins_actifs[$chemin_plug] = true; |
|
| 27 | - $dir = dirname((string) $chemin_plug); |
|
| 28 | - $maxiter = 100; |
|
| 29 | - while (strlen($dir) && !isset($deplie[$dir]) && $dir !== $racine && $maxiter-- > 0) { |
|
| 30 | - $deplie[$dir] = true; |
|
| 31 | - $dir = dirname($dir); |
|
| 32 | - } |
|
| 33 | - } |
|
| 17 | + $ligne_plug = charger_fonction('afficher_plugin', 'plugins'); |
|
| 18 | + $racine = basename((string) _DIR_PLUGINS); |
|
| 19 | + $init_dir = $current_dir = ''; |
|
| 20 | + // liste des repertoires deplies : construit en remontant l'arbo de chaque plugin actif |
|
| 21 | + // des qu'un path est deja note deplie on s'arrete |
|
| 22 | + $deplie = [$racine => true]; |
|
| 23 | + $fast_liste_plugins_actifs = []; |
|
| 24 | + foreach ($liste_plugins_actifs as $key => $plug) { |
|
| 25 | + $chemin_plug = chemin_plug($racine, $plug); |
|
| 26 | + $fast_liste_plugins_actifs[$chemin_plug] = true; |
|
| 27 | + $dir = dirname((string) $chemin_plug); |
|
| 28 | + $maxiter = 100; |
|
| 29 | + while (strlen($dir) && !isset($deplie[$dir]) && $dir !== $racine && $maxiter-- > 0) { |
|
| 30 | + $deplie[$dir] = true; |
|
| 31 | + $dir = dirname($dir); |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - // index repertoires --> plugin |
|
| 36 | - $dir_index = []; |
|
| 37 | - foreach ($liste_plugins as $key => $plug) { |
|
| 38 | - $liste_plugins[$key] = chemin_plug($racine, $plug); |
|
| 39 | - $dir_index[dirname((string) $liste_plugins[$key])][] = $key; |
|
| 40 | - } |
|
| 35 | + // index repertoires --> plugin |
|
| 36 | + $dir_index = []; |
|
| 37 | + foreach ($liste_plugins as $key => $plug) { |
|
| 38 | + $liste_plugins[$key] = chemin_plug($racine, $plug); |
|
| 39 | + $dir_index[dirname((string) $liste_plugins[$key])][] = $key; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - $visible = @isset($deplie[$current_dir]); |
|
| 43 | - $maxiter = 1000; |
|
| 42 | + $visible = @isset($deplie[$current_dir]); |
|
| 43 | + $maxiter = 1000; |
|
| 44 | 44 | |
| 45 | - $res = ''; |
|
| 46 | - while ((is_countable($liste_plugins) ? count($liste_plugins) : 0) && $maxiter--) { |
|
| 47 | - // le rep suivant |
|
| 48 | - $dir = dirname((string) reset($liste_plugins)); |
|
| 49 | - if ($dir != $current_dir) { |
|
| 50 | - $res .= tree_open_close_dir($current_dir, $dir, $deplie); |
|
| 51 | - } |
|
| 45 | + $res = ''; |
|
| 46 | + while ((is_countable($liste_plugins) ? count($liste_plugins) : 0) && $maxiter--) { |
|
| 47 | + // le rep suivant |
|
| 48 | + $dir = dirname((string) reset($liste_plugins)); |
|
| 49 | + if ($dir != $current_dir) { |
|
| 50 | + $res .= tree_open_close_dir($current_dir, $dir, $deplie); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - // d'abord tous les plugins du rep courant |
|
| 54 | - if (isset($dir_index[$current_dir])) { |
|
| 55 | - foreach ($dir_index[$current_dir] as $key) { |
|
| 56 | - $plug = $liste_plugins[$key]; |
|
| 57 | - $actif = @isset($fast_liste_plugins_actifs[$plug]); |
|
| 58 | - $id = substr(md5((string) $plug), 0, 16); |
|
| 59 | - $res .= $ligne_plug( |
|
| 60 | - $url_page, |
|
| 61 | - str_replace(_DIR_PLUGINS, '', _DIR_RACINE . $plug), |
|
| 62 | - $actif, |
|
| 63 | - 'menu-entree' |
|
| 64 | - ) . "\n"; |
|
| 65 | - unset($liste_plugins[$key]); |
|
| 66 | - } |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - $res .= tree_open_close_dir($current_dir, $init_dir, true); |
|
| 53 | + // d'abord tous les plugins du rep courant |
|
| 54 | + if (isset($dir_index[$current_dir])) { |
|
| 55 | + foreach ($dir_index[$current_dir] as $key) { |
|
| 56 | + $plug = $liste_plugins[$key]; |
|
| 57 | + $actif = @isset($fast_liste_plugins_actifs[$plug]); |
|
| 58 | + $id = substr(md5((string) $plug), 0, 16); |
|
| 59 | + $res .= $ligne_plug( |
|
| 60 | + $url_page, |
|
| 61 | + str_replace(_DIR_PLUGINS, '', _DIR_RACINE . $plug), |
|
| 62 | + $actif, |
|
| 63 | + 'menu-entree' |
|
| 64 | + ) . "\n"; |
|
| 65 | + unset($liste_plugins[$key]); |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + $res .= tree_open_close_dir($current_dir, $init_dir, true); |
|
| 70 | 70 | |
| 71 | - return "<ul class='menu-liste plugins'>" |
|
| 72 | - . $res |
|
| 73 | - . '</ul>'; |
|
| 71 | + return "<ul class='menu-liste plugins'>" |
|
| 72 | + . $res |
|
| 73 | + . '</ul>'; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | |
| 77 | 77 | // vraiment n'importe quoi la gestion des chemins des plugins |
| 78 | 78 | // une fonction pour aider... |
| 79 | 79 | function chemin_plug($racine, $plug) { |
| 80 | - return preg_replace(',[^/]+/\.\./,', '', "$racine/$plug"); |
|
| 80 | + return preg_replace(',[^/]+/\.\./,', '', "$racine/$plug"); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | function tree_open_close_dir(&$current, $target, $deplie = []) { |
| 84 | - if ($current == $target) { |
|
| 85 | - return ''; |
|
| 86 | - } |
|
| 87 | - $tcur = explode('/', (string) $current); |
|
| 88 | - $ttarg = explode('/', (string) $target); |
|
| 89 | - $tcom = []; |
|
| 90 | - $output = ''; |
|
| 91 | - // la partie commune |
|
| 92 | - while (reset($tcur) === reset($ttarg)) { |
|
| 93 | - $tcom[] = array_shift($tcur); |
|
| 94 | - array_shift($ttarg); |
|
| 95 | - } |
|
| 96 | - // fermer les repertoires courant jusqu'au point de fork |
|
| 97 | - while ($close = array_pop($tcur)) { |
|
| 98 | - $output .= "</ul>\n"; |
|
| 99 | - $output .= fin_block(); |
|
| 100 | - $output .= "</li>\n"; |
|
| 101 | - } |
|
| 102 | - $chemin = ''; |
|
| 103 | - if ($tcom !== []) { |
|
| 104 | - $chemin .= implode('/', $tcom) . '/'; |
|
| 105 | - } |
|
| 106 | - // ouvrir les repertoires jusqu'a la cible |
|
| 107 | - while ($open = array_shift($ttarg)) { |
|
| 108 | - $visible = @isset($deplie[$chemin . $open]); |
|
| 109 | - $chemin .= $open . '/'; |
|
| 110 | - $output .= '<li>'; |
|
| 111 | - $output .= bouton_block_depliable($chemin, $visible); |
|
| 112 | - $output .= debut_block_depliable($visible); |
|
| 84 | + if ($current == $target) { |
|
| 85 | + return ''; |
|
| 86 | + } |
|
| 87 | + $tcur = explode('/', (string) $current); |
|
| 88 | + $ttarg = explode('/', (string) $target); |
|
| 89 | + $tcom = []; |
|
| 90 | + $output = ''; |
|
| 91 | + // la partie commune |
|
| 92 | + while (reset($tcur) === reset($ttarg)) { |
|
| 93 | + $tcom[] = array_shift($tcur); |
|
| 94 | + array_shift($ttarg); |
|
| 95 | + } |
|
| 96 | + // fermer les repertoires courant jusqu'au point de fork |
|
| 97 | + while ($close = array_pop($tcur)) { |
|
| 98 | + $output .= "</ul>\n"; |
|
| 99 | + $output .= fin_block(); |
|
| 100 | + $output .= "</li>\n"; |
|
| 101 | + } |
|
| 102 | + $chemin = ''; |
|
| 103 | + if ($tcom !== []) { |
|
| 104 | + $chemin .= implode('/', $tcom) . '/'; |
|
| 105 | + } |
|
| 106 | + // ouvrir les repertoires jusqu'a la cible |
|
| 107 | + while ($open = array_shift($ttarg)) { |
|
| 108 | + $visible = @isset($deplie[$chemin . $open]); |
|
| 109 | + $chemin .= $open . '/'; |
|
| 110 | + $output .= '<li>'; |
|
| 111 | + $output .= bouton_block_depliable($chemin, $visible); |
|
| 112 | + $output .= debut_block_depliable($visible); |
|
| 113 | 113 | |
| 114 | - $output .= "<ul>\n"; |
|
| 115 | - } |
|
| 116 | - $current = $target; |
|
| 114 | + $output .= "<ul>\n"; |
|
| 115 | + } |
|
| 116 | + $current = $target; |
|
| 117 | 117 | |
| 118 | - return $output; |
|
| 118 | + return $output; |
|
| 119 | 119 | } |
@@ -58,10 +58,10 @@ discard block |
||
| 58 | 58 | $id = substr(md5((string) $plug), 0, 16); |
| 59 | 59 | $res .= $ligne_plug( |
| 60 | 60 | $url_page, |
| 61 | - str_replace(_DIR_PLUGINS, '', _DIR_RACINE . $plug), |
|
| 61 | + str_replace(_DIR_PLUGINS, '', _DIR_RACINE.$plug), |
|
| 62 | 62 | $actif, |
| 63 | 63 | 'menu-entree' |
| 64 | - ) . "\n"; |
|
| 64 | + )."\n"; |
|
| 65 | 65 | unset($liste_plugins[$key]); |
| 66 | 66 | } |
| 67 | 67 | } |
@@ -101,12 +101,12 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | $chemin = ''; |
| 103 | 103 | if ($tcom !== []) { |
| 104 | - $chemin .= implode('/', $tcom) . '/'; |
|
| 104 | + $chemin .= implode('/', $tcom).'/'; |
|
| 105 | 105 | } |
| 106 | 106 | // ouvrir les repertoires jusqu'a la cible |
| 107 | 107 | while ($open = array_shift($ttarg)) { |
| 108 | - $visible = @isset($deplie[$chemin . $open]); |
|
| 109 | - $chemin .= $open . '/'; |
|
| 108 | + $visible = @isset($deplie[$chemin.$open]); |
|
| 109 | + $chemin .= $open.'/'; |
|
| 110 | 110 | $output .= '<li>'; |
| 111 | 111 | $output .= bouton_block_depliable($chemin, $visible); |
| 112 | 112 | $output .= debut_block_depliable($visible); |