@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | 25 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 26 | - return; |
|
| 26 | + return; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
@@ -31,25 +31,25 @@ discard block |
||
| 31 | 31 | * Réparer la base de données |
| 32 | 32 | */ |
| 33 | 33 | function exec_base_repair_dist() { |
| 34 | - $action = null; |
|
| 35 | - $ok = false; |
|
| 36 | - if (!spip_connect()) { |
|
| 37 | - $message = _T('titre_probleme_technique'); |
|
| 38 | - } else { |
|
| 39 | - $version_sql = sql_version(); |
|
| 40 | - if (!$version_sql) { |
|
| 41 | - $message = _T('avis_erreur_connexion_mysql'); |
|
| 42 | - } else { |
|
| 43 | - $message = _T('texte_requetes_echouent'); |
|
| 44 | - $ok = true; |
|
| 45 | - } |
|
| 46 | - $action = _T('texte_tenter_reparation'); |
|
| 47 | - } |
|
| 48 | - if ($ok) { |
|
| 49 | - $admin = charger_fonction('admin', 'inc'); |
|
| 50 | - echo $admin('repair', $action, $message, true); |
|
| 51 | - } else { |
|
| 52 | - include_spip('inc/minipres'); |
|
| 53 | - echo minipres(_T('titre_reparation'), "<p>$message</p>"); |
|
| 54 | - } |
|
| 34 | + $action = null; |
|
| 35 | + $ok = false; |
|
| 36 | + if (!spip_connect()) { |
|
| 37 | + $message = _T('titre_probleme_technique'); |
|
| 38 | + } else { |
|
| 39 | + $version_sql = sql_version(); |
|
| 40 | + if (!$version_sql) { |
|
| 41 | + $message = _T('avis_erreur_connexion_mysql'); |
|
| 42 | + } else { |
|
| 43 | + $message = _T('texte_requetes_echouent'); |
|
| 44 | + $ok = true; |
|
| 45 | + } |
|
| 46 | + $action = _T('texte_tenter_reparation'); |
|
| 47 | + } |
|
| 48 | + if ($ok) { |
|
| 49 | + $admin = charger_fonction('admin', 'inc'); |
|
| 50 | + echo $admin('repair', $action, $message, true); |
|
| 51 | + } else { |
|
| 52 | + include_spip('inc/minipres'); |
|
| 53 | + echo minipres(_T('titre_reparation'), "<p>$message</p>"); |
|
| 54 | + } |
|
| 55 | 55 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/config'); |
@@ -37,26 +37,26 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | function exec_admin_plugin_dist($retour = '') { |
| 39 | 39 | |
| 40 | - if (!autoriser('configurer', '_plugins')) { |
|
| 41 | - include_spip('inc/minipres'); |
|
| 42 | - echo minipres(); |
|
| 43 | - } else { |
|
| 44 | - // on fait la verif du path avant tout, |
|
| 45 | - // et l'installation des qu'on est dans la colonne principale |
|
| 46 | - // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
|
| 47 | - // pour etre sur que les bons fichiers seront charges lors de l'install |
|
| 48 | - $new = actualise_plugins_actifs(); |
|
| 49 | - if ($new and _request('actualise') < 2) { |
|
| 50 | - include_spip('inc/headers'); |
|
| 51 | - if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 52 | - // attendre eventuellement l'invalidation du cache opcode |
|
| 53 | - spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 54 | - } |
|
| 55 | - redirige_par_entete(parametre_url(self(), 'actualise', _request('actualise') + 1, '&')); |
|
| 56 | - } else { |
|
| 57 | - admin_plug_args(_request('voir'), _request('erreur'), _request('format')); |
|
| 58 | - } |
|
| 59 | - } |
|
| 40 | + if (!autoriser('configurer', '_plugins')) { |
|
| 41 | + include_spip('inc/minipres'); |
|
| 42 | + echo minipres(); |
|
| 43 | + } else { |
|
| 44 | + // on fait la verif du path avant tout, |
|
| 45 | + // et l'installation des qu'on est dans la colonne principale |
|
| 46 | + // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
|
| 47 | + // pour etre sur que les bons fichiers seront charges lors de l'install |
|
| 48 | + $new = actualise_plugins_actifs(); |
|
| 49 | + if ($new and _request('actualise') < 2) { |
|
| 50 | + include_spip('inc/headers'); |
|
| 51 | + if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 52 | + // attendre eventuellement l'invalidation du cache opcode |
|
| 53 | + spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 54 | + } |
|
| 55 | + redirige_par_entete(parametre_url(self(), 'actualise', _request('actualise') + 1, '&')); |
|
| 56 | + } else { |
|
| 57 | + admin_plug_args(_request('voir'), _request('erreur'), _request('format')); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -81,132 +81,132 @@ discard block |
||
| 81 | 81 | * Format d'affichage (liste ou arborescence) |
| 82 | 82 | **/ |
| 83 | 83 | function admin_plug_args($quoi, $erreur, $format) { |
| 84 | - $lpf = null; |
|
| 85 | - $lcpas = null; |
|
| 86 | - $lcpaffichesup = null; |
|
| 87 | - if (!$quoi) { |
|
| 88 | - $quoi = 'actifs'; |
|
| 89 | - } |
|
| 90 | - // empecher l'affichage des erreurs dans le bandeau, on le donne ensuite |
|
| 91 | - // format brut par plugin |
|
| 92 | - $GLOBALS['erreurs_activation_raw'] = plugin_donne_erreurs(true, false); |
|
| 93 | - // format resume mis en forme |
|
| 94 | - $erreur_activation = plugin_donne_erreurs(); |
|
| 95 | - $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 96 | - echo $commencer_page(_T('icone_admin_plugin'), 'configuration', 'plugin'); |
|
| 97 | - |
|
| 98 | - echo debut_gauche(); |
|
| 99 | - echo recuperer_fond('prive/squelettes/navigation/configurer', ['exec' => 'admin_plugin']); |
|
| 100 | - |
|
| 101 | - echo pipeline( |
|
| 102 | - 'affiche_gauche', |
|
| 103 | - [ |
|
| 104 | - 'args' => ['exec' => 'admin_plugin'], |
|
| 105 | - 'data' => afficher_librairies() |
|
| 106 | - ] |
|
| 107 | - ); |
|
| 108 | - |
|
| 109 | - echo debut_droite(); |
|
| 110 | - echo gros_titre(_T('icone_admin_plugin'), ''); |
|
| 111 | - |
|
| 112 | - // Barre d'onglets de premier niveau |
|
| 113 | - echo barre_onglets('plugins', 'plugins_actifs'); |
|
| 114 | - // Barre d'onglets de second niveau |
|
| 115 | - $onglet2 = $quoi == 'actifs' ? 'plugins_actifs' : 'admin_plugin'; |
|
| 116 | - echo debut_onglet('onglets_simple second'); |
|
| 117 | - echo onglet(_T('plugins_tous_liste'), generer_url_ecrire('admin_plugin', 'voir=tous'), 'admin_plugin', $onglet2); |
|
| 118 | - echo onglet(_T('plugins_actifs_liste'), generer_url_ecrire('admin_plugin'), 'plugins_actifs', $onglet2); |
|
| 119 | - echo fin_onglet(); |
|
| 120 | - |
|
| 121 | - // message d'erreur au retour d'une operation |
|
| 122 | - if ($erreur) { |
|
| 123 | - echo "<div class='error'>$erreur</div>"; |
|
| 124 | - } |
|
| 125 | - if ($erreur_activation) { |
|
| 126 | - echo "<div class='error'>$erreur_activation</div>"; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - // la mise a jour de cette meta a ete faite par ecrire_plugin_actifs |
|
| 130 | - $actifs = unserialize($GLOBALS['meta']['plugin']); |
|
| 131 | - $lcpa = $actifs + unserialize($GLOBALS['meta']['plugin_attente']); |
|
| 132 | - |
|
| 133 | - // Les affichages se basent sur le repertoire, pas sur le nom |
|
| 134 | - $actifs = liste_chemin_plugin($actifs, ''); |
|
| 135 | - if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 136 | - $lcpas = liste_chemin_plugin($lcpa, _DIR_PLUGINS_SUPPL); |
|
| 137 | - } |
|
| 138 | - $lcpa = liste_chemin_plugin($lcpa); |
|
| 139 | - |
|
| 140 | - // on installe les plugins maintenant, |
|
| 141 | - // cela permet aux scripts d'install de faire des affichages (moches...) |
|
| 142 | - plugin_installes_meta(); |
|
| 143 | - |
|
| 144 | - echo "<div class='liste-plugins formulaire_spip'>"; |
|
| 145 | - echo debut_cadre_trait_couleur('plugin-24.png', true, '', _T('plugins_liste'), 'plugins'); |
|
| 146 | - |
|
| 147 | - if ($quoi !== 'actifs') { |
|
| 148 | - $lpf = liste_plugin_files(); |
|
| 149 | - if ($lpf) { |
|
| 150 | - echo '<p>' . _T('texte_presente_plugin') . '</p>'; |
|
| 151 | - } else { |
|
| 152 | - if (!@is_dir(_DIR_PLUGINS)) { |
|
| 153 | - echo '<p>' . _T('plugin_info_automatique_ftp', ['rep' => joli_repertoire(_DIR_PLUGINS)]) |
|
| 154 | - . ' — ' . _T('plugin_info_automatique_creer') . '</p>'; |
|
| 155 | - } |
|
| 156 | - } |
|
| 157 | - $lcpaffiche = $lpf; |
|
| 158 | - if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 159 | - $lcpaffichesup = liste_plugin_files(_DIR_PLUGINS_SUPPL); |
|
| 160 | - } |
|
| 161 | - } else { |
|
| 162 | - // la liste |
|
| 163 | - // $quoi=='actifs' |
|
| 164 | - $lcpaffiche = $lcpa; |
|
| 165 | - if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 166 | - $lcpaffichesup = $lcpas; |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - if ($quoi == 'actifs' or $lpf) { |
|
| 171 | - $nb = is_countable($lcpa) ? count($lcpa) : 0; |
|
| 172 | - if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 173 | - $nb += is_countable($lcpas) ? count($lcpas) : 0; |
|
| 174 | - } |
|
| 175 | - echo '<h3>' . sinon( |
|
| 176 | - singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'), |
|
| 177 | - _T('plugins_actif_aucun') |
|
| 178 | - ) . '</h3>'; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - if (empty($format)) { |
|
| 182 | - $format = 'liste'; |
|
| 183 | - } elseif (!in_array($format, ['liste', 'repertoires'])) { |
|
| 184 | - $format = 'repertoires'; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - $afficher = charger_fonction("afficher_$format", 'plugins'); |
|
| 188 | - $corps = $afficher(self(), $lcpaffiche, $lcpa, $actifs); |
|
| 189 | - if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 190 | - $corps .= $afficher(self(), $lcpaffichesup, $lcpas, $actifs, _DIR_PLUGINS_SUPPL); |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - if ($corps) { |
|
| 194 | - $corps .= "\n<div class='boutons' style='display:none;'>" |
|
| 195 | - . "<input type='submit' class='submit save' value='" . _T('bouton_enregistrer') |
|
| 196 | - . "' />" |
|
| 197 | - . '</div>'; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - echo redirige_action_post('activer_plugins', 'activer', 'admin_plugin', '', $corps); |
|
| 201 | - |
|
| 202 | - echo fin_cadre_trait_couleur(); |
|
| 203 | - |
|
| 204 | - if ($quoi == 'actifs') { |
|
| 205 | - echo affiche_les_plugins_verrouilles($actifs); |
|
| 206 | - } |
|
| 207 | - echo '</div>'; |
|
| 208 | - |
|
| 209 | - echo http_script(" |
|
| 84 | + $lpf = null; |
|
| 85 | + $lcpas = null; |
|
| 86 | + $lcpaffichesup = null; |
|
| 87 | + if (!$quoi) { |
|
| 88 | + $quoi = 'actifs'; |
|
| 89 | + } |
|
| 90 | + // empecher l'affichage des erreurs dans le bandeau, on le donne ensuite |
|
| 91 | + // format brut par plugin |
|
| 92 | + $GLOBALS['erreurs_activation_raw'] = plugin_donne_erreurs(true, false); |
|
| 93 | + // format resume mis en forme |
|
| 94 | + $erreur_activation = plugin_donne_erreurs(); |
|
| 95 | + $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 96 | + echo $commencer_page(_T('icone_admin_plugin'), 'configuration', 'plugin'); |
|
| 97 | + |
|
| 98 | + echo debut_gauche(); |
|
| 99 | + echo recuperer_fond('prive/squelettes/navigation/configurer', ['exec' => 'admin_plugin']); |
|
| 100 | + |
|
| 101 | + echo pipeline( |
|
| 102 | + 'affiche_gauche', |
|
| 103 | + [ |
|
| 104 | + 'args' => ['exec' => 'admin_plugin'], |
|
| 105 | + 'data' => afficher_librairies() |
|
| 106 | + ] |
|
| 107 | + ); |
|
| 108 | + |
|
| 109 | + echo debut_droite(); |
|
| 110 | + echo gros_titre(_T('icone_admin_plugin'), ''); |
|
| 111 | + |
|
| 112 | + // Barre d'onglets de premier niveau |
|
| 113 | + echo barre_onglets('plugins', 'plugins_actifs'); |
|
| 114 | + // Barre d'onglets de second niveau |
|
| 115 | + $onglet2 = $quoi == 'actifs' ? 'plugins_actifs' : 'admin_plugin'; |
|
| 116 | + echo debut_onglet('onglets_simple second'); |
|
| 117 | + echo onglet(_T('plugins_tous_liste'), generer_url_ecrire('admin_plugin', 'voir=tous'), 'admin_plugin', $onglet2); |
|
| 118 | + echo onglet(_T('plugins_actifs_liste'), generer_url_ecrire('admin_plugin'), 'plugins_actifs', $onglet2); |
|
| 119 | + echo fin_onglet(); |
|
| 120 | + |
|
| 121 | + // message d'erreur au retour d'une operation |
|
| 122 | + if ($erreur) { |
|
| 123 | + echo "<div class='error'>$erreur</div>"; |
|
| 124 | + } |
|
| 125 | + if ($erreur_activation) { |
|
| 126 | + echo "<div class='error'>$erreur_activation</div>"; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + // la mise a jour de cette meta a ete faite par ecrire_plugin_actifs |
|
| 130 | + $actifs = unserialize($GLOBALS['meta']['plugin']); |
|
| 131 | + $lcpa = $actifs + unserialize($GLOBALS['meta']['plugin_attente']); |
|
| 132 | + |
|
| 133 | + // Les affichages se basent sur le repertoire, pas sur le nom |
|
| 134 | + $actifs = liste_chemin_plugin($actifs, ''); |
|
| 135 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 136 | + $lcpas = liste_chemin_plugin($lcpa, _DIR_PLUGINS_SUPPL); |
|
| 137 | + } |
|
| 138 | + $lcpa = liste_chemin_plugin($lcpa); |
|
| 139 | + |
|
| 140 | + // on installe les plugins maintenant, |
|
| 141 | + // cela permet aux scripts d'install de faire des affichages (moches...) |
|
| 142 | + plugin_installes_meta(); |
|
| 143 | + |
|
| 144 | + echo "<div class='liste-plugins formulaire_spip'>"; |
|
| 145 | + echo debut_cadre_trait_couleur('plugin-24.png', true, '', _T('plugins_liste'), 'plugins'); |
|
| 146 | + |
|
| 147 | + if ($quoi !== 'actifs') { |
|
| 148 | + $lpf = liste_plugin_files(); |
|
| 149 | + if ($lpf) { |
|
| 150 | + echo '<p>' . _T('texte_presente_plugin') . '</p>'; |
|
| 151 | + } else { |
|
| 152 | + if (!@is_dir(_DIR_PLUGINS)) { |
|
| 153 | + echo '<p>' . _T('plugin_info_automatique_ftp', ['rep' => joli_repertoire(_DIR_PLUGINS)]) |
|
| 154 | + . ' — ' . _T('plugin_info_automatique_creer') . '</p>'; |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | + $lcpaffiche = $lpf; |
|
| 158 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 159 | + $lcpaffichesup = liste_plugin_files(_DIR_PLUGINS_SUPPL); |
|
| 160 | + } |
|
| 161 | + } else { |
|
| 162 | + // la liste |
|
| 163 | + // $quoi=='actifs' |
|
| 164 | + $lcpaffiche = $lcpa; |
|
| 165 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 166 | + $lcpaffichesup = $lcpas; |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + if ($quoi == 'actifs' or $lpf) { |
|
| 171 | + $nb = is_countable($lcpa) ? count($lcpa) : 0; |
|
| 172 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 173 | + $nb += is_countable($lcpas) ? count($lcpas) : 0; |
|
| 174 | + } |
|
| 175 | + echo '<h3>' . sinon( |
|
| 176 | + singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'), |
|
| 177 | + _T('plugins_actif_aucun') |
|
| 178 | + ) . '</h3>'; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + if (empty($format)) { |
|
| 182 | + $format = 'liste'; |
|
| 183 | + } elseif (!in_array($format, ['liste', 'repertoires'])) { |
|
| 184 | + $format = 'repertoires'; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + $afficher = charger_fonction("afficher_$format", 'plugins'); |
|
| 188 | + $corps = $afficher(self(), $lcpaffiche, $lcpa, $actifs); |
|
| 189 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 190 | + $corps .= $afficher(self(), $lcpaffichesup, $lcpas, $actifs, _DIR_PLUGINS_SUPPL); |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + if ($corps) { |
|
| 194 | + $corps .= "\n<div class='boutons' style='display:none;'>" |
|
| 195 | + . "<input type='submit' class='submit save' value='" . _T('bouton_enregistrer') |
|
| 196 | + . "' />" |
|
| 197 | + . '</div>'; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + echo redirige_action_post('activer_plugins', 'activer', 'admin_plugin', '', $corps); |
|
| 201 | + |
|
| 202 | + echo fin_cadre_trait_couleur(); |
|
| 203 | + |
|
| 204 | + if ($quoi == 'actifs') { |
|
| 205 | + echo affiche_les_plugins_verrouilles($actifs); |
|
| 206 | + } |
|
| 207 | + echo '</div>'; |
|
| 208 | + |
|
| 209 | + echo http_script(" |
|
| 210 | 210 | jQuery(function(){ |
| 211 | 211 | jQuery('.plugins li.item a[rel=info]').click(function(){ |
| 212 | 212 | var li = jQuery(this).parents('li').eq(0); |
@@ -232,15 +232,15 @@ discard block |
||
| 232 | 232 | }); |
| 233 | 233 | "); |
| 234 | 234 | |
| 235 | - echo pipeline( |
|
| 236 | - 'affiche_milieu', |
|
| 237 | - [ |
|
| 238 | - 'args' => ['exec' => 'admin_plugin'], |
|
| 239 | - 'data' => '' |
|
| 240 | - ] |
|
| 241 | - ); |
|
| 235 | + echo pipeline( |
|
| 236 | + 'affiche_milieu', |
|
| 237 | + [ |
|
| 238 | + 'args' => ['exec' => 'admin_plugin'], |
|
| 239 | + 'data' => '' |
|
| 240 | + ] |
|
| 241 | + ); |
|
| 242 | 242 | |
| 243 | - echo fin_gauche(), fin_page(); |
|
| 243 | + echo fin_gauche(), fin_page(); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -254,23 +254,23 @@ discard block |
||
| 254 | 254 | * Code HTML |
| 255 | 255 | **/ |
| 256 | 256 | function affiche_les_plugins_verrouilles($actifs) { |
| 257 | - if ((!$liste = liste_plugin_files(_DIR_PLUGINS_DIST))) { |
|
| 258 | - return ''; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - $afficher = charger_fonction('afficher_liste', 'plugins'); |
|
| 262 | - $liste = $afficher(self(), $liste, [], $actifs, _DIR_PLUGINS_DIST); |
|
| 263 | - |
|
| 264 | - return |
|
| 265 | - "<div id='plugins_dist'>" |
|
| 266 | - . debut_cadre_trait_couleur('', true, '', _T('plugins_liste_dist'), 'liste_plugins_dist') |
|
| 267 | - . '<p>' |
|
| 268 | - . _T('plugin_info_plugins_dist_1', ['plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST)]) |
|
| 269 | - . '<br />' . _T('plugin_info_plugins_dist_2') |
|
| 270 | - . '</p>' |
|
| 271 | - . $liste |
|
| 272 | - . fin_cadre_trait_couleur() |
|
| 273 | - . "</div>\n"; |
|
| 257 | + if ((!$liste = liste_plugin_files(_DIR_PLUGINS_DIST))) { |
|
| 258 | + return ''; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + $afficher = charger_fonction('afficher_liste', 'plugins'); |
|
| 262 | + $liste = $afficher(self(), $liste, [], $actifs, _DIR_PLUGINS_DIST); |
|
| 263 | + |
|
| 264 | + return |
|
| 265 | + "<div id='plugins_dist'>" |
|
| 266 | + . debut_cadre_trait_couleur('', true, '', _T('plugins_liste_dist'), 'liste_plugins_dist') |
|
| 267 | + . '<p>' |
|
| 268 | + . _T('plugin_info_plugins_dist_1', ['plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST)]) |
|
| 269 | + . '<br />' . _T('plugin_info_plugins_dist_2') |
|
| 270 | + . '</p>' |
|
| 271 | + . $liste |
|
| 272 | + . fin_cadre_trait_couleur() |
|
| 273 | + . "</div>\n"; |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
@@ -282,19 +282,19 @@ discard block |
||
| 282 | 282 | */ |
| 283 | 283 | function afficher_librairies() { |
| 284 | 284 | |
| 285 | - if (!$libs = liste_librairies()) { |
|
| 286 | - return ''; |
|
| 287 | - } |
|
| 288 | - ksort($libs); |
|
| 289 | - $res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees')); |
|
| 290 | - $res .= '<dl>'; |
|
| 291 | - foreach ($libs as $lib => $rep) { |
|
| 292 | - $res .= "<dt>$lib</dt><dd>" . joli_repertoire($rep) . "</dd>\n"; |
|
| 293 | - } |
|
| 294 | - $res .= '</dl>'; |
|
| 295 | - $res .= fin_cadre_enfonce(); |
|
| 296 | - |
|
| 297 | - return $res; |
|
| 285 | + if (!$libs = liste_librairies()) { |
|
| 286 | + return ''; |
|
| 287 | + } |
|
| 288 | + ksort($libs); |
|
| 289 | + $res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees')); |
|
| 290 | + $res .= '<dl>'; |
|
| 291 | + foreach ($libs as $lib => $rep) { |
|
| 292 | + $res .= "<dt>$lib</dt><dd>" . joli_repertoire($rep) . "</dd>\n"; |
|
| 293 | + } |
|
| 294 | + $res .= '</dl>'; |
|
| 295 | + $res .= fin_cadre_enfonce(); |
|
| 296 | + |
|
| 297 | + return $res; |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | |
@@ -305,22 +305,22 @@ discard block |
||
| 305 | 305 | * Tableau (nom de la lib => repertoire , ...) |
| 306 | 306 | */ |
| 307 | 307 | function liste_librairies() { |
| 308 | - $libs = []; |
|
| 309 | - foreach (array_reverse(creer_chemin()) as $d) { |
|
| 310 | - if ( |
|
| 311 | - is_dir($dir = $d . 'lib/') |
|
| 312 | - and $t = opendir($dir) |
|
| 313 | - ) { |
|
| 314 | - while (($f = readdir($t)) !== false) { |
|
| 315 | - if ( |
|
| 316 | - $f[0] != '.' |
|
| 317 | - and is_dir("$dir/$f") |
|
| 318 | - ) { |
|
| 319 | - $libs[$f] = $dir; |
|
| 320 | - } |
|
| 321 | - } |
|
| 322 | - } |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - return $libs; |
|
| 308 | + $libs = []; |
|
| 309 | + foreach (array_reverse(creer_chemin()) as $d) { |
|
| 310 | + if ( |
|
| 311 | + is_dir($dir = $d . 'lib/') |
|
| 312 | + and $t = opendir($dir) |
|
| 313 | + ) { |
|
| 314 | + while (($f = readdir($t)) !== false) { |
|
| 315 | + if ( |
|
| 316 | + $f[0] != '.' |
|
| 317 | + and is_dir("$dir/$f") |
|
| 318 | + ) { |
|
| 319 | + $libs[$f] = $dir; |
|
| 320 | + } |
|
| 321 | + } |
|
| 322 | + } |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + return $libs; |
|
| 326 | 326 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | |
| 22 | 22 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 23 | - return; |
|
| 23 | + return; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
@@ -28,29 +28,29 @@ discard block |
||
| 28 | 28 | * Demander à mettre à jour la base de données |
| 29 | 29 | */ |
| 30 | 30 | function exec_demande_mise_a_jour_dist() { |
| 31 | - // on fait la verif du path avant tout, |
|
| 32 | - // et l'installation des qu'on est dans la colonne principale |
|
| 33 | - // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
|
| 34 | - // pour etre sur que les bons fichiers seront charges lors de l'install |
|
| 35 | - include_spip('inc/plugin'); |
|
| 36 | - if (actualise_plugins_actifs()) { |
|
| 37 | - include_spip('inc/headers'); |
|
| 38 | - redirige_par_entete(self()); |
|
| 39 | - } |
|
| 31 | + // on fait la verif du path avant tout, |
|
| 32 | + // et l'installation des qu'on est dans la colonne principale |
|
| 33 | + // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
|
| 34 | + // pour etre sur que les bons fichiers seront charges lors de l'install |
|
| 35 | + include_spip('inc/plugin'); |
|
| 36 | + if (actualise_plugins_actifs()) { |
|
| 37 | + include_spip('inc/headers'); |
|
| 38 | + redirige_par_entete(self()); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - include_spip('inc/presentation'); |
|
| 42 | - include_spip('inc/filtres_boites'); |
|
| 43 | - $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 44 | - echo $commencer_page('', '', '', '', true, false, false); |
|
| 41 | + include_spip('inc/presentation'); |
|
| 42 | + include_spip('inc/filtres_boites'); |
|
| 43 | + $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 44 | + echo $commencer_page('', '', '', '', true, false, false); |
|
| 45 | 45 | |
| 46 | - echo debut_grand_cadre(); |
|
| 47 | - echo boite_ouvrir(_T('info_message_technique'), 'notice'); |
|
| 48 | - echo '<p>' . _T('info_procedure_maj_version') . '</p>', |
|
| 49 | - '<p>' . _T('info_administrateur_site_01') . '</p>'; |
|
| 50 | - echo bouton_action(_T('bouton_mettre_a_jour_base'), generer_url_ecrire('upgrade', 'reinstall=non')); |
|
| 51 | - echo boite_fermer(); |
|
| 52 | - // masquer les erreurs sql sur cette page car proviennent de la base pas a jour ! |
|
| 53 | - echo '<style type="text/css">#debug-nav {display: none;}</style>'; |
|
| 54 | - echo fin_grand_cadre(); |
|
| 55 | - echo fin_page(); |
|
| 46 | + echo debut_grand_cadre(); |
|
| 47 | + echo boite_ouvrir(_T('info_message_technique'), 'notice'); |
|
| 48 | + echo '<p>' . _T('info_procedure_maj_version') . '</p>', |
|
| 49 | + '<p>' . _T('info_administrateur_site_01') . '</p>'; |
|
| 50 | + echo bouton_action(_T('bouton_mettre_a_jour_base'), generer_url_ecrire('upgrade', 'reinstall=non')); |
|
| 51 | + echo boite_fermer(); |
|
| 52 | + // masquer les erreurs sql sur cette page car proviennent de la base pas a jour ! |
|
| 53 | + echo '<style type="text/css">#debug-nav {display: none;}</style>'; |
|
| 54 | + echo fin_grand_cadre(); |
|
| 55 | + echo fin_page(); |
|
| 56 | 56 | } |
@@ -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 | /** |
@@ -25,25 +25,25 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function exec_404_dist() { |
| 27 | 27 | |
| 28 | - $exec = _request('exec'); |
|
| 28 | + $exec = _request('exec'); |
|
| 29 | 29 | |
| 30 | - $titre = "exec_$exec"; |
|
| 31 | - $navigation = ''; |
|
| 32 | - $extra = ''; |
|
| 30 | + $titre = "exec_$exec"; |
|
| 31 | + $navigation = ''; |
|
| 32 | + $extra = ''; |
|
| 33 | 33 | |
| 34 | - include_spip('inc/presentation'); // alleger les inclusions avec un inc/presentation_mini |
|
| 35 | - $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 36 | - echo $commencer_page($titre); |
|
| 34 | + include_spip('inc/presentation'); // alleger les inclusions avec un inc/presentation_mini |
|
| 35 | + $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 36 | + echo $commencer_page($titre); |
|
| 37 | 37 | |
| 38 | - echo debut_gauche(); |
|
| 39 | - echo pipeline('affiche_gauche', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']); |
|
| 38 | + echo debut_gauche(); |
|
| 39 | + echo pipeline('affiche_gauche', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']); |
|
| 40 | 40 | |
| 41 | - echo creer_colonne_droite(); |
|
| 42 | - echo pipeline('affiche_droite', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']); |
|
| 41 | + echo creer_colonne_droite(); |
|
| 42 | + echo pipeline('affiche_droite', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']); |
|
| 43 | 43 | |
| 44 | - echo debut_droite(); |
|
| 45 | - echo "<h1 class='grostitre'>" . _T('fichier_introuvable', ['fichier' => $exec]) . '</h1>'; |
|
| 46 | - echo pipeline('affiche_milieu', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']); |
|
| 44 | + echo debut_droite(); |
|
| 45 | + echo "<h1 class='grostitre'>" . _T('fichier_introuvable', ['fichier' => $exec]) . '</h1>'; |
|
| 46 | + echo pipeline('affiche_milieu', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']); |
|
| 47 | 47 | |
| 48 | - echo fin_gauche(), fin_page(); |
|
| 48 | + echo fin_gauche(), fin_page(); |
|
| 49 | 49 | } |
@@ -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 | /** |
@@ -27,40 +27,40 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | function exec_403_dist($message = '') { |
| 29 | 29 | |
| 30 | - $exec = _request('exec'); |
|
| 30 | + $exec = _request('exec'); |
|
| 31 | 31 | |
| 32 | - $titre = "exec_$exec"; |
|
| 33 | - $navigation = ''; |
|
| 34 | - $extra = ''; |
|
| 32 | + $titre = "exec_$exec"; |
|
| 33 | + $navigation = ''; |
|
| 34 | + $extra = ''; |
|
| 35 | 35 | |
| 36 | - if (!$message) { |
|
| 37 | - $message = _T('avis_acces_interdit_prive', ['exec' => _request('exec')]); |
|
| 38 | - } |
|
| 36 | + if (!$message) { |
|
| 37 | + $message = _T('avis_acces_interdit_prive', ['exec' => _request('exec')]); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - $contenu = "<h1 class='grostitre'>" . _T('info_acces_interdit') . '</h1>' . $message; |
|
| 40 | + $contenu = "<h1 class='grostitre'>" . _T('info_acces_interdit') . '</h1>' . $message; |
|
| 41 | 41 | |
| 42 | - if (_request('var_zajax')) { |
|
| 43 | - include_spip('inc/actions'); |
|
| 44 | - ajax_retour($contenu); |
|
| 45 | - } else { |
|
| 46 | - include_spip('inc/presentation'); // alleger les inclusions avec un inc/presentation_mini |
|
| 42 | + if (_request('var_zajax')) { |
|
| 43 | + include_spip('inc/actions'); |
|
| 44 | + ajax_retour($contenu); |
|
| 45 | + } else { |
|
| 46 | + include_spip('inc/presentation'); // alleger les inclusions avec un inc/presentation_mini |
|
| 47 | 47 | |
| 48 | - $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 49 | - echo $commencer_page($titre); |
|
| 48 | + $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 49 | + echo $commencer_page($titre); |
|
| 50 | 50 | |
| 51 | - echo debut_gauche(); |
|
| 52 | - echo recuperer_fond('prive/squelettes/navigation/dist', []); |
|
| 53 | - echo pipeline('affiche_gauche', ['args' => ['exec' => '403', 'exec_erreur' => $exec], 'data' => '']); |
|
| 51 | + echo debut_gauche(); |
|
| 52 | + echo recuperer_fond('prive/squelettes/navigation/dist', []); |
|
| 53 | + echo pipeline('affiche_gauche', ['args' => ['exec' => '403', 'exec_erreur' => $exec], 'data' => '']); |
|
| 54 | 54 | |
| 55 | - echo creer_colonne_droite(); |
|
| 56 | - echo pipeline('affiche_droite', ['args' => ['exec' => '403', 'exec_erreur' => $exec], 'data' => '']); |
|
| 55 | + echo creer_colonne_droite(); |
|
| 56 | + echo pipeline('affiche_droite', ['args' => ['exec' => '403', 'exec_erreur' => $exec], 'data' => '']); |
|
| 57 | 57 | |
| 58 | - echo debut_droite(); |
|
| 59 | - echo pipeline( |
|
| 60 | - 'affiche_milieu', |
|
| 61 | - ['args' => ['exec' => '403', 'exec_erreur' => $exec], 'data' => $contenu] |
|
| 62 | - ); |
|
| 58 | + echo debut_droite(); |
|
| 59 | + echo pipeline( |
|
| 60 | + 'affiche_milieu', |
|
| 61 | + ['args' => ['exec' => '403', 'exec_erreur' => $exec], 'data' => $contenu] |
|
| 62 | + ); |
|
| 63 | 63 | |
| 64 | - echo fin_gauche(), fin_page(); |
|
| 65 | - } |
|
| 64 | + echo fin_gauche(), fin_page(); |
|
| 65 | + } |
|
| 66 | 66 | } |
@@ -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 | |
@@ -47,24 +47,24 @@ discard block |
||
| 47 | 47 | * - false si l'arbre xml ne peut être créé ou est vide |
| 48 | 48 | **/ |
| 49 | 49 | function spip_xml_load($fichier, $strict = true, $clean = true, $taille_max = 1_048_576, $datas = '', $profondeur = -1) { |
| 50 | - $contenu = ''; |
|
| 51 | - if (tester_url_absolue($fichier)) { |
|
| 52 | - include_spip('inc/distant'); |
|
| 53 | - $contenu = recuperer_url($fichier, ['taille_max' => $taille_max, 'datas' => $datas]); |
|
| 54 | - $contenu = $contenu['page'] ?? ''; |
|
| 55 | - } else { |
|
| 56 | - lire_fichier($fichier, $contenu); |
|
| 57 | - } |
|
| 58 | - $arbre = []; |
|
| 59 | - if ($contenu) { |
|
| 60 | - $arbre = spip_xml_parse($contenu, $strict, $clean, $profondeur); |
|
| 61 | - } |
|
| 50 | + $contenu = ''; |
|
| 51 | + if (tester_url_absolue($fichier)) { |
|
| 52 | + include_spip('inc/distant'); |
|
| 53 | + $contenu = recuperer_url($fichier, ['taille_max' => $taille_max, 'datas' => $datas]); |
|
| 54 | + $contenu = $contenu['page'] ?? ''; |
|
| 55 | + } else { |
|
| 56 | + lire_fichier($fichier, $contenu); |
|
| 57 | + } |
|
| 58 | + $arbre = []; |
|
| 59 | + if ($contenu) { |
|
| 60 | + $arbre = spip_xml_parse($contenu, $strict, $clean, $profondeur); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - return count($arbre) ? $arbre : false; |
|
| 63 | + return count($arbre) ? $arbre : false; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | if (!defined('_SPIP_XML_TAG_SPLIT')) { |
| 67 | - define('_SPIP_XML_TAG_SPLIT', '{<([^:>][^>]*?)>}sS'); |
|
| 67 | + define('_SPIP_XML_TAG_SPLIT', '{<([^:>][^>]*?)>}sS'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -83,153 +83,153 @@ discard block |
||
| 83 | 83 | * - false si l'arbre xml ne peut être créé ou est vide |
| 84 | 84 | **/ |
| 85 | 85 | function spip_xml_parse(&$texte, $strict = true, $clean = true, $profondeur = -1) { |
| 86 | - $out = []; |
|
| 87 | - // enlever les commentaires |
|
| 88 | - $charset = 'AUTO'; |
|
| 89 | - if ($clean === true) { |
|
| 90 | - if (preg_match(",<\?xml\s(.*?)encoding=['\"]?(.*?)['\"]?(\s(.*))?\?>,im", $texte, $regs)) { |
|
| 91 | - $charset = $regs[2]; |
|
| 92 | - } |
|
| 93 | - $texte = preg_replace(',<!--(.*?)-->,is', '', $texte); |
|
| 94 | - $texte = preg_replace(',<\?(.*?)\?>,is', '', $texte); |
|
| 95 | - include_spip('inc/charsets'); |
|
| 96 | - $clean = $charset; |
|
| 97 | - //$texte = importer_charset($texte,$charset); |
|
| 98 | - } |
|
| 99 | - if (is_string($clean)) { |
|
| 100 | - $charset = $clean; |
|
| 101 | - } |
|
| 102 | - $txt = $texte; |
|
| 86 | + $out = []; |
|
| 87 | + // enlever les commentaires |
|
| 88 | + $charset = 'AUTO'; |
|
| 89 | + if ($clean === true) { |
|
| 90 | + if (preg_match(",<\?xml\s(.*?)encoding=['\"]?(.*?)['\"]?(\s(.*))?\?>,im", $texte, $regs)) { |
|
| 91 | + $charset = $regs[2]; |
|
| 92 | + } |
|
| 93 | + $texte = preg_replace(',<!--(.*?)-->,is', '', $texte); |
|
| 94 | + $texte = preg_replace(',<\?(.*?)\?>,is', '', $texte); |
|
| 95 | + include_spip('inc/charsets'); |
|
| 96 | + $clean = $charset; |
|
| 97 | + //$texte = importer_charset($texte,$charset); |
|
| 98 | + } |
|
| 99 | + if (is_string($clean)) { |
|
| 100 | + $charset = $clean; |
|
| 101 | + } |
|
| 102 | + $txt = $texte; |
|
| 103 | 103 | |
| 104 | - // tant qu'il y a des tags |
|
| 105 | - $chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE); |
|
| 106 | - while ((is_countable($chars) ? count($chars) : 0) >= 2) { |
|
| 107 | - // tag ouvrant |
|
| 108 | - //$chars = preg_split("{<([^>]*?)>}s",$txt,2,PREG_SPLIT_DELIM_CAPTURE); |
|
| 104 | + // tant qu'il y a des tags |
|
| 105 | + $chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE); |
|
| 106 | + while ((is_countable($chars) ? count($chars) : 0) >= 2) { |
|
| 107 | + // tag ouvrant |
|
| 108 | + //$chars = preg_split("{<([^>]*?)>}s",$txt,2,PREG_SPLIT_DELIM_CAPTURE); |
|
| 109 | 109 | |
| 110 | - // $before doit etre vide ou des espaces uniquements! |
|
| 111 | - $before = trim($chars[0]); |
|
| 110 | + // $before doit etre vide ou des espaces uniquements! |
|
| 111 | + $before = trim($chars[0]); |
|
| 112 | 112 | |
| 113 | - if (strlen($before) > 0) { |
|
| 114 | - return importer_charset($texte, $charset); |
|
| 115 | - }//$texte; // before non vide, donc on est dans du texte |
|
| 113 | + if (strlen($before) > 0) { |
|
| 114 | + return importer_charset($texte, $charset); |
|
| 115 | + }//$texte; // before non vide, donc on est dans du texte |
|
| 116 | 116 | |
| 117 | - $tag = rtrim($chars[1]); |
|
| 118 | - $txt = $chars[2]; |
|
| 117 | + $tag = rtrim($chars[1]); |
|
| 118 | + $txt = $chars[2]; |
|
| 119 | 119 | |
| 120 | - if (strncmp($tag, '![CDATA[', 8) == 0) { |
|
| 121 | - return importer_charset($texte, $charset); |
|
| 122 | - }//$texte; |
|
| 123 | - if (substr($tag, -1) == '/') { // self closing tag |
|
| 124 | - $tag = rtrim(substr($tag, 0, strlen($tag) - 1)); |
|
| 125 | - $out[$tag][] = ''; |
|
| 126 | - } else { |
|
| 127 | - $closing_tag = preg_split(",\s|\t|\n|\r,", trim($tag)); |
|
| 128 | - $closing_tag = reset($closing_tag); |
|
| 129 | - // tag fermant |
|
| 130 | - $ncclos = strlen("</$closing_tag>"); |
|
| 131 | - $p = strpos($txt, (string) "</$closing_tag>"); |
|
| 132 | - if ($p !== false and (strpos($txt, '<') < $p)) { |
|
| 133 | - $nclose = 0; |
|
| 134 | - $nopen = 0; |
|
| 135 | - $d = 0; |
|
| 136 | - while ( |
|
| 137 | - $p !== false |
|
| 138 | - and ($morceau = substr($txt, $d, $p - $d)) |
|
| 139 | - and (($nopen += preg_match_all( |
|
| 140 | - '{<' . preg_quote($closing_tag) . '(\s*>|\s[^>]*[^/>]>)}is', |
|
| 141 | - $morceau, |
|
| 142 | - $matches, |
|
| 143 | - PREG_SET_ORDER |
|
| 144 | - )) > $nclose) |
|
| 145 | - ) { |
|
| 146 | - $nclose++; |
|
| 147 | - $d = $p + $ncclos; |
|
| 148 | - $p = strpos($txt, (string) "</$closing_tag>", $d); |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - if ($p === false) { |
|
| 152 | - if ($strict) { |
|
| 153 | - $out[$tag][] = "erreur : tag fermant $tag manquant::$txt"; |
|
| 120 | + if (strncmp($tag, '![CDATA[', 8) == 0) { |
|
| 121 | + return importer_charset($texte, $charset); |
|
| 122 | + }//$texte; |
|
| 123 | + if (substr($tag, -1) == '/') { // self closing tag |
|
| 124 | + $tag = rtrim(substr($tag, 0, strlen($tag) - 1)); |
|
| 125 | + $out[$tag][] = ''; |
|
| 126 | + } else { |
|
| 127 | + $closing_tag = preg_split(",\s|\t|\n|\r,", trim($tag)); |
|
| 128 | + $closing_tag = reset($closing_tag); |
|
| 129 | + // tag fermant |
|
| 130 | + $ncclos = strlen("</$closing_tag>"); |
|
| 131 | + $p = strpos($txt, (string) "</$closing_tag>"); |
|
| 132 | + if ($p !== false and (strpos($txt, '<') < $p)) { |
|
| 133 | + $nclose = 0; |
|
| 134 | + $nopen = 0; |
|
| 135 | + $d = 0; |
|
| 136 | + while ( |
|
| 137 | + $p !== false |
|
| 138 | + and ($morceau = substr($txt, $d, $p - $d)) |
|
| 139 | + and (($nopen += preg_match_all( |
|
| 140 | + '{<' . preg_quote($closing_tag) . '(\s*>|\s[^>]*[^/>]>)}is', |
|
| 141 | + $morceau, |
|
| 142 | + $matches, |
|
| 143 | + PREG_SET_ORDER |
|
| 144 | + )) > $nclose) |
|
| 145 | + ) { |
|
| 146 | + $nclose++; |
|
| 147 | + $d = $p + $ncclos; |
|
| 148 | + $p = strpos($txt, (string) "</$closing_tag>", $d); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + if ($p === false) { |
|
| 152 | + if ($strict) { |
|
| 153 | + $out[$tag][] = "erreur : tag fermant $tag manquant::$txt"; |
|
| 154 | 154 | |
| 155 | - return $out; |
|
| 156 | - } else { |
|
| 157 | - return importer_charset($texte, $charset); |
|
| 158 | - }//$texte // un tag qui constitue du texte a reporter dans $before |
|
| 159 | - } |
|
| 160 | - $content = substr($txt, 0, $p); |
|
| 161 | - $txt = substr($txt, $p + $ncclos); |
|
| 162 | - if ($profondeur == 0 or strpos($content, '<') === false) { // eviter une recursion si pas utile |
|
| 163 | - $out[$tag][] = importer_charset($content, $charset); |
|
| 164 | - }//$content; |
|
| 165 | - else { |
|
| 166 | - $out[$tag][] = spip_xml_parse($content, $strict, $clean, $profondeur - 1); |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - $chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE); |
|
| 170 | - } |
|
| 171 | - if (count($out) && (strlen(trim($txt)) == 0)) { |
|
| 172 | - return $out; |
|
| 173 | - } else { |
|
| 174 | - return importer_charset($texte, $charset); |
|
| 175 | - }//$texte; |
|
| 155 | + return $out; |
|
| 156 | + } else { |
|
| 157 | + return importer_charset($texte, $charset); |
|
| 158 | + }//$texte // un tag qui constitue du texte a reporter dans $before |
|
| 159 | + } |
|
| 160 | + $content = substr($txt, 0, $p); |
|
| 161 | + $txt = substr($txt, $p + $ncclos); |
|
| 162 | + if ($profondeur == 0 or strpos($content, '<') === false) { // eviter une recursion si pas utile |
|
| 163 | + $out[$tag][] = importer_charset($content, $charset); |
|
| 164 | + }//$content; |
|
| 165 | + else { |
|
| 166 | + $out[$tag][] = spip_xml_parse($content, $strict, $clean, $profondeur - 1); |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + $chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE); |
|
| 170 | + } |
|
| 171 | + if (count($out) && (strlen(trim($txt)) == 0)) { |
|
| 172 | + return $out; |
|
| 173 | + } else { |
|
| 174 | + return importer_charset($texte, $charset); |
|
| 175 | + }//$texte; |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | // https://code.spip.net/@spip_xml_aplatit |
| 179 | 179 | function spip_xml_aplatit($arbre, $separateur = ' ') { |
| 180 | - $s = ''; |
|
| 181 | - if (is_array($arbre)) { |
|
| 182 | - foreach ($arbre as $tag => $feuille) { |
|
| 183 | - if (is_array($feuille)) { |
|
| 184 | - if ($tag !== intval($tag)) { |
|
| 185 | - $f = spip_xml_aplatit($feuille, $separateur); |
|
| 186 | - if (strlen($f)) { |
|
| 187 | - $tagf = explode(' ', $tag); |
|
| 188 | - $tagf = $tagf[0]; |
|
| 189 | - $s .= "<$tag>$f</$tagf>"; |
|
| 190 | - } else { |
|
| 191 | - $s .= "<$tag />"; |
|
| 192 | - } |
|
| 193 | - } else { |
|
| 194 | - $s .= spip_xml_aplatit($feuille); |
|
| 195 | - } |
|
| 196 | - $s .= $separateur; |
|
| 197 | - } else { |
|
| 198 | - $s .= "$feuille$separateur"; |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - } |
|
| 180 | + $s = ''; |
|
| 181 | + if (is_array($arbre)) { |
|
| 182 | + foreach ($arbre as $tag => $feuille) { |
|
| 183 | + if (is_array($feuille)) { |
|
| 184 | + if ($tag !== intval($tag)) { |
|
| 185 | + $f = spip_xml_aplatit($feuille, $separateur); |
|
| 186 | + if (strlen($f)) { |
|
| 187 | + $tagf = explode(' ', $tag); |
|
| 188 | + $tagf = $tagf[0]; |
|
| 189 | + $s .= "<$tag>$f</$tagf>"; |
|
| 190 | + } else { |
|
| 191 | + $s .= "<$tag />"; |
|
| 192 | + } |
|
| 193 | + } else { |
|
| 194 | + $s .= spip_xml_aplatit($feuille); |
|
| 195 | + } |
|
| 196 | + $s .= $separateur; |
|
| 197 | + } else { |
|
| 198 | + $s .= "$feuille$separateur"; |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - return strlen($separateur) ? substr($s, 0, -strlen($separateur)) : $s; |
|
| 203 | + return strlen($separateur) ? substr($s, 0, -strlen($separateur)) : $s; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // https://code.spip.net/@spip_xml_tagname |
| 207 | 207 | function spip_xml_tagname($tag) { |
| 208 | - if (preg_match(',^([a-z][\w:]*),i', $tag, $reg)) { |
|
| 209 | - return $reg[1]; |
|
| 210 | - } |
|
| 208 | + if (preg_match(',^([a-z][\w:]*),i', $tag, $reg)) { |
|
| 209 | + return $reg[1]; |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | - return ''; |
|
| 212 | + return ''; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | // https://code.spip.net/@spip_xml_decompose_tag |
| 216 | 216 | function spip_xml_decompose_tag($tag) { |
| 217 | - $tagname = spip_xml_tagname($tag); |
|
| 218 | - $liste = []; |
|
| 219 | - $tag = ltrim(strpbrk($tag, " \n\t")); |
|
| 220 | - $p = strpos($tag, '='); |
|
| 221 | - while ($p !== false) { |
|
| 222 | - $attr = trim(substr($tag, 0, $p)); |
|
| 223 | - $tag = ltrim(substr($tag, $p + 1)); |
|
| 224 | - $quote = $tag[0]; |
|
| 225 | - $p = strpos($tag, $quote, 1); |
|
| 226 | - $cont = substr($tag, 1, $p - 1); |
|
| 227 | - $liste[$attr] = $cont; |
|
| 228 | - $tag = substr($tag, $p + 1); |
|
| 229 | - $p = strpos($tag, '='); |
|
| 230 | - } |
|
| 217 | + $tagname = spip_xml_tagname($tag); |
|
| 218 | + $liste = []; |
|
| 219 | + $tag = ltrim(strpbrk($tag, " \n\t")); |
|
| 220 | + $p = strpos($tag, '='); |
|
| 221 | + while ($p !== false) { |
|
| 222 | + $attr = trim(substr($tag, 0, $p)); |
|
| 223 | + $tag = ltrim(substr($tag, $p + 1)); |
|
| 224 | + $quote = $tag[0]; |
|
| 225 | + $p = strpos($tag, $quote, 1); |
|
| 226 | + $cont = substr($tag, 1, $p - 1); |
|
| 227 | + $liste[$attr] = $cont; |
|
| 228 | + $tag = substr($tag, $p + 1); |
|
| 229 | + $p = strpos($tag, '='); |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | - return [$tagname, $liste]; |
|
| 232 | + return [$tagname, $liste]; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | /** |
@@ -252,21 +252,21 @@ discard block |
||
| 252 | 252 | * false si aucun élément ne valide l'expression régulière, true sinon. |
| 253 | 253 | **/ |
| 254 | 254 | function spip_xml_match_nodes($regexp, &$arbre, &$matches, $init = true) { |
| 255 | - if ($init) { |
|
| 256 | - $matches = []; |
|
| 257 | - } |
|
| 258 | - if (is_array($arbre) && count($arbre)) { |
|
| 259 | - foreach (array_keys($arbre) as $tag) { |
|
| 260 | - if (preg_match($regexp, $tag)) { |
|
| 261 | - $matches[$tag] = &$arbre[$tag]; |
|
| 262 | - } |
|
| 263 | - if (is_array($arbre[$tag])) { |
|
| 264 | - foreach (array_keys($arbre[$tag]) as $occurences) { |
|
| 265 | - spip_xml_match_nodes($regexp, $arbre[$tag][$occurences], $matches, false); |
|
| 266 | - } |
|
| 267 | - } |
|
| 268 | - } |
|
| 269 | - } |
|
| 255 | + if ($init) { |
|
| 256 | + $matches = []; |
|
| 257 | + } |
|
| 258 | + if (is_array($arbre) && count($arbre)) { |
|
| 259 | + foreach (array_keys($arbre) as $tag) { |
|
| 260 | + if (preg_match($regexp, $tag)) { |
|
| 261 | + $matches[$tag] = &$arbre[$tag]; |
|
| 262 | + } |
|
| 263 | + if (is_array($arbre[$tag])) { |
|
| 264 | + foreach (array_keys($arbre[$tag]) as $occurences) { |
|
| 265 | + spip_xml_match_nodes($regexp, $arbre[$tag][$occurences], $matches, false); |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - return (is_countable($matches) ? count($matches) : 0); |
|
| 271 | + return (is_countable($matches) ? count($matches) : 0); |
|
| 272 | 272 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Minipres |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/headers'); |
@@ -46,61 +46,61 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | function install_debut_html($titre = 'AUTO', $onLoad = '', $all_inline = false) { |
| 48 | 48 | |
| 49 | - utiliser_langue_visiteur(); |
|
| 50 | - |
|
| 51 | - http_no_cache(); |
|
| 52 | - |
|
| 53 | - if ($titre == 'AUTO') { |
|
| 54 | - $titre = _T('info_installation_systeme_publication'); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - # le charset est en utf-8, pour recuperer le nom comme il faut |
|
| 58 | - # lors de l'installation |
|
| 59 | - if (!headers_sent()) { |
|
| 60 | - header('Content-Type: text/html; charset=utf-8'); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - $css = ''; |
|
| 64 | - $files = ['reset.css', 'clear.css', 'minipres.css']; |
|
| 65 | - if ($all_inline) { |
|
| 66 | - // inliner les CSS (optimisation de la page minipres qui passe en un seul hit a la demande) |
|
| 67 | - foreach ($files as $name) { |
|
| 68 | - $file = direction_css(find_in_theme($name)); |
|
| 69 | - if (function_exists('compacte')) { |
|
| 70 | - $file = compacte($file); |
|
| 71 | - } else { |
|
| 72 | - $file = url_absolue_css($file); // precaution |
|
| 73 | - } |
|
| 74 | - lire_fichier($file, $c); |
|
| 75 | - $css .= $c; |
|
| 76 | - } |
|
| 77 | - $css = "<style type='text/css'>" . $css . '</style>'; |
|
| 78 | - } else { |
|
| 79 | - foreach ($files as $name) { |
|
| 80 | - $file = direction_css(find_in_theme($name)); |
|
| 81 | - $css .= "<link rel='stylesheet' href='$file' type='text/css' />\n"; |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - // au cas ou minipres() est appele avant spip_initialisation_suite() |
|
| 86 | - if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 87 | - define('_DOCTYPE_ECRIRE', ''); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - return _DOCTYPE_ECRIRE . |
|
| 91 | - html_lang_attributes() . |
|
| 92 | - "<head>\n" . |
|
| 93 | - '<title>' . |
|
| 94 | - textebrut($titre) . |
|
| 95 | - "</title>\n" . |
|
| 96 | - "<meta name='viewport' content='width=device-width' />\n" . |
|
| 97 | - $css . |
|
| 98 | - '</head> |
|
| 49 | + utiliser_langue_visiteur(); |
|
| 50 | + |
|
| 51 | + http_no_cache(); |
|
| 52 | + |
|
| 53 | + if ($titre == 'AUTO') { |
|
| 54 | + $titre = _T('info_installation_systeme_publication'); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + # le charset est en utf-8, pour recuperer le nom comme il faut |
|
| 58 | + # lors de l'installation |
|
| 59 | + if (!headers_sent()) { |
|
| 60 | + header('Content-Type: text/html; charset=utf-8'); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + $css = ''; |
|
| 64 | + $files = ['reset.css', 'clear.css', 'minipres.css']; |
|
| 65 | + if ($all_inline) { |
|
| 66 | + // inliner les CSS (optimisation de la page minipres qui passe en un seul hit a la demande) |
|
| 67 | + foreach ($files as $name) { |
|
| 68 | + $file = direction_css(find_in_theme($name)); |
|
| 69 | + if (function_exists('compacte')) { |
|
| 70 | + $file = compacte($file); |
|
| 71 | + } else { |
|
| 72 | + $file = url_absolue_css($file); // precaution |
|
| 73 | + } |
|
| 74 | + lire_fichier($file, $c); |
|
| 75 | + $css .= $c; |
|
| 76 | + } |
|
| 77 | + $css = "<style type='text/css'>" . $css . '</style>'; |
|
| 78 | + } else { |
|
| 79 | + foreach ($files as $name) { |
|
| 80 | + $file = direction_css(find_in_theme($name)); |
|
| 81 | + $css .= "<link rel='stylesheet' href='$file' type='text/css' />\n"; |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + // au cas ou minipres() est appele avant spip_initialisation_suite() |
|
| 86 | + if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 87 | + define('_DOCTYPE_ECRIRE', ''); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + return _DOCTYPE_ECRIRE . |
|
| 91 | + html_lang_attributes() . |
|
| 92 | + "<head>\n" . |
|
| 93 | + '<title>' . |
|
| 94 | + textebrut($titre) . |
|
| 95 | + "</title>\n" . |
|
| 96 | + "<meta name='viewport' content='width=device-width' />\n" . |
|
| 97 | + $css . |
|
| 98 | + '</head> |
|
| 99 | 99 | <body' . $onLoad . " class='minipres'> |
| 100 | 100 | <div id='minipres'> |
| 101 | 101 | <h1>" . |
| 102 | - $titre . |
|
| 103 | - "</h1> |
|
| 102 | + $titre . |
|
| 103 | + "</h1> |
|
| 104 | 104 | <div>\n"; |
| 105 | 105 | } |
| 106 | 106 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @return string Code HTML |
| 111 | 111 | */ |
| 112 | 112 | function install_fin_html() { |
| 113 | - return "\n\t</div>\n\t</div>\n</body>\n</html>"; |
|
| 113 | + return "\n\t</div>\n\t</div>\n</body>\n</html>"; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | |
@@ -148,77 +148,77 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | function minipres($titre = '', $corps = '', $options = []) { |
| 150 | 150 | |
| 151 | - // compat signature old |
|
| 152 | - // minipres($titre='', $corps="", $onload='', $all_inline = false) |
|
| 153 | - $args = func_get_args(); |
|
| 154 | - if (isset($args[2]) and is_string($args[2])) { |
|
| 155 | - $options = ['onload' => $args[2]]; |
|
| 156 | - } |
|
| 157 | - if (isset($args[3])) { |
|
| 158 | - $options['all_inline'] = $args[3]; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - $options = array_merge([ |
|
| 162 | - 'onload' => '', |
|
| 163 | - 'all_inline' => false, |
|
| 164 | - ], $options); |
|
| 165 | - |
|
| 166 | - if (!defined('_AJAX')) { |
|
| 167 | - define('_AJAX', false); |
|
| 168 | - } // par securite |
|
| 169 | - if (!$titre) { |
|
| 170 | - if (!isset($options['status'])) { |
|
| 171 | - $options['status'] = 403; |
|
| 172 | - } |
|
| 173 | - if ( |
|
| 174 | - !$titre = _request('action') |
|
| 175 | - and !$titre = _request('exec') |
|
| 176 | - and !$titre = _request('page') |
|
| 177 | - ) { |
|
| 178 | - $titre = '?'; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - $titre = spip_htmlspecialchars($titre); |
|
| 182 | - |
|
| 183 | - $titre = ($titre == 'install') |
|
| 184 | - ? _T('avis_espace_interdit') |
|
| 185 | - : $titre . ' : ' . _T('info_acces_interdit'); |
|
| 186 | - |
|
| 187 | - $statut = $GLOBALS['visiteur_session']['statut'] ?? ''; |
|
| 188 | - $nom = $GLOBALS['visiteur_session']['nom'] ?? ''; |
|
| 189 | - |
|
| 190 | - if ($statut != '0minirezo') { |
|
| 191 | - $titre = _T('info_acces_interdit'); |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - if ($statut and test_espace_prive()) { |
|
| 195 | - $corps = bouton_action(_T('public:accueil_site'), generer_url_ecrire('accueil')); |
|
| 196 | - } |
|
| 197 | - elseif (!empty($_COOKIE['spip_admin'])) { |
|
| 198 | - $corps = bouton_action(_T('public:lien_connecter'), generer_url_public('login')); |
|
| 199 | - } |
|
| 200 | - else { |
|
| 201 | - $corps = bouton_action(_T('public:accueil_site'), $GLOBALS['meta']['adresse_site']); |
|
| 202 | - } |
|
| 203 | - $corps = "<div class='boutons'>$corps</div>"; |
|
| 204 | - spip_log($nom . " $titre " . $_SERVER['REQUEST_URI']); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - if (!_AJAX) { |
|
| 208 | - if (isset($options['status'])) { |
|
| 209 | - http_response_code($options['status']); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - return install_debut_html($titre, $options['onload'], $options['all_inline']) |
|
| 213 | - . $corps |
|
| 214 | - . install_fin_html(); |
|
| 215 | - } else { |
|
| 216 | - include_spip('inc/headers'); |
|
| 217 | - include_spip('inc/actions'); |
|
| 218 | - $url = self('&', true); |
|
| 219 | - foreach ($_POST as $v => $c) { |
|
| 220 | - $url = parametre_url($url, $v, $c, '&'); |
|
| 221 | - } |
|
| 222 | - ajax_retour('<div>' . $titre . redirige_formulaire($url) . '</div>', false); |
|
| 223 | - } |
|
| 151 | + // compat signature old |
|
| 152 | + // minipres($titre='', $corps="", $onload='', $all_inline = false) |
|
| 153 | + $args = func_get_args(); |
|
| 154 | + if (isset($args[2]) and is_string($args[2])) { |
|
| 155 | + $options = ['onload' => $args[2]]; |
|
| 156 | + } |
|
| 157 | + if (isset($args[3])) { |
|
| 158 | + $options['all_inline'] = $args[3]; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + $options = array_merge([ |
|
| 162 | + 'onload' => '', |
|
| 163 | + 'all_inline' => false, |
|
| 164 | + ], $options); |
|
| 165 | + |
|
| 166 | + if (!defined('_AJAX')) { |
|
| 167 | + define('_AJAX', false); |
|
| 168 | + } // par securite |
|
| 169 | + if (!$titre) { |
|
| 170 | + if (!isset($options['status'])) { |
|
| 171 | + $options['status'] = 403; |
|
| 172 | + } |
|
| 173 | + if ( |
|
| 174 | + !$titre = _request('action') |
|
| 175 | + and !$titre = _request('exec') |
|
| 176 | + and !$titre = _request('page') |
|
| 177 | + ) { |
|
| 178 | + $titre = '?'; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + $titre = spip_htmlspecialchars($titre); |
|
| 182 | + |
|
| 183 | + $titre = ($titre == 'install') |
|
| 184 | + ? _T('avis_espace_interdit') |
|
| 185 | + : $titre . ' : ' . _T('info_acces_interdit'); |
|
| 186 | + |
|
| 187 | + $statut = $GLOBALS['visiteur_session']['statut'] ?? ''; |
|
| 188 | + $nom = $GLOBALS['visiteur_session']['nom'] ?? ''; |
|
| 189 | + |
|
| 190 | + if ($statut != '0minirezo') { |
|
| 191 | + $titre = _T('info_acces_interdit'); |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + if ($statut and test_espace_prive()) { |
|
| 195 | + $corps = bouton_action(_T('public:accueil_site'), generer_url_ecrire('accueil')); |
|
| 196 | + } |
|
| 197 | + elseif (!empty($_COOKIE['spip_admin'])) { |
|
| 198 | + $corps = bouton_action(_T('public:lien_connecter'), generer_url_public('login')); |
|
| 199 | + } |
|
| 200 | + else { |
|
| 201 | + $corps = bouton_action(_T('public:accueil_site'), $GLOBALS['meta']['adresse_site']); |
|
| 202 | + } |
|
| 203 | + $corps = "<div class='boutons'>$corps</div>"; |
|
| 204 | + spip_log($nom . " $titre " . $_SERVER['REQUEST_URI']); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + if (!_AJAX) { |
|
| 208 | + if (isset($options['status'])) { |
|
| 209 | + http_response_code($options['status']); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + return install_debut_html($titre, $options['onload'], $options['all_inline']) |
|
| 213 | + . $corps |
|
| 214 | + . install_fin_html(); |
|
| 215 | + } else { |
|
| 216 | + include_spip('inc/headers'); |
|
| 217 | + include_spip('inc/actions'); |
|
| 218 | + $url = self('&', true); |
|
| 219 | + foreach ($_POST as $v => $c) { |
|
| 220 | + $url = parametre_url($url, $v, $c, '&'); |
|
| 221 | + } |
|
| 222 | + ajax_retour('<div>' . $titre . redirige_formulaire($url) . '</div>', false); |
|
| 223 | + } |
|
| 224 | 224 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | **/ |
| 8 | 8 | |
| 9 | 9 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 10 | - return; |
|
| 10 | + return; |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | include_spip('inc/acces'); |
@@ -101,93 +101,93 @@ discard block |
||
| 101 | 101 | * @return int|bool Timestamp du verrou, false si erreur |
| 102 | 102 | */ |
| 103 | 103 | function spip_nfslock($fichier, $max_age = 0) { |
| 104 | - $tries = 0; |
|
| 104 | + $tries = 0; |
|
| 105 | 105 | |
| 106 | - if (!$max_age) { |
|
| 107 | - $max_age = _DEFAULT_LOCKTIME; |
|
| 108 | - } |
|
| 109 | - $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 106 | + if (!$max_age) { |
|
| 107 | + $max_age = _DEFAULT_LOCKTIME; |
|
| 108 | + } |
|
| 109 | + $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 110 | 110 | |
| 111 | 111 | |
| 112 | - /* |
|
| 112 | + /* |
|
| 113 | 113 | * 1. create a tmp file with a psuedo random file name. we also make |
| 114 | 114 | * tpath which is a buffer to store the full pathname of the tmp file. |
| 115 | 115 | */ |
| 116 | 116 | |
| 117 | - $id = creer_uniqid(); |
|
| 118 | - $tpath = _DIR_TMP . "slock.$id"; |
|
| 119 | - $tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ... |
|
| 120 | - if (!$tmpfd) { /* open failed */ |
|
| 121 | - @fclose($tmpfd); |
|
| 122 | - spip_unlink($tpath); |
|
| 117 | + $id = creer_uniqid(); |
|
| 118 | + $tpath = _DIR_TMP . "slock.$id"; |
|
| 119 | + $tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ... |
|
| 120 | + if (!$tmpfd) { /* open failed */ |
|
| 121 | + @fclose($tmpfd); |
|
| 122 | + spip_unlink($tpath); |
|
| 123 | 123 | |
| 124 | - return false; //NFSL_SYSF |
|
| 125 | - } |
|
| 124 | + return false; //NFSL_SYSF |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - /* |
|
| 127 | + /* |
|
| 128 | 128 | * 2. make fullpath, a buffer for the full pathname of the lock file. |
| 129 | 129 | * then start looping trying to lock it |
| 130 | 130 | */ |
| 131 | 131 | |
| 132 | - while ($tries < 10) { |
|
| 133 | - /* |
|
| 132 | + while ($tries < 10) { |
|
| 133 | + /* |
|
| 134 | 134 | * 3. link tmp file to lock file. if it goes, we win and we clean |
| 135 | 135 | * up and return the st_ctime of the lock file. |
| 136 | 136 | */ |
| 137 | 137 | |
| 138 | - if (link($tpath, $lock_file) == 1) { |
|
| 139 | - spip_unlink($tpath); /* got it! */ |
|
| 140 | - @fclose($tmpfd); |
|
| 141 | - if (($our_tmp = lstat($lock_file)) == false) { /* stat failed... shouldn't happen */ |
|
| 142 | - spip_unlink($lock_file); |
|
| 138 | + if (link($tpath, $lock_file) == 1) { |
|
| 139 | + spip_unlink($tpath); /* got it! */ |
|
| 140 | + @fclose($tmpfd); |
|
| 141 | + if (($our_tmp = lstat($lock_file)) == false) { /* stat failed... shouldn't happen */ |
|
| 142 | + spip_unlink($lock_file); |
|
| 143 | 143 | |
| 144 | - return false; // (NFSL_SYSF); |
|
| 145 | - } |
|
| 144 | + return false; // (NFSL_SYSF); |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - return ($our_tmp['ctime']); |
|
| 148 | - } |
|
| 147 | + return ($our_tmp['ctime']); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /* |
|
| 150 | + /* |
|
| 151 | 151 | * 4. the lock failed. check for a stale lock file, being mindful |
| 152 | 152 | * of NFS and the fact the time is set from the NFS server. we |
| 153 | 153 | * do a write on the tmp file to update its time to the server's |
| 154 | 154 | * idea of "now." |
| 155 | 155 | */ |
| 156 | 156 | |
| 157 | - $old_stat = lstat($lock_file); |
|
| 158 | - if (@fputs($tmpfd, 'zz', 2) != 2 || !$our_tmp = fstat($tmpfd)) { |
|
| 159 | - break; |
|
| 160 | - } /* something bogus is going on */ |
|
| 157 | + $old_stat = lstat($lock_file); |
|
| 158 | + if (@fputs($tmpfd, 'zz', 2) != 2 || !$our_tmp = fstat($tmpfd)) { |
|
| 159 | + break; |
|
| 160 | + } /* something bogus is going on */ |
|
| 161 | 161 | |
| 162 | 162 | |
| 163 | - if ($old_stat != false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) { |
|
| 164 | - spip_unlink($lock_file); /* break the stale lock */ |
|
| 165 | - $tries++; |
|
| 166 | - /* It is CRITICAL that we sleep after breaking |
|
| 163 | + if ($old_stat != false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) { |
|
| 164 | + spip_unlink($lock_file); /* break the stale lock */ |
|
| 165 | + $tries++; |
|
| 166 | + /* It is CRITICAL that we sleep after breaking |
|
| 167 | 167 | * the lock. Otherwise, we could race with |
| 168 | 168 | * another process and unlink it's newly- |
| 169 | 169 | * created file. |
| 170 | 170 | */ |
| 171 | - sleep(1 + random_int(0, 4)); |
|
| 172 | - continue; |
|
| 173 | - } |
|
| 171 | + sleep(1 + random_int(0, 4)); |
|
| 172 | + continue; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - /* |
|
| 175 | + /* |
|
| 176 | 176 | * 5. try again |
| 177 | 177 | */ |
| 178 | 178 | |
| 179 | - $tries++; |
|
| 180 | - sleep(1 + random_int(0, 4)); |
|
| 181 | - } |
|
| 179 | + $tries++; |
|
| 180 | + sleep(1 + random_int(0, 4)); |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - /* |
|
| 183 | + /* |
|
| 184 | 184 | * 6. give up, failure. |
| 185 | 185 | */ |
| 186 | 186 | |
| 187 | - spip_unlink($tpath); |
|
| 188 | - @fclose($tmpfd); |
|
| 187 | + spip_unlink($tpath); |
|
| 188 | + @fclose($tmpfd); |
|
| 189 | 189 | |
| 190 | - return false; //(NFSL_LOCKED); |
|
| 190 | + return false; //(NFSL_LOCKED); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
@@ -231,75 +231,75 @@ discard block |
||
| 231 | 231 | * return bool true si déverrouillé, false sinon |
| 232 | 232 | */ |
| 233 | 233 | function spip_nfsunlock($fichier, $birth, $max_age = 0, $test = false) { |
| 234 | - $id = creer_uniqid(); |
|
| 235 | - if (!$max_age) { |
|
| 236 | - $max_age = _DEFAULT_LOCKTIME; |
|
| 237 | - } |
|
| 234 | + $id = creer_uniqid(); |
|
| 235 | + if (!$max_age) { |
|
| 236 | + $max_age = _DEFAULT_LOCKTIME; |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | - /* |
|
| 239 | + /* |
|
| 240 | 240 | * 1. Build a temp file and stat that to get an idea of what the server |
| 241 | 241 | * thinks the current time is (our_tmp.st_ctime).. |
| 242 | 242 | */ |
| 243 | 243 | |
| 244 | - $tpath = _DIR_TMP . "stime.$id"; |
|
| 245 | - $tmpfd = @fopen($tpath, 'w'); |
|
| 246 | - if ( |
|
| 247 | - (!$tmpfd) |
|
| 248 | - or (@fputs($tmpfd, 'zz', 2) != 2) |
|
| 249 | - or !($our_tmp = fstat($tmpfd)) |
|
| 250 | - ) { |
|
| 251 | - /* The open failed, or we can't write the file, or we can't stat it */ |
|
| 252 | - @fclose($tmpfd); |
|
| 253 | - spip_unlink($tpath); |
|
| 244 | + $tpath = _DIR_TMP . "stime.$id"; |
|
| 245 | + $tmpfd = @fopen($tpath, 'w'); |
|
| 246 | + if ( |
|
| 247 | + (!$tmpfd) |
|
| 248 | + or (@fputs($tmpfd, 'zz', 2) != 2) |
|
| 249 | + or !($our_tmp = fstat($tmpfd)) |
|
| 250 | + ) { |
|
| 251 | + /* The open failed, or we can't write the file, or we can't stat it */ |
|
| 252 | + @fclose($tmpfd); |
|
| 253 | + spip_unlink($tpath); |
|
| 254 | 254 | |
| 255 | - return false; //(NFSL_SYSF); |
|
| 256 | - } |
|
| 255 | + return false; //(NFSL_SYSF); |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | - @fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */ |
|
| 259 | - spip_unlink($tpath); |
|
| 258 | + @fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */ |
|
| 259 | + spip_unlink($tpath); |
|
| 260 | 260 | |
| 261 | - /* |
|
| 261 | + /* |
|
| 262 | 262 | * 2. make fullpath, a buffer for the full pathname of the lock file |
| 263 | 263 | */ |
| 264 | 264 | |
| 265 | - $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 265 | + $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 266 | 266 | |
| 267 | - /* |
|
| 267 | + /* |
|
| 268 | 268 | * 3. If the ctime hasn't been modified, unlink the file and return. If the |
| 269 | 269 | * lock has expired, sleep the usual random interval before returning. |
| 270 | 270 | * If we didn't sleep, there could be a race if the caller immediately |
| 271 | 271 | * tries to relock the file. |
| 272 | 272 | */ |
| 273 | 273 | |
| 274 | - if ( |
|
| 275 | - ($old_stat = @lstat($lock_file)) /* stat succeeds so file is there */ |
|
| 276 | - && ($old_stat['ctime'] == $birth) |
|
| 277 | - ) { /* hasn't been modified since birth */ |
|
| 278 | - if (!$test) { |
|
| 279 | - spip_unlink($lock_file); |
|
| 280 | - } /* so the lock is ours to remove */ |
|
| 281 | - if ($our_tmp['ctime'] >= $birth + $max_age) { /* the lock has expired */ |
|
| 282 | - if (!$test) { |
|
| 283 | - return false; |
|
| 284 | - } //(NFSL_LOST); |
|
| 285 | - sleep(1 + (random_int(0, 4))); /* so sleep a bit */ |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - return true;//(NFSL_OK); /* success */ |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - /* |
|
| 274 | + if ( |
|
| 275 | + ($old_stat = @lstat($lock_file)) /* stat succeeds so file is there */ |
|
| 276 | + && ($old_stat['ctime'] == $birth) |
|
| 277 | + ) { /* hasn't been modified since birth */ |
|
| 278 | + if (!$test) { |
|
| 279 | + spip_unlink($lock_file); |
|
| 280 | + } /* so the lock is ours to remove */ |
|
| 281 | + if ($our_tmp['ctime'] >= $birth + $max_age) { /* the lock has expired */ |
|
| 282 | + if (!$test) { |
|
| 283 | + return false; |
|
| 284 | + } //(NFSL_LOST); |
|
| 285 | + sleep(1 + (random_int(0, 4))); /* so sleep a bit */ |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + return true;//(NFSL_OK); /* success */ |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + /* |
|
| 292 | 292 | * 4. Either ctime has been modified, or the entire lock file is missing. |
| 293 | 293 | * If the lock should still be ours, based on the ctime of the temp |
| 294 | 294 | * file, return with NFSL_STOLEN. If not, then our lock is expired and |
| 295 | 295 | * someone else has grabbed the file, so return NFSL_LOST. |
| 296 | 296 | */ |
| 297 | 297 | |
| 298 | - if ($our_tmp['ctime'] < $birth + $max_age) { /* lock was stolen */ |
|
| 299 | - return false; |
|
| 300 | - } //(NFSL_STOLEN); |
|
| 298 | + if ($our_tmp['ctime'] < $birth + $max_age) { /* lock was stolen */ |
|
| 299 | + return false; |
|
| 300 | + } //(NFSL_STOLEN); |
|
| 301 | 301 | |
| 302 | - return false; //(NFSL_LOST); /* The lock must have expired first. */ |
|
| 302 | + return false; //(NFSL_LOST); /* The lock must have expired first. */ |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | |
@@ -323,5 +323,5 @@ discard block |
||
| 323 | 323 | * return bool true si déverrouillé, false sinon |
| 324 | 324 | */ |
| 325 | 325 | function spip_nfslock_test($fichier, $birth, $max_age = 0) { |
| 326 | - return spip_nfsunlock($fichier, $birth, $max_age, true); |
|
| 326 | + return spip_nfsunlock($fichier, $birth, $max_age, true); |
|
| 327 | 327 | } |
@@ -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 | /** |
@@ -33,118 +33,118 @@ discard block |
||
| 33 | 33 | **/ |
| 34 | 34 | function analyse_csv($t) { |
| 35 | 35 | |
| 36 | - // Quel est le séparateur ? |
|
| 37 | - $virg = substr_count($t, ','); |
|
| 38 | - $pvirg = substr_count($t, ';'); |
|
| 39 | - $tab = substr_count($t, "\t"); |
|
| 40 | - if ($virg > $pvirg) { |
|
| 41 | - $sep = ','; |
|
| 42 | - $hs = ','; |
|
| 43 | - } else { |
|
| 44 | - $sep = ';'; |
|
| 45 | - $hs = ';'; |
|
| 46 | - $virg = $pvirg; |
|
| 47 | - } |
|
| 48 | - // un certain nombre de tab => le séparateur est tab |
|
| 49 | - if ($tab > $virg / 10) { |
|
| 50 | - $sep = "\t"; |
|
| 51 | - $hs = "\t"; |
|
| 52 | - } |
|
| 36 | + // Quel est le séparateur ? |
|
| 37 | + $virg = substr_count($t, ','); |
|
| 38 | + $pvirg = substr_count($t, ';'); |
|
| 39 | + $tab = substr_count($t, "\t"); |
|
| 40 | + if ($virg > $pvirg) { |
|
| 41 | + $sep = ','; |
|
| 42 | + $hs = ','; |
|
| 43 | + } else { |
|
| 44 | + $sep = ';'; |
|
| 45 | + $hs = ';'; |
|
| 46 | + $virg = $pvirg; |
|
| 47 | + } |
|
| 48 | + // un certain nombre de tab => le séparateur est tab |
|
| 49 | + if ($tab > $virg / 10) { |
|
| 50 | + $sep = "\t"; |
|
| 51 | + $hs = "\t"; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - // un separateur suivi de 3 guillemets attention ! |
|
| 55 | - // attention au ; ou , suceptible d'etre confondu avec un separateur |
|
| 56 | - // on substitue un # et on remplacera a la fin |
|
| 57 | - $t = preg_replace("/([\n$sep])\"\"\"/", '\\1""#', $t); |
|
| 58 | - $t = str_replace('""', '"#', $t); |
|
| 59 | - preg_match_all('/"[^"]*"/', $t, $r); |
|
| 60 | - foreach ($r[0] as $cell) { |
|
| 61 | - $t = str_replace( |
|
| 62 | - $cell, |
|
| 63 | - str_replace( |
|
| 64 | - $sep, |
|
| 65 | - $hs, |
|
| 66 | - str_replace( |
|
| 67 | - "\n", |
|
| 68 | - '``**``', // échapper les saut de lignes, on les remettra après. |
|
| 69 | - substr($cell, 1, -1) |
|
| 70 | - ) |
|
| 71 | - ), |
|
| 72 | - $t |
|
| 73 | - ); |
|
| 74 | - } |
|
| 54 | + // un separateur suivi de 3 guillemets attention ! |
|
| 55 | + // attention au ; ou , suceptible d'etre confondu avec un separateur |
|
| 56 | + // on substitue un # et on remplacera a la fin |
|
| 57 | + $t = preg_replace("/([\n$sep])\"\"\"/", '\\1""#', $t); |
|
| 58 | + $t = str_replace('""', '"#', $t); |
|
| 59 | + preg_match_all('/"[^"]*"/', $t, $r); |
|
| 60 | + foreach ($r[0] as $cell) { |
|
| 61 | + $t = str_replace( |
|
| 62 | + $cell, |
|
| 63 | + str_replace( |
|
| 64 | + $sep, |
|
| 65 | + $hs, |
|
| 66 | + str_replace( |
|
| 67 | + "\n", |
|
| 68 | + '``**``', // échapper les saut de lignes, on les remettra après. |
|
| 69 | + substr($cell, 1, -1) |
|
| 70 | + ) |
|
| 71 | + ), |
|
| 72 | + $t |
|
| 73 | + ); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - $t = preg_replace( |
|
| 77 | - '/\r?\n/', |
|
| 78 | - "\n", |
|
| 79 | - preg_replace('/[\r\n]+/', "\n", $t) |
|
| 80 | - ); |
|
| 76 | + $t = preg_replace( |
|
| 77 | + '/\r?\n/', |
|
| 78 | + "\n", |
|
| 79 | + preg_replace('/[\r\n]+/', "\n", $t) |
|
| 80 | + ); |
|
| 81 | 81 | |
| 82 | - [$entete, $corps] = explode("\n", $t, 2); |
|
| 83 | - $caption = ''; |
|
| 84 | - // sauter la ligne de tete formee seulement de separateurs |
|
| 85 | - if (substr_count($entete, $sep) == strlen($entete)) { |
|
| 86 | - [$entete, $corps] = explode("\n", $corps, 2); |
|
| 87 | - } |
|
| 88 | - // si une seule colonne, en faire le titre |
|
| 89 | - if (preg_match("/^([^$sep]+)$sep+\$/", $entete, $l)) { |
|
| 90 | - $caption = "\n||" . $l[1] . '|'; |
|
| 91 | - [$entete, $corps] = explode("\n", $corps, 2); |
|
| 92 | - } |
|
| 93 | - // si premiere colonne vide, le raccourci doit quand meme produire <th... |
|
| 94 | - if ($entete[0] == $sep) { |
|
| 95 | - $entete = ' ' . $entete; |
|
| 96 | - } |
|
| 82 | + [$entete, $corps] = explode("\n", $t, 2); |
|
| 83 | + $caption = ''; |
|
| 84 | + // sauter la ligne de tete formee seulement de separateurs |
|
| 85 | + if (substr_count($entete, $sep) == strlen($entete)) { |
|
| 86 | + [$entete, $corps] = explode("\n", $corps, 2); |
|
| 87 | + } |
|
| 88 | + // si une seule colonne, en faire le titre |
|
| 89 | + if (preg_match("/^([^$sep]+)$sep+\$/", $entete, $l)) { |
|
| 90 | + $caption = "\n||" . $l[1] . '|'; |
|
| 91 | + [$entete, $corps] = explode("\n", $corps, 2); |
|
| 92 | + } |
|
| 93 | + // si premiere colonne vide, le raccourci doit quand meme produire <th... |
|
| 94 | + if ($entete[0] == $sep) { |
|
| 95 | + $entete = ' ' . $entete; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - $lignes = explode("\n", $corps); |
|
| 98 | + $lignes = explode("\n", $corps); |
|
| 99 | 99 | |
| 100 | - // retrait des lignes vides finales |
|
| 101 | - while ( |
|
| 102 | - count($lignes) > 0 |
|
| 103 | - and preg_match("/^$sep*$/", $lignes[count($lignes) - 1]) |
|
| 104 | - ) { |
|
| 105 | - unset($lignes[count($lignes) - 1]); |
|
| 106 | - } |
|
| 107 | - // calcul du nombre de colonne a chaque ligne |
|
| 108 | - $nbcols = []; |
|
| 109 | - $max = $mil = substr_count($entete, $sep); |
|
| 110 | - foreach ($lignes as $k => $v) { |
|
| 111 | - if ($max <> ($nbcols[$k] = substr_count($v, $sep))) { |
|
| 112 | - if ($max > $nbcols[$k]) { |
|
| 113 | - $mil = $nbcols[$k]; |
|
| 114 | - } else { |
|
| 115 | - $mil = $max; |
|
| 116 | - $max = $nbcols[$k]; |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - // Si pas le meme nombre, cadrer au nombre max |
|
| 121 | - if ($mil <> $max) { |
|
| 122 | - foreach ($nbcols as $k => $v) { |
|
| 123 | - if ($v < $max) { |
|
| 124 | - $lignes[$k] .= str_repeat($sep, $max - $v); |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - // et retirer les colonnes integralement vides |
|
| 129 | - while (true) { |
|
| 130 | - $nbcols = ($entete[strlen($entete) - 1] === $sep); |
|
| 131 | - foreach ($lignes as $v) { |
|
| 132 | - $nbcols &= ($v[strlen($v) - 1] === $sep); |
|
| 133 | - } |
|
| 134 | - if (!$nbcols) { |
|
| 135 | - break; |
|
| 136 | - } |
|
| 137 | - $entete = substr($entete, 0, -1); |
|
| 138 | - foreach ($lignes as $k => $v) { |
|
| 139 | - $lignes[$k] = substr($v, 0, -1); |
|
| 140 | - } |
|
| 141 | - } |
|
| 100 | + // retrait des lignes vides finales |
|
| 101 | + while ( |
|
| 102 | + count($lignes) > 0 |
|
| 103 | + and preg_match("/^$sep*$/", $lignes[count($lignes) - 1]) |
|
| 104 | + ) { |
|
| 105 | + unset($lignes[count($lignes) - 1]); |
|
| 106 | + } |
|
| 107 | + // calcul du nombre de colonne a chaque ligne |
|
| 108 | + $nbcols = []; |
|
| 109 | + $max = $mil = substr_count($entete, $sep); |
|
| 110 | + foreach ($lignes as $k => $v) { |
|
| 111 | + if ($max <> ($nbcols[$k] = substr_count($v, $sep))) { |
|
| 112 | + if ($max > $nbcols[$k]) { |
|
| 113 | + $mil = $nbcols[$k]; |
|
| 114 | + } else { |
|
| 115 | + $mil = $max; |
|
| 116 | + $max = $nbcols[$k]; |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + // Si pas le meme nombre, cadrer au nombre max |
|
| 121 | + if ($mil <> $max) { |
|
| 122 | + foreach ($nbcols as $k => $v) { |
|
| 123 | + if ($v < $max) { |
|
| 124 | + $lignes[$k] .= str_repeat($sep, $max - $v); |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + // et retirer les colonnes integralement vides |
|
| 129 | + while (true) { |
|
| 130 | + $nbcols = ($entete[strlen($entete) - 1] === $sep); |
|
| 131 | + foreach ($lignes as $v) { |
|
| 132 | + $nbcols &= ($v[strlen($v) - 1] === $sep); |
|
| 133 | + } |
|
| 134 | + if (!$nbcols) { |
|
| 135 | + break; |
|
| 136 | + } |
|
| 137 | + $entete = substr($entete, 0, -1); |
|
| 138 | + foreach ($lignes as $k => $v) { |
|
| 139 | + $lignes[$k] = substr($v, 0, -1); |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - foreach ($lignes as &$l) { |
|
| 144 | - $l = str_replace('"#', '"', $l); |
|
| 145 | - $l = str_replace('``**``', "\n", $l); |
|
| 146 | - $l = explode($sep, $l); |
|
| 147 | - } |
|
| 143 | + foreach ($lignes as &$l) { |
|
| 144 | + $l = str_replace('"#', '"', $l); |
|
| 145 | + $l = str_replace('``**``', "\n", $l); |
|
| 146 | + $l = explode($sep, $l); |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - return [explode($sep, $entete), $lignes, $caption]; |
|
| 149 | + return [explode($sep, $entete), $lignes, $caption]; |
|
| 150 | 150 | } |