@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/config'); |
@@ -37,26 +37,26 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | function exec_admin_plugin_dist($retour = '') { |
| 39 | 39 | |
| 40 | - if (!autoriser('configurer', '_plugins')) { |
|
| 41 | - include_spip('inc/minipres'); |
|
| 42 | - echo minipres(); |
|
| 43 | - } else { |
|
| 44 | - // on fait la verif du path avant tout, |
|
| 45 | - // et l'installation des qu'on est dans la colonne principale |
|
| 46 | - // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
|
| 47 | - // pour etre sur que les bons fichiers seront charges lors de l'install |
|
| 48 | - $new = actualise_plugins_actifs(); |
|
| 49 | - if ($new and _request('actualise') < 2) { |
|
| 50 | - include_spip('inc/headers'); |
|
| 51 | - if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 52 | - // attendre eventuellement l'invalidation du cache opcode |
|
| 53 | - spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 54 | - } |
|
| 55 | - redirige_par_entete(parametre_url(self(), 'actualise', _request('actualise') + 1, '&')); |
|
| 56 | - } else { |
|
| 57 | - admin_plug_args(_request('voir'), _request('erreur'), _request('format')); |
|
| 58 | - } |
|
| 59 | - } |
|
| 40 | + if (!autoriser('configurer', '_plugins')) { |
|
| 41 | + include_spip('inc/minipres'); |
|
| 42 | + echo minipres(); |
|
| 43 | + } else { |
|
| 44 | + // on fait la verif du path avant tout, |
|
| 45 | + // et l'installation des qu'on est dans la colonne principale |
|
| 46 | + // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
|
| 47 | + // pour etre sur que les bons fichiers seront charges lors de l'install |
|
| 48 | + $new = actualise_plugins_actifs(); |
|
| 49 | + if ($new and _request('actualise') < 2) { |
|
| 50 | + include_spip('inc/headers'); |
|
| 51 | + if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 52 | + // attendre eventuellement l'invalidation du cache opcode |
|
| 53 | + spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 54 | + } |
|
| 55 | + redirige_par_entete(parametre_url(self(), 'actualise', _request('actualise') + 1, '&')); |
|
| 56 | + } else { |
|
| 57 | + admin_plug_args(_request('voir'), _request('erreur'), _request('format')); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -81,132 +81,132 @@ discard block |
||
| 81 | 81 | * Format d'affichage (liste ou arborescence) |
| 82 | 82 | **/ |
| 83 | 83 | function admin_plug_args($quoi, $erreur, $format) { |
| 84 | - $lpf = null; |
|
| 85 | - $lcpas = null; |
|
| 86 | - $lcpaffichesup = null; |
|
| 87 | - if (!$quoi) { |
|
| 88 | - $quoi = 'actifs'; |
|
| 89 | - } |
|
| 90 | - // empecher l'affichage des erreurs dans le bandeau, on le donne ensuite |
|
| 91 | - // format brut par plugin |
|
| 92 | - $GLOBALS['erreurs_activation_raw'] = plugin_donne_erreurs(true, false); |
|
| 93 | - // format resume mis en forme |
|
| 94 | - $erreur_activation = plugin_donne_erreurs(); |
|
| 95 | - $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 96 | - echo $commencer_page(_T('icone_admin_plugin'), 'configuration', 'plugin'); |
|
| 97 | - |
|
| 98 | - echo debut_gauche(); |
|
| 99 | - echo recuperer_fond('prive/squelettes/navigation/configurer', ['exec' => 'admin_plugin']); |
|
| 100 | - |
|
| 101 | - echo pipeline( |
|
| 102 | - 'affiche_gauche', |
|
| 103 | - [ |
|
| 104 | - 'args' => ['exec' => 'admin_plugin'], |
|
| 105 | - 'data' => afficher_librairies() |
|
| 106 | - ] |
|
| 107 | - ); |
|
| 108 | - |
|
| 109 | - echo debut_droite(); |
|
| 110 | - echo gros_titre(_T('icone_admin_plugin'), ''); |
|
| 111 | - |
|
| 112 | - // Barre d'onglets de premier niveau |
|
| 113 | - echo barre_onglets('plugins', 'plugins_actifs'); |
|
| 114 | - // Barre d'onglets de second niveau |
|
| 115 | - $onglet2 = $quoi == 'actifs' ? 'plugins_actifs' : 'admin_plugin'; |
|
| 116 | - echo debut_onglet('onglets_simple second'); |
|
| 117 | - echo onglet(_T('plugins_tous_liste'), generer_url_ecrire('admin_plugin', 'voir=tous'), 'admin_plugin', $onglet2); |
|
| 118 | - echo onglet(_T('plugins_actifs_liste'), generer_url_ecrire('admin_plugin'), 'plugins_actifs', $onglet2); |
|
| 119 | - echo fin_onglet(); |
|
| 120 | - |
|
| 121 | - // message d'erreur au retour d'une operation |
|
| 122 | - if ($erreur) { |
|
| 123 | - echo "<div class='error'>$erreur</div>"; |
|
| 124 | - } |
|
| 125 | - if ($erreur_activation) { |
|
| 126 | - echo "<div class='error'>$erreur_activation</div>"; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - // la mise a jour de cette meta a ete faite par ecrire_plugin_actifs |
|
| 130 | - $actifs = (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'>$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 | } |
@@ -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 | // Authentifie via LDAP et retourne la ligne SQL decrivant l'utilisateur si ok |
@@ -25,12 +25,12 @@ discard block |
||
| 25 | 25 | // Attributs LDAP correspondants a ceux de SPIP, notamment pour le login |
| 26 | 26 | // ne pas ecraser une definition perso dans mes_options |
| 27 | 27 | if (!isset($GLOBALS['ldap_attributes']) or !is_array($GLOBALS['ldap_attributes'])) { |
| 28 | - $GLOBALS['ldap_attributes'] = [ |
|
| 29 | - 'login' => ['sAMAccountName', 'uid', 'login', 'userid', 'cn', 'sn'], |
|
| 30 | - 'nom' => 'cn', |
|
| 31 | - 'email' => 'mail', |
|
| 32 | - 'bio' => 'description' |
|
| 33 | - ]; |
|
| 28 | + $GLOBALS['ldap_attributes'] = [ |
|
| 29 | + 'login' => ['sAMAccountName', 'uid', 'login', 'userid', 'cn', 'sn'], |
|
| 30 | + 'nom' => 'cn', |
|
| 31 | + 'email' => 'mail', |
|
| 32 | + 'bio' => 'description' |
|
| 33 | + ]; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -56,50 +56,50 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | function auth_ldap_dist($login, $pass, $serveur = '', $phpauth = false) { |
| 58 | 58 | |
| 59 | - #spip_log("ldap $login " . ($pass ? "mdp fourni" : "mdp absent")); |
|
| 60 | - |
|
| 61 | - // Utilisateur connu ? |
|
| 62 | - // si http auth, inutile de reauthentifier: cela |
|
| 63 | - // ne marchera pas avec auth http autre que basic. |
|
| 64 | - $checkpass = isset($_SERVER['REMOTE_USER']) ? false : true; |
|
| 65 | - if (!($dn = auth_ldap_search($login, $pass, $checkpass, $serveur))) { |
|
| 66 | - return []; |
|
| 67 | - } |
|
| 68 | - $credentials_ldap = ['ldap_dn' => $dn, 'ldap_password' => $pass]; |
|
| 69 | - |
|
| 70 | - // Si l'utilisateur figure deja dans la base, y recuperer les infos |
|
| 71 | - $r = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login) . " AND source='ldap'", '', '', '', '', $serveur); |
|
| 72 | - |
|
| 73 | - if ($r) { |
|
| 74 | - return array_merge($r, $credentials_ldap); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - // sinon importer les infos depuis LDAP, |
|
| 78 | - |
|
| 79 | - if ( |
|
| 80 | - $GLOBALS['meta']['ldap_statut_import'] |
|
| 81 | - and $desc = auth_ldap_retrouver($dn, [], $serveur) |
|
| 82 | - ) { |
|
| 83 | - // rajouter le statut indique a l'install |
|
| 84 | - $desc['statut'] = $GLOBALS['meta']['ldap_statut_import']; |
|
| 85 | - $desc['login'] = $login; |
|
| 86 | - $desc['source'] = 'ldap'; |
|
| 87 | - $desc['pass'] = ''; |
|
| 88 | - |
|
| 89 | - $r = sql_insertq('spip_auteurs', $desc, [], $serveur); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - if ($r) { |
|
| 93 | - return array_merge( |
|
| 94 | - $credentials_ldap, |
|
| 95 | - sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($r), '', '', '', '', $serveur) |
|
| 96 | - ); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - // sinon echec |
|
| 100 | - spip_log("Creation de l'auteur '$login' impossible"); |
|
| 101 | - |
|
| 102 | - return []; |
|
| 59 | + #spip_log("ldap $login " . ($pass ? "mdp fourni" : "mdp absent")); |
|
| 60 | + |
|
| 61 | + // Utilisateur connu ? |
|
| 62 | + // si http auth, inutile de reauthentifier: cela |
|
| 63 | + // ne marchera pas avec auth http autre que basic. |
|
| 64 | + $checkpass = isset($_SERVER['REMOTE_USER']) ? false : true; |
|
| 65 | + if (!($dn = auth_ldap_search($login, $pass, $checkpass, $serveur))) { |
|
| 66 | + return []; |
|
| 67 | + } |
|
| 68 | + $credentials_ldap = ['ldap_dn' => $dn, 'ldap_password' => $pass]; |
|
| 69 | + |
|
| 70 | + // Si l'utilisateur figure deja dans la base, y recuperer les infos |
|
| 71 | + $r = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login) . " AND source='ldap'", '', '', '', '', $serveur); |
|
| 72 | + |
|
| 73 | + if ($r) { |
|
| 74 | + return array_merge($r, $credentials_ldap); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + // sinon importer les infos depuis LDAP, |
|
| 78 | + |
|
| 79 | + if ( |
|
| 80 | + $GLOBALS['meta']['ldap_statut_import'] |
|
| 81 | + and $desc = auth_ldap_retrouver($dn, [], $serveur) |
|
| 82 | + ) { |
|
| 83 | + // rajouter le statut indique a l'install |
|
| 84 | + $desc['statut'] = $GLOBALS['meta']['ldap_statut_import']; |
|
| 85 | + $desc['login'] = $login; |
|
| 86 | + $desc['source'] = 'ldap'; |
|
| 87 | + $desc['pass'] = ''; |
|
| 88 | + |
|
| 89 | + $r = sql_insertq('spip_auteurs', $desc, [], $serveur); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + if ($r) { |
|
| 93 | + return array_merge( |
|
| 94 | + $credentials_ldap, |
|
| 95 | + sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($r), '', '', '', '', $serveur) |
|
| 96 | + ); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + // sinon echec |
|
| 100 | + spip_log("Creation de l'auteur '$login' impossible"); |
|
| 101 | + |
|
| 102 | + return []; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -113,36 +113,36 @@ discard block |
||
| 113 | 113 | * @return array |
| 114 | 114 | */ |
| 115 | 115 | function auth_ldap_connect($serveur = '') { |
| 116 | - include_spip('base/connect_sql'); |
|
| 117 | - static $connexions_ldap = []; |
|
| 118 | - if (isset($connexions_ldap[$serveur])) { |
|
| 119 | - return $connexions_ldap[$serveur]; |
|
| 120 | - } |
|
| 121 | - $connexion = spip_connect($serveur); |
|
| 122 | - if (!is_array($connexion['ldap'])) { |
|
| 123 | - if ($connexion['authentification']['ldap']) { |
|
| 124 | - $f = _DIR_CONNECT . $connexion['authentification']['ldap']; |
|
| 125 | - unset($GLOBALS['ldap_link']); |
|
| 126 | - if (is_readable($f)) { |
|
| 127 | - include_once($f); |
|
| 128 | - }; |
|
| 129 | - if (isset($GLOBALS['ldap_link'])) { |
|
| 130 | - $connexion['ldap'] = [ |
|
| 131 | - 'link' => $GLOBALS['ldap_link'], |
|
| 132 | - 'base' => $GLOBALS['ldap_base'] |
|
| 133 | - ]; |
|
| 134 | - } else { |
|
| 135 | - spip_log("connection LDAP $serveur mal definie dans $f"); |
|
| 136 | - } |
|
| 137 | - if (isset($GLOBALS['ldap_champs'])) { |
|
| 138 | - $connexion['ldap']['attributes'] = $GLOBALS['ldap_champs']; |
|
| 139 | - } |
|
| 140 | - } else { |
|
| 141 | - spip_log("connection LDAP $serveur inconnue"); |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - return $connexions_ldap[$serveur] = $connexion['ldap']; |
|
| 116 | + include_spip('base/connect_sql'); |
|
| 117 | + static $connexions_ldap = []; |
|
| 118 | + if (isset($connexions_ldap[$serveur])) { |
|
| 119 | + return $connexions_ldap[$serveur]; |
|
| 120 | + } |
|
| 121 | + $connexion = spip_connect($serveur); |
|
| 122 | + if (!is_array($connexion['ldap'])) { |
|
| 123 | + if ($connexion['authentification']['ldap']) { |
|
| 124 | + $f = _DIR_CONNECT . $connexion['authentification']['ldap']; |
|
| 125 | + unset($GLOBALS['ldap_link']); |
|
| 126 | + if (is_readable($f)) { |
|
| 127 | + include_once($f); |
|
| 128 | + }; |
|
| 129 | + if (isset($GLOBALS['ldap_link'])) { |
|
| 130 | + $connexion['ldap'] = [ |
|
| 131 | + 'link' => $GLOBALS['ldap_link'], |
|
| 132 | + 'base' => $GLOBALS['ldap_base'] |
|
| 133 | + ]; |
|
| 134 | + } else { |
|
| 135 | + spip_log("connection LDAP $serveur mal definie dans $f"); |
|
| 136 | + } |
|
| 137 | + if (isset($GLOBALS['ldap_champs'])) { |
|
| 138 | + $connexion['ldap']['attributes'] = $GLOBALS['ldap_champs']; |
|
| 139 | + } |
|
| 140 | + } else { |
|
| 141 | + spip_log("connection LDAP $serveur inconnue"); |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + return $connexions_ldap[$serveur] = $connexion['ldap']; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -156,52 +156,52 @@ discard block |
||
| 156 | 156 | * Le login trouvé ou chaine vide si non trouvé |
| 157 | 157 | */ |
| 158 | 158 | function auth_ldap_search($login, $pass, $checkpass = true, $serveur = '') { |
| 159 | - // Securite anti-injection et contre un serveur LDAP laxiste |
|
| 160 | - $login_search = preg_replace('/[^-@._\s\d\w]/', '', $login); |
|
| 161 | - if (!strlen($login_search) or ($checkpass and !strlen($pass))) { |
|
| 162 | - return ''; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - // verifier la connexion |
|
| 166 | - if (!$ldap = auth_ldap_connect($serveur)) { |
|
| 167 | - return ''; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - $ldap_link = $ldap['link'] ?? null; |
|
| 171 | - $ldap_base = $ldap['base'] ?? null; |
|
| 172 | - $desc = !empty($ldap['attributes']) ? $ldap['attributes'] : $GLOBALS['ldap_attributes']; |
|
| 173 | - |
|
| 174 | - $logins = is_array($desc['login']) ? $desc['login'] : [$desc['login']]; |
|
| 175 | - |
|
| 176 | - // Tenter une recherche pour essayer de retrouver le DN |
|
| 177 | - foreach ($logins as $att) { |
|
| 178 | - $result = @ldap_search($ldap_link, $ldap_base, "$att=$login_search", ['dn']); |
|
| 179 | - $info = @ldap_get_entries($ldap_link, $result); |
|
| 180 | - // Ne pas accepter les resultats si plus d'une entree |
|
| 181 | - // (on veut un attribut unique) |
|
| 182 | - |
|
| 183 | - if (is_array($info) and $info['count'] == 1) { |
|
| 184 | - $dn = $info[0]['dn']; |
|
| 185 | - if (!$checkpass) { |
|
| 186 | - return $dn; |
|
| 187 | - } |
|
| 188 | - if (@ldap_bind($ldap_link, $dn, $pass)) { |
|
| 189 | - return $dn; |
|
| 190 | - } |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - if ($checkpass and !isset($dn)) { |
|
| 195 | - // Si echec, essayer de deviner le DN |
|
| 196 | - foreach ($logins as $att) { |
|
| 197 | - $dn = "$att=$login_search, $ldap_base"; |
|
| 198 | - if (@ldap_bind($ldap_link, $dn, $pass)) { |
|
| 199 | - return "$att=$login_search, $ldap_base"; |
|
| 200 | - } |
|
| 201 | - } |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - return ''; |
|
| 159 | + // Securite anti-injection et contre un serveur LDAP laxiste |
|
| 160 | + $login_search = preg_replace('/[^-@._\s\d\w]/', '', $login); |
|
| 161 | + if (!strlen($login_search) or ($checkpass and !strlen($pass))) { |
|
| 162 | + return ''; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + // verifier la connexion |
|
| 166 | + if (!$ldap = auth_ldap_connect($serveur)) { |
|
| 167 | + return ''; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + $ldap_link = $ldap['link'] ?? null; |
|
| 171 | + $ldap_base = $ldap['base'] ?? null; |
|
| 172 | + $desc = !empty($ldap['attributes']) ? $ldap['attributes'] : $GLOBALS['ldap_attributes']; |
|
| 173 | + |
|
| 174 | + $logins = is_array($desc['login']) ? $desc['login'] : [$desc['login']]; |
|
| 175 | + |
|
| 176 | + // Tenter une recherche pour essayer de retrouver le DN |
|
| 177 | + foreach ($logins as $att) { |
|
| 178 | + $result = @ldap_search($ldap_link, $ldap_base, "$att=$login_search", ['dn']); |
|
| 179 | + $info = @ldap_get_entries($ldap_link, $result); |
|
| 180 | + // Ne pas accepter les resultats si plus d'une entree |
|
| 181 | + // (on veut un attribut unique) |
|
| 182 | + |
|
| 183 | + if (is_array($info) and $info['count'] == 1) { |
|
| 184 | + $dn = $info[0]['dn']; |
|
| 185 | + if (!$checkpass) { |
|
| 186 | + return $dn; |
|
| 187 | + } |
|
| 188 | + if (@ldap_bind($ldap_link, $dn, $pass)) { |
|
| 189 | + return $dn; |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + if ($checkpass and !isset($dn)) { |
|
| 195 | + // Si echec, essayer de deviner le DN |
|
| 196 | + foreach ($logins as $att) { |
|
| 197 | + $dn = "$att=$login_search, $ldap_base"; |
|
| 198 | + if (@ldap_bind($ldap_link, $dn, $pass)) { |
|
| 199 | + return "$att=$login_search, $ldap_base"; |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + return ''; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -213,40 +213,40 @@ discard block |
||
| 213 | 213 | * @return array |
| 214 | 214 | */ |
| 215 | 215 | function auth_ldap_retrouver($dn, $desc = [], $serveur = '') { |
| 216 | - // Lire les infos sur l'utilisateur a partir de son DN depuis LDAP |
|
| 216 | + // Lire les infos sur l'utilisateur a partir de son DN depuis LDAP |
|
| 217 | 217 | |
| 218 | - if (!$ldap = auth_ldap_connect($serveur)) { |
|
| 219 | - spip_log("ldap $serveur injoignable"); |
|
| 218 | + if (!$ldap = auth_ldap_connect($serveur)) { |
|
| 219 | + spip_log("ldap $serveur injoignable"); |
|
| 220 | 220 | |
| 221 | - return []; |
|
| 222 | - } |
|
| 221 | + return []; |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - $ldap_link = $ldap['link']; |
|
| 225 | - if (!$desc) { |
|
| 226 | - $desc = $ldap['attributes'] ?: $GLOBALS['ldap_attributes']; |
|
| 227 | - unset($desc['login']); |
|
| 228 | - } |
|
| 229 | - $result = @ldap_read($ldap_link, $dn, 'objectClass=*', array_values($desc)); |
|
| 224 | + $ldap_link = $ldap['link']; |
|
| 225 | + if (!$desc) { |
|
| 226 | + $desc = $ldap['attributes'] ?: $GLOBALS['ldap_attributes']; |
|
| 227 | + unset($desc['login']); |
|
| 228 | + } |
|
| 229 | + $result = @ldap_read($ldap_link, $dn, 'objectClass=*', array_values($desc)); |
|
| 230 | 230 | |
| 231 | - if (!$result) { |
|
| 232 | - return []; |
|
| 233 | - } |
|
| 231 | + if (!$result) { |
|
| 232 | + return []; |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - // Recuperer les donnees du premier (unique?) compte de l'auteur |
|
| 236 | - $val = @ldap_get_entries($ldap_link, $result); |
|
| 237 | - if (!is_array($val) or !is_array($val[0])) { |
|
| 238 | - return []; |
|
| 239 | - } |
|
| 240 | - $val = $val[0]; |
|
| 235 | + // Recuperer les donnees du premier (unique?) compte de l'auteur |
|
| 236 | + $val = @ldap_get_entries($ldap_link, $result); |
|
| 237 | + if (!is_array($val) or !is_array($val[0])) { |
|
| 238 | + return []; |
|
| 239 | + } |
|
| 240 | + $val = $val[0]; |
|
| 241 | 241 | |
| 242 | - // Convertir depuis UTF-8 (jeu de caracteres par defaut) |
|
| 243 | - include_spip('inc/charsets'); |
|
| 242 | + // Convertir depuis UTF-8 (jeu de caracteres par defaut) |
|
| 243 | + include_spip('inc/charsets'); |
|
| 244 | 244 | |
| 245 | - foreach ($desc as $k => $v) { |
|
| 246 | - $desc[$k] = importer_charset($val[strtolower($v)][0], 'utf-8'); |
|
| 247 | - } |
|
| 245 | + foreach ($desc as $k => $v) { |
|
| 246 | + $desc[$k] = importer_charset($val[strtolower($v)][0], 'utf-8'); |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - return $desc; |
|
| 249 | + return $desc; |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | * @return string |
| 259 | 259 | */ |
| 260 | 260 | function auth_ldap_retrouver_login($login, $serveur = '') { |
| 261 | - return auth_ldap_search($login, '', false, $serveur) ? $login : ''; |
|
| 261 | + return auth_ldap_search($login, '', false, $serveur) ? $login : ''; |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
@@ -278,9 +278,9 @@ discard block |
||
| 278 | 278 | * Message d'erreur si login non valide, chaîne vide sinon |
| 279 | 279 | */ |
| 280 | 280 | function auth_ldap_verifier_pass($login, $new_pass, $id_auteur = 0, $serveur = '') { |
| 281 | - include_spip('auth/spip'); |
|
| 281 | + include_spip('auth/spip'); |
|
| 282 | 282 | |
| 283 | - return auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur); |
|
| 283 | + return auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * ``` |
| 302 | 302 | */ |
| 303 | 303 | function auth_ldap_autoriser_modifier_pass($serveur = '') { |
| 304 | - return true; |
|
| 304 | + return true; |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | /** |
@@ -319,23 +319,23 @@ discard block |
||
| 319 | 319 | * Informe du succès ou de l'echec du changement du mot de passe |
| 320 | 320 | */ |
| 321 | 321 | function auth_ldap_modifier_pass($login, $new_pass, $id_auteur, $serveur = '') { |
| 322 | - if (is_null($new_pass) or auth_ldap_verifier_pass($login, $new_pass, $id_auteur, $serveur) != '') { |
|
| 323 | - return false; |
|
| 324 | - } |
|
| 325 | - if (!$ldap = auth_ldap_connect($serveur)) { |
|
| 326 | - return false; |
|
| 327 | - } |
|
| 328 | - $link = $ldap['link']; |
|
| 329 | - include_spip('inc/session'); |
|
| 330 | - $dn = session_get('ldap_dn'); |
|
| 331 | - if ('' == $dn) { |
|
| 332 | - return false; |
|
| 333 | - } |
|
| 334 | - if (!ldap_bind($link, $dn, session_get('ldap_password'))) { |
|
| 335 | - return false; |
|
| 336 | - } |
|
| 337 | - $encoded_pass = '{MD5}' . base64_encode(pack('H*', md5($new_pass))); |
|
| 338 | - $success = ldap_mod_replace($link, $dn, ['userPassword' => $encoded_pass]); |
|
| 339 | - |
|
| 340 | - return $success; |
|
| 322 | + if (is_null($new_pass) or auth_ldap_verifier_pass($login, $new_pass, $id_auteur, $serveur) != '') { |
|
| 323 | + return false; |
|
| 324 | + } |
|
| 325 | + if (!$ldap = auth_ldap_connect($serveur)) { |
|
| 326 | + return false; |
|
| 327 | + } |
|
| 328 | + $link = $ldap['link']; |
|
| 329 | + include_spip('inc/session'); |
|
| 330 | + $dn = session_get('ldap_dn'); |
|
| 331 | + if ('' == $dn) { |
|
| 332 | + return false; |
|
| 333 | + } |
|
| 334 | + if (!ldap_bind($link, $dn, session_get('ldap_password'))) { |
|
| 335 | + return false; |
|
| 336 | + } |
|
| 337 | + $encoded_pass = '{MD5}' . base64_encode(pack('H*', md5($new_pass))); |
|
| 338 | + $success = ldap_mod_replace($link, $dn, ['userPassword' => $encoded_pass]); |
|
| 339 | + |
|
| 340 | + return $success; |
|
| 341 | 341 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\SQL |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | require_once _ROOT_RESTREINT . 'base/objets.php'; |
| 22 | 22 | |
@@ -42,118 +42,118 @@ discard block |
||
| 42 | 42 | **/ |
| 43 | 43 | function spip_connect($serveur = '', $version = '') { |
| 44 | 44 | |
| 45 | - $serveur = !is_string($serveur) ? '' : strtolower($serveur); |
|
| 46 | - $index = $serveur ?: 0; |
|
| 47 | - if (!$version) { |
|
| 48 | - $version = $GLOBALS['spip_sql_version']; |
|
| 49 | - } |
|
| 50 | - if (isset($GLOBALS['connexions'][$index][$version])) { |
|
| 51 | - return $GLOBALS['connexions'][$index]; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - include_spip('base/abstract_sql'); |
|
| 55 | - $install = (_request('exec') == 'install'); |
|
| 56 | - |
|
| 57 | - // Premiere connexion ? |
|
| 58 | - if (!($old = isset($GLOBALS['connexions'][$index]))) { |
|
| 59 | - $f = (!preg_match('/^[\w\.]*$/', $serveur)) |
|
| 60 | - ? '' // nom de serveur mal ecrit |
|
| 61 | - : ($serveur ? |
|
| 62 | - (_DIR_CONNECT . $serveur . '.php') // serveur externe |
|
| 63 | - : (_FILE_CONNECT ?: ($install ? _FILE_CONNECT_TMP // init du serveur principal |
|
| 64 | - : ''))); // installation pas faite |
|
| 65 | - |
|
| 66 | - unset($GLOBALS['db_ok']); |
|
| 67 | - unset($GLOBALS['spip_connect_version']); |
|
| 68 | - if ($f) { |
|
| 69 | - if (is_readable($f)) { |
|
| 70 | - include($f); |
|
| 71 | - } elseif ($serveur and !$install) { |
|
| 72 | - // chercher une declaration de serveur dans le path |
|
| 73 | - // qui pourra un jour servir a declarer des bases sqlite |
|
| 74 | - // par des plugins. Et sert aussi aux boucles POUR. |
|
| 75 | - find_in_path("$serveur.php", 'connect/', true); |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - if (!isset($GLOBALS['db_ok'])) { |
|
| 79 | - // fera mieux la prochaine fois |
|
| 80 | - if ($install) { |
|
| 81 | - return false; |
|
| 82 | - } |
|
| 83 | - if ($f and is_readable($f)) { |
|
| 84 | - spip_log("spip_connect: fichier de connexion '$f' OK.", _LOG_INFO_IMPORTANTE); |
|
| 85 | - } else { |
|
| 86 | - spip_log("spip_connect: fichier de connexion '$f' non trouve", _LOG_INFO_IMPORTANTE); |
|
| 87 | - } |
|
| 88 | - spip_log("spip_connect: echec connexion ou serveur $index mal defini dans '$f'.", _LOG_HS); |
|
| 89 | - |
|
| 90 | - // ne plus reessayer si ce n'est pas l'install |
|
| 91 | - return $GLOBALS['connexions'][$index] = false; |
|
| 92 | - } |
|
| 93 | - $GLOBALS['connexions'][$index] = $GLOBALS['db_ok']; |
|
| 94 | - } |
|
| 95 | - // si la connexion a deja ete tentee mais a echoue, le dire! |
|
| 96 | - if (!$GLOBALS['connexions'][$index]) { |
|
| 97 | - return false; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - // la connexion a reussi ou etait deja faite. |
|
| 101 | - // chargement de la version du jeu de fonctions |
|
| 102 | - // si pas dans le fichier par defaut |
|
| 103 | - $type = $GLOBALS['db_ok']['type']; |
|
| 104 | - $jeu = 'spip_' . $type . '_functions_' . $version; |
|
| 105 | - if (!isset($GLOBALS[$jeu])) { |
|
| 106 | - if (!find_in_path($type . '_' . $version . '.php', 'req/', true)) { |
|
| 107 | - spip_log("spip_connect: serveur $index version '$version' non defini pour '$type'", _LOG_HS); |
|
| 108 | - |
|
| 109 | - // ne plus reessayer |
|
| 110 | - return $GLOBALS['connexions'][$index][$version] = []; |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - $GLOBALS['connexions'][$index][$version] = $GLOBALS[$jeu]; |
|
| 114 | - if ($old) { |
|
| 115 | - return $GLOBALS['connexions'][$index]; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - $GLOBALS['connexions'][$index]['spip_connect_version'] = $GLOBALS['spip_connect_version'] ?? 0; |
|
| 119 | - |
|
| 120 | - // initialisation de l'alphabet utilise dans les connexions SQL |
|
| 121 | - // si l'installation l'a determine. |
|
| 122 | - // Celui du serveur principal l'impose aux serveurs secondaires |
|
| 123 | - // s'ils le connaissent |
|
| 124 | - |
|
| 125 | - if (!$serveur) { |
|
| 126 | - $charset = spip_connect_main($GLOBALS[$jeu], $GLOBALS['db_ok']['charset']); |
|
| 127 | - if (!$charset) { |
|
| 128 | - unset($GLOBALS['connexions'][$index]); |
|
| 129 | - spip_log('spip_connect: absence de charset', _LOG_AVERTISSEMENT); |
|
| 130 | - |
|
| 131 | - return false; |
|
| 132 | - } |
|
| 133 | - } else { |
|
| 134 | - if ($GLOBALS['db_ok']['charset']) { |
|
| 135 | - $charset = $GLOBALS['db_ok']['charset']; |
|
| 136 | - } |
|
| 137 | - // spip_meta n'existe pas toujours dans la base |
|
| 138 | - // C'est le cas d'un dump sqlite par exemple |
|
| 139 | - elseif ( |
|
| 140 | - $GLOBALS['connexions'][$index]['spip_connect_version'] |
|
| 141 | - and sql_showtable('spip_meta', true, $serveur) |
|
| 142 | - and $r = sql_getfetsel('valeur', 'spip_meta', "nom='charset_sql_connexion'", '', '', '', '', $serveur) |
|
| 143 | - ) { |
|
| 144 | - $charset = $r; |
|
| 145 | - } else { |
|
| 146 | - $charset = -1; |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - if ($charset != -1) { |
|
| 150 | - $f = $GLOBALS[$jeu]['set_charset']; |
|
| 151 | - if (function_exists($f)) { |
|
| 152 | - $f($charset, $serveur); |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - return $GLOBALS['connexions'][$index]; |
|
| 45 | + $serveur = !is_string($serveur) ? '' : strtolower($serveur); |
|
| 46 | + $index = $serveur ?: 0; |
|
| 47 | + if (!$version) { |
|
| 48 | + $version = $GLOBALS['spip_sql_version']; |
|
| 49 | + } |
|
| 50 | + if (isset($GLOBALS['connexions'][$index][$version])) { |
|
| 51 | + return $GLOBALS['connexions'][$index]; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + include_spip('base/abstract_sql'); |
|
| 55 | + $install = (_request('exec') == 'install'); |
|
| 56 | + |
|
| 57 | + // Premiere connexion ? |
|
| 58 | + if (!($old = isset($GLOBALS['connexions'][$index]))) { |
|
| 59 | + $f = (!preg_match('/^[\w\.]*$/', $serveur)) |
|
| 60 | + ? '' // nom de serveur mal ecrit |
|
| 61 | + : ($serveur ? |
|
| 62 | + (_DIR_CONNECT . $serveur . '.php') // serveur externe |
|
| 63 | + : (_FILE_CONNECT ?: ($install ? _FILE_CONNECT_TMP // init du serveur principal |
|
| 64 | + : ''))); // installation pas faite |
|
| 65 | + |
|
| 66 | + unset($GLOBALS['db_ok']); |
|
| 67 | + unset($GLOBALS['spip_connect_version']); |
|
| 68 | + if ($f) { |
|
| 69 | + if (is_readable($f)) { |
|
| 70 | + include($f); |
|
| 71 | + } elseif ($serveur and !$install) { |
|
| 72 | + // chercher une declaration de serveur dans le path |
|
| 73 | + // qui pourra un jour servir a declarer des bases sqlite |
|
| 74 | + // par des plugins. Et sert aussi aux boucles POUR. |
|
| 75 | + find_in_path("$serveur.php", 'connect/', true); |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + if (!isset($GLOBALS['db_ok'])) { |
|
| 79 | + // fera mieux la prochaine fois |
|
| 80 | + if ($install) { |
|
| 81 | + return false; |
|
| 82 | + } |
|
| 83 | + if ($f and is_readable($f)) { |
|
| 84 | + spip_log("spip_connect: fichier de connexion '$f' OK.", _LOG_INFO_IMPORTANTE); |
|
| 85 | + } else { |
|
| 86 | + spip_log("spip_connect: fichier de connexion '$f' non trouve", _LOG_INFO_IMPORTANTE); |
|
| 87 | + } |
|
| 88 | + spip_log("spip_connect: echec connexion ou serveur $index mal defini dans '$f'.", _LOG_HS); |
|
| 89 | + |
|
| 90 | + // ne plus reessayer si ce n'est pas l'install |
|
| 91 | + return $GLOBALS['connexions'][$index] = false; |
|
| 92 | + } |
|
| 93 | + $GLOBALS['connexions'][$index] = $GLOBALS['db_ok']; |
|
| 94 | + } |
|
| 95 | + // si la connexion a deja ete tentee mais a echoue, le dire! |
|
| 96 | + if (!$GLOBALS['connexions'][$index]) { |
|
| 97 | + return false; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + // la connexion a reussi ou etait deja faite. |
|
| 101 | + // chargement de la version du jeu de fonctions |
|
| 102 | + // si pas dans le fichier par defaut |
|
| 103 | + $type = $GLOBALS['db_ok']['type']; |
|
| 104 | + $jeu = 'spip_' . $type . '_functions_' . $version; |
|
| 105 | + if (!isset($GLOBALS[$jeu])) { |
|
| 106 | + if (!find_in_path($type . '_' . $version . '.php', 'req/', true)) { |
|
| 107 | + spip_log("spip_connect: serveur $index version '$version' non defini pour '$type'", _LOG_HS); |
|
| 108 | + |
|
| 109 | + // ne plus reessayer |
|
| 110 | + return $GLOBALS['connexions'][$index][$version] = []; |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + $GLOBALS['connexions'][$index][$version] = $GLOBALS[$jeu]; |
|
| 114 | + if ($old) { |
|
| 115 | + return $GLOBALS['connexions'][$index]; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + $GLOBALS['connexions'][$index]['spip_connect_version'] = $GLOBALS['spip_connect_version'] ?? 0; |
|
| 119 | + |
|
| 120 | + // initialisation de l'alphabet utilise dans les connexions SQL |
|
| 121 | + // si l'installation l'a determine. |
|
| 122 | + // Celui du serveur principal l'impose aux serveurs secondaires |
|
| 123 | + // s'ils le connaissent |
|
| 124 | + |
|
| 125 | + if (!$serveur) { |
|
| 126 | + $charset = spip_connect_main($GLOBALS[$jeu], $GLOBALS['db_ok']['charset']); |
|
| 127 | + if (!$charset) { |
|
| 128 | + unset($GLOBALS['connexions'][$index]); |
|
| 129 | + spip_log('spip_connect: absence de charset', _LOG_AVERTISSEMENT); |
|
| 130 | + |
|
| 131 | + return false; |
|
| 132 | + } |
|
| 133 | + } else { |
|
| 134 | + if ($GLOBALS['db_ok']['charset']) { |
|
| 135 | + $charset = $GLOBALS['db_ok']['charset']; |
|
| 136 | + } |
|
| 137 | + // spip_meta n'existe pas toujours dans la base |
|
| 138 | + // C'est le cas d'un dump sqlite par exemple |
|
| 139 | + elseif ( |
|
| 140 | + $GLOBALS['connexions'][$index]['spip_connect_version'] |
|
| 141 | + and sql_showtable('spip_meta', true, $serveur) |
|
| 142 | + and $r = sql_getfetsel('valeur', 'spip_meta', "nom='charset_sql_connexion'", '', '', '', '', $serveur) |
|
| 143 | + ) { |
|
| 144 | + $charset = $r; |
|
| 145 | + } else { |
|
| 146 | + $charset = -1; |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + if ($charset != -1) { |
|
| 150 | + $f = $GLOBALS[$jeu]['set_charset']; |
|
| 151 | + if (function_exists($f)) { |
|
| 152 | + $f($charset, $serveur); |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + return $GLOBALS['connexions'][$index]; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -162,12 +162,12 @@ discard block |
||
| 162 | 162 | * @param string $serveur Nom du connecteur de bdd utilisé |
| 163 | 163 | **/ |
| 164 | 164 | function spip_sql_erreur($serveur = '') { |
| 165 | - $connexion = spip_connect($serveur); |
|
| 166 | - $e = sql_errno($serveur); |
|
| 167 | - $t = ($connexion['type'] ?? 'sql'); |
|
| 168 | - $m = "Erreur $e de $t: " . sql_error($serveur) . "\nin " . sql_error_backtrace() . "\n" . trim($connexion['last']); |
|
| 169 | - $f = $t . $serveur; |
|
| 170 | - spip_log($m, $f . '.' . _LOG_ERREUR); |
|
| 165 | + $connexion = spip_connect($serveur); |
|
| 166 | + $e = sql_errno($serveur); |
|
| 167 | + $t = ($connexion['type'] ?? 'sql'); |
|
| 168 | + $m = "Erreur $e de $t: " . sql_error($serveur) . "\nin " . sql_error_backtrace() . "\n" . trim($connexion['last']); |
|
| 169 | + $f = $t . $serveur; |
|
| 170 | + spip_log($m, $f . '.' . _LOG_ERREUR); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -189,23 +189,23 @@ discard block |
||
| 189 | 189 | * - array : description de la connexion, si l'instruction sql est indisponible pour cette connexion |
| 190 | 190 | **/ |
| 191 | 191 | function spip_connect_sql($version, $ins = '', $serveur = '', $continue = false) { |
| 192 | - $desc = spip_connect($serveur, $version); |
|
| 193 | - if ( |
|
| 194 | - $desc |
|
| 195 | - and $f = ($desc[$version][$ins] ?? '') |
|
| 196 | - and function_exists($f) |
|
| 197 | - ) { |
|
| 198 | - return $f; |
|
| 199 | - } |
|
| 200 | - if ($continue) { |
|
| 201 | - return $desc; |
|
| 202 | - } |
|
| 203 | - if ($ins) { |
|
| 204 | - spip_log("Le serveur '$serveur' version $version n'a pas '$ins'", _LOG_ERREUR); |
|
| 205 | - } |
|
| 206 | - include_spip('inc/minipres'); |
|
| 207 | - echo minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'), ['status' => 503]); |
|
| 208 | - exit; |
|
| 192 | + $desc = spip_connect($serveur, $version); |
|
| 193 | + if ( |
|
| 194 | + $desc |
|
| 195 | + and $f = ($desc[$version][$ins] ?? '') |
|
| 196 | + and function_exists($f) |
|
| 197 | + ) { |
|
| 198 | + return $f; |
|
| 199 | + } |
|
| 200 | + if ($continue) { |
|
| 201 | + return $desc; |
|
| 202 | + } |
|
| 203 | + if ($ins) { |
|
| 204 | + spip_log("Le serveur '$serveur' version $version n'a pas '$ins'", _LOG_ERREUR); |
|
| 205 | + } |
|
| 206 | + include_spip('inc/minipres'); |
|
| 207 | + echo minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'), ['status' => 503]); |
|
| 208 | + exit; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -231,70 +231,70 @@ discard block |
||
| 231 | 231 | * @return array|null Description de la connexion |
| 232 | 232 | */ |
| 233 | 233 | function spip_connect_db( |
| 234 | - $host, |
|
| 235 | - $port, |
|
| 236 | - $login, |
|
| 237 | - $pass, |
|
| 238 | - $db = '', |
|
| 239 | - $type = 'mysql', |
|
| 240 | - $prefixe = '', |
|
| 241 | - $auth = '', |
|
| 242 | - $charset = '' |
|
| 234 | + $host, |
|
| 235 | + $port, |
|
| 236 | + $login, |
|
| 237 | + $pass, |
|
| 238 | + $db = '', |
|
| 239 | + $type = 'mysql', |
|
| 240 | + $prefixe = '', |
|
| 241 | + $auth = '', |
|
| 242 | + $charset = '' |
|
| 243 | 243 | ) { |
| 244 | - // temps avant nouvelle tentative de connexion |
|
| 245 | - // suite a une connection echouee |
|
| 246 | - if (!defined('_CONNECT_RETRY_DELAY')) { |
|
| 247 | - define('_CONNECT_RETRY_DELAY', 30); |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - $f = ''; |
|
| 251 | - // un fichier de identifiant par combinaison (type,host,port,db) |
|
| 252 | - // pour ne pas declarer tout indisponible d'un coup |
|
| 253 | - // si en cours d'installation ou si db=@test@ on ne pose rien |
|
| 254 | - // car c'est un test de connexion |
|
| 255 | - if (!defined('_ECRIRE_INSTALL') and $db !== '@test@') { |
|
| 256 | - $f = _DIR_TMP . $type . '.' . substr(md5($host . $port . $db), 0, 8) . '.out'; |
|
| 257 | - } elseif ($db == '@test@') { |
|
| 258 | - $db = ''; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - if ( |
|
| 262 | - $f |
|
| 263 | - and @file_exists($f) |
|
| 264 | - and (time() - @filemtime($f) < _CONNECT_RETRY_DELAY) |
|
| 265 | - ) { |
|
| 266 | - spip_log("Echec : $f recent. Pas de tentative de connexion", _LOG_HS); |
|
| 267 | - |
|
| 268 | - return null; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - if (!$prefixe) { |
|
| 272 | - $prefixe = $GLOBALS['table_prefix'] ?? $db; |
|
| 273 | - } |
|
| 274 | - $h = charger_fonction($type, 'req', true); |
|
| 275 | - if (!$h) { |
|
| 276 | - spip_log("les requetes $type ne sont pas fournies", _LOG_HS); |
|
| 277 | - |
|
| 278 | - return null; |
|
| 279 | - } |
|
| 280 | - if ($g = $h($host, $port, $login, $pass, $db, $prefixe)) { |
|
| 281 | - if (!is_array($auth)) { |
|
| 282 | - // compatibilite version 0.7 initiale |
|
| 283 | - $g['ldap'] = $auth; |
|
| 284 | - $auth = ['ldap' => $auth]; |
|
| 285 | - } |
|
| 286 | - $g['authentification'] = $auth; |
|
| 287 | - $g['type'] = $type; |
|
| 288 | - $g['charset'] = $charset; |
|
| 289 | - |
|
| 290 | - return $GLOBALS['db_ok'] = $g; |
|
| 291 | - } |
|
| 292 | - // En cas d'indisponibilite du serveur, eviter de le bombarder |
|
| 293 | - if ($f) { |
|
| 294 | - @touch($f); |
|
| 295 | - spip_log("Echec connexion serveur $type : host[$host] port[$port] login[$login] base[$db]", $type . '.' . _LOG_HS); |
|
| 296 | - } |
|
| 297 | - return null; |
|
| 244 | + // temps avant nouvelle tentative de connexion |
|
| 245 | + // suite a une connection echouee |
|
| 246 | + if (!defined('_CONNECT_RETRY_DELAY')) { |
|
| 247 | + define('_CONNECT_RETRY_DELAY', 30); |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + $f = ''; |
|
| 251 | + // un fichier de identifiant par combinaison (type,host,port,db) |
|
| 252 | + // pour ne pas declarer tout indisponible d'un coup |
|
| 253 | + // si en cours d'installation ou si db=@test@ on ne pose rien |
|
| 254 | + // car c'est un test de connexion |
|
| 255 | + if (!defined('_ECRIRE_INSTALL') and $db !== '@test@') { |
|
| 256 | + $f = _DIR_TMP . $type . '.' . substr(md5($host . $port . $db), 0, 8) . '.out'; |
|
| 257 | + } elseif ($db == '@test@') { |
|
| 258 | + $db = ''; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + if ( |
|
| 262 | + $f |
|
| 263 | + and @file_exists($f) |
|
| 264 | + and (time() - @filemtime($f) < _CONNECT_RETRY_DELAY) |
|
| 265 | + ) { |
|
| 266 | + spip_log("Echec : $f recent. Pas de tentative de connexion", _LOG_HS); |
|
| 267 | + |
|
| 268 | + return null; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + if (!$prefixe) { |
|
| 272 | + $prefixe = $GLOBALS['table_prefix'] ?? $db; |
|
| 273 | + } |
|
| 274 | + $h = charger_fonction($type, 'req', true); |
|
| 275 | + if (!$h) { |
|
| 276 | + spip_log("les requetes $type ne sont pas fournies", _LOG_HS); |
|
| 277 | + |
|
| 278 | + return null; |
|
| 279 | + } |
|
| 280 | + if ($g = $h($host, $port, $login, $pass, $db, $prefixe)) { |
|
| 281 | + if (!is_array($auth)) { |
|
| 282 | + // compatibilite version 0.7 initiale |
|
| 283 | + $g['ldap'] = $auth; |
|
| 284 | + $auth = ['ldap' => $auth]; |
|
| 285 | + } |
|
| 286 | + $g['authentification'] = $auth; |
|
| 287 | + $g['type'] = $type; |
|
| 288 | + $g['charset'] = $charset; |
|
| 289 | + |
|
| 290 | + return $GLOBALS['db_ok'] = $g; |
|
| 291 | + } |
|
| 292 | + // En cas d'indisponibilite du serveur, eviter de le bombarder |
|
| 293 | + if ($f) { |
|
| 294 | + @touch($f); |
|
| 295 | + spip_log("Echec connexion serveur $type : host[$host] port[$port] login[$login] base[$db]", $type . '.' . _LOG_HS); |
|
| 296 | + } |
|
| 297 | + return null; |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | |
@@ -326,32 +326,32 @@ discard block |
||
| 326 | 326 | * - nom du charset sinon |
| 327 | 327 | **/ |
| 328 | 328 | function spip_connect_main($connexion, $charset_sql_connexion = '') { |
| 329 | - if ($GLOBALS['spip_connect_version'] < 0.1 and _DIR_RESTREINT) { |
|
| 330 | - include_spip('inc/headers'); |
|
| 331 | - redirige_url_ecrire('upgrade', 'reinstall=oui'); |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - if (!($f = $connexion['select'])) { |
|
| 335 | - return false; |
|
| 336 | - } |
|
| 337 | - // si le charset est fourni, l'utiliser |
|
| 338 | - if ($charset_sql_connexion) { |
|
| 339 | - return $charset_sql_connexion; |
|
| 340 | - } |
|
| 341 | - // sinon on regarde la table spip_meta |
|
| 342 | - // en cas d'erreur select retourne la requette (is_string=true donc) |
|
| 343 | - if ( |
|
| 344 | - !$r = $f('valeur', 'spip_meta', "nom='charset_sql_connexion'") |
|
| 345 | - or is_string($r) |
|
| 346 | - ) { |
|
| 347 | - return false; |
|
| 348 | - } |
|
| 349 | - if (!($f = $connexion['fetch'])) { |
|
| 350 | - return false; |
|
| 351 | - } |
|
| 352 | - $r = $f($r); |
|
| 353 | - |
|
| 354 | - return (isset($r['valeur']) && $r['valeur']) ? $r['valeur'] : -1; |
|
| 329 | + if ($GLOBALS['spip_connect_version'] < 0.1 and _DIR_RESTREINT) { |
|
| 330 | + include_spip('inc/headers'); |
|
| 331 | + redirige_url_ecrire('upgrade', 'reinstall=oui'); |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + if (!($f = $connexion['select'])) { |
|
| 335 | + return false; |
|
| 336 | + } |
|
| 337 | + // si le charset est fourni, l'utiliser |
|
| 338 | + if ($charset_sql_connexion) { |
|
| 339 | + return $charset_sql_connexion; |
|
| 340 | + } |
|
| 341 | + // sinon on regarde la table spip_meta |
|
| 342 | + // en cas d'erreur select retourne la requette (is_string=true donc) |
|
| 343 | + if ( |
|
| 344 | + !$r = $f('valeur', 'spip_meta', "nom='charset_sql_connexion'") |
|
| 345 | + or is_string($r) |
|
| 346 | + ) { |
|
| 347 | + return false; |
|
| 348 | + } |
|
| 349 | + if (!($f = $connexion['fetch'])) { |
|
| 350 | + return false; |
|
| 351 | + } |
|
| 352 | + $r = $f($r); |
|
| 353 | + |
|
| 354 | + return (isset($r['valeur']) && $r['valeur']) ? $r['valeur'] : -1; |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | /** |
@@ -367,9 +367,9 @@ discard block |
||
| 367 | 367 | * @return array |
| 368 | 368 | */ |
| 369 | 369 | function spip_connect_ldap($serveur = '') { |
| 370 | - include_spip('auth/ldap'); |
|
| 370 | + include_spip('auth/ldap'); |
|
| 371 | 371 | |
| 372 | - return auth_ldap_connect($serveur); |
|
| 372 | + return auth_ldap_connect($serveur); |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /** |
@@ -385,16 +385,16 @@ discard block |
||
| 385 | 385 | * @return string Valeur échappée. |
| 386 | 386 | **/ |
| 387 | 387 | function _q($a): string { |
| 388 | - if (is_numeric($a)) { |
|
| 389 | - return strval($a); |
|
| 390 | - } elseif (is_array($a)) { |
|
| 391 | - return join(',', array_map('_q', $a)); |
|
| 392 | - } elseif (is_scalar($a)) { |
|
| 393 | - return ("'" . addslashes($a) . "'"); |
|
| 394 | - } elseif ($a === null) { |
|
| 395 | - return "''"; |
|
| 396 | - } |
|
| 397 | - throw new \RuntimeException("Can’t use _q with " . gettype($a)); |
|
| 388 | + if (is_numeric($a)) { |
|
| 389 | + return strval($a); |
|
| 390 | + } elseif (is_array($a)) { |
|
| 391 | + return join(',', array_map('_q', $a)); |
|
| 392 | + } elseif (is_scalar($a)) { |
|
| 393 | + return ("'" . addslashes($a) . "'"); |
|
| 394 | + } elseif ($a === null) { |
|
| 395 | + return "''"; |
|
| 396 | + } |
|
| 397 | + throw new \RuntimeException("Can’t use _q with " . gettype($a)); |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | /** |
@@ -410,73 +410,73 @@ discard block |
||
| 410 | 410 | * @return array |
| 411 | 411 | */ |
| 412 | 412 | function query_echappe_textes($query, $uniqid = null) { |
| 413 | - static $codeEchappements = null; |
|
| 414 | - if (is_null($codeEchappements) or $uniqid) { |
|
| 415 | - if (is_null($uniqid)) { |
|
| 416 | - $uniqid = uniqid(); |
|
| 417 | - } |
|
| 418 | - $uniqid = substr(md5($uniqid), 0, 4); |
|
| 419 | - $codeEchappements = ['\\\\' => "\x1@#{$uniqid}#@\x1", "\\'" => "\x2@#{$uniqid}#@\x2", '\\"' => "\x3@#{$uniqid}#@\x3", '%' => "\x4@#{$uniqid}#@\x4"]; |
|
| 420 | - } |
|
| 421 | - if ($query === null) { |
|
| 422 | - return $codeEchappements; |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - // si la query contient deja des codes d'echappement on va s'emmeler les pinceaux et donc on ne touche a rien |
|
| 426 | - // ce n'est pas un cas legitime |
|
| 427 | - foreach ($codeEchappements as $codeEchappement) { |
|
| 428 | - if (strpos($query, (string) $codeEchappement) !== false) { |
|
| 429 | - return [$query, []]; |
|
| 430 | - } |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - $query_echappees = str_replace(array_keys($codeEchappements), array_values($codeEchappements), $query); |
|
| 434 | - if (preg_match_all("/('[^']*')|(\"[^\"]*\")/S", $query_echappees, $textes)) { |
|
| 435 | - $textes = reset($textes); |
|
| 436 | - |
|
| 437 | - $parts = []; |
|
| 438 | - $currentpos = 0; |
|
| 439 | - $k = 0; |
|
| 440 | - while(count($textes)) { |
|
| 441 | - $part = array_shift($textes); |
|
| 442 | - $nextpos = strpos($query_echappees, $part, $currentpos); |
|
| 443 | - // si besoin recoller ensemble les doubles '' de sqlite (echappement des ') |
|
| 444 | - while (count($textes) and substr($part, -1) === "'") { |
|
| 445 | - $next = reset($textes); |
|
| 446 | - if (strpos($next, "'") === 0 |
|
| 447 | - and strpos($query_echappees, $part . $next, $currentpos) === $nextpos) { |
|
| 448 | - $part .= array_shift($textes); |
|
| 449 | - } |
|
| 450 | - else { |
|
| 451 | - break; |
|
| 452 | - } |
|
| 453 | - } |
|
| 454 | - $k++; |
|
| 455 | - $parts[$k] = [ |
|
| 456 | - 'texte' => $part, |
|
| 457 | - 'position' => $nextpos, |
|
| 458 | - 'placeholder' => '%'.$k.'$s', |
|
| 459 | - ]; |
|
| 460 | - $currentpos = $nextpos + strlen($part); |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - // et on replace les parts une par une en commencant par la fin |
|
| 464 | - while ($k>0) { |
|
| 465 | - $query_echappees = substr_replace($query_echappees, $parts[$k]['placeholder'], $parts[$k]['position'], strlen($parts[$k]['texte'])); |
|
| 466 | - $k--; |
|
| 467 | - } |
|
| 468 | - $textes = array_column($parts, 'texte'); |
|
| 469 | - } else { |
|
| 470 | - $textes = []; |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - // si il reste des quotes simples ou doubles, c'est qu'on s'est emmelle les pinceaux |
|
| 474 | - // dans le doute on ne touche a rien |
|
| 475 | - if (strpbrk($query_echappees, "'\"") !== false) { |
|
| 476 | - return [$query, []]; |
|
| 477 | - } |
|
| 478 | - |
|
| 479 | - return [$query_echappees, $textes]; |
|
| 413 | + static $codeEchappements = null; |
|
| 414 | + if (is_null($codeEchappements) or $uniqid) { |
|
| 415 | + if (is_null($uniqid)) { |
|
| 416 | + $uniqid = uniqid(); |
|
| 417 | + } |
|
| 418 | + $uniqid = substr(md5($uniqid), 0, 4); |
|
| 419 | + $codeEchappements = ['\\\\' => "\x1@#{$uniqid}#@\x1", "\\'" => "\x2@#{$uniqid}#@\x2", '\\"' => "\x3@#{$uniqid}#@\x3", '%' => "\x4@#{$uniqid}#@\x4"]; |
|
| 420 | + } |
|
| 421 | + if ($query === null) { |
|
| 422 | + return $codeEchappements; |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + // si la query contient deja des codes d'echappement on va s'emmeler les pinceaux et donc on ne touche a rien |
|
| 426 | + // ce n'est pas un cas legitime |
|
| 427 | + foreach ($codeEchappements as $codeEchappement) { |
|
| 428 | + if (strpos($query, (string) $codeEchappement) !== false) { |
|
| 429 | + return [$query, []]; |
|
| 430 | + } |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + $query_echappees = str_replace(array_keys($codeEchappements), array_values($codeEchappements), $query); |
|
| 434 | + if (preg_match_all("/('[^']*')|(\"[^\"]*\")/S", $query_echappees, $textes)) { |
|
| 435 | + $textes = reset($textes); |
|
| 436 | + |
|
| 437 | + $parts = []; |
|
| 438 | + $currentpos = 0; |
|
| 439 | + $k = 0; |
|
| 440 | + while(count($textes)) { |
|
| 441 | + $part = array_shift($textes); |
|
| 442 | + $nextpos = strpos($query_echappees, $part, $currentpos); |
|
| 443 | + // si besoin recoller ensemble les doubles '' de sqlite (echappement des ') |
|
| 444 | + while (count($textes) and substr($part, -1) === "'") { |
|
| 445 | + $next = reset($textes); |
|
| 446 | + if (strpos($next, "'") === 0 |
|
| 447 | + and strpos($query_echappees, $part . $next, $currentpos) === $nextpos) { |
|
| 448 | + $part .= array_shift($textes); |
|
| 449 | + } |
|
| 450 | + else { |
|
| 451 | + break; |
|
| 452 | + } |
|
| 453 | + } |
|
| 454 | + $k++; |
|
| 455 | + $parts[$k] = [ |
|
| 456 | + 'texte' => $part, |
|
| 457 | + 'position' => $nextpos, |
|
| 458 | + 'placeholder' => '%'.$k.'$s', |
|
| 459 | + ]; |
|
| 460 | + $currentpos = $nextpos + strlen($part); |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + // et on replace les parts une par une en commencant par la fin |
|
| 464 | + while ($k>0) { |
|
| 465 | + $query_echappees = substr_replace($query_echappees, $parts[$k]['placeholder'], $parts[$k]['position'], strlen($parts[$k]['texte'])); |
|
| 466 | + $k--; |
|
| 467 | + } |
|
| 468 | + $textes = array_column($parts, 'texte'); |
|
| 469 | + } else { |
|
| 470 | + $textes = []; |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + // si il reste des quotes simples ou doubles, c'est qu'on s'est emmelle les pinceaux |
|
| 474 | + // dans le doute on ne touche a rien |
|
| 475 | + if (strpbrk($query_echappees, "'\"") !== false) { |
|
| 476 | + return [$query, []]; |
|
| 477 | + } |
|
| 478 | + |
|
| 479 | + return [$query_echappees, $textes]; |
|
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | /** |
@@ -490,16 +490,16 @@ discard block |
||
| 490 | 490 | * @return string |
| 491 | 491 | */ |
| 492 | 492 | function query_reinjecte_textes($query, $textes) { |
| 493 | - // recuperer les codes echappements |
|
| 494 | - $codeEchappements = query_echappe_textes(null); |
|
| 493 | + // recuperer les codes echappements |
|
| 494 | + $codeEchappements = query_echappe_textes(null); |
|
| 495 | 495 | |
| 496 | - if (!empty($textes)) { |
|
| 497 | - $query = sprintf($query, ...$textes); |
|
| 498 | - } |
|
| 496 | + if (!empty($textes)) { |
|
| 497 | + $query = sprintf($query, ...$textes); |
|
| 498 | + } |
|
| 499 | 499 | |
| 500 | - $query = str_replace(array_values($codeEchappements), array_keys($codeEchappements), $query); |
|
| 500 | + $query = str_replace(array_values($codeEchappements), array_keys($codeEchappements), $query); |
|
| 501 | 501 | |
| 502 | - return $query; |
|
| 502 | + return $query; |
|
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | **/ |
| 519 | 519 | function spip_query($query, $serveur = '') { |
| 520 | 520 | |
| 521 | - $f = spip_connect_sql($GLOBALS['spip_sql_version'], 'query', $serveur, true); |
|
| 521 | + $f = spip_connect_sql($GLOBALS['spip_sql_version'], 'query', $serveur, true); |
|
| 522 | 522 | |
| 523 | - return function_exists($f) ? $f($query, $serveur) : false; |
|
| 523 | + return function_exists($f) ? $f($query, $serveur) : false; |
|
| 524 | 524 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | 19 | return; |
| 20 | 20 | } |
| 21 | -require_once _ROOT_RESTREINT . 'base/objets.php'; |
|
| 21 | +require_once _ROOT_RESTREINT.'base/objets.php'; |
|
| 22 | 22 | |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $f = (!preg_match('/^[\w\.]*$/', $serveur)) |
| 60 | 60 | ? '' // nom de serveur mal ecrit |
| 61 | 61 | : ($serveur ? |
| 62 | - (_DIR_CONNECT . $serveur . '.php') // serveur externe |
|
| 62 | + (_DIR_CONNECT.$serveur.'.php') // serveur externe |
|
| 63 | 63 | : (_FILE_CONNECT ?: ($install ? _FILE_CONNECT_TMP // init du serveur principal |
| 64 | 64 | : ''))); // installation pas faite |
| 65 | 65 | |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | // chargement de la version du jeu de fonctions |
| 102 | 102 | // si pas dans le fichier par defaut |
| 103 | 103 | $type = $GLOBALS['db_ok']['type']; |
| 104 | - $jeu = 'spip_' . $type . '_functions_' . $version; |
|
| 104 | + $jeu = 'spip_'.$type.'_functions_'.$version; |
|
| 105 | 105 | if (!isset($GLOBALS[$jeu])) { |
| 106 | - if (!find_in_path($type . '_' . $version . '.php', 'req/', true)) { |
|
| 106 | + if (!find_in_path($type.'_'.$version.'.php', 'req/', true)) { |
|
| 107 | 107 | spip_log("spip_connect: serveur $index version '$version' non defini pour '$type'", _LOG_HS); |
| 108 | 108 | |
| 109 | 109 | // ne plus reessayer |
@@ -165,9 +165,9 @@ discard block |
||
| 165 | 165 | $connexion = spip_connect($serveur); |
| 166 | 166 | $e = sql_errno($serveur); |
| 167 | 167 | $t = ($connexion['type'] ?? 'sql'); |
| 168 | - $m = "Erreur $e de $t: " . sql_error($serveur) . "\nin " . sql_error_backtrace() . "\n" . trim($connexion['last']); |
|
| 169 | - $f = $t . $serveur; |
|
| 170 | - spip_log($m, $f . '.' . _LOG_ERREUR); |
|
| 168 | + $m = "Erreur $e de $t: ".sql_error($serveur)."\nin ".sql_error_backtrace()."\n".trim($connexion['last']); |
|
| 169 | + $f = $t.$serveur; |
|
| 170 | + spip_log($m, $f.'.'._LOG_ERREUR); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | // si en cours d'installation ou si db=@test@ on ne pose rien |
| 254 | 254 | // car c'est un test de connexion |
| 255 | 255 | if (!defined('_ECRIRE_INSTALL') and $db !== '@test@') { |
| 256 | - $f = _DIR_TMP . $type . '.' . substr(md5($host . $port . $db), 0, 8) . '.out'; |
|
| 256 | + $f = _DIR_TMP.$type.'.'.substr(md5($host.$port.$db), 0, 8).'.out'; |
|
| 257 | 257 | } elseif ($db == '@test@') { |
| 258 | 258 | $db = ''; |
| 259 | 259 | } |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | // En cas d'indisponibilite du serveur, eviter de le bombarder |
| 293 | 293 | if ($f) { |
| 294 | 294 | @touch($f); |
| 295 | - spip_log("Echec connexion serveur $type : host[$host] port[$port] login[$login] base[$db]", $type . '.' . _LOG_HS); |
|
| 295 | + spip_log("Echec connexion serveur $type : host[$host] port[$port] login[$login] base[$db]", $type.'.'._LOG_HS); |
|
| 296 | 296 | } |
| 297 | 297 | return null; |
| 298 | 298 | } |
@@ -390,11 +390,11 @@ discard block |
||
| 390 | 390 | } elseif (is_array($a)) { |
| 391 | 391 | return join(',', array_map('_q', $a)); |
| 392 | 392 | } elseif (is_scalar($a)) { |
| 393 | - return ("'" . addslashes($a) . "'"); |
|
| 393 | + return ("'".addslashes($a)."'"); |
|
| 394 | 394 | } elseif ($a === null) { |
| 395 | 395 | return "''"; |
| 396 | 396 | } |
| 397 | - throw new \RuntimeException("Can’t use _q with " . gettype($a)); |
|
| 397 | + throw new \RuntimeException("Can’t use _q with ".gettype($a)); |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | /** |
@@ -437,14 +437,14 @@ discard block |
||
| 437 | 437 | $parts = []; |
| 438 | 438 | $currentpos = 0; |
| 439 | 439 | $k = 0; |
| 440 | - while(count($textes)) { |
|
| 440 | + while (count($textes)) { |
|
| 441 | 441 | $part = array_shift($textes); |
| 442 | 442 | $nextpos = strpos($query_echappees, $part, $currentpos); |
| 443 | 443 | // si besoin recoller ensemble les doubles '' de sqlite (echappement des ') |
| 444 | 444 | while (count($textes) and substr($part, -1) === "'") { |
| 445 | 445 | $next = reset($textes); |
| 446 | 446 | if (strpos($next, "'") === 0 |
| 447 | - and strpos($query_echappees, $part . $next, $currentpos) === $nextpos) { |
|
| 447 | + and strpos($query_echappees, $part.$next, $currentpos) === $nextpos) { |
|
| 448 | 448 | $part .= array_shift($textes); |
| 449 | 449 | } |
| 450 | 450 | else { |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | // et on replace les parts une par une en commencant par la fin |
| 464 | - while ($k>0) { |
|
| 464 | + while ($k > 0) { |
|
| 465 | 465 | $query_echappees = substr_replace($query_echappees, $parts[$k]['placeholder'], $parts[$k]['position'], strlen($parts[$k]['texte'])); |
| 466 | 466 | $k--; |
| 467 | 467 | } |
@@ -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 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * Pile complétée du code compilé |
| 38 | 38 | **/ |
| 39 | 39 | function balise_MENU_LANG_ECRIRE($p) { |
| 40 | - return calculer_balise_dynamique($p, 'MENU_LANG_ECRIRE', ['lang']); |
|
| 40 | + return calculer_balise_dynamique($p, 'MENU_LANG_ECRIRE', ['lang']); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -56,12 +56,12 @@ discard block |
||
| 56 | 56 | * - string: Si pas de multilinguisme |
| 57 | 57 | */ |
| 58 | 58 | function balise_MENU_LANG_ECRIRE_stat($args, $context_compil) { |
| 59 | - include_spip('inc/lang'); |
|
| 60 | - if (strpos($GLOBALS['meta']['langues_proposees'], ',') === false) { |
|
| 61 | - return ''; |
|
| 62 | - } |
|
| 59 | + include_spip('inc/lang'); |
|
| 60 | + if (strpos($GLOBALS['meta']['langues_proposees'], ',') === false) { |
|
| 61 | + return ''; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - return $args; |
|
| 64 | + return $args; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * Liste : Chemin du squelette, durée du cache, contexte |
| 78 | 78 | **/ |
| 79 | 79 | function balise_MENU_LANG_ECRIRE_dyn($opt) { |
| 80 | - return menu_lang_pour_tous('var_lang_ecrire', $opt); |
|
| 80 | + return menu_lang_pour_tous('var_lang_ecrire', $opt); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -97,30 +97,30 @@ discard block |
||
| 97 | 97 | * Liste : Chemin du squelette, durée du cache, contexte |
| 98 | 98 | **/ |
| 99 | 99 | function menu_lang_pour_tous($nom, $default) { |
| 100 | - include_spip('inc/lang'); |
|
| 100 | + include_spip('inc/lang'); |
|
| 101 | 101 | |
| 102 | - if ($GLOBALS['spip_lang'] <> $default) { |
|
| 103 | - $opt = lang_select($default); # et remplace |
|
| 104 | - if ($GLOBALS['spip_lang'] <> $default) { |
|
| 105 | - $default = ''; # annule tout choix par defaut |
|
| 106 | - if ($opt) { |
|
| 107 | - lang_select(); |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - } |
|
| 102 | + if ($GLOBALS['spip_lang'] <> $default) { |
|
| 103 | + $opt = lang_select($default); # et remplace |
|
| 104 | + if ($GLOBALS['spip_lang'] <> $default) { |
|
| 105 | + $default = ''; # annule tout choix par defaut |
|
| 106 | + if ($opt) { |
|
| 107 | + lang_select(); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - # lien a partir de / |
|
| 113 | - $cible = parametre_url(self(), 'lang', '', '&'); |
|
| 114 | - $post = generer_url_action('converser', 'redirect=' . rawurlencode($cible), true); |
|
| 112 | + # lien a partir de / |
|
| 113 | + $cible = parametre_url(self(), 'lang', '', '&'); |
|
| 114 | + $post = generer_url_action('converser', 'redirect=' . rawurlencode($cible), true); |
|
| 115 | 115 | |
| 116 | - return [ |
|
| 117 | - 'formulaires/menu_lang', |
|
| 118 | - 3600, |
|
| 119 | - [ |
|
| 120 | - 'nom' => $nom, |
|
| 121 | - 'url' => $post, |
|
| 122 | - 'name' => $nom, |
|
| 123 | - 'default' => $default, |
|
| 124 | - ] |
|
| 125 | - ]; |
|
| 116 | + return [ |
|
| 117 | + 'formulaires/menu_lang', |
|
| 118 | + 3600, |
|
| 119 | + [ |
|
| 120 | + 'nom' => $nom, |
|
| 121 | + 'url' => $post, |
|
| 122 | + 'name' => $nom, |
|
| 123 | + 'default' => $default, |
|
| 124 | + ] |
|
| 125 | + ]; |
|
| 126 | 126 | } |