@@ -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 | } |
@@ -147,11 +147,11 @@ discard block |
||
| 147 | 147 | if ($quoi !== 'actifs') { |
| 148 | 148 | $lpf = liste_plugin_files(); |
| 149 | 149 | if ($lpf) { |
| 150 | - echo '<p>' . _T('texte_presente_plugin') . '</p>'; |
|
| 150 | + echo '<p>'._T('texte_presente_plugin').'</p>'; |
|
| 151 | 151 | } else { |
| 152 | 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>'; |
|
| 153 | + echo '<p>'._T('plugin_info_automatique_ftp', ['rep' => joli_repertoire(_DIR_PLUGINS)]) |
|
| 154 | + . ' — '._T('plugin_info_automatique_creer').'</p>'; |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | $lcpaffiche = $lpf; |
@@ -172,10 +172,10 @@ discard block |
||
| 172 | 172 | if (defined('_DIR_PLUGINS_SUPPL')) { |
| 173 | 173 | $nb += is_countable($lcpas) ? count($lcpas) : 0; |
| 174 | 174 | } |
| 175 | - echo '<h3>' . sinon( |
|
| 175 | + echo '<h3>'.sinon( |
|
| 176 | 176 | singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'), |
| 177 | 177 | _T('plugins_actif_aucun') |
| 178 | - ) . '</h3>'; |
|
| 178 | + ).'</h3>'; |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | if (empty($format)) { |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | if ($corps) { |
| 194 | 194 | $corps .= "\n<div class='boutons' style='display:none;'>" |
| 195 | - . "<input type='submit' class='submit save' value='" . _T('bouton_enregistrer') |
|
| 195 | + . "<input type='submit' class='submit save' value='"._T('bouton_enregistrer') |
|
| 196 | 196 | . "' />" |
| 197 | 197 | . '</div>'; |
| 198 | 198 | } |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | . debut_cadre_trait_couleur('', true, '', _T('plugins_liste_dist'), 'liste_plugins_dist') |
| 267 | 267 | . '<p>' |
| 268 | 268 | . _T('plugin_info_plugins_dist_1', ['plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST)]) |
| 269 | - . '<br />' . _T('plugin_info_plugins_dist_2') |
|
| 269 | + . '<br />'._T('plugin_info_plugins_dist_2') |
|
| 270 | 270 | . '</p>' |
| 271 | 271 | . $liste |
| 272 | 272 | . fin_cadre_trait_couleur() |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | $res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees')); |
| 290 | 290 | $res .= '<dl>'; |
| 291 | 291 | foreach ($libs as $lib => $rep) { |
| 292 | - $res .= "<dt>$lib</dt><dd>" . joli_repertoire($rep) . "</dd>\n"; |
|
| 292 | + $res .= "<dt>$lib</dt><dd>".joli_repertoire($rep)."</dd>\n"; |
|
| 293 | 293 | } |
| 294 | 294 | $res .= '</dl>'; |
| 295 | 295 | $res .= fin_cadre_enfonce(); |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | $libs = []; |
| 309 | 309 | foreach (array_reverse(creer_chemin()) as $d) { |
| 310 | 310 | if ( |
| 311 | - is_dir($dir = $d . 'lib/') |
|
| 311 | + is_dir($dir = $d.'lib/') |
|
| 312 | 312 | and $t = opendir($dir) |
| 313 | 313 | ) { |
| 314 | 314 | while (($f = readdir($t)) !== false) { |
@@ -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'>".spip_htmlspecialchars($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 = (array) unserialize($GLOBALS['meta']['plugin']); |
|
| 131 | - $lcpa = $actifs + (array) 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'>".spip_htmlspecialchars($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 = (array) unserialize($GLOBALS['meta']['plugin']); |
|
| 131 | + $lcpa = $actifs + (array) 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 | } |
@@ -45,8 +45,8 @@ |
||
| 45 | 45 | |
| 46 | 46 | echo debut_grand_cadre(); |
| 47 | 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>'; |
|
| 48 | + echo '<p>'._T('info_procedure_maj_version').'</p>', |
|
| 49 | + '<p>'._T('info_administrateur_site_01').'</p>'; |
|
| 50 | 50 | echo bouton_action(_T('bouton_mettre_a_jour_base'), generer_url_ecrire('upgrade', 'reinstall=non')); |
| 51 | 51 | echo boite_fermer(); |
| 52 | 52 | // masquer les erreurs sql sur cette page car proviennent de la base pas a jour ! |
@@ -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 | } |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | echo pipeline('affiche_droite', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']); |
| 43 | 43 | |
| 44 | 44 | echo debut_droite(); |
| 45 | - echo "<h1 class='grostitre'>" . _T('fichier_introuvable', ['fichier' => $exec]) . '</h1>'; |
|
| 45 | + echo "<h1 class='grostitre'>"._T('fichier_introuvable', ['fichier' => $exec]).'</h1>'; |
|
| 46 | 46 | echo pipeline('affiche_milieu', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']); |
| 47 | 47 | |
| 48 | 48 | echo fin_gauche(), fin_page(); |
@@ -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 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | if (!$max_age) { |
| 107 | 107 | $max_age = _DEFAULT_LOCKTIME; |
| 108 | 108 | } |
| 109 | - $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8); |
|
| 109 | + $lock_file = _DIR_TMP._NAME_LOCK.'-'.substr(md5($fichier), 0, 8); |
|
| 110 | 110 | |
| 111 | 111 | |
| 112 | 112 | /* |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | |
| 117 | 117 | $id = creer_uniqid(); |
| 118 | - $tpath = _DIR_TMP . "slock.$id"; |
|
| 118 | + $tpath = _DIR_TMP."slock.$id"; |
|
| 119 | 119 | $tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ... |
| 120 | 120 | if (!$tmpfd) { /* open failed */ |
| 121 | 121 | @fclose($tmpfd); |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * thinks the current time is (our_tmp.st_ctime).. |
| 242 | 242 | */ |
| 243 | 243 | |
| 244 | - $tpath = _DIR_TMP . "stime.$id"; |
|
| 244 | + $tpath = _DIR_TMP."stime.$id"; |
|
| 245 | 245 | $tmpfd = @fopen($tpath, 'w'); |
| 246 | 246 | if ( |
| 247 | 247 | (!$tmpfd) |
@@ -255,14 +255,14 @@ discard block |
||
| 255 | 255 | return false; //(NFSL_SYSF); |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - @fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */ |
|
| 258 | + @fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */ |
|
| 259 | 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 |
@@ -282,10 +282,10 @@ discard block |
||
| 282 | 282 | if (!$test) { |
| 283 | 283 | return false; |
| 284 | 284 | } //(NFSL_LOST); |
| 285 | - sleep(1 + (random_int(0, 4))); /* so sleep a bit */ |
|
| 285 | + sleep(1 + (random_int(0, 4))); /* so sleep a bit */ |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - return true;//(NFSL_OK); /* success */ |
|
| 288 | + return true; //(NFSL_OK); /* success */ |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | /* |
@@ -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 | } |
@@ -87,12 +87,12 @@ |
||
| 87 | 87 | } |
| 88 | 88 | // si une seule colonne, en faire le titre |
| 89 | 89 | if (preg_match("/^([^$sep]+)$sep+\$/", $entete, $l)) { |
| 90 | - $caption = "\n||" . $l[1] . '|'; |
|
| 90 | + $caption = "\n||".$l[1].'|'; |
|
| 91 | 91 | [$entete, $corps] = explode("\n", $corps, 2); |
| 92 | 92 | } |
| 93 | 93 | // si premiere colonne vide, le raccourci doit quand meme produire <th... |
| 94 | 94 | if ($entete[0] == $sep) { |
| 95 | - $entete = ' ' . $entete; |
|
| 95 | + $entete = ' '.$entete; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | $lignes = explode("\n", $corps); |
@@ -37,16 +37,16 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // Regarder dans le repertoire local des images TeX et blocs MathML |
| 40 | - if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) { |
|
| 40 | + if (!@is_dir($dir_tex = _DIR_VAR.'cache-TeX/')) { |
|
| 41 | 41 | @mkdir($dir_tex, _SPIP_CHMOD); |
| 42 | 42 | } |
| 43 | - $fichier = $dir_tex . md5(trim($tex)) . $ext; |
|
| 43 | + $fichier = $dir_tex.md5(trim($tex)).$ext; |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | if (!@file_exists($fichier)) { |
| 47 | 47 | // Aller chercher l'image sur le serveur |
| 48 | 48 | if ($server) { |
| 49 | - spip_log($url = $server . '?' . rawurlencode($tex)); |
|
| 49 | + spip_log($url = $server.'?'.rawurlencode($tex)); |
|
| 50 | 50 | include_spip('inc/distant'); |
| 51 | 51 | recuperer_url($url, ['file' => $fichier]); |
| 52 | 52 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | return implode('', file($fichier)); |
| 62 | 62 | } // TeX |
| 63 | 63 | else { |
| 64 | - [, , , $size] = @spip_getimagesize($fichier); |
|
| 64 | + [,,, $size] = @spip_getimagesize($fichier); |
|
| 65 | 65 | $alt = "alt=\"$tex\" title=\"$tex\""; |
| 66 | 66 | |
| 67 | 67 | return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />"; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | if ($defaire_amp) { |
| 129 | 129 | $expression = str_replace('&', '&', $expression); |
| 130 | 130 | } |
| 131 | - $echap = "\n<p class=\"spip\" style=\"text-align: center;\">" . produire_image_math($expression) . "</p>\n"; |
|
| 131 | + $echap = "\n<p class=\"spip\" style=\"text-align: center;\">".produire_image_math($expression)."</p>\n"; |
|
| 132 | 132 | $pos = strpos($texte_milieu, (string) $regs[0]); |
| 133 | 133 | $texte_milieu = substr($texte_milieu, 0, $pos) |
| 134 | 134 | . code_echappement($echap, $source) |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | . substr($texte_milieu, $pos + strlen($regs[0])); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - $texte_a_voir = $texte_debut . $texte_milieu . $texte_fin; |
|
| 151 | + $texte_a_voir = $texte_debut.$texte_milieu.$texte_fin; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | return $texte_a_voir; |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | // |
| 14 | 14 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | // |
@@ -21,54 +21,54 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | function produire_image_math($tex) { |
| 23 | 23 | |
| 24 | - switch ($GLOBALS['traiter_math']) { |
|
| 25 | - // Attention: mathml desactiv'e pour l'instant |
|
| 26 | - case 'mathml': |
|
| 27 | - $ext = '.xhtml'; |
|
| 28 | - $server = $GLOBALS['mathml_server']; |
|
| 29 | - break; |
|
| 30 | - case 'tex': |
|
| 31 | - $ext = '.png'; |
|
| 32 | - $server = $GLOBALS['tex_server']; |
|
| 33 | - break; |
|
| 34 | - default: |
|
| 35 | - return $tex; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - // Regarder dans le repertoire local des images TeX et blocs MathML |
|
| 39 | - if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) { |
|
| 40 | - @mkdir($dir_tex, _SPIP_CHMOD); |
|
| 41 | - } |
|
| 42 | - $fichier = $dir_tex . md5(trim($tex)) . $ext; |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - if (!@file_exists($fichier)) { |
|
| 46 | - // Aller chercher l'image sur le serveur |
|
| 47 | - if ($server) { |
|
| 48 | - spip_log($url = $server . '?' . rawurlencode($tex)); |
|
| 49 | - include_spip('inc/distant'); |
|
| 50 | - recuperer_url($url, ['file' => $fichier]); |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - // Composer la reponse selon presence ou non de l'image |
|
| 56 | - $tex = entites_html($tex); |
|
| 57 | - if (@file_exists($fichier)) { |
|
| 58 | - // MathML |
|
| 59 | - if ($GLOBALS['traiter_math'] == 'mathml') { |
|
| 60 | - return implode('', file($fichier)); |
|
| 61 | - } // TeX |
|
| 62 | - else { |
|
| 63 | - [, , , $size] = @spip_getimagesize($fichier); |
|
| 64 | - $alt = "alt=\"$tex\" title=\"$tex\""; |
|
| 65 | - |
|
| 66 | - return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />"; |
|
| 67 | - } |
|
| 68 | - } else // pas de fichier |
|
| 69 | - { |
|
| 70 | - return "<tt><span class='spip_code' dir='ltr'>$tex</span></tt>"; |
|
| 71 | - } |
|
| 24 | + switch ($GLOBALS['traiter_math']) { |
|
| 25 | + // Attention: mathml desactiv'e pour l'instant |
|
| 26 | + case 'mathml': |
|
| 27 | + $ext = '.xhtml'; |
|
| 28 | + $server = $GLOBALS['mathml_server']; |
|
| 29 | + break; |
|
| 30 | + case 'tex': |
|
| 31 | + $ext = '.png'; |
|
| 32 | + $server = $GLOBALS['tex_server']; |
|
| 33 | + break; |
|
| 34 | + default: |
|
| 35 | + return $tex; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + // Regarder dans le repertoire local des images TeX et blocs MathML |
|
| 39 | + if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) { |
|
| 40 | + @mkdir($dir_tex, _SPIP_CHMOD); |
|
| 41 | + } |
|
| 42 | + $fichier = $dir_tex . md5(trim($tex)) . $ext; |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + if (!@file_exists($fichier)) { |
|
| 46 | + // Aller chercher l'image sur le serveur |
|
| 47 | + if ($server) { |
|
| 48 | + spip_log($url = $server . '?' . rawurlencode($tex)); |
|
| 49 | + include_spip('inc/distant'); |
|
| 50 | + recuperer_url($url, ['file' => $fichier]); |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + // Composer la reponse selon presence ou non de l'image |
|
| 56 | + $tex = entites_html($tex); |
|
| 57 | + if (@file_exists($fichier)) { |
|
| 58 | + // MathML |
|
| 59 | + if ($GLOBALS['traiter_math'] == 'mathml') { |
|
| 60 | + return implode('', file($fichier)); |
|
| 61 | + } // TeX |
|
| 62 | + else { |
|
| 63 | + [, , , $size] = @spip_getimagesize($fichier); |
|
| 64 | + $alt = "alt=\"$tex\" title=\"$tex\""; |
|
| 65 | + |
|
| 66 | + return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />"; |
|
| 67 | + } |
|
| 68 | + } else // pas de fichier |
|
| 69 | + { |
|
| 70 | + return "<tt><span class='spip_code' dir='ltr'>$tex</span></tt>"; |
|
| 71 | + } |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | |
@@ -103,52 +103,52 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | function traiter_math($letexte, $source = '', $defaire_amp = false) { |
| 105 | 105 | |
| 106 | - $texte_a_voir = $letexte; |
|
| 107 | - while (($debut = strpos($texte_a_voir, '<math>')) !== false) { |
|
| 108 | - if (!$fin = strpos($texte_a_voir, '</math>')) { |
|
| 109 | - $fin = strlen($texte_a_voir); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - $texte_debut = substr($texte_a_voir, 0, $debut); |
|
| 113 | - $texte_milieu = substr( |
|
| 114 | - $texte_a_voir, |
|
| 115 | - $debut + strlen('<math>'), |
|
| 116 | - $fin - $debut - strlen('<math>') |
|
| 117 | - ); |
|
| 118 | - $texte_fin = substr( |
|
| 119 | - $texte_a_voir, |
|
| 120 | - $fin + strlen('</math>'), |
|
| 121 | - strlen($texte_a_voir) |
|
| 122 | - ); |
|
| 123 | - |
|
| 124 | - // Les doubles $$x^2$$ en mode 'div' |
|
| 125 | - while ((preg_match(',[$][$]([^$]+)[$][$],', $texte_milieu, $regs))) { |
|
| 126 | - $expression = $regs[1]; |
|
| 127 | - if ($defaire_amp) { |
|
| 128 | - $expression = str_replace('&', '&', $expression); |
|
| 129 | - } |
|
| 130 | - $echap = "\n<p class=\"spip\" style=\"text-align: center;\">" . produire_image_math($expression) . "</p>\n"; |
|
| 131 | - $pos = strpos($texte_milieu, (string) $regs[0]); |
|
| 132 | - $texte_milieu = substr($texte_milieu, 0, $pos) |
|
| 133 | - . code_echappement($echap, $source) |
|
| 134 | - . substr($texte_milieu, $pos + strlen($regs[0])); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - // Les simples $x^2$ en mode 'span' |
|
| 138 | - while ((preg_match(',[$]([^$]+)[$],', $texte_milieu, $regs))) { |
|
| 139 | - $expression = $regs[1]; |
|
| 140 | - if ($defaire_amp) { |
|
| 141 | - $expression = str_replace('&', '&', $expression); |
|
| 142 | - } |
|
| 143 | - $echap = produire_image_math($expression); |
|
| 144 | - $pos = strpos($texte_milieu, (string) $regs[0]); |
|
| 145 | - $texte_milieu = substr($texte_milieu, 0, $pos) |
|
| 146 | - . code_echappement($echap, $source) |
|
| 147 | - . substr($texte_milieu, $pos + strlen($regs[0])); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - $texte_a_voir = $texte_debut . $texte_milieu . $texte_fin; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - return $texte_a_voir; |
|
| 106 | + $texte_a_voir = $letexte; |
|
| 107 | + while (($debut = strpos($texte_a_voir, '<math>')) !== false) { |
|
| 108 | + if (!$fin = strpos($texte_a_voir, '</math>')) { |
|
| 109 | + $fin = strlen($texte_a_voir); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + $texte_debut = substr($texte_a_voir, 0, $debut); |
|
| 113 | + $texte_milieu = substr( |
|
| 114 | + $texte_a_voir, |
|
| 115 | + $debut + strlen('<math>'), |
|
| 116 | + $fin - $debut - strlen('<math>') |
|
| 117 | + ); |
|
| 118 | + $texte_fin = substr( |
|
| 119 | + $texte_a_voir, |
|
| 120 | + $fin + strlen('</math>'), |
|
| 121 | + strlen($texte_a_voir) |
|
| 122 | + ); |
|
| 123 | + |
|
| 124 | + // Les doubles $$x^2$$ en mode 'div' |
|
| 125 | + while ((preg_match(',[$][$]([^$]+)[$][$],', $texte_milieu, $regs))) { |
|
| 126 | + $expression = $regs[1]; |
|
| 127 | + if ($defaire_amp) { |
|
| 128 | + $expression = str_replace('&', '&', $expression); |
|
| 129 | + } |
|
| 130 | + $echap = "\n<p class=\"spip\" style=\"text-align: center;\">" . produire_image_math($expression) . "</p>\n"; |
|
| 131 | + $pos = strpos($texte_milieu, (string) $regs[0]); |
|
| 132 | + $texte_milieu = substr($texte_milieu, 0, $pos) |
|
| 133 | + . code_echappement($echap, $source) |
|
| 134 | + . substr($texte_milieu, $pos + strlen($regs[0])); |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + // Les simples $x^2$ en mode 'span' |
|
| 138 | + while ((preg_match(',[$]([^$]+)[$],', $texte_milieu, $regs))) { |
|
| 139 | + $expression = $regs[1]; |
|
| 140 | + if ($defaire_amp) { |
|
| 141 | + $expression = str_replace('&', '&', $expression); |
|
| 142 | + } |
|
| 143 | + $echap = produire_image_math($expression); |
|
| 144 | + $pos = strpos($texte_milieu, (string) $regs[0]); |
|
| 145 | + $texte_milieu = substr($texte_milieu, 0, $pos) |
|
| 146 | + . code_echappement($echap, $source) |
|
| 147 | + . substr($texte_milieu, $pos + strlen($regs[0])); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + $texte_a_voir = $texte_debut . $texte_milieu . $texte_fin; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + return $texte_a_voir; |
|
| 154 | 154 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | if (substr($recherche, 0, 1) == '/' and substr($recherche, -1, 1) == '/' and strlen($recherche) > 2) { |
| 101 | 101 | // c'est une preg |
| 102 | 102 | $recherche_trans = translitteration($recherche); |
| 103 | - $preg = $recherche_trans . $options['preg_flags']; |
|
| 103 | + $preg = $recherche_trans.$options['preg_flags']; |
|
| 104 | 104 | $is_preg = true; |
| 105 | 105 | } else { |
| 106 | 106 | // s'il y a plusieurs mots il faut les chercher tous : oblige REGEXP, |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if (preg_match(',\s+,' . $u, $recherche_mod)) { |
|
| 123 | + if (preg_match(',\s+,'.$u, $recherche_mod)) { |
|
| 124 | 124 | $is_preg = true; |
| 125 | 125 | |
| 126 | 126 | $recherche_inter = '|'; |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | foreach ($recherche_mots as $mot) { |
| 131 | 131 | if (strlen($mot) >= $min_long) { |
| 132 | 132 | // echapper les caracteres de regexp qui sont eventuellement dans la recherche |
| 133 | - $recherche_inter .= preg_quote($mot) . ' '; |
|
| 133 | + $recherche_inter .= preg_quote($mot).' '; |
|
| 134 | 134 | $petits_mots = false; |
| 135 | 135 | } |
| 136 | 136 | } |
@@ -138,14 +138,14 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | // mais on cherche quand même l'expression complète, même si elle |
| 140 | 140 | // comporte des mots de moins de quatre lettres |
| 141 | - $recherche = trim(preg_replace(',\s+,' . $u, '|', $recherche_inter), '|'); |
|
| 141 | + $recherche = trim(preg_replace(',\s+,'.$u, '|', $recherche_inter), '|'); |
|
| 142 | 142 | if (!$recherche or $petits_mots) { |
| 143 | 143 | $recherche = preg_quote($recherche_org); |
| 144 | 144 | } |
| 145 | 145 | $recherche_trans = translitteration($recherche); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - $preg = '/' . str_replace('/', '\\/', $recherche_trans) . '/' . $options['preg_flags']; |
|
| 148 | + $preg = '/'.str_replace('/', '\\/', $recherche_trans).'/'.$options['preg_flags']; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Si la chaine est inactive, on va utiliser LIKE pour aller plus vite |
@@ -185,11 +185,11 @@ discard block |
||
| 185 | 185 | } |
| 186 | 186 | $q = sql_quote( |
| 187 | 187 | '%' |
| 188 | - . preg_replace(',\s+,' . $u, '%', $q) |
|
| 188 | + . preg_replace(',\s+,'.$u, '%', $q) |
|
| 189 | 189 | . '%' |
| 190 | 190 | ); |
| 191 | 191 | |
| 192 | - $preg = '/' . preg_replace(',\s+,' . $u, '.+', trim($recherche_mod)) . '/' . $options['preg_flags']; |
|
| 192 | + $preg = '/'.preg_replace(',\s+,'.$u, '.+', trim($recherche_mod)).'/'.$options['preg_flags']; |
|
| 193 | 193 | } else { |
| 194 | 194 | $methode = 'REGEXP'; |
| 195 | 195 | $q = sql_quote(trim($recherche, '/')); |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | foreach ($tables as $table => $champs) { |
| 312 | 312 | # lock via memoization, si dispo |
| 313 | 313 | if (function_exists('cache_lock')) { |
| 314 | - cache_lock($lock = _RECHERCHE_LOCK_KEY . ' ' . $table . ' ' . $recherche); |
|
| 314 | + cache_lock($lock = _RECHERCHE_LOCK_KEY.' '.$table.' '.$recherche); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | spip_timer('rech'); |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | |
| 327 | 327 | |
| 328 | 328 | spip_log( |
| 329 | - "recherche $table ($recherche) : " . (is_countable($results[$table]) ? count($results[$table]) : 0) . ' resultats ' . spip_timer('rech'), |
|
| 329 | + "recherche $table ($recherche) : ".(is_countable($results[$table]) ? count($results[$table]) : 0).' resultats '.spip_timer('rech'), |
|
| 330 | 330 | 'recherche' |
| 331 | 331 | ); |
| 332 | 332 | |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | |
| 362 | 362 | $results = recherche_en_base($recherche, $tables, $options); |
| 363 | 363 | |
| 364 | - $preg = '/' . str_replace('/', '\\/', $recherche) . '/' . $options['preg_flags']; |
|
| 364 | + $preg = '/'.str_replace('/', '\\/', $recherche).'/'.$options['preg_flags']; |
|
| 365 | 365 | |
| 366 | 366 | foreach ($results as $table => $r) { |
| 367 | 367 | $_id_table = id_table_objet($table); |
@@ -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 | defined('_RECHERCHE_LOCK_KEY') || define('_RECHERCHE_LOCK_KEY', 'fulltext'); |
@@ -35,198 +35,198 @@ discard block |
||
| 35 | 35 | * @return array Couples (type d'objet => Couples (champ => score)) |
| 36 | 36 | */ |
| 37 | 37 | function liste_des_champs() { |
| 38 | - static $liste = null; |
|
| 39 | - if (is_null($liste)) { |
|
| 40 | - $liste = []; |
|
| 41 | - // recuperer les tables_objets_sql declarees |
|
| 42 | - include_spip('base/objets'); |
|
| 43 | - $tables_objets = lister_tables_objets_sql(); |
|
| 44 | - foreach ($tables_objets as $t => $infos) { |
|
| 45 | - if ($infos['rechercher_champs']) { |
|
| 46 | - $liste[$infos['type']] = $infos['rechercher_champs']; |
|
| 47 | - } |
|
| 48 | - } |
|
| 49 | - // puis passer dans le pipeline |
|
| 50 | - $liste = pipeline('rechercher_liste_des_champs', $liste); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - return $liste; |
|
| 38 | + static $liste = null; |
|
| 39 | + if (is_null($liste)) { |
|
| 40 | + $liste = []; |
|
| 41 | + // recuperer les tables_objets_sql declarees |
|
| 42 | + include_spip('base/objets'); |
|
| 43 | + $tables_objets = lister_tables_objets_sql(); |
|
| 44 | + foreach ($tables_objets as $t => $infos) { |
|
| 45 | + if ($infos['rechercher_champs']) { |
|
| 46 | + $liste[$infos['type']] = $infos['rechercher_champs']; |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | + // puis passer dans le pipeline |
|
| 50 | + $liste = pipeline('rechercher_liste_des_champs', $liste); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + return $liste; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | // Recherche des auteurs et mots-cles associes |
| 58 | 58 | // en ne regardant que le titre ou le nom |
| 59 | 59 | function liste_des_jointures() { |
| 60 | - static $liste = null; |
|
| 61 | - if (is_null($liste)) { |
|
| 62 | - $liste = []; |
|
| 63 | - // recuperer les tables_objets_sql declarees |
|
| 64 | - include_spip('base/objets'); |
|
| 65 | - $tables_objets = lister_tables_objets_sql(); |
|
| 66 | - foreach ($tables_objets as $t => $infos) { |
|
| 67 | - if ($infos['rechercher_jointures']) { |
|
| 68 | - $liste[$infos['type']] = $infos['rechercher_jointures']; |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - // puis passer dans le pipeline |
|
| 72 | - $liste = pipeline('rechercher_liste_des_jointures', $liste); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - return $liste; |
|
| 60 | + static $liste = null; |
|
| 61 | + if (is_null($liste)) { |
|
| 62 | + $liste = []; |
|
| 63 | + // recuperer les tables_objets_sql declarees |
|
| 64 | + include_spip('base/objets'); |
|
| 65 | + $tables_objets = lister_tables_objets_sql(); |
|
| 66 | + foreach ($tables_objets as $t => $infos) { |
|
| 67 | + if ($infos['rechercher_jointures']) { |
|
| 68 | + $liste[$infos['type']] = $infos['rechercher_jointures']; |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + // puis passer dans le pipeline |
|
| 72 | + $liste = pipeline('rechercher_liste_des_jointures', $liste); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + return $liste; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | function expression_recherche($recherche, $options) { |
| 79 | - // ne calculer qu'une seule fois l'expression par hit |
|
| 80 | - // (meme si utilisee dans plusieurs boucles) |
|
| 81 | - static $expression = []; |
|
| 82 | - $key = serialize([$recherche, $options['preg_flags']]); |
|
| 83 | - if (isset($expression[$key])) { |
|
| 84 | - return $expression[$key]; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 88 | - if ($u and strpos($options['preg_flags'], (string) $u) === false) { |
|
| 89 | - $options['preg_flags'] .= $u; |
|
| 90 | - } |
|
| 91 | - include_spip('inc/charsets'); |
|
| 92 | - $recherche = trim($recherche); |
|
| 93 | - |
|
| 94 | - // retirer les + de +truc et les * de truc* |
|
| 95 | - $recherche = preg_replace(',(^|\s)\+(\w),Uims', '$1$2', $recherche); |
|
| 96 | - $recherche = preg_replace(',(\w)\*($|\s),Uims', '$1$2', $recherche); |
|
| 97 | - |
|
| 98 | - $is_preg = false; |
|
| 99 | - if (substr($recherche, 0, 1) == '/' and substr($recherche, -1, 1) == '/' and strlen($recherche) > 2) { |
|
| 100 | - // c'est une preg |
|
| 101 | - $recherche_trans = translitteration($recherche); |
|
| 102 | - $preg = $recherche_trans . $options['preg_flags']; |
|
| 103 | - $is_preg = true; |
|
| 104 | - } else { |
|
| 105 | - // s'il y a plusieurs mots il faut les chercher tous : oblige REGEXP, |
|
| 106 | - // sauf ceux de moins de 4 lettres (on supprime ainsi 'le', 'les', 'un', |
|
| 107 | - // 'une', 'des' ...) |
|
| 108 | - |
|
| 109 | - // attention : plusieurs mots entre guillemets sont a rechercher tels quels |
|
| 110 | - $recherche_trans = $recherche_mod = $recherche_org = $recherche; |
|
| 111 | - |
|
| 112 | - // les expressions entre " " sont un mot a chercher tel quel |
|
| 113 | - // -> on remplace les espaces par un \x1 et on enleve les guillemets |
|
| 114 | - if (preg_match(',["][^"]+["],Uims', $recherche_mod, $matches)) { |
|
| 115 | - foreach ($matches as $match) { |
|
| 116 | - $word = preg_replace(',\s+,Uims', "\x1", $match); |
|
| 117 | - $word = trim($word, '"'); |
|
| 118 | - $recherche_mod = str_replace($match, $word, $recherche_mod); |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - if (preg_match(',\s+,' . $u, $recherche_mod)) { |
|
| 123 | - $is_preg = true; |
|
| 124 | - |
|
| 125 | - $recherche_inter = '|'; |
|
| 126 | - $recherche_mots = explode(' ', $recherche_mod); |
|
| 127 | - $min_long = defined('_RECHERCHE_MIN_CAR') ? _RECHERCHE_MIN_CAR : 4; |
|
| 128 | - $petits_mots = true; |
|
| 129 | - foreach ($recherche_mots as $mot) { |
|
| 130 | - if (strlen($mot) >= $min_long) { |
|
| 131 | - // echapper les caracteres de regexp qui sont eventuellement dans la recherche |
|
| 132 | - $recherche_inter .= preg_quote($mot) . ' '; |
|
| 133 | - $petits_mots = false; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - $recherche_inter = str_replace("\x1", '\s', $recherche_inter); |
|
| 137 | - |
|
| 138 | - // mais on cherche quand même l'expression complète, même si elle |
|
| 139 | - // comporte des mots de moins de quatre lettres |
|
| 140 | - $recherche = trim(preg_replace(',\s+,' . $u, '|', $recherche_inter), '|'); |
|
| 141 | - if (!$recherche or $petits_mots) { |
|
| 142 | - $recherche = preg_quote($recherche_org); |
|
| 143 | - } |
|
| 144 | - $recherche_trans = translitteration($recherche); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - $preg = '/' . str_replace('/', '\\/', $recherche_trans) . '/' . $options['preg_flags']; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - // Si la chaine est inactive, on va utiliser LIKE pour aller plus vite |
|
| 151 | - // ou si l'expression reguliere est invalide |
|
| 152 | - if ( |
|
| 153 | - !$is_preg |
|
| 154 | - or (@preg_match($preg, '') === false) |
|
| 155 | - ) { |
|
| 156 | - $methode = 'LIKE'; |
|
| 157 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 158 | - |
|
| 159 | - // echapper les % et _ |
|
| 160 | - $q = str_replace(['%', '_'], ['\%', '\_'], trim($recherche)); |
|
| 161 | - |
|
| 162 | - // eviter les parentheses et autres caractères qui interferent avec pcre par la suite (dans le preg_match_all) s'il y a des reponses |
|
| 163 | - $recherche = preg_quote($recherche, '/'); |
|
| 164 | - $recherche_trans = translitteration($recherche); |
|
| 165 | - $recherche_mod = $recherche_trans; |
|
| 166 | - |
|
| 167 | - // les expressions entre " " sont un mot a chercher tel quel |
|
| 168 | - // -> on remplace les espaces par un _ et on enleve les guillemets |
|
| 169 | - // corriger le like dans le $q |
|
| 170 | - if (preg_match(',["][^"]+["],Uims', $q, $matches)) { |
|
| 171 | - foreach ($matches as $match) { |
|
| 172 | - $word = preg_replace(',\s+,Uims', '_', $match); |
|
| 173 | - $word = trim($word, '"'); |
|
| 174 | - $q = str_replace($match, $word, $q); |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - // corriger la regexp |
|
| 178 | - if (preg_match(',["][^"]+["],Uims', $recherche_mod, $matches)) { |
|
| 179 | - foreach ($matches as $match) { |
|
| 180 | - $word = preg_replace(',\s+,Uims', '[\s]', $match); |
|
| 181 | - $word = trim($word, '"'); |
|
| 182 | - $recherche_mod = str_replace($match, $word, $recherche_mod); |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - $q = sql_quote( |
|
| 186 | - '%' |
|
| 187 | - . preg_replace(',\s+,' . $u, '%', $q) |
|
| 188 | - . '%' |
|
| 189 | - ); |
|
| 190 | - |
|
| 191 | - $preg = '/' . preg_replace(',\s+,' . $u, '.+', trim($recherche_mod)) . '/' . $options['preg_flags']; |
|
| 192 | - } else { |
|
| 193 | - $methode = 'REGEXP'; |
|
| 194 | - $q = sql_quote(trim($recherche, '/')); |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - // tous les caracteres transliterables de $q sont remplaces par un joker |
|
| 198 | - // permet de matcher en SQL meme si on est sensible aux accents (SQLite) |
|
| 199 | - $q_t = $q; |
|
| 200 | - for ($i = 0; $i < spip_strlen($q); $i++) { |
|
| 201 | - $char = spip_substr($q, $i, 1); |
|
| 202 | - if ( |
|
| 203 | - !is_ascii($char) |
|
| 204 | - and $char_t = translitteration($char) |
|
| 205 | - and $char_t !== $char |
|
| 206 | - ) { |
|
| 207 | - // on utilise ..?.? car le char utf peut etre encode sur 1, 2 ou 3 bytes |
|
| 208 | - // mais c'est un pis aller cf #4354 |
|
| 209 | - $q_t = str_replace($char, $is_preg ? '..?.?' : '_', $q_t); |
|
| 210 | - } |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - $q = $q_t; |
|
| 214 | - |
|
| 215 | - // fix : SQLite 3 est sensible aux accents, on jokerise les caracteres |
|
| 216 | - // les plus frequents qui peuvent etre accentues |
|
| 217 | - // (oui c'est tres dicustable...) |
|
| 218 | - if ( |
|
| 219 | - isset($GLOBALS['connexions'][$options['serveur'] ?: 0]['type']) |
|
| 220 | - and strncmp($GLOBALS['connexions'][$options['serveur'] ?: 0]['type'], 'sqlite', 6) == 0 |
|
| 221 | - ) { |
|
| 222 | - $q_t = strtr($q, 'aeuioc', $is_preg ? '......' : '______'); |
|
| 223 | - // si il reste au moins un char significatif... |
|
| 224 | - if (preg_match(",[^'%_.],", $q_t)) { |
|
| 225 | - $q = $q_t; |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - return $expression[$key] = [$methode, $q, $preg]; |
|
| 79 | + // ne calculer qu'une seule fois l'expression par hit |
|
| 80 | + // (meme si utilisee dans plusieurs boucles) |
|
| 81 | + static $expression = []; |
|
| 82 | + $key = serialize([$recherche, $options['preg_flags']]); |
|
| 83 | + if (isset($expression[$key])) { |
|
| 84 | + return $expression[$key]; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 88 | + if ($u and strpos($options['preg_flags'], (string) $u) === false) { |
|
| 89 | + $options['preg_flags'] .= $u; |
|
| 90 | + } |
|
| 91 | + include_spip('inc/charsets'); |
|
| 92 | + $recherche = trim($recherche); |
|
| 93 | + |
|
| 94 | + // retirer les + de +truc et les * de truc* |
|
| 95 | + $recherche = preg_replace(',(^|\s)\+(\w),Uims', '$1$2', $recherche); |
|
| 96 | + $recherche = preg_replace(',(\w)\*($|\s),Uims', '$1$2', $recherche); |
|
| 97 | + |
|
| 98 | + $is_preg = false; |
|
| 99 | + if (substr($recherche, 0, 1) == '/' and substr($recherche, -1, 1) == '/' and strlen($recherche) > 2) { |
|
| 100 | + // c'est une preg |
|
| 101 | + $recherche_trans = translitteration($recherche); |
|
| 102 | + $preg = $recherche_trans . $options['preg_flags']; |
|
| 103 | + $is_preg = true; |
|
| 104 | + } else { |
|
| 105 | + // s'il y a plusieurs mots il faut les chercher tous : oblige REGEXP, |
|
| 106 | + // sauf ceux de moins de 4 lettres (on supprime ainsi 'le', 'les', 'un', |
|
| 107 | + // 'une', 'des' ...) |
|
| 108 | + |
|
| 109 | + // attention : plusieurs mots entre guillemets sont a rechercher tels quels |
|
| 110 | + $recherche_trans = $recherche_mod = $recherche_org = $recherche; |
|
| 111 | + |
|
| 112 | + // les expressions entre " " sont un mot a chercher tel quel |
|
| 113 | + // -> on remplace les espaces par un \x1 et on enleve les guillemets |
|
| 114 | + if (preg_match(',["][^"]+["],Uims', $recherche_mod, $matches)) { |
|
| 115 | + foreach ($matches as $match) { |
|
| 116 | + $word = preg_replace(',\s+,Uims', "\x1", $match); |
|
| 117 | + $word = trim($word, '"'); |
|
| 118 | + $recherche_mod = str_replace($match, $word, $recherche_mod); |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + if (preg_match(',\s+,' . $u, $recherche_mod)) { |
|
| 123 | + $is_preg = true; |
|
| 124 | + |
|
| 125 | + $recherche_inter = '|'; |
|
| 126 | + $recherche_mots = explode(' ', $recherche_mod); |
|
| 127 | + $min_long = defined('_RECHERCHE_MIN_CAR') ? _RECHERCHE_MIN_CAR : 4; |
|
| 128 | + $petits_mots = true; |
|
| 129 | + foreach ($recherche_mots as $mot) { |
|
| 130 | + if (strlen($mot) >= $min_long) { |
|
| 131 | + // echapper les caracteres de regexp qui sont eventuellement dans la recherche |
|
| 132 | + $recherche_inter .= preg_quote($mot) . ' '; |
|
| 133 | + $petits_mots = false; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + $recherche_inter = str_replace("\x1", '\s', $recherche_inter); |
|
| 137 | + |
|
| 138 | + // mais on cherche quand même l'expression complète, même si elle |
|
| 139 | + // comporte des mots de moins de quatre lettres |
|
| 140 | + $recherche = trim(preg_replace(',\s+,' . $u, '|', $recherche_inter), '|'); |
|
| 141 | + if (!$recherche or $petits_mots) { |
|
| 142 | + $recherche = preg_quote($recherche_org); |
|
| 143 | + } |
|
| 144 | + $recherche_trans = translitteration($recherche); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + $preg = '/' . str_replace('/', '\\/', $recherche_trans) . '/' . $options['preg_flags']; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + // Si la chaine est inactive, on va utiliser LIKE pour aller plus vite |
|
| 151 | + // ou si l'expression reguliere est invalide |
|
| 152 | + if ( |
|
| 153 | + !$is_preg |
|
| 154 | + or (@preg_match($preg, '') === false) |
|
| 155 | + ) { |
|
| 156 | + $methode = 'LIKE'; |
|
| 157 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 158 | + |
|
| 159 | + // echapper les % et _ |
|
| 160 | + $q = str_replace(['%', '_'], ['\%', '\_'], trim($recherche)); |
|
| 161 | + |
|
| 162 | + // eviter les parentheses et autres caractères qui interferent avec pcre par la suite (dans le preg_match_all) s'il y a des reponses |
|
| 163 | + $recherche = preg_quote($recherche, '/'); |
|
| 164 | + $recherche_trans = translitteration($recherche); |
|
| 165 | + $recherche_mod = $recherche_trans; |
|
| 166 | + |
|
| 167 | + // les expressions entre " " sont un mot a chercher tel quel |
|
| 168 | + // -> on remplace les espaces par un _ et on enleve les guillemets |
|
| 169 | + // corriger le like dans le $q |
|
| 170 | + if (preg_match(',["][^"]+["],Uims', $q, $matches)) { |
|
| 171 | + foreach ($matches as $match) { |
|
| 172 | + $word = preg_replace(',\s+,Uims', '_', $match); |
|
| 173 | + $word = trim($word, '"'); |
|
| 174 | + $q = str_replace($match, $word, $q); |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + // corriger la regexp |
|
| 178 | + if (preg_match(',["][^"]+["],Uims', $recherche_mod, $matches)) { |
|
| 179 | + foreach ($matches as $match) { |
|
| 180 | + $word = preg_replace(',\s+,Uims', '[\s]', $match); |
|
| 181 | + $word = trim($word, '"'); |
|
| 182 | + $recherche_mod = str_replace($match, $word, $recherche_mod); |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + $q = sql_quote( |
|
| 186 | + '%' |
|
| 187 | + . preg_replace(',\s+,' . $u, '%', $q) |
|
| 188 | + . '%' |
|
| 189 | + ); |
|
| 190 | + |
|
| 191 | + $preg = '/' . preg_replace(',\s+,' . $u, '.+', trim($recherche_mod)) . '/' . $options['preg_flags']; |
|
| 192 | + } else { |
|
| 193 | + $methode = 'REGEXP'; |
|
| 194 | + $q = sql_quote(trim($recherche, '/')); |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + // tous les caracteres transliterables de $q sont remplaces par un joker |
|
| 198 | + // permet de matcher en SQL meme si on est sensible aux accents (SQLite) |
|
| 199 | + $q_t = $q; |
|
| 200 | + for ($i = 0; $i < spip_strlen($q); $i++) { |
|
| 201 | + $char = spip_substr($q, $i, 1); |
|
| 202 | + if ( |
|
| 203 | + !is_ascii($char) |
|
| 204 | + and $char_t = translitteration($char) |
|
| 205 | + and $char_t !== $char |
|
| 206 | + ) { |
|
| 207 | + // on utilise ..?.? car le char utf peut etre encode sur 1, 2 ou 3 bytes |
|
| 208 | + // mais c'est un pis aller cf #4354 |
|
| 209 | + $q_t = str_replace($char, $is_preg ? '..?.?' : '_', $q_t); |
|
| 210 | + } |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + $q = $q_t; |
|
| 214 | + |
|
| 215 | + // fix : SQLite 3 est sensible aux accents, on jokerise les caracteres |
|
| 216 | + // les plus frequents qui peuvent etre accentues |
|
| 217 | + // (oui c'est tres dicustable...) |
|
| 218 | + if ( |
|
| 219 | + isset($GLOBALS['connexions'][$options['serveur'] ?: 0]['type']) |
|
| 220 | + and strncmp($GLOBALS['connexions'][$options['serveur'] ?: 0]['type'], 'sqlite', 6) == 0 |
|
| 221 | + ) { |
|
| 222 | + $q_t = strtr($q, 'aeuioc', $is_preg ? '......' : '______'); |
|
| 223 | + // si il reste au moins un char significatif... |
|
| 224 | + if (preg_match(",[^'%_.],", $q_t)) { |
|
| 225 | + $q = $q_t; |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + return $expression[$key] = [$methode, $q, $preg]; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | |
@@ -253,142 +253,142 @@ discard block |
||
| 253 | 253 | * @return array |
| 254 | 254 | */ |
| 255 | 255 | function recherche_en_base($recherche = '', $tables = null, $options = [], $serveur = '') { |
| 256 | - include_spip('base/abstract_sql'); |
|
| 257 | - |
|
| 258 | - if (!is_array($tables)) { |
|
| 259 | - $liste = liste_des_champs(); |
|
| 260 | - |
|
| 261 | - if ( |
|
| 262 | - is_string($tables) |
|
| 263 | - and $tables != '' |
|
| 264 | - ) { |
|
| 265 | - $toutes = []; |
|
| 266 | - foreach (explode(',', $tables) as $t) { |
|
| 267 | - $t = trim($t); |
|
| 268 | - if (isset($liste[$t])) { |
|
| 269 | - $toutes[$t] = $liste[$t]; |
|
| 270 | - } |
|
| 271 | - } |
|
| 272 | - $tables = $toutes; |
|
| 273 | - unset($toutes); |
|
| 274 | - } else { |
|
| 275 | - $tables = $liste; |
|
| 276 | - } |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - if (!strlen($recherche) or !count($tables)) { |
|
| 280 | - return []; |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - include_spip('inc/autoriser'); |
|
| 284 | - |
|
| 285 | - // options par defaut |
|
| 286 | - $options = array_merge( |
|
| 287 | - [ |
|
| 288 | - 'preg_flags' => 'UimsS', |
|
| 289 | - 'toutvoir' => false, |
|
| 290 | - 'champs' => false, |
|
| 291 | - 'score' => false, |
|
| 292 | - 'matches' => false, |
|
| 293 | - 'jointures' => false, |
|
| 294 | - 'serveur' => $serveur |
|
| 295 | - ], |
|
| 296 | - $options |
|
| 297 | - ); |
|
| 298 | - |
|
| 299 | - $results = []; |
|
| 300 | - |
|
| 301 | - // Utiliser l'iterateur (DATA:recherche) |
|
| 302 | - // pour recuperer les couples (id_objet, score) |
|
| 303 | - // Le resultat est au format { |
|
| 304 | - // id1 = { 'score' => x, attrs => { } }, |
|
| 305 | - // id2 = { 'score' => x, attrs => { } }, |
|
| 306 | - // } |
|
| 307 | - |
|
| 308 | - include_spip('inc/recherche_to_array'); |
|
| 309 | - |
|
| 310 | - foreach ($tables as $table => $champs) { |
|
| 311 | - # lock via memoization, si dispo |
|
| 312 | - if (function_exists('cache_lock')) { |
|
| 313 | - cache_lock($lock = _RECHERCHE_LOCK_KEY . ' ' . $table . ' ' . $recherche); |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - spip_timer('rech'); |
|
| 317 | - |
|
| 318 | - # TODO : ici plutot charger un iterateur via l'API iterateurs |
|
| 319 | - $to_array = charger_fonction('recherche_to_array', 'inc'); |
|
| 320 | - $results[$table] = $to_array( |
|
| 321 | - $recherche, |
|
| 322 | - array_merge($options, ['table' => $table, 'champs' => $champs]) |
|
| 323 | - ); |
|
| 324 | - ##var_dump($results[$table]); |
|
| 325 | - |
|
| 326 | - |
|
| 327 | - spip_log( |
|
| 328 | - "recherche $table ($recherche) : " . (is_countable($results[$table]) ? count($results[$table]) : 0) . ' resultats ' . spip_timer('rech'), |
|
| 329 | - 'recherche' |
|
| 330 | - ); |
|
| 331 | - |
|
| 332 | - if (isset($lock)) { |
|
| 333 | - cache_unlock($lock); |
|
| 334 | - } |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - return $results; |
|
| 256 | + include_spip('base/abstract_sql'); |
|
| 257 | + |
|
| 258 | + if (!is_array($tables)) { |
|
| 259 | + $liste = liste_des_champs(); |
|
| 260 | + |
|
| 261 | + if ( |
|
| 262 | + is_string($tables) |
|
| 263 | + and $tables != '' |
|
| 264 | + ) { |
|
| 265 | + $toutes = []; |
|
| 266 | + foreach (explode(',', $tables) as $t) { |
|
| 267 | + $t = trim($t); |
|
| 268 | + if (isset($liste[$t])) { |
|
| 269 | + $toutes[$t] = $liste[$t]; |
|
| 270 | + } |
|
| 271 | + } |
|
| 272 | + $tables = $toutes; |
|
| 273 | + unset($toutes); |
|
| 274 | + } else { |
|
| 275 | + $tables = $liste; |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + if (!strlen($recherche) or !count($tables)) { |
|
| 280 | + return []; |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + include_spip('inc/autoriser'); |
|
| 284 | + |
|
| 285 | + // options par defaut |
|
| 286 | + $options = array_merge( |
|
| 287 | + [ |
|
| 288 | + 'preg_flags' => 'UimsS', |
|
| 289 | + 'toutvoir' => false, |
|
| 290 | + 'champs' => false, |
|
| 291 | + 'score' => false, |
|
| 292 | + 'matches' => false, |
|
| 293 | + 'jointures' => false, |
|
| 294 | + 'serveur' => $serveur |
|
| 295 | + ], |
|
| 296 | + $options |
|
| 297 | + ); |
|
| 298 | + |
|
| 299 | + $results = []; |
|
| 300 | + |
|
| 301 | + // Utiliser l'iterateur (DATA:recherche) |
|
| 302 | + // pour recuperer les couples (id_objet, score) |
|
| 303 | + // Le resultat est au format { |
|
| 304 | + // id1 = { 'score' => x, attrs => { } }, |
|
| 305 | + // id2 = { 'score' => x, attrs => { } }, |
|
| 306 | + // } |
|
| 307 | + |
|
| 308 | + include_spip('inc/recherche_to_array'); |
|
| 309 | + |
|
| 310 | + foreach ($tables as $table => $champs) { |
|
| 311 | + # lock via memoization, si dispo |
|
| 312 | + if (function_exists('cache_lock')) { |
|
| 313 | + cache_lock($lock = _RECHERCHE_LOCK_KEY . ' ' . $table . ' ' . $recherche); |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + spip_timer('rech'); |
|
| 317 | + |
|
| 318 | + # TODO : ici plutot charger un iterateur via l'API iterateurs |
|
| 319 | + $to_array = charger_fonction('recherche_to_array', 'inc'); |
|
| 320 | + $results[$table] = $to_array( |
|
| 321 | + $recherche, |
|
| 322 | + array_merge($options, ['table' => $table, 'champs' => $champs]) |
|
| 323 | + ); |
|
| 324 | + ##var_dump($results[$table]); |
|
| 325 | + |
|
| 326 | + |
|
| 327 | + spip_log( |
|
| 328 | + "recherche $table ($recherche) : " . (is_countable($results[$table]) ? count($results[$table]) : 0) . ' resultats ' . spip_timer('rech'), |
|
| 329 | + 'recherche' |
|
| 330 | + ); |
|
| 331 | + |
|
| 332 | + if (isset($lock)) { |
|
| 333 | + cache_unlock($lock); |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + return $results; |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | |
| 341 | 341 | // Effectue une recherche sur toutes les tables de la base de donnees |
| 342 | 342 | function remplace_en_base($recherche = '', $remplace = null, $tables = null, $options = []) { |
| 343 | - include_spip('inc/modifier'); |
|
| 344 | - |
|
| 345 | - // options par defaut |
|
| 346 | - $options = array_merge( |
|
| 347 | - [ |
|
| 348 | - 'preg_flags' => 'UimsS', |
|
| 349 | - 'toutmodifier' => false |
|
| 350 | - ], |
|
| 351 | - $options |
|
| 352 | - ); |
|
| 353 | - $options['champs'] = true; |
|
| 354 | - |
|
| 355 | - |
|
| 356 | - if (!is_array($tables)) { |
|
| 357 | - $tables = liste_des_champs(); |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - $results = recherche_en_base($recherche, $tables, $options); |
|
| 361 | - |
|
| 362 | - $preg = '/' . str_replace('/', '\\/', $recherche) . '/' . $options['preg_flags']; |
|
| 363 | - |
|
| 364 | - foreach ($results as $table => $r) { |
|
| 365 | - $_id_table = id_table_objet($table); |
|
| 366 | - foreach ($r as $id => $x) { |
|
| 367 | - if ( |
|
| 368 | - $options['toutmodifier'] |
|
| 369 | - or autoriser('modifier', $table, $id) |
|
| 370 | - ) { |
|
| 371 | - $modifs = []; |
|
| 372 | - foreach ($x['champs'] as $key => $val) { |
|
| 373 | - if ($key == $_id_table) { |
|
| 374 | - continue; |
|
| 375 | - } |
|
| 376 | - $repl = preg_replace($preg, $remplace, $val); |
|
| 377 | - if ($repl <> $val) { |
|
| 378 | - $modifs[$key] = $repl; |
|
| 379 | - } |
|
| 380 | - } |
|
| 381 | - if ($modifs) { |
|
| 382 | - objet_modifier_champs( |
|
| 383 | - $table, |
|
| 384 | - $id, |
|
| 385 | - [ |
|
| 386 | - 'champs' => array_keys($modifs), |
|
| 387 | - ], |
|
| 388 | - $modifs |
|
| 389 | - ); |
|
| 390 | - } |
|
| 391 | - } |
|
| 392 | - } |
|
| 393 | - } |
|
| 343 | + include_spip('inc/modifier'); |
|
| 344 | + |
|
| 345 | + // options par defaut |
|
| 346 | + $options = array_merge( |
|
| 347 | + [ |
|
| 348 | + 'preg_flags' => 'UimsS', |
|
| 349 | + 'toutmodifier' => false |
|
| 350 | + ], |
|
| 351 | + $options |
|
| 352 | + ); |
|
| 353 | + $options['champs'] = true; |
|
| 354 | + |
|
| 355 | + |
|
| 356 | + if (!is_array($tables)) { |
|
| 357 | + $tables = liste_des_champs(); |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + $results = recherche_en_base($recherche, $tables, $options); |
|
| 361 | + |
|
| 362 | + $preg = '/' . str_replace('/', '\\/', $recherche) . '/' . $options['preg_flags']; |
|
| 363 | + |
|
| 364 | + foreach ($results as $table => $r) { |
|
| 365 | + $_id_table = id_table_objet($table); |
|
| 366 | + foreach ($r as $id => $x) { |
|
| 367 | + if ( |
|
| 368 | + $options['toutmodifier'] |
|
| 369 | + or autoriser('modifier', $table, $id) |
|
| 370 | + ) { |
|
| 371 | + $modifs = []; |
|
| 372 | + foreach ($x['champs'] as $key => $val) { |
|
| 373 | + if ($key == $_id_table) { |
|
| 374 | + continue; |
|
| 375 | + } |
|
| 376 | + $repl = preg_replace($preg, $remplace, $val); |
|
| 377 | + if ($repl <> $val) { |
|
| 378 | + $modifs[$key] = $repl; |
|
| 379 | + } |
|
| 380 | + } |
|
| 381 | + if ($modifs) { |
|
| 382 | + objet_modifier_champs( |
|
| 383 | + $table, |
|
| 384 | + $id, |
|
| 385 | + [ |
|
| 386 | + 'champs' => array_keys($modifs), |
|
| 387 | + ], |
|
| 388 | + $modifs |
|
| 389 | + ); |
|
| 390 | + } |
|
| 391 | + } |
|
| 392 | + } |
|
| 393 | + } |
|
| 394 | 394 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | $n = 0; |
| 46 | 46 | $time = $GLOBALS['meta']['cache_mark'] ?? 0; |
| 47 | 47 | for ($i = 0; $i < 256; $i++) { |
| 48 | - $dir = _DIR_CACHE . sprintf('%02s', dechex($i)); |
|
| 48 | + $dir = _DIR_CACHE.sprintf('%02s', dechex($i)); |
|
| 49 | 49 | if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
| 50 | 50 | while (($f = readdir($d)) !== false) { |
| 51 | 51 | if (preg_match(',^[[0-9a-f]+\.cache$,S', $f) and $a = stat("$dir/$f")) { |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | // stocker la date_modif_$objet (ne sert a rien pour le moment) |
| 104 | 104 | if (isset($objet)) { |
| 105 | - ecrire_meta('derniere_modif_' . $objet, time()); |
|
| 105 | + ecrire_meta('derniere_modif_'.$objet, time()); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // si $derniere_modif_invalide est un array('article', 'rubrique') |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | // sur certains sites on veut absolument garder certains caches référencés dans un CDN |
| 147 | 147 | // on peut donc inhiber la purge de ces répertoires pour eviter tout probleme |
| 148 | - if (file_exists(rtrim($dir, '/') . '/inhib_purger_repertoire.txt')) { |
|
| 148 | + if (file_exists(rtrim($dir, '/').'/inhib_purger_repertoire.txt')) { |
|
| 149 | 149 | return 0; |
| 150 | 150 | } |
| 151 | 151 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | ) |
| 209 | 209 | ) { |
| 210 | 210 | // supprimer le fichier (de facon propre) |
| 211 | - supprimer_fichier(_DIR_CACHE . $cache); |
|
| 211 | + supprimer_fichier(_DIR_CACHE.$cache); |
|
| 212 | 212 | } else { |
| 213 | 213 | spip_log("Nom de fichier cache incorrect : $cache"); |
| 214 | 214 | } |
@@ -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('base/serial'); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * en droit de l'éliminer |
| 28 | 28 | */ |
| 29 | 29 | if (!defined('_AGE_CACHE_ATIME')) { |
| 30 | - define('_AGE_CACHE_ATIME', 3600); |
|
| 30 | + define('_AGE_CACHE_ATIME', 3600); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
@@ -40,31 +40,31 @@ discard block |
||
| 40 | 40 | * @return int Taille approximative en octets |
| 41 | 41 | **/ |
| 42 | 42 | function taille_du_cache() { |
| 43 | - # check dirs until we reach > 500 files |
|
| 44 | - $t = 0; |
|
| 45 | - $n = 0; |
|
| 46 | - $time = $GLOBALS['meta']['cache_mark'] ?? 0; |
|
| 47 | - for ($i = 0; $i < 256; $i++) { |
|
| 48 | - $dir = _DIR_CACHE . sprintf('%02s', dechex($i)); |
|
| 49 | - if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 50 | - while (($f = readdir($d)) !== false) { |
|
| 51 | - if (preg_match(',^[[0-9a-f]+\.cache$,S', $f) and $a = stat("$dir/$f")) { |
|
| 52 | - $n++; |
|
| 53 | - if ($a['mtime'] >= $time) { |
|
| 54 | - if ($a['blocks'] > 0) { |
|
| 55 | - $t += 512 * $a['blocks']; |
|
| 56 | - } else { |
|
| 57 | - $t += $a['size']; |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - if ($n > 500) { |
|
| 64 | - return intval(256 * $t / (1 + $i)); |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - return $t; |
|
| 43 | + # check dirs until we reach > 500 files |
|
| 44 | + $t = 0; |
|
| 45 | + $n = 0; |
|
| 46 | + $time = $GLOBALS['meta']['cache_mark'] ?? 0; |
|
| 47 | + for ($i = 0; $i < 256; $i++) { |
|
| 48 | + $dir = _DIR_CACHE . sprintf('%02s', dechex($i)); |
|
| 49 | + if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 50 | + while (($f = readdir($d)) !== false) { |
|
| 51 | + if (preg_match(',^[[0-9a-f]+\.cache$,S', $f) and $a = stat("$dir/$f")) { |
|
| 52 | + $n++; |
|
| 53 | + if ($a['mtime'] >= $time) { |
|
| 54 | + if ($a['blocks'] > 0) { |
|
| 55 | + $t += 512 * $a['blocks']; |
|
| 56 | + } else { |
|
| 57 | + $t += $a['size']; |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + if ($n > 500) { |
|
| 64 | + return intval(256 * $t / (1 + $i)); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + return $t; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | |
@@ -91,30 +91,30 @@ discard block |
||
| 91 | 91 | * Inutilisé |
| 92 | 92 | **/ |
| 93 | 93 | function inc_suivre_invalideur_dist($cond, $modif = true) { |
| 94 | - if (!$modif) { |
|
| 95 | - return; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - // determiner l'objet modifie : forum, article, etc |
|
| 99 | - if (preg_match(',["\']([a-z_]+)[/"\'],', $cond, $r)) { |
|
| 100 | - $objet = objet_type($r[1]); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - // stocker la date_modif_$objet (ne sert a rien pour le moment) |
|
| 104 | - if (isset($objet)) { |
|
| 105 | - ecrire_meta('derniere_modif_' . $objet, time()); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - // si $derniere_modif_invalide est un array('article', 'rubrique') |
|
| 109 | - // n'affecter la meta que si un de ces objets est modifie |
|
| 110 | - if (is_array($GLOBALS['derniere_modif_invalide'])) { |
|
| 111 | - if (in_array($objet, $GLOBALS['derniere_modif_invalide'])) { |
|
| 112 | - ecrire_meta('derniere_modif', time()); |
|
| 113 | - } |
|
| 114 | - } // sinon, cas standard, toujours affecter la meta |
|
| 115 | - else { |
|
| 116 | - ecrire_meta('derniere_modif', time()); |
|
| 117 | - } |
|
| 94 | + if (!$modif) { |
|
| 95 | + return; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + // determiner l'objet modifie : forum, article, etc |
|
| 99 | + if (preg_match(',["\']([a-z_]+)[/"\'],', $cond, $r)) { |
|
| 100 | + $objet = objet_type($r[1]); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + // stocker la date_modif_$objet (ne sert a rien pour le moment) |
|
| 104 | + if (isset($objet)) { |
|
| 105 | + ecrire_meta('derniere_modif_' . $objet, time()); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + // si $derniere_modif_invalide est un array('article', 'rubrique') |
|
| 109 | + // n'affecter la meta que si un de ces objets est modifie |
|
| 110 | + if (is_array($GLOBALS['derniere_modif_invalide'])) { |
|
| 111 | + if (in_array($objet, $GLOBALS['derniere_modif_invalide'])) { |
|
| 112 | + ecrire_meta('derniere_modif', time()); |
|
| 113 | + } |
|
| 114 | + } // sinon, cas standard, toujours affecter la meta |
|
| 115 | + else { |
|
| 116 | + ecrire_meta('derniere_modif', time()); |
|
| 117 | + } |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
@@ -139,57 +139,57 @@ discard block |
||
| 139 | 139 | * Nombre de fichiers supprimés |
| 140 | 140 | **/ |
| 141 | 141 | function purger_repertoire($dir, $options = []) { |
| 142 | - if (!is_dir($dir) or !is_readable($dir)) { |
|
| 143 | - return 0; |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - // sur certains sites on veut absolument garder certains caches référencés dans un CDN |
|
| 147 | - // on peut donc inhiber la purge de ces répertoires pour eviter tout probleme |
|
| 148 | - if (file_exists(rtrim($dir, '/') . '/inhib_purger_repertoire.txt')) { |
|
| 149 | - return 0; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - $handle = opendir($dir); |
|
| 153 | - if (!$handle) { |
|
| 154 | - return 0; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - $total = 0; |
|
| 158 | - |
|
| 159 | - while (($fichier = @readdir($handle)) !== false) { |
|
| 160 | - // Eviter ".", "..", ".htaccess", ".svn" etc & CACHEDIR.TAG |
|
| 161 | - if ($fichier[0] == '.' or $fichier == 'CACHEDIR.TAG') { |
|
| 162 | - continue; |
|
| 163 | - } |
|
| 164 | - $chemin = "$dir/$fichier"; |
|
| 165 | - if (is_file($chemin)) { |
|
| 166 | - if ( |
|
| 167 | - (!isset($options['atime']) or (@fileatime($chemin) < $options['atime'])) |
|
| 168 | - and (!isset($options['mtime']) or (@filemtime($chemin) < $options['mtime'])) |
|
| 169 | - ) { |
|
| 170 | - supprimer_fichier($chemin); |
|
| 171 | - $total++; |
|
| 172 | - } |
|
| 173 | - } else { |
|
| 174 | - if (is_dir($chemin)) { |
|
| 175 | - $opts = $options; |
|
| 176 | - if (isset($options['limit'])) { |
|
| 177 | - $opts['limit'] = $options['limit'] - $total; |
|
| 178 | - } |
|
| 179 | - $total += purger_repertoire($chemin, $opts); |
|
| 180 | - if (isset($options['subdir']) && $options['subdir']) { |
|
| 181 | - spip_unlink($chemin); |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - if (isset($options['limit']) and $total >= $options['limit']) { |
|
| 187 | - break; |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - closedir($handle); |
|
| 191 | - |
|
| 192 | - return $total; |
|
| 142 | + if (!is_dir($dir) or !is_readable($dir)) { |
|
| 143 | + return 0; |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + // sur certains sites on veut absolument garder certains caches référencés dans un CDN |
|
| 147 | + // on peut donc inhiber la purge de ces répertoires pour eviter tout probleme |
|
| 148 | + if (file_exists(rtrim($dir, '/') . '/inhib_purger_repertoire.txt')) { |
|
| 149 | + return 0; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + $handle = opendir($dir); |
|
| 153 | + if (!$handle) { |
|
| 154 | + return 0; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + $total = 0; |
|
| 158 | + |
|
| 159 | + while (($fichier = @readdir($handle)) !== false) { |
|
| 160 | + // Eviter ".", "..", ".htaccess", ".svn" etc & CACHEDIR.TAG |
|
| 161 | + if ($fichier[0] == '.' or $fichier == 'CACHEDIR.TAG') { |
|
| 162 | + continue; |
|
| 163 | + } |
|
| 164 | + $chemin = "$dir/$fichier"; |
|
| 165 | + if (is_file($chemin)) { |
|
| 166 | + if ( |
|
| 167 | + (!isset($options['atime']) or (@fileatime($chemin) < $options['atime'])) |
|
| 168 | + and (!isset($options['mtime']) or (@filemtime($chemin) < $options['mtime'])) |
|
| 169 | + ) { |
|
| 170 | + supprimer_fichier($chemin); |
|
| 171 | + $total++; |
|
| 172 | + } |
|
| 173 | + } else { |
|
| 174 | + if (is_dir($chemin)) { |
|
| 175 | + $opts = $options; |
|
| 176 | + if (isset($options['limit'])) { |
|
| 177 | + $opts['limit'] = $options['limit'] - $total; |
|
| 178 | + } |
|
| 179 | + $total += purger_repertoire($chemin, $opts); |
|
| 180 | + if (isset($options['subdir']) && $options['subdir']) { |
|
| 181 | + spip_unlink($chemin); |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + if (isset($options['limit']) and $total >= $options['limit']) { |
|
| 187 | + break; |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + closedir($handle); |
|
| 191 | + |
|
| 192 | + return $total; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | |
@@ -200,26 +200,26 @@ discard block |
||
| 200 | 200 | // Securite : est sur que c'est un cache |
| 201 | 201 | function retire_cache($cache) { |
| 202 | 202 | |
| 203 | - if ( |
|
| 204 | - preg_match( |
|
| 205 | - ',^([0-9a-f]/)?([0-9]+/)?[0-9a-f]+\.cache(\.gz)?$,i', |
|
| 206 | - $cache |
|
| 207 | - ) |
|
| 208 | - ) { |
|
| 209 | - // supprimer le fichier (de facon propre) |
|
| 210 | - supprimer_fichier(_DIR_CACHE . $cache); |
|
| 211 | - } else { |
|
| 212 | - spip_log("Nom de fichier cache incorrect : $cache"); |
|
| 213 | - } |
|
| 203 | + if ( |
|
| 204 | + preg_match( |
|
| 205 | + ',^([0-9a-f]/)?([0-9]+/)?[0-9a-f]+\.cache(\.gz)?$,i', |
|
| 206 | + $cache |
|
| 207 | + ) |
|
| 208 | + ) { |
|
| 209 | + // supprimer le fichier (de facon propre) |
|
| 210 | + supprimer_fichier(_DIR_CACHE . $cache); |
|
| 211 | + } else { |
|
| 212 | + spip_log("Nom de fichier cache incorrect : $cache"); |
|
| 213 | + } |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | // Supprimer les caches marques "x" |
| 217 | 217 | // A priori dans cette version la fonction ne sera pas appelee, car |
| 218 | 218 | // la meta est toujours false ; mais evitons un bug si elle est appellee |
| 219 | 219 | function inc_retire_caches_dist($chemin = '') { |
| 220 | - if (isset($GLOBALS['meta']['invalider_caches'])) { |
|
| 221 | - effacer_meta('invalider_caches'); |
|
| 222 | - } # concurrence |
|
| 220 | + if (isset($GLOBALS['meta']['invalider_caches'])) { |
|
| 221 | + effacer_meta('invalider_caches'); |
|
| 222 | + } # concurrence |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | ####################################################################### |
@@ -230,9 +230,9 @@ discard block |
||
| 230 | 230 | ## |
| 231 | 231 | |
| 232 | 232 | function retire_caches($chemin = '') { |
| 233 | - if ($retire_caches = charger_fonction('retire_caches', 'inc', true)) { |
|
| 234 | - return $retire_caches($chemin); |
|
| 235 | - } |
|
| 233 | + if ($retire_caches = charger_fonction('retire_caches', 'inc', true)) { |
|
| 234 | + return $retire_caches($chemin); |
|
| 235 | + } |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | |
@@ -240,10 +240,10 @@ discard block |
||
| 240 | 240 | // (note: si absente, n'est pas appellee) |
| 241 | 241 | |
| 242 | 242 | function calcul_invalideurs($corps, $primary, &$boucles, $id_boucle) { |
| 243 | - if ($calcul_invalideurs = charger_fonction('calcul_invalideurs', 'inc', true)) { |
|
| 244 | - return $calcul_invalideurs($corps, $primary, $boucles, $id_boucle); |
|
| 245 | - } |
|
| 246 | - return $corps; |
|
| 243 | + if ($calcul_invalideurs = charger_fonction('calcul_invalideurs', 'inc', true)) { |
|
| 244 | + return $calcul_invalideurs($corps, $primary, $boucles, $id_boucle); |
|
| 245 | + } |
|
| 246 | + return $corps; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | |
@@ -252,41 +252,41 @@ discard block |
||
| 252 | 252 | // invoquee quand on vide tout le cache en bloc (action/purger) |
| 253 | 253 | // |
| 254 | 254 | function supprime_invalideurs() { |
| 255 | - if ($supprime_invalideurs = charger_fonction('supprime_invalideurs', 'inc', true)) { |
|
| 256 | - return $supprime_invalideurs(); |
|
| 257 | - } |
|
| 255 | + if ($supprime_invalideurs = charger_fonction('supprime_invalideurs', 'inc', true)) { |
|
| 256 | + return $supprime_invalideurs(); |
|
| 257 | + } |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | |
| 261 | 261 | // Calcul des pages : noter dans la base les liens d'invalidation |
| 262 | 262 | function maj_invalideurs($fichier, &$page) { |
| 263 | - if ($maj_invalideurs = charger_fonction('maj_invalideurs', 'inc', true)) { |
|
| 264 | - return $maj_invalideurs($fichier, $page); |
|
| 265 | - } |
|
| 263 | + if ($maj_invalideurs = charger_fonction('maj_invalideurs', 'inc', true)) { |
|
| 264 | + return $maj_invalideurs($fichier, $page); |
|
| 265 | + } |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | |
| 269 | 269 | // les invalideurs sont de la forme "objet/id_objet" |
| 270 | 270 | function insere_invalideur($inval, $fichier) { |
| 271 | - if ($insere_invalideur = charger_fonction('insere_invalideur', 'inc', true)) { |
|
| 272 | - return $insere_invalideur($inval, $fichier); |
|
| 273 | - } |
|
| 271 | + if ($insere_invalideur = charger_fonction('insere_invalideur', 'inc', true)) { |
|
| 272 | + return $insere_invalideur($inval, $fichier); |
|
| 273 | + } |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | // |
| 277 | 277 | // Marquer les fichiers caches invalides comme etant a supprimer |
| 278 | 278 | // |
| 279 | 279 | function applique_invalideur($depart) { |
| 280 | - if ($applique_invalideur = charger_fonction('applique_invalideur', 'inc', true)) { |
|
| 281 | - return $applique_invalideur($depart); |
|
| 282 | - } |
|
| 280 | + if ($applique_invalideur = charger_fonction('applique_invalideur', 'inc', true)) { |
|
| 281 | + return $applique_invalideur($depart); |
|
| 282 | + } |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | // |
| 286 | 286 | // Invalider les caches liés à telle condition |
| 287 | 287 | // |
| 288 | 288 | function suivre_invalideur($cond, $modif = true) { |
| 289 | - if ($suivre_invalideur = charger_fonction('suivre_invalideur', 'inc', true)) { |
|
| 290 | - return $suivre_invalideur($cond, $modif); |
|
| 291 | - } |
|
| 289 | + if ($suivre_invalideur = charger_fonction('suivre_invalideur', 'inc', true)) { |
|
| 290 | + return $suivre_invalideur($cond, $modif); |
|
| 291 | + } |
|
| 292 | 292 | } |