Completed
Push — master ( f0405e...7791a8 )
by cam
05:00
created
ecrire/public/parametrer.php 2 patches
Indentation   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_fichiers_fonctions();
@@ -31,167 +31,167 @@  discard block
 block discarded – undo
31 31
 
32 32
 // https://code.spip.net/@public_parametrer_dist
33 33
 function public_parametrer_dist($fond, $contexte = '', $cache = '', $connect = '') {
34
-	static $composer, $styliser, $notes = null;
35
-	$page = tester_redirection($fond, $contexte, $connect);
36
-	if ($page) {
37
-		return $page;
38
-	}
39
-
40
-	if (isset($contexte['lang'])) {
41
-		$lang = $contexte['lang'];
42
-	} elseif (!isset($lang)) {
43
-		$lang = $GLOBALS['meta']['langue_site'];
44
-	}
45
-
46
-	$select = ((!isset($GLOBALS['forcer_lang']) or !$GLOBALS['forcer_lang']) and $lang <> $GLOBALS['spip_lang']);
47
-	if ($select) {
48
-		$select = lang_select($lang);
49
-	}
50
-
51
-	$debug = (defined('_VAR_MODE') && _VAR_MODE == 'debug');
52
-
53
-	if (!$styliser) {
54
-		$styliser = charger_fonction('styliser', 'public');
55
-	}
56
-	list($skel, $mime_type, $gram, $sourcefile) =
57
-		$styliser($fond, $contexte, $GLOBALS['spip_lang'], $connect);
58
-
59
-	if ($skel) {
60
-
61
-		// sauver le nom de l'eventuel squelette en cours d'execution
62
-		// (recursion possible a cause des modeles)
63
-		if ($debug) {
64
-			$courant = @$GLOBALS['debug_objets']['courant'];
65
-			$GLOBALS['debug_objets']['contexte'][$sourcefile] = $contexte;
66
-		}
67
-
68
-		// charger le squelette en specifiant les langages cibles et source
69
-		// au cas il faudrait le compiler (source posterieure au resultat)
70
-
71
-		if (!$composer) {
72
-			$composer = charger_fonction('composer', 'public');
73
-		}
74
-		$fonc = $composer($skel, $mime_type, $gram, $sourcefile, $connect);
75
-	} else {
76
-		$fonc = '';
77
-	}
78
-
79
-	if (!$fonc) { // squelette inconnu (==='') ou faux (===false)
80
-		$page = $fonc;
81
-	} else {
82
-		// Preparer l'appel de la fonction principale du squelette 
83
-
84
-		spip_timer($a = 'calcul page ' . rand(0, 1000));
85
-
86
-		// On cree un marqueur de notes unique lie a cette composition
87
-		// et on enregistre l'etat courant des globales de notes...
88
-		if (is_null($notes)) {
89
-			$notes = charger_fonction('notes', 'inc', true);
90
-		}
91
-		if ($notes) {
92
-			$notes('', 'empiler');
93
-		}
94
-
95
-		// Rajouter d'office ces deux parametres
96
-		// (mais vaudrait mieux que le compilateur sache le simuler
97
-		// car ca interdit l'usage de criteres conditionnels dessus).
98
-		if (!isset($contexte['date'])) {
99
-			$contexte['date'] = date("Y-m-d H:i:s");
100
-			$contexte['date_default'] = true;
101
-		} else {
102
-			$contexte['date'] = normaliser_date($contexte['date'], true);
103
-		}
104
-
105
-		if (!isset($contexte['date_redac'])) {
106
-			$contexte['date_redac'] = date("Y-m-d H:i:s");
107
-			$contexte['date_redac_default'] = true;
108
-		} else {
109
-			$contexte['date_redac'] = normaliser_date($contexte['date_redac'], true);
110
-		}
111
-
112
-		// Passer le nom du cache pour produire sa destruction automatique
113
-		$page = $fonc(array('cache' => $cache), array($contexte));
114
-
115
-		// Restituer les globales de notes telles qu'elles etaient avant l'appel
116
-		// Si l'inclus n'a pas affiche ses notes, tant pis (elles *doivent*
117
-		// etre dans son resultat, autrement elles ne seraient pas prises en
118
-		// compte a chaque calcul d'un texte contenant un modele, mais seulement
119
-		// quand le modele serait calcule, et on aurait des resultats incoherents)
120
-		if ($notes) {
121
-			$notes('', 'depiler');
122
-		}
123
-
124
-		// reinjecter en dynamique la pile des notes
125
-		// si il y a des inclure dynamiques
126
-		// si la pile n'est pas vide
127
-		// la generalisation de cette injection permettrait de corriger le point juste au dessus
128
-		// en faisant remonter les notes a l'incluant (A tester et valider avant application)
129
-		if ($notes) {
130
-			$page['notes'] = $notes('', 'sauver_etat');
131
-		}
132
-
133
-		// spip_log: un joli contexte
134
-		$infos = presenter_contexte(array_filter($contexte));
135
-
136
-		$profile = spip_timer($a);
137
-		spip_log("calcul ($profile) [$skel] $infos"
138
-			. ' (' . strlen($page['texte']) . ' octets)');
139
-
140
-		if (defined('_CALCUL_PROFILER') AND intval($profile)>_CALCUL_PROFILER){
141
-			spip_log("calcul ($profile) [$skel] $infos"
142
-				.' ('.strlen($page['texte']).' octets) | '.$_SERVER['REQUEST_URI'],"profiler"._LOG_AVERTISSEMENT);
143
-		}
144
-
145
-		if ($debug) {
146
-			// si c'est ce que demande le debusqueur, lui passer la main
147
-			$t = strlen($page['texte']) ? $page['texte'] : " ";
148
-			$GLOBALS['debug_objets']['resultat'][$fonc . 'tout'] = $t;
149
-			$GLOBALS['debug_objets']['courant'] = $courant;
150
-			$GLOBALS['debug_objets']['profile'][$sourcefile] = $profile;
151
-			if ($GLOBALS['debug_objets']['sourcefile']
152
-				and (_request('var_mode_objet') == $fonc)
153
-				and (_request('var_mode_affiche') == 'resultat')
154
-			) {
155
-				erreur_squelette();
156
-			}
157
-		}
158
-		// Si #CACHE{} n'etait pas la, le mettre a $delais
159
-		if (!isset($page['entetes']['X-Spip-Cache'])) {
160
-			// Dans l'espace prive ou dans un modeles/ on pose un cache 0 par defaut
161
-			// si aucun #CACHE{} spécifié
162
-			// le contexte implicite qui conditionne le cache assure qu'on retombe pas sur le meme
163
-			// entre public et prive
164
-			if (test_espace_prive() or strncmp($fond, 'modeles/', 8) == 0) {
165
-				$page['entetes']['X-Spip-Cache'] = 0;
166
-			} else {
167
-				$page['entetes']['X-Spip-Cache'] = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : 36000;
168
-			}
169
-		}
170
-
171
-		$page['contexte'] = $contexte;
172
-
173
-		// faire remonter le fichier source
174
-		static $js_inclus = false;
175
-		if (defined('_VAR_INCLURE') and _VAR_INCLURE) {
176
-			$page['sourcefile'] = $sourcefile;
177
-			$page['texte'] =
178
-				"<div class='inclure_blocs'><h6>" . $page['sourcefile'] . "</h6>" . $page['texte'] . "</div>"
179
-				. ($js_inclus ? "" : "<script type='text/javascript'>jQuery(function(){jQuery('.inclure_blocs > h6:first-child').hover(function(){jQuery(this).parent().addClass('hover')},function(){jQuery(this).parent().removeClass('hover')})});</script>");
180
-			$js_inclus = true;
181
-		}
182
-
183
-		// Si un modele contenait #SESSION, on note l'info dans $page
184
-		if (isset($GLOBALS['cache_utilise_session'])) {
185
-			$page['invalideurs']['session'] = $GLOBALS['cache_utilise_session'];
186
-			unset($GLOBALS['cache_utilise_session']);
187
-		}
188
-	}
189
-
190
-	if ($select) {
191
-		lang_select();
192
-	}
193
-
194
-	return $page;
34
+    static $composer, $styliser, $notes = null;
35
+    $page = tester_redirection($fond, $contexte, $connect);
36
+    if ($page) {
37
+        return $page;
38
+    }
39
+
40
+    if (isset($contexte['lang'])) {
41
+        $lang = $contexte['lang'];
42
+    } elseif (!isset($lang)) {
43
+        $lang = $GLOBALS['meta']['langue_site'];
44
+    }
45
+
46
+    $select = ((!isset($GLOBALS['forcer_lang']) or !$GLOBALS['forcer_lang']) and $lang <> $GLOBALS['spip_lang']);
47
+    if ($select) {
48
+        $select = lang_select($lang);
49
+    }
50
+
51
+    $debug = (defined('_VAR_MODE') && _VAR_MODE == 'debug');
52
+
53
+    if (!$styliser) {
54
+        $styliser = charger_fonction('styliser', 'public');
55
+    }
56
+    list($skel, $mime_type, $gram, $sourcefile) =
57
+        $styliser($fond, $contexte, $GLOBALS['spip_lang'], $connect);
58
+
59
+    if ($skel) {
60
+
61
+        // sauver le nom de l'eventuel squelette en cours d'execution
62
+        // (recursion possible a cause des modeles)
63
+        if ($debug) {
64
+            $courant = @$GLOBALS['debug_objets']['courant'];
65
+            $GLOBALS['debug_objets']['contexte'][$sourcefile] = $contexte;
66
+        }
67
+
68
+        // charger le squelette en specifiant les langages cibles et source
69
+        // au cas il faudrait le compiler (source posterieure au resultat)
70
+
71
+        if (!$composer) {
72
+            $composer = charger_fonction('composer', 'public');
73
+        }
74
+        $fonc = $composer($skel, $mime_type, $gram, $sourcefile, $connect);
75
+    } else {
76
+        $fonc = '';
77
+    }
78
+
79
+    if (!$fonc) { // squelette inconnu (==='') ou faux (===false)
80
+        $page = $fonc;
81
+    } else {
82
+        // Preparer l'appel de la fonction principale du squelette 
83
+
84
+        spip_timer($a = 'calcul page ' . rand(0, 1000));
85
+
86
+        // On cree un marqueur de notes unique lie a cette composition
87
+        // et on enregistre l'etat courant des globales de notes...
88
+        if (is_null($notes)) {
89
+            $notes = charger_fonction('notes', 'inc', true);
90
+        }
91
+        if ($notes) {
92
+            $notes('', 'empiler');
93
+        }
94
+
95
+        // Rajouter d'office ces deux parametres
96
+        // (mais vaudrait mieux que le compilateur sache le simuler
97
+        // car ca interdit l'usage de criteres conditionnels dessus).
98
+        if (!isset($contexte['date'])) {
99
+            $contexte['date'] = date("Y-m-d H:i:s");
100
+            $contexte['date_default'] = true;
101
+        } else {
102
+            $contexte['date'] = normaliser_date($contexte['date'], true);
103
+        }
104
+
105
+        if (!isset($contexte['date_redac'])) {
106
+            $contexte['date_redac'] = date("Y-m-d H:i:s");
107
+            $contexte['date_redac_default'] = true;
108
+        } else {
109
+            $contexte['date_redac'] = normaliser_date($contexte['date_redac'], true);
110
+        }
111
+
112
+        // Passer le nom du cache pour produire sa destruction automatique
113
+        $page = $fonc(array('cache' => $cache), array($contexte));
114
+
115
+        // Restituer les globales de notes telles qu'elles etaient avant l'appel
116
+        // Si l'inclus n'a pas affiche ses notes, tant pis (elles *doivent*
117
+        // etre dans son resultat, autrement elles ne seraient pas prises en
118
+        // compte a chaque calcul d'un texte contenant un modele, mais seulement
119
+        // quand le modele serait calcule, et on aurait des resultats incoherents)
120
+        if ($notes) {
121
+            $notes('', 'depiler');
122
+        }
123
+
124
+        // reinjecter en dynamique la pile des notes
125
+        // si il y a des inclure dynamiques
126
+        // si la pile n'est pas vide
127
+        // la generalisation de cette injection permettrait de corriger le point juste au dessus
128
+        // en faisant remonter les notes a l'incluant (A tester et valider avant application)
129
+        if ($notes) {
130
+            $page['notes'] = $notes('', 'sauver_etat');
131
+        }
132
+
133
+        // spip_log: un joli contexte
134
+        $infos = presenter_contexte(array_filter($contexte));
135
+
136
+        $profile = spip_timer($a);
137
+        spip_log("calcul ($profile) [$skel] $infos"
138
+            . ' (' . strlen($page['texte']) . ' octets)');
139
+
140
+        if (defined('_CALCUL_PROFILER') AND intval($profile)>_CALCUL_PROFILER){
141
+            spip_log("calcul ($profile) [$skel] $infos"
142
+                .' ('.strlen($page['texte']).' octets) | '.$_SERVER['REQUEST_URI'],"profiler"._LOG_AVERTISSEMENT);
143
+        }
144
+
145
+        if ($debug) {
146
+            // si c'est ce que demande le debusqueur, lui passer la main
147
+            $t = strlen($page['texte']) ? $page['texte'] : " ";
148
+            $GLOBALS['debug_objets']['resultat'][$fonc . 'tout'] = $t;
149
+            $GLOBALS['debug_objets']['courant'] = $courant;
150
+            $GLOBALS['debug_objets']['profile'][$sourcefile] = $profile;
151
+            if ($GLOBALS['debug_objets']['sourcefile']
152
+                and (_request('var_mode_objet') == $fonc)
153
+                and (_request('var_mode_affiche') == 'resultat')
154
+            ) {
155
+                erreur_squelette();
156
+            }
157
+        }
158
+        // Si #CACHE{} n'etait pas la, le mettre a $delais
159
+        if (!isset($page['entetes']['X-Spip-Cache'])) {
160
+            // Dans l'espace prive ou dans un modeles/ on pose un cache 0 par defaut
161
+            // si aucun #CACHE{} spécifié
162
+            // le contexte implicite qui conditionne le cache assure qu'on retombe pas sur le meme
163
+            // entre public et prive
164
+            if (test_espace_prive() or strncmp($fond, 'modeles/', 8) == 0) {
165
+                $page['entetes']['X-Spip-Cache'] = 0;
166
+            } else {
167
+                $page['entetes']['X-Spip-Cache'] = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : 36000;
168
+            }
169
+        }
170
+
171
+        $page['contexte'] = $contexte;
172
+
173
+        // faire remonter le fichier source
174
+        static $js_inclus = false;
175
+        if (defined('_VAR_INCLURE') and _VAR_INCLURE) {
176
+            $page['sourcefile'] = $sourcefile;
177
+            $page['texte'] =
178
+                "<div class='inclure_blocs'><h6>" . $page['sourcefile'] . "</h6>" . $page['texte'] . "</div>"
179
+                . ($js_inclus ? "" : "<script type='text/javascript'>jQuery(function(){jQuery('.inclure_blocs > h6:first-child').hover(function(){jQuery(this).parent().addClass('hover')},function(){jQuery(this).parent().removeClass('hover')})});</script>");
180
+            $js_inclus = true;
181
+        }
182
+
183
+        // Si un modele contenait #SESSION, on note l'info dans $page
184
+        if (isset($GLOBALS['cache_utilise_session'])) {
185
+            $page['invalideurs']['session'] = $GLOBALS['cache_utilise_session'];
186
+            unset($GLOBALS['cache_utilise_session']);
187
+        }
188
+    }
189
+
190
+    if ($select) {
191
+        lang_select();
192
+    }
193
+
194
+    return $page;
195 195
 }
196 196
 
197 197
 /** 
@@ -200,33 +200,33 @@  discard block
 block discarded – undo
200 200
  * @return string
201 201
 */
202 202
 function presenter_contexte($contexte, $profondeur_max = 1, $max_lines = 0) {
203
-	$infos = array();
204
-	$line = 0;
205
-	foreach ($contexte as $var => $val) {
206
-		$line++;
207
-		if ($max_lines and $max_lines < $line) {
208
-			$infos[] = '…';
209
-			break;
210
-		}
211
-		if (is_array($val)) {
212
-			if ($profondeur_max > 0) {
213
-				$val = 'array:' . count($val) . '(' . presenter_contexte($val, $profondeur_max - 1, 3) . ')';
214
-			} else {
215
-				$val = 'array:' . count($val);
216
-			}
217
-		} elseif (is_object($val)) {
218
-			$val = get_class($val);
219
-		} elseif (strlen("$val") > 30) {
220
-			$val = substr("$val", 0, 29) . '…';
221
-			if (strstr($val, ' ')) {
222
-				$val = "'$val'";
223
-			}
224
-		} elseif (strstr($val, ' ')) {
225
-			$val = "'$val'";
226
-		}
227
-		$infos[] = $var . '=' . $val;
228
-	}
229
-	return join(', ', $infos);
203
+    $infos = array();
204
+    $line = 0;
205
+    foreach ($contexte as $var => $val) {
206
+        $line++;
207
+        if ($max_lines and $max_lines < $line) {
208
+            $infos[] = '…';
209
+            break;
210
+        }
211
+        if (is_array($val)) {
212
+            if ($profondeur_max > 0) {
213
+                $val = 'array:' . count($val) . '(' . presenter_contexte($val, $profondeur_max - 1, 3) . ')';
214
+            } else {
215
+                $val = 'array:' . count($val);
216
+            }
217
+        } elseif (is_object($val)) {
218
+            $val = get_class($val);
219
+        } elseif (strlen("$val") > 30) {
220
+            $val = substr("$val", 0, 29) . '…';
221
+            if (strstr($val, ' ')) {
222
+                $val = "'$val'";
223
+            }
224
+        } elseif (strstr($val, ' ')) {
225
+            $val = "'$val'";
226
+        }
227
+        $infos[] = $var . '=' . $val;
228
+    }
229
+    return join(', ', $infos);
230 230
 }
231 231
 
232 232
 
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
  * @return array|bool
244 244
  */
245 245
 function tester_redirection($fond, $contexte, $connect) {
246
-	static $tester_redirection = null;
247
-	if (is_null($tester_redirection)) {
248
-		$tester_redirection = charger_fonction('tester_redirection', 'public');
249
-	}
250
-	return $tester_redirection($fond, $contexte, $connect);
246
+    static $tester_redirection = null;
247
+    if (is_null($tester_redirection)) {
248
+        $tester_redirection = charger_fonction('tester_redirection', 'public');
249
+    }
250
+    return $tester_redirection($fond, $contexte, $connect);
251 251
 }
252 252
 
253 253
 
@@ -263,40 +263,40 @@  discard block
 block discarded – undo
263 263
  * @return array|bool
264 264
  */
265 265
 function public_tester_redirection_dist($fond, $contexte, $connect) {
266
-	if ($fond == 'article'
267
-		and $id_article = intval($contexte['id_article'])
268
-	) {
269
-		include_spip('public/quete'); // pour quete_virtuel et ses dependances
270
-		$m = quete_virtuel($id_article, $connect);
271
-		if (strlen($m)) {
272
-			include_spip('inc/texte');
273
-			// les navigateurs pataugent si l'URL est vide
274
-			if ($url = virtuel_redirige($m, true)) {
275
-				// passer en url absolue car cette redirection pourra
276
-				// etre utilisee dans un contexte d'url qui change
277
-				// y compris url arbo
278
-				$status = 302;
279
-				if (defined('_STATUS_REDIRECTION_VIRTUEL')) {
280
-					$status = _STATUS_REDIRECTION_VIRTUEL;
281
-				}
282
-				if (!preg_match(',^\w+:,', $url)) {
283
-					include_spip('inc/filtres_mini');
284
-					$url = url_absolue($url);
285
-				}
286
-				$url = str_replace('&amp;', '&', $url);
287
-
288
-				return array(
289
-					'texte' => "<"
290
-						. "?php include_spip('inc/headers');redirige_par_entete('"
291
-						. texte_script($url)
292
-						. "','',$status);"
293
-						. "?" . ">",
294
-					'process_ins' => 'php',
295
-					'status' => $status
296
-				);
297
-			}
298
-		}
299
-	}
300
-
301
-	return false;
266
+    if ($fond == 'article'
267
+        and $id_article = intval($contexte['id_article'])
268
+    ) {
269
+        include_spip('public/quete'); // pour quete_virtuel et ses dependances
270
+        $m = quete_virtuel($id_article, $connect);
271
+        if (strlen($m)) {
272
+            include_spip('inc/texte');
273
+            // les navigateurs pataugent si l'URL est vide
274
+            if ($url = virtuel_redirige($m, true)) {
275
+                // passer en url absolue car cette redirection pourra
276
+                // etre utilisee dans un contexte d'url qui change
277
+                // y compris url arbo
278
+                $status = 302;
279
+                if (defined('_STATUS_REDIRECTION_VIRTUEL')) {
280
+                    $status = _STATUS_REDIRECTION_VIRTUEL;
281
+                }
282
+                if (!preg_match(',^\w+:,', $url)) {
283
+                    include_spip('inc/filtres_mini');
284
+                    $url = url_absolue($url);
285
+                }
286
+                $url = str_replace('&amp;', '&', $url);
287
+
288
+                return array(
289
+                    'texte' => "<"
290
+                        . "?php include_spip('inc/headers');redirige_par_entete('"
291
+                        . texte_script($url)
292
+                        . "','',$status);"
293
+                        . "?" . ">",
294
+                    'process_ins' => 'php',
295
+                    'status' => $status
296
+                );
297
+            }
298
+        }
299
+    }
300
+
301
+    return false;
302 302
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	} else {
82 82
 		// Preparer l'appel de la fonction principale du squelette 
83 83
 
84
-		spip_timer($a = 'calcul page ' . rand(0, 1000));
84
+		spip_timer($a = 'calcul page '.rand(0, 1000));
85 85
 
86 86
 		// On cree un marqueur de notes unique lie a cette composition
87 87
 		// et on enregistre l'etat courant des globales de notes...
@@ -135,17 +135,17 @@  discard block
 block discarded – undo
135 135
 
136 136
 		$profile = spip_timer($a);
137 137
 		spip_log("calcul ($profile) [$skel] $infos"
138
-			. ' (' . strlen($page['texte']) . ' octets)');
138
+			. ' ('.strlen($page['texte']).' octets)');
139 139
 
140
-		if (defined('_CALCUL_PROFILER') AND intval($profile)>_CALCUL_PROFILER){
140
+		if (defined('_CALCUL_PROFILER') AND intval($profile) > _CALCUL_PROFILER) {
141 141
 			spip_log("calcul ($profile) [$skel] $infos"
142
-				.' ('.strlen($page['texte']).' octets) | '.$_SERVER['REQUEST_URI'],"profiler"._LOG_AVERTISSEMENT);
142
+				.' ('.strlen($page['texte']).' octets) | '.$_SERVER['REQUEST_URI'], "profiler"._LOG_AVERTISSEMENT);
143 143
 		}
144 144
 
145 145
 		if ($debug) {
146 146
 			// si c'est ce que demande le debusqueur, lui passer la main
147 147
 			$t = strlen($page['texte']) ? $page['texte'] : " ";
148
-			$GLOBALS['debug_objets']['resultat'][$fonc . 'tout'] = $t;
148
+			$GLOBALS['debug_objets']['resultat'][$fonc.'tout'] = $t;
149 149
 			$GLOBALS['debug_objets']['courant'] = $courant;
150 150
 			$GLOBALS['debug_objets']['profile'][$sourcefile] = $profile;
151 151
 			if ($GLOBALS['debug_objets']['sourcefile']
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 		if (defined('_VAR_INCLURE') and _VAR_INCLURE) {
176 176
 			$page['sourcefile'] = $sourcefile;
177 177
 			$page['texte'] =
178
-				"<div class='inclure_blocs'><h6>" . $page['sourcefile'] . "</h6>" . $page['texte'] . "</div>"
178
+				"<div class='inclure_blocs'><h6>".$page['sourcefile']."</h6>".$page['texte']."</div>"
179 179
 				. ($js_inclus ? "" : "<script type='text/javascript'>jQuery(function(){jQuery('.inclure_blocs > h6:first-child').hover(function(){jQuery(this).parent().addClass('hover')},function(){jQuery(this).parent().removeClass('hover')})});</script>");
180 180
 			$js_inclus = true;
181 181
 		}
@@ -210,21 +210,21 @@  discard block
 block discarded – undo
210 210
 		}
211 211
 		if (is_array($val)) {
212 212
 			if ($profondeur_max > 0) {
213
-				$val = 'array:' . count($val) . '(' . presenter_contexte($val, $profondeur_max - 1, 3) . ')';
213
+				$val = 'array:'.count($val).'('.presenter_contexte($val, $profondeur_max - 1, 3).')';
214 214
 			} else {
215
-				$val = 'array:' . count($val);
215
+				$val = 'array:'.count($val);
216 216
 			}
217 217
 		} elseif (is_object($val)) {
218 218
 			$val = get_class($val);
219 219
 		} elseif (strlen("$val") > 30) {
220
-			$val = substr("$val", 0, 29) . '…';
220
+			$val = substr("$val", 0, 29).'…';
221 221
 			if (strstr($val, ' ')) {
222 222
 				$val = "'$val'";
223 223
 			}
224 224
 		} elseif (strstr($val, ' ')) {
225 225
 			$val = "'$val'";
226 226
 		}
227
-		$infos[] = $var . '=' . $val;
227
+		$infos[] = $var.'='.$val;
228 228
 	}
229 229
 	return join(', ', $infos);
230 230
 }
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 						. "?php include_spip('inc/headers');redirige_par_entete('"
291 291
 						. texte_script($url)
292 292
 						. "','',$status);"
293
-						. "?" . ">",
293
+						. "?".">",
294 294
 					'process_ins' => 'php',
295 295
 					'status' => $status
296 296
 				);
Please login to merge, or discard this patch.
ecrire/public/aiguiller.php 1 patch
Indentation   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -11,153 +11,153 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 function securiser_redirect_action($redirect) {
18
-	// cas d'un double urlencode : si un urldecode de l'url n'est pas secure, on retient ca comme redirect
19
-	if (strpos($redirect, '%') !== false) {
20
-		$r2 = urldecode($redirect);
21
-		if (($r3 = securiser_redirect_action($r2)) !== $r2) {
22
-			return $r3;
23
-		}
24
-	}
25
-	if ((tester_url_absolue($redirect) or preg_match(',^\w+:,',trim($redirect)))
26
-		and !defined('_AUTORISER_ACTION_ABS_REDIRECT')) {
27
-		// si l'url est une url du site, on la laisse passer sans rien faire
28
-		// c'est encore le plus simple
29
-		$base = $GLOBALS['meta']['adresse_site'] . "/";
30
-		if (strlen($base) and strncmp($redirect, $base, strlen($base)) == 0) {
31
-			return $redirect;
32
-		}
33
-		$base = url_de_base();
34
-		if (strlen($base) and strncmp($redirect, $base, strlen($base)) == 0) {
35
-			return $redirect;
36
-		}
18
+    // cas d'un double urlencode : si un urldecode de l'url n'est pas secure, on retient ca comme redirect
19
+    if (strpos($redirect, '%') !== false) {
20
+        $r2 = urldecode($redirect);
21
+        if (($r3 = securiser_redirect_action($r2)) !== $r2) {
22
+            return $r3;
23
+        }
24
+    }
25
+    if ((tester_url_absolue($redirect) or preg_match(',^\w+:,',trim($redirect)))
26
+        and !defined('_AUTORISER_ACTION_ABS_REDIRECT')) {
27
+        // si l'url est une url du site, on la laisse passer sans rien faire
28
+        // c'est encore le plus simple
29
+        $base = $GLOBALS['meta']['adresse_site'] . "/";
30
+        if (strlen($base) and strncmp($redirect, $base, strlen($base)) == 0) {
31
+            return $redirect;
32
+        }
33
+        $base = url_de_base();
34
+        if (strlen($base) and strncmp($redirect, $base, strlen($base)) == 0) {
35
+            return $redirect;
36
+        }
37 37
 
38
-		return "";
39
-	}
38
+        return "";
39
+    }
40 40
 
41
-	return $redirect;
41
+    return $redirect;
42 42
 }
43 43
 
44 44
 // https://code.spip.net/@traiter_appels_actions
45 45
 function traiter_appels_actions() {
46
-	// cas de l'appel qui renvoie une redirection (302) ou rien (204)
47
-	if ($action = _request('action')) {
48
-		include_spip('base/abstract_sql'); // chargement systematique pour les actions
49
-		include_spip('inc/autoriser');
50
-		include_spip('inc/headers');
51
-		include_spip('inc/actions');
52
-		// des actions peuvent appeler _T
53
-		if (!isset($GLOBALS['spip_lang'])) {
54
-			include_spip('inc/lang');
55
-			utiliser_langue_visiteur();
56
-		}
57
-		// si l'action est provoque par un hit {ajax}
58
-		// il faut transmettre l'env ajax au redirect
59
-		// on le met avant dans la query string au cas ou l'action fait elle meme sa redirection
60
-		if (($v = _request('var_ajax'))
61
-			and ($v !== 'form')
62
-			and ($args = _request('var_ajax_env'))
63
-			and ($url = _request('redirect'))
64
-		) {
65
-			$url = parametre_url($url, 'var_ajax', $v, '&');
66
-			$url = parametre_url($url, 'var_ajax_env', $args, '&');
67
-			set_request('redirect', $url);
68
-		} else {
69
-			if (_request('redirect')) {
70
-				set_request('redirect', securiser_redirect_action(_request('redirect')));
71
-			}
72
-		}
73
-		$var_f = charger_fonction($action, 'action');
74
-		$var_f();
75
-		if (!isset($GLOBALS['redirect'])) {
76
-			$GLOBALS['redirect'] = _request('redirect');
77
-			if ($_SERVER['REQUEST_METHOD'] == 'POST') {
78
-				$GLOBALS['redirect'] = urldecode($GLOBALS['redirect']);
79
-			}
80
-			$GLOBALS['redirect'] = securiser_redirect_action($GLOBALS['redirect']);
81
-		}
82
-		if ($url = $GLOBALS['redirect']) {
83
-			// si l'action est provoque par un hit {ajax}
84
-			// il faut transmettre l'env ajax au redirect 
85
-			// qui a pu etre defini par l'action
86
-			if (($v = _request('var_ajax'))
87
-				and ($v !== 'form')
88
-				and ($args = _request('var_ajax_env'))
89
-			) {
90
-				$url = parametre_url($url, 'var_ajax', $v, '&');
91
-				$url = parametre_url($url, 'var_ajax_env', $args, '&');
92
-				// passer l'ancre en variable pour pouvoir la gerer cote serveur
93
-				$url = preg_replace(',#([^#&?]+)$,', "&var_ajax_ancre=\\1", $url);
94
-			}
95
-			$url = str_replace('&amp;', '&', $url); // les redirections se font en &, pas en en &amp;
96
-			redirige_par_entete($url);
97
-		}
98
-		if (!headers_sent()
99
-			and !ob_get_length()
100
-		) {
101
-			http_status(204);
102
-		} // No Content
103
-		return true;
104
-	}
46
+    // cas de l'appel qui renvoie une redirection (302) ou rien (204)
47
+    if ($action = _request('action')) {
48
+        include_spip('base/abstract_sql'); // chargement systematique pour les actions
49
+        include_spip('inc/autoriser');
50
+        include_spip('inc/headers');
51
+        include_spip('inc/actions');
52
+        // des actions peuvent appeler _T
53
+        if (!isset($GLOBALS['spip_lang'])) {
54
+            include_spip('inc/lang');
55
+            utiliser_langue_visiteur();
56
+        }
57
+        // si l'action est provoque par un hit {ajax}
58
+        // il faut transmettre l'env ajax au redirect
59
+        // on le met avant dans la query string au cas ou l'action fait elle meme sa redirection
60
+        if (($v = _request('var_ajax'))
61
+            and ($v !== 'form')
62
+            and ($args = _request('var_ajax_env'))
63
+            and ($url = _request('redirect'))
64
+        ) {
65
+            $url = parametre_url($url, 'var_ajax', $v, '&');
66
+            $url = parametre_url($url, 'var_ajax_env', $args, '&');
67
+            set_request('redirect', $url);
68
+        } else {
69
+            if (_request('redirect')) {
70
+                set_request('redirect', securiser_redirect_action(_request('redirect')));
71
+            }
72
+        }
73
+        $var_f = charger_fonction($action, 'action');
74
+        $var_f();
75
+        if (!isset($GLOBALS['redirect'])) {
76
+            $GLOBALS['redirect'] = _request('redirect');
77
+            if ($_SERVER['REQUEST_METHOD'] == 'POST') {
78
+                $GLOBALS['redirect'] = urldecode($GLOBALS['redirect']);
79
+            }
80
+            $GLOBALS['redirect'] = securiser_redirect_action($GLOBALS['redirect']);
81
+        }
82
+        if ($url = $GLOBALS['redirect']) {
83
+            // si l'action est provoque par un hit {ajax}
84
+            // il faut transmettre l'env ajax au redirect 
85
+            // qui a pu etre defini par l'action
86
+            if (($v = _request('var_ajax'))
87
+                and ($v !== 'form')
88
+                and ($args = _request('var_ajax_env'))
89
+            ) {
90
+                $url = parametre_url($url, 'var_ajax', $v, '&');
91
+                $url = parametre_url($url, 'var_ajax_env', $args, '&');
92
+                // passer l'ancre en variable pour pouvoir la gerer cote serveur
93
+                $url = preg_replace(',#([^#&?]+)$,', "&var_ajax_ancre=\\1", $url);
94
+            }
95
+            $url = str_replace('&amp;', '&', $url); // les redirections se font en &, pas en en &amp;
96
+            redirige_par_entete($url);
97
+        }
98
+        if (!headers_sent()
99
+            and !ob_get_length()
100
+        ) {
101
+            http_status(204);
102
+        } // No Content
103
+        return true;
104
+    }
105 105
 
106
-	return false;
106
+    return false;
107 107
 }
108 108
 
109 109
 
110 110
 // https://code.spip.net/@refuser_traiter_formulaire_ajax
111 111
 function refuser_traiter_formulaire_ajax() {
112
-	if ($v = _request('var_ajax')
113
-		and $v == 'form'
114
-		and $form = _request('formulaire_action')
115
-		and $args = _request('formulaire_action_args')
116
-		and decoder_contexte_ajax($args, $form) !== false
117
-	) {
118
-		// on est bien dans le contexte de traitement d'un formulaire en ajax
119
-		// mais traiter ne veut pas
120
-		// on le dit a la page qui va resumbit
121
-		// sans ajax
122
-		include_spip('inc/actions');
123
-		ajax_retour('noajax', false);
124
-		exit;
125
-	}
112
+    if ($v = _request('var_ajax')
113
+        and $v == 'form'
114
+        and $form = _request('formulaire_action')
115
+        and $args = _request('formulaire_action_args')
116
+        and decoder_contexte_ajax($args, $form) !== false
117
+    ) {
118
+        // on est bien dans le contexte de traitement d'un formulaire en ajax
119
+        // mais traiter ne veut pas
120
+        // on le dit a la page qui va resumbit
121
+        // sans ajax
122
+        include_spip('inc/actions');
123
+        ajax_retour('noajax', false);
124
+        exit;
125
+    }
126 126
 }
127 127
 
128 128
 // https://code.spip.net/@traiter_appels_inclusions_ajax
129 129
 function traiter_appels_inclusions_ajax() {
130
-	// traiter les appels de bloc ajax (ex: pagination)
131
-	if ($v = _request('var_ajax')
132
-		and $v !== 'form'
133
-		and $args = _request('var_ajax_env')
134
-	) {
135
-		include_spip('inc/filtres');
136
-		include_spip('inc/actions');
137
-		if ($args = decoder_contexte_ajax($args)
138
-			and $fond = $args['fond']
139
-		) {
140
-			include_spip('public/assembler');
141
-			$contexte = calculer_contexte();
142
-			$contexte = array_merge($args, $contexte);
143
-			$page = recuperer_fond($fond, $contexte, array('trim' => false));
144
-			$texte = $page;
145
-			if ($ancre = _request('var_ajax_ancre')) {
146
-				// pas n'importe quoi quand meme dans la variable !
147
-				$ancre = str_replace(array('<', '"', "'"), array('&lt;', '&quot;', ''), $ancre);
148
-				$texte = "<a href='#$ancre' name='ajax_ancre' style='display:none;'>anchor</a>" . $texte;
149
-			}
150
-		} else {
151
-			include_spip('inc/headers');
152
-			http_status(403);
153
-			$texte = _L('signature ajax bloc incorrecte');
154
-		}
155
-		ajax_retour($texte, false);
130
+    // traiter les appels de bloc ajax (ex: pagination)
131
+    if ($v = _request('var_ajax')
132
+        and $v !== 'form'
133
+        and $args = _request('var_ajax_env')
134
+    ) {
135
+        include_spip('inc/filtres');
136
+        include_spip('inc/actions');
137
+        if ($args = decoder_contexte_ajax($args)
138
+            and $fond = $args['fond']
139
+        ) {
140
+            include_spip('public/assembler');
141
+            $contexte = calculer_contexte();
142
+            $contexte = array_merge($args, $contexte);
143
+            $page = recuperer_fond($fond, $contexte, array('trim' => false));
144
+            $texte = $page;
145
+            if ($ancre = _request('var_ajax_ancre')) {
146
+                // pas n'importe quoi quand meme dans la variable !
147
+                $ancre = str_replace(array('<', '"', "'"), array('&lt;', '&quot;', ''), $ancre);
148
+                $texte = "<a href='#$ancre' name='ajax_ancre' style='display:none;'>anchor</a>" . $texte;
149
+            }
150
+        } else {
151
+            include_spip('inc/headers');
152
+            http_status(403);
153
+            $texte = _L('signature ajax bloc incorrecte');
154
+        }
155
+        ajax_retour($texte, false);
156 156
 
157
-		return true; // on a fini le hit
158
-	}
157
+        return true; // on a fini le hit
158
+    }
159 159
 
160
-	return false;
160
+    return false;
161 161
 }
162 162
 
163 163
 // au 1er appel, traite les formulaires dynamiques charger/verifier/traiter
@@ -166,148 +166,148 @@  discard block
 block discarded – undo
166 166
 
167 167
 // https://code.spip.net/@traiter_formulaires_dynamiques
168 168
 function traiter_formulaires_dynamiques($get = false) {
169
-	static $post = array();
170
-	static $done = false;
169
+    static $post = array();
170
+    static $done = false;
171 171
 
172
-	if ($get) {
173
-		return $post;
174
-	}
175
-	if ($done) {
176
-		return false;
177
-	}
178
-	$done = true;
172
+    if ($get) {
173
+        return $post;
174
+    }
175
+    if ($done) {
176
+        return false;
177
+    }
178
+    $done = true;
179 179
 
180
-	if (!($form = _request('formulaire_action')
181
-		and $args = _request('formulaire_action_args'))
182
-	) {
183
-		return false;
184
-	} // le hit peut continuer normalement
180
+    if (!($form = _request('formulaire_action')
181
+        and $args = _request('formulaire_action_args'))
182
+    ) {
183
+        return false;
184
+    } // le hit peut continuer normalement
185 185
 
186
-	include_spip('inc/filtres');
187
-	if (($args = decoder_contexte_ajax($args, $form)) === false) {
188
-		spip_log("signature ajax form incorrecte : $form");
186
+    include_spip('inc/filtres');
187
+    if (($args = decoder_contexte_ajax($args, $form)) === false) {
188
+        spip_log("signature ajax form incorrecte : $form");
189 189
 
190
-		return false; // continuons le hit comme si de rien etait
191
-	} else {
192
-		include_spip('inc/lang');
193
-		// sauvegarder la lang en cours
194
-		$old_lang = $GLOBALS['spip_lang'];
195
-		// changer la langue avec celle qui a cours dans le formulaire
196
-		// on la depile de $args car c'est un argument implicite masque	
197
-		changer_langue(array_shift($args));
190
+        return false; // continuons le hit comme si de rien etait
191
+    } else {
192
+        include_spip('inc/lang');
193
+        // sauvegarder la lang en cours
194
+        $old_lang = $GLOBALS['spip_lang'];
195
+        // changer la langue avec celle qui a cours dans le formulaire
196
+        // on la depile de $args car c'est un argument implicite masque	
197
+        changer_langue(array_shift($args));
198 198
 
199 199
 
200
-		// inclure mes_fonctions et autres filtres avant verifier/traiter
201
-		include_fichiers_fonctions();
202
-		// ainsi que l'API SQL bien utile dans verifier/traiter
203
-		include_spip('base/abstract_sql');
200
+        // inclure mes_fonctions et autres filtres avant verifier/traiter
201
+        include_fichiers_fonctions();
202
+        // ainsi que l'API SQL bien utile dans verifier/traiter
203
+        include_spip('base/abstract_sql');
204 204
 
205
-		/**
206
-		 * Pipeline exécuté lors de la soumission d'un formulaire,
207
-		 * mais avant l'appel de la fonction de vérification.
208
-		 */
209
-		pipeline(
210
-			'formulaire_receptionner',
211
-			array(
212
-				'args' => array('form' => $form, 'args' => $args),
213
-				'data' => null,
214
-			)
215
-		);
205
+        /**
206
+         * Pipeline exécuté lors de la soumission d'un formulaire,
207
+         * mais avant l'appel de la fonction de vérification.
208
+         */
209
+        pipeline(
210
+            'formulaire_receptionner',
211
+            array(
212
+                'args' => array('form' => $form, 'args' => $args),
213
+                'data' => null,
214
+            )
215
+        );
216 216
 
217
-		$verifier = charger_fonction("verifier", "formulaires/$form/", true);
218
-		$post["erreurs_$form"] = pipeline(
219
-			'formulaire_verifier',
220
-			array(
221
-				'args' => array('form' => $form, 'args' => $args),
222
-				'data' => $verifier ? call_user_func_array($verifier, $args) : array()
223
-			)
224
-		);
225
-		// prise en charge CVT multi etape si besoin
226
-		if (_request('cvtm_prev_post')) {
227
-			include_spip('inc/cvt_multietapes');
228
-			$post["erreurs_$form"] = cvtmulti_formulaire_verifier_etapes(
229
-				array('form' => $form, 'args' => $args),
230
-				$post["erreurs_$form"]
231
-			);
232
-		}
217
+        $verifier = charger_fonction("verifier", "formulaires/$form/", true);
218
+        $post["erreurs_$form"] = pipeline(
219
+            'formulaire_verifier',
220
+            array(
221
+                'args' => array('form' => $form, 'args' => $args),
222
+                'data' => $verifier ? call_user_func_array($verifier, $args) : array()
223
+            )
224
+        );
225
+        // prise en charge CVT multi etape si besoin
226
+        if (_request('cvtm_prev_post')) {
227
+            include_spip('inc/cvt_multietapes');
228
+            $post["erreurs_$form"] = cvtmulti_formulaire_verifier_etapes(
229
+                array('form' => $form, 'args' => $args),
230
+                $post["erreurs_$form"]
231
+            );
232
+        }
233 233
 
234
-		// accessibilite : si des erreurs mais pas de message general l'ajouter
235
-		if ((isset($post["erreurs_$form"]) and count($post["erreurs_$form"])) and !isset($post["erreurs_$form"]['message_erreur'])) {
236
-			$post["erreurs_$form"]['message_erreur'] = singulier_ou_pluriel(count($post["erreurs_$form"]),
237
-				'avis_1_erreur_saisie', 'avis_nb_erreurs_saisie');
238
-		}
234
+        // accessibilite : si des erreurs mais pas de message general l'ajouter
235
+        if ((isset($post["erreurs_$form"]) and count($post["erreurs_$form"])) and !isset($post["erreurs_$form"]['message_erreur'])) {
236
+            $post["erreurs_$form"]['message_erreur'] = singulier_ou_pluriel(count($post["erreurs_$form"]),
237
+                'avis_1_erreur_saisie', 'avis_nb_erreurs_saisie');
238
+        }
239 239
 
240
-		// si on ne demandait qu'une verif json
241
-		if (_request('formulaire_action_verifier_json')) {
242
-			include_spip('inc/json');
243
-			include_spip('inc/actions');
244
-			ajax_retour(json_encode($post["erreurs_$form"]), 'text/plain');
240
+        // si on ne demandait qu'une verif json
241
+        if (_request('formulaire_action_verifier_json')) {
242
+            include_spip('inc/json');
243
+            include_spip('inc/actions');
244
+            ajax_retour(json_encode($post["erreurs_$form"]), 'text/plain');
245 245
 
246
-			return true; // on a fini le hit
247
-		}
248
-		$retour = "";
249
-		if (isset($post["erreurs_$form"]) and (count($post["erreurs_$form"]) == 0)) {
250
-			$rev = "";
251
-			if ($traiter = charger_fonction("traiter", "formulaires/$form/", true)) {
252
-				$rev = call_user_func_array($traiter, $args);
253
-			}
246
+            return true; // on a fini le hit
247
+        }
248
+        $retour = "";
249
+        if (isset($post["erreurs_$form"]) and (count($post["erreurs_$form"]) == 0)) {
250
+            $rev = "";
251
+            if ($traiter = charger_fonction("traiter", "formulaires/$form/", true)) {
252
+                $rev = call_user_func_array($traiter, $args);
253
+            }
254 254
 
255
-			$rev = pipeline(
256
-				'formulaire_traiter',
257
-				array(
258
-					'args' => array('form' => $form, 'args' => $args),
259
-					'data' => $rev
260
-				)
261
-			);
262
-			// le retour de traiter est
263
-			// un tableau explicite ('editable'=>$editable,'message_ok'=>$message,'redirect'=>$redirect,'id_xx'=>$id_xx)
264
-			// il permet le pipelinage, en particulier
265
-			// en y passant l'id de l'objet cree/modifie
266
-			// si message_erreur est present, on considere que le traitement a echoue
267
-			$post["message_ok_$form"] = '';
268
-			// on peut avoir message_ok et message_erreur
269
-			if (isset($rev['message_ok'])) {
270
-				$post["message_ok_$form"] = $rev['message_ok'];
271
-			}
255
+            $rev = pipeline(
256
+                'formulaire_traiter',
257
+                array(
258
+                    'args' => array('form' => $form, 'args' => $args),
259
+                    'data' => $rev
260
+                )
261
+            );
262
+            // le retour de traiter est
263
+            // un tableau explicite ('editable'=>$editable,'message_ok'=>$message,'redirect'=>$redirect,'id_xx'=>$id_xx)
264
+            // il permet le pipelinage, en particulier
265
+            // en y passant l'id de l'objet cree/modifie
266
+            // si message_erreur est present, on considere que le traitement a echoue
267
+            $post["message_ok_$form"] = '';
268
+            // on peut avoir message_ok et message_erreur
269
+            if (isset($rev['message_ok'])) {
270
+                $post["message_ok_$form"] = $rev['message_ok'];
271
+            }
272 272
 
273
-			// verifier si traiter n'a pas echoue avec une erreur :
274
-			if (isset($rev['message_erreur'])) {
275
-				$post["erreurs_$form"]["message_erreur"] = $rev['message_erreur'];
276
-				// si il y a une erreur on ne redirige pas
277
-			} else {
278
-				// sinon faire ce qu'il faut :
279
-				if (isset($rev['editable'])) {
280
-					$post["editable_$form"] = $rev['editable'];
281
-				}
282
-				// si une redirection est demandee, appeler redirigae_formulaire qui choisira
283
-				// le bon mode de redirection (302 et on ne revient pas ici, ou javascript et on continue)
284
-				if (isset($rev['redirect']) and $rev['redirect']) {
285
-					include_spip('inc/headers');
286
-					list($masque, $message) = redirige_formulaire($rev['redirect'], '', 'ajaxform');
287
-					$post["message_ok_$form"] .= $message;
288
-					$retour .= $masque;
289
-				}
290
-			}
291
-		}
292
-		// si le formulaire a ete soumis en ajax, on le renvoie direct !
293
-		if (_request('var_ajax')) {
294
-			if (find_in_path('formulaire_.php', 'balise/', true)) {
295
-				include_spip('inc/actions');
296
-				include_spip('public/assembler');
297
-				array_unshift($args, $form);
298
-				$retour .= inclure_balise_dynamique(call_user_func_array('balise_formulaire__dyn', $args), false);
299
-				// on ajoute un br en display none en tete du retour ajax pour regler un bug dans IE6/7
300
-				// sans cela le formulaire n'est pas actif apres le hit ajax
301
-				// la classe ajax-form-is-ok sert a s'assurer que le retour ajax s'est bien passe
302
-				$retour = "<br class='bugajaxie ajax-form-is-ok' style='display:none;'/>" . $retour;
303
-				ajax_retour($retour, false);
273
+            // verifier si traiter n'a pas echoue avec une erreur :
274
+            if (isset($rev['message_erreur'])) {
275
+                $post["erreurs_$form"]["message_erreur"] = $rev['message_erreur'];
276
+                // si il y a une erreur on ne redirige pas
277
+            } else {
278
+                // sinon faire ce qu'il faut :
279
+                if (isset($rev['editable'])) {
280
+                    $post["editable_$form"] = $rev['editable'];
281
+                }
282
+                // si une redirection est demandee, appeler redirigae_formulaire qui choisira
283
+                // le bon mode de redirection (302 et on ne revient pas ici, ou javascript et on continue)
284
+                if (isset($rev['redirect']) and $rev['redirect']) {
285
+                    include_spip('inc/headers');
286
+                    list($masque, $message) = redirige_formulaire($rev['redirect'], '', 'ajaxform');
287
+                    $post["message_ok_$form"] .= $message;
288
+                    $retour .= $masque;
289
+                }
290
+            }
291
+        }
292
+        // si le formulaire a ete soumis en ajax, on le renvoie direct !
293
+        if (_request('var_ajax')) {
294
+            if (find_in_path('formulaire_.php', 'balise/', true)) {
295
+                include_spip('inc/actions');
296
+                include_spip('public/assembler');
297
+                array_unshift($args, $form);
298
+                $retour .= inclure_balise_dynamique(call_user_func_array('balise_formulaire__dyn', $args), false);
299
+                // on ajoute un br en display none en tete du retour ajax pour regler un bug dans IE6/7
300
+                // sans cela le formulaire n'est pas actif apres le hit ajax
301
+                // la classe ajax-form-is-ok sert a s'assurer que le retour ajax s'est bien passe
302
+                $retour = "<br class='bugajaxie ajax-form-is-ok' style='display:none;'/>" . $retour;
303
+                ajax_retour($retour, false);
304 304
 
305
-				return true; // on a fini le hit
306
-			}
307
-		}
308
-		// restaurer la lang en cours
309
-		changer_langue($old_lang);
310
-	}
305
+                return true; // on a fini le hit
306
+            }
307
+        }
308
+        // restaurer la lang en cours
309
+        changer_langue($old_lang);
310
+    }
311 311
 
312
-	return false; // le hit peut continuer normalement
312
+    return false; // le hit peut continuer normalement
313 313
 }
Please login to merge, or discard this patch.
ecrire/base/dump.php 2 patches
Indentation   +486 added lines, -486 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  */
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 define('_VERSION_ARCHIVE', '1.3');
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
  * @return string
39 39
  **/
40 40
 function base_dump_meta_name($rub) {
41
-	return $meta = "status_dump_{$rub}_" . abs($GLOBALS['visiteur_session']['id_auteur']);
41
+    return $meta = "status_dump_{$rub}_" . abs($GLOBALS['visiteur_session']['id_auteur']);
42 42
 }
43 43
 
44 44
 /**
@@ -53,15 +53,15 @@  discard block
 block discarded – undo
53 53
  * @return string
54 54
  **/
55 55
 function base_dump_dir($meta) {
56
-	include_spip('inc/documents');
57
-	// determine upload va aussi initialiser l'index "restreint"
58
-	$maindir = determine_upload();
59
-	if (!$GLOBALS['visiteur_session']['restreint']) {
60
-		$maindir = _DIR_DUMP;
61
-	}
62
-	$dir = sous_repertoire($maindir, $meta);
63
-
64
-	return $dir;
56
+    include_spip('inc/documents');
57
+    // determine upload va aussi initialiser l'index "restreint"
58
+    $maindir = determine_upload();
59
+    if (!$GLOBALS['visiteur_session']['restreint']) {
60
+        $maindir = _DIR_DUMP;
61
+    }
62
+    $dir = sous_repertoire($maindir, $meta);
63
+
64
+    return $dir;
65 65
 }
66 66
 
67 67
 /**
@@ -75,28 +75,28 @@  discard block
 block discarded – undo
75 75
  * @return array
76 76
  */
77 77
 function base_lister_toutes_tables(
78
-	$serveur = '',
79
-	$tables = array(),
80
-	$exclude = array(),
81
-	$affiche_vrai_prefixe = false
78
+    $serveur = '',
79
+    $tables = array(),
80
+    $exclude = array(),
81
+    $affiche_vrai_prefixe = false
82 82
 ) {
83
-	spip_connect($serveur);
84
-	$connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0];
85
-	$prefixe = $connexion['prefixe'];
86
-
87
-	$p = '/^' . $prefixe . '/';
88
-	$res = $tables;
89
-	foreach (sql_alltable(null, $serveur) as $t) {
90
-		if (preg_match($p, $t)) {
91
-			$t1 = preg_replace($p, 'spip', $t);
92
-			if (!in_array($t1, $tables) and !in_array($t1, $exclude)) {
93
-				$res[] = ($affiche_vrai_prefixe ? $t : $t1);
94
-			}
95
-		}
96
-	}
97
-	sort($res);
98
-
99
-	return $res;
83
+    spip_connect($serveur);
84
+    $connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0];
85
+    $prefixe = $connexion['prefixe'];
86
+
87
+    $p = '/^' . $prefixe . '/';
88
+    $res = $tables;
89
+    foreach (sql_alltable(null, $serveur) as $t) {
90
+        if (preg_match($p, $t)) {
91
+            $t1 = preg_replace($p, 'spip', $t);
92
+            if (!in_array($t1, $tables) and !in_array($t1, $exclude)) {
93
+                $res[] = ($affiche_vrai_prefixe ? $t : $t1);
94
+            }
95
+        }
96
+    }
97
+    sort($res);
98
+
99
+    return $res;
100 100
 }
101 101
 
102 102
 /**
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
  * @return string
107 107
  */
108 108
 function base_prefixe_tables($serveur = '') {
109
-	spip_connect($serveur);
110
-	$connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0];
111
-	$prefixe = $connexion['prefixe'];
109
+    spip_connect($serveur);
110
+    $connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0];
111
+    $prefixe = $connexion['prefixe'];
112 112
 
113
-	return $prefixe;
113
+    return $prefixe;
114 114
 }
115 115
 
116 116
 
@@ -125,29 +125,29 @@  discard block
 block discarded – undo
125 125
  * @return array
126 126
  */
127 127
 function base_saisie_tables($name, $tables, $exclude = array(), $post = null, $serveur = '') {
128
-	include_spip('inc/filtres');
129
-	$res = array();
130
-	foreach ($tables as $k => $t) {
131
-		// par defaut tout est coche sauf les tables dans $exclude
132
-		if (is_null($post)) {
133
-			$check = (in_array($t, $exclude) ? false : true);
134
-		} // mais si on a poste une selection, la reprendre
135
-		else {
136
-			$check = in_array($t, $post);
137
-		}
138
-
139
-		$res[$k] = "<input type='checkbox' value='$t' name='$name"
140
-			. "[]' id='$name$k'"
141
-			. ($check ? " checked='checked'" : '')
142
-			. "/>\n"
143
-			. "<label for='$name$k'>$t</label>"
144
-			. " ("
145
-			. sinon(singulier_ou_pluriel(sql_countsel($t, '', '', '', $serveur), 'dump:une_donnee', 'dump:nb_donnees'),
146
-				_T('dump:aucune_donnee'))
147
-			. ")";
148
-	}
149
-
150
-	return $res;
128
+    include_spip('inc/filtres');
129
+    $res = array();
130
+    foreach ($tables as $k => $t) {
131
+        // par defaut tout est coche sauf les tables dans $exclude
132
+        if (is_null($post)) {
133
+            $check = (in_array($t, $exclude) ? false : true);
134
+        } // mais si on a poste une selection, la reprendre
135
+        else {
136
+            $check = in_array($t, $post);
137
+        }
138
+
139
+        $res[$k] = "<input type='checkbox' value='$t' name='$name"
140
+            . "[]' id='$name$k'"
141
+            . ($check ? " checked='checked'" : '')
142
+            . "/>\n"
143
+            . "<label for='$name$k'>$t</label>"
144
+            . " ("
145
+            . sinon(singulier_ou_pluriel(sql_countsel($t, '', '', '', $serveur), 'dump:une_donnee', 'dump:nb_donnees'),
146
+                _T('dump:aucune_donnee'))
147
+            . ")";
148
+    }
149
+
150
+    return $res;
151 151
 }
152 152
 
153 153
 
@@ -159,27 +159,27 @@  discard block
 block discarded – undo
159 159
  * @return array
160 160
  */
161 161
 function lister_tables_noexport() {
162
-	// par defaut tout est exporte sauf les tables ci-dessous
163
-	static $EXPORT_tables_noexport = null;
164
-	if (!is_null($EXPORT_tables_noexport)) {
165
-		return $EXPORT_tables_noexport;
166
-	}
167
-
168
-	$EXPORT_tables_noexport = array(
169
-		'spip_caches', // plugin invalideur
170
-		'spip_resultats', // resultats de recherche ... c'est un cache !
171
-		'spip_test', // c'est un test !
172
-		#'spip_referers',
173
-		#'spip_referers_articles',
174
-		#'spip_visites',
175
-		#'spip_visites_articles',
176
-		#'spip_versions',
177
-		#'spip_versions_fragments'
178
-	);
179
-
180
-	$EXPORT_tables_noexport = pipeline('lister_tables_noexport', $EXPORT_tables_noexport);
181
-
182
-	return $EXPORT_tables_noexport;
162
+    // par defaut tout est exporte sauf les tables ci-dessous
163
+    static $EXPORT_tables_noexport = null;
164
+    if (!is_null($EXPORT_tables_noexport)) {
165
+        return $EXPORT_tables_noexport;
166
+    }
167
+
168
+    $EXPORT_tables_noexport = array(
169
+        'spip_caches', // plugin invalideur
170
+        'spip_resultats', // resultats de recherche ... c'est un cache !
171
+        'spip_test', // c'est un test !
172
+        #'spip_referers',
173
+        #'spip_referers_articles',
174
+        #'spip_visites',
175
+        #'spip_visites_articles',
176
+        #'spip_versions',
177
+        #'spip_versions_fragments'
178
+    );
179
+
180
+    $EXPORT_tables_noexport = pipeline('lister_tables_noexport', $EXPORT_tables_noexport);
181
+
182
+    return $EXPORT_tables_noexport;
183 183
 }
184 184
 
185 185
 /**
@@ -190,25 +190,25 @@  discard block
 block discarded – undo
190 190
  * @return array
191 191
  */
192 192
 function lister_tables_noimport() {
193
-	static $IMPORT_tables_noimport = null;
194
-	if (!is_null($IMPORT_tables_noimport)) {
195
-		return $IMPORT_tables_noimport;
196
-	}
197
-
198
-	$IMPORT_tables_noimport = array();
199
-	// par defaut tout est importe sauf les tables ci-dessous
200
-	// possibiliter de definir cela tables via la meta
201
-	// compatibilite
202
-	if (isset($GLOBALS['meta']['IMPORT_tables_noimport'])) {
203
-		$IMPORT_tables_noimport = unserialize($GLOBALS['meta']['IMPORT_tables_noimport']);
204
-		if (!is_array($IMPORT_tables_noimport)) {
205
-			include_spip('inc/meta');
206
-			effacer_meta('IMPORT_tables_noimport');
207
-		}
208
-	}
209
-	$IMPORT_tables_noimport = pipeline('lister_tables_noimport', $IMPORT_tables_noimport);
210
-
211
-	return $IMPORT_tables_noimport;
193
+    static $IMPORT_tables_noimport = null;
194
+    if (!is_null($IMPORT_tables_noimport)) {
195
+        return $IMPORT_tables_noimport;
196
+    }
197
+
198
+    $IMPORT_tables_noimport = array();
199
+    // par defaut tout est importe sauf les tables ci-dessous
200
+    // possibiliter de definir cela tables via la meta
201
+    // compatibilite
202
+    if (isset($GLOBALS['meta']['IMPORT_tables_noimport'])) {
203
+        $IMPORT_tables_noimport = unserialize($GLOBALS['meta']['IMPORT_tables_noimport']);
204
+        if (!is_array($IMPORT_tables_noimport)) {
205
+            include_spip('inc/meta');
206
+            effacer_meta('IMPORT_tables_noimport');
207
+        }
208
+    }
209
+    $IMPORT_tables_noimport = pipeline('lister_tables_noimport', $IMPORT_tables_noimport);
210
+
211
+    return $IMPORT_tables_noimport;
212 212
 }
213 213
 
214 214
 
@@ -220,23 +220,23 @@  discard block
 block discarded – undo
220 220
  * @return array
221 221
  */
222 222
 function lister_tables_noerase() {
223
-	static $IMPORT_tables_noerase = null;
224
-	if (!is_null($IMPORT_tables_noerase)) {
225
-		return $IMPORT_tables_noerase;
226
-	}
227
-
228
-	$IMPORT_tables_noerase = array(
229
-		'spip_meta',
230
-		// par defaut on ne vide pas les stats, car elles ne figurent pas dans les dump
231
-		// et le cas echeant, un bouton dans l'admin permet de les vider a la main...
232
-		'spip_referers',
233
-		'spip_referers_articles',
234
-		'spip_visites',
235
-		'spip_visites_articles'
236
-	);
237
-	$IMPORT_tables_noerase = pipeline('lister_tables_noerase', $IMPORT_tables_noerase);
238
-
239
-	return $IMPORT_tables_noerase;
223
+    static $IMPORT_tables_noerase = null;
224
+    if (!is_null($IMPORT_tables_noerase)) {
225
+        return $IMPORT_tables_noerase;
226
+    }
227
+
228
+    $IMPORT_tables_noerase = array(
229
+        'spip_meta',
230
+        // par defaut on ne vide pas les stats, car elles ne figurent pas dans les dump
231
+        // et le cas echeant, un bouton dans l'admin permet de les vider a la main...
232
+        'spip_referers',
233
+        'spip_referers_articles',
234
+        'spip_visites',
235
+        'spip_visites_articles'
236
+    );
237
+    $IMPORT_tables_noerase = pipeline('lister_tables_noerase', $IMPORT_tables_noerase);
238
+
239
+    return $IMPORT_tables_noerase;
240 240
 }
241 241
 
242 242
 
@@ -250,83 +250,83 @@  discard block
 block discarded – undo
250 250
  * @return array
251 251
  */
252 252
 function base_liste_table_for_dump($exclude_tables = array()) {
253
-	$tables_for_dump = array();
254
-	$tables_pointees = array();
255
-	$tables = array();
256
-	$tables_principales = $GLOBALS['tables_principales'];
257
-	$tables_auxiliaires = $GLOBALS['tables_auxiliaires'];
258
-	$tables_jointures = $GLOBALS['tables_jointures'];
259
-
260
-	if (include_spip('base/objets')
261
-		and function_exists('lister_tables_objets_sql')
262
-	) {
263
-		$tables = lister_tables_objets_sql();
264
-		foreach ($tables as $t => $infos) {
265
-			if ($infos['principale'] and !isset($tables_principales[$t])) {
266
-				$tables_principales[$t] = true;
267
-			}
268
-			if (!$infos['principale'] and !isset($tables_auxiliaires[$t])) {
269
-				$tables_auxiliaires[$t] = true;
270
-			}
271
-			if (count($infos['tables_jointures'])) {
272
-				$tables_jointures[$t] = array_merge(isset($tables_jointures[$t]) ? $tables_jointures[$t] : array(),
273
-					$infos['tables_jointures']);
274
-			}
275
-		}
276
-	}
277
-
278
-	// on construit un index des tables de liens
279
-	// pour les ajouter SI les deux tables qu'ils connectent sont sauvegardees
280
-	$tables_for_link = array();
281
-	foreach ($tables_jointures as $table => $liste_relations) {
282
-		if (is_array($liste_relations)) {
283
-			$nom = $table;
284
-			if (!isset($tables_auxiliaires[$nom]) && !isset($tables_principales[$nom])) {
285
-				$nom = "spip_$table";
286
-			}
287
-			if (isset($tables_auxiliaires[$nom]) || isset($tables_principales[$nom])) {
288
-				foreach ($liste_relations as $link_table) {
289
-					if (isset($tables_auxiliaires[$link_table])/*||isset($tables_principales[$link_table])*/) {
290
-						$tables_for_link[$link_table][] = $nom;
291
-					} else {
292
-						if (isset($tables_auxiliaires["spip_$link_table"])/*||isset($tables_principales["spip_$link_table"])*/) {
293
-							$tables_for_link["spip_$link_table"][] = $nom;
294
-						}
295
-					}
296
-				}
297
-			}
298
-		}
299
-	}
300
-
301
-	$liste_tables = array_merge(array_keys($tables_principales), array_keys($tables_auxiliaires), array_keys($tables));
302
-	foreach ($liste_tables as $table) {
303
-		//		$name = preg_replace("{^spip_}","",$table);
304
-		if (!isset($tables_pointees[$table])
305
-			&& !in_array($table, $exclude_tables)
306
-			&& !isset($tables_for_link[$table])
307
-		) {
308
-			$tables_for_dump[] = $table;
309
-			$tables_pointees[$table] = 1;
310
-		}
311
-	}
312
-	foreach ($tables_for_link as $link_table => $liste) {
313
-		$connecte = true;
314
-		foreach ($liste as $connect_table) {
315
-			if (!in_array($connect_table, $tables_for_dump)) {
316
-				$connecte = false;
317
-			}
318
-		}
319
-		if ($connecte)
320
-			# on ajoute les liaisons en premier
321
-			# si une restauration est interrompue,
322
-			# cela se verra mieux si il manque des objets
323
-			# que des liens
324
-		{
325
-			array_unshift($tables_for_dump, $link_table);
326
-		}
327
-	}
328
-
329
-	return array($tables_for_dump, $tables_for_link);
253
+    $tables_for_dump = array();
254
+    $tables_pointees = array();
255
+    $tables = array();
256
+    $tables_principales = $GLOBALS['tables_principales'];
257
+    $tables_auxiliaires = $GLOBALS['tables_auxiliaires'];
258
+    $tables_jointures = $GLOBALS['tables_jointures'];
259
+
260
+    if (include_spip('base/objets')
261
+        and function_exists('lister_tables_objets_sql')
262
+    ) {
263
+        $tables = lister_tables_objets_sql();
264
+        foreach ($tables as $t => $infos) {
265
+            if ($infos['principale'] and !isset($tables_principales[$t])) {
266
+                $tables_principales[$t] = true;
267
+            }
268
+            if (!$infos['principale'] and !isset($tables_auxiliaires[$t])) {
269
+                $tables_auxiliaires[$t] = true;
270
+            }
271
+            if (count($infos['tables_jointures'])) {
272
+                $tables_jointures[$t] = array_merge(isset($tables_jointures[$t]) ? $tables_jointures[$t] : array(),
273
+                    $infos['tables_jointures']);
274
+            }
275
+        }
276
+    }
277
+
278
+    // on construit un index des tables de liens
279
+    // pour les ajouter SI les deux tables qu'ils connectent sont sauvegardees
280
+    $tables_for_link = array();
281
+    foreach ($tables_jointures as $table => $liste_relations) {
282
+        if (is_array($liste_relations)) {
283
+            $nom = $table;
284
+            if (!isset($tables_auxiliaires[$nom]) && !isset($tables_principales[$nom])) {
285
+                $nom = "spip_$table";
286
+            }
287
+            if (isset($tables_auxiliaires[$nom]) || isset($tables_principales[$nom])) {
288
+                foreach ($liste_relations as $link_table) {
289
+                    if (isset($tables_auxiliaires[$link_table])/*||isset($tables_principales[$link_table])*/) {
290
+                        $tables_for_link[$link_table][] = $nom;
291
+                    } else {
292
+                        if (isset($tables_auxiliaires["spip_$link_table"])/*||isset($tables_principales["spip_$link_table"])*/) {
293
+                            $tables_for_link["spip_$link_table"][] = $nom;
294
+                        }
295
+                    }
296
+                }
297
+            }
298
+        }
299
+    }
300
+
301
+    $liste_tables = array_merge(array_keys($tables_principales), array_keys($tables_auxiliaires), array_keys($tables));
302
+    foreach ($liste_tables as $table) {
303
+        //		$name = preg_replace("{^spip_}","",$table);
304
+        if (!isset($tables_pointees[$table])
305
+            && !in_array($table, $exclude_tables)
306
+            && !isset($tables_for_link[$table])
307
+        ) {
308
+            $tables_for_dump[] = $table;
309
+            $tables_pointees[$table] = 1;
310
+        }
311
+    }
312
+    foreach ($tables_for_link as $link_table => $liste) {
313
+        $connecte = true;
314
+        foreach ($liste as $connect_table) {
315
+            if (!in_array($connect_table, $tables_for_dump)) {
316
+                $connecte = false;
317
+            }
318
+        }
319
+        if ($connecte)
320
+            # on ajoute les liaisons en premier
321
+            # si une restauration est interrompue,
322
+            # cela se verra mieux si il manque des objets
323
+            # que des liens
324
+        {
325
+            array_unshift($tables_for_dump, $link_table);
326
+        }
327
+    }
328
+
329
+    return array($tables_for_dump, $tables_for_link);
330 330
 }
331 331
 
332 332
 /**
@@ -341,34 +341,34 @@  discard block
 block discarded – undo
341 341
  * @param string $serveur
342 342
  */
343 343
 function base_vider_tables_destination_copie($tables, $exclure_tables = array(), $serveur = '') {
344
-	$trouver_table = charger_fonction('trouver_table', 'base');
345
-
346
-	spip_log('Vider ' . count($tables) . " tables sur serveur '$serveur' : " . join(', ', $tables),
347
-		'base.' . _LOG_INFO_IMPORTANTE);
348
-	foreach ($tables as $table) {
349
-		if (!in_array($table, $exclure_tables)) {
350
-			// sur le serveur principal, il ne faut pas supprimer l'auteur loge !
351
-			if (($table != 'spip_auteurs') or $serveur != '') {
352
-				// regarder si il y a au moins un champ impt='non'
353
-				$desc = $trouver_table($table, $serveur);
354
-				if (isset($desc['field']['impt'])) {
355
-					sql_delete($table, "impt='oui'", $serveur);
356
-				} else {
357
-					sql_delete($table, "", $serveur);
358
-				}
359
-			}
360
-		}
361
-	}
362
-
363
-	// sur le serveur principal, il ne faut pas supprimer l'auteur loge !
364
-	// Bidouille pour garder l'acces admin actuel pendant toute la restauration
365
-	if ($serveur == ''
366
-		and in_array('spip_auteurs', $tables)
367
-		and !in_array('spip_auteurs', $exclure_tables)
368
-	) {
369
-		base_conserver_copieur(true, $serveur);
370
-		sql_delete("spip_auteurs", "id_auteur>0", $serveur);
371
-	}
344
+    $trouver_table = charger_fonction('trouver_table', 'base');
345
+
346
+    spip_log('Vider ' . count($tables) . " tables sur serveur '$serveur' : " . join(', ', $tables),
347
+        'base.' . _LOG_INFO_IMPORTANTE);
348
+    foreach ($tables as $table) {
349
+        if (!in_array($table, $exclure_tables)) {
350
+            // sur le serveur principal, il ne faut pas supprimer l'auteur loge !
351
+            if (($table != 'spip_auteurs') or $serveur != '') {
352
+                // regarder si il y a au moins un champ impt='non'
353
+                $desc = $trouver_table($table, $serveur);
354
+                if (isset($desc['field']['impt'])) {
355
+                    sql_delete($table, "impt='oui'", $serveur);
356
+                } else {
357
+                    sql_delete($table, "", $serveur);
358
+                }
359
+            }
360
+        }
361
+    }
362
+
363
+    // sur le serveur principal, il ne faut pas supprimer l'auteur loge !
364
+    // Bidouille pour garder l'acces admin actuel pendant toute la restauration
365
+    if ($serveur == ''
366
+        and in_array('spip_auteurs', $tables)
367
+        and !in_array('spip_auteurs', $exclure_tables)
368
+    ) {
369
+        base_conserver_copieur(true, $serveur);
370
+        sql_delete("spip_auteurs", "id_auteur>0", $serveur);
371
+    }
372 372
 }
373 373
 
374 374
 /**
@@ -379,21 +379,21 @@  discard block
 block discarded – undo
379 379
  * @return void
380 380
  */
381 381
 function base_conserver_copieur($move = true, $serveur = '') {
382
-	// s'asurer qu'on a pas deja fait la manip !
383
-	if ($GLOBALS['visiteur_session']['id_auteur'] > 0 and sql_countsel("spip_auteurs", "id_auteur>0")) {
384
-		spip_log('Conserver copieur dans id_auteur=' . $GLOBALS['visiteur_session']['id_auteur'] . " pour le serveur '$serveur'",
385
-			'dump.' . _LOG_INFO_IMPORTANTE);
386
-		sql_delete("spip_auteurs", "id_auteur<0", $serveur);
387
-		if ($move) {
388
-			sql_updateq('spip_auteurs', array('id_auteur' => -$GLOBALS['visiteur_session']['id_auteur']),
389
-				"id_auteur=" . intval($GLOBALS['visiteur_session']['id_auteur']), array(), $serveur);
390
-		} else {
391
-			$row = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $GLOBALS['visiteur_session']['id_auteur'], '', '', '', '',
392
-				$serveur);
393
-			$row['id_auteur'] = -$GLOBALS['visiteur_session']['id_auteur'];
394
-			sql_insertq('spip_auteurs', $row, array(), $serveur);
395
-		}
396
-	}
382
+    // s'asurer qu'on a pas deja fait la manip !
383
+    if ($GLOBALS['visiteur_session']['id_auteur'] > 0 and sql_countsel("spip_auteurs", "id_auteur>0")) {
384
+        spip_log('Conserver copieur dans id_auteur=' . $GLOBALS['visiteur_session']['id_auteur'] . " pour le serveur '$serveur'",
385
+            'dump.' . _LOG_INFO_IMPORTANTE);
386
+        sql_delete("spip_auteurs", "id_auteur<0", $serveur);
387
+        if ($move) {
388
+            sql_updateq('spip_auteurs', array('id_auteur' => -$GLOBALS['visiteur_session']['id_auteur']),
389
+                "id_auteur=" . intval($GLOBALS['visiteur_session']['id_auteur']), array(), $serveur);
390
+        } else {
391
+            $row = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $GLOBALS['visiteur_session']['id_auteur'], '', '', '', '',
392
+                $serveur);
393
+            $row['id_auteur'] = -$GLOBALS['visiteur_session']['id_auteur'];
394
+            sql_insertq('spip_auteurs', $row, array(), $serveur);
395
+        }
396
+    }
397 397
 }
398 398
 
399 399
 /**
@@ -408,19 +408,19 @@  discard block
 block discarded – undo
408 408
  * @param string $serveur
409 409
  */
410 410
 function base_detruire_copieur_si_besoin($serveur = '') {
411
-	// rien a faire si ce n'est pas le serveur principal !
412
-	if ($serveur == '') {
413
-		if (sql_countsel("spip_auteurs", "id_auteur>0")) {
414
-			spip_log("Detruire copieur id_auteur<0 pour le serveur '$serveur'", 'dump.' . _LOG_INFO_IMPORTANTE);
415
-			sql_delete("spip_auteurs", "id_auteur<0", $serveur);
416
-		} else {
417
-			spip_log("Restaurer copieur id_auteur<0 pour le serveur '$serveur' (aucun autre auteur en base)",
418
-				'dump.' . _LOG_INFO_IMPORTANTE);
419
-			sql_update('spip_auteurs', array('id_auteur' => '-id_auteur'), "id_auteur<0");
420
-		}
421
-	} else {
422
-		spip_log("Pas de destruction copieur sur serveur '$serveur'", 'dump.' . _LOG_INFO_IMPORTANTE);
423
-	}
411
+    // rien a faire si ce n'est pas le serveur principal !
412
+    if ($serveur == '') {
413
+        if (sql_countsel("spip_auteurs", "id_auteur>0")) {
414
+            spip_log("Detruire copieur id_auteur<0 pour le serveur '$serveur'", 'dump.' . _LOG_INFO_IMPORTANTE);
415
+            sql_delete("spip_auteurs", "id_auteur<0", $serveur);
416
+        } else {
417
+            spip_log("Restaurer copieur id_auteur<0 pour le serveur '$serveur' (aucun autre auteur en base)",
418
+                'dump.' . _LOG_INFO_IMPORTANTE);
419
+            sql_update('spip_auteurs', array('id_auteur' => '-id_auteur'), "id_auteur<0");
420
+        }
421
+    } else {
422
+        spip_log("Pas de destruction copieur sur serveur '$serveur'", 'dump.' . _LOG_INFO_IMPORTANTE);
423
+    }
424 424
 }
425 425
 
426 426
 /**
@@ -435,40 +435,40 @@  discard block
 block discarded – undo
435 435
  * @return array
436 436
  */
437 437
 function base_preparer_table_dest($table, $desc, $serveur_dest, $init = false) {
438
-	$upgrade = false;
439
-	// si la table existe et qu'on est a l'init, la dropper
440
-	if ($desc_dest = sql_showtable($table, true, $serveur_dest) and $init) {
441
-		if ($serveur_dest == '' and in_array($table, array('spip_meta', 'spip_auteurs'))) {
442
-			// ne pas dropper auteurs et meta sur le serveur principal
443
-			// faire un simple upgrade a la place
444
-			// pour ajouter les champs manquants
445
-			$upgrade = true;
446
-			// coherence avec le drop sur les autres tables
447
-			base_vider_tables_destination_copie(array($table), array(), $serveur_dest);
448
-			if ($table == 'spip_meta') {
449
-				// virer les version base qui vont venir avec l'import
450
-				sql_delete($table, "nom like '%_base_version'", $serveur_dest);
451
-				// hum casse la base si pas version_installee a l'import ...
452
-				sql_delete($table, "nom='version_installee'", $serveur_dest);
453
-			}
454
-		} else {
455
-			sql_drop_table($table, '', $serveur_dest);
456
-			spip_log("drop table '$table' sur serveur '$serveur_dest'", 'dump.' . _LOG_INFO_IMPORTANTE);
457
-		}
458
-		$desc_dest = false;
459
-	}
460
-	// si la table n'existe pas dans la destination, la creer a l'identique !
461
-	if (!$desc_dest) {
462
-		spip_log("creation '$table' sur serveur '$serveur_dest'", 'dump.' . _LOG_INFO_IMPORTANTE);
463
-		include_spip('base/create');
464
-		creer_ou_upgrader_table($table, $desc, 'auto', $upgrade, $serveur_dest);
465
-		$desc_dest = sql_showtable($table, true, $serveur_dest);
466
-	}
467
-	if (!$desc_dest) {
468
-		spip_log("Erreur creation '$table' sur serveur '$serveur_dest'" . var_export($desc, 1), 'dump.' . _LOG_ERREUR);
469
-	}
470
-
471
-	return $desc_dest;
438
+    $upgrade = false;
439
+    // si la table existe et qu'on est a l'init, la dropper
440
+    if ($desc_dest = sql_showtable($table, true, $serveur_dest) and $init) {
441
+        if ($serveur_dest == '' and in_array($table, array('spip_meta', 'spip_auteurs'))) {
442
+            // ne pas dropper auteurs et meta sur le serveur principal
443
+            // faire un simple upgrade a la place
444
+            // pour ajouter les champs manquants
445
+            $upgrade = true;
446
+            // coherence avec le drop sur les autres tables
447
+            base_vider_tables_destination_copie(array($table), array(), $serveur_dest);
448
+            if ($table == 'spip_meta') {
449
+                // virer les version base qui vont venir avec l'import
450
+                sql_delete($table, "nom like '%_base_version'", $serveur_dest);
451
+                // hum casse la base si pas version_installee a l'import ...
452
+                sql_delete($table, "nom='version_installee'", $serveur_dest);
453
+            }
454
+        } else {
455
+            sql_drop_table($table, '', $serveur_dest);
456
+            spip_log("drop table '$table' sur serveur '$serveur_dest'", 'dump.' . _LOG_INFO_IMPORTANTE);
457
+        }
458
+        $desc_dest = false;
459
+    }
460
+    // si la table n'existe pas dans la destination, la creer a l'identique !
461
+    if (!$desc_dest) {
462
+        spip_log("creation '$table' sur serveur '$serveur_dest'", 'dump.' . _LOG_INFO_IMPORTANTE);
463
+        include_spip('base/create');
464
+        creer_ou_upgrader_table($table, $desc, 'auto', $upgrade, $serveur_dest);
465
+        $desc_dest = sql_showtable($table, true, $serveur_dest);
466
+    }
467
+    if (!$desc_dest) {
468
+        spip_log("Erreur creation '$table' sur serveur '$serveur_dest'" . var_export($desc, 1), 'dump.' . _LOG_ERREUR);
469
+    }
470
+
471
+    return $desc_dest;
472 472
 }
473 473
 
474 474
 /**
@@ -514,186 +514,186 @@  discard block
 block discarded – undo
514 514
  */
515 515
 function base_copier_tables($status_file, $tables, $serveur_source, $serveur_dest, $options = array()) {
516 516
 
517
-	$callback_progression = isset($options['callback_progression']) ? $options['callback_progression'] : '';
518
-	$max_time = isset($options['max_time']) ? $options['max_time'] : 0;
519
-	$drop_source = isset($options['drop_source']) ? $options['drop_source'] : false;
520
-	$no_erase_dest = isset($options['no_erase_dest']) ? $options['no_erase_dest'] : array();
521
-	$where = isset($options['where']) ? $options['where'] : array();
522
-	$fonction_base_inserer = isset($options['fonction_base_inserer']) ? $options['fonction_base_inserer'] : 'inserer_copie';
523
-	$desc_tables_dest = isset($options['desc_tables_dest']) ? $options['desc_tables_dest'] : array();
524
-	$racine_fonctions = (isset($options['racine_fonctions_dest']) ? $options['racine_fonctions_dest'] : 'base');
525
-	$data_pool = (isset($options['data_pool']) ? $options['data_pool'] : 50 * 1024);
526
-
527
-	spip_log("Copier " . count($tables) . " tables de '$serveur_source' vers '$serveur_dest'",
528
-		'dump.' . _LOG_INFO_IMPORTANTE);
529
-
530
-	if (!$inserer_copie = charger_fonction($fonction_base_inserer, $racine_fonctions, true)) {
531
-		spip_log("Fonction '{$racine_fonctions}_$fonction_base_inserer' inconnue. Abandon", 'dump.' . _LOG_INFO_IMPORTANTE);
532
-
533
-		return true; // echec mais on a fini, donc true
534
-	}
535
-	if (!$preparer_table_dest = charger_fonction('preparer_table_dest', $racine_fonctions, true)) {
536
-		spip_log("Fonction '{$racine_fonctions}_$preparer_table_dest' inconnue. Abandon", 'dump.' . _LOG_INFO_IMPORTANTE);
537
-
538
-		return true; // echec mais on a fini, donc true
539
-	}
540
-
541
-	if (!lire_fichier($status_file, $status)
542
-		or !$status = unserialize($status)
543
-	) {
544
-		$status = array();
545
-	}
546
-	$status['etape'] = 'basecopie';
547
-
548
-	// puis relister les tables a importer
549
-	// et les vider si besoin, au moment du premier passage ici
550
-	$initialisation_copie = (!isset($status["dump_status_copie"])) ? 0 : $status["dump_status_copie"];
551
-
552
-	// si init pas encore faite, vider les tables du serveur destination
553
-	if (!$initialisation_copie) {
554
-		if (!$vider_tables_destination_copie = charger_fonction('vider_tables_destination_copie', $racine_fonctions,
555
-			true)
556
-		) {
557
-			spip_log("Fonction '{$racine_fonctions}_vider_tables_destination_copie' inconnue. Abandon",
558
-				'dump.' . _LOG_INFO_IMPORTANTE);
559
-
560
-			return true; // echec mais on a fini, donc true
561
-		}
562
-		$vider_tables_destination_copie($tables, $no_erase_dest, $serveur_dest);
563
-		$status["dump_status_copie"] = 'ok';
564
-		ecrire_fichier($status_file, serialize($status));
565
-	}
566
-
567
-	// les tables auteurs et meta doivent etre copiees en dernier !
568
-	if (in_array('spip_auteurs', $tables)) {
569
-		$tables = array_diff($tables, array('spip_auteurs'));
570
-		$tables[] = 'spip_auteurs';
571
-	}
572
-	if (in_array('spip_meta', $tables)) {
573
-		$tables = array_diff($tables, array('spip_meta'));
574
-		$tables[] = 'spip_meta';
575
-	}
576
-	spip_log("Tables a copier :" . implode(", ", $tables), 'dump.' . _LOG_INFO);
577
-
578
-	$trouver_table = charger_fonction('trouver_table', 'base');
579
-
580
-	foreach ($tables as $table) {
581
-		// si table commence par spip_ c'est une table SPIP, renommer le prefixe si besoin
582
-		// sinon chercher la vraie table
583
-		$desc_source = false;
584
-		if (strncmp($table, "spip_", 5) == 0) {
585
-			$desc_source = $trouver_table(preg_replace(",^spip_,", "", $table), $serveur_source, true);
586
-		}
587
-		if (!$desc_source or !isset($desc_source['exist']) or !$desc_source['exist']) {
588
-			$desc_source = $trouver_table($table, $serveur_source, false);
589
-		}
590
-
591
-		// verifier que la table est presente dans la base source
592
-		if ($desc_source) {
593
-			// $status['tables_copiees'][$table] contient l'avancement
594
-			// de la copie pour la $table : 0 a N et -N quand elle est finie (-1 si vide et finie...)
595
-			if (!isset($status['tables_copiees'][$table])) {
596
-				$status['tables_copiees'][$table] = 0;
597
-			}
598
-
599
-			if (is_numeric($status['tables_copiees'][$table])
600
-				and $status['tables_copiees'][$table] >= 0
601
-				and $desc_dest = $preparer_table_dest(
602
-					$table,
603
-					isset($desc_tables_dest[$table]) ? $desc_tables_dest[$table] : $desc_source,
604
-					$serveur_dest,
605
-					$status['tables_copiees'][$table] == 0)
606
-			) {
607
-				if ($callback_progression) {
608
-					$callback_progression($status['tables_copiees'][$table], 0, $table);
609
-				}
610
-				while (true) {
611
-					$n = intval($status['tables_copiees'][$table]);
612
-					// on copie par lot de 400
613
-					$res = sql_select('*', $table, isset($where[$table]) ? $where[$table] : '', '', '', "$n,400", '',
614
-						$serveur_source);
615
-					while ($row = sql_fetch($res, $serveur_source)) {
616
-						$rows = array($row);
617
-						// lire un groupe de donnees si demande en option
618
-						// (permet un envoi par lot vers la destination)
619
-						if ($data_pool > 0) {
620
-							$s = strlen(serialize($row));
621
-							while ($s < $data_pool and $row = sql_fetch($res, $serveur_source)) {
622
-								$s += strlen(serialize($row));
623
-								$rows[] = $row;
624
-							}
625
-						}
626
-						// si l'enregistrement est deja en base, ca fera un echec ou un doublon
627
-						// mais si ca renvoie false c'est une erreur fatale => abandon
628
-						if ($inserer_copie($table, $rows, $desc_dest, $serveur_dest) === false) {
629
-							// forcer la sortie, charge a l'appelant de gerer l'echec
630
-							spip_log("Erreur fatale dans $inserer_copie table $table", "dump" . _LOG_ERREUR);
631
-							$status['errors'][] = "Erreur fatale  lors de la copie de la table $table";
632
-							ecrire_fichier($status_file, serialize($status));
633
-
634
-							// copie finie
635
-							return true;
636
-						}
637
-						$status['tables_copiees'][$table] += count($rows);
638
-						if ($max_time and time() > $max_time) {
639
-							break;
640
-						}
641
-					}
642
-					if ($n == $status['tables_copiees'][$table]) {
643
-						break;
644
-					}
645
-					spip_log("recopie $table " . $status['tables_copiees'][$table], 'dump.' . _LOG_INFO_IMPORTANTE);
646
-					if ($callback_progression) {
647
-						$callback_progression($status['tables_copiees'][$table], 0, $table);
648
-					}
649
-					ecrire_fichier($status_file, serialize($status));
650
-					if ($max_time and time() > $max_time) {
651
-						return false;
652
-					} // on a pas fini, mais le temps imparti est ecoule
653
-				}
654
-				if ($drop_source) {
655
-					sql_drop_table($table, '', $serveur_source);
656
-					spip_log("drop $table sur serveur source '$serveur_source'", 'dump.' . _LOG_INFO_IMPORTANTE);
657
-				}
658
-				$status['tables_copiees'][$table] = ($status['tables_copiees'][$table] ? -$status['tables_copiees'][$table] : "zero");
659
-				ecrire_fichier($status_file, serialize($status));
660
-				spip_log("tables_recopiees " . implode(',', array_keys($status['tables_copiees'])), 'dump.' . _LOG_INFO);
661
-				if ($callback_progression) {
662
-					$callback_progression($status['tables_copiees'][$table], $status['tables_copiees'][$table], $table);
663
-				}
664
-			} else {
665
-				if ($status['tables_copiees'][$table] < 0) {
666
-					spip_log("Table $table deja copiee : " . $status['tables_copiees'][$table], "dump." . _LOG_INFO);
667
-				}
668
-				if ($callback_progression) {
669
-					$callback_progression(0, $status['tables_copiees'][$table],
670
-						"$table" . ((is_numeric($status['tables_copiees'][$table]) and $status['tables_copiees'][$table] >= 0) ? "[Echec]" : ""));
671
-				}
672
-			}
673
-		} else {
674
-			$status['errors'][] = "Impossible de lire la description de la table $table";
675
-			ecrire_fichier($status_file, serialize($status));
676
-			spip_log("Impossible de lire la description de la table $table", "dump." . _LOG_ERREUR);
677
-		}
678
-	}
679
-
680
-	// si le nombre de tables envoyees n'est pas egal au nombre de tables demandees
681
-	// abandonner
682
-	if (count($status['tables_copiees']) < count($tables)) {
683
-		spip_log("Nombre de tables copiees incorrect : " . count($status['tables_copiees']) . "/" . count($tables),
684
-			"dump." . _LOG_ERREUR);
685
-		$status['errors'][] = "Nombre de tables copiees incorrect : " . count($status['tables_copiees']) . "/" . count($tables);
686
-		ecrire_fichier($status_file, serialize($status));
687
-	}
688
-
689
-	if ($detruire_copieur_si_besoin = charger_fonction('detruire_copieur_si_besoin', $racine_fonctions, true)) {
690
-		$detruire_copieur_si_besoin($serveur_dest);
691
-	} else {
692
-		spip_log("Fonction '{$racine_fonctions}_detruire_copieur_si_besoin' inconnue.", 'dump.' . _LOG_INFO_IMPORTANTE);
693
-	}
694
-
695
-	// OK, copie complete
696
-	return true;
517
+    $callback_progression = isset($options['callback_progression']) ? $options['callback_progression'] : '';
518
+    $max_time = isset($options['max_time']) ? $options['max_time'] : 0;
519
+    $drop_source = isset($options['drop_source']) ? $options['drop_source'] : false;
520
+    $no_erase_dest = isset($options['no_erase_dest']) ? $options['no_erase_dest'] : array();
521
+    $where = isset($options['where']) ? $options['where'] : array();
522
+    $fonction_base_inserer = isset($options['fonction_base_inserer']) ? $options['fonction_base_inserer'] : 'inserer_copie';
523
+    $desc_tables_dest = isset($options['desc_tables_dest']) ? $options['desc_tables_dest'] : array();
524
+    $racine_fonctions = (isset($options['racine_fonctions_dest']) ? $options['racine_fonctions_dest'] : 'base');
525
+    $data_pool = (isset($options['data_pool']) ? $options['data_pool'] : 50 * 1024);
526
+
527
+    spip_log("Copier " . count($tables) . " tables de '$serveur_source' vers '$serveur_dest'",
528
+        'dump.' . _LOG_INFO_IMPORTANTE);
529
+
530
+    if (!$inserer_copie = charger_fonction($fonction_base_inserer, $racine_fonctions, true)) {
531
+        spip_log("Fonction '{$racine_fonctions}_$fonction_base_inserer' inconnue. Abandon", 'dump.' . _LOG_INFO_IMPORTANTE);
532
+
533
+        return true; // echec mais on a fini, donc true
534
+    }
535
+    if (!$preparer_table_dest = charger_fonction('preparer_table_dest', $racine_fonctions, true)) {
536
+        spip_log("Fonction '{$racine_fonctions}_$preparer_table_dest' inconnue. Abandon", 'dump.' . _LOG_INFO_IMPORTANTE);
537
+
538
+        return true; // echec mais on a fini, donc true
539
+    }
540
+
541
+    if (!lire_fichier($status_file, $status)
542
+        or !$status = unserialize($status)
543
+    ) {
544
+        $status = array();
545
+    }
546
+    $status['etape'] = 'basecopie';
547
+
548
+    // puis relister les tables a importer
549
+    // et les vider si besoin, au moment du premier passage ici
550
+    $initialisation_copie = (!isset($status["dump_status_copie"])) ? 0 : $status["dump_status_copie"];
551
+
552
+    // si init pas encore faite, vider les tables du serveur destination
553
+    if (!$initialisation_copie) {
554
+        if (!$vider_tables_destination_copie = charger_fonction('vider_tables_destination_copie', $racine_fonctions,
555
+            true)
556
+        ) {
557
+            spip_log("Fonction '{$racine_fonctions}_vider_tables_destination_copie' inconnue. Abandon",
558
+                'dump.' . _LOG_INFO_IMPORTANTE);
559
+
560
+            return true; // echec mais on a fini, donc true
561
+        }
562
+        $vider_tables_destination_copie($tables, $no_erase_dest, $serveur_dest);
563
+        $status["dump_status_copie"] = 'ok';
564
+        ecrire_fichier($status_file, serialize($status));
565
+    }
566
+
567
+    // les tables auteurs et meta doivent etre copiees en dernier !
568
+    if (in_array('spip_auteurs', $tables)) {
569
+        $tables = array_diff($tables, array('spip_auteurs'));
570
+        $tables[] = 'spip_auteurs';
571
+    }
572
+    if (in_array('spip_meta', $tables)) {
573
+        $tables = array_diff($tables, array('spip_meta'));
574
+        $tables[] = 'spip_meta';
575
+    }
576
+    spip_log("Tables a copier :" . implode(", ", $tables), 'dump.' . _LOG_INFO);
577
+
578
+    $trouver_table = charger_fonction('trouver_table', 'base');
579
+
580
+    foreach ($tables as $table) {
581
+        // si table commence par spip_ c'est une table SPIP, renommer le prefixe si besoin
582
+        // sinon chercher la vraie table
583
+        $desc_source = false;
584
+        if (strncmp($table, "spip_", 5) == 0) {
585
+            $desc_source = $trouver_table(preg_replace(",^spip_,", "", $table), $serveur_source, true);
586
+        }
587
+        if (!$desc_source or !isset($desc_source['exist']) or !$desc_source['exist']) {
588
+            $desc_source = $trouver_table($table, $serveur_source, false);
589
+        }
590
+
591
+        // verifier que la table est presente dans la base source
592
+        if ($desc_source) {
593
+            // $status['tables_copiees'][$table] contient l'avancement
594
+            // de la copie pour la $table : 0 a N et -N quand elle est finie (-1 si vide et finie...)
595
+            if (!isset($status['tables_copiees'][$table])) {
596
+                $status['tables_copiees'][$table] = 0;
597
+            }
598
+
599
+            if (is_numeric($status['tables_copiees'][$table])
600
+                and $status['tables_copiees'][$table] >= 0
601
+                and $desc_dest = $preparer_table_dest(
602
+                    $table,
603
+                    isset($desc_tables_dest[$table]) ? $desc_tables_dest[$table] : $desc_source,
604
+                    $serveur_dest,
605
+                    $status['tables_copiees'][$table] == 0)
606
+            ) {
607
+                if ($callback_progression) {
608
+                    $callback_progression($status['tables_copiees'][$table], 0, $table);
609
+                }
610
+                while (true) {
611
+                    $n = intval($status['tables_copiees'][$table]);
612
+                    // on copie par lot de 400
613
+                    $res = sql_select('*', $table, isset($where[$table]) ? $where[$table] : '', '', '', "$n,400", '',
614
+                        $serveur_source);
615
+                    while ($row = sql_fetch($res, $serveur_source)) {
616
+                        $rows = array($row);
617
+                        // lire un groupe de donnees si demande en option
618
+                        // (permet un envoi par lot vers la destination)
619
+                        if ($data_pool > 0) {
620
+                            $s = strlen(serialize($row));
621
+                            while ($s < $data_pool and $row = sql_fetch($res, $serveur_source)) {
622
+                                $s += strlen(serialize($row));
623
+                                $rows[] = $row;
624
+                            }
625
+                        }
626
+                        // si l'enregistrement est deja en base, ca fera un echec ou un doublon
627
+                        // mais si ca renvoie false c'est une erreur fatale => abandon
628
+                        if ($inserer_copie($table, $rows, $desc_dest, $serveur_dest) === false) {
629
+                            // forcer la sortie, charge a l'appelant de gerer l'echec
630
+                            spip_log("Erreur fatale dans $inserer_copie table $table", "dump" . _LOG_ERREUR);
631
+                            $status['errors'][] = "Erreur fatale  lors de la copie de la table $table";
632
+                            ecrire_fichier($status_file, serialize($status));
633
+
634
+                            // copie finie
635
+                            return true;
636
+                        }
637
+                        $status['tables_copiees'][$table] += count($rows);
638
+                        if ($max_time and time() > $max_time) {
639
+                            break;
640
+                        }
641
+                    }
642
+                    if ($n == $status['tables_copiees'][$table]) {
643
+                        break;
644
+                    }
645
+                    spip_log("recopie $table " . $status['tables_copiees'][$table], 'dump.' . _LOG_INFO_IMPORTANTE);
646
+                    if ($callback_progression) {
647
+                        $callback_progression($status['tables_copiees'][$table], 0, $table);
648
+                    }
649
+                    ecrire_fichier($status_file, serialize($status));
650
+                    if ($max_time and time() > $max_time) {
651
+                        return false;
652
+                    } // on a pas fini, mais le temps imparti est ecoule
653
+                }
654
+                if ($drop_source) {
655
+                    sql_drop_table($table, '', $serveur_source);
656
+                    spip_log("drop $table sur serveur source '$serveur_source'", 'dump.' . _LOG_INFO_IMPORTANTE);
657
+                }
658
+                $status['tables_copiees'][$table] = ($status['tables_copiees'][$table] ? -$status['tables_copiees'][$table] : "zero");
659
+                ecrire_fichier($status_file, serialize($status));
660
+                spip_log("tables_recopiees " . implode(',', array_keys($status['tables_copiees'])), 'dump.' . _LOG_INFO);
661
+                if ($callback_progression) {
662
+                    $callback_progression($status['tables_copiees'][$table], $status['tables_copiees'][$table], $table);
663
+                }
664
+            } else {
665
+                if ($status['tables_copiees'][$table] < 0) {
666
+                    spip_log("Table $table deja copiee : " . $status['tables_copiees'][$table], "dump." . _LOG_INFO);
667
+                }
668
+                if ($callback_progression) {
669
+                    $callback_progression(0, $status['tables_copiees'][$table],
670
+                        "$table" . ((is_numeric($status['tables_copiees'][$table]) and $status['tables_copiees'][$table] >= 0) ? "[Echec]" : ""));
671
+                }
672
+            }
673
+        } else {
674
+            $status['errors'][] = "Impossible de lire la description de la table $table";
675
+            ecrire_fichier($status_file, serialize($status));
676
+            spip_log("Impossible de lire la description de la table $table", "dump." . _LOG_ERREUR);
677
+        }
678
+    }
679
+
680
+    // si le nombre de tables envoyees n'est pas egal au nombre de tables demandees
681
+    // abandonner
682
+    if (count($status['tables_copiees']) < count($tables)) {
683
+        spip_log("Nombre de tables copiees incorrect : " . count($status['tables_copiees']) . "/" . count($tables),
684
+            "dump." . _LOG_ERREUR);
685
+        $status['errors'][] = "Nombre de tables copiees incorrect : " . count($status['tables_copiees']) . "/" . count($tables);
686
+        ecrire_fichier($status_file, serialize($status));
687
+    }
688
+
689
+    if ($detruire_copieur_si_besoin = charger_fonction('detruire_copieur_si_besoin', $racine_fonctions, true)) {
690
+        $detruire_copieur_si_besoin($serveur_dest);
691
+    } else {
692
+        spip_log("Fonction '{$racine_fonctions}_detruire_copieur_si_besoin' inconnue.", 'dump.' . _LOG_INFO_IMPORTANTE);
693
+    }
694
+
695
+    // OK, copie complete
696
+    return true;
697 697
 }
698 698
 
699 699
 /**
@@ -707,27 +707,27 @@  discard block
 block discarded – undo
707 707
  */
708 708
 function base_inserer_copie($table, $rows, $desc_dest, $serveur_dest) {
709 709
 
710
-	// verifier le nombre d'insertion
711
-	$nb1 = sql_countsel($table, '', '', '', $serveur_dest);
712
-	// si l'enregistrement est deja en base, ca fera un echec ou un doublon
713
-	$r = sql_insertq_multi($table, $rows, $desc_dest, $serveur_dest);
714
-	$nb = sql_countsel($table, '', '', '', $serveur_dest);
715
-	if ($nb - $nb1 < count($rows)) {
716
-		spip_log("base_inserer_copie : " . ($nb - $nb1) . " insertions au lieu de " . count($rows) . ". On retente 1 par 1",
717
-			"dump" . _LOG_INFO_IMPORTANTE);
718
-		foreach ($rows as $row) {
719
-			// si l'enregistrement est deja en base, ca fera un echec ou un doublon
720
-			$r = sql_insertq($table, $row, $desc_dest, $serveur_dest);
721
-		}
722
-		// on reverifie le total
723
-		$r = 0;
724
-		$nb = sql_countsel($table, '', '', '', $serveur_dest);
725
-		if ($nb - $nb1 < count($rows)) {
726
-			spip_log("base_inserer_copie : " . ($nb - $nb1) . " insertions au lieu de " . count($rows) . " apres insertion 1 par 1",
727
-				"dump" . _LOG_ERREUR);
728
-			$r = false;
729
-		}
730
-	}
731
-
732
-	return $r;
710
+    // verifier le nombre d'insertion
711
+    $nb1 = sql_countsel($table, '', '', '', $serveur_dest);
712
+    // si l'enregistrement est deja en base, ca fera un echec ou un doublon
713
+    $r = sql_insertq_multi($table, $rows, $desc_dest, $serveur_dest);
714
+    $nb = sql_countsel($table, '', '', '', $serveur_dest);
715
+    if ($nb - $nb1 < count($rows)) {
716
+        spip_log("base_inserer_copie : " . ($nb - $nb1) . " insertions au lieu de " . count($rows) . ". On retente 1 par 1",
717
+            "dump" . _LOG_INFO_IMPORTANTE);
718
+        foreach ($rows as $row) {
719
+            // si l'enregistrement est deja en base, ca fera un echec ou un doublon
720
+            $r = sql_insertq($table, $row, $desc_dest, $serveur_dest);
721
+        }
722
+        // on reverifie le total
723
+        $r = 0;
724
+        $nb = sql_countsel($table, '', '', '', $serveur_dest);
725
+        if ($nb - $nb1 < count($rows)) {
726
+            spip_log("base_inserer_copie : " . ($nb - $nb1) . " insertions au lieu de " . count($rows) . " apres insertion 1 par 1",
727
+                "dump" . _LOG_ERREUR);
728
+            $r = false;
729
+        }
730
+    }
731
+
732
+    return $r;
733 733
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
  * @return string
39 39
  **/
40 40
 function base_dump_meta_name($rub) {
41
-	return $meta = "status_dump_{$rub}_" . abs($GLOBALS['visiteur_session']['id_auteur']);
41
+	return $meta = "status_dump_{$rub}_".abs($GLOBALS['visiteur_session']['id_auteur']);
42 42
 }
43 43
 
44 44
 /**
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	$connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0];
85 85
 	$prefixe = $connexion['prefixe'];
86 86
 
87
-	$p = '/^' . $prefixe . '/';
87
+	$p = '/^'.$prefixe.'/';
88 88
 	$res = $tables;
89 89
 	foreach (sql_alltable(null, $serveur) as $t) {
90 90
 		if (preg_match($p, $t)) {
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 function base_vider_tables_destination_copie($tables, $exclure_tables = array(), $serveur = '') {
344 344
 	$trouver_table = charger_fonction('trouver_table', 'base');
345 345
 
346
-	spip_log('Vider ' . count($tables) . " tables sur serveur '$serveur' : " . join(', ', $tables),
347
-		'base.' . _LOG_INFO_IMPORTANTE);
346
+	spip_log('Vider '.count($tables)." tables sur serveur '$serveur' : ".join(', ', $tables),
347
+		'base.'._LOG_INFO_IMPORTANTE);
348 348
 	foreach ($tables as $table) {
349 349
 		if (!in_array($table, $exclure_tables)) {
350 350
 			// sur le serveur principal, il ne faut pas supprimer l'auteur loge !
@@ -381,14 +381,14 @@  discard block
 block discarded – undo
381 381
 function base_conserver_copieur($move = true, $serveur = '') {
382 382
 	// s'asurer qu'on a pas deja fait la manip !
383 383
 	if ($GLOBALS['visiteur_session']['id_auteur'] > 0 and sql_countsel("spip_auteurs", "id_auteur>0")) {
384
-		spip_log('Conserver copieur dans id_auteur=' . $GLOBALS['visiteur_session']['id_auteur'] . " pour le serveur '$serveur'",
385
-			'dump.' . _LOG_INFO_IMPORTANTE);
384
+		spip_log('Conserver copieur dans id_auteur='.$GLOBALS['visiteur_session']['id_auteur']." pour le serveur '$serveur'",
385
+			'dump.'._LOG_INFO_IMPORTANTE);
386 386
 		sql_delete("spip_auteurs", "id_auteur<0", $serveur);
387 387
 		if ($move) {
388 388
 			sql_updateq('spip_auteurs', array('id_auteur' => -$GLOBALS['visiteur_session']['id_auteur']),
389
-				"id_auteur=" . intval($GLOBALS['visiteur_session']['id_auteur']), array(), $serveur);
389
+				"id_auteur=".intval($GLOBALS['visiteur_session']['id_auteur']), array(), $serveur);
390 390
 		} else {
391
-			$row = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $GLOBALS['visiteur_session']['id_auteur'], '', '', '', '',
391
+			$row = sql_fetsel('*', 'spip_auteurs', 'id_auteur='.$GLOBALS['visiteur_session']['id_auteur'], '', '', '', '',
392 392
 				$serveur);
393 393
 			$row['id_auteur'] = -$GLOBALS['visiteur_session']['id_auteur'];
394 394
 			sql_insertq('spip_auteurs', $row, array(), $serveur);
@@ -411,15 +411,15 @@  discard block
 block discarded – undo
411 411
 	// rien a faire si ce n'est pas le serveur principal !
412 412
 	if ($serveur == '') {
413 413
 		if (sql_countsel("spip_auteurs", "id_auteur>0")) {
414
-			spip_log("Detruire copieur id_auteur<0 pour le serveur '$serveur'", 'dump.' . _LOG_INFO_IMPORTANTE);
414
+			spip_log("Detruire copieur id_auteur<0 pour le serveur '$serveur'", 'dump.'._LOG_INFO_IMPORTANTE);
415 415
 			sql_delete("spip_auteurs", "id_auteur<0", $serveur);
416 416
 		} else {
417 417
 			spip_log("Restaurer copieur id_auteur<0 pour le serveur '$serveur' (aucun autre auteur en base)",
418
-				'dump.' . _LOG_INFO_IMPORTANTE);
418
+				'dump.'._LOG_INFO_IMPORTANTE);
419 419
 			sql_update('spip_auteurs', array('id_auteur' => '-id_auteur'), "id_auteur<0");
420 420
 		}
421 421
 	} else {
422
-		spip_log("Pas de destruction copieur sur serveur '$serveur'", 'dump.' . _LOG_INFO_IMPORTANTE);
422
+		spip_log("Pas de destruction copieur sur serveur '$serveur'", 'dump.'._LOG_INFO_IMPORTANTE);
423 423
 	}
424 424
 }
425 425
 
@@ -453,19 +453,19 @@  discard block
 block discarded – undo
453 453
 			}
454 454
 		} else {
455 455
 			sql_drop_table($table, '', $serveur_dest);
456
-			spip_log("drop table '$table' sur serveur '$serveur_dest'", 'dump.' . _LOG_INFO_IMPORTANTE);
456
+			spip_log("drop table '$table' sur serveur '$serveur_dest'", 'dump.'._LOG_INFO_IMPORTANTE);
457 457
 		}
458 458
 		$desc_dest = false;
459 459
 	}
460 460
 	// si la table n'existe pas dans la destination, la creer a l'identique !
461 461
 	if (!$desc_dest) {
462
-		spip_log("creation '$table' sur serveur '$serveur_dest'", 'dump.' . _LOG_INFO_IMPORTANTE);
462
+		spip_log("creation '$table' sur serveur '$serveur_dest'", 'dump.'._LOG_INFO_IMPORTANTE);
463 463
 		include_spip('base/create');
464 464
 		creer_ou_upgrader_table($table, $desc, 'auto', $upgrade, $serveur_dest);
465 465
 		$desc_dest = sql_showtable($table, true, $serveur_dest);
466 466
 	}
467 467
 	if (!$desc_dest) {
468
-		spip_log("Erreur creation '$table' sur serveur '$serveur_dest'" . var_export($desc, 1), 'dump.' . _LOG_ERREUR);
468
+		spip_log("Erreur creation '$table' sur serveur '$serveur_dest'".var_export($desc, 1), 'dump.'._LOG_ERREUR);
469 469
 	}
470 470
 
471 471
 	return $desc_dest;
@@ -524,16 +524,16 @@  discard block
 block discarded – undo
524 524
 	$racine_fonctions = (isset($options['racine_fonctions_dest']) ? $options['racine_fonctions_dest'] : 'base');
525 525
 	$data_pool = (isset($options['data_pool']) ? $options['data_pool'] : 50 * 1024);
526 526
 
527
-	spip_log("Copier " . count($tables) . " tables de '$serveur_source' vers '$serveur_dest'",
528
-		'dump.' . _LOG_INFO_IMPORTANTE);
527
+	spip_log("Copier ".count($tables)." tables de '$serveur_source' vers '$serveur_dest'",
528
+		'dump.'._LOG_INFO_IMPORTANTE);
529 529
 
530 530
 	if (!$inserer_copie = charger_fonction($fonction_base_inserer, $racine_fonctions, true)) {
531
-		spip_log("Fonction '{$racine_fonctions}_$fonction_base_inserer' inconnue. Abandon", 'dump.' . _LOG_INFO_IMPORTANTE);
531
+		spip_log("Fonction '{$racine_fonctions}_$fonction_base_inserer' inconnue. Abandon", 'dump.'._LOG_INFO_IMPORTANTE);
532 532
 
533 533
 		return true; // echec mais on a fini, donc true
534 534
 	}
535 535
 	if (!$preparer_table_dest = charger_fonction('preparer_table_dest', $racine_fonctions, true)) {
536
-		spip_log("Fonction '{$racine_fonctions}_$preparer_table_dest' inconnue. Abandon", 'dump.' . _LOG_INFO_IMPORTANTE);
536
+		spip_log("Fonction '{$racine_fonctions}_$preparer_table_dest' inconnue. Abandon", 'dump.'._LOG_INFO_IMPORTANTE);
537 537
 
538 538
 		return true; // echec mais on a fini, donc true
539 539
 	}
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 			true)
556 556
 		) {
557 557
 			spip_log("Fonction '{$racine_fonctions}_vider_tables_destination_copie' inconnue. Abandon",
558
-				'dump.' . _LOG_INFO_IMPORTANTE);
558
+				'dump.'._LOG_INFO_IMPORTANTE);
559 559
 
560 560
 			return true; // echec mais on a fini, donc true
561 561
 		}
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 		$tables = array_diff($tables, array('spip_meta'));
574 574
 		$tables[] = 'spip_meta';
575 575
 	}
576
-	spip_log("Tables a copier :" . implode(", ", $tables), 'dump.' . _LOG_INFO);
576
+	spip_log("Tables a copier :".implode(", ", $tables), 'dump.'._LOG_INFO);
577 577
 
578 578
 	$trouver_table = charger_fonction('trouver_table', 'base');
579 579
 
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 						// mais si ca renvoie false c'est une erreur fatale => abandon
628 628
 						if ($inserer_copie($table, $rows, $desc_dest, $serveur_dest) === false) {
629 629
 							// forcer la sortie, charge a l'appelant de gerer l'echec
630
-							spip_log("Erreur fatale dans $inserer_copie table $table", "dump" . _LOG_ERREUR);
630
+							spip_log("Erreur fatale dans $inserer_copie table $table", "dump"._LOG_ERREUR);
631 631
 							$status['errors'][] = "Erreur fatale  lors de la copie de la table $table";
632 632
 							ecrire_fichier($status_file, serialize($status));
633 633
 
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 					if ($n == $status['tables_copiees'][$table]) {
643 643
 						break;
644 644
 					}
645
-					spip_log("recopie $table " . $status['tables_copiees'][$table], 'dump.' . _LOG_INFO_IMPORTANTE);
645
+					spip_log("recopie $table ".$status['tables_copiees'][$table], 'dump.'._LOG_INFO_IMPORTANTE);
646 646
 					if ($callback_progression) {
647 647
 						$callback_progression($status['tables_copiees'][$table], 0, $table);
648 648
 					}
@@ -653,43 +653,43 @@  discard block
 block discarded – undo
653 653
 				}
654 654
 				if ($drop_source) {
655 655
 					sql_drop_table($table, '', $serveur_source);
656
-					spip_log("drop $table sur serveur source '$serveur_source'", 'dump.' . _LOG_INFO_IMPORTANTE);
656
+					spip_log("drop $table sur serveur source '$serveur_source'", 'dump.'._LOG_INFO_IMPORTANTE);
657 657
 				}
658 658
 				$status['tables_copiees'][$table] = ($status['tables_copiees'][$table] ? -$status['tables_copiees'][$table] : "zero");
659 659
 				ecrire_fichier($status_file, serialize($status));
660
-				spip_log("tables_recopiees " . implode(',', array_keys($status['tables_copiees'])), 'dump.' . _LOG_INFO);
660
+				spip_log("tables_recopiees ".implode(',', array_keys($status['tables_copiees'])), 'dump.'._LOG_INFO);
661 661
 				if ($callback_progression) {
662 662
 					$callback_progression($status['tables_copiees'][$table], $status['tables_copiees'][$table], $table);
663 663
 				}
664 664
 			} else {
665 665
 				if ($status['tables_copiees'][$table] < 0) {
666
-					spip_log("Table $table deja copiee : " . $status['tables_copiees'][$table], "dump." . _LOG_INFO);
666
+					spip_log("Table $table deja copiee : ".$status['tables_copiees'][$table], "dump."._LOG_INFO);
667 667
 				}
668 668
 				if ($callback_progression) {
669 669
 					$callback_progression(0, $status['tables_copiees'][$table],
670
-						"$table" . ((is_numeric($status['tables_copiees'][$table]) and $status['tables_copiees'][$table] >= 0) ? "[Echec]" : ""));
670
+						"$table".((is_numeric($status['tables_copiees'][$table]) and $status['tables_copiees'][$table] >= 0) ? "[Echec]" : ""));
671 671
 				}
672 672
 			}
673 673
 		} else {
674 674
 			$status['errors'][] = "Impossible de lire la description de la table $table";
675 675
 			ecrire_fichier($status_file, serialize($status));
676
-			spip_log("Impossible de lire la description de la table $table", "dump." . _LOG_ERREUR);
676
+			spip_log("Impossible de lire la description de la table $table", "dump."._LOG_ERREUR);
677 677
 		}
678 678
 	}
679 679
 
680 680
 	// si le nombre de tables envoyees n'est pas egal au nombre de tables demandees
681 681
 	// abandonner
682 682
 	if (count($status['tables_copiees']) < count($tables)) {
683
-		spip_log("Nombre de tables copiees incorrect : " . count($status['tables_copiees']) . "/" . count($tables),
684
-			"dump." . _LOG_ERREUR);
685
-		$status['errors'][] = "Nombre de tables copiees incorrect : " . count($status['tables_copiees']) . "/" . count($tables);
683
+		spip_log("Nombre de tables copiees incorrect : ".count($status['tables_copiees'])."/".count($tables),
684
+			"dump."._LOG_ERREUR);
685
+		$status['errors'][] = "Nombre de tables copiees incorrect : ".count($status['tables_copiees'])."/".count($tables);
686 686
 		ecrire_fichier($status_file, serialize($status));
687 687
 	}
688 688
 
689 689
 	if ($detruire_copieur_si_besoin = charger_fonction('detruire_copieur_si_besoin', $racine_fonctions, true)) {
690 690
 		$detruire_copieur_si_besoin($serveur_dest);
691 691
 	} else {
692
-		spip_log("Fonction '{$racine_fonctions}_detruire_copieur_si_besoin' inconnue.", 'dump.' . _LOG_INFO_IMPORTANTE);
692
+		spip_log("Fonction '{$racine_fonctions}_detruire_copieur_si_besoin' inconnue.", 'dump.'._LOG_INFO_IMPORTANTE);
693 693
 	}
694 694
 
695 695
 	// OK, copie complete
@@ -713,8 +713,8 @@  discard block
 block discarded – undo
713 713
 	$r = sql_insertq_multi($table, $rows, $desc_dest, $serveur_dest);
714 714
 	$nb = sql_countsel($table, '', '', '', $serveur_dest);
715 715
 	if ($nb - $nb1 < count($rows)) {
716
-		spip_log("base_inserer_copie : " . ($nb - $nb1) . " insertions au lieu de " . count($rows) . ". On retente 1 par 1",
717
-			"dump" . _LOG_INFO_IMPORTANTE);
716
+		spip_log("base_inserer_copie : ".($nb - $nb1)." insertions au lieu de ".count($rows).". On retente 1 par 1",
717
+			"dump"._LOG_INFO_IMPORTANTE);
718 718
 		foreach ($rows as $row) {
719 719
 			// si l'enregistrement est deja en base, ca fera un echec ou un doublon
720 720
 			$r = sql_insertq($table, $row, $desc_dest, $serveur_dest);
@@ -723,8 +723,8 @@  discard block
 block discarded – undo
723 723
 		$r = 0;
724 724
 		$nb = sql_countsel($table, '', '', '', $serveur_dest);
725 725
 		if ($nb - $nb1 < count($rows)) {
726
-			spip_log("base_inserer_copie : " . ($nb - $nb1) . " insertions au lieu de " . count($rows) . " apres insertion 1 par 1",
727
-				"dump" . _LOG_ERREUR);
726
+			spip_log("base_inserer_copie : ".($nb - $nb1)." insertions au lieu de ".count($rows)." apres insertion 1 par 1",
727
+				"dump"._LOG_ERREUR);
728 728
 			$r = false;
729 729
 		}
730 730
 	}
Please login to merge, or discard this patch.
ecrire/inc/filtres.php 2 patches
Indentation   +2040 added lines, -2040 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Filtres
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/charsets');
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
  * @return string Fonction PHP correspondante du filtre
43 43
  */
44 44
 function charger_filtre($fonc, $default = 'filtre_identite_dist') {
45
-	include_spip('public/parametrer'); // inclure les fichiers fonctions
46
-	return chercher_filtre($fonc, $default);
45
+    include_spip('public/parametrer'); // inclure les fichiers fonctions
46
+    return chercher_filtre($fonc, $default);
47 47
 }
48 48
 
49 49
 /**
@@ -75,38 +75,38 @@  discard block
 block discarded – undo
75 75
  *     Fonction PHP correspondante du filtre demandé
76 76
  */
77 77
 function chercher_filtre($fonc, $default = null) {
78
-	if (!$fonc) {
79
-		return $default;
80
-	}
81
-	// Cas des types mime, sans confondre avec les appels de fonction de classe
82
-	// Foo::Bar
83
-	// qui peuvent etre avec un namespace : space\Foo::Bar
84
-	if (preg_match(',^[\w]+/,', $fonc)) {
85
-		$nom = preg_replace(',\W,', '_', $fonc);
86
-		$f = chercher_filtre($nom);
87
-		// cas du sous-type MIME sans filtre associe, passer au type:
88
-		// si filtre_text_plain pas defini, passe a filtre_text
89
-		if (!$f and $nom !== $fonc) {
90
-			$f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc));
91
-		}
92
-
93
-		return $f;
94
-	}
95
-
96
-	include_fichiers_fonctions();
97
-	foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) {
98
-		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
99
-		// fonction ou name\space\fonction
100
-		if (is_callable($f)) {
101
-			return $f;
102
-		}
103
-		// méthode statique d'une classe Classe::methode ou name\space\Classe::methode
104
-		elseif (false === strpos($f, '::') and is_callable(array($f))) {
105
-			return $f;
106
-		}
107
-	}
108
-
109
-	return $default;
78
+    if (!$fonc) {
79
+        return $default;
80
+    }
81
+    // Cas des types mime, sans confondre avec les appels de fonction de classe
82
+    // Foo::Bar
83
+    // qui peuvent etre avec un namespace : space\Foo::Bar
84
+    if (preg_match(',^[\w]+/,', $fonc)) {
85
+        $nom = preg_replace(',\W,', '_', $fonc);
86
+        $f = chercher_filtre($nom);
87
+        // cas du sous-type MIME sans filtre associe, passer au type:
88
+        // si filtre_text_plain pas defini, passe a filtre_text
89
+        if (!$f and $nom !== $fonc) {
90
+            $f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc));
91
+        }
92
+
93
+        return $f;
94
+    }
95
+
96
+    include_fichiers_fonctions();
97
+    foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) {
98
+        trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
99
+        // fonction ou name\space\fonction
100
+        if (is_callable($f)) {
101
+            return $f;
102
+        }
103
+        // méthode statique d'une classe Classe::methode ou name\space\Classe::methode
104
+        elseif (false === strpos($f, '::') and is_callable(array($f))) {
105
+            return $f;
106
+        }
107
+    }
108
+
109
+    return $default;
110 110
 }
111 111
 
112 112
 /**
@@ -130,20 +130,20 @@  discard block
 block discarded – undo
130 130
  *     Chaîne vide sinon (filtre introuvable).
131 131
  **/
132 132
 function appliquer_filtre($arg, $filtre, $force = null) {
133
-	$f = chercher_filtre($filtre);
134
-	if (!$f) {
135
-		if (!$force) {
136
-			return '';
137
-		} else {
138
-			return $arg;
139
-		}
140
-	}
133
+    $f = chercher_filtre($filtre);
134
+    if (!$f) {
135
+        if (!$force) {
136
+            return '';
137
+        } else {
138
+            return $arg;
139
+        }
140
+    }
141 141
 
142
-	$args = func_get_args();
143
-	array_shift($args); // enlever $arg
144
-	array_shift($args); // enlever $filtre
145
-	array_unshift($args, $arg); // remettre $arg
146
-	return call_user_func_array($f, $args);
142
+    $args = func_get_args();
143
+    array_shift($args); // enlever $arg
144
+    array_shift($args); // enlever $filtre
145
+    array_unshift($args, $arg); // remettre $arg
146
+    return call_user_func_array($f, $args);
147 147
 }
148 148
 
149 149
 /**
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
  *     Version de SPIP
160 160
  **/
161 161
 function spip_version() {
162
-	$version = $GLOBALS['spip_version_affichee'];
163
-	if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
164
-		$version .= " $vcs_version";
165
-	}
162
+    $version = $GLOBALS['spip_version_affichee'];
163
+    if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
164
+        $version .= " $vcs_version";
165
+    }
166 166
 
167
-	return $version;
167
+    return $version;
168 168
 }
169 169
 
170 170
 /**
@@ -177,19 +177,19 @@  discard block
 block discarded – undo
177 177
  *    - string|null si $raw = false
178 178
  */
179 179
 function version_vcs_courante($dir, $raw = false) {
180
-	$desc = decrire_version_git($dir);
181
-	if ($desc === null) {
182
-		$desc = decrire_version_svn($dir);
183
-	}
184
-	if ($desc === null or $raw) {
185
-		return $desc;
186
-	}
187
-	// affichage "GIT [master: abcdef]"
188
-	$commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit'];
189
-	if ($desc['branch']) {
190
-		$commit = $desc['branch'] . ': ' . $commit;
191
-	}
192
-	return "{$desc['vcs']} [$commit]";
180
+    $desc = decrire_version_git($dir);
181
+    if ($desc === null) {
182
+        $desc = decrire_version_svn($dir);
183
+    }
184
+    if ($desc === null or $raw) {
185
+        return $desc;
186
+    }
187
+    // affichage "GIT [master: abcdef]"
188
+    $commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit'];
189
+    if ($desc['branch']) {
190
+        $commit = $desc['branch'] . ': ' . $commit;
191
+    }
192
+    return "{$desc['vcs']} [$commit]";
193 193
 }
194 194
 
195 195
 /**
@@ -201,24 +201,24 @@  discard block
 block discarded – undo
201 201
  *      array ['branch' => xx, 'commit' => yy] sinon.
202 202
  **/
203 203
 function decrire_version_git($dir) {
204
-	if (!$dir) {
205
-		$dir = '.';
206
-	}
204
+    if (!$dir) {
205
+        $dir = '.';
206
+    }
207 207
 
208
-	// version installee par GIT
209
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
210
-		$currentHead = trim(substr($c, 4));
211
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
212
-			return [
213
-				'vcs' => 'GIT',
214
-				'branch' => basename($currentHead),
215
-				'commit' => trim($hash),
216
-				'commit_short' => substr(trim($hash), 0, 8),
217
-			];
218
-		}
219
-	}
208
+    // version installee par GIT
209
+    if (lire_fichier($dir . '/.git/HEAD', $c)) {
210
+        $currentHead = trim(substr($c, 4));
211
+        if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
212
+            return [
213
+                'vcs' => 'GIT',
214
+                'branch' => basename($currentHead),
215
+                'commit' => trim($hash),
216
+                'commit_short' => substr(trim($hash), 0, 8),
217
+            ];
218
+        }
219
+    }
220 220
 
221
-	return null;
221
+    return null;
222 222
 }
223 223
 
224 224
 
@@ -231,25 +231,25 @@  discard block
 block discarded – undo
231 231
  *      array ['commit' => yy, 'date' => xx, 'author' => xx] sinon.
232 232
  **/
233 233
 function decrire_version_svn($dir) {
234
-	if (!$dir) {
235
-		$dir = '.';
236
-	}
237
-	// version installee par SVN
238
-	if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
239
-		$db = new SQLite3($dir . '/.svn/wc.db');
240
-		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
241
-		if ($result) {
242
-			$row = $result->fetchArray();
243
-			if ($row['changed_revision'] != "") {
244
-				return [
245
-					'vcs' => 'SVN',
246
-					'branch' => '',
247
-					'commit' => $row['changed_revision'],
248
-				];
249
-			}
250
-		}
251
-	}
252
-	return null;
234
+    if (!$dir) {
235
+        $dir = '.';
236
+    }
237
+    // version installee par SVN
238
+    if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
239
+        $db = new SQLite3($dir . '/.svn/wc.db');
240
+        $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
241
+        if ($result) {
242
+            $row = $result->fetchArray();
243
+            if ($row['changed_revision'] != "") {
244
+                return [
245
+                    'vcs' => 'SVN',
246
+                    'branch' => '',
247
+                    'commit' => $row['changed_revision'],
248
+                ];
249
+            }
250
+        }
251
+    }
252
+    return null;
253 253
 }
254 254
 
255 255
 /**
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
  *
268 268
  **/
269 269
 function version_svn_courante($dir) {
270
-	if ($desc = decrire_version_svn($dir)) {
271
-		return -$desc['commit'];
272
-	}
273
-	return 0;
270
+    if ($desc = decrire_version_svn($dir)) {
271
+        return -$desc['commit'];
272
+    }
273
+    return 0;
274 274
 }
275 275
 
276 276
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
@@ -314,18 +314,18 @@  discard block
 block discarded – undo
314 314
  *     Code HTML retourné par le filtre
315 315
  **/
316 316
 function filtrer($filtre) {
317
-	$tous = func_get_args();
318
-	if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') {
319
-		return image_filtrer($tous);
320
-	} elseif ($f = chercher_filtre($filtre)) {
321
-		array_shift($tous);
322
-		return call_user_func_array($f, $tous);
323
-	} else {
324
-		// le filtre n'existe pas, on provoque une erreur
325
-		$msg = array('zbug_erreur_filtre', array('filtre' => texte_script($filtre)));
326
-		erreur_squelette($msg);
327
-		return '';
328
-	}
317
+    $tous = func_get_args();
318
+    if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') {
319
+        return image_filtrer($tous);
320
+    } elseif ($f = chercher_filtre($filtre)) {
321
+        array_shift($tous);
322
+        return call_user_func_array($f, $tous);
323
+    } else {
324
+        // le filtre n'existe pas, on provoque une erreur
325
+        $msg = array('zbug_erreur_filtre', array('filtre' => texte_script($filtre)));
326
+        erreur_squelette($msg);
327
+        return '';
328
+    }
329 329
 }
330 330
 
331 331
 /**
@@ -342,11 +342,11 @@  discard block
 block discarded – undo
342 342
  * @return bool true si on trouve le filtre dans la matrice, false sinon.
343 343
  */
344 344
 function trouver_filtre_matrice($filtre) {
345
-	if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
346
-		find_in_path($f, '', true);
347
-		$GLOBALS['spip_matrice'][$filtre] = true;
348
-	}
349
-	return !empty($GLOBALS['spip_matrice'][$filtre]);
345
+    if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
346
+        find_in_path($f, '', true);
347
+        $GLOBALS['spip_matrice'][$filtre] = true;
348
+    }
349
+    return !empty($GLOBALS['spip_matrice'][$filtre]);
350 350
 }
351 351
 
352 352
 
@@ -374,8 +374,8 @@  discard block
 block discarded – undo
374 374
  * @return mixed
375 375
  */
376 376
 function filtre_set(&$Pile, $val, $key, $continue = null) {
377
-	$Pile['vars'][$key] = $val;
378
-	return $continue ? $val : '';
377
+    $Pile['vars'][$key] = $val;
378
+    return $continue ? $val : '';
379 379
 }
380 380
 
381 381
 /**
@@ -401,8 +401,8 @@  discard block
 block discarded – undo
401 401
  * @return string|mixed Retourne `$val` si `$continue` présent, sinon ''.
402 402
  */
403 403
 function filtre_setenv(&$Pile, $val, $key, $continue = null) {
404
-	$Pile[0][$key] = $val;
405
-	return $continue ? $val : '';
404
+    $Pile[0][$key] = $val;
405
+    return $continue ? $val : '';
406 406
 }
407 407
 
408 408
 /**
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
  * @return string
412 412
  */
413 413
 function filtre_sanitize_env(&$Pile, $keys) {
414
-	$Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
415
-	return '';
414
+    $Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
415
+    return '';
416 416
 }
417 417
 
418 418
 
@@ -435,18 +435,18 @@  discard block
 block discarded – undo
435 435
  * @return mixed Retourne la valeur (sans la modifier).
436 436
  */
437 437
 function filtre_debug($val, $key = null) {
438
-	$debug = (
439
-		is_null($key) ? '' : (var_export($key, true) . " = ")
440
-		) . var_export($val, true);
438
+    $debug = (
439
+        is_null($key) ? '' : (var_export($key, true) . " = ")
440
+        ) . var_export($val, true);
441 441
 
442
-	include_spip('inc/autoriser');
443
-	if (autoriser('webmestre')) {
444
-		echo "<div class='spip_debug'>\n", $debug, "</div>\n";
445
-	}
442
+    include_spip('inc/autoriser');
443
+    if (autoriser('webmestre')) {
444
+        echo "<div class='spip_debug'>\n", $debug, "</div>\n";
445
+    }
446 446
 
447
-	spip_log($debug, 'debug');
447
+    spip_log($debug, 'debug');
448 448
 
449
-	return $val;
449
+    return $val;
450 450
 }
451 451
 
452 452
 
@@ -474,71 +474,71 @@  discard block
 block discarded – undo
474 474
  *     Texte qui a reçu les filtres
475 475
  **/
476 476
 function image_filtrer($args) {
477
-	$filtre = array_shift($args); # enlever $filtre
478
-	$texte = array_shift($args);
479
-	if (!strlen($texte)) {
480
-		return;
481
-	}
482
-	find_in_path('filtres_images_mini.php', 'inc/', true);
483
-	statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
484
-	// Cas du nom de fichier local
485
-	if (strpos(substr($texte, strlen(_DIR_RACINE)), '..') === false
486
-		and !preg_match(',^/|[<>]|\s,S', $texte)
487
-		and (
488
-			file_exists(preg_replace(',[?].*$,', '', $texte))
489
-			or tester_url_absolue($texte)
490
-		)
491
-	) {
492
-		array_unshift($args, "<img src='$texte' />");
493
-		$res = call_user_func_array($filtre, $args);
494
-		statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
495
-		return $res;
496
-	}
497
-
498
-	// Cas general : trier toutes les images, avec eventuellement leur <span>
499
-	if (preg_match_all(
500
-		',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
501
-		$texte, $tags, PREG_SET_ORDER)) {
502
-		foreach ($tags as $tag) {
503
-			$class = extraire_attribut($tag[3], 'class');
504
-			if (!$class or
505
-				(strpos($class, 'filtre_inactif') === false
506
-					// compat historique a virer en 3.2
507
-					and strpos($class, 'no_image_filtrer') === false)
508
-			) {
509
-				array_unshift($args, $tag[3]);
510
-				if ($reduit = call_user_func_array($filtre, $args)) {
511
-					// En cas de span spip_documents, modifier le style=...width:
512
-					if ($tag[1]) {
513
-						$w = extraire_attribut($reduit, 'width');
514
-						if (!$w and preg_match(",width:\s*(\d+)px,S", extraire_attribut($reduit, 'style'), $regs)) {
515
-							$w = $regs[1];
516
-						}
517
-						if ($w and ($style = extraire_attribut($tag[1], 'style'))) {
518
-							$style = preg_replace(",width:\s*\d+px,S", "width:${w}px", $style);
519
-							$replace = inserer_attribut($tag[1], 'style', $style);
520
-							$texte = str_replace($tag[1], $replace, $texte);
521
-						}
522
-					}
523
-					// traiter aussi un eventuel mouseover
524
-					if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
525
-						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
526
-							$srcover = $match[1];
527
-							array_shift($args);
528
-							array_unshift($args, "<img src='" . $match[1] . "' />");
529
-							$srcover_filter = call_user_func_array($filtre, $args);
530
-							$srcover_filter = extraire_attribut($srcover_filter, 'src');
531
-							$reduit = str_replace($srcover, $srcover_filter, $reduit);
532
-						}
533
-					}
534
-					$texte = str_replace($tag[3], $reduit, $texte);
535
-				}
536
-				array_shift($args);
537
-			}
538
-		}
539
-	}
540
-	statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
541
-	return $texte;
477
+    $filtre = array_shift($args); # enlever $filtre
478
+    $texte = array_shift($args);
479
+    if (!strlen($texte)) {
480
+        return;
481
+    }
482
+    find_in_path('filtres_images_mini.php', 'inc/', true);
483
+    statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
484
+    // Cas du nom de fichier local
485
+    if (strpos(substr($texte, strlen(_DIR_RACINE)), '..') === false
486
+        and !preg_match(',^/|[<>]|\s,S', $texte)
487
+        and (
488
+            file_exists(preg_replace(',[?].*$,', '', $texte))
489
+            or tester_url_absolue($texte)
490
+        )
491
+    ) {
492
+        array_unshift($args, "<img src='$texte' />");
493
+        $res = call_user_func_array($filtre, $args);
494
+        statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
495
+        return $res;
496
+    }
497
+
498
+    // Cas general : trier toutes les images, avec eventuellement leur <span>
499
+    if (preg_match_all(
500
+        ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
501
+        $texte, $tags, PREG_SET_ORDER)) {
502
+        foreach ($tags as $tag) {
503
+            $class = extraire_attribut($tag[3], 'class');
504
+            if (!$class or
505
+                (strpos($class, 'filtre_inactif') === false
506
+                    // compat historique a virer en 3.2
507
+                    and strpos($class, 'no_image_filtrer') === false)
508
+            ) {
509
+                array_unshift($args, $tag[3]);
510
+                if ($reduit = call_user_func_array($filtre, $args)) {
511
+                    // En cas de span spip_documents, modifier le style=...width:
512
+                    if ($tag[1]) {
513
+                        $w = extraire_attribut($reduit, 'width');
514
+                        if (!$w and preg_match(",width:\s*(\d+)px,S", extraire_attribut($reduit, 'style'), $regs)) {
515
+                            $w = $regs[1];
516
+                        }
517
+                        if ($w and ($style = extraire_attribut($tag[1], 'style'))) {
518
+                            $style = preg_replace(",width:\s*\d+px,S", "width:${w}px", $style);
519
+                            $replace = inserer_attribut($tag[1], 'style', $style);
520
+                            $texte = str_replace($tag[1], $replace, $texte);
521
+                        }
522
+                    }
523
+                    // traiter aussi un eventuel mouseover
524
+                    if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
525
+                        if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
526
+                            $srcover = $match[1];
527
+                            array_shift($args);
528
+                            array_unshift($args, "<img src='" . $match[1] . "' />");
529
+                            $srcover_filter = call_user_func_array($filtre, $args);
530
+                            $srcover_filter = extraire_attribut($srcover_filter, 'src');
531
+                            $reduit = str_replace($srcover, $srcover_filter, $reduit);
532
+                        }
533
+                    }
534
+                    $texte = str_replace($tag[3], $reduit, $texte);
535
+                }
536
+                array_shift($args);
537
+            }
538
+        }
539
+    }
540
+    statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
541
+    return $texte;
542 542
 }
543 543
 
544 544
 /**
@@ -553,65 +553,65 @@  discard block
 block discarded – undo
553 553
  **/
554 554
 function taille_image($img, $force_refresh = false) {
555 555
 
556
-	static $largeur_img = array(), $hauteur_img = array();
557
-	$srcWidth = 0;
558
-	$srcHeight = 0;
559
-
560
-	$src = extraire_attribut($img, 'src');
561
-
562
-	if (!$src) {
563
-		$src = $img;
564
-	} else {
565
-		$srcWidth = extraire_attribut($img, 'width');
566
-		$srcHeight = extraire_attribut($img, 'height');
567
-	}
568
-
569
-	// ne jamais operer directement sur une image distante pour des raisons de perfo
570
-	// la copie locale a toutes les chances d'etre la ou de resservir
571
-	if (tester_url_absolue($src)) {
572
-		include_spip('inc/distant');
573
-		$fichier = copie_locale($src);
574
-		$src = $fichier ? _DIR_RACINE . $fichier : $src;
575
-	}
576
-	if (($p = strpos($src, '?')) !== false) {
577
-		$src = substr($src, 0, $p);
578
-	}
579
-
580
-	$srcsize = false;
581
-	if (isset($largeur_img[$src]) and !$force_refresh) {
582
-		$srcWidth = $largeur_img[$src];
583
-	}
584
-	if (isset($hauteur_img[$src]) and !$force_refresh) {
585
-		$srcHeight = $hauteur_img[$src];
586
-	}
587
-	if (!$srcWidth or !$srcHeight) {
588
-
589
-		if (file_exists($src)
590
-			and $srcsize = spip_getimagesize($src)
591
-		) {
592
-			if (!$srcWidth) {
593
-				$largeur_img[$src] = $srcWidth = $srcsize[0];
594
-			}
595
-			if (!$srcHeight) {
596
-				$hauteur_img[$src] = $srcHeight = $srcsize[1];
597
-			}
598
-		}
599
-		// $src peut etre une reference a une image temporaire dont a n'a que le log .src
600
-		// on s'y refere, l'image sera reconstruite en temps utile si necessaire
601
-		elseif (@file_exists($f = "$src.src")
602
-			and lire_fichier($f, $valeurs)
603
-			and $valeurs = unserialize($valeurs)
604
-		) {
605
-			if (!$srcWidth) {
606
-				$largeur_img[$src] = $srcWidth = $valeurs["largeur_dest"];
607
-			}
608
-			if (!$srcHeight) {
609
-				$hauteur_img[$src] = $srcHeight = $valeurs["hauteur_dest"];
610
-			}
611
-		}
612
-	}
613
-
614
-	return array($srcHeight, $srcWidth);
556
+    static $largeur_img = array(), $hauteur_img = array();
557
+    $srcWidth = 0;
558
+    $srcHeight = 0;
559
+
560
+    $src = extraire_attribut($img, 'src');
561
+
562
+    if (!$src) {
563
+        $src = $img;
564
+    } else {
565
+        $srcWidth = extraire_attribut($img, 'width');
566
+        $srcHeight = extraire_attribut($img, 'height');
567
+    }
568
+
569
+    // ne jamais operer directement sur une image distante pour des raisons de perfo
570
+    // la copie locale a toutes les chances d'etre la ou de resservir
571
+    if (tester_url_absolue($src)) {
572
+        include_spip('inc/distant');
573
+        $fichier = copie_locale($src);
574
+        $src = $fichier ? _DIR_RACINE . $fichier : $src;
575
+    }
576
+    if (($p = strpos($src, '?')) !== false) {
577
+        $src = substr($src, 0, $p);
578
+    }
579
+
580
+    $srcsize = false;
581
+    if (isset($largeur_img[$src]) and !$force_refresh) {
582
+        $srcWidth = $largeur_img[$src];
583
+    }
584
+    if (isset($hauteur_img[$src]) and !$force_refresh) {
585
+        $srcHeight = $hauteur_img[$src];
586
+    }
587
+    if (!$srcWidth or !$srcHeight) {
588
+
589
+        if (file_exists($src)
590
+            and $srcsize = spip_getimagesize($src)
591
+        ) {
592
+            if (!$srcWidth) {
593
+                $largeur_img[$src] = $srcWidth = $srcsize[0];
594
+            }
595
+            if (!$srcHeight) {
596
+                $hauteur_img[$src] = $srcHeight = $srcsize[1];
597
+            }
598
+        }
599
+        // $src peut etre une reference a une image temporaire dont a n'a que le log .src
600
+        // on s'y refere, l'image sera reconstruite en temps utile si necessaire
601
+        elseif (@file_exists($f = "$src.src")
602
+            and lire_fichier($f, $valeurs)
603
+            and $valeurs = unserialize($valeurs)
604
+        ) {
605
+            if (!$srcWidth) {
606
+                $largeur_img[$src] = $srcWidth = $valeurs["largeur_dest"];
607
+            }
608
+            if (!$srcHeight) {
609
+                $hauteur_img[$src] = $srcHeight = $valeurs["hauteur_dest"];
610
+            }
611
+        }
612
+    }
613
+
614
+    return array($srcHeight, $srcWidth);
615 615
 }
616 616
 
617 617
 
@@ -629,12 +629,12 @@  discard block
 block discarded – undo
629 629
  *     Largeur en pixels, NULL ou 0 si aucune image.
630 630
  **/
631 631
 function largeur($img) {
632
-	if (!$img) {
633
-		return;
634
-	}
635
-	list($h, $l) = taille_image($img);
632
+    if (!$img) {
633
+        return;
634
+    }
635
+    list($h, $l) = taille_image($img);
636 636
 
637
-	return $l;
637
+    return $l;
638 638
 }
639 639
 
640 640
 /**
@@ -651,12 +651,12 @@  discard block
 block discarded – undo
651 651
  *     Hauteur en pixels, NULL ou 0 si aucune image.
652 652
  **/
653 653
 function hauteur($img) {
654
-	if (!$img) {
655
-		return;
656
-	}
657
-	list($h, $l) = taille_image($img);
654
+    if (!$img) {
655
+        return;
656
+    }
657
+    list($h, $l) = taille_image($img);
658 658
 
659
-	return $h;
659
+    return $h;
660 660
 }
661 661
 
662 662
 
@@ -676,11 +676,11 @@  discard block
 block discarded – undo
676 676
  * @return string
677 677
  **/
678 678
 function corriger_entites_html($texte) {
679
-	if (strpos($texte, '&amp;') === false) {
680
-		return $texte;
681
-	}
679
+    if (strpos($texte, '&amp;') === false) {
680
+        return $texte;
681
+    }
682 682
 
683
-	return preg_replace(',&amp;(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte);
683
+    return preg_replace(',&amp;(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte);
684 684
 }
685 685
 
686 686
 /**
@@ -695,11 +695,11 @@  discard block
 block discarded – undo
695 695
  * @return string
696 696
  **/
697 697
 function corriger_toutes_entites_html($texte) {
698
-	if (strpos($texte, '&amp;') === false) {
699
-		return $texte;
700
-	}
698
+    if (strpos($texte, '&amp;') === false) {
699
+        return $texte;
700
+    }
701 701
 
702
-	return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
702
+    return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
703 703
 }
704 704
 
705 705
 /**
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
  * @return string
710 710
  **/
711 711
 function proteger_amp($texte) {
712
-	return str_replace('&', '&amp;', $texte);
712
+    return str_replace('&', '&amp;', $texte);
713 713
 }
714 714
 
715 715
 
@@ -740,20 +740,20 @@  discard block
 block discarded – undo
740 740
  * @return mixed|string
741 741
  */
742 742
 function entites_html($texte, $tout = false, $quote = true) {
743
-	if (!is_string($texte) or !$texte
744
-		or strpbrk($texte, "&\"'<>") == false
745
-	) {
746
-		return $texte;
747
-	}
748
-	include_spip('inc/texte');
749
-	$flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
750
-	$flags |= ENT_HTML401;
751
-	$texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
752
-	if ($tout) {
753
-		return corriger_toutes_entites_html($texte);
754
-	} else {
755
-		return corriger_entites_html($texte);
756
-	}
743
+    if (!is_string($texte) or !$texte
744
+        or strpbrk($texte, "&\"'<>") == false
745
+    ) {
746
+        return $texte;
747
+    }
748
+    include_spip('inc/texte');
749
+    $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
750
+    $flags |= ENT_HTML401;
751
+    $texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
752
+    if ($tout) {
753
+        return corriger_toutes_entites_html($texte);
754
+    } else {
755
+        return corriger_entites_html($texte);
756
+    }
757 757
 }
758 758
 
759 759
 /**
@@ -772,37 +772,37 @@  discard block
 block discarded – undo
772 772
  *     Texte converti
773 773
  **/
774 774
 function filtrer_entites($texte) {
775
-	if (strpos($texte, '&') === false) {
776
-		return $texte;
777
-	}
778
-	// filtrer
779
-	$texte = html2unicode($texte);
780
-	// remettre le tout dans le charset cible
781
-	$texte = unicode2charset($texte);
782
-	// cas particulier des " et ' qu'il faut filtrer aussi
783
-	// (on le faisait deja avec un &quot;)
784
-	if (strpos($texte, "&#") !== false) {
785
-		$texte = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $texte);
786
-	}
775
+    if (strpos($texte, '&') === false) {
776
+        return $texte;
777
+    }
778
+    // filtrer
779
+    $texte = html2unicode($texte);
780
+    // remettre le tout dans le charset cible
781
+    $texte = unicode2charset($texte);
782
+    // cas particulier des " et ' qu'il faut filtrer aussi
783
+    // (on le faisait deja avec un &quot;)
784
+    if (strpos($texte, "&#") !== false) {
785
+        $texte = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $texte);
786
+    }
787 787
 
788
-	return $texte;
788
+    return $texte;
789 789
 }
790 790
 
791 791
 
792 792
 if (!function_exists('filtre_filtrer_entites_dist')) {
793
-	/**
794
-	 * Version sécurisée de filtrer_entites
795
-	 * 
796
-	 * @uses interdire_scripts()
797
-	 * @uses filtrer_entites()
798
-	 * 
799
-	 * @param string $t
800
-	 * @return string
801
-	 */
802
-	function filtre_filtrer_entites_dist($t) {
803
-		include_spip('inc/texte');
804
-		return interdire_scripts(filtrer_entites($t));
805
-	}
793
+    /**
794
+     * Version sécurisée de filtrer_entites
795
+     * 
796
+     * @uses interdire_scripts()
797
+     * @uses filtrer_entites()
798
+     * 
799
+     * @param string $t
800
+     * @return string
801
+     */
802
+    function filtre_filtrer_entites_dist($t) {
803
+        include_spip('inc/texte');
804
+        return interdire_scripts(filtrer_entites($t));
805
+    }
806 806
 }
807 807
 
808 808
 
@@ -817,18 +817,18 @@  discard block
 block discarded – undo
817 817
  * @return string|array
818 818
  **/
819 819
 function supprimer_caracteres_illegaux($texte) {
820
-	static $from = "\x0\x1\x2\x3\x4\x5\x6\x7\x8\xB\xC\xE\xF\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
821
-	static $to = null;
820
+    static $from = "\x0\x1\x2\x3\x4\x5\x6\x7\x8\xB\xC\xE\xF\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
821
+    static $to = null;
822 822
 
823
-	if (is_array($texte)) {
824
-		return array_map('supprimer_caracteres_illegaux', $texte);
825
-	}
823
+    if (is_array($texte)) {
824
+        return array_map('supprimer_caracteres_illegaux', $texte);
825
+    }
826 826
 
827
-	if (!$to) {
828
-		$to = str_repeat('-', strlen($from));
829
-	}
827
+    if (!$to) {
828
+        $to = str_repeat('-', strlen($from));
829
+    }
830 830
 
831
-	return strtr($texte, $from, $to);
831
+    return strtr($texte, $from, $to);
832 832
 }
833 833
 
834 834
 /**
@@ -840,10 +840,10 @@  discard block
 block discarded – undo
840 840
  * @return string|array
841 841
  **/
842 842
 function corriger_caracteres($texte) {
843
-	$texte = corriger_caracteres_windows($texte);
844
-	$texte = supprimer_caracteres_illegaux($texte);
843
+    $texte = corriger_caracteres_windows($texte);
844
+    $texte = supprimer_caracteres_illegaux($texte);
845 845
 
846
-	return $texte;
846
+    return $texte;
847 847
 }
848 848
 
849 849
 /**
@@ -861,40 +861,40 @@  discard block
 block discarded – undo
861 861
  */
862 862
 function texte_backend($texte) {
863 863
 
864
-	static $apostrophe = array("&#8217;", "'"); # n'allouer qu'une fois
864
+    static $apostrophe = array("&#8217;", "'"); # n'allouer qu'une fois
865 865
 
866
-	// si on a des liens ou des images, les passer en absolu
867
-	$texte = liens_absolus($texte);
866
+    // si on a des liens ou des images, les passer en absolu
867
+    $texte = liens_absolus($texte);
868 868
 
869
-	// echapper les tags &gt; &lt;
870
-	$texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
869
+    // echapper les tags &gt; &lt;
870
+    $texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
871 871
 
872
-	// importer les &eacute;
873
-	$texte = filtrer_entites($texte);
872
+    // importer les &eacute;
873
+    $texte = filtrer_entites($texte);
874 874
 
875
-	// " -> &quot; et tout ce genre de choses
876
-	$u = $GLOBALS['meta']['pcre_u'];
877
-	$texte = str_replace("&nbsp;", " ", $texte);
878
-	$texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
879
-	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
880
-	$texte = entites_html($texte, false, false);
881
-	// mais bien echapper les double quotes !
882
-	$texte = str_replace('"', '&#034;', $texte);
875
+    // " -> &quot; et tout ce genre de choses
876
+    $u = $GLOBALS['meta']['pcre_u'];
877
+    $texte = str_replace("&nbsp;", " ", $texte);
878
+    $texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
879
+    // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
880
+    $texte = entites_html($texte, false, false);
881
+    // mais bien echapper les double quotes !
882
+    $texte = str_replace('"', '&#034;', $texte);
883 883
 
884
-	// verifier le charset
885
-	$texte = charset2unicode($texte);
884
+    // verifier le charset
885
+    $texte = charset2unicode($texte);
886 886
 
887
-	// Caracteres problematiques en iso-latin 1
888
-	if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') {
889
-		$texte = str_replace(chr(156), '&#156;', $texte);
890
-		$texte = str_replace(chr(140), '&#140;', $texte);
891
-		$texte = str_replace(chr(159), '&#159;', $texte);
892
-	}
887
+    // Caracteres problematiques en iso-latin 1
888
+    if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') {
889
+        $texte = str_replace(chr(156), '&#156;', $texte);
890
+        $texte = str_replace(chr(140), '&#140;', $texte);
891
+        $texte = str_replace(chr(159), '&#159;', $texte);
892
+    }
893 893
 
894
-	// l'apostrophe curly pose probleme a certains lecteure de RSS
895
-	// et le caractere apostrophe alourdit les squelettes avec PHP
896
-	// ==> on les remplace par l'entite HTML
897
-	return str_replace($apostrophe, "'", $texte);
894
+    // l'apostrophe curly pose probleme a certains lecteure de RSS
895
+    // et le caractere apostrophe alourdit les squelettes avec PHP
896
+    // ==> on les remplace par l'entite HTML
897
+    return str_replace($apostrophe, "'", $texte);
898 898
 }
899 899
 
900 900
 /**
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
  *     Texte encodé et quote pour XML
912 912
  */
913 913
 function texte_backendq($texte) {
914
-	return addslashes(texte_backend($texte));
914
+    return addslashes(texte_backend($texte));
915 915
 }
916 916
 
917 917
 
@@ -934,9 +934,9 @@  discard block
 block discarded – undo
934 934
  *     Numéro de titre, sinon chaîne vide
935 935
  **/
936 936
 function supprimer_numero($texte) {
937
-	return preg_replace(
938
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
939
-		"", $texte);
937
+    return preg_replace(
938
+        ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
939
+        "", $texte);
940 940
 }
941 941
 
942 942
 /**
@@ -959,13 +959,13 @@  discard block
 block discarded – undo
959 959
  *     Numéro de titre, sinon chaîne vide
960 960
  **/
961 961
 function recuperer_numero($texte) {
962
-	if (preg_match(
963
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
964
-		$texte, $regs)) {
965
-		return strval($regs[1]);
966
-	} else {
967
-		return '';
968
-	}
962
+    if (preg_match(
963
+        ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
964
+        $texte, $regs)) {
965
+        return strval($regs[1]);
966
+    } else {
967
+        return '';
968
+    }
969 969
 }
970 970
 
971 971
 /**
@@ -992,13 +992,13 @@  discard block
 block discarded – undo
992 992
  *     Texte converti
993 993
  **/
994 994
 function supprimer_tags($texte, $rempl = "") {
995
-	$texte = preg_replace(",<(!--|\w|/|!\[endif|!\[if)[^>]*>,US", $rempl, $texte);
996
-	// ne pas oublier un < final non ferme car coupe
997
-	$texte = preg_replace(",<(!--|\w|/).*$,US", $rempl, $texte);
998
-	// mais qui peut aussi etre un simple signe plus petit que
999
-	$texte = str_replace('<', '&lt;', $texte);
995
+    $texte = preg_replace(",<(!--|\w|/|!\[endif|!\[if)[^>]*>,US", $rempl, $texte);
996
+    // ne pas oublier un < final non ferme car coupe
997
+    $texte = preg_replace(",<(!--|\w|/).*$,US", $rempl, $texte);
998
+    // mais qui peut aussi etre un simple signe plus petit que
999
+    $texte = str_replace('<', '&lt;', $texte);
1000 1000
 
1001
-	return $texte;
1001
+    return $texte;
1002 1002
 }
1003 1003
 
1004 1004
 /**
@@ -1021,9 +1021,9 @@  discard block
 block discarded – undo
1021 1021
  *     Texte converti
1022 1022
  **/
1023 1023
 function echapper_tags($texte, $rempl = "") {
1024
-	$texte = preg_replace("/<([^>]*)>/", "&lt;\\1&gt;", $texte);
1024
+    $texte = preg_replace("/<([^>]*)>/", "&lt;\\1&gt;", $texte);
1025 1025
 
1026
-	return $texte;
1026
+    return $texte;
1027 1027
 }
1028 1028
 
1029 1029
 /**
@@ -1044,18 +1044,18 @@  discard block
 block discarded – undo
1044 1044
  *     Texte converti
1045 1045
  **/
1046 1046
 function textebrut($texte) {
1047
-	$u = $GLOBALS['meta']['pcre_u'];
1048
-	$texte = preg_replace('/\s+/S' . $u, " ", $texte);
1049
-	$texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
1050
-	$texte = preg_replace("/^\n+/", "", $texte);
1051
-	$texte = preg_replace("/\n+$/", "", $texte);
1052
-	$texte = preg_replace("/\n +/", "\n", $texte);
1053
-	$texte = supprimer_tags($texte);
1054
-	$texte = preg_replace("/(&nbsp;| )+/S", " ", $texte);
1055
-	// nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1056
-	$texte = str_replace("&#8217;", "'", $texte);
1047
+    $u = $GLOBALS['meta']['pcre_u'];
1048
+    $texte = preg_replace('/\s+/S' . $u, " ", $texte);
1049
+    $texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
1050
+    $texte = preg_replace("/^\n+/", "", $texte);
1051
+    $texte = preg_replace("/\n+$/", "", $texte);
1052
+    $texte = preg_replace("/\n +/", "\n", $texte);
1053
+    $texte = supprimer_tags($texte);
1054
+    $texte = preg_replace("/(&nbsp;| )+/S", " ", $texte);
1055
+    // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1056
+    $texte = str_replace("&#8217;", "'", $texte);
1057 1057
 
1058
-	return $texte;
1058
+    return $texte;
1059 1059
 }
1060 1060
 
1061 1061
 
@@ -1071,17 +1071,17 @@  discard block
 block discarded – undo
1071 1071
  *     Texte avec liens ouvrants
1072 1072
  **/
1073 1073
 function liens_ouvrants($texte) {
1074
-	if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1075
-		$texte, $liens, PREG_PATTERN_ORDER)) {
1076
-		foreach ($liens[0] as $a) {
1077
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1078
-			$ablank = inserer_attribut($a, 'rel', $rel);
1079
-			$ablank = inserer_attribut($ablank, 'target', '_blank');
1080
-			$texte = str_replace($a, $ablank, $texte);
1081
-		}
1082
-	}
1074
+    if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1075
+        $texte, $liens, PREG_PATTERN_ORDER)) {
1076
+        foreach ($liens[0] as $a) {
1077
+            $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1078
+            $ablank = inserer_attribut($a, 'rel', $rel);
1079
+            $ablank = inserer_attribut($ablank, 'target', '_blank');
1080
+            $texte = str_replace($a, $ablank, $texte);
1081
+        }
1082
+    }
1083 1083
 
1084
-	return $texte;
1084
+    return $texte;
1085 1085
 }
1086 1086
 
1087 1087
 /**
@@ -1091,22 +1091,22 @@  discard block
 block discarded – undo
1091 1091
  * @return string
1092 1092
  */
1093 1093
 function liens_nofollow($texte) {
1094
-	if (stripos($texte, "<a") === false) {
1095
-		return $texte;
1096
-	}
1094
+    if (stripos($texte, "<a") === false) {
1095
+        return $texte;
1096
+    }
1097 1097
 
1098
-	if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1099
-		foreach ($regs[0] as $a) {
1100
-			$rel = extraire_attribut($a, "rel");
1101
-			if (strpos($rel, "nofollow") === false) {
1102
-				$rel = "nofollow" . ($rel ? " $rel" : "");
1103
-				$anofollow = inserer_attribut($a, "rel", $rel);
1104
-				$texte = str_replace($a, $anofollow, $texte);
1105
-			}
1106
-		}
1107
-	}
1098
+    if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1099
+        foreach ($regs[0] as $a) {
1100
+            $rel = extraire_attribut($a, "rel");
1101
+            if (strpos($rel, "nofollow") === false) {
1102
+                $rel = "nofollow" . ($rel ? " $rel" : "");
1103
+                $anofollow = inserer_attribut($a, "rel", $rel);
1104
+                $texte = str_replace($a, $anofollow, $texte);
1105
+            }
1106
+        }
1107
+    }
1108 1108
 
1109
-	return $texte;
1109
+    return $texte;
1110 1110
 }
1111 1111
 
1112 1112
 /**
@@ -1125,12 +1125,12 @@  discard block
 block discarded – undo
1125 1125
  *     Texte sans paraghaphes
1126 1126
  **/
1127 1127
 function PtoBR($texte) {
1128
-	$u = $GLOBALS['meta']['pcre_u'];
1129
-	$texte = preg_replace("@</p>@iS", "\n", $texte);
1130
-	$texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1131
-	$texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1128
+    $u = $GLOBALS['meta']['pcre_u'];
1129
+    $texte = preg_replace("@</p>@iS", "\n", $texte);
1130
+    $texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1131
+    $texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1132 1132
 
1133
-	return $texte;
1133
+    return $texte;
1134 1134
 }
1135 1135
 
1136 1136
 
@@ -1154,14 +1154,14 @@  discard block
 block discarded – undo
1154 1154
  * @return string Texte encadré du style CSS
1155 1155
  */
1156 1156
 function lignes_longues($texte) {
1157
-	if (!strlen(trim($texte))) {
1158
-		return $texte;
1159
-	}
1160
-	include_spip('inc/texte');
1161
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1162
-		'div' : 'span';
1157
+    if (!strlen(trim($texte))) {
1158
+        return $texte;
1159
+    }
1160
+    include_spip('inc/texte');
1161
+    $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1162
+        'div' : 'span';
1163 1163
 
1164
-	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1164
+    return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1165 1165
 }
1166 1166
 
1167 1167
 /**
@@ -1180,30 +1180,30 @@  discard block
 block discarded – undo
1180 1180
  * @return string Texte en majuscule
1181 1181
  */
1182 1182
 function majuscules($texte) {
1183
-	if (!strlen($texte)) {
1184
-		return '';
1185
-	}
1183
+    if (!strlen($texte)) {
1184
+        return '';
1185
+    }
1186 1186
 
1187
-	// Cas du turc
1188
-	if ($GLOBALS['spip_lang'] == 'tr') {
1189
-		# remplacer hors des tags et des entites
1190
-		if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1191
-			foreach ($regs as $n => $match) {
1192
-				$texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1193
-			}
1194
-		}
1187
+    // Cas du turc
1188
+    if ($GLOBALS['spip_lang'] == 'tr') {
1189
+        # remplacer hors des tags et des entites
1190
+        if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1191
+            foreach ($regs as $n => $match) {
1192
+                $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1193
+            }
1194
+        }
1195 1195
 
1196
-		$texte = str_replace('i', '&#304;', $texte);
1196
+        $texte = str_replace('i', '&#304;', $texte);
1197 1197
 
1198
-		if ($regs) {
1199
-			foreach ($regs as $n => $match) {
1200
-				$texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1201
-			}
1202
-		}
1203
-	}
1198
+        if ($regs) {
1199
+            foreach ($regs as $n => $match) {
1200
+                $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1201
+            }
1202
+        }
1203
+    }
1204 1204
 
1205
-	// Cas general
1206
-	return "<span style='text-transform: uppercase;'>$texte</span>";
1205
+    // Cas general
1206
+    return "<span style='text-transform: uppercase;'>$texte</span>";
1207 1207
 }
1208 1208
 
1209 1209
 /**
@@ -1221,29 +1221,29 @@  discard block
 block discarded – undo
1221 1221
  * @return string
1222 1222
  **/
1223 1223
 function taille_en_octets($taille) {
1224
-	if (!defined('_KILOBYTE')) {
1225
-		/**
1226
-		 * Définit le nombre d'octets dans un Kilobyte
1227
-		 *
1228
-		 * @var int
1229
-		 **/
1230
-		define('_KILOBYTE', 1024);
1231
-	}
1224
+    if (!defined('_KILOBYTE')) {
1225
+        /**
1226
+         * Définit le nombre d'octets dans un Kilobyte
1227
+         *
1228
+         * @var int
1229
+         **/
1230
+        define('_KILOBYTE', 1024);
1231
+    }
1232 1232
 
1233
-	if ($taille < 1) {
1234
-		return '';
1235
-	}
1236
-	if ($taille < _KILOBYTE) {
1237
-		$taille = _T('taille_octets', array('taille' => $taille));
1238
-	} elseif ($taille < _KILOBYTE * _KILOBYTE) {
1239
-		$taille = _T('taille_ko', array('taille' => round($taille / _KILOBYTE, 1)));
1240
-	} elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1241
-		$taille = _T('taille_mo', array('taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)));
1242
-	} else {
1243
-		$taille = _T('taille_go', array('taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)));
1244
-	}
1233
+    if ($taille < 1) {
1234
+        return '';
1235
+    }
1236
+    if ($taille < _KILOBYTE) {
1237
+        $taille = _T('taille_octets', array('taille' => $taille));
1238
+    } elseif ($taille < _KILOBYTE * _KILOBYTE) {
1239
+        $taille = _T('taille_ko', array('taille' => round($taille / _KILOBYTE, 1)));
1240
+    } elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1241
+        $taille = _T('taille_mo', array('taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)));
1242
+    } else {
1243
+        $taille = _T('taille_go', array('taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)));
1244
+    }
1245 1245
 
1246
-	return $taille;
1246
+    return $taille;
1247 1247
 }
1248 1248
 
1249 1249
 
@@ -1265,15 +1265,15 @@  discard block
 block discarded – undo
1265 1265
  *     Texte prêt pour être utilisé en attribut HTML
1266 1266
  **/
1267 1267
 function attribut_html($texte, $textebrut = true) {
1268
-	$u = $GLOBALS['meta']['pcre_u'];
1269
-	if ($textebrut) {
1270
-		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1271
-	}
1272
-	$texte = texte_backend($texte);
1273
-	$texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
1268
+    $u = $GLOBALS['meta']['pcre_u'];
1269
+    if ($textebrut) {
1270
+        $texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1271
+    }
1272
+    $texte = texte_backend($texte);
1273
+    $texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
1274 1274
 
1275
-	return preg_replace(array("/&(amp;|#38;)/", "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/"), array("&", "&#38;"),
1276
-		$texte);
1275
+    return preg_replace(array("/&(amp;|#38;)/", "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/"), array("&", "&#38;"),
1276
+        $texte);
1277 1277
 }
1278 1278
 
1279 1279
 
@@ -1293,12 +1293,12 @@  discard block
 block discarded – undo
1293 1293
  *     URL ou chaîne vide
1294 1294
  **/
1295 1295
 function vider_url($url, $entites = true) {
1296
-	# un message pour abs_url
1297
-	$GLOBALS['mode_abs_url'] = 'url';
1298
-	$url = trim($url);
1299
-	$r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1296
+    # un message pour abs_url
1297
+    $GLOBALS['mode_abs_url'] = 'url';
1298
+    $url = trim($url);
1299
+    $r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1300 1300
 
1301
-	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1301
+    return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1302 1302
 }
1303 1303
 
1304 1304
 
@@ -1313,10 +1313,10 @@  discard block
 block discarded – undo
1313 1313
  * @return string Adresse email maquillée
1314 1314
  **/
1315 1315
 function antispam($texte) {
1316
-	include_spip('inc/acces');
1317
-	$masque = creer_pass_aleatoire(3);
1316
+    include_spip('inc/acces');
1317
+    $masque = creer_pass_aleatoire(3);
1318 1318
 
1319
-	return preg_replace("/@/", " $masque ", $texte);
1319
+    return preg_replace("/@/", " $masque ", $texte);
1320 1320
 }
1321 1321
 
1322 1322
 /**
@@ -1348,12 +1348,12 @@  discard block
 block discarded – undo
1348 1348
  *     True si on a le droit d'accès, false sinon.
1349 1349
  **/
1350 1350
 function securiser_acces($id_auteur, $cle, $dir, $op = '', $args = '') {
1351
-	include_spip('inc/acces');
1352
-	if ($op) {
1353
-		$dir .= " $op $args";
1354
-	}
1351
+    include_spip('inc/acces');
1352
+    if ($op) {
1353
+        $dir .= " $op $args";
1354
+    }
1355 1355
 
1356
-	return verifier_low_sec($id_auteur, $cle, $dir);
1356
+    return verifier_low_sec($id_auteur, $cle, $dir);
1357 1357
 }
1358 1358
 
1359 1359
 /**
@@ -1378,11 +1378,11 @@  discard block
 block discarded – undo
1378 1378
  *     Retourne $texte, sinon $sinon.
1379 1379
  **/
1380 1380
 function sinon($texte, $sinon = '') {
1381
-	if ($texte or (!is_array($texte) and strlen($texte))) {
1382
-		return $texte;
1383
-	} else {
1384
-		return $sinon;
1385
-	}
1381
+    if ($texte or (!is_array($texte) and strlen($texte))) {
1382
+        return $texte;
1383
+    } else {
1384
+        return $sinon;
1385
+    }
1386 1386
 }
1387 1387
 
1388 1388
 /**
@@ -1406,7 +1406,7 @@  discard block
 block discarded – undo
1406 1406
  * @return mixed
1407 1407
  **/
1408 1408
 function choixsivide($a, $vide, $pasvide) {
1409
-	return $a ? $pasvide : $vide;
1409
+    return $a ? $pasvide : $vide;
1410 1410
 }
1411 1411
 
1412 1412
 /**
@@ -1430,7 +1430,7 @@  discard block
 block discarded – undo
1430 1430
  * @return mixed
1431 1431
  **/
1432 1432
 function choixsiegal($a1, $a2, $v, $f) {
1433
-	return ($a1 == $a2) ? $v : $f;
1433
+    return ($a1 == $a2) ? $v : $f;
1434 1434
 }
1435 1435
 
1436 1436
 //
@@ -1449,13 +1449,13 @@  discard block
 block discarded – undo
1449 1449
  * @return string
1450 1450
  **/
1451 1451
 function filtrer_ical($texte) {
1452
-	#include_spip('inc/charsets');
1453
-	$texte = html2unicode($texte);
1454
-	$texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8');
1455
-	$texte = preg_replace("/\n/", " ", $texte);
1456
-	$texte = preg_replace("/,/", "\,", $texte);
1452
+    #include_spip('inc/charsets');
1453
+    $texte = html2unicode($texte);
1454
+    $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8');
1455
+    $texte = preg_replace("/\n/", " ", $texte);
1456
+    $texte = preg_replace("/,/", "\,", $texte);
1457 1457
 
1458
-	return $texte;
1458
+    return $texte;
1459 1459
 }
1460 1460
 
1461 1461
 
@@ -1480,53 +1480,53 @@  discard block
 block discarded – undo
1480 1480
  * @return string
1481 1481
  **/
1482 1482
 function post_autobr($texte, $delim = "\n_ ") {
1483
-	if (!function_exists('echappe_html')) {
1484
-		include_spip('inc/texte_mini');
1485
-	}
1486
-	$texte = str_replace("\r\n", "\r", $texte);
1487
-	$texte = str_replace("\r", "\n", $texte);
1488
-
1489
-	if (preg_match(",\n+$,", $texte, $fin)) {
1490
-		$texte = substr($texte, 0, -strlen($fin = $fin[0]));
1491
-	} else {
1492
-		$fin = '';
1493
-	}
1494
-
1495
-	$texte = echappe_html($texte, '', true);
1496
-
1497
-	// echapper les modeles
1498
-	if (strpos($texte, "<") !== false) {
1499
-		include_spip('inc/lien');
1500
-		if (defined('_PREG_MODELE')) {
1501
-			$preg_modeles = "@" . _PREG_MODELE . "@imsS";
1502
-			$texte = echappe_html($texte, '', true, $preg_modeles);
1503
-		}
1504
-	}
1505
-
1506
-	$debut = '';
1507
-	$suite = $texte;
1508
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1509
-		$debut .= substr($suite, 0, $t - 1);
1510
-		$suite = substr($suite, $t);
1511
-		$car = substr($suite, 0, 1);
1512
-		if (($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> "|") and ($car <> "}")
1513
-			and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1514
-			and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1515
-		) {
1516
-			$debut .= $delim;
1517
-		} else {
1518
-			$debut .= "\n";
1519
-		}
1520
-		if (preg_match(",^\n+,", $suite, $regs)) {
1521
-			$debut .= $regs[0];
1522
-			$suite = substr($suite, strlen($regs[0]));
1523
-		}
1524
-	}
1525
-	$texte = $debut . $suite;
1526
-
1527
-	$texte = echappe_retour($texte);
1528
-
1529
-	return $texte . $fin;
1483
+    if (!function_exists('echappe_html')) {
1484
+        include_spip('inc/texte_mini');
1485
+    }
1486
+    $texte = str_replace("\r\n", "\r", $texte);
1487
+    $texte = str_replace("\r", "\n", $texte);
1488
+
1489
+    if (preg_match(",\n+$,", $texte, $fin)) {
1490
+        $texte = substr($texte, 0, -strlen($fin = $fin[0]));
1491
+    } else {
1492
+        $fin = '';
1493
+    }
1494
+
1495
+    $texte = echappe_html($texte, '', true);
1496
+
1497
+    // echapper les modeles
1498
+    if (strpos($texte, "<") !== false) {
1499
+        include_spip('inc/lien');
1500
+        if (defined('_PREG_MODELE')) {
1501
+            $preg_modeles = "@" . _PREG_MODELE . "@imsS";
1502
+            $texte = echappe_html($texte, '', true, $preg_modeles);
1503
+        }
1504
+    }
1505
+
1506
+    $debut = '';
1507
+    $suite = $texte;
1508
+    while ($t = strpos('-' . $suite, "\n", 1)) {
1509
+        $debut .= substr($suite, 0, $t - 1);
1510
+        $suite = substr($suite, $t);
1511
+        $car = substr($suite, 0, 1);
1512
+        if (($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> "|") and ($car <> "}")
1513
+            and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1514
+            and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1515
+        ) {
1516
+            $debut .= $delim;
1517
+        } else {
1518
+            $debut .= "\n";
1519
+        }
1520
+        if (preg_match(",^\n+,", $suite, $regs)) {
1521
+            $debut .= $regs[0];
1522
+            $suite = substr($suite, strlen($regs[0]));
1523
+        }
1524
+    }
1525
+    $texte = $debut . $suite;
1526
+
1527
+    $texte = echappe_retour($texte);
1528
+
1529
+    return $texte . $fin;
1530 1530
 }
1531 1531
 
1532 1532
 
@@ -1567,46 +1567,46 @@  discard block
 block discarded – undo
1567 1567
  * @return string
1568 1568
  **/
1569 1569
 function extraire_idiome($letexte, $lang = null, $options = array()) {
1570
-	static $traduire = false;
1571
-	if ($letexte
1572
-		and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER)
1573
-	) {
1574
-		if (!$traduire) {
1575
-			$traduire = charger_fonction('traduire', 'inc');
1576
-			include_spip('inc/lang');
1577
-		}
1578
-		if (!$lang) {
1579
-			$lang = $GLOBALS['spip_lang'];
1580
-		}
1581
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1582
-		if (is_bool($options)) {
1583
-			$options = array('echappe_span' => $options);
1584
-		}
1585
-		if (!isset($options['echappe_span'])) {
1586
-			$options = array_merge($options, array('echappe_span' => false));
1587
-		}
1588
-
1589
-		foreach ($regs as $reg) {
1590
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1591
-			$desc = $traduire($cle, $lang, true);
1592
-			$l = $desc->langue;
1593
-			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
1594
-			if (strlen($desc->texte)) {
1595
-				$trad = code_echappement($desc->texte, 'idiome', false);
1596
-				if ($l !== $lang) {
1597
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1598
-				}
1599
-				if (lang_dir($l) !== lang_dir($lang)) {
1600
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1601
-				}
1602
-				if (!$options['echappe_span']) {
1603
-					$trad = echappe_retour($trad, 'idiome');
1604
-				}
1605
-				$letexte = str_replace($reg[0], $trad, $letexte);
1606
-			}
1607
-		}
1608
-	}
1609
-	return $letexte;
1570
+    static $traduire = false;
1571
+    if ($letexte
1572
+        and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER)
1573
+    ) {
1574
+        if (!$traduire) {
1575
+            $traduire = charger_fonction('traduire', 'inc');
1576
+            include_spip('inc/lang');
1577
+        }
1578
+        if (!$lang) {
1579
+            $lang = $GLOBALS['spip_lang'];
1580
+        }
1581
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1582
+        if (is_bool($options)) {
1583
+            $options = array('echappe_span' => $options);
1584
+        }
1585
+        if (!isset($options['echappe_span'])) {
1586
+            $options = array_merge($options, array('echappe_span' => false));
1587
+        }
1588
+
1589
+        foreach ($regs as $reg) {
1590
+            $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1591
+            $desc = $traduire($cle, $lang, true);
1592
+            $l = $desc->langue;
1593
+            // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
1594
+            if (strlen($desc->texte)) {
1595
+                $trad = code_echappement($desc->texte, 'idiome', false);
1596
+                if ($l !== $lang) {
1597
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1598
+                }
1599
+                if (lang_dir($l) !== lang_dir($lang)) {
1600
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1601
+                }
1602
+                if (!$options['echappe_span']) {
1603
+                    $trad = echappe_retour($trad, 'idiome');
1604
+                }
1605
+                $letexte = str_replace($reg[0], $trad, $letexte);
1606
+            }
1607
+        }
1608
+    }
1609
+    return $letexte;
1610 1610
 }
1611 1611
 
1612 1612
 /**
@@ -1658,64 +1658,64 @@  discard block
 block discarded – undo
1658 1658
  **/
1659 1659
 function extraire_multi($letexte, $lang = null, $options = array()) {
1660 1660
 
1661
-	if ($letexte
1662
-		and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER)
1663
-	) {
1664
-		if (!$lang) {
1665
-			$lang = $GLOBALS['spip_lang'];
1666
-		}
1667
-
1668
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1669
-		if (is_bool($options)) {
1670
-			$options = array('echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT);
1671
-		}
1672
-		if (!isset($options['echappe_span'])) {
1673
-			$options = array_merge($options, array('echappe_span' => false));
1674
-		}
1675
-		if (!isset($options['lang_defaut'])) {
1676
-			$options = array_merge($options, array('lang_defaut' => _LANGUE_PAR_DEFAUT));
1677
-		}
1678
-
1679
-		include_spip('inc/lang');
1680
-		foreach ($regs as $reg) {
1681
-			// chercher la version de la langue courante
1682
-			$trads = extraire_trads($reg[1]);
1683
-			if ($l = approcher_langue($trads, $lang)) {
1684
-				$trad = $trads[$l];
1685
-			} else {
1686
-				if ($options['lang_defaut'] == 'aucune') {
1687
-					$trad = '';
1688
-				} else {
1689
-					// langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php)
1690
-					// ou la premiere dispo
1691
-					// mais typographier le texte selon les regles de celle-ci
1692
-					// Attention aux blocs multi sur plusieurs lignes
1693
-					if (!$l = approcher_langue($trads, $options['lang_defaut'])) {
1694
-						$l = key($trads);
1695
-					}
1696
-					$trad = $trads[$l];
1697
-					$typographie = charger_fonction(lang_typo($l), 'typographie');
1698
-					$trad = $typographie($trad);
1699
-					// Tester si on echappe en span ou en div
1700
-					// il ne faut pas echapper en div si propre produit un seul paragraphe
1701
-					include_spip('inc/texte');
1702
-					$trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1703
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1704
-					$trad = code_echappement($trad, 'multi', false, $mode);
1705
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1706
-					if (lang_dir($l) !== lang_dir($lang)) {
1707
-						$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1708
-					}
1709
-					if (!$options['echappe_span']) {
1710
-						$trad = echappe_retour($trad, 'multi');
1711
-					}
1712
-				}
1713
-			}
1714
-			$letexte = str_replace($reg[0], $trad, $letexte);
1715
-		}
1716
-	}
1717
-
1718
-	return $letexte;
1661
+    if ($letexte
1662
+        and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER)
1663
+    ) {
1664
+        if (!$lang) {
1665
+            $lang = $GLOBALS['spip_lang'];
1666
+        }
1667
+
1668
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1669
+        if (is_bool($options)) {
1670
+            $options = array('echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT);
1671
+        }
1672
+        if (!isset($options['echappe_span'])) {
1673
+            $options = array_merge($options, array('echappe_span' => false));
1674
+        }
1675
+        if (!isset($options['lang_defaut'])) {
1676
+            $options = array_merge($options, array('lang_defaut' => _LANGUE_PAR_DEFAUT));
1677
+        }
1678
+
1679
+        include_spip('inc/lang');
1680
+        foreach ($regs as $reg) {
1681
+            // chercher la version de la langue courante
1682
+            $trads = extraire_trads($reg[1]);
1683
+            if ($l = approcher_langue($trads, $lang)) {
1684
+                $trad = $trads[$l];
1685
+            } else {
1686
+                if ($options['lang_defaut'] == 'aucune') {
1687
+                    $trad = '';
1688
+                } else {
1689
+                    // langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php)
1690
+                    // ou la premiere dispo
1691
+                    // mais typographier le texte selon les regles de celle-ci
1692
+                    // Attention aux blocs multi sur plusieurs lignes
1693
+                    if (!$l = approcher_langue($trads, $options['lang_defaut'])) {
1694
+                        $l = key($trads);
1695
+                    }
1696
+                    $trad = $trads[$l];
1697
+                    $typographie = charger_fonction(lang_typo($l), 'typographie');
1698
+                    $trad = $typographie($trad);
1699
+                    // Tester si on echappe en span ou en div
1700
+                    // il ne faut pas echapper en div si propre produit un seul paragraphe
1701
+                    include_spip('inc/texte');
1702
+                    $trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1703
+                    $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1704
+                    $trad = code_echappement($trad, 'multi', false, $mode);
1705
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1706
+                    if (lang_dir($l) !== lang_dir($lang)) {
1707
+                        $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1708
+                    }
1709
+                    if (!$options['echappe_span']) {
1710
+                        $trad = echappe_retour($trad, 'multi');
1711
+                    }
1712
+                }
1713
+            }
1714
+            $letexte = str_replace($reg[0], $trad, $letexte);
1715
+        }
1716
+    }
1717
+
1718
+    return $letexte;
1719 1719
 }
1720 1720
 
1721 1721
 /**
@@ -1731,20 +1731,20 @@  discard block
 block discarded – undo
1731 1731
  *     Peut retourner un code de langue vide, lorsqu'un texte par défaut est indiqué.
1732 1732
  **/
1733 1733
 function extraire_trads($bloc) {
1734
-	$lang = '';
1734
+    $lang = '';
1735 1735
 // ce reg fait planter l'analyse multi s'il y a de l'{italique} dans le champ
1736 1736
 //	while (preg_match("/^(.*?)[{\[]([a-z_]+)[}\]]/siS", $bloc, $regs)) {
1737
-	while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) {
1738
-		$texte = trim($regs[1]);
1739
-		if ($texte or $lang) {
1740
-			$trads[$lang] = $texte;
1741
-		}
1742
-		$bloc = substr($bloc, strlen($regs[0]));
1743
-		$lang = $regs[2];
1744
-	}
1745
-	$trads[$lang] = $bloc;
1737
+    while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) {
1738
+        $texte = trim($regs[1]);
1739
+        if ($texte or $lang) {
1740
+            $trads[$lang] = $texte;
1741
+        }
1742
+        $bloc = substr($bloc, strlen($regs[0]));
1743
+        $lang = $regs[2];
1744
+    }
1745
+    $trads[$lang] = $bloc;
1746 1746
 
1747
-	return $trads;
1747
+    return $trads;
1748 1748
 }
1749 1749
 
1750 1750
 
@@ -1755,7 +1755,7 @@  discard block
 block discarded – undo
1755 1755
  * @return string L'initiale en majuscule
1756 1756
  */
1757 1757
 function filtre_initiale($nom) {
1758
-	return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1758
+    return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1759 1759
 }
1760 1760
 
1761 1761
 
@@ -1800,33 +1800,33 @@  discard block
 block discarded – undo
1800 1800
  *      - null (interne) : si on empile
1801 1801
  **/
1802 1802
 function unique($donnee, $famille = '', $cpt = false) {
1803
-	static $mem = array();
1804
-	// permettre de vider la pile et de la restaurer
1805
-	// pour le calcul de introduction...
1806
-	if ($famille == '_spip_raz_') {
1807
-		$tmp = $mem;
1808
-		$mem = array();
1809
-
1810
-		return $tmp;
1811
-	} elseif ($famille == '_spip_set_') {
1812
-		$mem = $donnee;
1813
-
1814
-		return;
1815
-	}
1816
-	// eviter une notice
1817
-	if (!isset($mem[$famille])) {
1818
-		$mem[$famille] = array();
1819
-	}
1820
-	if ($cpt) {
1821
-		return count($mem[$famille]);
1822
-	}
1823
-	// eviter une notice
1824
-	if (!isset($mem[$famille][$donnee])) {
1825
-		$mem[$famille][$donnee] = 0;
1826
-	}
1827
-	if (!($mem[$famille][$donnee]++)) {
1828
-		return $donnee;
1829
-	}
1803
+    static $mem = array();
1804
+    // permettre de vider la pile et de la restaurer
1805
+    // pour le calcul de introduction...
1806
+    if ($famille == '_spip_raz_') {
1807
+        $tmp = $mem;
1808
+        $mem = array();
1809
+
1810
+        return $tmp;
1811
+    } elseif ($famille == '_spip_set_') {
1812
+        $mem = $donnee;
1813
+
1814
+        return;
1815
+    }
1816
+    // eviter une notice
1817
+    if (!isset($mem[$famille])) {
1818
+        $mem[$famille] = array();
1819
+    }
1820
+    if ($cpt) {
1821
+        return count($mem[$famille]);
1822
+    }
1823
+    // eviter une notice
1824
+    if (!isset($mem[$famille][$donnee])) {
1825
+        $mem[$famille][$donnee] = 0;
1826
+    }
1827
+    if (!($mem[$famille][$donnee]++)) {
1828
+        return $donnee;
1829
+    }
1830 1830
 }
1831 1831
 
1832 1832
 
@@ -1854,18 +1854,18 @@  discard block
 block discarded – undo
1854 1854
  *     Une des valeurs en fonction du compteur.
1855 1855
  **/
1856 1856
 function alterner($i) {
1857
-	// recuperer les arguments (attention fonctions un peu space)
1858
-	$num = func_num_args();
1859
-	$args = func_get_args();
1857
+    // recuperer les arguments (attention fonctions un peu space)
1858
+    $num = func_num_args();
1859
+    $args = func_get_args();
1860 1860
 
1861
-	if ($num == 2 && is_array($args[1])) {
1862
-		$args = $args[1];
1863
-		array_unshift($args, '');
1864
-		$num = count($args);
1865
-	}
1861
+    if ($num == 2 && is_array($args[1])) {
1862
+        $args = $args[1];
1863
+        array_unshift($args, '');
1864
+        $num = count($args);
1865
+    }
1866 1866
 
1867
-	// renvoyer le i-ieme argument, modulo le nombre d'arguments
1868
-	return $args[(intval($i) - 1) % ($num - 1) + 1];
1867
+    // renvoyer le i-ieme argument, modulo le nombre d'arguments
1868
+    return $args[(intval($i) - 1) % ($num - 1) + 1];
1869 1869
 }
1870 1870
 
1871 1871
 
@@ -1890,46 +1890,46 @@  discard block
 block discarded – undo
1890 1890
  *     - Tableau complet (si 2e argument)
1891 1891
  **/
1892 1892
 function extraire_attribut($balise, $attribut, $complet = false) {
1893
-	if (is_array($balise)) {
1894
-		array_walk(
1895
-			$balise,
1896
-			function(&$a, $key, $t){
1897
-				$a = extraire_attribut($a, $t);
1898
-			},
1899
-			$attribut
1900
-		);
1901
-
1902
-		return $balise;
1903
-	}
1904
-	if (preg_match(
1905
-		',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1906
-		. $attribut
1907
-		. '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1908
-
1909
-		$balise, $r)) {
1910
-		if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
1911
-			$r[4] = substr($r[3], 1, -1);
1912
-			$r[3] = $r[3][0];
1913
-		} elseif ($r[3] !== '') {
1914
-			$r[4] = $r[3];
1915
-			$r[3] = '';
1916
-		} else {
1917
-			$r[4] = trim($r[2]);
1918
-		}
1919
-		$att = $r[4];
1920
-		if (strpos($att, "&#") !== false) {
1921
-			$att = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $att);
1922
-		}
1923
-		$att = filtrer_entites($att);
1924
-	} else {
1925
-		$att = null;
1926
-	}
1927
-
1928
-	if ($complet) {
1929
-		return array($att, $r);
1930
-	} else {
1931
-		return $att;
1932
-	}
1893
+    if (is_array($balise)) {
1894
+        array_walk(
1895
+            $balise,
1896
+            function(&$a, $key, $t){
1897
+                $a = extraire_attribut($a, $t);
1898
+            },
1899
+            $attribut
1900
+        );
1901
+
1902
+        return $balise;
1903
+    }
1904
+    if (preg_match(
1905
+        ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1906
+        . $attribut
1907
+        . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1908
+
1909
+        $balise, $r)) {
1910
+        if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
1911
+            $r[4] = substr($r[3], 1, -1);
1912
+            $r[3] = $r[3][0];
1913
+        } elseif ($r[3] !== '') {
1914
+            $r[4] = $r[3];
1915
+            $r[3] = '';
1916
+        } else {
1917
+            $r[4] = trim($r[2]);
1918
+        }
1919
+        $att = $r[4];
1920
+        if (strpos($att, "&#") !== false) {
1921
+            $att = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $att);
1922
+        }
1923
+        $att = filtrer_entites($att);
1924
+    } else {
1925
+        $att = null;
1926
+    }
1927
+
1928
+    if ($complet) {
1929
+        return array($att, $r);
1930
+    } else {
1931
+        return $att;
1932
+    }
1933 1933
 }
1934 1934
 
1935 1935
 /**
@@ -1961,37 +1961,37 @@  discard block
 block discarded – undo
1961 1961
  *     Code html modifié
1962 1962
  **/
1963 1963
 function inserer_attribut($balise, $attribut, $val, $proteger = true, $vider = false) {
1964
-	// preparer l'attribut
1965
-	// supprimer les &nbsp; etc mais pas les balises html
1966
-	// qui ont un sens dans un attribut value d'un input
1967
-	if ($proteger) {
1968
-		$val = attribut_html($val, false);
1969
-	}
1970
-
1971
-	// echapper les ' pour eviter tout bug
1972
-	$val = str_replace("'", "&#039;", $val);
1973
-	if ($vider and strlen($val) == 0) {
1974
-		$insert = '';
1975
-	} else {
1976
-		$insert = " $attribut='$val'";
1977
-	}
1978
-
1979
-	list($old, $r) = extraire_attribut($balise, $attribut, true);
1980
-
1981
-	if ($old !== null) {
1982
-		// Remplacer l'ancien attribut du meme nom
1983
-		$balise = $r[1] . $insert . $r[5];
1984
-	} else {
1985
-		// preferer une balise " />" (comme <img />)
1986
-		if (preg_match(',/>,', $balise)) {
1987
-			$balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
1988
-		} // sinon une balise <a ...> ... </a>
1989
-		else {
1990
-			$balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
1991
-		}
1992
-	}
1993
-
1994
-	return $balise;
1964
+    // preparer l'attribut
1965
+    // supprimer les &nbsp; etc mais pas les balises html
1966
+    // qui ont un sens dans un attribut value d'un input
1967
+    if ($proteger) {
1968
+        $val = attribut_html($val, false);
1969
+    }
1970
+
1971
+    // echapper les ' pour eviter tout bug
1972
+    $val = str_replace("'", "&#039;", $val);
1973
+    if ($vider and strlen($val) == 0) {
1974
+        $insert = '';
1975
+    } else {
1976
+        $insert = " $attribut='$val'";
1977
+    }
1978
+
1979
+    list($old, $r) = extraire_attribut($balise, $attribut, true);
1980
+
1981
+    if ($old !== null) {
1982
+        // Remplacer l'ancien attribut du meme nom
1983
+        $balise = $r[1] . $insert . $r[5];
1984
+    } else {
1985
+        // preferer une balise " />" (comme <img />)
1986
+        if (preg_match(',/>,', $balise)) {
1987
+            $balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
1988
+        } // sinon une balise <a ...> ... </a>
1989
+        else {
1990
+            $balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
1991
+        }
1992
+    }
1993
+
1994
+    return $balise;
1995 1995
 }
1996 1996
 
1997 1997
 /**
@@ -2009,7 +2009,7 @@  discard block
 block discarded – undo
2009 2009
  * @return string Code HTML sans l'attribut
2010 2010
  **/
2011 2011
 function vider_attribut($balise, $attribut) {
2012
-	return inserer_attribut($balise, $attribut, '', false, true);
2012
+    return inserer_attribut($balise, $attribut, '', false, true);
2013 2013
 }
2014 2014
 
2015 2015
 
@@ -2021,9 +2021,9 @@  discard block
 block discarded – undo
2021 2021
  * @return string
2022 2022
  */
2023 2023
 function tester_config($id, $mode = '') {
2024
-	include_spip('action/inscrire_auteur');
2024
+    include_spip('action/inscrire_auteur');
2025 2025
 
2026
-	return tester_statut_inscription($mode, $id);
2026
+    return tester_statut_inscription($mode, $id);
2027 2027
 }
2028 2028
 
2029 2029
 //
@@ -2048,7 +2048,7 @@  discard block
 block discarded – undo
2048 2048
  * @return int $a+$b
2049 2049
  **/
2050 2050
 function plus($a, $b) {
2051
-	return $a + $b;
2051
+    return $a + $b;
2052 2052
 }
2053 2053
 function strplus($a, $b) {return strize('plus', $a, $b);}
2054 2054
 /**
@@ -2067,7 +2067,7 @@  discard block
 block discarded – undo
2067 2067
  * @return int $a-$b
2068 2068
  **/
2069 2069
 function moins($a, $b) {
2070
-	return $a - $b;
2070
+    return $a - $b;
2071 2071
 }
2072 2072
 function strmoins($a, $b) {return strize('moins', $a, $b);}
2073 2073
 
@@ -2088,7 +2088,7 @@  discard block
 block discarded – undo
2088 2088
  * @return int $a*$b
2089 2089
  **/
2090 2090
 function mult($a, $b) {
2091
-	return $a * $b;
2091
+    return $a * $b;
2092 2092
 }
2093 2093
 function strmult($a, $b) {return strize('mult', $a, $b);}
2094 2094
 
@@ -2109,7 +2109,7 @@  discard block
 block discarded – undo
2109 2109
  * @return int $a/$b (ou 0 si $b est nul)
2110 2110
  **/
2111 2111
 function div($a, $b) {
2112
-	return $b ? $a / $b : 0;
2112
+    return $b ? $a / $b : 0;
2113 2113
 }
2114 2114
 function strdiv($a, $b) {return strize('div', $a, $b);}
2115 2115
 
@@ -2131,7 +2131,7 @@  discard block
 block discarded – undo
2131 2131
  * @return int ($nb % $mod) + $add
2132 2132
  **/
2133 2133
 function modulo($nb, $mod, $add = 0) {
2134
-	return ($mod ? $nb % $mod : 0) + $add;
2134
+    return ($mod ? $nb % $mod : 0) + $add;
2135 2135
 }
2136 2136
 
2137 2137
 
@@ -2146,24 +2146,24 @@  discard block
 block discarded – undo
2146 2146
  *      - true sinon
2147 2147
  **/
2148 2148
 function nom_acceptable($nom) {
2149
-	if (!is_string($nom)) {
2150
-		return false;
2151
-	}
2152
-	if (!defined('_TAGS_NOM_AUTEUR')) {
2153
-		define('_TAGS_NOM_AUTEUR', '');
2154
-	}
2155
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2156
-	foreach ($tags_acceptes as $tag) {
2157
-		if (strlen($tag)) {
2158
-			$remp1[] = '<' . trim($tag) . '>';
2159
-			$remp1[] = '</' . trim($tag) . '>';
2160
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2161
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2162
-		}
2163
-	}
2164
-	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2149
+    if (!is_string($nom)) {
2150
+        return false;
2151
+    }
2152
+    if (!defined('_TAGS_NOM_AUTEUR')) {
2153
+        define('_TAGS_NOM_AUTEUR', '');
2154
+    }
2155
+    $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2156
+    foreach ($tags_acceptes as $tag) {
2157
+        if (strlen($tag)) {
2158
+            $remp1[] = '<' . trim($tag) . '>';
2159
+            $remp1[] = '</' . trim($tag) . '>';
2160
+            $remp2[] = '\x60' . trim($tag) . '\x61';
2161
+            $remp2[] = '\x60/' . trim($tag) . '\x61';
2162
+        }
2163
+    }
2164
+    $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2165 2165
 
2166
-	return str_replace('&lt;', '<', $v_nom) == $nom;
2166
+    return str_replace('&lt;', '<', $v_nom) == $nom;
2167 2167
 }
2168 2168
 
2169 2169
 
@@ -2177,29 +2177,29 @@  discard block
 block discarded – undo
2177 2177
  *      - la normalisation de la dernière adresse donnée sinon
2178 2178
  **/
2179 2179
 function email_valide($adresses) {
2180
-	// eviter d'injecter n'importe quoi dans preg_match
2181
-	if (!is_string($adresses)) {
2182
-		return false;
2183
-	}
2180
+    // eviter d'injecter n'importe quoi dans preg_match
2181
+    if (!is_string($adresses)) {
2182
+        return false;
2183
+    }
2184 2184
 
2185
-	// Si c'est un spammeur autant arreter tout de suite
2186
-	if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) {
2187
-		spip_log("Tentative d'injection de mail : $adresses");
2185
+    // Si c'est un spammeur autant arreter tout de suite
2186
+    if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) {
2187
+        spip_log("Tentative d'injection de mail : $adresses");
2188 2188
 
2189
-		return false;
2190
-	}
2189
+        return false;
2190
+    }
2191 2191
 
2192
-	foreach (explode(',', $adresses) as $v) {
2193
-		// nettoyer certains formats
2194
-		// "Marie Toto <[email protected]>"
2195
-		$adresse = trim(preg_replace(",^[^<>\"]*<([^<>\"]+)>$,i", "\\1", $v));
2196
-		// RFC 822
2197
-		if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) {
2198
-			return false;
2199
-		}
2200
-	}
2192
+    foreach (explode(',', $adresses) as $v) {
2193
+        // nettoyer certains formats
2194
+        // "Marie Toto <[email protected]>"
2195
+        $adresse = trim(preg_replace(",^[^<>\"]*<([^<>\"]+)>$,i", "\\1", $v));
2196
+        // RFC 822
2197
+        if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) {
2198
+            return false;
2199
+        }
2200
+    }
2201 2201
 
2202
-	return $adresse;
2202
+    return $adresse;
2203 2203
 }
2204 2204
 
2205 2205
 /**
@@ -2213,20 +2213,20 @@  discard block
 block discarded – undo
2213 2213
  * @return string Texte
2214 2214
  **/
2215 2215
 function afficher_enclosures($tags) {
2216
-	$s = array();
2217
-	foreach (extraire_balises($tags, 'a') as $tag) {
2218
-		if (extraire_attribut($tag, 'rel') == 'enclosure'
2219
-			and $t = extraire_attribut($tag, 'href')
2220
-		) {
2221
-			$s[] = preg_replace(',>[^<]+</a>,S',
2222
-				'>'
2223
-				. http_img_pack('attachment-16.png', $t,
2224
-					'title="' . attribut_html($t) . '"')
2225
-				. '</a>', $tag);
2226
-		}
2227
-	}
2216
+    $s = array();
2217
+    foreach (extraire_balises($tags, 'a') as $tag) {
2218
+        if (extraire_attribut($tag, 'rel') == 'enclosure'
2219
+            and $t = extraire_attribut($tag, 'href')
2220
+        ) {
2221
+            $s[] = preg_replace(',>[^<]+</a>,S',
2222
+                '>'
2223
+                . http_img_pack('attachment-16.png', $t,
2224
+                    'title="' . attribut_html($t) . '"')
2225
+                . '</a>', $tag);
2226
+        }
2227
+    }
2228 2228
 
2229
-	return join('&nbsp;', $s);
2229
+    return join('&nbsp;', $s);
2230 2230
 }
2231 2231
 
2232 2232
 /**
@@ -2241,15 +2241,15 @@  discard block
 block discarded – undo
2241 2241
  * @return string Liens trouvés
2242 2242
  **/
2243 2243
 function afficher_tags($tags, $rels = 'tag,directory') {
2244
-	$s = array();
2245
-	foreach (extraire_balises($tags, 'a') as $tag) {
2246
-		$rel = extraire_attribut($tag, 'rel');
2247
-		if (strstr(",$rels,", ",$rel,")) {
2248
-			$s[] = $tag;
2249
-		}
2250
-	}
2244
+    $s = array();
2245
+    foreach (extraire_balises($tags, 'a') as $tag) {
2246
+        $rel = extraire_attribut($tag, 'rel');
2247
+        if (strstr(",$rels,", ",$rel,")) {
2248
+            $s[] = $tag;
2249
+        }
2250
+    }
2251 2251
 
2252
-	return join(', ', $s);
2252
+    return join(', ', $s);
2253 2253
 }
2254 2254
 
2255 2255
 
@@ -2271,21 +2271,21 @@  discard block
 block discarded – undo
2271 2271
  * @return string Tag HTML `<a>` avec microformat.
2272 2272
  **/
2273 2273
 function enclosure2microformat($e) {
2274
-	if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) {
2275
-		$url = filtrer_entites(extraire_attribut($e, 'href'));
2276
-	}
2277
-	$type = extraire_attribut($e, 'type');
2278
-	if (!$length = extraire_attribut($e, 'length')) {
2279
-		# <media:content : longeur dans fileSize. On tente.
2280
-		$length = extraire_attribut($e, 'fileSize');
2281
-	}
2282
-	$fichier = basename($url);
2274
+    if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) {
2275
+        $url = filtrer_entites(extraire_attribut($e, 'href'));
2276
+    }
2277
+    $type = extraire_attribut($e, 'type');
2278
+    if (!$length = extraire_attribut($e, 'length')) {
2279
+        # <media:content : longeur dans fileSize. On tente.
2280
+        $length = extraire_attribut($e, 'fileSize');
2281
+    }
2282
+    $fichier = basename($url);
2283 2283
 
2284
-	return '<a rel="enclosure"'
2285
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2286
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2287
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2288
-	. '>' . $fichier . '</a>';
2284
+    return '<a rel="enclosure"'
2285
+    . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2286
+    . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2287
+    . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2288
+    . '>' . $fichier . '</a>';
2289 2289
 }
2290 2290
 
2291 2291
 /**
@@ -2303,24 +2303,24 @@  discard block
 block discarded – undo
2303 2303
  * @return string Tags RSS `<enclosure>`.
2304 2304
  **/
2305 2305
 function microformat2enclosure($tags) {
2306
-	$enclosures = array();
2307
-	foreach (extraire_balises($tags, 'a') as $e) {
2308
-		if (extraire_attribut($e, 'rel') == 'enclosure') {
2309
-			$url = filtrer_entites(extraire_attribut($e, 'href'));
2310
-			$type = extraire_attribut($e, 'type');
2311
-			if (!$length = intval(extraire_attribut($e, 'title'))) {
2312
-				$length = intval(extraire_attribut($e, 'length'));
2313
-			} # vieux data
2314
-			$fichier = basename($url);
2315
-			$enclosures[] = '<enclosure'
2316
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2317
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2318
-				. ($length ? ' length="' . $length . '"' : '')
2319
-				. ' />';
2320
-		}
2321
-	}
2306
+    $enclosures = array();
2307
+    foreach (extraire_balises($tags, 'a') as $e) {
2308
+        if (extraire_attribut($e, 'rel') == 'enclosure') {
2309
+            $url = filtrer_entites(extraire_attribut($e, 'href'));
2310
+            $type = extraire_attribut($e, 'type');
2311
+            if (!$length = intval(extraire_attribut($e, 'title'))) {
2312
+                $length = intval(extraire_attribut($e, 'length'));
2313
+            } # vieux data
2314
+            $fichier = basename($url);
2315
+            $enclosures[] = '<enclosure'
2316
+                . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2317
+                . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2318
+                . ($length ? ' length="' . $length . '"' : '')
2319
+                . ' />';
2320
+        }
2321
+    }
2322 2322
 
2323
-	return join("\n", $enclosures);
2323
+    return join("\n", $enclosures);
2324 2324
 }
2325 2325
 
2326 2326
 
@@ -2336,16 +2336,16 @@  discard block
 block discarded – undo
2336 2336
  * @return string Tags RSS Atom `<dc:subject>`.
2337 2337
  **/
2338 2338
 function tags2dcsubject($tags) {
2339
-	$subjects = '';
2340
-	foreach (extraire_balises($tags, 'a') as $e) {
2341
-		if (extraire_attribut($e, rel) == 'tag') {
2342
-			$subjects .= '<dc:subject>'
2343
-				. texte_backend(textebrut($e))
2344
-				. '</dc:subject>' . "\n";
2345
-		}
2346
-	}
2339
+    $subjects = '';
2340
+    foreach (extraire_balises($tags, 'a') as $e) {
2341
+        if (extraire_attribut($e, rel) == 'tag') {
2342
+            $subjects .= '<dc:subject>'
2343
+                . texte_backend(textebrut($e))
2344
+                . '</dc:subject>' . "\n";
2345
+        }
2346
+    }
2347 2347
 
2348
-	return $subjects;
2348
+    return $subjects;
2349 2349
 }
2350 2350
 
2351 2351
 /**
@@ -2374,23 +2374,23 @@  discard block
 block discarded – undo
2374 2374
  *     - Tableau de résultats, si tableau en entrée.
2375 2375
  **/
2376 2376
 function extraire_balise($texte, $tag = 'a') {
2377
-	if (is_array($texte)) {
2378
-		array_walk(
2379
-			$texte,
2380
-			function(&$a, $key, $t){
2381
-				$a = extraire_balise($a, $t);
2382
-			},
2383
-			$tag
2384
-		);
2377
+    if (is_array($texte)) {
2378
+        array_walk(
2379
+            $texte,
2380
+            function(&$a, $key, $t){
2381
+                $a = extraire_balise($a, $t);
2382
+            },
2383
+            $tag
2384
+        );
2385 2385
 
2386
-		return $texte;
2387
-	}
2386
+        return $texte;
2387
+    }
2388 2388
 
2389
-	if (preg_match(
2390
-		",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2391
-		$texte, $regs)) {
2392
-		return $regs[0];
2393
-	}
2389
+    if (preg_match(
2390
+        ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2391
+        $texte, $regs)) {
2392
+        return $regs[0];
2393
+    }
2394 2394
 }
2395 2395
 
2396 2396
 /**
@@ -2418,25 +2418,25 @@  discard block
 block discarded – undo
2418 2418
  *     - Tableau de résultats, si tableau en entrée.
2419 2419
  **/
2420 2420
 function extraire_balises($texte, $tag = 'a') {
2421
-	if (is_array($texte)) {
2422
-		array_walk(
2423
-			$texte,
2424
-			function(&$a, $key, $t){
2425
-				$a = extraire_balises($a, $t);
2426
-			},
2427
-			$tag
2428
-		);
2421
+    if (is_array($texte)) {
2422
+        array_walk(
2423
+            $texte,
2424
+            function(&$a, $key, $t){
2425
+                $a = extraire_balises($a, $t);
2426
+            },
2427
+            $tag
2428
+        );
2429 2429
 
2430
-		return $texte;
2431
-	}
2430
+        return $texte;
2431
+    }
2432 2432
 
2433
-	if (preg_match_all(
2434
-		",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2435
-		$texte, $regs, PREG_PATTERN_ORDER)) {
2436
-		return $regs[0];
2437
-	} else {
2438
-		return array();
2439
-	}
2433
+    if (preg_match_all(
2434
+        ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2435
+        $texte, $regs, PREG_PATTERN_ORDER)) {
2436
+        return $regs[0];
2437
+    } else {
2438
+        return array();
2439
+    }
2440 2440
 }
2441 2441
 
2442 2442
 /**
@@ -2465,11 +2465,11 @@  discard block
 block discarded – undo
2465 2465
  *     - `$def` si on n'a pas transmis de tableau
2466 2466
  **/
2467 2467
 function in_any($val, $vals, $def = '') {
2468
-	if (!is_array($vals) and $v = unserialize($vals)) {
2469
-		$vals = $v;
2470
-	}
2468
+    if (!is_array($vals) and $v = unserialize($vals)) {
2469
+        $vals = $v;
2470
+    }
2471 2471
 
2472
-	return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2472
+    return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2473 2473
 }
2474 2474
 
2475 2475
 
@@ -2490,12 +2490,12 @@  discard block
 block discarded – undo
2490 2490
  *     Résultat du calcul
2491 2491
  **/
2492 2492
 function valeur_numerique($expr) {
2493
-	$a = 0;
2494
-	if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2495
-		eval("\$a = $expr;");
2496
-	}
2493
+    $a = 0;
2494
+    if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2495
+        eval("\$a = $expr;");
2496
+    }
2497 2497
 
2498
-	return intval($a);
2498
+    return intval($a);
2499 2499
 }
2500 2500
 
2501 2501
 /**
@@ -2514,7 +2514,7 @@  discard block
 block discarded – undo
2514 2514
  *      Retourne `$a*$b/$c`
2515 2515
  **/
2516 2516
 function regledetrois($a, $b, $c) {
2517
-	return round($a * $b / $c);
2517
+    return round($a * $b / $c);
2518 2518
 }
2519 2519
 
2520 2520
 
@@ -2538,76 +2538,76 @@  discard block
 block discarded – undo
2538 2538
  **/
2539 2539
 function form_hidden($action) {
2540 2540
 
2541
-	$contexte = array();
2542
-	include_spip('inc/urls');
2543
-	if ($p = urls_decoder_url($action, '')
2544
-		and reset($p)
2545
-	) {
2546
-		$fond = array_shift($p);
2547
-		if ($fond != '404') {
2548
-			$contexte = array_shift($p);
2549
-			$contexte['page'] = $fond;
2550
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2551
-		}
2552
-	}
2553
-	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2554
-	if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2555
-		unset($contexte['type']);
2556
-	}
2557
-	if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) {
2558
-		unset($contexte['type-page']);
2559
-	}
2560
-
2561
-	// on va remplir un tableau de valeurs en prenant bien soin de ne pas
2562
-	// ecraser les elements de la forme mots[]=1&mots[]=2
2563
-	$values = array();
2564
-
2565
-	// d'abord avec celles de l'url
2566
-	if (false !== ($p = strpos($action, '?'))) {
2567
-		foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2568
-			$c = explode('=', $c, 2);
2569
-			$var = array_shift($c);
2570
-			$val = array_shift($c);
2571
-			if ($var) {
2572
-				$val = rawurldecode($val);
2573
-				$var = rawurldecode($var); // decoder les [] eventuels
2574
-				if (preg_match(',\[\]$,S', $var)) {
2575
-					$values[] = array($var, $val);
2576
-				} else {
2577
-					if (!isset($values[$var])) {
2578
-						$values[$var] = array($var, $val);
2579
-					}
2580
-				}
2581
-			}
2582
-		}
2583
-	}
2584
-
2585
-	// ensuite avec celles du contexte, sans doublonner !
2586
-	foreach ($contexte as $var => $val) {
2587
-		if (preg_match(',\[\]$,S', $var)) {
2588
-			$values[] = array($var, $val);
2589
-		} else {
2590
-			if (!isset($values[$var])) {
2591
-				$values[$var] = array($var, $val);
2592
-			}
2593
-		}
2594
-	}
2595
-
2596
-	// puis on rassemble le tout
2597
-	$hidden = array();
2598
-	foreach ($values as $value) {
2599
-		list($var, $val) = $value;
2600
-		$hidden[] = '<input name="'
2601
-			. entites_html($var)
2602
-			. '"'
2603
-			. (is_null($val)
2604
-				? ''
2605
-				: ' value="' . entites_html($val) . '"'
2606
-			)
2607
-			. ' type="hidden"' . "\n/>";
2608
-	}
2609
-
2610
-	return join("", $hidden);
2541
+    $contexte = array();
2542
+    include_spip('inc/urls');
2543
+    if ($p = urls_decoder_url($action, '')
2544
+        and reset($p)
2545
+    ) {
2546
+        $fond = array_shift($p);
2547
+        if ($fond != '404') {
2548
+            $contexte = array_shift($p);
2549
+            $contexte['page'] = $fond;
2550
+            $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2551
+        }
2552
+    }
2553
+    // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2554
+    if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2555
+        unset($contexte['type']);
2556
+    }
2557
+    if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) {
2558
+        unset($contexte['type-page']);
2559
+    }
2560
+
2561
+    // on va remplir un tableau de valeurs en prenant bien soin de ne pas
2562
+    // ecraser les elements de la forme mots[]=1&mots[]=2
2563
+    $values = array();
2564
+
2565
+    // d'abord avec celles de l'url
2566
+    if (false !== ($p = strpos($action, '?'))) {
2567
+        foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2568
+            $c = explode('=', $c, 2);
2569
+            $var = array_shift($c);
2570
+            $val = array_shift($c);
2571
+            if ($var) {
2572
+                $val = rawurldecode($val);
2573
+                $var = rawurldecode($var); // decoder les [] eventuels
2574
+                if (preg_match(',\[\]$,S', $var)) {
2575
+                    $values[] = array($var, $val);
2576
+                } else {
2577
+                    if (!isset($values[$var])) {
2578
+                        $values[$var] = array($var, $val);
2579
+                    }
2580
+                }
2581
+            }
2582
+        }
2583
+    }
2584
+
2585
+    // ensuite avec celles du contexte, sans doublonner !
2586
+    foreach ($contexte as $var => $val) {
2587
+        if (preg_match(',\[\]$,S', $var)) {
2588
+            $values[] = array($var, $val);
2589
+        } else {
2590
+            if (!isset($values[$var])) {
2591
+                $values[$var] = array($var, $val);
2592
+            }
2593
+        }
2594
+    }
2595
+
2596
+    // puis on rassemble le tout
2597
+    $hidden = array();
2598
+    foreach ($values as $value) {
2599
+        list($var, $val) = $value;
2600
+        $hidden[] = '<input name="'
2601
+            . entites_html($var)
2602
+            . '"'
2603
+            . (is_null($val)
2604
+                ? ''
2605
+                : ' value="' . entites_html($val) . '"'
2606
+            )
2607
+            . ' type="hidden"' . "\n/>";
2608
+    }
2609
+
2610
+    return join("", $hidden);
2611 2611
 }
2612 2612
 
2613 2613
 /**
@@ -2625,15 +2625,15 @@  discard block
 block discarded – undo
2625 2625
  *     Liste (première page, dernière page).
2626 2626
  **/
2627 2627
 function filtre_bornes_pagination_dist($courante, $nombre, $max = 10) {
2628
-	if ($max <= 0 or $max >= $nombre) {
2629
-		return array(1, $nombre);
2630
-	}
2628
+    if ($max <= 0 or $max >= $nombre) {
2629
+        return array(1, $nombre);
2630
+    }
2631 2631
 
2632
-	$premiere = max(1, $courante - floor(($max - 1) / 2));
2633
-	$derniere = min($nombre, $premiere + $max - 2);
2634
-	$premiere = $derniere == $nombre ? $derniere - $max + 1 : $premiere;
2632
+    $premiere = max(1, $courante - floor(($max - 1) / 2));
2633
+    $derniere = min($nombre, $premiere + $max - 2);
2634
+    $premiere = $derniere == $nombre ? $derniere - $max + 1 : $premiere;
2635 2635
 
2636
-	return array($premiere, $derniere);
2636
+    return array($premiere, $derniere);
2637 2637
 }
2638 2638
 
2639 2639
 
@@ -2655,7 +2655,7 @@  discard block
 block discarded – undo
2655 2655
  *    - la première valeur du tableau sinon.
2656 2656
  **/
2657 2657
 function filtre_reset($array) {
2658
-	return !is_array($array) ? null : reset($array);
2658
+    return !is_array($array) ? null : reset($array);
2659 2659
 }
2660 2660
 
2661 2661
 /**
@@ -2676,7 +2676,7 @@  discard block
 block discarded – undo
2676 2676
  *    - la dernière valeur du tableau sinon.
2677 2677
  **/
2678 2678
 function filtre_end($array) {
2679
-	return !is_array($array) ? null : end($array);
2679
+    return !is_array($array) ? null : end($array);
2680 2680
 }
2681 2681
 
2682 2682
 /**
@@ -2696,11 +2696,11 @@  discard block
 block discarded – undo
2696 2696
  *
2697 2697
  **/
2698 2698
 function filtre_push($array, $val) {
2699
-	if (!is_array($array) or !array_push($array, $val)) {
2700
-		return '';
2701
-	}
2699
+    if (!is_array($array) or !array_push($array, $val)) {
2700
+        return '';
2701
+    }
2702 2702
 
2703
-	return $array;
2703
+    return $array;
2704 2704
 }
2705 2705
 
2706 2706
 /**
@@ -2719,7 +2719,7 @@  discard block
 block discarded – undo
2719 2719
  *     - `true` si la valeur existe dans le tableau, `false` sinon.
2720 2720
  **/
2721 2721
 function filtre_find($array, $val) {
2722
-	return (is_array($array) and in_array($val, $array));
2722
+    return (is_array($array) and in_array($val, $array));
2723 2723
 }
2724 2724
 
2725 2725
 
@@ -2754,59 +2754,59 @@  discard block
 block discarded – undo
2754 2754
  *     Code HTML de la pagination
2755 2755
  **/
2756 2756
 function filtre_pagination_dist(
2757
-	$total,
2758
-	$nom,
2759
-	$position,
2760
-	$pas,
2761
-	$liste = true,
2762
-	$modele = '',
2763
-	$connect = '',
2764
-	$env = array()
2757
+    $total,
2758
+    $nom,
2759
+    $position,
2760
+    $pas,
2761
+    $liste = true,
2762
+    $modele = '',
2763
+    $connect = '',
2764
+    $env = array()
2765 2765
 ) {
2766
-	static $ancres = array();
2767
-	if ($pas < 1) {
2768
-		return '';
2769
-	}
2770
-	$ancre = 'pagination' . $nom; // #pagination_articles
2771
-	$debut = 'debut' . $nom; // 'debut_articles'
2772
-
2773
-	// n'afficher l'ancre qu'une fois
2774
-	if (!isset($ancres[$ancre])) {
2775
-		$bloc_ancre = $ancres[$ancre] = "<a name='" . $ancre . "' id='" . $ancre . "'></a>";
2776
-	} else {
2777
-		$bloc_ancre = '';
2778
-	}
2779
-	// liste = false : on ne veut que l'ancre
2780
-	if (!$liste) {
2781
-		return $ancres[$ancre];
2782
-	}
2783
-
2784
-	$self = (empty($env['self']) ? self() : $env['self']);
2785
-	$pagination = array(
2786
-		'debut' => $debut,
2787
-		'url' => parametre_url($self, 'fragment', ''), // nettoyer l'id ahah eventuel
2788
-		'total' => $total,
2789
-		'position' => intval($position),
2790
-		'pas' => $pas,
2791
-		'nombre_pages' => floor(($total - 1) / $pas) + 1,
2792
-		'page_courante' => floor(intval($position) / $pas) + 1,
2793
-		'ancre' => $ancre,
2794
-		'bloc_ancre' => $bloc_ancre
2795
-	);
2796
-	if (is_array($env)) {
2797
-		$pagination = array_merge($env, $pagination);
2798
-	}
2799
-
2800
-	// Pas de pagination
2801
-	if ($pagination['nombre_pages'] <= 1) {
2802
-		return '';
2803
-	}
2804
-
2805
-	if ($modele) {
2806
-		$modele = '_' . $modele;
2807
-	}
2808
-
2809
-	return recuperer_fond("modeles/pagination$modele", $pagination, array('trim' => true), $connect);
2766
+    static $ancres = array();
2767
+    if ($pas < 1) {
2768
+        return '';
2769
+    }
2770
+    $ancre = 'pagination' . $nom; // #pagination_articles
2771
+    $debut = 'debut' . $nom; // 'debut_articles'
2772
+
2773
+    // n'afficher l'ancre qu'une fois
2774
+    if (!isset($ancres[$ancre])) {
2775
+        $bloc_ancre = $ancres[$ancre] = "<a name='" . $ancre . "' id='" . $ancre . "'></a>";
2776
+    } else {
2777
+        $bloc_ancre = '';
2778
+    }
2779
+    // liste = false : on ne veut que l'ancre
2780
+    if (!$liste) {
2781
+        return $ancres[$ancre];
2782
+    }
2783
+
2784
+    $self = (empty($env['self']) ? self() : $env['self']);
2785
+    $pagination = array(
2786
+        'debut' => $debut,
2787
+        'url' => parametre_url($self, 'fragment', ''), // nettoyer l'id ahah eventuel
2788
+        'total' => $total,
2789
+        'position' => intval($position),
2790
+        'pas' => $pas,
2791
+        'nombre_pages' => floor(($total - 1) / $pas) + 1,
2792
+        'page_courante' => floor(intval($position) / $pas) + 1,
2793
+        'ancre' => $ancre,
2794
+        'bloc_ancre' => $bloc_ancre
2795
+    );
2796
+    if (is_array($env)) {
2797
+        $pagination = array_merge($env, $pagination);
2798
+    }
2799
+
2800
+    // Pas de pagination
2801
+    if ($pagination['nombre_pages'] <= 1) {
2802
+        return '';
2803
+    }
2804
+
2805
+    if ($modele) {
2806
+        $modele = '_' . $modele;
2807
+    }
2808
+
2809
+    return recuperer_fond("modeles/pagination$modele", $pagination, array('trim' => true), $connect);
2810 2810
 }
2811 2811
 
2812 2812
 
@@ -2823,15 +2823,15 @@  discard block
 block discarded – undo
2823 2823
  *     Contenu avec urls en absolus
2824 2824
  **/
2825 2825
 function urls_absolues_css($contenu, $source) {
2826
-	$path = suivre_lien(url_absolue($source), './');
2826
+    $path = suivre_lien(url_absolue($source), './');
2827 2827
 
2828
-	return preg_replace_callback(
2829
-		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2830
-		function($x) use ($path) {
2831
-			return "url('" . suivre_lien($path, $x[1]) . "')";
2832
-		},
2833
-		$contenu
2834
-	);
2828
+    return preg_replace_callback(
2829
+        ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2830
+        function($x) use ($path) {
2831
+            return "url('" . suivre_lien($path, $x[1]) . "')";
2832
+        },
2833
+        $contenu
2834
+    );
2835 2835
 }
2836 2836
 
2837 2837
 
@@ -2860,118 +2860,118 @@  discard block
 block discarded – undo
2860 2860
  *     Chemin du fichier CSS inversé
2861 2861
  **/
2862 2862
 function direction_css($css, $voulue = '') {
2863
-	if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2864
-		return $css;
2865
-	}
2866
-
2867
-	// si on a precise le sens voulu en argument, le prendre en compte
2868
-	if ($voulue = strtolower($voulue)) {
2869
-		if ($voulue != 'rtl' and $voulue != 'ltr') {
2870
-			$voulue = lang_dir($voulue);
2871
-		}
2872
-	} else {
2873
-		$voulue = lang_dir();
2874
-	}
2875
-
2876
-	$r = count($r) > 1;
2877
-	$right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2878
-	$dir = $r ? 'rtl' : 'ltr';
2879
-	$ndir = $r ? 'ltr' : 'rtl';
2880
-
2881
-	if ($voulue == $dir) {
2882
-		return $css;
2883
-	}
2884
-
2885
-	if (
2886
-		// url absolue
2887
-		preg_match(",^https?:,i", $css)
2888
-		// ou qui contient un ?
2889
-		or (($p = strpos($css, '?')) !== false)
2890
-	) {
2891
-		$distant = true;
2892
-		$cssf = parse_url($css);
2893
-		$cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2894
-		$cssf = preg_replace(',[?:&=],', "_", $cssf);
2895
-	} else {
2896
-		$distant = false;
2897
-		$cssf = $css;
2898
-		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2899
-		//propose (rien a faire dans ce cas)
2900
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2901
-		if (@file_exists($f)) {
2902
-			return $f;
2903
-		}
2904
-	}
2905
-
2906
-	// 2.
2907
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2908
-	$f = $dir_var
2909
-		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2910
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2911
-
2912
-	// la css peut etre distante (url absolue !)
2913
-	if ($distant) {
2914
-		include_spip('inc/distant');
2915
-		$res = recuperer_url($css);
2916
-		if (!$res or !$contenu = $res['page']) {
2917
-			return $css;
2918
-		}
2919
-	} else {
2920
-		if ((@filemtime($f) > @filemtime($css))
2921
-			and (_VAR_MODE != 'recalcul')
2922
-		) {
2923
-			return $f;
2924
-		}
2925
-		if (!lire_fichier($css, $contenu)) {
2926
-			return $css;
2927
-		}
2928
-	}
2929
-
2930
-
2931
-	// Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2932
-	include_spip("lib/csstidy/class.csstidy");
2933
-	$parser = new csstidy();
2934
-	$parser->set_cfg('optimise_shorthands', 0);
2935
-	$parser->set_cfg('reverse_left_and_right', true);
2936
-	$parser->parse($contenu);
2937
-
2938
-	$contenu = $parser->print->plain();
2939
-
2940
-
2941
-	// reperer les @import auxquels il faut propager le direction_css
2942
-	preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
2943
-	$src = array();
2944
-	$src_direction_css = array();
2945
-	$src_faux_abs = array();
2946
-	$d = dirname($css);
2947
-	foreach ($regs[1] as $k => $import_css) {
2948
-		$css_direction = direction_css("$d/$import_css", $voulue);
2949
-		// si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2950
-		if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2951
-			$css_direction = substr($css_direction, strlen($d) + 1);
2952
-		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2953
-		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2954
-			$css_direction = substr($css_direction, strlen($dir_var));
2955
-			$src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2956
-			$css_direction = "/@@@@@@/" . $css_direction;
2957
-		}
2958
-		$src[] = $regs[0][$k];
2959
-		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
2960
-	}
2961
-	$contenu = str_replace($src, $src_direction_css, $contenu);
2962
-
2963
-	$contenu = urls_absolues_css($contenu, $css);
2964
-
2965
-	// virer les fausses url absolues que l'on a mis dans les import
2966
-	if (count($src_faux_abs)) {
2967
-		$contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
2968
-	}
2969
-
2970
-	if (!ecrire_fichier($f, $contenu)) {
2971
-		return $css;
2972
-	}
2973
-
2974
-	return $f;
2863
+    if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2864
+        return $css;
2865
+    }
2866
+
2867
+    // si on a precise le sens voulu en argument, le prendre en compte
2868
+    if ($voulue = strtolower($voulue)) {
2869
+        if ($voulue != 'rtl' and $voulue != 'ltr') {
2870
+            $voulue = lang_dir($voulue);
2871
+        }
2872
+    } else {
2873
+        $voulue = lang_dir();
2874
+    }
2875
+
2876
+    $r = count($r) > 1;
2877
+    $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2878
+    $dir = $r ? 'rtl' : 'ltr';
2879
+    $ndir = $r ? 'ltr' : 'rtl';
2880
+
2881
+    if ($voulue == $dir) {
2882
+        return $css;
2883
+    }
2884
+
2885
+    if (
2886
+        // url absolue
2887
+        preg_match(",^https?:,i", $css)
2888
+        // ou qui contient un ?
2889
+        or (($p = strpos($css, '?')) !== false)
2890
+    ) {
2891
+        $distant = true;
2892
+        $cssf = parse_url($css);
2893
+        $cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2894
+        $cssf = preg_replace(',[?:&=],', "_", $cssf);
2895
+    } else {
2896
+        $distant = false;
2897
+        $cssf = $css;
2898
+        // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2899
+        //propose (rien a faire dans ce cas)
2900
+        $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2901
+        if (@file_exists($f)) {
2902
+            return $f;
2903
+        }
2904
+    }
2905
+
2906
+    // 2.
2907
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2908
+    $f = $dir_var
2909
+        . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2910
+        . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2911
+
2912
+    // la css peut etre distante (url absolue !)
2913
+    if ($distant) {
2914
+        include_spip('inc/distant');
2915
+        $res = recuperer_url($css);
2916
+        if (!$res or !$contenu = $res['page']) {
2917
+            return $css;
2918
+        }
2919
+    } else {
2920
+        if ((@filemtime($f) > @filemtime($css))
2921
+            and (_VAR_MODE != 'recalcul')
2922
+        ) {
2923
+            return $f;
2924
+        }
2925
+        if (!lire_fichier($css, $contenu)) {
2926
+            return $css;
2927
+        }
2928
+    }
2929
+
2930
+
2931
+    // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2932
+    include_spip("lib/csstidy/class.csstidy");
2933
+    $parser = new csstidy();
2934
+    $parser->set_cfg('optimise_shorthands', 0);
2935
+    $parser->set_cfg('reverse_left_and_right', true);
2936
+    $parser->parse($contenu);
2937
+
2938
+    $contenu = $parser->print->plain();
2939
+
2940
+
2941
+    // reperer les @import auxquels il faut propager le direction_css
2942
+    preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
2943
+    $src = array();
2944
+    $src_direction_css = array();
2945
+    $src_faux_abs = array();
2946
+    $d = dirname($css);
2947
+    foreach ($regs[1] as $k => $import_css) {
2948
+        $css_direction = direction_css("$d/$import_css", $voulue);
2949
+        // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2950
+        if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2951
+            $css_direction = substr($css_direction, strlen($d) + 1);
2952
+        } // si la css_direction commence par $dir_var on la fait passer pour une absolue
2953
+        elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2954
+            $css_direction = substr($css_direction, strlen($dir_var));
2955
+            $src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2956
+            $css_direction = "/@@@@@@/" . $css_direction;
2957
+        }
2958
+        $src[] = $regs[0][$k];
2959
+        $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
2960
+    }
2961
+    $contenu = str_replace($src, $src_direction_css, $contenu);
2962
+
2963
+    $contenu = urls_absolues_css($contenu, $css);
2964
+
2965
+    // virer les fausses url absolues que l'on a mis dans les import
2966
+    if (count($src_faux_abs)) {
2967
+        $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
2968
+    }
2969
+
2970
+    if (!ecrire_fichier($f, $contenu)) {
2971
+        return $css;
2972
+    }
2973
+
2974
+    return $f;
2975 2975
 }
2976 2976
 
2977 2977
 
@@ -2994,43 +2994,43 @@  discard block
 block discarded – undo
2994 2994
  *     - Chemin ou URL du fichier CSS source sinon.
2995 2995
  **/
2996 2996
 function url_absolue_css($css) {
2997
-	if (!preg_match(',\.css$,i', $css, $r)) {
2998
-		return $css;
2999
-	}
2997
+    if (!preg_match(',\.css$,i', $css, $r)) {
2998
+        return $css;
2999
+    }
3000 3000
 
3001
-	$url_absolue_css = url_absolue($css);
3001
+    $url_absolue_css = url_absolue($css);
3002 3002
 
3003
-	$f = basename($css, '.css');
3004
-	$f = sous_repertoire(_DIR_VAR, 'cache-css')
3005
-		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3006
-		. '.css';
3003
+    $f = basename($css, '.css');
3004
+    $f = sous_repertoire(_DIR_VAR, 'cache-css')
3005
+        . preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3006
+        . '.css';
3007 3007
 
3008
-	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
3009
-		return $f;
3010
-	}
3008
+    if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
3009
+        return $f;
3010
+    }
3011 3011
 
3012
-	if ($url_absolue_css == $css) {
3013
-		if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3014
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3015
-		) {
3016
-			include_spip('inc/distant');
3017
-			if (!$contenu = recuperer_page($css)) {
3018
-				return $css;
3019
-			}
3020
-		}
3021
-	} elseif (!lire_fichier($css, $contenu)) {
3022
-		return $css;
3023
-	}
3012
+    if ($url_absolue_css == $css) {
3013
+        if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3014
+            or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3015
+        ) {
3016
+            include_spip('inc/distant');
3017
+            if (!$contenu = recuperer_page($css)) {
3018
+                return $css;
3019
+            }
3020
+        }
3021
+    } elseif (!lire_fichier($css, $contenu)) {
3022
+        return $css;
3023
+    }
3024 3024
 
3025
-	// passer les url relatives a la css d'origine en url absolues
3026
-	$contenu = urls_absolues_css($contenu, $css);
3025
+    // passer les url relatives a la css d'origine en url absolues
3026
+    $contenu = urls_absolues_css($contenu, $css);
3027 3027
 
3028
-	// ecrire la css
3029
-	if (!ecrire_fichier($f, $contenu)) {
3030
-		return $css;
3031
-	}
3028
+    // ecrire la css
3029
+    if (!ecrire_fichier($f, $contenu)) {
3030
+        return $css;
3031
+    }
3032 3032
 
3033
-	return $f;
3033
+    return $f;
3034 3034
 }
3035 3035
 
3036 3036
 
@@ -3064,24 +3064,24 @@  discard block
 block discarded – undo
3064 3064
  *     Valeur trouvée ou valeur par défaut.
3065 3065
  **/
3066 3066
 function table_valeur($table, $cle, $defaut = '', $conserver_null = false) {
3067
-	foreach (explode('/', $cle) as $k) {
3067
+    foreach (explode('/', $cle) as $k) {
3068 3068
 
3069
-		$table = is_string($table) ? @unserialize($table) : $table;
3069
+        $table = is_string($table) ? @unserialize($table) : $table;
3070 3070
 
3071
-		if (is_object($table)) {
3072
-			$table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut;
3073
-		} elseif (is_array($table)) {
3074
-			if ($conserver_null) {
3075
-				$table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3076
-			} else {
3077
-				$table = isset($table[$k]) ? $table[$k] : $defaut;
3078
-			}
3079
-		} else {
3080
-			$table = $defaut;
3081
-		}
3082
-	}
3071
+        if (is_object($table)) {
3072
+            $table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut;
3073
+        } elseif (is_array($table)) {
3074
+            if ($conserver_null) {
3075
+                $table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3076
+            } else {
3077
+                $table = isset($table[$k]) ? $table[$k] : $defaut;
3078
+            }
3079
+        } else {
3080
+            $table = $defaut;
3081
+        }
3082
+    }
3083 3083
 
3084
-	return $table;
3084
+    return $table;
3085 3085
 }
3086 3086
 
3087 3087
 /**
@@ -3114,22 +3114,22 @@  discard block
 block discarded – undo
3114 3114
  *     - string : expression trouvée.
3115 3115
  **/
3116 3116
 function filtre_match_dist($texte, $expression, $modif = "UimsS", $capte = 0) {
3117
-	if (intval($modif) and $capte == 0) {
3118
-		$capte = $modif;
3119
-		$modif = "UimsS";
3120
-	}
3121
-	$expression = str_replace("\/", "/", $expression);
3122
-	$expression = str_replace("/", "\/", $expression);
3117
+    if (intval($modif) and $capte == 0) {
3118
+        $capte = $modif;
3119
+        $modif = "UimsS";
3120
+    }
3121
+    $expression = str_replace("\/", "/", $expression);
3122
+    $expression = str_replace("/", "\/", $expression);
3123 3123
 
3124
-	if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3125
-		if (isset($r[$capte])) {
3126
-			return $r[$capte];
3127
-		} else {
3128
-			return true;
3129
-		}
3130
-	}
3124
+    if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3125
+        if (isset($r[$capte])) {
3126
+            return $r[$capte];
3127
+        } else {
3128
+            return true;
3129
+        }
3130
+    }
3131 3131
 
3132
-	return false;
3132
+    return false;
3133 3133
 }
3134 3134
 
3135 3135
 
@@ -3156,10 +3156,10 @@  discard block
 block discarded – undo
3156 3156
  *     Texte
3157 3157
  **/
3158 3158
 function replace($texte, $expression, $replace = '', $modif = "UimsS") {
3159
-	$expression = str_replace("\/", "/", $expression);
3160
-	$expression = str_replace("/", "\/", $expression);
3159
+    $expression = str_replace("\/", "/", $expression);
3160
+    $expression = str_replace("/", "\/", $expression);
3161 3161
 
3162
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3162
+    return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3163 3163
 }
3164 3164
 
3165 3165
 
@@ -3177,21 +3177,21 @@  discard block
 block discarded – undo
3177 3177
  **/
3178 3178
 function traiter_doublons_documents(&$doublons, $letexte) {
3179 3179
 
3180
-	// Verifier dans le texte & les notes (pas beau, helas)
3181
-	$t = $letexte . $GLOBALS['les_notes'];
3180
+    // Verifier dans le texte & les notes (pas beau, helas)
3181
+    $t = $letexte . $GLOBALS['les_notes'];
3182 3182
 
3183
-	if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3184
-		and preg_match_all(
3185
-			',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3186
-			$t, $matches, PREG_PATTERN_ORDER)
3187
-	) {
3188
-		if (!isset($doublons['documents'])) {
3189
-			$doublons['documents'] = "";
3190
-		}
3191
-		$doublons['documents'] .= "," . join(',', $matches[1]);
3192
-	}
3183
+    if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3184
+        and preg_match_all(
3185
+            ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3186
+            $t, $matches, PREG_PATTERN_ORDER)
3187
+    ) {
3188
+        if (!isset($doublons['documents'])) {
3189
+            $doublons['documents'] = "";
3190
+        }
3191
+        $doublons['documents'] .= "," . join(',', $matches[1]);
3192
+    }
3193 3193
 
3194
-	return $letexte;
3194
+    return $letexte;
3195 3195
 }
3196 3196
 
3197 3197
 /**
@@ -3205,7 +3205,7 @@  discard block
 block discarded – undo
3205 3205
  * @return string Chaîne vide
3206 3206
  **/
3207 3207
 function vide($texte) {
3208
-	return "";
3208
+    return "";
3209 3209
 }
3210 3210
 
3211 3211
 //
@@ -3234,23 +3234,23 @@  discard block
 block discarded – undo
3234 3234
  *      Code HTML résultant
3235 3235
  **/
3236 3236
 function env_to_params($env, $ignore_params = array()) {
3237
-	$ignore_params = array_merge(
3238
-		array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3239
-		$ignore_params
3240
-	);
3241
-	if (!is_array($env)) {
3242
-		$env = unserialize($env);
3243
-	}
3244
-	$texte = "";
3245
-	if ($env) {
3246
-		foreach ($env as $i => $j) {
3247
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3248
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3249
-			}
3250
-		}
3251
-	}
3252
-
3253
-	return $texte;
3237
+    $ignore_params = array_merge(
3238
+        array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3239
+        $ignore_params
3240
+    );
3241
+    if (!is_array($env)) {
3242
+        $env = unserialize($env);
3243
+    }
3244
+    $texte = "";
3245
+    if ($env) {
3246
+        foreach ($env as $i => $j) {
3247
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3248
+                $texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3249
+            }
3250
+        }
3251
+    }
3252
+
3253
+    return $texte;
3254 3254
 }
3255 3255
 
3256 3256
 /**
@@ -3273,23 +3273,23 @@  discard block
 block discarded – undo
3273 3273
  *      Code HTML résultant
3274 3274
  **/
3275 3275
 function env_to_attributs($env, $ignore_params = array()) {
3276
-	$ignore_params = array_merge(
3277
-		array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3278
-		$ignore_params
3279
-	);
3280
-	if (!is_array($env)) {
3281
-		$env = unserialize($env);
3282
-	}
3283
-	$texte = "";
3284
-	if ($env) {
3285
-		foreach ($env as $i => $j) {
3286
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3287
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3288
-			}
3289
-		}
3290
-	}
3276
+    $ignore_params = array_merge(
3277
+        array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3278
+        $ignore_params
3279
+    );
3280
+    if (!is_array($env)) {
3281
+        $env = unserialize($env);
3282
+    }
3283
+    $texte = "";
3284
+    if ($env) {
3285
+        foreach ($env as $i => $j) {
3286
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3287
+                $texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3288
+            }
3289
+        }
3290
+    }
3291 3291
 
3292
-	return $texte;
3292
+    return $texte;
3293 3293
 }
3294 3294
 
3295 3295
 
@@ -3306,9 +3306,9 @@  discard block
 block discarded – undo
3306 3306
  * @return string Chaînes concaténés
3307 3307
  **/
3308 3308
 function concat() {
3309
-	$args = func_get_args();
3309
+    $args = func_get_args();
3310 3310
 
3311
-	return join('', $args);
3311
+    return join('', $args);
3312 3312
 }
3313 3313
 
3314 3314
 
@@ -3328,23 +3328,23 @@  discard block
 block discarded – undo
3328 3328
  *     Contenu du ou des fichiers, concaténé
3329 3329
  **/
3330 3330
 function charge_scripts($files, $script = true) {
3331
-	$flux = "";
3332
-	foreach (is_array($files) ? $files : explode("|", $files) as $file) {
3333
-		if (!is_string($file)) {
3334
-			continue;
3335
-		}
3336
-		if ($script) {
3337
-			$file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : '';
3338
-		}
3339
-		if ($file) {
3340
-			$path = find_in_path($file);
3341
-			if ($path) {
3342
-				$flux .= spip_file_get_contents($path);
3343
-			}
3344
-		}
3345
-	}
3331
+    $flux = "";
3332
+    foreach (is_array($files) ? $files : explode("|", $files) as $file) {
3333
+        if (!is_string($file)) {
3334
+            continue;
3335
+        }
3336
+        if ($script) {
3337
+            $file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : '';
3338
+        }
3339
+        if ($file) {
3340
+            $path = find_in_path($file);
3341
+            if ($path) {
3342
+                $flux .= spip_file_get_contents($path);
3343
+            }
3344
+        }
3345
+    }
3346 3346
 
3347
-	return $flux;
3347
+    return $flux;
3348 3348
 }
3349 3349
 
3350 3350
 
@@ -3366,55 +3366,55 @@  discard block
 block discarded – undo
3366 3366
  */
3367 3367
 function http_img_pack($img, $alt, $atts = '', $title = '', $options = array()) {
3368 3368
 
3369
-	$img_file = $img;
3370
-	if ($p = strpos($img_file, '?')) {
3371
-		$img_file = substr($img_file,0, $p);
3372
-	}
3373
-	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3374
-		$img_file = chemin_image($img);
3375
-	}
3376
-	else {
3377
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3378
-			// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3379
-			// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3380
-			if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3381
-			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3382
-			  and file_exists($variante_svg_generique)) {
3383
-				if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3384
-					$img_file = $variante_svg_size;
3385
-				}
3386
-				else {
3387
-					$img_file = $variante_svg_generique;
3388
-				}
3389
-			}
3390
-		}
3391
-	}
3392
-	if (stripos($atts, 'width') === false) {
3393
-		// utiliser directement l'info de taille presente dans le nom
3394
-		if ((!isset($options['utiliser_suffixe_size'])
3395
-				or $options['utiliser_suffixe_size'] == true
3396
-			  or strpos($img_file, '-xx.svg') !== false)
3397
-			and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3398
-					 or preg_match(',\?([0-9]+)px$,', $img, $regs))
3399
-		) {
3400
-			$largeur = $hauteur = intval($regs[1]);
3401
-		} else {
3402
-			$taille = taille_image($img_file);
3403
-			list($hauteur, $largeur) = $taille;
3404
-			if (!$hauteur or !$largeur) {
3405
-				return "";
3406
-			}
3407
-		}
3408
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3409
-	}
3410
-
3411
-	if (file_exists($img_file)) {
3412
-		$img_file = timestamp($img_file);
3413
-	}
3414
-	return "<img src='$img_file' alt='" . attribut_html($alt ? $alt : $title) . "'"
3415
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3416
-	. " " . ltrim($atts)
3417
-	. " />";
3369
+    $img_file = $img;
3370
+    if ($p = strpos($img_file, '?')) {
3371
+        $img_file = substr($img_file,0, $p);
3372
+    }
3373
+    if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3374
+        $img_file = chemin_image($img);
3375
+    }
3376
+    else {
3377
+        if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3378
+            // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3379
+            // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3380
+            if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3381
+              and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3382
+              and file_exists($variante_svg_generique)) {
3383
+                if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3384
+                    $img_file = $variante_svg_size;
3385
+                }
3386
+                else {
3387
+                    $img_file = $variante_svg_generique;
3388
+                }
3389
+            }
3390
+        }
3391
+    }
3392
+    if (stripos($atts, 'width') === false) {
3393
+        // utiliser directement l'info de taille presente dans le nom
3394
+        if ((!isset($options['utiliser_suffixe_size'])
3395
+                or $options['utiliser_suffixe_size'] == true
3396
+              or strpos($img_file, '-xx.svg') !== false)
3397
+            and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3398
+                     or preg_match(',\?([0-9]+)px$,', $img, $regs))
3399
+        ) {
3400
+            $largeur = $hauteur = intval($regs[1]);
3401
+        } else {
3402
+            $taille = taille_image($img_file);
3403
+            list($hauteur, $largeur) = $taille;
3404
+            if (!$hauteur or !$largeur) {
3405
+                return "";
3406
+            }
3407
+        }
3408
+        $atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3409
+    }
3410
+
3411
+    if (file_exists($img_file)) {
3412
+        $img_file = timestamp($img_file);
3413
+    }
3414
+    return "<img src='$img_file' alt='" . attribut_html($alt ? $alt : $title) . "'"
3415
+    . ($title ? ' title="' . attribut_html($title) . '"' : '')
3416
+    . " " . ltrim($atts)
3417
+    . " />";
3418 3418
 }
3419 3419
 
3420 3420
 /**
@@ -3426,13 +3426,13 @@  discard block
 block discarded – undo
3426 3426
  * @return string
3427 3427
  */
3428 3428
 function http_style_background($img, $att = '', $size=null) {
3429
-	if ($size and is_numeric($size)){
3430
-		$size = trim($size) . "px";
3431
-	}
3432
-	return " style='background" .
3433
-		($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3434
-		. ($size ? "background-size:{$size};" : '')
3435
-		. "'";
3429
+    if ($size and is_numeric($size)){
3430
+        $size = trim($size) . "px";
3431
+    }
3432
+    return " style='background" .
3433
+        ($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3434
+        . ($size ? "background-size:{$size};" : '')
3435
+        . "'";
3436 3436
 }
3437 3437
 
3438 3438
 /**
@@ -3448,17 +3448,17 @@  discard block
 block discarded – undo
3448 3448
  *     Code HTML de la balise IMG
3449 3449
  */
3450 3450
 function filtre_balise_img_dist($img, $alt = "", $class = "", $width=null) {
3451
-	$atts = $class ? " class='" . attribut_html($class) . "'" : '';
3452
-	// ecriture courte : on donne le width en 2e arg
3453
-	if (empty($width) and is_numeric($alt)) {
3454
-		$width = $alt;
3455
-		$alt = '';
3456
-	}
3457
-	if ($width) {
3458
-		$atts .= " width='{$width}'";
3459
-	}
3460
-	return http_img_pack($img, $alt, $atts, '',
3461
-		array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3451
+    $atts = $class ? " class='" . attribut_html($class) . "'" : '';
3452
+    // ecriture courte : on donne le width en 2e arg
3453
+    if (empty($width) and is_numeric($alt)) {
3454
+        $width = $alt;
3455
+        $alt = '';
3456
+    }
3457
+    if ($width) {
3458
+        $atts .= " width='{$width}'";
3459
+    }
3460
+    return http_img_pack($img, $alt, $atts, '',
3461
+        array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3462 3462
 }
3463 3463
 
3464 3464
 
@@ -3474,42 +3474,42 @@  discard block
 block discarded – undo
3474 3474
  * @return string
3475 3475
  */
3476 3476
 function filtre_balise_svg_dist($img, $alt = "", $class = "") {
3477
-	$img_file = $img;
3478
-	if ($p = strpos($img_file, '?')) {
3479
-		$img_file = substr($img_file,0, $p);
3480
-	}
3477
+    $img_file = $img;
3478
+    if ($p = strpos($img_file, '?')) {
3479
+        $img_file = substr($img_file,0, $p);
3480
+    }
3481 3481
 
3482
-	if (!$img_file or !$svg = file_get_contents($img_file)) {
3483
-		return '';
3484
-	}
3482
+    if (!$img_file or !$svg = file_get_contents($img_file)) {
3483
+        return '';
3484
+    }
3485 3485
 
3486
-	if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3487
-		return '';
3488
-	}
3489
-	$balise_svg = $match[0];
3490
-	$balise_svg_source = $balise_svg;
3486
+    if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3487
+        return '';
3488
+    }
3489
+    $balise_svg = $match[0];
3490
+    $balise_svg_source = $balise_svg;
3491 3491
 
3492
-	// entete XML à supprimer
3493
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3492
+    // entete XML à supprimer
3493
+    $svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3494 3494
 
3495
-	// IE est toujours mon ami
3496
-	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3497
-	if ($class) {
3498
-		$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3499
-	}
3500
-	if ($alt){
3501
-		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3502
-		$id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4);
3503
-		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3504
-		$title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3505
-		$balise_svg .= $title;
3506
-	}
3507
-	else {
3508
-		$balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3509
-	}
3510
-	$svg = str_replace($balise_svg_source, $balise_svg, $svg);
3495
+    // IE est toujours mon ami
3496
+    $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3497
+    if ($class) {
3498
+        $balise_svg = inserer_attribut($balise_svg, 'class', $class);
3499
+    }
3500
+    if ($alt){
3501
+        $balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3502
+        $id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4);
3503
+        $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3504
+        $title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3505
+        $balise_svg .= $title;
3506
+    }
3507
+    else {
3508
+        $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3509
+    }
3510
+    $svg = str_replace($balise_svg_source, $balise_svg, $svg);
3511 3511
 
3512
-	return $svg;
3512
+    return $svg;
3513 3513
 }
3514 3514
 
3515 3515
 
@@ -3532,17 +3532,17 @@  discard block
 block discarded – undo
3532 3532
  *     Code HTML résultant
3533 3533
  **/
3534 3534
 function filtre_foreach_dist($tableau, $modele = 'foreach') {
3535
-	$texte = '';
3536
-	if (is_array($tableau)) {
3537
-		foreach ($tableau as $k => $v) {
3538
-			$res = recuperer_fond('modeles/' . $modele,
3539
-				array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3540
-			);
3541
-			$texte .= $res;
3542
-		}
3543
-	}
3535
+    $texte = '';
3536
+    if (is_array($tableau)) {
3537
+        foreach ($tableau as $k => $v) {
3538
+            $res = recuperer_fond('modeles/' . $modele,
3539
+                array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3540
+            );
3541
+            $texte .= $res;
3542
+        }
3543
+    }
3544 3544
 
3545
-	return $texte;
3545
+    return $texte;
3546 3546
 }
3547 3547
 
3548 3548
 
@@ -3567,37 +3567,37 @@  discard block
 block discarded – undo
3567 3567
  *         - tout : retourne toutes les informations du plugin actif
3568 3568
  **/
3569 3569
 function filtre_info_plugin_dist($plugin, $type_info, $reload = false) {
3570
-	include_spip('inc/plugin');
3571
-	$plugin = strtoupper($plugin);
3572
-	$plugins_actifs = liste_plugin_actifs();
3573
-
3574
-	if (!$plugin) {
3575
-		return serialize(array_keys($plugins_actifs));
3576
-	} elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3577
-		return '';
3578
-	} elseif (($type_info == 'est_actif') and !$reload) {
3579
-		return $plugins_actifs[$plugin] ? 1 : 0;
3580
-	} elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3581
-		return $plugins_actifs[$plugin][$type_info];
3582
-	} else {
3583
-		$get_infos = charger_fonction('get_infos', 'plugins');
3584
-		// On prend en compte les extensions
3585
-		if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3586
-			$dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3587
-		} else {
3588
-			$dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3589
-		}
3590
-		if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3591
-			return '';
3592
-		}
3593
-		if ($type_info == 'tout') {
3594
-			return $infos;
3595
-		} elseif ($type_info == 'est_actif') {
3596
-			return $infos ? 1 : 0;
3597
-		} else {
3598
-			return strval($infos[$type_info]);
3599
-		}
3600
-	}
3570
+    include_spip('inc/plugin');
3571
+    $plugin = strtoupper($plugin);
3572
+    $plugins_actifs = liste_plugin_actifs();
3573
+
3574
+    if (!$plugin) {
3575
+        return serialize(array_keys($plugins_actifs));
3576
+    } elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3577
+        return '';
3578
+    } elseif (($type_info == 'est_actif') and !$reload) {
3579
+        return $plugins_actifs[$plugin] ? 1 : 0;
3580
+    } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3581
+        return $plugins_actifs[$plugin][$type_info];
3582
+    } else {
3583
+        $get_infos = charger_fonction('get_infos', 'plugins');
3584
+        // On prend en compte les extensions
3585
+        if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3586
+            $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3587
+        } else {
3588
+            $dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3589
+        }
3590
+        if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3591
+            return '';
3592
+        }
3593
+        if ($type_info == 'tout') {
3594
+            return $infos;
3595
+        } elseif ($type_info == 'est_actif') {
3596
+            return $infos ? 1 : 0;
3597
+        } else {
3598
+            return strval($infos[$type_info]);
3599
+        }
3600
+    }
3601 3601
 }
3602 3602
 
3603 3603
 
@@ -3624,9 +3624,9 @@  discard block
 block discarded – undo
3624 3624
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3625 3625
  */
3626 3626
 function puce_changement_statut($id_objet, $statut, $id_rubrique, $type, $ajax = false) {
3627
-	$puce_statut = charger_fonction('puce_statut', 'inc');
3627
+    $puce_statut = charger_fonction('puce_statut', 'inc');
3628 3628
 
3629
-	return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3629
+    return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3630 3630
 }
3631 3631
 
3632 3632
 
@@ -3656,13 +3656,13 @@  discard block
 block discarded – undo
3656 3656
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3657 3657
  */
3658 3658
 function filtre_puce_statut_dist($statut, $objet, $id_objet = 0, $id_parent = 0) {
3659
-	static $puce_statut = null;
3660
-	if (!$puce_statut) {
3661
-		$puce_statut = charger_fonction('puce_statut', 'inc');
3662
-	}
3659
+    static $puce_statut = null;
3660
+    if (!$puce_statut) {
3661
+        $puce_statut = charger_fonction('puce_statut', 'inc');
3662
+    }
3663 3663
 
3664
-	return $puce_statut($id_objet, $statut, $id_parent, $objet, false,
3665
-		objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false);
3664
+    return $puce_statut($id_objet, $statut, $id_parent, $objet, false,
3665
+        objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false);
3666 3666
 }
3667 3667
 
3668 3668
 
@@ -3689,100 +3689,100 @@  discard block
 block discarded – undo
3689 3689
  *   hash du contexte
3690 3690
  */
3691 3691
 function encoder_contexte_ajax($c, $form = '', $emboite = null, $ajaxid = '') {
3692
-	if (is_string($c)
3693
-		and @unserialize($c) !== false
3694
-	) {
3695
-		$c = unserialize($c);
3696
-	}
3697
-
3698
-	// supprimer les parametres debut_x
3699
-	// pour que la pagination ajax ne soit pas plantee
3700
-	// si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3701
-	// le debut_x=0 n'existe pas, et on resterait sur 1
3702
-	if (is_array($c)) {
3703
-		foreach ($c as $k => $v) {
3704
-			if (strpos($k, 'debut_') === 0) {
3705
-				unset($c[$k]);
3706
-			}
3707
-		}
3708
-	}
3709
-
3710
-	if (!function_exists('calculer_cle_action')) {
3711
-		include_spip("inc/securiser_action");
3712
-	}
3713
-
3714
-	$c = serialize($c);
3715
-	$cle = calculer_cle_action($form . $c);
3716
-	$c = "$cle:$c";
3717
-
3718
-	// on ne stocke pas les contextes dans des fichiers en cache
3719
-	// par defaut, sauf si cette configuration a été forcée
3720
-	// OU que la longueur de l’argument géneré est plus long
3721
-	// que ce qui est toléré.
3722
-	$cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
3723
-	if (!$cache_contextes_ajax) {
3724
-		$env = $c;
3725
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3726
-			$env = gzdeflate($env);
3727
-			// https://core.spip.net/issues/2667 | https://bugs.php.net/bug.php?id=61287
3728
-			if ((PHP_VERSION_ID == 50400) and !@gzinflate($env)) {
3729
-				$cache_contextes_ajax = true;
3730
-				spip_log("Contextes AJAX forces en fichiers ! Erreur PHP 5.4.0", _LOG_AVERTISSEMENT);
3731
-			}
3732
-		}
3733
-		$env = _xor($env);
3734
-		$env = base64_encode($env);
3735
-		$len = strlen($env);
3736
-		// Si l’url est trop longue pour le navigateur
3737
-		$max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
3738
-		if ($len > $max_len) {
3739
-			$cache_contextes_ajax = true;
3740
-			spip_log("Contextes AJAX forces en fichiers !"
3741
-				. " Cela arrive lorsque la valeur du contexte" 
3742
-				. " depasse la longueur maximale autorisee ($max_len). Ici : $len."
3743
-				, _LOG_AVERTISSEMENT);
3744
-		}
3745
-		// Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
3746
-		elseif (
3747
-			$max_len = @ini_get('suhosin.get.max_value_length')
3748
-			and $max_len < $len
3749
-		) {
3750
-			$cache_contextes_ajax = true;
3751
-			spip_log("Contextes AJAX forces en fichiers !"
3752
-				. " Cela arrive lorsque la valeur du contexte"
3753
-				. " depasse la longueur maximale autorisee par Suhosin"
3754
-				. " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3755
-				. " Vous devriez modifier les parametres de Suhosin"
3756
-				. " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT);
3757
-		} 
3758
-
3759
-	}
3760
-
3761
-	if ($cache_contextes_ajax) {
3762
-		$dir = sous_repertoire(_DIR_CACHE, 'contextes');
3763
-		// stocker les contextes sur disque et ne passer qu'un hash dans l'url
3764
-		$md5 = md5($c);
3765
-		ecrire_fichier("$dir/c$md5", $c);
3766
-		$env = $md5;
3767
-	}
3768
-
3769
-	if ($emboite === null) {
3770
-		return $env;
3771
-	}
3772
-	if (!trim($emboite)) {
3773
-		return "";
3774
-	}
3775
-	// toujours encoder l'url source dans le bloc ajax
3776
-	$r = self();
3777
-	$r = ' data-origin="' . $r . '"';
3778
-	$class = 'ajaxbloc';
3779
-	if ($ajaxid and is_string($ajaxid)) {
3780
-		// ajaxid est normalement conforme a un nom de classe css
3781
-		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3782
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3783
-	}
3784
-
3785
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3692
+    if (is_string($c)
3693
+        and @unserialize($c) !== false
3694
+    ) {
3695
+        $c = unserialize($c);
3696
+    }
3697
+
3698
+    // supprimer les parametres debut_x
3699
+    // pour que la pagination ajax ne soit pas plantee
3700
+    // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3701
+    // le debut_x=0 n'existe pas, et on resterait sur 1
3702
+    if (is_array($c)) {
3703
+        foreach ($c as $k => $v) {
3704
+            if (strpos($k, 'debut_') === 0) {
3705
+                unset($c[$k]);
3706
+            }
3707
+        }
3708
+    }
3709
+
3710
+    if (!function_exists('calculer_cle_action')) {
3711
+        include_spip("inc/securiser_action");
3712
+    }
3713
+
3714
+    $c = serialize($c);
3715
+    $cle = calculer_cle_action($form . $c);
3716
+    $c = "$cle:$c";
3717
+
3718
+    // on ne stocke pas les contextes dans des fichiers en cache
3719
+    // par defaut, sauf si cette configuration a été forcée
3720
+    // OU que la longueur de l’argument géneré est plus long
3721
+    // que ce qui est toléré.
3722
+    $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
3723
+    if (!$cache_contextes_ajax) {
3724
+        $env = $c;
3725
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3726
+            $env = gzdeflate($env);
3727
+            // https://core.spip.net/issues/2667 | https://bugs.php.net/bug.php?id=61287
3728
+            if ((PHP_VERSION_ID == 50400) and !@gzinflate($env)) {
3729
+                $cache_contextes_ajax = true;
3730
+                spip_log("Contextes AJAX forces en fichiers ! Erreur PHP 5.4.0", _LOG_AVERTISSEMENT);
3731
+            }
3732
+        }
3733
+        $env = _xor($env);
3734
+        $env = base64_encode($env);
3735
+        $len = strlen($env);
3736
+        // Si l’url est trop longue pour le navigateur
3737
+        $max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
3738
+        if ($len > $max_len) {
3739
+            $cache_contextes_ajax = true;
3740
+            spip_log("Contextes AJAX forces en fichiers !"
3741
+                . " Cela arrive lorsque la valeur du contexte" 
3742
+                . " depasse la longueur maximale autorisee ($max_len). Ici : $len."
3743
+                , _LOG_AVERTISSEMENT);
3744
+        }
3745
+        // Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
3746
+        elseif (
3747
+            $max_len = @ini_get('suhosin.get.max_value_length')
3748
+            and $max_len < $len
3749
+        ) {
3750
+            $cache_contextes_ajax = true;
3751
+            spip_log("Contextes AJAX forces en fichiers !"
3752
+                . " Cela arrive lorsque la valeur du contexte"
3753
+                . " depasse la longueur maximale autorisee par Suhosin"
3754
+                . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3755
+                . " Vous devriez modifier les parametres de Suhosin"
3756
+                . " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT);
3757
+        } 
3758
+
3759
+    }
3760
+
3761
+    if ($cache_contextes_ajax) {
3762
+        $dir = sous_repertoire(_DIR_CACHE, 'contextes');
3763
+        // stocker les contextes sur disque et ne passer qu'un hash dans l'url
3764
+        $md5 = md5($c);
3765
+        ecrire_fichier("$dir/c$md5", $c);
3766
+        $env = $md5;
3767
+    }
3768
+
3769
+    if ($emboite === null) {
3770
+        return $env;
3771
+    }
3772
+    if (!trim($emboite)) {
3773
+        return "";
3774
+    }
3775
+    // toujours encoder l'url source dans le bloc ajax
3776
+    $r = self();
3777
+    $r = ' data-origin="' . $r . '"';
3778
+    $class = 'ajaxbloc';
3779
+    if ($ajaxid and is_string($ajaxid)) {
3780
+        // ajaxid est normalement conforme a un nom de classe css
3781
+        // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3782
+        $class .= ' ajax-id-' . entites_html($ajaxid);
3783
+    }
3784
+
3785
+    return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3786 3786
 }
3787 3787
 
3788 3788
 /**
@@ -3802,36 +3802,36 @@  discard block
 block discarded – undo
3802 3802
  *   - false : erreur de décodage
3803 3803
  */
3804 3804
 function decoder_contexte_ajax($c, $form = '') {
3805
-	if (!function_exists('calculer_cle_action')) {
3806
-		include_spip("inc/securiser_action");
3807
-	}
3808
-	if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
3809
-		and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
3810
-		and lire_fichier("$dir/c$c", $contexte)
3811
-	) {
3812
-		$c = $contexte;
3813
-	} else {
3814
-		$c = @base64_decode($c);
3815
-		$c = _xor($c);
3816
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3817
-			$c = @gzinflate($c);
3818
-		}
3819
-	}
3820
-
3821
-	// extraire la signature en debut de contexte
3822
-	// et la verifier avant de deserializer
3823
-	// format : signature:donneesserializees
3824
-	if ($p = strpos($c,":")){
3825
-		$cle = substr($c,0,$p);
3826
-		$c = substr($c,$p+1);
3827
-
3828
-		if ($cle == calculer_cle_action($form . $c)) {
3829
-			$env = @unserialize($c);
3830
-			return $env;
3831
-		}
3832
-	}
3833
-
3834
-	return false;
3805
+    if (!function_exists('calculer_cle_action')) {
3806
+        include_spip("inc/securiser_action");
3807
+    }
3808
+    if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
3809
+        and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
3810
+        and lire_fichier("$dir/c$c", $contexte)
3811
+    ) {
3812
+        $c = $contexte;
3813
+    } else {
3814
+        $c = @base64_decode($c);
3815
+        $c = _xor($c);
3816
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3817
+            $c = @gzinflate($c);
3818
+        }
3819
+    }
3820
+
3821
+    // extraire la signature en debut de contexte
3822
+    // et la verifier avant de deserializer
3823
+    // format : signature:donneesserializees
3824
+    if ($p = strpos($c,":")){
3825
+        $cle = substr($c,0,$p);
3826
+        $c = substr($c,$p+1);
3827
+
3828
+        if ($cle == calculer_cle_action($form . $c)) {
3829
+            $env = @unserialize($c);
3830
+            return $env;
3831
+        }
3832
+    }
3833
+
3834
+    return false;
3835 3835
 }
3836 3836
 
3837 3837
 
@@ -3849,20 +3849,20 @@  discard block
 block discarded – undo
3849 3849
  *    Message décrypté ou encrypté
3850 3850
  **/
3851 3851
 function _xor($message, $key = null) {
3852
-	if (is_null($key)) {
3853
-		if (!function_exists('calculer_cle_action')) {
3854
-			include_spip("inc/securiser_action");
3855
-		}
3856
-		$key = pack("H*", calculer_cle_action('_xor'));
3857
-	}
3852
+    if (is_null($key)) {
3853
+        if (!function_exists('calculer_cle_action')) {
3854
+            include_spip("inc/securiser_action");
3855
+        }
3856
+        $key = pack("H*", calculer_cle_action('_xor'));
3857
+    }
3858 3858
 
3859
-	$keylen = strlen($key);
3860
-	$messagelen = strlen($message);
3861
-	for ($i = 0; $i < $messagelen; $i++) {
3862
-		$message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
3863
-	}
3859
+    $keylen = strlen($key);
3860
+    $messagelen = strlen($message);
3861
+    for ($i = 0; $i < $messagelen; $i++) {
3862
+        $message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
3863
+    }
3864 3864
 
3865
-	return $message;
3865
+    return $message;
3866 3866
 }
3867 3867
 
3868 3868
 /**
@@ -3920,22 +3920,22 @@  discard block
 block discarded – undo
3920 3920
  *   Code HTML
3921 3921
  */
3922 3922
 function lien_ou_expose($url, $libelle = null, $on = false, $class = "", $title = "", $rel = "", $evt = '') {
3923
-	if ($on) {
3924
-		$bal = "strong";
3925
-		$att = "class='on'";
3926
-	} else {
3927
-		$bal = 'a';
3928
-		$att = "href='$url'"
3929
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
3930
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
3931
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3932
-			. $evt;
3933
-	}
3934
-	if ($libelle === null) {
3935
-		$libelle = $url;
3936
-	}
3923
+    if ($on) {
3924
+        $bal = "strong";
3925
+        $att = "class='on'";
3926
+    } else {
3927
+        $bal = 'a';
3928
+        $att = "href='$url'"
3929
+            . ($title ? " title='" . attribut_html($title) . "'" : '')
3930
+            . ($class ? " class='" . attribut_html($class) . "'" : '')
3931
+            . ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3932
+            . $evt;
3933
+    }
3934
+    if ($libelle === null) {
3935
+        $libelle = $url;
3936
+    }
3937 3937
 
3938
-	return "<$bal $att>$libelle</$bal>";
3938
+    return "<$bal $att>$libelle</$bal>";
3939 3939
 }
3940 3940
 
3941 3941
 
@@ -3952,18 +3952,18 @@  discard block
 block discarded – undo
3952 3952
  * @return string : la chaine de langue finale en utilisant la fonction _T()
3953 3953
  */
3954 3954
 function singulier_ou_pluriel($nb, $chaine_un, $chaine_plusieurs, $var = 'nb', $vars = array()) {
3955
-	if (!is_numeric($nb) or $nb == 0) {
3956
-		return "";
3957
-	}
3958
-	if (!is_array($vars)) {
3959
-		return "";
3960
-	}
3961
-	$vars[$var] = $nb;
3962
-	if ($nb >= 2) {
3963
-		return _T($chaine_plusieurs, $vars);
3964
-	} else {
3965
-		return _T($chaine_un, $vars);
3966
-	}
3955
+    if (!is_numeric($nb) or $nb == 0) {
3956
+        return "";
3957
+    }
3958
+    if (!is_array($vars)) {
3959
+        return "";
3960
+    }
3961
+    $vars[$var] = $nb;
3962
+    if ($nb >= 2) {
3963
+        return _T($chaine_plusieurs, $vars);
3964
+    } else {
3965
+        return _T($chaine_un, $vars);
3966
+    }
3967 3967
 }
3968 3968
 
3969 3969
 
@@ -3988,56 +3988,56 @@  discard block
 block discarded – undo
3988 3988
  * @return string
3989 3989
  */
3990 3990
 function prepare_icone_base($type, $lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
3991
-	if (in_array($fonction, array("del", "supprimer.gif"))) {
3992
-		$class .= ' danger';
3993
-	} elseif ($fonction == "rien.gif") {
3994
-		$fonction = "";
3995
-	} elseif ($fonction == "delsafe") {
3996
-		$fonction = "del";
3997
-	}
3998
-
3999
-	$fond_origine = $fond;
4000
-	// remappage des icone : article-24.png+new => article-new-24.png
4001
-	if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4002
-		list($fond, $fonction) = $icone_renommer($fond, $fonction);
4003
-	}
4004
-
4005
-	// ajouter le type d'objet dans la class de l'icone
4006
-	$class .= " " . substr(basename($fond), 0, -4);
4007
-
4008
-	$alt = attribut_html($texte);
4009
-	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4010
-
4011
-	$ajax = "";
4012
-	if (strpos($class, "ajax") !== false) {
4013
-		$ajax = "ajax";
4014
-		if (strpos($class, "preload") !== false) {
4015
-			$ajax .= " preload";
4016
-		}
4017
-		if (strpos($class, "nocache") !== false) {
4018
-			$ajax .= " nocache";
4019
-		}
4020
-		$ajax = " class='$ajax'";
4021
-	}
4022
-
4023
-	$size = 24;
4024
-	if (preg_match("/-([0-9]{1,3})[.](gif|png|svg)$/i", $fond, $match)
4025
-	  or preg_match("/-([0-9]{1,3})([.](gif|png|svg))?$/i", $fond_origine, $match)) {
4026
-		$size = $match[1];
4027
-	}
4028
-
4029
-	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4030
-	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
4031
-
4032
-	if ($type == 'lien') {
4033
-		return "<span class='icone s$size $class'>"
4034
-		. "<a href='$lien'$title$ajax$javascript>"
4035
-		. $icone
4036
-		. "<b>$texte</b>"
4037
-		. "</a></span>\n";
4038
-	} else {
4039
-		return bouton_action("$icone<b>$texte</b>", $lien, "icone s$size $class", $javascript, $alt);
4040
-	}
3991
+    if (in_array($fonction, array("del", "supprimer.gif"))) {
3992
+        $class .= ' danger';
3993
+    } elseif ($fonction == "rien.gif") {
3994
+        $fonction = "";
3995
+    } elseif ($fonction == "delsafe") {
3996
+        $fonction = "del";
3997
+    }
3998
+
3999
+    $fond_origine = $fond;
4000
+    // remappage des icone : article-24.png+new => article-new-24.png
4001
+    if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4002
+        list($fond, $fonction) = $icone_renommer($fond, $fonction);
4003
+    }
4004
+
4005
+    // ajouter le type d'objet dans la class de l'icone
4006
+    $class .= " " . substr(basename($fond), 0, -4);
4007
+
4008
+    $alt = attribut_html($texte);
4009
+    $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4010
+
4011
+    $ajax = "";
4012
+    if (strpos($class, "ajax") !== false) {
4013
+        $ajax = "ajax";
4014
+        if (strpos($class, "preload") !== false) {
4015
+            $ajax .= " preload";
4016
+        }
4017
+        if (strpos($class, "nocache") !== false) {
4018
+            $ajax .= " nocache";
4019
+        }
4020
+        $ajax = " class='$ajax'";
4021
+    }
4022
+
4023
+    $size = 24;
4024
+    if (preg_match("/-([0-9]{1,3})[.](gif|png|svg)$/i", $fond, $match)
4025
+      or preg_match("/-([0-9]{1,3})([.](gif|png|svg))?$/i", $fond_origine, $match)) {
4026
+        $size = $match[1];
4027
+    }
4028
+
4029
+    $icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4030
+    $icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
4031
+
4032
+    if ($type == 'lien') {
4033
+        return "<span class='icone s$size $class'>"
4034
+        . "<a href='$lien'$title$ajax$javascript>"
4035
+        . $icone
4036
+        . "<b>$texte</b>"
4037
+        . "</a></span>\n";
4038
+    } else {
4039
+        return bouton_action("$icone<b>$texte</b>", $lien, "icone s$size $class", $javascript, $alt);
4040
+    }
4041 4041
 }
4042 4042
 
4043 4043
 /**
@@ -4061,7 +4061,7 @@  discard block
 block discarded – undo
4061 4061
  *     Code HTML du lien
4062 4062
  **/
4063 4063
 function icone_base($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4064
-	return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4064
+    return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4065 4065
 }
4066 4066
 
4067 4067
 /**
@@ -4096,7 +4096,7 @@  discard block
 block discarded – undo
4096 4096
  *     Code HTML du lien
4097 4097
  **/
4098 4098
 function filtre_icone_verticale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4099
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4099
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4100 4100
 }
4101 4101
 
4102 4102
 /**
@@ -4141,7 +4141,7 @@  discard block
 block discarded – undo
4141 4141
  *     Code HTML du lien
4142 4142
  **/
4143 4143
 function filtre_icone_horizontale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4144
-	return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4144
+    return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4145 4145
 }
4146 4146
 
4147 4147
 /**
@@ -4172,7 +4172,7 @@  discard block
 block discarded – undo
4172 4172
  *     Code HTML du lien
4173 4173
  **/
4174 4174
 function filtre_bouton_action_horizontal_dist($lien, $texte, $fond, $fonction = "", $class = "", $confirm = "") {
4175
-	return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, "horizontale $class", $confirm);
4175
+    return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, "horizontale $class", $confirm);
4176 4176
 }
4177 4177
 
4178 4178
 /**
@@ -4202,7 +4202,7 @@  discard block
 block discarded – undo
4202 4202
  *     Code HTML du lien
4203 4203
  */
4204 4204
 function filtre_icone_dist($lien, $texte, $fond, $align = "", $fonction = "", $class = "", $javascript = "") {
4205
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4205
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4206 4206
 }
4207 4207
 
4208 4208
 
@@ -4250,26 +4250,26 @@  discard block
 block discarded – undo
4250 4250
  * @return string Code CSS
4251 4251
  */
4252 4252
 function bando_images_background() {
4253
-	include_spip('inc/bandeau');
4254
-	// recuperer tous les boutons et leurs images
4255
-	$boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4253
+    include_spip('inc/bandeau');
4254
+    // recuperer tous les boutons et leurs images
4255
+    $boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4256 4256
 
4257
-	$res = "";
4258
-	foreach ($boutons as $page => $detail) {
4259
-		if ($detail->icone and strlen(trim($detail->icone))) {
4260
-			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4261
-		}
4262
-		$selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4263
-		if (is_array($detail->sousmenu)) {
4264
-			foreach ($detail->sousmenu as $souspage => $sousdetail) {
4265
-				if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4266
-					$res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4267
-				}
4268
-			}
4269
-		}
4270
-	}
4257
+    $res = "";
4258
+    foreach ($boutons as $page => $detail) {
4259
+        if ($detail->icone and strlen(trim($detail->icone))) {
4260
+            $res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4261
+        }
4262
+        $selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4263
+        if (is_array($detail->sousmenu)) {
4264
+            foreach ($detail->sousmenu as $souspage => $sousdetail) {
4265
+                if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4266
+                    $res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4267
+                }
4268
+            }
4269
+        }
4270
+    }
4271 4271
 
4272
-	return $res;
4272
+    return $res;
4273 4273
 }
4274 4274
 
4275 4275
 /**
@@ -4288,19 +4288,19 @@  discard block
 block discarded – undo
4288 4288
  * @return string
4289 4289
  */
4290 4290
 function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") {
4291
-	if ($confirm) {
4292
-		$confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4293
-		if ($callback) {
4294
-			$callback = "$confirm?($callback):false";
4295
-		} else {
4296
-			$callback = $confirm;
4297
-		}
4298
-	}
4299
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4300
-	$title = $title ? " title='$title'" : "";
4291
+    if ($confirm) {
4292
+        $confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4293
+        if ($callback) {
4294
+            $callback = "$confirm?($callback):false";
4295
+        } else {
4296
+            $callback = $confirm;
4297
+        }
4298
+    }
4299
+    $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4300
+    $title = $title ? " title='$title'" : "";
4301 4301
 
4302
-	return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4303
-	. "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4302
+    return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4303
+    . "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4304 4304
 }
4305 4305
 
4306 4306
 /**
@@ -4321,78 +4321,78 @@  discard block
 block discarded – undo
4321 4321
  * @return string
4322 4322
  */
4323 4323
 function generer_info_entite($id_objet, $type_objet, $info, $etoile = "") {
4324
-	static $trouver_table = null;
4325
-	static $objets;
4326
-
4327
-	// On verifie qu'on a tout ce qu'il faut
4328
-	$id_objet = intval($id_objet);
4329
-	if (!($id_objet and $type_objet and $info)) {
4330
-		return '';
4331
-	}
4332
-
4333
-	// si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4334
-	if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4335
-		return '';
4336
-	}
4337
-
4338
-	// Si on demande l'url, on retourne direct la fonction
4339
-	if ($info == 'url') {
4340
-		return generer_url_entite($id_objet, $type_objet);
4341
-	}
4342
-
4343
-	// Sinon on va tout chercher dans la table et on garde en memoire
4344
-	$demande_titre = ($info == 'titre');
4345
-
4346
-	// On ne fait la requete que si on a pas deja l'objet ou si on demande le titre mais qu'on ne l'a pas encore
4347
-	if (!isset($objets[$type_objet][$id_objet])
4348
-		or
4349
-		($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4350
-	) {
4351
-		if (!$trouver_table) {
4352
-			$trouver_table = charger_fonction('trouver_table', 'base');
4353
-		}
4354
-		$desc = $trouver_table(table_objet_sql($type_objet));
4355
-		if (!$desc) {
4356
-			return $objets[$type_objet] = false;
4357
-		}
4358
-
4359
-		// Si on demande le titre, on le gere en interne
4360
-		$champ_titre = "";
4361
-		if ($demande_titre) {
4362
-			// si pas de titre declare mais champ titre, il sera peuple par le select *
4363
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4364
-		}
4365
-		include_spip('base/abstract_sql');
4366
-		include_spip('base/connect_sql');
4367
-		$objets[$type_objet][$id_objet] = sql_fetsel(
4368
-			'*' . $champ_titre,
4369
-			$desc['table_sql'],
4370
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4371
-		);
4372
-	}
4373
-
4374
-	// Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee
4375
-	if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) {
4376
-		$info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]);
4377
-	} // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee
4378
-	else {
4379
-		if ($generer = charger_fonction("generer_${info}_entite", '', true)) {
4380
-			$info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]);
4381
-		} // Sinon on prend directement le champ SQL tel quel
4382
-		else {
4383
-			$info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : '');
4384
-		}
4385
-	}
4386
-
4387
-	// On va ensuite appliquer les traitements automatiques si besoin
4388
-	if (!$etoile) {
4389
-		// FIXME: on fournit un ENV minimum avec id et type et connect=''
4390
-		// mais ce fonctionnement est a ameliorer !
4391
-		$info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet),
4392
-			array('id_objet' => $id_objet, 'objet' => $type_objet, ''));
4393
-	}
4394
-
4395
-	return $info_generee;
4324
+    static $trouver_table = null;
4325
+    static $objets;
4326
+
4327
+    // On verifie qu'on a tout ce qu'il faut
4328
+    $id_objet = intval($id_objet);
4329
+    if (!($id_objet and $type_objet and $info)) {
4330
+        return '';
4331
+    }
4332
+
4333
+    // si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4334
+    if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4335
+        return '';
4336
+    }
4337
+
4338
+    // Si on demande l'url, on retourne direct la fonction
4339
+    if ($info == 'url') {
4340
+        return generer_url_entite($id_objet, $type_objet);
4341
+    }
4342
+
4343
+    // Sinon on va tout chercher dans la table et on garde en memoire
4344
+    $demande_titre = ($info == 'titre');
4345
+
4346
+    // On ne fait la requete que si on a pas deja l'objet ou si on demande le titre mais qu'on ne l'a pas encore
4347
+    if (!isset($objets[$type_objet][$id_objet])
4348
+        or
4349
+        ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4350
+    ) {
4351
+        if (!$trouver_table) {
4352
+            $trouver_table = charger_fonction('trouver_table', 'base');
4353
+        }
4354
+        $desc = $trouver_table(table_objet_sql($type_objet));
4355
+        if (!$desc) {
4356
+            return $objets[$type_objet] = false;
4357
+        }
4358
+
4359
+        // Si on demande le titre, on le gere en interne
4360
+        $champ_titre = "";
4361
+        if ($demande_titre) {
4362
+            // si pas de titre declare mais champ titre, il sera peuple par le select *
4363
+            $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4364
+        }
4365
+        include_spip('base/abstract_sql');
4366
+        include_spip('base/connect_sql');
4367
+        $objets[$type_objet][$id_objet] = sql_fetsel(
4368
+            '*' . $champ_titre,
4369
+            $desc['table_sql'],
4370
+            id_table_objet($type_objet) . ' = ' . intval($id_objet)
4371
+        );
4372
+    }
4373
+
4374
+    // Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee
4375
+    if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) {
4376
+        $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]);
4377
+    } // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee
4378
+    else {
4379
+        if ($generer = charger_fonction("generer_${info}_entite", '', true)) {
4380
+            $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]);
4381
+        } // Sinon on prend directement le champ SQL tel quel
4382
+        else {
4383
+            $info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : '');
4384
+        }
4385
+    }
4386
+
4387
+    // On va ensuite appliquer les traitements automatiques si besoin
4388
+    if (!$etoile) {
4389
+        // FIXME: on fournit un ENV minimum avec id et type et connect=''
4390
+        // mais ce fonctionnement est a ameliorer !
4391
+        $info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet),
4392
+            array('id_objet' => $id_objet, 'objet' => $type_objet, ''));
4393
+    }
4394
+
4395
+    return $info_generee;
4396 4396
 }
4397 4397
 
4398 4398
 /**
@@ -4406,44 +4406,44 @@  discard block
 block discarded – undo
4406 4406
  * @return string
4407 4407
  */
4408 4408
 function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = array(), $connect = '') {
4409
-	if (!$champ) {
4410
-		return $texte;
4411
-	}
4409
+    if (!$champ) {
4410
+        return $texte;
4411
+    }
4412 4412
 	
4413
-	// On charge toujours les filtres de texte car la majorité des traitements les utilisent
4414
-	// et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4415
-	include_spip('inc/texte');
4413
+    // On charge toujours les filtres de texte car la majorité des traitements les utilisent
4414
+    // et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4415
+    include_spip('inc/texte');
4416 4416
 	
4417
-	$champ = strtoupper($champ);
4418
-	$traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false;
4419
-	if (!$traitements or !is_array($traitements)) {
4420
-		return $texte;
4421
-	}
4417
+    $champ = strtoupper($champ);
4418
+    $traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false;
4419
+    if (!$traitements or !is_array($traitements)) {
4420
+        return $texte;
4421
+    }
4422 4422
 
4423
-	$traitement = '';
4424
-	if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4425
-		// necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4426
-		$table_objet = table_objet($table_objet);
4427
-		if (isset($traitements[$table_objet])) {
4428
-			$traitement = $traitements[$table_objet];
4429
-		}
4430
-	}
4431
-	if (!$traitement and isset($traitements[0])) {
4432
-		$traitement = $traitements[0];
4433
-	}
4434
-	// (sinon prendre le premier de la liste par defaut ?)
4423
+    $traitement = '';
4424
+    if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4425
+        // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4426
+        $table_objet = table_objet($table_objet);
4427
+        if (isset($traitements[$table_objet])) {
4428
+            $traitement = $traitements[$table_objet];
4429
+        }
4430
+    }
4431
+    if (!$traitement and isset($traitements[0])) {
4432
+        $traitement = $traitements[0];
4433
+    }
4434
+    // (sinon prendre le premier de la liste par defaut ?)
4435 4435
 
4436
-	if (!$traitement) {
4437
-		return $texte;
4438
-	}
4436
+    if (!$traitement) {
4437
+        return $texte;
4438
+    }
4439 4439
 
4440
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4440
+    $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4441 4441
 
4442
-	// Fournir $connect et $Pile[0] au traitement si besoin
4443
-	$Pile = array(0 => $env);
4444
-	eval("\$texte = $traitement;");
4442
+    // Fournir $connect et $Pile[0] au traitement si besoin
4443
+    $Pile = array(0 => $env);
4444
+    eval("\$texte = $traitement;");
4445 4445
 
4446
-	return $texte;
4446
+    return $texte;
4447 4447
 }
4448 4448
 
4449 4449
 
@@ -4457,21 +4457,21 @@  discard block
 block discarded – undo
4457 4457
  * @return string
4458 4458
  */
4459 4459
 function generer_lien_entite($id_objet, $objet, $longueur = 80, $connect = null) {
4460
-	include_spip('inc/liens');
4461
-	$titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4462
-	// lorsque l'objet n'est plus declare (plugin desactive par exemple)
4463
-	// le raccourcis n'est plus valide
4464
-	$titre = isset($titre['titre']) ? typo($titre['titre']) : '';
4465
-	// on essaye avec generer_info_entite ?
4466
-	if (!strlen($titre) and !$connect) {
4467
-		$titre = generer_info_entite($id_objet, $objet, 'titre');
4468
-	}
4469
-	if (!strlen($titre)) {
4470
-		$titre = _T('info_sans_titre');
4471
-	}
4472
-	$url = generer_url_entite($id_objet, $objet, '', '', $connect);
4460
+    include_spip('inc/liens');
4461
+    $titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4462
+    // lorsque l'objet n'est plus declare (plugin desactive par exemple)
4463
+    // le raccourcis n'est plus valide
4464
+    $titre = isset($titre['titre']) ? typo($titre['titre']) : '';
4465
+    // on essaye avec generer_info_entite ?
4466
+    if (!strlen($titre) and !$connect) {
4467
+        $titre = generer_info_entite($id_objet, $objet, 'titre');
4468
+    }
4469
+    if (!strlen($titre)) {
4470
+        $titre = _T('info_sans_titre');
4471
+    }
4472
+    $url = generer_url_entite($id_objet, $objet, '', '', $connect);
4473 4473
 
4474
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4474
+    return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4475 4475
 }
4476 4476
 
4477 4477
 
@@ -4488,15 +4488,15 @@  discard block
 block discarded – undo
4488 4488
  * @return string
4489 4489
  */
4490 4490
 function wrap($texte, $wrap) {
4491
-	$balises = extraire_balises($wrap);
4492
-	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4493
-		$texte = $wrap . $texte;
4494
-		$regs = array_reverse($regs[1]);
4495
-		$wrap = "</" . implode("></", $regs) . ">";
4496
-		$texte = $texte . $wrap;
4497
-	}
4491
+    $balises = extraire_balises($wrap);
4492
+    if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4493
+        $texte = $wrap . $texte;
4494
+        $regs = array_reverse($regs[1]);
4495
+        $wrap = "</" . implode("></", $regs) . ">";
4496
+        $texte = $texte . $wrap;
4497
+    }
4498 4498
 
4499
-	return $texte;
4499
+    return $texte;
4500 4500
 }
4501 4501
 
4502 4502
 
@@ -4516,43 +4516,43 @@  discard block
 block discarded – undo
4516 4516
  * @return array|mixed|string
4517 4517
  */
4518 4518
 function filtre_print_dist($u, $join = "<br />", $indent = 0) {
4519
-	if (is_string($u)) {
4520
-		$u = typo($u);
4519
+    if (is_string($u)) {
4520
+        $u = typo($u);
4521 4521
 
4522
-		return $u;
4523
-	}
4522
+        return $u;
4523
+    }
4524 4524
 
4525
-	// caster $u en array si besoin
4526
-	if (is_object($u)) {
4527
-		$u = (array)$u;
4528
-	}
4525
+    // caster $u en array si besoin
4526
+    if (is_object($u)) {
4527
+        $u = (array)$u;
4528
+    }
4529 4529
 
4530
-	if (is_array($u)) {
4531
-		$out = "";
4532
-		// toutes les cles sont numeriques ?
4533
-		// et aucun enfant n'est un tableau
4534
-		// liste simple separee par des virgules
4535
-		$numeric_keys = array_map('is_numeric', array_keys($u));
4536
-		$array_values = array_map('is_array', $u);
4537
-		$object_values = array_map('is_object', $u);
4538
-		if (array_sum($numeric_keys) == count($numeric_keys)
4539
-			and !array_sum($array_values)
4540
-			and !array_sum($object_values)
4541
-		) {
4542
-			return join(", ", array_map('filtre_print_dist', $u));
4543
-		}
4530
+    if (is_array($u)) {
4531
+        $out = "";
4532
+        // toutes les cles sont numeriques ?
4533
+        // et aucun enfant n'est un tableau
4534
+        // liste simple separee par des virgules
4535
+        $numeric_keys = array_map('is_numeric', array_keys($u));
4536
+        $array_values = array_map('is_array', $u);
4537
+        $object_values = array_map('is_object', $u);
4538
+        if (array_sum($numeric_keys) == count($numeric_keys)
4539
+            and !array_sum($array_values)
4540
+            and !array_sum($object_values)
4541
+        ) {
4542
+            return join(", ", array_map('filtre_print_dist', $u));
4543
+        }
4544 4544
 
4545
-		// sinon on passe a la ligne et on indente
4546
-		$i_str = str_pad("", $indent, " ");
4547
-		foreach ($u as $k => $v) {
4548
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4549
-		}
4545
+        // sinon on passe a la ligne et on indente
4546
+        $i_str = str_pad("", $indent, " ");
4547
+        foreach ($u as $k => $v) {
4548
+            $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4549
+        }
4550 4550
 
4551
-		return $out;
4552
-	}
4551
+        return $out;
4552
+    }
4553 4553
 
4554
-	// on sait pas quoi faire...
4555
-	return $u;
4554
+    // on sait pas quoi faire...
4555
+    return $u;
4556 4556
 }
4557 4557
 
4558 4558
 
@@ -4565,10 +4565,10 @@  discard block
 block discarded – undo
4565 4565
  * @return string|array
4566 4566
  */
4567 4567
 function objet_info($objet, $info) {
4568
-	$table = table_objet_sql($objet);
4569
-	$infos = lister_tables_objets_sql($table);
4568
+    $table = table_objet_sql($objet);
4569
+    $infos = lister_tables_objets_sql($table);
4570 4570
 
4571
-	return (isset($infos[$info]) ? $infos[$info] : '');
4571
+    return (isset($infos[$info]) ? $infos[$info] : '');
4572 4572
 }
4573 4573
 
4574 4574
 /**
@@ -4583,11 +4583,11 @@  discard block
 block discarded – undo
4583 4583
  *     Texte traduit du comptage, tel que '3 articles'
4584 4584
  */
4585 4585
 function objet_afficher_nb($nb, $objet) {
4586
-	if (!$nb) {
4587
-		return _T(objet_info($objet, 'info_aucun_objet'));
4588
-	} else {
4589
-		return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb));
4590
-	}
4586
+    if (!$nb) {
4587
+        return _T(objet_info($objet, 'info_aucun_objet'));
4588
+    } else {
4589
+        return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb));
4590
+    }
4591 4591
 }
4592 4592
 
4593 4593
 /**
@@ -4599,11 +4599,11 @@  discard block
 block discarded – undo
4599 4599
  * @return string
4600 4600
  */
4601 4601
 function objet_icone($objet, $taille = 24, $class='') {
4602
-	$icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4603
-	$icone = chemin_image($icone);
4604
-	$balise_img = charger_filtre('balise_img');
4602
+    $icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4603
+    $icone = chemin_image($icone);
4604
+    $balise_img = charger_filtre('balise_img');
4605 4605
 
4606
-	return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4606
+    return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4607 4607
 }
4608 4608
 
4609 4609
 /**
@@ -4624,12 +4624,12 @@  discard block
 block discarded – undo
4624 4624
  * @return string
4625 4625
  */
4626 4626
 function objet_T($objet, $chaine, $args = array(), $options = array()){
4627
-	$chaine = explode(':',$chaine);
4628
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4629
-		return $t;
4630
-	}
4631
-	$chaine = implode(':',$chaine);
4632
-	return _T($chaine, $args, $options);
4627
+    $chaine = explode(':',$chaine);
4628
+    if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4629
+        return $t;
4630
+    }
4631
+    $chaine = implode(':',$chaine);
4632
+    return _T($chaine, $args, $options);
4633 4633
 }
4634 4634
 
4635 4635
 /**
@@ -4643,17 +4643,17 @@  discard block
 block discarded – undo
4643 4643
  * @return string      Code HTML
4644 4644
  */
4645 4645
 function insert_head_css_conditionnel($flux) {
4646
-	if (strpos($flux, '<!-- insert_head_css -->') === false
4647
-		and $p = strpos($flux, '<!-- insert_head -->')
4648
-	) {
4649
-		// plutot avant le premier js externe (jquery) pour etre non bloquant
4650
-		if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
4651
-			$p = $p1;
4652
-		}
4653
-		$flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4654
-	}
4646
+    if (strpos($flux, '<!-- insert_head_css -->') === false
4647
+        and $p = strpos($flux, '<!-- insert_head -->')
4648
+    ) {
4649
+        // plutot avant le premier js externe (jquery) pour etre non bloquant
4650
+        if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
4651
+            $p = $p1;
4652
+        }
4653
+        $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4654
+    }
4655 4655
 
4656
-	return $flux;
4656
+    return $flux;
4657 4657
 }
4658 4658
 
4659 4659
 /**
@@ -4674,69 +4674,69 @@  discard block
 block discarded – undo
4674 4674
  * @return string
4675 4675
  */
4676 4676
 function produire_fond_statique($fond, $contexte = array(), $options = array(), $connect = '') {
4677
-	if (isset($contexte['format'])) {
4678
-		$extension = $contexte['format'];
4679
-		unset($contexte['format']);
4680
-	} else {
4681
-		$extension = "html";
4682
-		if (preg_match(',[.](css|js|json)$,', $fond, $m)) {
4683
-			$extension = $m[1];
4684
-		}
4685
-	}
4686
-	// recuperer le contenu produit par le squelette
4687
-	$options['raw'] = true;
4688
-	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4689
-
4690
-	// calculer le nom de la css
4691
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4692
-	$nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4693
-	$contexte_implicite = calculer_contexte_implicite();
4694
-
4695
-	// par defaut on hash selon les contextes qui sont a priori moins variables
4696
-	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4697
-	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4698
-	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4699
-		$hash = md5($contexte_implicite['host'] . '::'. $cache);
4700
-	}
4701
-	else {
4702
-		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4703
-		ksort($contexte);
4704
-		$hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4705
-	}
4706
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4707
-
4708
-	// mettre a jour le fichier si il n'existe pas
4709
-	// ou trop ancien
4710
-	// le dernier fichier produit est toujours suffixe par .last
4711
-	// et recopie sur le fichier cible uniquement si il change
4712
-	if (!file_exists($filename)
4713
-		or !file_exists($filename . ".last")
4714
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4715
-		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4716
-	) {
4717
-		$contenu = $cache['texte'];
4718
-		// passer les urls en absolu si c'est une css
4719
-		if ($extension == "css") {
4720
-			$contenu = urls_absolues_css($contenu,
4721
-				test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond));
4722
-		}
4723
-
4724
-		$comment = '';
4725
-		// ne pas insérer de commentaire si c'est du json
4726
-		if ($extension != "json") {
4727
-			$comment = "/* #PRODUIRE{fond=$fond";
4728
-			foreach ($contexte as $k => $v) {
4729
-				$comment .= ",$k=$v";
4730
-			}
4731
-			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4732
-			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4733
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
4734
-		}
4735
-		// et ecrire le fichier si il change
4736
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4737
-	}
4738
-
4739
-	return timestamp($filename);
4677
+    if (isset($contexte['format'])) {
4678
+        $extension = $contexte['format'];
4679
+        unset($contexte['format']);
4680
+    } else {
4681
+        $extension = "html";
4682
+        if (preg_match(',[.](css|js|json)$,', $fond, $m)) {
4683
+            $extension = $m[1];
4684
+        }
4685
+    }
4686
+    // recuperer le contenu produit par le squelette
4687
+    $options['raw'] = true;
4688
+    $cache = recuperer_fond($fond, $contexte, $options, $connect);
4689
+
4690
+    // calculer le nom de la css
4691
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4692
+    $nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4693
+    $contexte_implicite = calculer_contexte_implicite();
4694
+
4695
+    // par defaut on hash selon les contextes qui sont a priori moins variables
4696
+    // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4697
+    // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4698
+    if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4699
+        $hash = md5($contexte_implicite['host'] . '::'. $cache);
4700
+    }
4701
+    else {
4702
+        unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4703
+        ksort($contexte);
4704
+        $hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4705
+    }
4706
+    $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4707
+
4708
+    // mettre a jour le fichier si il n'existe pas
4709
+    // ou trop ancien
4710
+    // le dernier fichier produit est toujours suffixe par .last
4711
+    // et recopie sur le fichier cible uniquement si il change
4712
+    if (!file_exists($filename)
4713
+        or !file_exists($filename . ".last")
4714
+        or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4715
+        or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4716
+    ) {
4717
+        $contenu = $cache['texte'];
4718
+        // passer les urls en absolu si c'est une css
4719
+        if ($extension == "css") {
4720
+            $contenu = urls_absolues_css($contenu,
4721
+                test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond));
4722
+        }
4723
+
4724
+        $comment = '';
4725
+        // ne pas insérer de commentaire si c'est du json
4726
+        if ($extension != "json") {
4727
+            $comment = "/* #PRODUIRE{fond=$fond";
4728
+            foreach ($contexte as $k => $v) {
4729
+                $comment .= ",$k=$v";
4730
+            }
4731
+            // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4732
+            // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4733
+            $comment .= "}\n   md5:" . md5($contenu) . " */\n";
4734
+        }
4735
+        // et ecrire le fichier si il change
4736
+        ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4737
+    }
4738
+
4739
+    return timestamp($filename);
4740 4740
 }
4741 4741
 
4742 4742
 /**
@@ -4749,14 +4749,14 @@  discard block
 block discarded – undo
4749 4749
  *    $fichier auquel on a ajouté le timestamp
4750 4750
  */
4751 4751
 function timestamp($fichier) {
4752
-	if (!$fichier
4753
-		or !file_exists($fichier)
4754
-		or !$m = filemtime($fichier)
4755
-	) {
4756
-		return $fichier;
4757
-	}
4752
+    if (!$fichier
4753
+        or !file_exists($fichier)
4754
+        or !$m = filemtime($fichier)
4755
+    ) {
4756
+        return $fichier;
4757
+    }
4758 4758
 
4759
-	return "$fichier?$m";
4759
+    return "$fichier?$m";
4760 4760
 }
4761 4761
 
4762 4762
 /**
@@ -4766,11 +4766,11 @@  discard block
 block discarded – undo
4766 4766
  * @return string
4767 4767
  */
4768 4768
 function supprimer_timestamp($url) {
4769
-	if (strpos($url, "?") === false) {
4770
-		return $url;
4771
-	}
4769
+    if (strpos($url, "?") === false) {
4770
+        return $url;
4771
+    }
4772 4772
 
4773
-	return preg_replace(",\?[[:digit:]]+$,", "", $url);
4773
+    return preg_replace(",\?[[:digit:]]+$,", "", $url);
4774 4774
 }
4775 4775
 
4776 4776
 /**
@@ -4785,9 +4785,9 @@  discard block
 block discarded – undo
4785 4785
  * @return string
4786 4786
  */
4787 4787
 function filtre_nettoyer_titre_email_dist($titre) {
4788
-	include_spip('inc/envoyer_mail');
4788
+    include_spip('inc/envoyer_mail');
4789 4789
 
4790
-	return nettoyer_titre_email($titre);
4790
+    return nettoyer_titre_email($titre);
4791 4791
 }
4792 4792
 
4793 4793
 /**
@@ -4809,19 +4809,19 @@  discard block
 block discarded – undo
4809 4809
  * @return string
4810 4810
  */
4811 4811
 function filtre_chercher_rubrique_dist(
4812
-	$titre,
4813
-	$id_objet,
4814
-	$id_parent,
4815
-	$objet,
4816
-	$id_secteur,
4817
-	$restreint,
4818
-	$actionable = false,
4819
-	$retour_sans_cadre = false
4812
+    $titre,
4813
+    $id_objet,
4814
+    $id_parent,
4815
+    $objet,
4816
+    $id_secteur,
4817
+    $restreint,
4818
+    $actionable = false,
4819
+    $retour_sans_cadre = false
4820 4820
 ) {
4821
-	include_spip('inc/filtres_ecrire');
4821
+    include_spip('inc/filtres_ecrire');
4822 4822
 
4823
-	return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable,
4824
-		$retour_sans_cadre);
4823
+    return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable,
4824
+        $retour_sans_cadre);
4825 4825
 }
4826 4826
 
4827 4827
 /**
@@ -4850,56 +4850,56 @@  discard block
 block discarded – undo
4850 4850
  *     Chaîne vide si l'accès est autorisé
4851 4851
  */
4852 4852
 function sinon_interdire_acces($ok = false, $url = '', $statut = 0, $message = null) {
4853
-	if ($ok) {
4854
-		return '';
4855
-	}
4856
-
4857
-	// Vider tous les tampons
4858
-	$level = @ob_get_level();
4859
-	while ($level--) {
4860
-		@ob_end_clean();
4861
-	}
4862
-
4863
-	include_spip('inc/headers');
4864
-
4865
-	// S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
4866
-	if ($url) {
4867
-		redirige_par_entete($url, '', $statut);
4868
-	}
4869
-
4870
-	// ecriture simplifiee avec message en 3eme argument (= statut 403)
4871
-	if (!is_numeric($statut) and is_null($message)) {
4872
-		$message = $statut;
4873
-		$statut = 0;
4874
-	}
4875
-	if (!$message) {
4876
-		$message = '';
4877
-	}
4878
-	$statut = intval($statut);
4879
-
4880
-	// Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
4881
-	if (test_espace_prive()) {
4882
-		if (!$statut or !in_array($statut, array(404, 403))) {
4883
-			$statut = 403;
4884
-		}
4885
-		http_status(403);
4886
-		$echec = charger_fonction('403', 'exec');
4887
-		$echec($message);
4888
-	} else {
4889
-		// Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
4890
-		if (!$statut) {
4891
-			$statut = 404;
4892
-		}
4893
-		// Dans tous les cas on modifie l'entité avec ce qui est demandé
4894
-		http_status($statut);
4895
-		// Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
4896
-		if ($statut >= 400) {
4897
-			echo recuperer_fond("$statut", array('erreur' => $message));
4898
-		}
4899
-	}
4900
-
4901
-
4902
-	exit;
4853
+    if ($ok) {
4854
+        return '';
4855
+    }
4856
+
4857
+    // Vider tous les tampons
4858
+    $level = @ob_get_level();
4859
+    while ($level--) {
4860
+        @ob_end_clean();
4861
+    }
4862
+
4863
+    include_spip('inc/headers');
4864
+
4865
+    // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
4866
+    if ($url) {
4867
+        redirige_par_entete($url, '', $statut);
4868
+    }
4869
+
4870
+    // ecriture simplifiee avec message en 3eme argument (= statut 403)
4871
+    if (!is_numeric($statut) and is_null($message)) {
4872
+        $message = $statut;
4873
+        $statut = 0;
4874
+    }
4875
+    if (!$message) {
4876
+        $message = '';
4877
+    }
4878
+    $statut = intval($statut);
4879
+
4880
+    // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
4881
+    if (test_espace_prive()) {
4882
+        if (!$statut or !in_array($statut, array(404, 403))) {
4883
+            $statut = 403;
4884
+        }
4885
+        http_status(403);
4886
+        $echec = charger_fonction('403', 'exec');
4887
+        $echec($message);
4888
+    } else {
4889
+        // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
4890
+        if (!$statut) {
4891
+            $statut = 404;
4892
+        }
4893
+        // Dans tous les cas on modifie l'entité avec ce qui est demandé
4894
+        http_status($statut);
4895
+        // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
4896
+        if ($statut >= 400) {
4897
+            echo recuperer_fond("$statut", array('erreur' => $message));
4898
+        }
4899
+    }
4900
+
4901
+
4902
+    exit;
4903 4903
 }
4904 4904
 
4905 4905
 /**
@@ -4910,11 +4910,11 @@  discard block
 block discarded – undo
4910 4910
  * @return string
4911 4911
  */
4912 4912
 function filtre_compacte_dist($source, $format = null) {
4913
-	if (function_exists('compacte')) {
4914
-		return compacte($source, $format);
4915
-	}
4913
+    if (function_exists('compacte')) {
4914
+        return compacte($source, $format);
4915
+    }
4916 4916
 
4917
-	return $source;
4917
+    return $source;
4918 4918
 }
4919 4919
 
4920 4920
 
@@ -4926,29 +4926,29 @@  discard block
 block discarded – undo
4926 4926
  * @return string
4927 4927
  */
4928 4928
 function spip_affiche_mot_de_passe_masque($passe, $afficher_partiellement = false, $portion_pourcent = null) {
4929
-	$l = strlen($passe);
4930
-
4931
-	if ($l<=8 or !$afficher_partiellement){
4932
-		if (!$l) {
4933
-			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
4934
-		}
4935
-		return str_pad('',$afficher_partiellement ? $l : 16,'*');
4936
-	}
4937
-
4938
-	if (is_null($portion_pourcent)) {
4939
-		if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
4940
-			define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
4941
-		}
4942
-		$portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
4943
-	}
4944
-	if ($portion_pourcent >= 100) {
4945
-		return $passe;
4946
-	}
4947
-	$e = intval(ceil($l * $portion_pourcent / 100 / 2));
4948
-	$e = max($e, 0);
4949
-	$mid = str_pad('',$l-2*$e,'*');
4950
-	if ($e>0 and strlen($mid)>8){
4951
-		$mid = '***...***';
4952
-	}
4953
-	return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
4929
+    $l = strlen($passe);
4930
+
4931
+    if ($l<=8 or !$afficher_partiellement){
4932
+        if (!$l) {
4933
+            return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
4934
+        }
4935
+        return str_pad('',$afficher_partiellement ? $l : 16,'*');
4936
+    }
4937
+
4938
+    if (is_null($portion_pourcent)) {
4939
+        if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
4940
+            define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
4941
+        }
4942
+        $portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
4943
+    }
4944
+    if ($portion_pourcent >= 100) {
4945
+        return $passe;
4946
+    }
4947
+    $e = intval(ceil($l * $portion_pourcent / 100 / 2));
4948
+    $e = max($e, 0);
4949
+    $mid = str_pad('',$l-2*$e,'*');
4950
+    if ($e>0 and strlen($mid)>8){
4951
+        $mid = '***...***';
4952
+    }
4953
+    return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
4954 4954
 }
4955 4955
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	}
95 95
 
96 96
 	include_fichiers_fonctions();
97
-	foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) {
97
+	foreach (array('filtre_'.$fonc, 'filtre_'.$fonc.'_dist', $fonc) as $f) {
98 98
 		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
99 99
 		// fonction ou name\space\fonction
100 100
 		if (is_callable($f)) {
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	// affichage "GIT [master: abcdef]"
188 188
 	$commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit'];
189 189
 	if ($desc['branch']) {
190
-		$commit = $desc['branch'] . ': ' . $commit;
190
+		$commit = $desc['branch'].': '.$commit;
191 191
 	}
192 192
 	return "{$desc['vcs']} [$commit]";
193 193
 }
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
 	}
207 207
 
208 208
 	// version installee par GIT
209
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
209
+	if (lire_fichier($dir.'/.git/HEAD', $c)) {
210 210
 		$currentHead = trim(substr($c, 4));
211
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
211
+		if (lire_fichier($dir.'/.git/'.$currentHead, $hash)) {
212 212
 			return [
213 213
 				'vcs' => 'GIT',
214 214
 				'branch' => basename($currentHead),
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 		$dir = '.';
236 236
 	}
237 237
 	// version installee par SVN
238
-	if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
239
-		$db = new SQLite3($dir . '/.svn/wc.db');
238
+	if (file_exists($dir.'/.svn/wc.db') && class_exists('SQLite3')) {
239
+		$db = new SQLite3($dir.'/.svn/wc.db');
240 240
 		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
241 241
 		if ($result) {
242 242
 			$row = $result->fetchArray();
@@ -275,11 +275,11 @@  discard block
 block discarded – undo
275 275
 
276 276
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
277 277
 // et laisser passer les fonctions personnelles baptisees image_...
278
-$GLOBALS['spip_matrice']['image_graver'] = true;//'inc/filtres_images_mini.php';
279
-$GLOBALS['spip_matrice']['image_select'] = true;//'inc/filtres_images_mini.php';
280
-$GLOBALS['spip_matrice']['image_reduire'] = true;//'inc/filtres_images_mini.php';
281
-$GLOBALS['spip_matrice']['image_reduire_par'] = true;//'inc/filtres_images_mini.php';
282
-$GLOBALS['spip_matrice']['image_passe_partout'] = true;//'inc/filtres_images_mini.php';
278
+$GLOBALS['spip_matrice']['image_graver'] = true; //'inc/filtres_images_mini.php';
279
+$GLOBALS['spip_matrice']['image_select'] = true; //'inc/filtres_images_mini.php';
280
+$GLOBALS['spip_matrice']['image_reduire'] = true; //'inc/filtres_images_mini.php';
281
+$GLOBALS['spip_matrice']['image_reduire_par'] = true; //'inc/filtres_images_mini.php';
282
+$GLOBALS['spip_matrice']['image_passe_partout'] = true; //'inc/filtres_images_mini.php';
283 283
 
284 284
 $GLOBALS['spip_matrice']['couleur_html_to_hex'] = 'inc/filtres_images_mini.php';
285 285
 $GLOBALS['spip_matrice']['couleur_foncer'] = 'inc/filtres_images_mini.php';
@@ -436,8 +436,8 @@  discard block
 block discarded – undo
436 436
  */
437 437
 function filtre_debug($val, $key = null) {
438 438
 	$debug = (
439
-		is_null($key) ? '' : (var_export($key, true) . " = ")
440
-		) . var_export($val, true);
439
+		is_null($key) ? '' : (var_export($key, true)." = ")
440
+		).var_export($val, true);
441 441
 
442 442
 	include_spip('inc/autoriser');
443 443
 	if (autoriser('webmestre')) {
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
526 526
 							$srcover = $match[1];
527 527
 							array_shift($args);
528
-							array_unshift($args, "<img src='" . $match[1] . "' />");
528
+							array_unshift($args, "<img src='".$match[1]."' />");
529 529
 							$srcover_filter = call_user_func_array($filtre, $args);
530 530
 							$srcover_filter = extraire_attribut($srcover_filter, 'src');
531 531
 							$reduit = str_replace($srcover, $srcover_filter, $reduit);
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
 	// " -> &quot; et tout ce genre de choses
876 876
 	$u = $GLOBALS['meta']['pcre_u'];
877 877
 	$texte = str_replace("&nbsp;", " ", $texte);
878
-	$texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
878
+	$texte = preg_replace('/\s{2,}/S'.$u, " ", $texte);
879 879
 	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
880 880
 	$texte = entites_html($texte, false, false);
881 881
 	// mais bien echapper les double quotes !
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
  **/
936 936
 function supprimer_numero($texte) {
937 937
 	return preg_replace(
938
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
938
+		",^[[:space:]]*([0-9]+)([.)]|".chr(194).'?'.chr(176).")[[:space:]]+,S",
939 939
 		"", $texte);
940 940
 }
941 941
 
@@ -960,7 +960,7 @@  discard block
 block discarded – undo
960 960
  **/
961 961
 function recuperer_numero($texte) {
962 962
 	if (preg_match(
963
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
963
+		",^[[:space:]]*([0-9]+)([.)]|".chr(194).'?'.chr(176).")[[:space:]]+,S",
964 964
 		$texte, $regs)) {
965 965
 		return strval($regs[1]);
966 966
 	} else {
@@ -1045,8 +1045,8 @@  discard block
 block discarded – undo
1045 1045
  **/
1046 1046
 function textebrut($texte) {
1047 1047
 	$u = $GLOBALS['meta']['pcre_u'];
1048
-	$texte = preg_replace('/\s+/S' . $u, " ", $texte);
1049
-	$texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
1048
+	$texte = preg_replace('/\s+/S'.$u, " ", $texte);
1049
+	$texte = preg_replace("/<(p|br)( [^>]*)?".">/iS", "\n\n", $texte);
1050 1050
 	$texte = preg_replace("/^\n+/", "", $texte);
1051 1051
 	$texte = preg_replace("/\n+$/", "", $texte);
1052 1052
 	$texte = preg_replace("/\n +/", "\n", $texte);
@@ -1074,7 +1074,7 @@  discard block
 block discarded – undo
1074 1074
 	if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1075 1075
 		$texte, $liens, PREG_PATTERN_ORDER)) {
1076 1076
 		foreach ($liens[0] as $a) {
1077
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1077
+			$rel = 'noopener noreferrer '.extraire_attribut($a, 'rel');
1078 1078
 			$ablank = inserer_attribut($a, 'rel', $rel);
1079 1079
 			$ablank = inserer_attribut($ablank, 'target', '_blank');
1080 1080
 			$texte = str_replace($a, $ablank, $texte);
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
 		foreach ($regs[0] as $a) {
1100 1100
 			$rel = extraire_attribut($a, "rel");
1101 1101
 			if (strpos($rel, "nofollow") === false) {
1102
-				$rel = "nofollow" . ($rel ? " $rel" : "");
1102
+				$rel = "nofollow".($rel ? " $rel" : "");
1103 1103
 				$anofollow = inserer_attribut($a, "rel", $rel);
1104 1104
 				$texte = str_replace($a, $anofollow, $texte);
1105 1105
 			}
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
 	$u = $GLOBALS['meta']['pcre_u'];
1129 1129
 	$texte = preg_replace("@</p>@iS", "\n", $texte);
1130 1130
 	$texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1131
-	$texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1131
+	$texte = preg_replace("@^\s*<br />@S".$u, "", $texte);
1132 1132
 
1133 1133
 	return $texte;
1134 1134
 }
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
 		return $texte;
1159 1159
 	}
1160 1160
 	include_spip('inc/texte');
1161
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1161
+	$tag = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $texte) ?
1162 1162
 		'div' : 'span';
1163 1163
 
1164 1164
 	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
@@ -1267,7 +1267,7 @@  discard block
 block discarded – undo
1267 1267
 function attribut_html($texte, $textebrut = true) {
1268 1268
 	$u = $GLOBALS['meta']['pcre_u'];
1269 1269
 	if ($textebrut) {
1270
-		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1270
+		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS".$u), array(" ", ""), textebrut($texte));
1271 1271
 	}
1272 1272
 	$texte = texte_backend($texte);
1273 1273
 	$texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
@@ -1296,7 +1296,7 @@  discard block
 block discarded – undo
1296 1296
 	# un message pour abs_url
1297 1297
 	$GLOBALS['mode_abs_url'] = 'url';
1298 1298
 	$url = trim($url);
1299
-	$r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1299
+	$r = ",^(?:"._PROTOCOLES_STD.'):?/?/?$,iS';
1300 1300
 
1301 1301
 	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1302 1302
 }
@@ -1498,14 +1498,14 @@  discard block
 block discarded – undo
1498 1498
 	if (strpos($texte, "<") !== false) {
1499 1499
 		include_spip('inc/lien');
1500 1500
 		if (defined('_PREG_MODELE')) {
1501
-			$preg_modeles = "@" . _PREG_MODELE . "@imsS";
1501
+			$preg_modeles = "@"._PREG_MODELE."@imsS";
1502 1502
 			$texte = echappe_html($texte, '', true, $preg_modeles);
1503 1503
 		}
1504 1504
 	}
1505 1505
 
1506 1506
 	$debut = '';
1507 1507
 	$suite = $texte;
1508
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1508
+	while ($t = strpos('-'.$suite, "\n", 1)) {
1509 1509
 		$debut .= substr($suite, 0, $t - 1);
1510 1510
 		$suite = substr($suite, $t);
1511 1511
 		$car = substr($suite, 0, 1);
@@ -1522,11 +1522,11 @@  discard block
 block discarded – undo
1522 1522
 			$suite = substr($suite, strlen($regs[0]));
1523 1523
 		}
1524 1524
 	}
1525
-	$texte = $debut . $suite;
1525
+	$texte = $debut.$suite;
1526 1526
 
1527 1527
 	$texte = echappe_retour($texte);
1528 1528
 
1529
-	return $texte . $fin;
1529
+	return $texte.$fin;
1530 1530
 }
1531 1531
 
1532 1532
 
@@ -1587,7 +1587,7 @@  discard block
 block discarded – undo
1587 1587
 		}
1588 1588
 
1589 1589
 		foreach ($regs as $reg) {
1590
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1590
+			$cle = ($reg[1] ? $reg[1].':' : '').$reg[2];
1591 1591
 			$desc = $traduire($cle, $lang, true);
1592 1592
 			$l = $desc->langue;
1593 1593
 			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
@@ -1700,7 +1700,7 @@  discard block
 block discarded – undo
1700 1700
 					// il ne faut pas echapper en div si propre produit un seul paragraphe
1701 1701
 					include_spip('inc/texte');
1702 1702
 					$trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1703
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1703
+					$mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1704 1704
 					$trad = code_echappement($trad, 'multi', false, $mode);
1705 1705
 					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1706 1706
 					if (lang_dir($l) !== lang_dir($lang)) {
@@ -1893,7 +1893,7 @@  discard block
 block discarded – undo
1893 1893
 	if (is_array($balise)) {
1894 1894
 		array_walk(
1895 1895
 			$balise,
1896
-			function(&$a, $key, $t){
1896
+			function(&$a, $key, $t) {
1897 1897
 				$a = extraire_attribut($a, $t);
1898 1898
 			},
1899 1899
 			$attribut
@@ -1980,14 +1980,14 @@  discard block
 block discarded – undo
1980 1980
 
1981 1981
 	if ($old !== null) {
1982 1982
 		// Remplacer l'ancien attribut du meme nom
1983
-		$balise = $r[1] . $insert . $r[5];
1983
+		$balise = $r[1].$insert.$r[5];
1984 1984
 	} else {
1985 1985
 		// preferer une balise " />" (comme <img />)
1986 1986
 		if (preg_match(',/>,', $balise)) {
1987
-			$balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
1987
+			$balise = preg_replace(",\s?/>,S", $insert." />", $balise, 1);
1988 1988
 		} // sinon une balise <a ...> ... </a>
1989 1989
 		else {
1990
-			$balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
1990
+			$balise = preg_replace(",\s?>,S", $insert.">", $balise, 1);
1991 1991
 		}
1992 1992
 	}
1993 1993
 
@@ -2029,8 +2029,8 @@  discard block
 block discarded – undo
2029 2029
 //
2030 2030
 // Quelques fonctions de calcul arithmetique
2031 2031
 //
2032
-function floatstr($a) { return str_replace(',','.',(string)floatval($a)); }
2033
-function strize($f, $a, $b) { return floatstr($f(floatstr($a),floatstr($b))); }
2032
+function floatstr($a) { return str_replace(',', '.', (string) floatval($a)); }
2033
+function strize($f, $a, $b) { return floatstr($f(floatstr($a), floatstr($b))); }
2034 2034
 
2035 2035
 /**
2036 2036
  * Additionne 2 nombres
@@ -2050,7 +2050,7 @@  discard block
 block discarded – undo
2050 2050
 function plus($a, $b) {
2051 2051
 	return $a + $b;
2052 2052
 }
2053
-function strplus($a, $b) {return strize('plus', $a, $b);}
2053
+function strplus($a, $b) {return strize('plus', $a, $b); }
2054 2054
 /**
2055 2055
  * Soustrait 2 nombres
2056 2056
  *
@@ -2069,7 +2069,7 @@  discard block
 block discarded – undo
2069 2069
 function moins($a, $b) {
2070 2070
 	return $a - $b;
2071 2071
 }
2072
-function strmoins($a, $b) {return strize('moins', $a, $b);}
2072
+function strmoins($a, $b) {return strize('moins', $a, $b); }
2073 2073
 
2074 2074
 /**
2075 2075
  * Multiplie 2 nombres
@@ -2090,7 +2090,7 @@  discard block
 block discarded – undo
2090 2090
 function mult($a, $b) {
2091 2091
 	return $a * $b;
2092 2092
 }
2093
-function strmult($a, $b) {return strize('mult', $a, $b);}
2093
+function strmult($a, $b) {return strize('mult', $a, $b); }
2094 2094
 
2095 2095
 /**
2096 2096
  * Divise 2 nombres
@@ -2111,7 +2111,7 @@  discard block
 block discarded – undo
2111 2111
 function div($a, $b) {
2112 2112
 	return $b ? $a / $b : 0;
2113 2113
 }
2114
-function strdiv($a, $b) {return strize('div', $a, $b);}
2114
+function strdiv($a, $b) {return strize('div', $a, $b); }
2115 2115
 
2116 2116
 /**
2117 2117
  * Retourne le modulo 2 nombres
@@ -2152,13 +2152,13 @@  discard block
 block discarded – undo
2152 2152
 	if (!defined('_TAGS_NOM_AUTEUR')) {
2153 2153
 		define('_TAGS_NOM_AUTEUR', '');
2154 2154
 	}
2155
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2155
+	$tags_acceptes = array_unique(explode(',', 'multi,'._TAGS_NOM_AUTEUR));
2156 2156
 	foreach ($tags_acceptes as $tag) {
2157 2157
 		if (strlen($tag)) {
2158
-			$remp1[] = '<' . trim($tag) . '>';
2159
-			$remp1[] = '</' . trim($tag) . '>';
2160
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2161
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2158
+			$remp1[] = '<'.trim($tag).'>';
2159
+			$remp1[] = '</'.trim($tag).'>';
2160
+			$remp2[] = '\x60'.trim($tag).'\x61';
2161
+			$remp2[] = '\x60/'.trim($tag).'\x61';
2162 2162
 		}
2163 2163
 	}
2164 2164
 	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
@@ -2221,7 +2221,7 @@  discard block
 block discarded – undo
2221 2221
 			$s[] = preg_replace(',>[^<]+</a>,S',
2222 2222
 				'>'
2223 2223
 				. http_img_pack('attachment-16.png', $t,
2224
-					'title="' . attribut_html($t) . '"')
2224
+					'title="'.attribut_html($t).'"')
2225 2225
 				. '</a>', $tag);
2226 2226
 		}
2227 2227
 	}
@@ -2282,10 +2282,10 @@  discard block
 block discarded – undo
2282 2282
 	$fichier = basename($url);
2283 2283
 
2284 2284
 	return '<a rel="enclosure"'
2285
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2286
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2287
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2288
-	. '>' . $fichier . '</a>';
2285
+	. ($url ? ' href="'.spip_htmlspecialchars($url).'"' : '')
2286
+	. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2287
+	. ($length ? ' title="'.spip_htmlspecialchars($length).'"' : '')
2288
+	. '>'.$fichier.'</a>';
2289 2289
 }
2290 2290
 
2291 2291
 /**
@@ -2313,9 +2313,9 @@  discard block
 block discarded – undo
2313 2313
 			} # vieux data
2314 2314
 			$fichier = basename($url);
2315 2315
 			$enclosures[] = '<enclosure'
2316
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2317
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2318
-				. ($length ? ' length="' . $length . '"' : '')
2316
+				. ($url ? ' url="'.spip_htmlspecialchars($url).'"' : '')
2317
+				. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2318
+				. ($length ? ' length="'.$length.'"' : '')
2319 2319
 				. ' />';
2320 2320
 		}
2321 2321
 	}
@@ -2341,7 +2341,7 @@  discard block
 block discarded – undo
2341 2341
 		if (extraire_attribut($e, rel) == 'tag') {
2342 2342
 			$subjects .= '<dc:subject>'
2343 2343
 				. texte_backend(textebrut($e))
2344
-				. '</dc:subject>' . "\n";
2344
+				. '</dc:subject>'."\n";
2345 2345
 		}
2346 2346
 	}
2347 2347
 
@@ -2377,7 +2377,7 @@  discard block
 block discarded – undo
2377 2377
 	if (is_array($texte)) {
2378 2378
 		array_walk(
2379 2379
 			$texte,
2380
-			function(&$a, $key, $t){
2380
+			function(&$a, $key, $t) {
2381 2381
 				$a = extraire_balise($a, $t);
2382 2382
 			},
2383 2383
 			$tag
@@ -2421,7 +2421,7 @@  discard block
 block discarded – undo
2421 2421
 	if (is_array($texte)) {
2422 2422
 		array_walk(
2423 2423
 			$texte,
2424
-			function(&$a, $key, $t){
2424
+			function(&$a, $key, $t) {
2425 2425
 				$a = extraire_balises($a, $t);
2426 2426
 			},
2427 2427
 			$tag
@@ -2547,7 +2547,7 @@  discard block
 block discarded – undo
2547 2547
 		if ($fond != '404') {
2548 2548
 			$contexte = array_shift($p);
2549 2549
 			$contexte['page'] = $fond;
2550
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2550
+			$action = preg_replace('/([?]'.preg_quote($fond).'[^&=]*[0-9]+)(&|$)/', '?&', $action);
2551 2551
 		}
2552 2552
 	}
2553 2553
 	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
@@ -2602,9 +2602,9 @@  discard block
 block discarded – undo
2602 2602
 			. '"'
2603 2603
 			. (is_null($val)
2604 2604
 				? ''
2605
-				: ' value="' . entites_html($val) . '"'
2605
+				: ' value="'.entites_html($val).'"'
2606 2606
 			)
2607
-			. ' type="hidden"' . "\n/>";
2607
+			. ' type="hidden"'."\n/>";
2608 2608
 	}
2609 2609
 
2610 2610
 	return join("", $hidden);
@@ -2767,12 +2767,12 @@  discard block
 block discarded – undo
2767 2767
 	if ($pas < 1) {
2768 2768
 		return '';
2769 2769
 	}
2770
-	$ancre = 'pagination' . $nom; // #pagination_articles
2771
-	$debut = 'debut' . $nom; // 'debut_articles'
2770
+	$ancre = 'pagination'.$nom; // #pagination_articles
2771
+	$debut = 'debut'.$nom; // 'debut_articles'
2772 2772
 
2773 2773
 	// n'afficher l'ancre qu'une fois
2774 2774
 	if (!isset($ancres[$ancre])) {
2775
-		$bloc_ancre = $ancres[$ancre] = "<a name='" . $ancre . "' id='" . $ancre . "'></a>";
2775
+		$bloc_ancre = $ancres[$ancre] = "<a name='".$ancre."' id='".$ancre."'></a>";
2776 2776
 	} else {
2777 2777
 		$bloc_ancre = '';
2778 2778
 	}
@@ -2803,7 +2803,7 @@  discard block
 block discarded – undo
2803 2803
 	}
2804 2804
 
2805 2805
 	if ($modele) {
2806
-		$modele = '_' . $modele;
2806
+		$modele = '_'.$modele;
2807 2807
 	}
2808 2808
 
2809 2809
 	return recuperer_fond("modeles/pagination$modele", $pagination, array('trim' => true), $connect);
@@ -2828,7 +2828,7 @@  discard block
 block discarded – undo
2828 2828
 	return preg_replace_callback(
2829 2829
 		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2830 2830
 		function($x) use ($path) {
2831
-			return "url('" . suivre_lien($path, $x[1]) . "')";
2831
+			return "url('".suivre_lien($path, $x[1])."')";
2832 2832
 		},
2833 2833
 		$contenu
2834 2834
 	);
@@ -2890,14 +2890,14 @@  discard block
 block discarded – undo
2890 2890
 	) {
2891 2891
 		$distant = true;
2892 2892
 		$cssf = parse_url($css);
2893
-		$cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2893
+		$cssf = $cssf['path'].($cssf['query'] ? "?".$cssf['query'] : "");
2894 2894
 		$cssf = preg_replace(',[?:&=],', "_", $cssf);
2895 2895
 	} else {
2896 2896
 		$distant = false;
2897 2897
 		$cssf = $css;
2898 2898
 		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2899 2899
 		//propose (rien a faire dans ce cas)
2900
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2900
+		$f = preg_replace(',(_rtl)?\.css$,i', '_'.$ndir.'.css', $css);
2901 2901
 		if (@file_exists($f)) {
2902 2902
 			return $f;
2903 2903
 		}
@@ -2907,7 +2907,7 @@  discard block
 block discarded – undo
2907 2907
 	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2908 2908
 	$f = $dir_var
2909 2909
 		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2910
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2910
+		. '.'.substr(md5($cssf), 0, 4).'_'.$ndir.'.css';
2911 2911
 
2912 2912
 	// la css peut etre distante (url absolue !)
2913 2913
 	if ($distant) {
@@ -2952,8 +2952,8 @@  discard block
 block discarded – undo
2952 2952
 		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2953 2953
 		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2954 2954
 			$css_direction = substr($css_direction, strlen($dir_var));
2955
-			$src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2956
-			$css_direction = "/@@@@@@/" . $css_direction;
2955
+			$src_faux_abs["/@@@@@@/".$css_direction] = $css_direction;
2956
+			$css_direction = "/@@@@@@/".$css_direction;
2957 2957
 		}
2958 2958
 		$src[] = $regs[0][$k];
2959 2959
 		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
@@ -3002,7 +3002,7 @@  discard block
 block discarded – undo
3002 3002
 
3003 3003
 	$f = basename($css, '.css');
3004 3004
 	$f = sous_repertoire(_DIR_VAR, 'cache-css')
3005
-		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3005
+		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-".substr(md5("$css-urlabs"), 0, 4)."\\2", $f)
3006 3006
 		. '.css';
3007 3007
 
3008 3008
 	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
@@ -3011,7 +3011,7 @@  discard block
 block discarded – undo
3011 3011
 
3012 3012
 	if ($url_absolue_css == $css) {
3013 3013
 		if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3014
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3014
+			or !lire_fichier(_DIR_RACINE.substr($css, $l), $contenu)
3015 3015
 		) {
3016 3016
 			include_spip('inc/distant');
3017 3017
 			if (!$contenu = recuperer_page($css)) {
@@ -3121,7 +3121,7 @@  discard block
 block discarded – undo
3121 3121
 	$expression = str_replace("\/", "/", $expression);
3122 3122
 	$expression = str_replace("/", "\/", $expression);
3123 3123
 
3124
-	if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3124
+	if (preg_match('/'.$expression.'/'.$modif, $texte, $r)) {
3125 3125
 		if (isset($r[$capte])) {
3126 3126
 			return $r[$capte];
3127 3127
 		} else {
@@ -3159,7 +3159,7 @@  discard block
 block discarded – undo
3159 3159
 	$expression = str_replace("\/", "/", $expression);
3160 3160
 	$expression = str_replace("/", "\/", $expression);
3161 3161
 
3162
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3162
+	return preg_replace('/'.$expression.'/'.$modif, $replace, $texte);
3163 3163
 }
3164 3164
 
3165 3165
 
@@ -3178,7 +3178,7 @@  discard block
 block discarded – undo
3178 3178
 function traiter_doublons_documents(&$doublons, $letexte) {
3179 3179
 
3180 3180
 	// Verifier dans le texte & les notes (pas beau, helas)
3181
-	$t = $letexte . $GLOBALS['les_notes'];
3181
+	$t = $letexte.$GLOBALS['les_notes'];
3182 3182
 
3183 3183
 	if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3184 3184
 		and preg_match_all(
@@ -3188,7 +3188,7 @@  discard block
 block discarded – undo
3188 3188
 		if (!isset($doublons['documents'])) {
3189 3189
 			$doublons['documents'] = "";
3190 3190
 		}
3191
-		$doublons['documents'] .= "," . join(',', $matches[1]);
3191
+		$doublons['documents'] .= ",".join(',', $matches[1]);
3192 3192
 	}
3193 3193
 
3194 3194
 	return $letexte;
@@ -3245,7 +3245,7 @@  discard block
 block discarded – undo
3245 3245
 	if ($env) {
3246 3246
 		foreach ($env as $i => $j) {
3247 3247
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3248
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3248
+				$texte .= "<param name='".attribut_html($i)."'\n\tvalue='".attribut_html($j)."' />";
3249 3249
 			}
3250 3250
 		}
3251 3251
 	}
@@ -3284,7 +3284,7 @@  discard block
 block discarded – undo
3284 3284
 	if ($env) {
3285 3285
 		foreach ($env as $i => $j) {
3286 3286
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3287
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3287
+				$texte .= attribut_html($i)."='".attribut_html($j)."' ";
3288 3288
 			}
3289 3289
 		}
3290 3290
 	}
@@ -3368,19 +3368,19 @@  discard block
 block discarded – undo
3368 3368
 
3369 3369
 	$img_file = $img;
3370 3370
 	if ($p = strpos($img_file, '?')) {
3371
-		$img_file = substr($img_file,0, $p);
3371
+		$img_file = substr($img_file, 0, $p);
3372 3372
 	}
3373 3373
 	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3374 3374
 		$img_file = chemin_image($img);
3375 3375
 	}
3376 3376
 	else {
3377
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3377
+		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) {
3378 3378
 			// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3379 3379
 			// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3380 3380
 			if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3381
-			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3381
+			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0]))."-xx.svg"
3382 3382
 			  and file_exists($variante_svg_generique)) {
3383
-				if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3383
+				if ($variante_svg_size = substr($variante_svg_generique, 0, -6).$m[1].".svg" and file_exists($variante_svg_size)) {
3384 3384
 					$img_file = $variante_svg_size;
3385 3385
 				}
3386 3386
 				else {
@@ -3405,15 +3405,15 @@  discard block
 block discarded – undo
3405 3405
 				return "";
3406 3406
 			}
3407 3407
 		}
3408
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3408
+		$atts .= " width='".$largeur."' height='".$hauteur."'";
3409 3409
 	}
3410 3410
 
3411 3411
 	if (file_exists($img_file)) {
3412 3412
 		$img_file = timestamp($img_file);
3413 3413
 	}
3414
-	return "<img src='$img_file' alt='" . attribut_html($alt ? $alt : $title) . "'"
3415
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3416
-	. " " . ltrim($atts)
3414
+	return "<img src='$img_file' alt='".attribut_html($alt ? $alt : $title)."'"
3415
+	. ($title ? ' title="'.attribut_html($title).'"' : '')
3416
+	. " ".ltrim($atts)
3417 3417
 	. " />";
3418 3418
 }
3419 3419
 
@@ -3425,12 +3425,12 @@  discard block
 block discarded – undo
3425 3425
  * @param string $size
3426 3426
  * @return string
3427 3427
  */
3428
-function http_style_background($img, $att = '', $size=null) {
3429
-	if ($size and is_numeric($size)){
3430
-		$size = trim($size) . "px";
3428
+function http_style_background($img, $att = '', $size = null) {
3429
+	if ($size and is_numeric($size)) {
3430
+		$size = trim($size)."px";
3431 3431
 	}
3432
-	return " style='background" .
3433
-		($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3432
+	return " style='background".
3433
+		($att ? "" : "-image").": url(\"".chemin_image($img)."\")".($att ? (' '.$att) : '').";"
3434 3434
 		. ($size ? "background-size:{$size};" : '')
3435 3435
 		. "'";
3436 3436
 }
@@ -3447,8 +3447,8 @@  discard block
 block discarded – undo
3447 3447
  * @return string
3448 3448
  *     Code HTML de la balise IMG
3449 3449
  */
3450
-function filtre_balise_img_dist($img, $alt = "", $class = "", $width=null) {
3451
-	$atts = $class ? " class='" . attribut_html($class) . "'" : '';
3450
+function filtre_balise_img_dist($img, $alt = "", $class = "", $width = null) {
3451
+	$atts = $class ? " class='".attribut_html($class)."'" : '';
3452 3452
 	// ecriture courte : on donne le width en 2e arg
3453 3453
 	if (empty($width) and is_numeric($alt)) {
3454 3454
 		$width = $alt;
@@ -3476,7 +3476,7 @@  discard block
 block discarded – undo
3476 3476
 function filtre_balise_svg_dist($img, $alt = "", $class = "") {
3477 3477
 	$img_file = $img;
3478 3478
 	if ($p = strpos($img_file, '?')) {
3479
-		$img_file = substr($img_file,0, $p);
3479
+		$img_file = substr($img_file, 0, $p);
3480 3480
 	}
3481 3481
 
3482 3482
 	if (!$img_file or !$svg = file_get_contents($img_file)) {
@@ -3490,18 +3490,18 @@  discard block
 block discarded – undo
3490 3490
 	$balise_svg_source = $balise_svg;
3491 3491
 
3492 3492
 	// entete XML à supprimer
3493
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3493
+	$svg = preg_replace(',^\s*<\?xml[^>]*\?'.'>,', '', $svg);
3494 3494
 
3495 3495
 	// IE est toujours mon ami
3496 3496
 	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3497 3497
 	if ($class) {
3498 3498
 		$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3499 3499
 	}
3500
-	if ($alt){
3500
+	if ($alt) {
3501 3501
 		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3502
-		$id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4);
3502
+		$id = "img-svg-title-".substr(md5("$img_file:$svg:$alt"), 0, 4);
3503 3503
 		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3504
-		$title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3504
+		$title = "<title id=\"$id\">".entites_html($alt)."</title>\n";
3505 3505
 		$balise_svg .= $title;
3506 3506
 	}
3507 3507
 	else {
@@ -3535,7 +3535,7 @@  discard block
 block discarded – undo
3535 3535
 	$texte = '';
3536 3536
 	if (is_array($tableau)) {
3537 3537
 		foreach ($tableau as $k => $v) {
3538
-			$res = recuperer_fond('modeles/' . $modele,
3538
+			$res = recuperer_fond('modeles/'.$modele,
3539 3539
 				array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3540 3540
 			);
3541 3541
 			$texte .= $res;
@@ -3712,7 +3712,7 @@  discard block
 block discarded – undo
3712 3712
 	}
3713 3713
 
3714 3714
 	$c = serialize($c);
3715
-	$cle = calculer_cle_action($form . $c);
3715
+	$cle = calculer_cle_action($form.$c);
3716 3716
 	$c = "$cle:$c";
3717 3717
 
3718 3718
 	// on ne stocke pas les contextes dans des fichiers en cache
@@ -3774,15 +3774,15 @@  discard block
 block discarded – undo
3774 3774
 	}
3775 3775
 	// toujours encoder l'url source dans le bloc ajax
3776 3776
 	$r = self();
3777
-	$r = ' data-origin="' . $r . '"';
3777
+	$r = ' data-origin="'.$r.'"';
3778 3778
 	$class = 'ajaxbloc';
3779 3779
 	if ($ajaxid and is_string($ajaxid)) {
3780 3780
 		// ajaxid est normalement conforme a un nom de classe css
3781 3781
 		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3782
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3782
+		$class .= ' ajax-id-'.entites_html($ajaxid);
3783 3783
 	}
3784 3784
 
3785
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3785
+	return "<div class='$class' "."data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3786 3786
 }
3787 3787
 
3788 3788
 /**
@@ -3821,11 +3821,11 @@  discard block
 block discarded – undo
3821 3821
 	// extraire la signature en debut de contexte
3822 3822
 	// et la verifier avant de deserializer
3823 3823
 	// format : signature:donneesserializees
3824
-	if ($p = strpos($c,":")){
3825
-		$cle = substr($c,0,$p);
3826
-		$c = substr($c,$p+1);
3824
+	if ($p = strpos($c, ":")) {
3825
+		$cle = substr($c, 0, $p);
3826
+		$c = substr($c, $p + 1);
3827 3827
 
3828
-		if ($cle == calculer_cle_action($form . $c)) {
3828
+		if ($cle == calculer_cle_action($form.$c)) {
3829 3829
 			$env = @unserialize($c);
3830 3830
 			return $env;
3831 3831
 		}
@@ -3926,9 +3926,9 @@  discard block
 block discarded – undo
3926 3926
 	} else {
3927 3927
 		$bal = 'a';
3928 3928
 		$att = "href='$url'"
3929
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
3930
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
3931
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3929
+			. ($title ? " title='".attribut_html($title)."'" : '')
3930
+			. ($class ? " class='".attribut_html($class)."'" : '')
3931
+			. ($rel ? " rel='".attribut_html($rel)."'" : '')
3932 3932
 			. $evt;
3933 3933
 	}
3934 3934
 	if ($libelle === null) {
@@ -4003,7 +4003,7 @@  discard block
 block discarded – undo
4003 4003
 	}
4004 4004
 
4005 4005
 	// ajouter le type d'objet dans la class de l'icone
4006
-	$class .= " " . substr(basename($fond), 0, -4);
4006
+	$class .= " ".substr(basename($fond), 0, -4);
4007 4007
 
4008 4008
 	$alt = attribut_html($texte);
4009 4009
 	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
@@ -4027,7 +4027,7 @@  discard block
 block discarded – undo
4027 4027
 	}
4028 4028
 
4029 4029
 	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4030
-	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
4030
+	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "")."\">$icone</span>";
4031 4031
 
4032 4032
 	if ($type == 'lien') {
4033 4033
 		return "<span class='icone s$size $class'>"
@@ -4257,13 +4257,13 @@  discard block
 block discarded – undo
4257 4257
 	$res = "";
4258 4258
 	foreach ($boutons as $page => $detail) {
4259 4259
 		if ($detail->icone and strlen(trim($detail->icone))) {
4260
-			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4260
+			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(".$detail->icone.");}";
4261 4261
 		}
4262 4262
 		$selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4263 4263
 		if (is_array($detail->sousmenu)) {
4264 4264
 			foreach ($detail->sousmenu as $souspage => $sousdetail) {
4265 4265
 				if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4266
-					$res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4266
+					$res .= "\n$selecteur.bando2_$souspage {background-image:url(".$sousdetail->icone.");}";
4267 4267
 				}
4268 4268
 			}
4269 4269
 		}
@@ -4289,17 +4289,17 @@  discard block
 block discarded – undo
4289 4289
  */
4290 4290
 function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") {
4291 4291
 	if ($confirm) {
4292
-		$confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4292
+		$confirm = "confirm(\"".attribut_html($confirm)."\")";
4293 4293
 		if ($callback) {
4294 4294
 			$callback = "$confirm?($callback):false";
4295 4295
 		} else {
4296 4296
 			$callback = $confirm;
4297 4297
 		}
4298 4298
 	}
4299
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4299
+	$onclick = $callback ? " onclick='return ".addcslashes($callback, "'")."'" : "";
4300 4300
 	$title = $title ? " title='$title'" : "";
4301 4301
 
4302
-	return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4302
+	return "<form class='bouton_action_post $class' method='post' action='$url'><div>".form_hidden($url)
4303 4303
 	. "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4304 4304
 }
4305 4305
 
@@ -4360,14 +4360,14 @@  discard block
 block discarded – undo
4360 4360
 		$champ_titre = "";
4361 4361
 		if ($demande_titre) {
4362 4362
 			// si pas de titre declare mais champ titre, il sera peuple par le select *
4363
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4363
+			$champ_titre = (!empty($desc['titre'])) ? ', '.$desc['titre'] : '';
4364 4364
 		}
4365 4365
 		include_spip('base/abstract_sql');
4366 4366
 		include_spip('base/connect_sql');
4367 4367
 		$objets[$type_objet][$id_objet] = sql_fetsel(
4368
-			'*' . $champ_titre,
4368
+			'*'.$champ_titre,
4369 4369
 			$desc['table_sql'],
4370
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4370
+			id_table_objet($type_objet).' = '.intval($id_objet)
4371 4371
 		);
4372 4372
 	}
4373 4373
 
@@ -4437,7 +4437,7 @@  discard block
 block discarded – undo
4437 4437
 		return $texte;
4438 4438
 	}
4439 4439
 
4440
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4440
+	$traitement = str_replace('%s', "'".texte_script($texte)."'", $traitement);
4441 4441
 
4442 4442
 	// Fournir $connect et $Pile[0] au traitement si besoin
4443 4443
 	$Pile = array(0 => $env);
@@ -4471,7 +4471,7 @@  discard block
 block discarded – undo
4471 4471
 	}
4472 4472
 	$url = generer_url_entite($id_objet, $objet, '', '', $connect);
4473 4473
 
4474
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4474
+	return "<a href='$url' class='$objet'>".couper($titre, $longueur)."</a>";
4475 4475
 }
4476 4476
 
4477 4477
 
@@ -4490,10 +4490,10 @@  discard block
 block discarded – undo
4490 4490
 function wrap($texte, $wrap) {
4491 4491
 	$balises = extraire_balises($wrap);
4492 4492
 	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4493
-		$texte = $wrap . $texte;
4493
+		$texte = $wrap.$texte;
4494 4494
 		$regs = array_reverse($regs[1]);
4495
-		$wrap = "</" . implode("></", $regs) . ">";
4496
-		$texte = $texte . $wrap;
4495
+		$wrap = "</".implode("></", $regs).">";
4496
+		$texte = $texte.$wrap;
4497 4497
 	}
4498 4498
 
4499 4499
 	return $texte;
@@ -4524,7 +4524,7 @@  discard block
 block discarded – undo
4524 4524
 
4525 4525
 	// caster $u en array si besoin
4526 4526
 	if (is_object($u)) {
4527
-		$u = (array)$u;
4527
+		$u = (array) $u;
4528 4528
 	}
4529 4529
 
4530 4530
 	if (is_array($u)) {
@@ -4545,7 +4545,7 @@  discard block
 block discarded – undo
4545 4545
 		// sinon on passe a la ligne et on indente
4546 4546
 		$i_str = str_pad("", $indent, " ");
4547 4547
 		foreach ($u as $k => $v) {
4548
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4548
+			$out .= $join.$i_str."$k: ".filtre_print_dist($v, $join, $indent + 2);
4549 4549
 		}
4550 4550
 
4551 4551
 		return $out;
@@ -4598,8 +4598,8 @@  discard block
 block discarded – undo
4598 4598
  * @param string $class
4599 4599
  * @return string
4600 4600
  */
4601
-function objet_icone($objet, $taille = 24, $class='') {
4602
-	$icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4601
+function objet_icone($objet, $taille = 24, $class = '') {
4602
+	$icone = objet_info($objet, 'icone_objet')."-".$taille.".png";
4603 4603
 	$icone = chemin_image($icone);
4604 4604
 	$balise_img = charger_filtre('balise_img');
4605 4605
 
@@ -4623,12 +4623,12 @@  discard block
 block discarded – undo
4623 4623
  * @param array $options
4624 4624
  * @return string
4625 4625
  */
4626
-function objet_T($objet, $chaine, $args = array(), $options = array()){
4627
-	$chaine = explode(':',$chaine);
4628
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4626
+function objet_T($objet, $chaine, $args = array(), $options = array()) {
4627
+	$chaine = explode(':', $chaine);
4628
+	if ($t = _T($objet.':'.end($chaine), $args, array_merge($options, array('force'=>false)))) {
4629 4629
 		return $t;
4630 4630
 	}
4631
-	$chaine = implode(':',$chaine);
4631
+	$chaine = implode(':', $chaine);
4632 4632
 	return _T($chaine, $args, $options);
4633 4633
 }
4634 4634
 
@@ -4688,7 +4688,7 @@  discard block
 block discarded – undo
4688 4688
 	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4689 4689
 
4690 4690
 	// calculer le nom de la css
4691
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4691
+	$dir_var = sous_repertoire(_DIR_VAR, 'cache-'.$extension);
4692 4692
 	$nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4693 4693
 	$contexte_implicite = calculer_contexte_implicite();
4694 4694
 
@@ -4696,22 +4696,22 @@  discard block
 block discarded – undo
4696 4696
 	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4697 4697
 	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4698 4698
 	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4699
-		$hash = md5($contexte_implicite['host'] . '::'. $cache);
4699
+		$hash = md5($contexte_implicite['host'].'::'.$cache);
4700 4700
 	}
4701 4701
 	else {
4702 4702
 		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4703 4703
 		ksort($contexte);
4704
-		$hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4704
+		$hash = md5($fond.json_encode($contexte_implicite).json_encode($contexte).$connect);
4705 4705
 	}
4706
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4706
+	$filename = $dir_var.$extension."dyn-$nom_safe-".substr($hash, 0, 8).".$extension";
4707 4707
 
4708 4708
 	// mettre a jour le fichier si il n'existe pas
4709 4709
 	// ou trop ancien
4710 4710
 	// le dernier fichier produit est toujours suffixe par .last
4711 4711
 	// et recopie sur le fichier cible uniquement si il change
4712 4712
 	if (!file_exists($filename)
4713
-		or !file_exists($filename . ".last")
4714
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4713
+		or !file_exists($filename.".last")
4714
+		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename.".last") < $cache['lastmodified'])
4715 4715
 		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4716 4716
 	) {
4717 4717
 		$contenu = $cache['texte'];
@@ -4730,10 +4730,10 @@  discard block
 block discarded – undo
4730 4730
 			}
4731 4731
 			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4732 4732
 			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4733
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
4733
+			$comment .= "}\n   md5:".md5($contenu)." */\n";
4734 4734
 		}
4735 4735
 		// et ecrire le fichier si il change
4736
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4736
+		ecrire_fichier_calcule_si_modifie($filename, $comment.$contenu, false, true);
4737 4737
 	}
4738 4738
 
4739 4739
 	return timestamp($filename);
@@ -4928,11 +4928,11 @@  discard block
 block discarded – undo
4928 4928
 function spip_affiche_mot_de_passe_masque($passe, $afficher_partiellement = false, $portion_pourcent = null) {
4929 4929
 	$l = strlen($passe);
4930 4930
 
4931
-	if ($l<=8 or !$afficher_partiellement){
4931
+	if ($l <= 8 or !$afficher_partiellement) {
4932 4932
 		if (!$l) {
4933 4933
 			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
4934 4934
 		}
4935
-		return str_pad('',$afficher_partiellement ? $l : 16,'*');
4935
+		return str_pad('', $afficher_partiellement ? $l : 16, '*');
4936 4936
 	}
4937 4937
 
4938 4938
 	if (is_null($portion_pourcent)) {
@@ -4946,9 +4946,9 @@  discard block
 block discarded – undo
4946 4946
 	}
4947 4947
 	$e = intval(ceil($l * $portion_pourcent / 100 / 2));
4948 4948
 	$e = max($e, 0);
4949
-	$mid = str_pad('',$l-2*$e,'*');
4950
-	if ($e>0 and strlen($mid)>8){
4949
+	$mid = str_pad('', $l - 2 * $e, '*');
4950
+	if ($e > 0 and strlen($mid) > 8) {
4951 4951
 		$mid = '***...***';
4952 4952
 	}
4953
-	return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
4953
+	return substr($passe, 0, $e).$mid.($e > 0 ? substr($passe, -$e) : '');
4954 4954
 }
4955 4955
\ No newline at end of file
Please login to merge, or discard this patch.
ecrire/inc/utils.php 2 patches
Indentation   +2242 added lines, -2243 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 
@@ -48,63 +48,63 @@  discard block
 block discarded – undo
48 48
  *     Nom de la fonction, ou false.
49 49
  */
50 50
 function charger_fonction($nom, $dossier = 'exec', $continue = false) {
51
-	static $echecs = array();
52
-
53
-	if (strlen($dossier) and substr($dossier, -1) != '/') {
54
-		$dossier .= '/';
55
-	}
56
-	$f = str_replace('/', '_', $dossier) . $nom;
57
-
58
-	if (function_exists($f)) {
59
-		return $f;
60
-	}
61
-	if (function_exists($g = $f . '_dist')) {
62
-		return $g;
63
-	}
64
-
65
-	if (isset($echecs[$f])) {
66
-		return $echecs[$f];
67
-	}
68
-	// Sinon charger le fichier de declaration si plausible
69
-
70
-	if (!preg_match(',^\w+$,', $f)) {
71
-		if ($continue) {
72
-			return false;
73
-		} //appel interne, on passe
74
-		include_spip('inc/minipres');
75
-		echo minipres();
76
-		exit;
77
-	}
78
-
79
-	// passer en minuscules (cf les balises de formulaires)
80
-	// et inclure le fichier
81
-	if (!$inc = include_spip($dossier . ($d = strtolower($nom)))
82
-		// si le fichier truc/machin/nom.php n'existe pas,
83
-		// la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions
84
-		and strlen(dirname($dossier)) and dirname($dossier) != '.'
85
-	) {
86
-		include_spip(substr($dossier, 0, -1));
87
-	}
88
-	if (function_exists($f)) {
89
-		return $f;
90
-	}
91
-	if (function_exists($g)) {
92
-		return $g;
93
-	}
94
-
95
-	if ($continue) {
96
-		return $echecs[$f] = false;
97
-	}
98
-
99
-	// Echec : message d'erreur
100
-	spip_log("fonction $nom ($f ou $g) indisponible" .
101
-		($inc ? "" : " (fichier $d absent de $dossier)"));
102
-
103
-	include_spip('inc/minipres');
104
-	echo minipres(_T('forum_titre_erreur'),
105
-		_T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')),
106
-		array('all_inline'=>true,'status'=>404));
107
-	exit;
51
+    static $echecs = array();
52
+
53
+    if (strlen($dossier) and substr($dossier, -1) != '/') {
54
+        $dossier .= '/';
55
+    }
56
+    $f = str_replace('/', '_', $dossier) . $nom;
57
+
58
+    if (function_exists($f)) {
59
+        return $f;
60
+    }
61
+    if (function_exists($g = $f . '_dist')) {
62
+        return $g;
63
+    }
64
+
65
+    if (isset($echecs[$f])) {
66
+        return $echecs[$f];
67
+    }
68
+    // Sinon charger le fichier de declaration si plausible
69
+
70
+    if (!preg_match(',^\w+$,', $f)) {
71
+        if ($continue) {
72
+            return false;
73
+        } //appel interne, on passe
74
+        include_spip('inc/minipres');
75
+        echo minipres();
76
+        exit;
77
+    }
78
+
79
+    // passer en minuscules (cf les balises de formulaires)
80
+    // et inclure le fichier
81
+    if (!$inc = include_spip($dossier . ($d = strtolower($nom)))
82
+        // si le fichier truc/machin/nom.php n'existe pas,
83
+        // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions
84
+        and strlen(dirname($dossier)) and dirname($dossier) != '.'
85
+    ) {
86
+        include_spip(substr($dossier, 0, -1));
87
+    }
88
+    if (function_exists($f)) {
89
+        return $f;
90
+    }
91
+    if (function_exists($g)) {
92
+        return $g;
93
+    }
94
+
95
+    if ($continue) {
96
+        return $echecs[$f] = false;
97
+    }
98
+
99
+    // Echec : message d'erreur
100
+    spip_log("fonction $nom ($f ou $g) indisponible" .
101
+        ($inc ? "" : " (fichier $d absent de $dossier)"));
102
+
103
+    include_spip('inc/minipres');
104
+    echo minipres(_T('forum_titre_erreur'),
105
+        _T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')),
106
+        array('all_inline'=>true,'status'=>404));
107
+    exit;
108 108
 }
109 109
 
110 110
 /**
@@ -114,17 +114,17 @@  discard block
 block discarded – undo
114 114
  * @return bool
115 115
  */
116 116
 function include_once_check($file) {
117
-	if (file_exists($file)) {
118
-		include_once $file;
117
+    if (file_exists($file)) {
118
+        include_once $file;
119 119
 
120
-		return true;
121
-	}
122
-	$crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : '');
123
-	$crash = ($crash ? $crash : array());
124
-	$crash[$file] = true;
125
-	ecrire_meta('message_crash_plugins', serialize($crash));
120
+        return true;
121
+    }
122
+    $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : '');
123
+    $crash = ($crash ? $crash : array());
124
+    $crash[$file] = true;
125
+    ecrire_meta('message_crash_plugins', serialize($crash));
126 126
 
127
-	return false;
127
+    return false;
128 128
 }
129 129
 
130 130
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
  *     - string : chemin du fichier trouvé
149 149
  **/
150 150
 function include_spip($f, $include = true) {
151
-	return find_in_path($f . '.php', '', $include);
151
+    return find_in_path($f . '.php', '', $include);
152 152
 }
153 153
 
154 154
 /**
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
  *     - string : chemin du fichier trouvé
169 169
  **/
170 170
 function require_spip($f) {
171
-	return find_in_path($f . '.php', '', 'required');
171
+    return find_in_path($f . '.php', '', 'required');
172 172
 }
173 173
 
174 174
 
@@ -177,26 +177,26 @@  discard block
 block discarded – undo
177 177
  * quand on a besoin dans le PHP de filtres/fonctions qui y sont definis
178 178
  */
179 179
 function include_fichiers_fonctions() {
180
-	static $done = false;
181
-	if (!$done) {
182
-		include_spip('inc/lang');
180
+    static $done = false;
181
+    if (!$done) {
182
+        include_spip('inc/lang');
183 183
 
184
-		// NB: mes_fonctions peut initialiser $dossier_squelettes (old-style)
185
-		// donc il faut l'inclure "en globals"
186
-		if ($f = find_in_path('mes_fonctions.php')) {
187
-			global $dossier_squelettes;
188
-			include_once(_ROOT_CWD . $f);
189
-		}
184
+        // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style)
185
+        // donc il faut l'inclure "en globals"
186
+        if ($f = find_in_path('mes_fonctions.php')) {
187
+            global $dossier_squelettes;
188
+            include_once(_ROOT_CWD . $f);
189
+        }
190 190
 
191
-		if (@is_readable(_CACHE_PLUGINS_FCT)) {
192
-			// chargement optimise precompile
193
-			include_once(_CACHE_PLUGINS_FCT);
194
-		}
195
-		if (test_espace_prive()) {
196
-			include_spip('inc/filtres_ecrire');
197
-		}
198
-		$done = true;
199
-	}
191
+        if (@is_readable(_CACHE_PLUGINS_FCT)) {
192
+            // chargement optimise precompile
193
+            include_once(_CACHE_PLUGINS_FCT);
194
+        }
195
+        if (test_espace_prive()) {
196
+            include_spip('inc/filtres_ecrire');
197
+        }
198
+        $done = true;
199
+    }
200 200
 }
201 201
 
202 202
 /**
@@ -222,22 +222,22 @@  discard block
 block discarded – undo
222 222
  *     Les paramètres du pipeline modifiés
223 223
  **/
224 224
 function minipipe($fonc, &$val) {
225
-	// fonction
226
-	if (function_exists($fonc)) {
227
-		$val = call_user_func($fonc, $val);
228
-	} // Class::Methode
229
-	else {
230
-		if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs)
231
-			and $methode = array($regs[1], $regs[2])
232
-			and is_callable($methode)
233
-		) {
234
-			$val = call_user_func($methode, $val);
235
-		} else {
236
-			spip_log("Erreur - '$fonc' non definie !");
237
-		}
238
-	}
225
+    // fonction
226
+    if (function_exists($fonc)) {
227
+        $val = call_user_func($fonc, $val);
228
+    } // Class::Methode
229
+    else {
230
+        if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs)
231
+            and $methode = array($regs[1], $regs[2])
232
+            and is_callable($methode)
233
+        ) {
234
+            $val = call_user_func($methode, $val);
235
+        } else {
236
+            spip_log("Erreur - '$fonc' non definie !");
237
+        }
238
+    }
239 239
 
240
-	return $val;
240
+    return $val;
241 241
 }
242 242
 
243 243
 /**
@@ -268,45 +268,45 @@  discard block
 block discarded – undo
268 268
  *     Résultat
269 269
  */
270 270
 function pipeline($action, $val = null) {
271
-	static $charger;
272
-
273
-	// chargement initial des fonctions mises en cache, ou generation du cache
274
-	if (!$charger) {
275
-		if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) {
276
-			include_spip('inc/plugin');
277
-			// generer les fichiers php precompiles
278
-			// de chargement des plugins et des pipelines
279
-			actualise_plugins_actifs();
280
-			if (!($ok = @is_readable($charger))) {
281
-				spip_log("fichier $charger pas cree");
282
-			}
283
-		}
284
-
285
-		if ($ok) {
286
-			include_once $charger;
287
-		}
288
-	}
289
-
290
-	// appliquer notre fonction si elle existe
291
-	$fonc = 'execute_pipeline_' . strtolower($action);
292
-	if (function_exists($fonc)) {
293
-		$val = $fonc($val);
294
-	} // plantage ?
295
-	else {
296
-		spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR);
297
-	}
298
-
299
-	// si le flux est une table avec 2 cle args&data
300
-	// on ne ressort du pipe que les donnees dans 'data'
301
-	// array_key_exists pour php 4.1.0
302
-	if (is_array($val)
303
-		and count($val) == 2
304
-		and (array_key_exists('data', $val))
305
-	) {
306
-		$val = $val['data'];
307
-	}
308
-
309
-	return $val;
271
+    static $charger;
272
+
273
+    // chargement initial des fonctions mises en cache, ou generation du cache
274
+    if (!$charger) {
275
+        if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) {
276
+            include_spip('inc/plugin');
277
+            // generer les fichiers php precompiles
278
+            // de chargement des plugins et des pipelines
279
+            actualise_plugins_actifs();
280
+            if (!($ok = @is_readable($charger))) {
281
+                spip_log("fichier $charger pas cree");
282
+            }
283
+        }
284
+
285
+        if ($ok) {
286
+            include_once $charger;
287
+        }
288
+    }
289
+
290
+    // appliquer notre fonction si elle existe
291
+    $fonc = 'execute_pipeline_' . strtolower($action);
292
+    if (function_exists($fonc)) {
293
+        $val = $fonc($val);
294
+    } // plantage ?
295
+    else {
296
+        spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR);
297
+    }
298
+
299
+    // si le flux est une table avec 2 cle args&data
300
+    // on ne ressort du pipe que les donnees dans 'data'
301
+    // array_key_exists pour php 4.1.0
302
+    if (is_array($val)
303
+        and count($val) == 2
304
+        and (array_key_exists('data', $val))
305
+    ) {
306
+        $val = $val['data'];
307
+    }
308
+
309
+    return $val;
310 310
 }
311 311
 
312 312
 /**
@@ -350,35 +350,35 @@  discard block
 block discarded – undo
350 350
  *     paramètre est planté pour cause de compatibilité ascendante.
351 351
  */
352 352
 function spip_log($message = null, $name = null) {
353
-	static $pre = array();
354
-	static $log;
355
-	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
356
-	if (!isset($regs[1]) or !$logname = $regs[1]) {
357
-		$logname = null;
358
-	}
359
-	if (!isset($regs[2]) or !$niveau = $regs[2]) {
360
-		$niveau = _LOG_INFO;
361
-	}
362
-
363
-	if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) {
364
-		if (!$pre) {
365
-			$pre = array(
366
-				_LOG_HS => 'HS:',
367
-				_LOG_ALERTE_ROUGE => 'ALERTE:',
368
-				_LOG_CRITIQUE => 'CRITIQUE:',
369
-				_LOG_ERREUR => 'ERREUR:',
370
-				_LOG_AVERTISSEMENT => 'WARNING:',
371
-				_LOG_INFO_IMPORTANTE => '!INFO:',
372
-				_LOG_INFO => 'info:',
373
-				_LOG_DEBUG => 'debug:'
374
-			);
375
-			$log = charger_fonction('log', 'inc');
376
-		}
377
-		if (!is_string($message)) {
378
-			$message = print_r($message, true);
379
-		}
380
-		$log($pre[$niveau] . ' ' . $message, $logname);
381
-	}
353
+    static $pre = array();
354
+    static $log;
355
+    preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
356
+    if (!isset($regs[1]) or !$logname = $regs[1]) {
357
+        $logname = null;
358
+    }
359
+    if (!isset($regs[2]) or !$niveau = $regs[2]) {
360
+        $niveau = _LOG_INFO;
361
+    }
362
+
363
+    if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) {
364
+        if (!$pre) {
365
+            $pre = array(
366
+                _LOG_HS => 'HS:',
367
+                _LOG_ALERTE_ROUGE => 'ALERTE:',
368
+                _LOG_CRITIQUE => 'CRITIQUE:',
369
+                _LOG_ERREUR => 'ERREUR:',
370
+                _LOG_AVERTISSEMENT => 'WARNING:',
371
+                _LOG_INFO_IMPORTANTE => '!INFO:',
372
+                _LOG_INFO => 'info:',
373
+                _LOG_DEBUG => 'debug:'
374
+            );
375
+            $log = charger_fonction('log', 'inc');
376
+        }
377
+        if (!is_string($message)) {
378
+            $message = print_r($message, true);
379
+        }
380
+        $log($pre[$niveau] . ' ' . $message, $logname);
381
+    }
382 382
 }
383 383
 
384 384
 /**
@@ -389,8 +389,8 @@  discard block
 block discarded – undo
389 389
  * @param array $opt Tableau d'options
390 390
  **/
391 391
 function journal($phrase, $opt = array()) {
392
-	$journal = charger_fonction('journal', 'inc');
393
-	$journal($phrase, $opt);
392
+    $journal = charger_fonction('journal', 'inc');
393
+    $journal($phrase, $opt);
394 394
 }
395 395
 
396 396
 
@@ -409,36 +409,36 @@  discard block
 block discarded – undo
409 409
  **/
410 410
 function _request($var, $c = false) {
411 411
 
412
-	if (is_array($c)) {
413
-		return isset($c[$var]) ? $c[$var] : null;
414
-	}
412
+    if (is_array($c)) {
413
+        return isset($c[$var]) ? $c[$var] : null;
414
+    }
415 415
 
416
-	if (isset($_GET[$var])) {
417
-		$a = $_GET[$var];
418
-	} elseif (isset($_POST[$var])) {
419
-		$a = $_POST[$var];
420
-	} else {
421
-		return null;
422
-	}
416
+    if (isset($_GET[$var])) {
417
+        $a = $_GET[$var];
418
+    } elseif (isset($_POST[$var])) {
419
+        $a = $_POST[$var];
420
+    } else {
421
+        return null;
422
+    }
423 423
 
424
-	// Si on est en ajax et en POST tout a ete encode
425
-	// via encodeURIComponent, il faut donc repasser
426
-	// dans le charset local...
427
-	if (defined('_AJAX')
428
-		and _AJAX
429
-		and isset($GLOBALS['meta']['charset'])
430
-		and $GLOBALS['meta']['charset'] != 'utf-8'
431
-		and is_string($a)
432
-		// check rapide mais pas fiable
433
-		and preg_match(',[\x80-\xFF],', $a)
434
-		// check fiable
435
-		and include_spip('inc/charsets')
436
-		and is_utf8($a)
437
-	) {
438
-		return importer_charset($a, 'utf-8');
439
-	}
424
+    // Si on est en ajax et en POST tout a ete encode
425
+    // via encodeURIComponent, il faut donc repasser
426
+    // dans le charset local...
427
+    if (defined('_AJAX')
428
+        and _AJAX
429
+        and isset($GLOBALS['meta']['charset'])
430
+        and $GLOBALS['meta']['charset'] != 'utf-8'
431
+        and is_string($a)
432
+        // check rapide mais pas fiable
433
+        and preg_match(',[\x80-\xFF],', $a)
434
+        // check fiable
435
+        and include_spip('inc/charsets')
436
+        and is_utf8($a)
437
+    ) {
438
+        return importer_charset($a, 'utf-8');
439
+    }
440 440
 
441
-	return $a;
441
+    return $a;
442 442
 }
443 443
 
444 444
 
@@ -456,22 +456,22 @@  discard block
 block discarded – undo
456 456
  *     - false sinon
457 457
  **/
458 458
 function set_request($var, $val = null, $c = false) {
459
-	if (is_array($c)) {
460
-		unset($c[$var]);
461
-		if ($val !== null) {
462
-			$c[$var] = $val;
463
-		}
459
+    if (is_array($c)) {
460
+        unset($c[$var]);
461
+        if ($val !== null) {
462
+            $c[$var] = $val;
463
+        }
464 464
 
465
-		return $c;
466
-	}
465
+        return $c;
466
+    }
467 467
 
468
-	unset($_GET[$var]);
469
-	unset($_POST[$var]);
470
-	if ($val !== null) {
471
-		$_GET[$var] = $val;
472
-	}
468
+    unset($_GET[$var]);
469
+    unset($_POST[$var]);
470
+    if ($val !== null) {
471
+        $_GET[$var] = $val;
472
+    }
473 473
 
474
-	return false; # n'affecte pas $c
474
+    return false; # n'affecte pas $c
475 475
 }
476 476
 
477 477
 /**
@@ -491,25 +491,25 @@  discard block
 block discarded – undo
491 491
  * @return array|mixed|string
492 492
  */
493 493
 function spip_sanitize_from_request($value, $key, $sanitize_function='entites_html') {
494
-	if (is_array($value)) {
495
-		if ($key=='*') {
496
-			$key = array_keys($value);
497
-		}
498
-		if (!is_array($key)) {
499
-			$key = [$key];
500
-		}
501
-		foreach ($key as $k) {
502
-			if (!empty($value[$k])) {
503
-				$value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function);
504
-			}
505
-		}
506
-		return $value;
507
-	}
508
-	// si la valeur vient des GET ou POST on la sanitize
509
-	if (!empty($value) and $value == _request($key)) {
510
-		$value = $sanitize_function($value);
511
-	}
512
-	return $value;
494
+    if (is_array($value)) {
495
+        if ($key=='*') {
496
+            $key = array_keys($value);
497
+        }
498
+        if (!is_array($key)) {
499
+            $key = [$key];
500
+        }
501
+        foreach ($key as $k) {
502
+            if (!empty($value[$k])) {
503
+                $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function);
504
+            }
505
+        }
506
+        return $value;
507
+    }
508
+    // si la valeur vient des GET ou POST on la sanitize
509
+    if (!empty($value) and $value == _request($key)) {
510
+        $value = $sanitize_function($value);
511
+    }
512
+    return $value;
513 513
 }
514 514
 
515 515
 /**
@@ -517,23 +517,22 @@  discard block
 block discarded – undo
517 517
  * 
518 518
  * On est sur le web, on exclut certains protocoles, 
519 519
  * notamment 'file://', 'php://' et d'autres…
520
-
521 520
  * @param string $url
522 521
  * @return bool
523 522
  */
524 523
 function tester_url_absolue($url) {
525
-	$url = trim($url);
526
-	if (preg_match(";^([a-z]{3,7}:)?//;Uims", $url, $m)) {
527
-		if (
528
-			isset($m[1])
529
-			and $p = strtolower(rtrim($m[1], ':'))
530
-			and in_array($p, array('file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip'))
531
-		  ) {
532
-			return false;
533
-		}
534
-		return true;
535
-	}
536
-	return false;
524
+    $url = trim($url);
525
+    if (preg_match(";^([a-z]{3,7}:)?//;Uims", $url, $m)) {
526
+        if (
527
+            isset($m[1])
528
+            and $p = strtolower(rtrim($m[1], ':'))
529
+            and in_array($p, array('file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip'))
530
+            ) {
531
+            return false;
532
+        }
533
+        return true;
534
+    }
535
+    return false;
537 536
 }
538 537
 
539 538
 /**
@@ -555,94 +554,94 @@  discard block
 block discarded – undo
555 554
  * @return string URL
556 555
  */
557 556
 function parametre_url($url, $c, $v = null, $sep = '&amp;') {
558
-	// requete erronnee : plusieurs variable dans $c et aucun $v
559
-	if (strpos($c, "|") !== false and is_null($v)) {
560
-		return null;
561
-	}
562
-
563
-	// lever l'#ancre
564
-	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
565
-		$url = $r[1];
566
-		$ancre = $r[2];
567
-	} else {
568
-		$ancre = '';
569
-	}
570
-
571
-	// eclater
572
-	$url = preg_split(',[?]|&amp;|&,', $url);
573
-
574
-	// recuperer la base
575
-	$a = array_shift($url);
576
-	if (!$a) {
577
-		$a = './';
578
-	}
579
-
580
-	$regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,';
581
-	$ajouts = array_flip(explode('|', $c));
582
-	$u = is_array($v) ? $v : rawurlencode($v);
583
-	$testv = (is_array($v) ? count($v) : strlen($v));
584
-	$v_read = null;
585
-	// lire les variables et agir
586
-	foreach ($url as $n => $val) {
587
-		if (preg_match($regexp, urldecode($val), $r)) {
588
-			$r = array_pad($r, 3, null);
589
-			if ($v === null) {
590
-				// c'est un tableau, on memorise les valeurs
591
-				if (substr($r[1], -2) == "[]") {
592
-					if (!$v_read) {
593
-						$v_read = array();
594
-					}
595
-					$v_read[] = $r[2] ? substr($r[2], 1) : '';
596
-				} // c'est un scalaire, on retourne direct
597
-				else {
598
-					return $r[2] ? substr($r[2], 1) : '';
599
-				}
600
-			} // suppression
601
-			elseif (!$testv) {
602
-				unset($url[$n]);
603
-			}
604
-			// Ajout. Pour une variable, remplacer au meme endroit,
605
-			// pour un tableau ce sera fait dans la prochaine boucle
606
-			elseif (substr($r[1], -2) != '[]') {
607
-				$url[$n] = $r[1] . '=' . $u;
608
-				unset($ajouts[$r[1]]);
609
-			}
610
-			// Pour les tableaux on laisse tomber les valeurs de
611
-			// départ, on remplira à l'étape suivante
612
-			else {
613
-				unset($url[$n]);
614
-			}
615
-		}
616
-	}
617
-
618
-	// traiter les parametres pas encore trouves
619
-	if ($v === null
620
-		and $args = func_get_args()
621
-		and count($args) == 2
622
-	) {
623
-		return $v_read; // rien trouve ou un tableau
624
-	} elseif ($testv) {
625
-		foreach ($ajouts as $k => $n) {
626
-			if (!is_array($v)) {
627
-				$url[] = $k . '=' . $u;
628
-			} else {
629
-				$id = (substr($k, -2) == '[]') ? $k : ($k . "[]");
630
-				foreach ($v as $w) {
631
-					$url[] = $id . '=' . (is_array($w) ? 'Array' : $w);
632
-				}
633
-			}
634
-		}
635
-	}
636
-
637
-	// eliminer les vides
638
-	$url = array_filter($url);
639
-
640
-	// recomposer l'adresse
641
-	if ($url) {
642
-		$a .= '?' . join($sep, $url);
643
-	}
644
-
645
-	return $a . $ancre;
557
+    // requete erronnee : plusieurs variable dans $c et aucun $v
558
+    if (strpos($c, "|") !== false and is_null($v)) {
559
+        return null;
560
+    }
561
+
562
+    // lever l'#ancre
563
+    if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
564
+        $url = $r[1];
565
+        $ancre = $r[2];
566
+    } else {
567
+        $ancre = '';
568
+    }
569
+
570
+    // eclater
571
+    $url = preg_split(',[?]|&amp;|&,', $url);
572
+
573
+    // recuperer la base
574
+    $a = array_shift($url);
575
+    if (!$a) {
576
+        $a = './';
577
+    }
578
+
579
+    $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,';
580
+    $ajouts = array_flip(explode('|', $c));
581
+    $u = is_array($v) ? $v : rawurlencode($v);
582
+    $testv = (is_array($v) ? count($v) : strlen($v));
583
+    $v_read = null;
584
+    // lire les variables et agir
585
+    foreach ($url as $n => $val) {
586
+        if (preg_match($regexp, urldecode($val), $r)) {
587
+            $r = array_pad($r, 3, null);
588
+            if ($v === null) {
589
+                // c'est un tableau, on memorise les valeurs
590
+                if (substr($r[1], -2) == "[]") {
591
+                    if (!$v_read) {
592
+                        $v_read = array();
593
+                    }
594
+                    $v_read[] = $r[2] ? substr($r[2], 1) : '';
595
+                } // c'est un scalaire, on retourne direct
596
+                else {
597
+                    return $r[2] ? substr($r[2], 1) : '';
598
+                }
599
+            } // suppression
600
+            elseif (!$testv) {
601
+                unset($url[$n]);
602
+            }
603
+            // Ajout. Pour une variable, remplacer au meme endroit,
604
+            // pour un tableau ce sera fait dans la prochaine boucle
605
+            elseif (substr($r[1], -2) != '[]') {
606
+                $url[$n] = $r[1] . '=' . $u;
607
+                unset($ajouts[$r[1]]);
608
+            }
609
+            // Pour les tableaux on laisse tomber les valeurs de
610
+            // départ, on remplira à l'étape suivante
611
+            else {
612
+                unset($url[$n]);
613
+            }
614
+        }
615
+    }
616
+
617
+    // traiter les parametres pas encore trouves
618
+    if ($v === null
619
+        and $args = func_get_args()
620
+        and count($args) == 2
621
+    ) {
622
+        return $v_read; // rien trouve ou un tableau
623
+    } elseif ($testv) {
624
+        foreach ($ajouts as $k => $n) {
625
+            if (!is_array($v)) {
626
+                $url[] = $k . '=' . $u;
627
+            } else {
628
+                $id = (substr($k, -2) == '[]') ? $k : ($k . "[]");
629
+                foreach ($v as $w) {
630
+                    $url[] = $id . '=' . (is_array($w) ? 'Array' : $w);
631
+                }
632
+            }
633
+        }
634
+    }
635
+
636
+    // eliminer les vides
637
+    $url = array_filter($url);
638
+
639
+    // recomposer l'adresse
640
+    if ($url) {
641
+        $a .= '?' . join($sep, $url);
642
+    }
643
+
644
+    return $a . $ancre;
646 645
 }
647 646
 
648 647
 /**
@@ -660,21 +659,21 @@  discard block
 block discarded – undo
660 659
  * @return string
661 660
  */
662 661
 function ancre_url($url, $ancre) {
663
-	// lever l'#ancre
664
-	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
665
-		$url = $r[1];
666
-	}
667
-	if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
668
-		if (!function_exists('translitteration')) {
669
-			include_spip('inc/charsets');
670
-		}
671
-		$ancre = preg_replace(
672
-			array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'),
673
-			array('', '-'),
674
-			translitteration($ancre)
675
-		);
676
-	}
677
-	return $url . (strlen($ancre) ? '#' . $ancre : '');
662
+    // lever l'#ancre
663
+    if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
664
+        $url = $r[1];
665
+    }
666
+    if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
667
+        if (!function_exists('translitteration')) {
668
+            include_spip('inc/charsets');
669
+        }
670
+        $ancre = preg_replace(
671
+            array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'),
672
+            array('', '-'),
673
+            translitteration($ancre)
674
+        );
675
+    }
676
+    return $url . (strlen($ancre) ? '#' . $ancre : '');
678 677
 }
679 678
 
680 679
 /**
@@ -684,16 +683,16 @@  discard block
 block discarded – undo
684 683
  * @return string
685 684
  */
686 685
 function nettoyer_uri($reset = null) {
687
-	static $done = false;
688
-	static $propre = '';
689
-	if (!is_null($reset)) {
690
-		return $propre = $reset;
691
-	}
692
-	if ($done) {
693
-		return $propre;
694
-	}
695
-	$done = true;
696
-	return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);
686
+    static $done = false;
687
+    static $propre = '';
688
+    if (!is_null($reset)) {
689
+        return $propre = $reset;
690
+    }
691
+    if ($done) {
692
+        return $propre;
693
+    }
694
+    $done = true;
695
+    return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);
697 696
 }
698 697
 
699 698
 /**
@@ -705,13 +704,13 @@  discard block
 block discarded – undo
705 704
  * @return string
706 705
  */
707 706
 function nettoyer_uri_var($request_uri) {
708
-	$uri1 = $request_uri;
709
-	do {
710
-		$uri = $uri1;
711
-		$uri1 = preg_replace(',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i',
712
-			'\1', $uri);
713
-	} while ($uri <> $uri1);
714
-	return preg_replace(',[?&]$,', '', $uri1);
707
+    $uri1 = $request_uri;
708
+    do {
709
+        $uri = $uri1;
710
+        $uri1 = preg_replace(',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i',
711
+            '\1', $uri);
712
+    } while ($uri <> $uri1);
713
+    return preg_replace(',[?&]$,', '', $uri1);
715 714
 }
716 715
 
717 716
 
@@ -725,47 +724,47 @@  discard block
 block discarded – undo
725 724
  *    URL vers soi-même
726 725
  **/
727 726
 function self($amp = '&amp;', $root = false) {
728
-	$url = nettoyer_uri();
729
-	if (!$root
730
-		and (
731
-			// si pas de profondeur on peut tronquer
732
-			$GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
733
-			// sinon c'est OK si _SET_HTML_BASE a ete force a false
734
-			or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE))
735
-	) {
736
-		$url = preg_replace(',^[^?]*/,', '', $url);
737
-	}
738
-	// ajouter le cas echeant les variables _POST['id_...']
739
-	foreach ($_POST as $v => $c) {
740
-		if (substr($v, 0, 3) == 'id_') {
741
-			$url = parametre_url($url, $v, $c, '&');
742
-		}
743
-	}
744
-
745
-	// supprimer les variables sans interet
746
-	if (test_espace_prive()) {
747
-		$url = preg_replace(',([?&])('
748
-			. 'lang|show_docs|'
749
-			. 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
750
-		$url = preg_replace(',([?&])[&]+,', '\1', $url);
751
-		$url = preg_replace(',[&]$,', '\1', $url);
752
-	}
753
-
754
-	// eviter les hacks
755
-	include_spip('inc/filtres_mini');
756
-	$url = spip_htmlspecialchars($url);
727
+    $url = nettoyer_uri();
728
+    if (!$root
729
+        and (
730
+            // si pas de profondeur on peut tronquer
731
+            $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
732
+            // sinon c'est OK si _SET_HTML_BASE a ete force a false
733
+            or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE))
734
+    ) {
735
+        $url = preg_replace(',^[^?]*/,', '', $url);
736
+    }
737
+    // ajouter le cas echeant les variables _POST['id_...']
738
+    foreach ($_POST as $v => $c) {
739
+        if (substr($v, 0, 3) == 'id_') {
740
+            $url = parametre_url($url, $v, $c, '&');
741
+        }
742
+    }
743
+
744
+    // supprimer les variables sans interet
745
+    if (test_espace_prive()) {
746
+        $url = preg_replace(',([?&])('
747
+            . 'lang|show_docs|'
748
+            . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
749
+        $url = preg_replace(',([?&])[&]+,', '\1', $url);
750
+        $url = preg_replace(',[&]$,', '\1', $url);
751
+    }
752
+
753
+    // eviter les hacks
754
+    include_spip('inc/filtres_mini');
755
+    $url = spip_htmlspecialchars($url);
757 756
 	
758
-	$url = str_replace(array("'", '"', '<', '[', ']', ':'), array('%27', '%22', '%3C', '%5B', '%5D', '%3A'), $url);
757
+    $url = str_replace(array("'", '"', '<', '[', ']', ':'), array('%27', '%22', '%3C', '%5B', '%5D', '%3A'), $url);
759 758
 
760
-	// &amp; ?
761
-	if ($amp != '&amp;') {
762
-		$url = str_replace('&amp;', $amp, $url);
763
-	}
759
+    // &amp; ?
760
+    if ($amp != '&amp;') {
761
+        $url = str_replace('&amp;', $amp, $url);
762
+    }
764 763
 
765
-	// Si ca demarre par ? ou vide, donner './'
766
-	$url = preg_replace(',^([?].*)?$,', './\1', $url);
764
+    // Si ca demarre par ? ou vide, donner './'
765
+    $url = preg_replace(',^([?].*)?$,', './\1', $url);
767 766
 
768
-	return $url;
767
+    return $url;
769 768
 }
770 769
 
771 770
 
@@ -776,7 +775,7 @@  discard block
 block discarded – undo
776 775
  *     true si c'est le cas, false sinon.
777 776
  */
778 777
 function test_espace_prive() {
779
-	return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false;
778
+    return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false;
780 779
 }
781 780
 
782 781
 /**
@@ -786,7 +785,7 @@  discard block
 block discarded – undo
786 785
  * @return bool
787 786
  */
788 787
 function test_plugin_actif($plugin) {
789
-	return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
788
+    return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
790 789
 }
791 790
 
792 791
 /**
@@ -817,51 +816,51 @@  discard block
 block discarded – undo
817 816
  *     Texte
818 817
  */
819 818
 function _T($texte, $args = array(), $options = array()) {
820
-	static $traduire = false;
821
-	$o = array('class' => '', 'force' => true, 'sanitize' => true);
822
-	if ($options) {
823
-		// support de l'ancien argument $class
824
-		if (is_string($options)) {
825
-			$options = array('class' => $options);
826
-		}
827
-		$o = array_merge($o, $options);
828
-	}
819
+    static $traduire = false;
820
+    $o = array('class' => '', 'force' => true, 'sanitize' => true);
821
+    if ($options) {
822
+        // support de l'ancien argument $class
823
+        if (is_string($options)) {
824
+            $options = array('class' => $options);
825
+        }
826
+        $o = array_merge($o, $options);
827
+    }
829 828
 
830
-	if (!$traduire) {
831
-		$traduire = charger_fonction('traduire', 'inc');
832
-		include_spip('inc/lang');
833
-	}
829
+    if (!$traduire) {
830
+        $traduire = charger_fonction('traduire', 'inc');
831
+        include_spip('inc/lang');
832
+    }
834 833
 
835
-	// On peut passer explicitement la langue dans le tableau
836
-	// On utilise le même nom de variable que la globale
837
-	if (isset($args['spip_lang'])) {
838
-		$lang = $args['spip_lang'];
839
-		// On l'enleve pour ne pas le passer au remplacement
840
-		unset($args['spip_lang']);
841
-	} // Sinon on prend la langue du contexte
842
-	else {
843
-		$lang = $GLOBALS['spip_lang'];
844
-	}
845
-	$text = $traduire($texte, $lang);
834
+    // On peut passer explicitement la langue dans le tableau
835
+    // On utilise le même nom de variable que la globale
836
+    if (isset($args['spip_lang'])) {
837
+        $lang = $args['spip_lang'];
838
+        // On l'enleve pour ne pas le passer au remplacement
839
+        unset($args['spip_lang']);
840
+    } // Sinon on prend la langue du contexte
841
+    else {
842
+        $lang = $GLOBALS['spip_lang'];
843
+    }
844
+    $text = $traduire($texte, $lang);
846 845
 
847
-	if (!strlen($text)) {
848
-		if (!$o['force']) {
849
-			return '';
850
-		}
846
+    if (!strlen($text)) {
847
+        if (!$o['force']) {
848
+            return '';
849
+        }
851 850
 
852
-		$text = $texte;
851
+        $text = $texte;
853 852
 
854
-		// pour les chaines non traduites, assurer un service minimum
855
-		if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
856
-			$text = str_replace('_', ' ',
857
-				(($n = strpos($text, ':')) === false ? $texte :
858
-					substr($texte, $n + 1)));
859
-		}
860
-		$o['class'] = null;
853
+        // pour les chaines non traduites, assurer un service minimum
854
+        if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
855
+            $text = str_replace('_', ' ',
856
+                (($n = strpos($text, ':')) === false ? $texte :
857
+                    substr($texte, $n + 1)));
858
+        }
859
+        $o['class'] = null;
861 860
 
862
-	}
861
+    }
863 862
 
864
-	return _L($text, $args, $o);
863
+    return _L($text, $args, $o);
865 864
 
866 865
 }
867 866
 
@@ -889,53 +888,53 @@  discard block
 block discarded – undo
889 888
  *     Texte
890 889
  */
891 890
 function _L($text, $args = array(), $options = array()) {
892
-	$f = $text;
893
-	$defaut_options = array(
894
-		'class' => null,
895
-		'sanitize' => true,
896
-	);
897
-	// support de l'ancien argument $class
898
-	if ($options and is_string($options)) {
899
-		$options = array('class' => $options);
900
-	}
901
-	if (is_array($options)) {
902
-		$options += $defaut_options;
903
-	} else {
904
-		$options = $defaut_options;
905
-	}
906
-
907
-	if (is_array($args) and count($args)) {
908
-		if (!function_exists('interdire_scripts')) {
909
-			include_spip('inc/texte');
910
-		}
911
-		if (!function_exists('echapper_html_suspect')) {
912
-			include_spip('inc/texte_mini');
913
-		}
914
-		foreach ($args as $name => $value) {
915
-			if (strpos($text, "@$name@") !== false) {
916
-				if ($options['sanitize']) {
917
-					$value = echapper_html_suspect($value);
918
-					$value = interdire_scripts($value, -1);
919
-				}
920
-				if (!empty($options['class'])) {
921
-					$value = "<span class='".$options['class']."'>$value</span>";
922
-				}
923
-				$text = str_replace("@$name@", $value, $text);
924
-				unset($args[$name]);
925
-			}
926
-		}
927
-		// Si des variables n'ont pas ete inserees, le signaler
928
-		// (chaines de langues pas a jour)
929
-		if ($args) {
930
-			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
931
-		}
932
-	}
933
-
934
-	if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) {
935
-		return "<span class=debug-traduction-erreur>$text</span>";
936
-	} else {
937
-		return $text;
938
-	}
891
+    $f = $text;
892
+    $defaut_options = array(
893
+        'class' => null,
894
+        'sanitize' => true,
895
+    );
896
+    // support de l'ancien argument $class
897
+    if ($options and is_string($options)) {
898
+        $options = array('class' => $options);
899
+    }
900
+    if (is_array($options)) {
901
+        $options += $defaut_options;
902
+    } else {
903
+        $options = $defaut_options;
904
+    }
905
+
906
+    if (is_array($args) and count($args)) {
907
+        if (!function_exists('interdire_scripts')) {
908
+            include_spip('inc/texte');
909
+        }
910
+        if (!function_exists('echapper_html_suspect')) {
911
+            include_spip('inc/texte_mini');
912
+        }
913
+        foreach ($args as $name => $value) {
914
+            if (strpos($text, "@$name@") !== false) {
915
+                if ($options['sanitize']) {
916
+                    $value = echapper_html_suspect($value);
917
+                    $value = interdire_scripts($value, -1);
918
+                }
919
+                if (!empty($options['class'])) {
920
+                    $value = "<span class='".$options['class']."'>$value</span>";
921
+                }
922
+                $text = str_replace("@$name@", $value, $text);
923
+                unset($args[$name]);
924
+            }
925
+        }
926
+        // Si des variables n'ont pas ete inserees, le signaler
927
+        // (chaines de langues pas a jour)
928
+        if ($args) {
929
+            spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
930
+        }
931
+    }
932
+
933
+    if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) {
934
+        return "<span class=debug-traduction-erreur>$text</span>";
935
+    } else {
936
+        return $text;
937
+    }
939 938
 }
940 939
 
941 940
 
@@ -949,13 +948,13 @@  discard block
 block discarded – undo
949 948
  * @return string
950 949
  */
951 950
 function joli_repertoire($rep) {
952
-	$a = substr($rep, 0, 1);
953
-	if ($a <> '.' and $a <> '/') {
954
-		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
955
-	}
956
-	$rep = preg_replace(',(^\.\.\/),', '', $rep);
951
+    $a = substr($rep, 0, 1);
952
+    if ($a <> '.' and $a <> '/') {
953
+        $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
954
+    }
955
+    $rep = preg_replace(',(^\.\.\/),', '', $rep);
957 956
 
958
-	return $rep;
957
+    return $rep;
959 958
 }
960 959
 
961 960
 
@@ -980,33 +979,33 @@  discard block
 block discarded – undo
980 979
  * @return float|int|string|void
981 980
  */
982 981
 function spip_timer($t = 'rien', $raw = false) {
983
-	static $time;
984
-	$a = time();
985
-	$b = microtime();
986
-	// microtime peut contenir les microsecondes et le temps
987
-	$b = explode(' ', $b);
988
-	if (count($b) == 2) {
989
-		$a = end($b);
990
-	} // plus precis !
991
-	$b = reset($b);
992
-	if (!isset($time[$t])) {
993
-		$time[$t] = $a + $b;
994
-	} else {
995
-		$p = ($a + $b - $time[$t]) * 1000;
996
-		unset($time[$t]);
982
+    static $time;
983
+    $a = time();
984
+    $b = microtime();
985
+    // microtime peut contenir les microsecondes et le temps
986
+    $b = explode(' ', $b);
987
+    if (count($b) == 2) {
988
+        $a = end($b);
989
+    } // plus precis !
990
+    $b = reset($b);
991
+    if (!isset($time[$t])) {
992
+        $time[$t] = $a + $b;
993
+    } else {
994
+        $p = ($a + $b - $time[$t]) * 1000;
995
+        unset($time[$t]);
997 996
 #			echo "'$p'";exit;
998
-		if ($raw) {
999
-			return $p;
1000
-		}
1001
-		if ($p < 1000) {
1002
-			$s = '';
1003
-		} else {
1004
-			$s = sprintf("%d ", $x = floor($p / 1000));
1005
-			$p -= ($x * 1000);
1006
-		}
997
+        if ($raw) {
998
+            return $p;
999
+        }
1000
+        if ($p < 1000) {
1001
+            $s = '';
1002
+        } else {
1003
+            $s = sprintf("%d ", $x = floor($p / 1000));
1004
+            $p -= ($x * 1000);
1005
+        }
1007 1006
 
1008
-		return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p);
1009
-	}
1007
+        return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p);
1008
+    }
1010 1009
 }
1011 1010
 
1012 1011
 
@@ -1014,21 +1013,21 @@  discard block
 block discarded – undo
1014 1013
 // sinon renvoie True et le date sauf si ca n'est pas souhaite
1015 1014
 // https://code.spip.net/@spip_touch
1016 1015
 function spip_touch($fichier, $duree = 0, $touch = true) {
1017
-	if ($duree) {
1018
-		clearstatcache();
1019
-		if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) {
1020
-			return false;
1021
-		}
1022
-	}
1023
-	if ($touch !== false) {
1024
-		if (!@touch($fichier)) {
1025
-			spip_unlink($fichier);
1026
-			@touch($fichier);
1027
-		};
1028
-		@chmod($fichier, _SPIP_CHMOD & ~0111);
1029
-	}
1016
+    if ($duree) {
1017
+        clearstatcache();
1018
+        if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) {
1019
+            return false;
1020
+        }
1021
+    }
1022
+    if ($touch !== false) {
1023
+        if (!@touch($fichier)) {
1024
+            spip_unlink($fichier);
1025
+            @touch($fichier);
1026
+        };
1027
+        @chmod($fichier, _SPIP_CHMOD & ~0111);
1028
+    }
1030 1029
 
1031
-	return true;
1030
+    return true;
1032 1031
 }
1033 1032
 
1034 1033
 
@@ -1040,11 +1039,11 @@  discard block
 block discarded – undo
1040 1039
  * @uses cron()
1041 1040
  **/
1042 1041
 function action_cron() {
1043
-	include_spip('inc/headers');
1044
-	http_status(204); // No Content
1045
-	header("Connection: close");
1046
-	define('_DIRECT_CRON_FORCE', true);
1047
-	cron();
1042
+    include_spip('inc/headers');
1043
+    http_status(204); // No Content
1044
+    header("Connection: close");
1045
+    define('_DIRECT_CRON_FORCE', true);
1046
+    cron();
1048 1047
 }
1049 1048
 
1050 1049
 /**
@@ -1060,26 +1059,26 @@  discard block
 block discarded – undo
1060 1059
  *     True si la tache a pu être effectuée
1061 1060
  */
1062 1061
 function cron($taches = array(), $taches_old = array()) {
1063
-	// si pas en mode cron force, laisser tomber.
1064
-	if (!defined('_DIRECT_CRON_FORCE')) {
1065
-		return false;
1066
-	}
1067
-	if (!is_array($taches)) {
1068
-		$taches = $taches_old;
1069
-	} // compat anciens appels
1070
-	// si taches a inserer en base et base inaccessible, laisser tomber
1071
-	// sinon on ne verifie pas la connexion tout de suite, car si ca se trouve
1072
-	// queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
1073
-	// et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
1074
-	if ($taches and count($taches) and !spip_connect()) {
1075
-		return false;
1076
-	}
1077
-	spip_log("cron !", 'jq' . _LOG_DEBUG);
1078
-	if ($genie = charger_fonction('genie', 'inc', true)) {
1079
-		return $genie($taches);
1080
-	}
1081
-
1082
-	return false;
1062
+    // si pas en mode cron force, laisser tomber.
1063
+    if (!defined('_DIRECT_CRON_FORCE')) {
1064
+        return false;
1065
+    }
1066
+    if (!is_array($taches)) {
1067
+        $taches = $taches_old;
1068
+    } // compat anciens appels
1069
+    // si taches a inserer en base et base inaccessible, laisser tomber
1070
+    // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve
1071
+    // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
1072
+    // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
1073
+    if ($taches and count($taches) and !spip_connect()) {
1074
+        return false;
1075
+    }
1076
+    spip_log("cron !", 'jq' . _LOG_DEBUG);
1077
+    if ($genie = charger_fonction('genie', 'inc', true)) {
1078
+        return $genie($taches);
1079
+    }
1080
+
1081
+    return false;
1083 1082
 }
1084 1083
 
1085 1084
 /**
@@ -1111,17 +1110,17 @@  discard block
 block discarded – undo
1111 1110
  *     Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté.
1112 1111
  */
1113 1112
 function job_queue_add(
1114
-	$function,
1115
-	$description,
1116
-	$arguments = array(),
1117
-	$file = '',
1118
-	$no_duplicate = false,
1119
-	$time = 0,
1120
-	$priority = 0
1113
+    $function,
1114
+    $description,
1115
+    $arguments = array(),
1116
+    $file = '',
1117
+    $no_duplicate = false,
1118
+    $time = 0,
1119
+    $priority = 0
1121 1120
 ) {
1122
-	include_spip('inc/queue');
1121
+    include_spip('inc/queue');
1123 1122
 
1124
-	return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
1123
+    return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
1125 1124
 }
1126 1125
 
1127 1126
 /**
@@ -1132,9 +1131,9 @@  discard block
 block discarded – undo
1132 1131
  * @return bool
1133 1132
  */
1134 1133
 function job_queue_remove($id_job) {
1135
-	include_spip('inc/queue');
1134
+    include_spip('inc/queue');
1136 1135
 
1137
-	return queue_remove_job($id_job);
1136
+    return queue_remove_job($id_job);
1138 1137
 }
1139 1138
 
1140 1139
 /**
@@ -1147,9 +1146,9 @@  discard block
 block discarded – undo
1147 1146
  *     or an array of simple array to link multiples objet in one time
1148 1147
  */
1149 1148
 function job_queue_link($id_job, $objets) {
1150
-	include_spip('inc/queue');
1149
+    include_spip('inc/queue');
1151 1150
 
1152
-	return queue_link_job($id_job, $objets);
1151
+    return queue_link_job($id_job, $objets);
1153 1152
 }
1154 1153
 
1155 1154
 
@@ -1169,36 +1168,36 @@  discard block
 block discarded – undo
1169 1168
  *  - `null` si la queue n'est pas encore initialisée
1170 1169
  */
1171 1170
 function queue_sleep_time_to_next_job($force = null) {
1172
-	static $queue_next_job_time = -1;
1173
-	if ($force === true) {
1174
-		$queue_next_job_time = -1;
1175
-	} elseif ($force) {
1176
-		$queue_next_job_time = $force;
1177
-	}
1178
-
1179
-	if ($queue_next_job_time == -1) {
1180
-		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1181
-			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt");
1182
-		}
1183
-		// utiliser un cache memoire si dispo
1184
-		if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
1185
-			$queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
1186
-		} else {
1187
-			$queue_next_job_time = null;
1188
-			if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) {
1189
-				$queue_next_job_time = intval($contenu);
1190
-			}
1191
-		}
1192
-	}
1193
-
1194
-	if (is_null($queue_next_job_time)) {
1195
-		return null;
1196
-	}
1197
-	if (!$_SERVER['REQUEST_TIME']) {
1198
-		$_SERVER['REQUEST_TIME'] = time();
1199
-	}
1200
-
1201
-	return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
1171
+    static $queue_next_job_time = -1;
1172
+    if ($force === true) {
1173
+        $queue_next_job_time = -1;
1174
+    } elseif ($force) {
1175
+        $queue_next_job_time = $force;
1176
+    }
1177
+
1178
+    if ($queue_next_job_time == -1) {
1179
+        if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1180
+            define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt");
1181
+        }
1182
+        // utiliser un cache memoire si dispo
1183
+        if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
1184
+            $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
1185
+        } else {
1186
+            $queue_next_job_time = null;
1187
+            if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) {
1188
+                $queue_next_job_time = intval($contenu);
1189
+            }
1190
+        }
1191
+    }
1192
+
1193
+    if (is_null($queue_next_job_time)) {
1194
+        return null;
1195
+    }
1196
+    if (!$_SERVER['REQUEST_TIME']) {
1197
+        $_SERVER['REQUEST_TIME'] = time();
1198
+    }
1199
+
1200
+    return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
1202 1201
 }
1203 1202
 
1204 1203
 
@@ -1210,9 +1209,9 @@  discard block
 block discarded – undo
1210 1209
  * @return string
1211 1210
  */
1212 1211
 function quote_amp($u) {
1213
-	return preg_replace(
1214
-		"/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i",
1215
-		"&amp;", $u);
1212
+    return preg_replace(
1213
+        "/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i",
1214
+        "&amp;", $u);
1216 1215
 }
1217 1216
 
1218 1217
 
@@ -1235,27 +1234,27 @@  discard block
 block discarded – undo
1235 1234
  *     Balise HTML `<script>` et son contenu
1236 1235
  **/
1237 1236
 function http_script($script, $src = '', $noscript = '') {
1238
-	static $done = array();
1237
+    static $done = array();
1239 1238
 
1240
-	if ($src && !isset($done[$src])) {
1241
-		$done[$src] = true;
1242
-		$src = find_in_path($src, _JAVASCRIPT);
1243
-		$src = " src='$src'";
1244
-	} else {
1245
-		$src = '';
1246
-	}
1247
-	if ($script) {
1248
-		$script = ("/*<![CDATA[*/\n" .
1249
-			preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1250
-			"/*]]>*/");
1251
-	}
1252
-	if ($noscript) {
1253
-		$noscript = "<noscript>\n\t$noscript\n</noscript>\n";
1254
-	}
1239
+    if ($src && !isset($done[$src])) {
1240
+        $done[$src] = true;
1241
+        $src = find_in_path($src, _JAVASCRIPT);
1242
+        $src = " src='$src'";
1243
+    } else {
1244
+        $src = '';
1245
+    }
1246
+    if ($script) {
1247
+        $script = ("/*<![CDATA[*/\n" .
1248
+            preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1249
+            "/*]]>*/");
1250
+    }
1251
+    if ($noscript) {
1252
+        $noscript = "<noscript>\n\t$noscript\n</noscript>\n";
1253
+    }
1255 1254
 
1256
-	return ($src or $script or $noscript)
1257
-		? "<script type='text/javascript'$src>$script</script>$noscript"
1258
-		: '';
1255
+    return ($src or $script or $noscript)
1256
+        ? "<script type='text/javascript'$src>$script</script>$noscript"
1257
+        : '';
1259 1258
 }
1260 1259
 
1261 1260
 
@@ -1290,7 +1289,7 @@  discard block
 block discarded – undo
1290 1289
  *     Texte échappé
1291 1290
  **/
1292 1291
 function texte_script($texte) {
1293
-	return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte));
1292
+    return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte));
1294 1293
 }
1295 1294
 
1296 1295
 
@@ -1327,69 +1326,69 @@  discard block
 block discarded – undo
1327 1326
  *     Liste des chemins, par ordre de priorité.
1328 1327
  **/
1329 1328
 function _chemin($dir_path = null) {
1330
-	static $path_base = null;
1331
-	static $path_full = null;
1332
-	if ($path_base == null) {
1333
-		// Chemin standard depuis l'espace public
1334
-		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
1335
-			_DIR_RACINE . ':' .
1336
-			_DIR_RACINE . 'squelettes-dist/:' .
1337
-			_DIR_RACINE . 'prive/:' .
1338
-			_DIR_RESTREINT;
1339
-		// Ajouter squelettes/
1340
-		if (@is_dir(_DIR_RACINE . 'squelettes')) {
1341
-			$path = _DIR_RACINE . 'squelettes/:' . $path;
1342
-		}
1343
-		foreach (explode(':', $path) as $dir) {
1344
-			if (strlen($dir) and substr($dir, -1) != '/') {
1345
-				$dir .= "/";
1346
-			}
1347
-			$path_base[] = $dir;
1348
-		}
1349
-		$path_full = $path_base;
1350
-		// Et le(s) dossier(s) des squelettes nommes
1351
-		if (strlen($GLOBALS['dossier_squelettes'])) {
1352
-			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1353
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1354
-			}
1355
-		}
1356
-		$GLOBALS['path_sig'] = md5(serialize($path_full));
1357
-	}
1358
-	if ($dir_path === null) {
1359
-		return $path_full;
1360
-	}
1361
-
1362
-	if (strlen($dir_path)) {
1363
-		$tete = "";
1364
-		if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1365
-			$tete = array_shift($path_base);
1366
-		}
1367
-		$dirs = array_reverse(explode(':', $dir_path));
1368
-		foreach ($dirs as $dir_path) {
1369
-			#if ($dir_path{0}!='/')
1370
-			#	$dir_path = $dir_path;
1371
-			if (substr($dir_path, -1) != '/') {
1372
-				$dir_path .= "/";
1373
-			}
1374
-			if (!in_array($dir_path, $path_base)) {
1375
-				array_unshift($path_base, $dir_path);
1376
-			}
1377
-		}
1378
-		if (strlen($tete)) {
1379
-			array_unshift($path_base, $tete);
1380
-		}
1381
-	}
1382
-	$path_full = $path_base;
1383
-	// Et le(s) dossier(s) des squelettes nommes
1384
-	if (strlen($GLOBALS['dossier_squelettes'])) {
1385
-		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1386
-			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1387
-		}
1388
-	}
1389
-
1390
-	$GLOBALS['path_sig'] = md5(serialize($path_full));
1391
-
1392
-	return $path_full;
1329
+    static $path_base = null;
1330
+    static $path_full = null;
1331
+    if ($path_base == null) {
1332
+        // Chemin standard depuis l'espace public
1333
+        $path = defined('_SPIP_PATH') ? _SPIP_PATH :
1334
+            _DIR_RACINE . ':' .
1335
+            _DIR_RACINE . 'squelettes-dist/:' .
1336
+            _DIR_RACINE . 'prive/:' .
1337
+            _DIR_RESTREINT;
1338
+        // Ajouter squelettes/
1339
+        if (@is_dir(_DIR_RACINE . 'squelettes')) {
1340
+            $path = _DIR_RACINE . 'squelettes/:' . $path;
1341
+        }
1342
+        foreach (explode(':', $path) as $dir) {
1343
+            if (strlen($dir) and substr($dir, -1) != '/') {
1344
+                $dir .= "/";
1345
+            }
1346
+            $path_base[] = $dir;
1347
+        }
1348
+        $path_full = $path_base;
1349
+        // Et le(s) dossier(s) des squelettes nommes
1350
+        if (strlen($GLOBALS['dossier_squelettes'])) {
1351
+            foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1352
+                array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1353
+            }
1354
+        }
1355
+        $GLOBALS['path_sig'] = md5(serialize($path_full));
1356
+    }
1357
+    if ($dir_path === null) {
1358
+        return $path_full;
1359
+    }
1360
+
1361
+    if (strlen($dir_path)) {
1362
+        $tete = "";
1363
+        if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1364
+            $tete = array_shift($path_base);
1365
+        }
1366
+        $dirs = array_reverse(explode(':', $dir_path));
1367
+        foreach ($dirs as $dir_path) {
1368
+            #if ($dir_path{0}!='/')
1369
+            #	$dir_path = $dir_path;
1370
+            if (substr($dir_path, -1) != '/') {
1371
+                $dir_path .= "/";
1372
+            }
1373
+            if (!in_array($dir_path, $path_base)) {
1374
+                array_unshift($path_base, $dir_path);
1375
+            }
1376
+        }
1377
+        if (strlen($tete)) {
1378
+            array_unshift($path_base, $tete);
1379
+        }
1380
+    }
1381
+    $path_full = $path_base;
1382
+    // Et le(s) dossier(s) des squelettes nommes
1383
+    if (strlen($GLOBALS['dossier_squelettes'])) {
1384
+        foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1385
+            array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1386
+        }
1387
+    }
1388
+
1389
+    $GLOBALS['path_sig'] = md5(serialize($path_full));
1390
+
1391
+    return $path_full;
1393 1392
 }
1394 1393
 
1395 1394
 /**
@@ -1402,76 +1401,76 @@  discard block
 block discarded – undo
1402 1401
  * @return array Liste de chemins
1403 1402
  **/
1404 1403
 function creer_chemin() {
1405
-	$path_a = _chemin();
1406
-	static $c = '';
1404
+    $path_a = _chemin();
1405
+    static $c = '';
1407 1406
 
1408
-	// on calcule le chemin si le dossier skel a change
1409
-	if ($c != $GLOBALS['dossier_squelettes']) {
1410
-		// assurer le non plantage lors de la montee de version :
1411
-		$c = $GLOBALS['dossier_squelettes'];
1412
-		$path_a = _chemin(''); // forcer un recalcul du chemin
1413
-	}
1407
+    // on calcule le chemin si le dossier skel a change
1408
+    if ($c != $GLOBALS['dossier_squelettes']) {
1409
+        // assurer le non plantage lors de la montee de version :
1410
+        $c = $GLOBALS['dossier_squelettes'];
1411
+        $path_a = _chemin(''); // forcer un recalcul du chemin
1412
+    }
1414 1413
 
1415
-	return $path_a;
1414
+    return $path_a;
1416 1415
 }
1417 1416
 
1418 1417
 
1419 1418
 function lister_themes_prives() {
1420
-	static $themes = null;
1421
-	if (is_null($themes)) {
1422
-		// si pas encore definie
1423
-		if (!defined('_SPIP_THEME_PRIVE')) {
1424
-			define('_SPIP_THEME_PRIVE', 'spip');
1425
-		}
1426
-		$themes = array(_SPIP_THEME_PRIVE);
1427
-		// lors d'une installation neuve, prefs n'est pas definie.
1428
-		if (isset($GLOBALS['visiteur_session']['prefs'])) {
1429
-			$prefs = $GLOBALS['visiteur_session']['prefs'];
1430
-		} else {
1431
-			$prefs = array();
1432
-		}
1433
-		if (is_string($prefs)) {
1434
-			$prefs = unserialize($GLOBALS['visiteur_session']['prefs']);
1435
-		}
1436
-		if (
1437
-			((isset($prefs['theme']) and $theme = $prefs['theme'])
1438
-				or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut']))
1439
-			and $theme != _SPIP_THEME_PRIVE
1440
-		) {
1441
-			array_unshift($themes, $theme);
1442
-		} // placer le theme choisi en tete
1443
-	}
1444
-
1445
-	return $themes;
1419
+    static $themes = null;
1420
+    if (is_null($themes)) {
1421
+        // si pas encore definie
1422
+        if (!defined('_SPIP_THEME_PRIVE')) {
1423
+            define('_SPIP_THEME_PRIVE', 'spip');
1424
+        }
1425
+        $themes = array(_SPIP_THEME_PRIVE);
1426
+        // lors d'une installation neuve, prefs n'est pas definie.
1427
+        if (isset($GLOBALS['visiteur_session']['prefs'])) {
1428
+            $prefs = $GLOBALS['visiteur_session']['prefs'];
1429
+        } else {
1430
+            $prefs = array();
1431
+        }
1432
+        if (is_string($prefs)) {
1433
+            $prefs = unserialize($GLOBALS['visiteur_session']['prefs']);
1434
+        }
1435
+        if (
1436
+            ((isset($prefs['theme']) and $theme = $prefs['theme'])
1437
+                or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut']))
1438
+            and $theme != _SPIP_THEME_PRIVE
1439
+        ) {
1440
+            array_unshift($themes, $theme);
1441
+        } // placer le theme choisi en tete
1442
+    }
1443
+
1444
+    return $themes;
1446 1445
 }
1447 1446
 
1448 1447
 function find_in_theme($file, $subdir = '', $include = false) {
1449
-	static $themefiles = array();
1450
-	if (isset($themefiles["$subdir$file"])) {
1451
-		return $themefiles["$subdir$file"];
1452
-	}
1453
-	// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1454
-	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1455
-	if (preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1456
-	  and $file_svg_generique = substr($file,0, -strlen($m[0])) . "-xx.svg"
1457
-		and $f = find_in_theme("$file_svg_generique")) {
1458
-		if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) {
1459
-			return $themefiles["$subdir$file"] = $fsize;
1460
-		}
1461
-		else {
1462
-			return $themefiles["$subdir$file"] = "$f?".$m[1]."px";
1463
-		}
1464
-	}
1465
-
1466
-	$themes = lister_themes_prives();
1467
-	foreach ($themes as $theme) {
1468
-		if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) {
1469
-			return $themefiles["$subdir$file"] = $f;
1470
-		}
1471
-	}
1472
-	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1473
-
1474
-	return $themefiles["$subdir$file"] = "";
1448
+    static $themefiles = array();
1449
+    if (isset($themefiles["$subdir$file"])) {
1450
+        return $themefiles["$subdir$file"];
1451
+    }
1452
+    // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1453
+    // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1454
+    if (preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1455
+      and $file_svg_generique = substr($file,0, -strlen($m[0])) . "-xx.svg"
1456
+        and $f = find_in_theme("$file_svg_generique")) {
1457
+        if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) {
1458
+            return $themefiles["$subdir$file"] = $fsize;
1459
+        }
1460
+        else {
1461
+            return $themefiles["$subdir$file"] = "$f?".$m[1]."px";
1462
+        }
1463
+    }
1464
+
1465
+    $themes = lister_themes_prives();
1466
+    foreach ($themes as $theme) {
1467
+        if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) {
1468
+            return $themefiles["$subdir$file"] = $f;
1469
+        }
1470
+    }
1471
+    spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1472
+
1473
+    return $themefiles["$subdir$file"] = "";
1475 1474
 }
1476 1475
 
1477 1476
 
@@ -1495,31 +1494,31 @@  discard block
 block discarded – undo
1495 1494
  *     sinon chaîne vide.
1496 1495
  **/
1497 1496
 function chemin_image($icone) {
1498
-	static $icone_renommer;
1499
-	if ($p = strpos($icone, '?')) {
1500
-		$icone = substr($icone,0, $p);
1501
-	}
1502
-	// gerer le cas d'un double appel en evitant de refaire le travail inutilement
1503
-	if (strpos($icone, "/") !== false and file_exists($icone)) {
1504
-		return $icone;
1505
-	}
1506
-
1507
-	// si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
1508
-	if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) {
1509
-		return $f;
1510
-	}
1511
-	// sinon passer par le module de renommage
1512
-	if (is_null($icone_renommer)) {
1513
-		$icone_renommer = charger_fonction('icone_renommer', 'inc', true);
1514
-	}
1515
-	if ($icone_renommer) {
1516
-		list($icone, $fonction) = $icone_renommer($icone, "");
1517
-		if (file_exists($icone)) {
1518
-			return $icone;
1519
-		}
1520
-	}
1521
-
1522
-	return find_in_path($icone, _NOM_IMG_PACK);
1497
+    static $icone_renommer;
1498
+    if ($p = strpos($icone, '?')) {
1499
+        $icone = substr($icone,0, $p);
1500
+    }
1501
+    // gerer le cas d'un double appel en evitant de refaire le travail inutilement
1502
+    if (strpos($icone, "/") !== false and file_exists($icone)) {
1503
+        return $icone;
1504
+    }
1505
+
1506
+    // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
1507
+    if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) {
1508
+        return $f;
1509
+    }
1510
+    // sinon passer par le module de renommage
1511
+    if (is_null($icone_renommer)) {
1512
+        $icone_renommer = charger_fonction('icone_renommer', 'inc', true);
1513
+    }
1514
+    if ($icone_renommer) {
1515
+        list($icone, $fonction) = $icone_renommer($icone, "");
1516
+        if (file_exists($icone)) {
1517
+            return $icone;
1518
+        }
1519
+    }
1520
+
1521
+    return find_in_path($icone, _NOM_IMG_PACK);
1523 1522
 }
1524 1523
 
1525 1524
 //
@@ -1557,127 +1556,127 @@  discard block
 block discarded – undo
1557 1556
  *     - false : fichier introuvable
1558 1557
  **/
1559 1558
 function find_in_path($file, $dirname = '', $include = false) {
1560
-	static $dirs = array();
1561
-	static $inc = array(); # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec
1562
-	static $c = '';
1563
-
1564
-	if (!$file and !strlen($file)) {
1565
-		return false;
1566
-	}
1567
-
1568
-	// on calcule le chemin si le dossier skel a change
1569
-	if ($c != $GLOBALS['dossier_squelettes']) {
1570
-		// assurer le non plantage lors de la montee de version :
1571
-		$c = $GLOBALS['dossier_squelettes'];
1572
-		creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
1573
-	}
1574
-
1575
-	if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) {
1576
-		if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) {
1577
-			return false;
1578
-		}
1579
-		if ($include and !isset($inc[$dirname][$file])) {
1580
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1581
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1582
-		}
1583
-
1584
-		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1585
-	}
1586
-
1587
-	$a = strrpos($file, '/');
1588
-	if ($a !== false) {
1589
-		$dirname .= substr($file, 0, ++$a);
1590
-		$file = substr($file, $a);
1591
-	}
1592
-
1593
-	foreach (creer_chemin() as $dir) {
1594
-		if (!isset($dirs[$a = $dir . $dirname])) {
1595
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1596
-		}
1597
-		if ($dirs[$a]) {
1598
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
1599
-				if ($include and !isset($inc[$dirname][$file])) {
1600
-					include_once _ROOT_CWD . $a;
1601
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1602
-				}
1603
-				if (!defined('_SAUVER_CHEMIN')) {
1604
-					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1605
-					if (is_null($GLOBALS['path_files'])) {
1606
-						return $a;
1607
-					}
1608
-					define('_SAUVER_CHEMIN', true);
1609
-				}
1610
-
1611
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1612
-			}
1613
-		}
1614
-	}
1615
-
1616
-	if ($include) {
1617
-		spip_log("include_spip $dirname$file non trouve");
1618
-		if ($include === 'required') {
1619
-			echo '<pre>',
1620
-			"<strong>Erreur Fatale</strong><br />";
1621
-			if (function_exists('debug_print_backtrace')) {
1622
-				echo debug_print_backtrace();
1623
-			}
1624
-			echo '</pre>';
1625
-			die("Erreur interne: ne peut inclure $dirname$file");
1626
-		}
1627
-	}
1628
-
1629
-	if (!defined('_SAUVER_CHEMIN')) {
1630
-		// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1631
-		if (is_null($GLOBALS['path_files'])) {
1632
-			return false;
1633
-		}
1634
-		define('_SAUVER_CHEMIN', true);
1635
-	}
1636
-
1637
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1559
+    static $dirs = array();
1560
+    static $inc = array(); # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec
1561
+    static $c = '';
1562
+
1563
+    if (!$file and !strlen($file)) {
1564
+        return false;
1565
+    }
1566
+
1567
+    // on calcule le chemin si le dossier skel a change
1568
+    if ($c != $GLOBALS['dossier_squelettes']) {
1569
+        // assurer le non plantage lors de la montee de version :
1570
+        $c = $GLOBALS['dossier_squelettes'];
1571
+        creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
1572
+    }
1573
+
1574
+    if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) {
1575
+        if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) {
1576
+            return false;
1577
+        }
1578
+        if ($include and !isset($inc[$dirname][$file])) {
1579
+            include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1580
+            $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1581
+        }
1582
+
1583
+        return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1584
+    }
1585
+
1586
+    $a = strrpos($file, '/');
1587
+    if ($a !== false) {
1588
+        $dirname .= substr($file, 0, ++$a);
1589
+        $file = substr($file, $a);
1590
+    }
1591
+
1592
+    foreach (creer_chemin() as $dir) {
1593
+        if (!isset($dirs[$a = $dir . $dirname])) {
1594
+            $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1595
+        }
1596
+        if ($dirs[$a]) {
1597
+            if (file_exists(_ROOT_CWD . ($a .= $file))) {
1598
+                if ($include and !isset($inc[$dirname][$file])) {
1599
+                    include_once _ROOT_CWD . $a;
1600
+                    $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1601
+                }
1602
+                if (!defined('_SAUVER_CHEMIN')) {
1603
+                    // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1604
+                    if (is_null($GLOBALS['path_files'])) {
1605
+                        return $a;
1606
+                    }
1607
+                    define('_SAUVER_CHEMIN', true);
1608
+                }
1609
+
1610
+                return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1611
+            }
1612
+        }
1613
+    }
1614
+
1615
+    if ($include) {
1616
+        spip_log("include_spip $dirname$file non trouve");
1617
+        if ($include === 'required') {
1618
+            echo '<pre>',
1619
+            "<strong>Erreur Fatale</strong><br />";
1620
+            if (function_exists('debug_print_backtrace')) {
1621
+                echo debug_print_backtrace();
1622
+            }
1623
+            echo '</pre>';
1624
+            die("Erreur interne: ne peut inclure $dirname$file");
1625
+        }
1626
+    }
1627
+
1628
+    if (!defined('_SAUVER_CHEMIN')) {
1629
+        // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1630
+        if (is_null($GLOBALS['path_files'])) {
1631
+            return false;
1632
+        }
1633
+        define('_SAUVER_CHEMIN', true);
1634
+    }
1635
+
1636
+    return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1638 1637
 }
1639 1638
 
1640 1639
 function clear_path_cache() {
1641
-	$GLOBALS['path_files'] = array();
1642
-	spip_unlink(_CACHE_CHEMIN);
1640
+    $GLOBALS['path_files'] = array();
1641
+    spip_unlink(_CACHE_CHEMIN);
1643 1642
 }
1644 1643
 
1645 1644
 function load_path_cache() {
1646
-	// charger le path des plugins
1647
-	if (@is_readable(_CACHE_PLUGINS_PATH)) {
1648
-		include_once(_CACHE_PLUGINS_PATH);
1649
-	}
1650
-	$GLOBALS['path_files'] = array();
1651
-	// si le visiteur est admin,
1652
-	// on ne recharge pas le cache pour forcer sa mise a jour
1653
-	if (
1654
-		// la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier
1655
-		//AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')
1656
-		// utiliser le cookie est un pis aller qui marche 'en general'
1657
-		// on blinde par un second test au moment de la lecture de la session
1658
-		// !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
1659
-		// et en ignorant ce cache en cas de recalcul explicite
1660
-	!_request('var_mode')
1661
-	) {
1662
-		// on essaye de lire directement sans verrou pour aller plus vite
1663
-		if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
1664
-			// mais si semble corrompu on relit avec un verrou
1665
-			if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1666
-				lire_fichier(_CACHE_CHEMIN, $contenu);
1667
-				if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1668
-					$GLOBALS['path_files'] = array();
1669
-				}
1670
-			}
1671
-		}
1672
-	}
1645
+    // charger le path des plugins
1646
+    if (@is_readable(_CACHE_PLUGINS_PATH)) {
1647
+        include_once(_CACHE_PLUGINS_PATH);
1648
+    }
1649
+    $GLOBALS['path_files'] = array();
1650
+    // si le visiteur est admin,
1651
+    // on ne recharge pas le cache pour forcer sa mise a jour
1652
+    if (
1653
+        // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier
1654
+        //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')
1655
+        // utiliser le cookie est un pis aller qui marche 'en general'
1656
+        // on blinde par un second test au moment de la lecture de la session
1657
+        // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
1658
+        // et en ignorant ce cache en cas de recalcul explicite
1659
+    !_request('var_mode')
1660
+    ) {
1661
+        // on essaye de lire directement sans verrou pour aller plus vite
1662
+        if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
1663
+            // mais si semble corrompu on relit avec un verrou
1664
+            if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1665
+                lire_fichier(_CACHE_CHEMIN, $contenu);
1666
+                if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1667
+                    $GLOBALS['path_files'] = array();
1668
+                }
1669
+            }
1670
+        }
1671
+    }
1673 1672
 }
1674 1673
 
1675 1674
 function save_path_cache() {
1676
-	if (defined('_SAUVER_CHEMIN')
1677
-		and _SAUVER_CHEMIN
1678
-	) {
1679
-		ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
1680
-	}
1675
+    if (defined('_SAUVER_CHEMIN')
1676
+        and _SAUVER_CHEMIN
1677
+    ) {
1678
+        ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
1679
+    }
1681 1680
 }
1682 1681
 
1683 1682
 
@@ -1697,33 +1696,33 @@  discard block
 block discarded – undo
1697 1696
  * @return array
1698 1697
  */
1699 1698
 function find_all_in_path($dir, $pattern, $recurs = false) {
1700
-	$liste_fichiers = array();
1701
-	$maxfiles = 10000;
1702
-
1703
-	// cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1704
-	// on a pas encore inclus flock.php
1705
-	if (!function_exists('preg_files')) {
1706
-		include_once _ROOT_RESTREINT . 'inc/flock.php';
1707
-	}
1708
-
1709
-	// Parcourir le chemin
1710
-	foreach (creer_chemin() as $d) {
1711
-		$f = $d . $dir;
1712
-		if (@is_dir($f)) {
1713
-			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs);
1714
-			foreach ($liste as $chemin) {
1715
-				$nom = basename($chemin);
1716
-				// ne prendre que les fichiers pas deja trouves
1717
-				// car find_in_path prend le premier qu'il trouve,
1718
-				// les autres sont donc masques
1719
-				if (!isset($liste_fichiers[$nom])) {
1720
-					$liste_fichiers[$nom] = $chemin;
1721
-				}
1722
-			}
1723
-		}
1724
-	}
1725
-
1726
-	return $liste_fichiers;
1699
+    $liste_fichiers = array();
1700
+    $maxfiles = 10000;
1701
+
1702
+    // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1703
+    // on a pas encore inclus flock.php
1704
+    if (!function_exists('preg_files')) {
1705
+        include_once _ROOT_RESTREINT . 'inc/flock.php';
1706
+    }
1707
+
1708
+    // Parcourir le chemin
1709
+    foreach (creer_chemin() as $d) {
1710
+        $f = $d . $dir;
1711
+        if (@is_dir($f)) {
1712
+            $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs);
1713
+            foreach ($liste as $chemin) {
1714
+                $nom = basename($chemin);
1715
+                // ne prendre que les fichiers pas deja trouves
1716
+                // car find_in_path prend le premier qu'il trouve,
1717
+                // les autres sont donc masques
1718
+                if (!isset($liste_fichiers[$nom])) {
1719
+                    $liste_fichiers[$nom] = $chemin;
1720
+                }
1721
+            }
1722
+        }
1723
+    }
1724
+
1725
+    return $liste_fichiers;
1727 1726
 }
1728 1727
 
1729 1728
 /**
@@ -1735,17 +1734,17 @@  discard block
 block discarded – undo
1735 1734
  * @return bool
1736 1735
  */
1737 1736
 function autoriser_sans_cookie($nom, $strict = false) {
1738
-	static $autsanscookie = array('install', 'base_repair');
1737
+    static $autsanscookie = array('install', 'base_repair');
1739 1738
 
1740
-	if (in_array($nom, $autsanscookie)) {
1741
-		if (test_espace_prive()){
1742
-			include_spip('base/connect_sql');
1743
-			if (!$strict or !spip_connect()){
1744
-				return true;
1745
-			}
1746
-		}
1747
-	}
1748
-	return false;
1739
+    if (in_array($nom, $autsanscookie)) {
1740
+        if (test_espace_prive()){
1741
+            include_spip('base/connect_sql');
1742
+            if (!$strict or !spip_connect()){
1743
+                return true;
1744
+            }
1745
+        }
1746
+    }
1747
+    return false;
1749 1748
 }
1750 1749
 
1751 1750
 /**
@@ -1771,99 +1770,99 @@  discard block
 block discarded – undo
1771 1770
  *           (cas des raccourcis personalises [->spip20] : il faut implementer une fonction generer_url_spip et une fonction generer_url_ecrire_spip)
1772 1771
  */
1773 1772
 function generer_url_entite($id = '', $entite = '', $args = '', $ancre = '', $public = null, $type = null) {
1774
-	if ($public === null) {
1775
-		$public = !test_espace_prive();
1776
-	}
1777
-	$entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
1778
-
1779
-	if (!$public) {
1780
-		if (!$entite) {
1781
-			return '';
1782
-		}
1783
-		if (!function_exists('generer_url_ecrire_objet')) {
1784
-			include_spip('inc/urls');
1785
-		}
1786
-		$res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false);
1787
-	} else {
1788
-		if ($type === null) {
1789
-			$type = (isset($GLOBALS['type_urls']))
1790
-				? $GLOBALS['type_urls'] // pour surcharge via fichier d'options
1791
-				: ((isset($GLOBALS['meta']['type_urls'])) // sinon la config url_etendues
1792
-					? ($GLOBALS['meta']['type_urls']) : "page"); // sinon type "page" par défaut
1793
-		}
1794
-
1795
-		$f = charger_fonction($type, 'urls', true);
1796
-		// se rabattre sur les urls page si les urls perso non dispo
1797
-		if (!$f) {
1798
-			$f = charger_fonction('page', 'urls', true);
1799
-		}
1800
-
1801
-		// si $entite='', on veut la fonction de passage URL ==> id
1802
-		// sinon on veut effectuer le passage id ==> URL
1803
-		if (!$entite) {
1804
-			return $f;
1805
-		}
1806
-
1807
-		// mais d'abord il faut tester le cas des urls sur une
1808
-		// base distante
1809
-		if (is_string($public)
1810
-			and $g = charger_fonction('connect', 'urls', true)
1811
-		) {
1812
-			$f = $g;
1813
-		}
1814
-
1815
-		$res = $f(intval($id), $entite, $args, $ancre, $public);
1816
-
1817
-	}
1818
-	if ($res) {
1819
-		return $res;
1820
-	}
1821
-	// Sinon c'est un raccourci ou compat SPIP < 2
1822
-	if (!function_exists($f = 'generer_url_' . $entite)) {
1823
-		if (!function_exists($f .= '_dist')) {
1824
-			$f = '';
1825
-		}
1826
-	}
1827
-	if ($f) {
1828
-		$url = $f($id, $args, $ancre);
1829
-		if (strlen($args)) {
1830
-			$url .= strstr($url, '?')
1831
-				? '&amp;' . $args
1832
-				: '?' . $args;
1833
-		}
1834
-
1835
-		return $url;
1836
-	}
1837
-	// On a ete gentil mais la ....
1838
-	spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public");
1839
-
1840
-	return '';
1773
+    if ($public === null) {
1774
+        $public = !test_espace_prive();
1775
+    }
1776
+    $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
1777
+
1778
+    if (!$public) {
1779
+        if (!$entite) {
1780
+            return '';
1781
+        }
1782
+        if (!function_exists('generer_url_ecrire_objet')) {
1783
+            include_spip('inc/urls');
1784
+        }
1785
+        $res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false);
1786
+    } else {
1787
+        if ($type === null) {
1788
+            $type = (isset($GLOBALS['type_urls']))
1789
+                ? $GLOBALS['type_urls'] // pour surcharge via fichier d'options
1790
+                : ((isset($GLOBALS['meta']['type_urls'])) // sinon la config url_etendues
1791
+                    ? ($GLOBALS['meta']['type_urls']) : "page"); // sinon type "page" par défaut
1792
+        }
1793
+
1794
+        $f = charger_fonction($type, 'urls', true);
1795
+        // se rabattre sur les urls page si les urls perso non dispo
1796
+        if (!$f) {
1797
+            $f = charger_fonction('page', 'urls', true);
1798
+        }
1799
+
1800
+        // si $entite='', on veut la fonction de passage URL ==> id
1801
+        // sinon on veut effectuer le passage id ==> URL
1802
+        if (!$entite) {
1803
+            return $f;
1804
+        }
1805
+
1806
+        // mais d'abord il faut tester le cas des urls sur une
1807
+        // base distante
1808
+        if (is_string($public)
1809
+            and $g = charger_fonction('connect', 'urls', true)
1810
+        ) {
1811
+            $f = $g;
1812
+        }
1813
+
1814
+        $res = $f(intval($id), $entite, $args, $ancre, $public);
1815
+
1816
+    }
1817
+    if ($res) {
1818
+        return $res;
1819
+    }
1820
+    // Sinon c'est un raccourci ou compat SPIP < 2
1821
+    if (!function_exists($f = 'generer_url_' . $entite)) {
1822
+        if (!function_exists($f .= '_dist')) {
1823
+            $f = '';
1824
+        }
1825
+    }
1826
+    if ($f) {
1827
+        $url = $f($id, $args, $ancre);
1828
+        if (strlen($args)) {
1829
+            $url .= strstr($url, '?')
1830
+                ? '&amp;' . $args
1831
+                : '?' . $args;
1832
+        }
1833
+
1834
+        return $url;
1835
+    }
1836
+    // On a ete gentil mais la ....
1837
+    spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public");
1838
+
1839
+    return '';
1841 1840
 }
1842 1841
 
1843 1842
 function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') {
1844
-	$exec = objet_info($entite, 'url_edit');
1845
-	$url = generer_url_ecrire($exec, $args);
1846
-	if (intval($id)) {
1847
-		$url = parametre_url($url, id_table_objet($entite), $id);
1848
-	} else {
1849
-		$url = parametre_url($url, 'new', 'oui');
1850
-	}
1851
-	if ($ancre) {
1852
-		$url = ancre_url($url, $ancre);
1853
-	}
1843
+    $exec = objet_info($entite, 'url_edit');
1844
+    $url = generer_url_ecrire($exec, $args);
1845
+    if (intval($id)) {
1846
+        $url = parametre_url($url, id_table_objet($entite), $id);
1847
+    } else {
1848
+        $url = parametre_url($url, 'new', 'oui');
1849
+    }
1850
+    if ($ancre) {
1851
+        $url = ancre_url($url, $ancre);
1852
+    }
1854 1853
 
1855
-	return $url;
1854
+    return $url;
1856 1855
 }
1857 1856
 
1858 1857
 // https://code.spip.net/@urls_connect_dist
1859 1858
 function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) {
1860
-	include_spip('base/connect_sql');
1861
-	$id_type = id_table_objet($entite, $public);
1859
+    include_spip('base/connect_sql');
1860
+    $id_type = id_table_objet($entite, $public);
1862 1861
 
1863
-	return _DIR_RACINE . get_spip_script('./')
1864
-	. "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1865
-	. (!$args ? '' : "&$args")
1866
-	. (!$ancre ? '' : "#$ancre");
1862
+    return _DIR_RACINE . get_spip_script('./')
1863
+    . "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1864
+    . (!$args ? '' : "&$args")
1865
+    . (!$ancre ? '' : "#$ancre");
1867 1866
 }
1868 1867
 
1869 1868
 
@@ -1874,32 +1873,32 @@  discard block
 block discarded – undo
1874 1873
  * @return string
1875 1874
  */
1876 1875
 function urlencode_1738($url) {
1877
-	if (preg_match(',[^\x00-\x7E],sS', $url)) {
1878
-		$uri = '';
1879
-		for ($i = 0; $i < strlen($url); $i++) {
1880
-			if (ord($a = $url[$i]) > 127) {
1881
-				$a = rawurlencode($a);
1882
-			}
1883
-			$uri .= $a;
1884
-		}
1885
-		$url = $uri;
1886
-	}
1876
+    if (preg_match(',[^\x00-\x7E],sS', $url)) {
1877
+        $uri = '';
1878
+        for ($i = 0; $i < strlen($url); $i++) {
1879
+            if (ord($a = $url[$i]) > 127) {
1880
+                $a = rawurlencode($a);
1881
+            }
1882
+            $uri .= $a;
1883
+        }
1884
+        $url = $uri;
1885
+    }
1887 1886
 
1888
-	return quote_amp($url);
1887
+    return quote_amp($url);
1889 1888
 }
1890 1889
 
1891 1890
 // https://code.spip.net/@generer_url_entite_absolue
1892 1891
 function generer_url_entite_absolue($id = '', $entite = '', $args = '', $ancre = '', $connect = null) {
1893
-	if (!$connect) {
1894
-		$connect = true;
1895
-	}
1896
-	$h = generer_url_entite($id, $entite, $args, $ancre, $connect);
1897
-	if (!preg_match(',^\w+:,', $h)) {
1898
-		include_spip('inc/filtres_mini');
1899
-		$h = url_absolue($h);
1900
-	}
1892
+    if (!$connect) {
1893
+        $connect = true;
1894
+    }
1895
+    $h = generer_url_entite($id, $entite, $args, $ancre, $connect);
1896
+    if (!preg_match(',^\w+:,', $h)) {
1897
+        include_spip('inc/filtres_mini');
1898
+        $h = url_absolue($h);
1899
+    }
1901 1900
 
1902
-	return $h;
1901
+    return $h;
1903 1902
 }
1904 1903
 
1905 1904
 
@@ -1915,11 +1914,11 @@  discard block
 block discarded – undo
1915 1914
  *     true si la valeur est considérée active ; false sinon.
1916 1915
  **/
1917 1916
 function test_valeur_serveur($truc) {
1918
-	if (!$truc) {
1919
-		return false;
1920
-	}
1917
+    if (!$truc) {
1918
+        return false;
1919
+    }
1921 1920
 
1922
-	return (strtolower($truc) !== 'off');
1921
+    return (strtolower($truc) !== 'off');
1923 1922
 }
1924 1923
 
1925 1924
 //
@@ -1947,80 +1946,80 @@  discard block
 block discarded – undo
1947 1946
  */
1948 1947
 function url_de_base($profondeur = null) {
1949 1948
 
1950
-	static $url = array();
1951
-	if (is_array($profondeur)) {
1952
-		return $url = $profondeur;
1953
-	}
1954
-	if ($profondeur === false) {
1955
-		return $url;
1956
-	}
1957
-
1958
-	if (is_null($profondeur)) {
1959
-		$profondeur = $GLOBALS['profondeur_url'];
1960
-	}
1961
-
1962
-	if (isset($url[$profondeur])) {
1963
-		return $url[$profondeur];
1964
-	}
1965
-
1966
-	$http = 'http';
1967
-
1968
-	if (
1969
-		isset($_SERVER["SCRIPT_URI"])
1970
-		and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https'
1971
-	) {
1972
-		$http = 'https';
1973
-	} elseif (
1974
-		isset($_SERVER['HTTPS'])
1975
-		and test_valeur_serveur($_SERVER['HTTPS'])
1976
-	) {
1977
-		$http = 'https';
1978
-	}
1979
-
1980
-	// note : HTTP_HOST contient le :port si necessaire
1981
-	$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
1982
-	// si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback
1983
-	if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) {
1984
-		$host = $GLOBALS['meta']['adresse_site'];
1985
-		if ($scheme = parse_url($host, PHP_URL_SCHEME)) {
1986
-			$http = $scheme;
1987
-			$host = str_replace("{$scheme}://", '', $host);
1988
-		}
1989
-	}
1990
-	if (isset($_SERVER['SERVER_PORT'])
1991
-		and $port = $_SERVER['SERVER_PORT']
1992
-		and strpos($host, ":") == false
1993
-	) {
1994
-		if (!defined('_PORT_HTTP_STANDARD')) {
1995
-			define('_PORT_HTTP_STANDARD', '80');
1996
-		}
1997
-		if (!defined('_PORT_HTTPS_STANDARD')) {
1998
-			define('_PORT_HTTPS_STANDARD', '443');
1999
-		}
2000
-		if ($http == "http" and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) {
2001
-			$host .= ":$port";
2002
-		}
2003
-		if ($http == "https" and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) {
2004
-			$host .= ":$port";
2005
-		}
2006
-	}
2007
-
2008
-	if (!$GLOBALS['REQUEST_URI']) {
2009
-		if (isset($_SERVER['REQUEST_URI'])) {
2010
-			$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2011
-		} else {
2012
-			$GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2013
-			if (!empty($_SERVER['QUERY_STRING'])
2014
-				and !strpos($_SERVER['REQUEST_URI'], '?')
2015
-			) {
2016
-				$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2017
-			}
2018
-		}
2019
-	}
2020
-
2021
-	$url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
2022
-
2023
-	return $url[$profondeur];
1949
+    static $url = array();
1950
+    if (is_array($profondeur)) {
1951
+        return $url = $profondeur;
1952
+    }
1953
+    if ($profondeur === false) {
1954
+        return $url;
1955
+    }
1956
+
1957
+    if (is_null($profondeur)) {
1958
+        $profondeur = $GLOBALS['profondeur_url'];
1959
+    }
1960
+
1961
+    if (isset($url[$profondeur])) {
1962
+        return $url[$profondeur];
1963
+    }
1964
+
1965
+    $http = 'http';
1966
+
1967
+    if (
1968
+        isset($_SERVER["SCRIPT_URI"])
1969
+        and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https'
1970
+    ) {
1971
+        $http = 'https';
1972
+    } elseif (
1973
+        isset($_SERVER['HTTPS'])
1974
+        and test_valeur_serveur($_SERVER['HTTPS'])
1975
+    ) {
1976
+        $http = 'https';
1977
+    }
1978
+
1979
+    // note : HTTP_HOST contient le :port si necessaire
1980
+    $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
1981
+    // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback
1982
+    if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) {
1983
+        $host = $GLOBALS['meta']['adresse_site'];
1984
+        if ($scheme = parse_url($host, PHP_URL_SCHEME)) {
1985
+            $http = $scheme;
1986
+            $host = str_replace("{$scheme}://", '', $host);
1987
+        }
1988
+    }
1989
+    if (isset($_SERVER['SERVER_PORT'])
1990
+        and $port = $_SERVER['SERVER_PORT']
1991
+        and strpos($host, ":") == false
1992
+    ) {
1993
+        if (!defined('_PORT_HTTP_STANDARD')) {
1994
+            define('_PORT_HTTP_STANDARD', '80');
1995
+        }
1996
+        if (!defined('_PORT_HTTPS_STANDARD')) {
1997
+            define('_PORT_HTTPS_STANDARD', '443');
1998
+        }
1999
+        if ($http == "http" and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) {
2000
+            $host .= ":$port";
2001
+        }
2002
+        if ($http == "https" and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) {
2003
+            $host .= ":$port";
2004
+        }
2005
+    }
2006
+
2007
+    if (!$GLOBALS['REQUEST_URI']) {
2008
+        if (isset($_SERVER['REQUEST_URI'])) {
2009
+            $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2010
+        } else {
2011
+            $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2012
+            if (!empty($_SERVER['QUERY_STRING'])
2013
+                and !strpos($_SERVER['REQUEST_URI'], '?')
2014
+            ) {
2015
+                $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2016
+            }
2017
+        }
2018
+    }
2019
+
2020
+    $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
2021
+
2022
+    return $url[$profondeur];
2024 2023
 }
2025 2024
 
2026 2025
 /**
@@ -2033,26 +2032,26 @@  discard block
 block discarded – undo
2033 2032
  * @return string
2034 2033
  */
2035 2034
 function url_de_($http, $host, $request, $prof = 0) {
2036
-	$prof = max($prof, 0);
2035
+    $prof = max($prof, 0);
2037 2036
 
2038
-	$myself = ltrim($request, '/');
2039
-	# supprimer la chaine de GET
2040
-	list($myself) = explode('?', $myself);
2041
-	// vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
2042
-	// protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
2043
-	if (strpos($myself,'://') !== false) {
2044
-		$myself = explode('://',$myself);
2045
-		array_shift($myself);
2046
-		$myself = implode('://',$myself);
2047
-		$myself = explode('/',$myself);
2048
-		array_shift($myself);
2049
-		$myself = implode('/',$myself);
2050
-	}
2051
-	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2037
+    $myself = ltrim($request, '/');
2038
+    # supprimer la chaine de GET
2039
+    list($myself) = explode('?', $myself);
2040
+    // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
2041
+    // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
2042
+    if (strpos($myself,'://') !== false) {
2043
+        $myself = explode('://',$myself);
2044
+        array_shift($myself);
2045
+        $myself = implode('://',$myself);
2046
+        $myself = explode('/',$myself);
2047
+        array_shift($myself);
2048
+        $myself = implode('/',$myself);
2049
+    }
2050
+    $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2052 2051
 
2053
-	$url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2052
+    $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2054 2053
 
2055
-	return $url;
2054
+    return $url;
2056 2055
 }
2057 2056
 
2058 2057
 
@@ -2087,26 +2086,26 @@  discard block
 block discarded – undo
2087 2086
  * @return string URL
2088 2087
  **/
2089 2088
 function generer_url_ecrire($script = '', $args = "", $no_entities = false, $rel = false) {
2090
-	if (!$rel) {
2091
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2092
-	} else {
2093
-		if (!is_string($rel)) {
2094
-			$rel = _DIR_RESTREINT ? _DIR_RESTREINT :
2095
-				('./' . _SPIP_ECRIRE_SCRIPT);
2096
-		}
2097
-	}
2098
-
2099
-	list($script, $ancre) = array_pad(explode('#', $script), 2, null);
2100
-	if ($script and ($script <> 'accueil' or $rel)) {
2101
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
2102
-	} elseif ($args) {
2103
-		$args = "?$args";
2104
-	}
2105
-	if ($ancre) {
2106
-		$args .= "#$ancre";
2107
-	}
2108
-
2109
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2089
+    if (!$rel) {
2090
+        $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2091
+    } else {
2092
+        if (!is_string($rel)) {
2093
+            $rel = _DIR_RESTREINT ? _DIR_RESTREINT :
2094
+                ('./' . _SPIP_ECRIRE_SCRIPT);
2095
+        }
2096
+    }
2097
+
2098
+    list($script, $ancre) = array_pad(explode('#', $script), 2, null);
2099
+    if ($script and ($script <> 'accueil' or $rel)) {
2100
+        $args = "?exec=$script" . (!$args ? '' : "&$args");
2101
+    } elseif ($args) {
2102
+        $args = "?$args";
2103
+    }
2104
+    if ($ancre) {
2105
+        $args .= "#$ancre";
2106
+    }
2107
+
2108
+    return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2110 2109
 }
2111 2110
 
2112 2111
 //
@@ -2128,12 +2127,12 @@  discard block
 block discarded – undo
2128 2127
  *     Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut
2129 2128
  **/
2130 2129
 function get_spip_script($default = '') {
2131
-	# cas define('_SPIP_SCRIPT', '');
2132
-	if (_SPIP_SCRIPT) {
2133
-		return _SPIP_SCRIPT;
2134
-	} else {
2135
-		return $default;
2136
-	}
2130
+    # cas define('_SPIP_SCRIPT', '');
2131
+    if (_SPIP_SCRIPT) {
2132
+        return _SPIP_SCRIPT;
2133
+    } else {
2134
+        return $default;
2135
+    }
2137 2136
 }
2138 2137
 
2139 2138
 /**
@@ -2162,39 +2161,39 @@  discard block
 block discarded – undo
2162 2161
  * @return string URL
2163 2162
  **/
2164 2163
 function generer_url_public($script = '', $args = "", $no_entities = false, $rel = true, $action = '') {
2165
-	// si le script est une action (spip_pass, spip_inscription),
2166
-	// standardiser vers la nouvelle API
2167
-
2168
-	if (!$action) {
2169
-		$action = get_spip_script();
2170
-	}
2171
-	if ($script) {
2172
-		$action = parametre_url($action, _SPIP_PAGE, $script, '&');
2173
-	}
2174
-
2175
-	if ($args) {
2176
-		if (is_array($args)) {
2177
-			$r = '';
2178
-			foreach ($args as $k => $v) {
2179
-				$r .= '&' . $k . '=' . $v;
2180
-			}
2181
-			$args = substr($r, 1);
2182
-		}
2183
-		$action .=
2184
-			(strpos($action, '?') !== false ? '&' : '?') . $args;
2185
-	}
2186
-	if (!$no_entities) {
2187
-		$action = quote_amp($action);
2188
-	}
2189
-
2190
-	// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2191
-	return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action"));
2164
+    // si le script est une action (spip_pass, spip_inscription),
2165
+    // standardiser vers la nouvelle API
2166
+
2167
+    if (!$action) {
2168
+        $action = get_spip_script();
2169
+    }
2170
+    if ($script) {
2171
+        $action = parametre_url($action, _SPIP_PAGE, $script, '&');
2172
+    }
2173
+
2174
+    if ($args) {
2175
+        if (is_array($args)) {
2176
+            $r = '';
2177
+            foreach ($args as $k => $v) {
2178
+                $r .= '&' . $k . '=' . $v;
2179
+            }
2180
+            $args = substr($r, 1);
2181
+        }
2182
+        $action .=
2183
+            (strpos($action, '?') !== false ? '&' : '?') . $args;
2184
+    }
2185
+    if (!$no_entities) {
2186
+        $action = quote_amp($action);
2187
+    }
2188
+
2189
+    // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2190
+    return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action"));
2192 2191
 }
2193 2192
 
2194 2193
 // https://code.spip.net/@generer_url_prive
2195 2194
 function generer_url_prive($script, $args = "", $no_entities = false) {
2196 2195
 
2197
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2196
+    return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2198 2197
 }
2199 2198
 
2200 2199
 // Pour les formulaires en methode POST,
@@ -2219,19 +2218,19 @@  discard block
 block discarded – undo
2219 2218
  **/
2220 2219
 function generer_form_ecrire($script, $corps, $atts = '', $submit = '') {
2221 2220
 
2222
-	$script1 = explode('&', $script);
2223
-	$script1 = reset($script1);
2221
+    $script1 = explode('&', $script);
2222
+    $script1 = reset($script1);
2224 2223
 
2225
-	return "<form action='"
2226
-	. ($script ? generer_url_ecrire($script) : '')
2227
-	. "' "
2228
-	. ($atts ? $atts : " method='post'")
2229
-	. "><div>\n"
2230
-	. "<input type='hidden' name='exec' value='$script1' />"
2231
-	. $corps
2232
-	. (!$submit ? '' :
2233
-		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>"))
2234
-	. "</div></form>\n";
2224
+    return "<form action='"
2225
+    . ($script ? generer_url_ecrire($script) : '')
2226
+    . "' "
2227
+    . ($atts ? $atts : " method='post'")
2228
+    . "><div>\n"
2229
+    . "<input type='hidden' name='exec' value='$script1' />"
2230
+    . $corps
2231
+    . (!$submit ? '' :
2232
+        ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>"))
2233
+    . "</div></form>\n";
2235 2234
 }
2236 2235
 
2237 2236
 /**
@@ -2248,22 +2247,22 @@  discard block
 block discarded – undo
2248 2247
  * @return string
2249 2248
  */
2250 2249
 function generer_form_action($script, $corps, $atts = '', $public = false) {
2251
-	// si l'on est dans l'espace prive, on garde dans l'url
2252
-	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2253
-	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
2254
-	$h = (_DIR_RACINE and !$public)
2255
-		? generer_url_ecrire(_request('exec'))
2256
-		: generer_url_public();
2250
+    // si l'on est dans l'espace prive, on garde dans l'url
2251
+    // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2252
+    // ou non de proceder a l'authentification (cas typique de l'install par exemple)
2253
+    $h = (_DIR_RACINE and !$public)
2254
+        ? generer_url_ecrire(_request('exec'))
2255
+        : generer_url_public();
2257 2256
 
2258
-	return "\n<form action='" .
2259
-	$h .
2260
-	"'" .
2261
-	$atts .
2262
-	">\n" .
2263
-	"<div>" .
2264
-	"\n<input type='hidden' name='action' value='$script' />" .
2265
-	$corps .
2266
-	"</div></form>";
2257
+    return "\n<form action='" .
2258
+    $h .
2259
+    "'" .
2260
+    $atts .
2261
+    ">\n" .
2262
+    "<div>" .
2263
+    "\n<input type='hidden' name='action' value='$script' />" .
2264
+    $corps .
2265
+    "</div></form>";
2267 2266
 }
2268 2267
 
2269 2268
 /**
@@ -2282,22 +2281,22 @@  discard block
 block discarded – undo
2282 2281
  *     URL
2283 2282
  */
2284 2283
 function generer_url_action($script, $args = "", $no_entities = false, $public = false) {
2285
-	// si l'on est dans l'espace prive, on garde dans l'url
2286
-	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2287
-	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
2288
-	$url = (_DIR_RACINE and !$public)
2289
-		? generer_url_ecrire(_request('exec'))
2290
-		: generer_url_public('', '', false, false);
2291
-	$url = parametre_url($url, 'action', $script);
2292
-	if ($args) {
2293
-		$url .= quote_amp('&' . $args);
2294
-	}
2284
+    // si l'on est dans l'espace prive, on garde dans l'url
2285
+    // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2286
+    // ou non de proceder a l'authentification (cas typique de l'install par exemple)
2287
+    $url = (_DIR_RACINE and !$public)
2288
+        ? generer_url_ecrire(_request('exec'))
2289
+        : generer_url_public('', '', false, false);
2290
+    $url = parametre_url($url, 'action', $script);
2291
+    if ($args) {
2292
+        $url .= quote_amp('&' . $args);
2293
+    }
2295 2294
 
2296
-	if ($no_entities) {
2297
-		$url = str_replace('&amp;', '&', $url);
2298
-	}
2295
+    if ($no_entities) {
2296
+        $url = str_replace('&amp;', '&', $url);
2297
+    }
2299 2298
 
2300
-	return $url;
2299
+    return $url;
2301 2300
 }
2302 2301
 
2303 2302
 
@@ -2310,8 +2309,8 @@  discard block
 block discarded – undo
2310 2309
  * @param string $ta Répertoire temporaire accessible
2311 2310
  */
2312 2311
 function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) {
2313
-	spip_initialisation_core($pi, $pa, $ti, $ta);
2314
-	spip_initialisation_suite();
2312
+    spip_initialisation_core($pi, $pa, $ti, $ta);
2313
+    spip_initialisation_suite();
2315 2314
 }
2316 2315
 
2317 2316
 /**
@@ -2331,315 +2330,315 @@  discard block
 block discarded – undo
2331 2330
  * @param string $ta Répertoire temporaire accessible
2332 2331
  */
2333 2332
 function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) {
2334
-	static $too_late = 0;
2335
-	if ($too_late++) {
2336
-		return;
2337
-	}
2338
-
2339
-	// Declaration des repertoires
2340
-
2341
-	// le nom du repertoire plugins/ activables/desactivables
2342
-	if (!defined('_DIR_PLUGINS')) {
2343
-		define('_DIR_PLUGINS', _DIR_RACINE . "plugins/");
2344
-	}
2345
-
2346
-	// le nom du repertoire des extensions/ permanentes du core, toujours actives
2347
-	if (!defined('_DIR_PLUGINS_DIST')) {
2348
-		define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/");
2349
-	}
2350
-
2351
-	// le nom du repertoire des librairies
2352
-	if (!defined('_DIR_LIB')) {
2353
-		define('_DIR_LIB', _DIR_RACINE . "lib/");
2354
-	}
2355
-
2356
-	if (!defined('_DIR_IMG')) {
2357
-		define('_DIR_IMG', $pa);
2358
-	}
2359
-	if (!defined('_DIR_LOGOS')) {
2360
-		define('_DIR_LOGOS', $pa);
2361
-	}
2362
-	if (!defined('_DIR_IMG_ICONES')) {
2363
-		define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/");
2364
-	}
2365
-
2366
-	if (!defined('_DIR_DUMP')) {
2367
-		define('_DIR_DUMP', $ti . "dump/");
2368
-	}
2369
-	if (!defined('_DIR_SESSIONS')) {
2370
-		define('_DIR_SESSIONS', $ti . "sessions/");
2371
-	}
2372
-	if (!defined('_DIR_TRANSFERT')) {
2373
-		define('_DIR_TRANSFERT', $ti . "upload/");
2374
-	}
2375
-	if (!defined('_DIR_CACHE')) {
2376
-		define('_DIR_CACHE', $ti . "cache/");
2377
-	}
2378
-	if (!defined('_DIR_CACHE_XML')) {
2379
-		define('_DIR_CACHE_XML', _DIR_CACHE . "xml/");
2380
-	}
2381
-	if (!defined('_DIR_SKELS')) {
2382
-		define('_DIR_SKELS', _DIR_CACHE . "skel/");
2383
-	}
2384
-	if (!defined('_DIR_AIDE')) {
2385
-		define('_DIR_AIDE', _DIR_CACHE . "aide/");
2386
-	}
2387
-	if (!defined('_DIR_TMP')) {
2388
-		define('_DIR_TMP', $ti);
2389
-	}
2390
-
2391
-	if (!defined('_DIR_VAR')) {
2392
-		define('_DIR_VAR', $ta);
2393
-	}
2394
-
2395
-	if (!defined('_DIR_ETC')) {
2396
-		define('_DIR_ETC', $pi);
2397
-	}
2398
-	if (!defined('_DIR_CONNECT')) {
2399
-		define('_DIR_CONNECT', $pi);
2400
-	}
2401
-	if (!defined('_DIR_CHMOD')) {
2402
-		define('_DIR_CHMOD', $pi);
2403
-	}
2404
-
2405
-	if (!isset($GLOBALS['test_dirs']))
2406
-		// Pas $pi car il est bon de le mettre hors ecriture apres intstall
2407
-		// il sera rajoute automatiquement si besoin a l'etape 2 de l'install
2408
-	{
2409
-		$GLOBALS['test_dirs'] = array($pa, $ti, $ta);
2410
-	}
2411
-
2412
-	// Declaration des fichiers
2413
-
2414
-	if (!defined('_CACHE_PLUGINS_PATH')) {
2415
-		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php");
2416
-	}
2417
-	if (!defined('_CACHE_PLUGINS_OPT')) {
2418
-		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php");
2419
-	}
2420
-	if (!defined('_CACHE_PLUGINS_FCT')) {
2421
-		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php");
2422
-	}
2423
-	if (!defined('_CACHE_PIPELINES')) {
2424
-		define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php");
2425
-	}
2426
-	if (!defined('_CACHE_CHEMIN')) {
2427
-		define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt");
2428
-	}
2429
-
2430
-	# attention .php obligatoire pour ecrire_fichier_securise
2431
-	if (!defined('_FILE_META')) {
2432
-		define('_FILE_META', $ti . 'meta_cache.php');
2433
-	}
2434
-	if (!defined('_DIR_LOG')) {
2435
-		define('_DIR_LOG', _DIR_TMP . 'log/');
2436
-	}
2437
-	if (!defined('_FILE_LOG')) {
2438
-		define('_FILE_LOG', 'spip');
2439
-	}
2440
-	if (!defined('_FILE_LOG_SUFFIX')) {
2441
-		define('_FILE_LOG_SUFFIX', '.log');
2442
-	}
2443
-
2444
-	// Le fichier de connexion a la base de donnees
2445
-	// tient compte des anciennes versions (inc_connect...)
2446
-	if (!defined('_FILE_CONNECT_INS')) {
2447
-		define('_FILE_CONNECT_INS', 'connect');
2448
-	}
2449
-	if (!defined('_FILE_CONNECT')) {
2450
-		define('_FILE_CONNECT',
2451
-		(@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2452
-			: (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2453
-				: false)));
2454
-	}
2455
-
2456
-	// Le fichier de reglages des droits
2457
-	if (!defined('_FILE_CHMOD_INS')) {
2458
-		define('_FILE_CHMOD_INS', 'chmod');
2459
-	}
2460
-	if (!defined('_FILE_CHMOD')) {
2461
-		define('_FILE_CHMOD',
2462
-		(@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2463
-			: false));
2464
-	}
2465
-
2466
-	if (!defined('_FILE_LDAP')) {
2467
-		define('_FILE_LDAP', 'ldap.php');
2468
-	}
2469
-
2470
-	if (!defined('_FILE_TMP_SUFFIX')) {
2471
-		define('_FILE_TMP_SUFFIX', '.tmp.php');
2472
-	}
2473
-	if (!defined('_FILE_CONNECT_TMP')) {
2474
-		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2475
-	}
2476
-	if (!defined('_FILE_CHMOD_TMP')) {
2477
-		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2478
-	}
2479
-
2480
-	// Definition des droits d'acces en ecriture
2481
-	if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) {
2482
-		include_once _FILE_CHMOD;
2483
-	}
2484
-
2485
-	// Se mefier des fichiers mal remplis!
2486
-	if (!defined('_SPIP_CHMOD')) {
2487
-		define('_SPIP_CHMOD', 0777);
2488
-	}
2489
-
2490
-	if (!defined('_DEFAULT_CHARSET')) {
2491
-		/** Le charset par défaut lors de l'installation */
2492
-		define('_DEFAULT_CHARSET', 'utf-8');
2493
-	}
2494
-	if (!defined('_ROOT_PLUGINS')) {
2495
-		define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/");
2496
-	}
2497
-	if (!defined('_ROOT_PLUGINS_DIST')) {
2498
-		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/");
2499
-	}
2500
-	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2501
-		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2502
-	}
2503
-
2504
-	// La taille des Log
2505
-	if (!defined('_MAX_LOG')) {
2506
-		define('_MAX_LOG', 100);
2507
-	}
2508
-
2509
-	// Sommes-nous dans l'empire du Mal ?
2510
-	// (ou sous le signe du Pingouin, ascendant GNU ?)
2511
-	if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) {
2512
-		if (!defined('_OS_SERVEUR')) {
2513
-			define('_OS_SERVEUR', 'windows');
2514
-		}
2515
-		if (!defined('_SPIP_LOCK_MODE')) {
2516
-			define('_SPIP_LOCK_MODE', 1);
2517
-		} // utiliser le flock php
2518
-	} else {
2519
-		if (!defined('_OS_SERVEUR')) {
2520
-			define('_OS_SERVEUR', '');
2521
-		}
2522
-		if (!defined('_SPIP_LOCK_MODE')) {
2523
-			define('_SPIP_LOCK_MODE', 1);
2524
-		} // utiliser le flock php
2525
-		#if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
2526
-	}
2527
-
2528
-	// Langue par defaut
2529
-	if (!defined('_LANGUE_PAR_DEFAUT')) {
2530
-		define('_LANGUE_PAR_DEFAUT', 'fr');
2531
-	}
2532
-
2533
-	//
2534
-	// Module de lecture/ecriture/suppression de fichiers utilisant flock()
2535
-	// (non surchargeable en l'etat ; attention si on utilise include_spip()
2536
-	// pour le rendre surchargeable, on va provoquer un reecriture
2537
-	// systematique du noyau ou une baisse de perfs => a etudier)
2538
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
2539
-
2540
-	// charger tout de suite le path et son cache
2541
-	load_path_cache();
2542
-
2543
-	// *********** traiter les variables ************
2544
-
2545
-	//
2546
-	// Securite
2547
-	//
2548
-
2549
-	// Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
2550
-	if (isset($_REQUEST['GLOBALS'])) {
2551
-		die();
2552
-	}
2553
-	// nettoyer les magic quotes \' et les caracteres nuls %00
2554
-	spip_desinfecte($_GET);
2555
-	spip_desinfecte($_POST);
2556
-	spip_desinfecte($_COOKIE);
2557
-	spip_desinfecte($_REQUEST);
2558
-
2559
-	// appliquer le cookie_prefix
2560
-	if ($GLOBALS['cookie_prefix'] != 'spip') {
2561
-		include_spip('inc/cookie');
2562
-		recuperer_cookies_spip($GLOBALS['cookie_prefix']);
2563
-	}
2564
-
2565
-	//
2566
-	// Capacites php (en fonction de la version)
2567
-	//
2568
-	$GLOBALS['flag_ob'] = (function_exists("ob_start")
2569
-		&& function_exists("ini_get")
2570
-		&& !strstr(@ini_get('disable_functions'), 'ob_'));
2571
-	$GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name");
2572
-	$GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != "");
2573
-	$GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] ||
2574
-		(get_cfg_var('upload_max_filesize') > 0));
2575
-
2576
-
2577
-	// Compatibilite avec serveurs ne fournissant pas $REQUEST_URI
2578
-	if (isset($_SERVER['REQUEST_URI'])) {
2579
-		$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2580
-	} else {
2581
-		$GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2582
-		if (!empty($_SERVER['QUERY_STRING'])
2583
-			and !strpos($_SERVER['REQUEST_URI'], '?')
2584
-		) {
2585
-			$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2586
-		}
2587
-	}
2588
-
2589
-	// Duree de validite de l'alea pour les cookies et ce qui s'ensuit.
2590
-	if (!defined('_RENOUVELLE_ALEA')) {
2591
-		define('_RENOUVELLE_ALEA', 12 * 3600);
2592
-	}
2593
-	if (!defined('_DUREE_COOKIE_ADMIN')) {
2594
-		define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600);
2595
-	}
2596
-
2597
-	// charger les meta si possible et renouveller l'alea au besoin
2598
-	// charge aussi effacer_meta et ecrire_meta
2599
-	$inc_meta = charger_fonction('meta', 'inc');
2600
-	$inc_meta();
2601
-
2602
-	// nombre de repertoires depuis la racine
2603
-	// on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
2604
-	// ou a defaut celle donnee en meta ; (mais si celle-ci est fausse
2605
-	// le calcul est faux)
2606
-	if (!_DIR_RESTREINT) {
2607
-		$GLOBALS['profondeur_url'] = 1;
2608
-	} else {
2609
-		$uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : '';
2610
-		$uri_ref = $_SERVER["SCRIPT_NAME"];
2611
-		if (!$uri_ref
2612
-			// si on est appele avec un autre ti, on est sans doute en mutu
2613
-			// si jamais c'est de la mutu avec sous rep, on est perdu si on se fie
2614
-			// a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer
2615
-			// s'en remettre a l'adresse du site. alea jacta est.
2616
-			or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES
2617
-		) {
2618
-
2619
-			if (isset($GLOBALS['meta']['adresse_site'])) {
2620
-				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2621
-				$uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/';
2622
-			} else {
2623
-				$uri_ref = "";
2624
-			}
2625
-		}
2626
-		if (!$uri or !$uri_ref) {
2627
-			$GLOBALS['profondeur_url'] = 0;
2628
-		} else {
2629
-			$GLOBALS['profondeur_url'] = max(0,
2630
-				substr_count($uri[0], '/')
2631
-				- substr_count($uri_ref, '/'));
2632
-		}
2633
-	}
2634
-	// s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
2635
-	if (_FILE_CONNECT) {
2636
-		if (verifier_visiteur() == '0minirezo'
2637
-			// si c'est un admin sans cookie admin, il faut ignorer le cache chemin !
2638
-			and !isset($_COOKIE['spip_admin'])
2639
-		) {
2640
-			clear_path_cache();
2641
-		}
2642
-	}
2333
+    static $too_late = 0;
2334
+    if ($too_late++) {
2335
+        return;
2336
+    }
2337
+
2338
+    // Declaration des repertoires
2339
+
2340
+    // le nom du repertoire plugins/ activables/desactivables
2341
+    if (!defined('_DIR_PLUGINS')) {
2342
+        define('_DIR_PLUGINS', _DIR_RACINE . "plugins/");
2343
+    }
2344
+
2345
+    // le nom du repertoire des extensions/ permanentes du core, toujours actives
2346
+    if (!defined('_DIR_PLUGINS_DIST')) {
2347
+        define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/");
2348
+    }
2349
+
2350
+    // le nom du repertoire des librairies
2351
+    if (!defined('_DIR_LIB')) {
2352
+        define('_DIR_LIB', _DIR_RACINE . "lib/");
2353
+    }
2354
+
2355
+    if (!defined('_DIR_IMG')) {
2356
+        define('_DIR_IMG', $pa);
2357
+    }
2358
+    if (!defined('_DIR_LOGOS')) {
2359
+        define('_DIR_LOGOS', $pa);
2360
+    }
2361
+    if (!defined('_DIR_IMG_ICONES')) {
2362
+        define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/");
2363
+    }
2364
+
2365
+    if (!defined('_DIR_DUMP')) {
2366
+        define('_DIR_DUMP', $ti . "dump/");
2367
+    }
2368
+    if (!defined('_DIR_SESSIONS')) {
2369
+        define('_DIR_SESSIONS', $ti . "sessions/");
2370
+    }
2371
+    if (!defined('_DIR_TRANSFERT')) {
2372
+        define('_DIR_TRANSFERT', $ti . "upload/");
2373
+    }
2374
+    if (!defined('_DIR_CACHE')) {
2375
+        define('_DIR_CACHE', $ti . "cache/");
2376
+    }
2377
+    if (!defined('_DIR_CACHE_XML')) {
2378
+        define('_DIR_CACHE_XML', _DIR_CACHE . "xml/");
2379
+    }
2380
+    if (!defined('_DIR_SKELS')) {
2381
+        define('_DIR_SKELS', _DIR_CACHE . "skel/");
2382
+    }
2383
+    if (!defined('_DIR_AIDE')) {
2384
+        define('_DIR_AIDE', _DIR_CACHE . "aide/");
2385
+    }
2386
+    if (!defined('_DIR_TMP')) {
2387
+        define('_DIR_TMP', $ti);
2388
+    }
2389
+
2390
+    if (!defined('_DIR_VAR')) {
2391
+        define('_DIR_VAR', $ta);
2392
+    }
2393
+
2394
+    if (!defined('_DIR_ETC')) {
2395
+        define('_DIR_ETC', $pi);
2396
+    }
2397
+    if (!defined('_DIR_CONNECT')) {
2398
+        define('_DIR_CONNECT', $pi);
2399
+    }
2400
+    if (!defined('_DIR_CHMOD')) {
2401
+        define('_DIR_CHMOD', $pi);
2402
+    }
2403
+
2404
+    if (!isset($GLOBALS['test_dirs']))
2405
+        // Pas $pi car il est bon de le mettre hors ecriture apres intstall
2406
+        // il sera rajoute automatiquement si besoin a l'etape 2 de l'install
2407
+    {
2408
+        $GLOBALS['test_dirs'] = array($pa, $ti, $ta);
2409
+    }
2410
+
2411
+    // Declaration des fichiers
2412
+
2413
+    if (!defined('_CACHE_PLUGINS_PATH')) {
2414
+        define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php");
2415
+    }
2416
+    if (!defined('_CACHE_PLUGINS_OPT')) {
2417
+        define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php");
2418
+    }
2419
+    if (!defined('_CACHE_PLUGINS_FCT')) {
2420
+        define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php");
2421
+    }
2422
+    if (!defined('_CACHE_PIPELINES')) {
2423
+        define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php");
2424
+    }
2425
+    if (!defined('_CACHE_CHEMIN')) {
2426
+        define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt");
2427
+    }
2428
+
2429
+    # attention .php obligatoire pour ecrire_fichier_securise
2430
+    if (!defined('_FILE_META')) {
2431
+        define('_FILE_META', $ti . 'meta_cache.php');
2432
+    }
2433
+    if (!defined('_DIR_LOG')) {
2434
+        define('_DIR_LOG', _DIR_TMP . 'log/');
2435
+    }
2436
+    if (!defined('_FILE_LOG')) {
2437
+        define('_FILE_LOG', 'spip');
2438
+    }
2439
+    if (!defined('_FILE_LOG_SUFFIX')) {
2440
+        define('_FILE_LOG_SUFFIX', '.log');
2441
+    }
2442
+
2443
+    // Le fichier de connexion a la base de donnees
2444
+    // tient compte des anciennes versions (inc_connect...)
2445
+    if (!defined('_FILE_CONNECT_INS')) {
2446
+        define('_FILE_CONNECT_INS', 'connect');
2447
+    }
2448
+    if (!defined('_FILE_CONNECT')) {
2449
+        define('_FILE_CONNECT',
2450
+        (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2451
+            : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2452
+                : false)));
2453
+    }
2454
+
2455
+    // Le fichier de reglages des droits
2456
+    if (!defined('_FILE_CHMOD_INS')) {
2457
+        define('_FILE_CHMOD_INS', 'chmod');
2458
+    }
2459
+    if (!defined('_FILE_CHMOD')) {
2460
+        define('_FILE_CHMOD',
2461
+        (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2462
+            : false));
2463
+    }
2464
+
2465
+    if (!defined('_FILE_LDAP')) {
2466
+        define('_FILE_LDAP', 'ldap.php');
2467
+    }
2468
+
2469
+    if (!defined('_FILE_TMP_SUFFIX')) {
2470
+        define('_FILE_TMP_SUFFIX', '.tmp.php');
2471
+    }
2472
+    if (!defined('_FILE_CONNECT_TMP')) {
2473
+        define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2474
+    }
2475
+    if (!defined('_FILE_CHMOD_TMP')) {
2476
+        define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2477
+    }
2478
+
2479
+    // Definition des droits d'acces en ecriture
2480
+    if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) {
2481
+        include_once _FILE_CHMOD;
2482
+    }
2483
+
2484
+    // Se mefier des fichiers mal remplis!
2485
+    if (!defined('_SPIP_CHMOD')) {
2486
+        define('_SPIP_CHMOD', 0777);
2487
+    }
2488
+
2489
+    if (!defined('_DEFAULT_CHARSET')) {
2490
+        /** Le charset par défaut lors de l'installation */
2491
+        define('_DEFAULT_CHARSET', 'utf-8');
2492
+    }
2493
+    if (!defined('_ROOT_PLUGINS')) {
2494
+        define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/");
2495
+    }
2496
+    if (!defined('_ROOT_PLUGINS_DIST')) {
2497
+        define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/");
2498
+    }
2499
+    if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2500
+        define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2501
+    }
2502
+
2503
+    // La taille des Log
2504
+    if (!defined('_MAX_LOG')) {
2505
+        define('_MAX_LOG', 100);
2506
+    }
2507
+
2508
+    // Sommes-nous dans l'empire du Mal ?
2509
+    // (ou sous le signe du Pingouin, ascendant GNU ?)
2510
+    if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) {
2511
+        if (!defined('_OS_SERVEUR')) {
2512
+            define('_OS_SERVEUR', 'windows');
2513
+        }
2514
+        if (!defined('_SPIP_LOCK_MODE')) {
2515
+            define('_SPIP_LOCK_MODE', 1);
2516
+        } // utiliser le flock php
2517
+    } else {
2518
+        if (!defined('_OS_SERVEUR')) {
2519
+            define('_OS_SERVEUR', '');
2520
+        }
2521
+        if (!defined('_SPIP_LOCK_MODE')) {
2522
+            define('_SPIP_LOCK_MODE', 1);
2523
+        } // utiliser le flock php
2524
+        #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
2525
+    }
2526
+
2527
+    // Langue par defaut
2528
+    if (!defined('_LANGUE_PAR_DEFAUT')) {
2529
+        define('_LANGUE_PAR_DEFAUT', 'fr');
2530
+    }
2531
+
2532
+    //
2533
+    // Module de lecture/ecriture/suppression de fichiers utilisant flock()
2534
+    // (non surchargeable en l'etat ; attention si on utilise include_spip()
2535
+    // pour le rendre surchargeable, on va provoquer un reecriture
2536
+    // systematique du noyau ou une baisse de perfs => a etudier)
2537
+    include_once _ROOT_RESTREINT . 'inc/flock.php';
2538
+
2539
+    // charger tout de suite le path et son cache
2540
+    load_path_cache();
2541
+
2542
+    // *********** traiter les variables ************
2543
+
2544
+    //
2545
+    // Securite
2546
+    //
2547
+
2548
+    // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
2549
+    if (isset($_REQUEST['GLOBALS'])) {
2550
+        die();
2551
+    }
2552
+    // nettoyer les magic quotes \' et les caracteres nuls %00
2553
+    spip_desinfecte($_GET);
2554
+    spip_desinfecte($_POST);
2555
+    spip_desinfecte($_COOKIE);
2556
+    spip_desinfecte($_REQUEST);
2557
+
2558
+    // appliquer le cookie_prefix
2559
+    if ($GLOBALS['cookie_prefix'] != 'spip') {
2560
+        include_spip('inc/cookie');
2561
+        recuperer_cookies_spip($GLOBALS['cookie_prefix']);
2562
+    }
2563
+
2564
+    //
2565
+    // Capacites php (en fonction de la version)
2566
+    //
2567
+    $GLOBALS['flag_ob'] = (function_exists("ob_start")
2568
+        && function_exists("ini_get")
2569
+        && !strstr(@ini_get('disable_functions'), 'ob_'));
2570
+    $GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name");
2571
+    $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != "");
2572
+    $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] ||
2573
+        (get_cfg_var('upload_max_filesize') > 0));
2574
+
2575
+
2576
+    // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI
2577
+    if (isset($_SERVER['REQUEST_URI'])) {
2578
+        $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2579
+    } else {
2580
+        $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2581
+        if (!empty($_SERVER['QUERY_STRING'])
2582
+            and !strpos($_SERVER['REQUEST_URI'], '?')
2583
+        ) {
2584
+            $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2585
+        }
2586
+    }
2587
+
2588
+    // Duree de validite de l'alea pour les cookies et ce qui s'ensuit.
2589
+    if (!defined('_RENOUVELLE_ALEA')) {
2590
+        define('_RENOUVELLE_ALEA', 12 * 3600);
2591
+    }
2592
+    if (!defined('_DUREE_COOKIE_ADMIN')) {
2593
+        define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600);
2594
+    }
2595
+
2596
+    // charger les meta si possible et renouveller l'alea au besoin
2597
+    // charge aussi effacer_meta et ecrire_meta
2598
+    $inc_meta = charger_fonction('meta', 'inc');
2599
+    $inc_meta();
2600
+
2601
+    // nombre de repertoires depuis la racine
2602
+    // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
2603
+    // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse
2604
+    // le calcul est faux)
2605
+    if (!_DIR_RESTREINT) {
2606
+        $GLOBALS['profondeur_url'] = 1;
2607
+    } else {
2608
+        $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : '';
2609
+        $uri_ref = $_SERVER["SCRIPT_NAME"];
2610
+        if (!$uri_ref
2611
+            // si on est appele avec un autre ti, on est sans doute en mutu
2612
+            // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie
2613
+            // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer
2614
+            // s'en remettre a l'adresse du site. alea jacta est.
2615
+            or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES
2616
+        ) {
2617
+
2618
+            if (isset($GLOBALS['meta']['adresse_site'])) {
2619
+                $uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2620
+                $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/';
2621
+            } else {
2622
+                $uri_ref = "";
2623
+            }
2624
+        }
2625
+        if (!$uri or !$uri_ref) {
2626
+            $GLOBALS['profondeur_url'] = 0;
2627
+        } else {
2628
+            $GLOBALS['profondeur_url'] = max(0,
2629
+                substr_count($uri[0], '/')
2630
+                - substr_count($uri_ref, '/'));
2631
+        }
2632
+    }
2633
+    // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
2634
+    if (_FILE_CONNECT) {
2635
+        if (verifier_visiteur() == '0minirezo'
2636
+            // si c'est un admin sans cookie admin, il faut ignorer le cache chemin !
2637
+            and !isset($_COOKIE['spip_admin'])
2638
+        ) {
2639
+            clear_path_cache();
2640
+        }
2641
+    }
2643 2642
 
2644 2643
 }
2645 2644
 
@@ -2649,174 +2648,174 @@  discard block
 block discarded – undo
2649 2648
  *
2650 2649
  */
2651 2650
 function spip_initialisation_suite() {
2652
-	static $too_late = 0;
2653
-	if ($too_late++) {
2654
-		return;
2655
-	}
2656
-
2657
-	// taille mini des login
2658
-	if (!defined('_LOGIN_TROP_COURT')) {
2659
-		define('_LOGIN_TROP_COURT', 4);
2660
-	}
2661
-
2662
-	// la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2663
-	#if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko
2664
-	#if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels
2665
-	#if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels
2666
-
2667
-	// la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2668
-	#if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko
2669
-	#if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko
2670
-	#if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels
2671
-	#if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels
2672
-
2673
-	if (!defined('_PASS_LONGUEUR_MINI')) {
2674
-		define('_PASS_LONGUEUR_MINI', 6);
2675
-	}
2676
-
2677
-
2678
-	// Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)
2679
-	if (!defined('_IMG_QUALITE')) {
2680
-		define('_IMG_QUALITE', 85);
2681
-	} # valeur par defaut
2682
-	if (!defined('_IMG_GD_QUALITE')) {
2683
-		define('_IMG_GD_QUALITE', _IMG_QUALITE);
2684
-	} # surcharge pour la lib GD
2685
-	if (!defined('_IMG_CONVERT_QUALITE')) {
2686
-		define('_IMG_CONVERT_QUALITE', _IMG_QUALITE);
2687
-	} # surcharge pour imagick en ligne de commande
2688
-	// Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE
2689
-	if (!defined('_IMG_IMAGICK_QUALITE')) {
2690
-		define('_IMG_IMAGICK_QUALITE', 75);
2691
-	} # surcharge pour imagick en PHP
2692
-
2693
-	if (!defined('_COPIE_LOCALE_MAX_SIZE')) {
2694
-		define('_COPIE_LOCALE_MAX_SIZE', 33554432);
2695
-	} // poids en octet
2696
-
2697
-	// qq chaines standard
2698
-	if (!defined('_ACCESS_FILE_NAME')) {
2699
-		define('_ACCESS_FILE_NAME', '.htaccess');
2700
-	}
2701
-	if (!defined('_AUTH_USER_FILE')) {
2702
-		define('_AUTH_USER_FILE', '.htpasswd');
2703
-	}
2704
-	if (!defined('_SPIP_DUMP')) {
2705
-		define('_SPIP_DUMP', 'dump@nom_site@@[email protected]');
2706
-	}
2707
-	if (!defined('_CACHE_RUBRIQUES')) {
2708
-		/** Fichier cache pour le navigateur de rubrique du bandeau */
2709
-		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2710
-	}
2711
-	if (!defined('_CACHE_RUBRIQUES_MAX')) {
2712
-		/** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
2713
-		define('_CACHE_RUBRIQUES_MAX', 500);
2714
-	}
2715
-
2716
-	if (!defined('_EXTENSION_SQUELETTES')) {
2717
-		define('_EXTENSION_SQUELETTES', 'html');
2718
-	}
2719
-
2720
-	if (!defined('_DOCTYPE_ECRIRE')) {
2721
-		/** Définit le doctype de l’espace privé */
2722
-		define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n");
2723
-	}
2724
-	if (!defined('_DOCTYPE_AIDE')) {
2725
-		/** Définit le doctype de l’aide en ligne */
2726
-		define('_DOCTYPE_AIDE',
2727
-		"<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>");
2728
-	}
2729
-
2730
-	if (!defined('_SPIP_SCRIPT')) {
2731
-		/** L'adresse de base du site ; on peut mettre '' si la racine est gerée par
2732
-		 * le script de l'espace public, alias index.php */
2733
-		define('_SPIP_SCRIPT', 'spip.php');
2734
-	}
2735
-	if (!defined('_SPIP_PAGE')) {
2736
-		/** Argument page, personalisable en cas de conflit avec un autre script */
2737
-		define('_SPIP_PAGE', 'page');
2738
-	}
2739
-
2740
-	// le script de l'espace prive
2741
-	// Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:
2742
-	// les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)
2743
-	// meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html
2744
-	if (!defined('_SPIP_ECRIRE_SCRIPT')) {
2745
-		if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) {
2746
-			define('_SPIP_ECRIRE_SCRIPT', 'index.php');
2747
-		} else {
2748
-			define('_SPIP_ECRIRE_SCRIPT', '');
2749
-		}
2750
-	}
2751
-
2752
-
2753
-	if (!defined('_SPIP_AJAX')) {
2754
-		define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax']))
2755
-			? 1
2756
-			: (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));
2757
-	}
2758
-
2759
-	// La requete est-elle en ajax ?
2760
-	if (!defined('_AJAX')) {
2761
-		define('_AJAX',
2762
-			(isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery
2763
-				or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery
2764
-				or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins
2765
-				or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip
2766
-			)
2767
-			and empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient
2768
-		);
2769
-	}
2770
-
2771
-	# nombre de pixels maxi pour calcul de la vignette avec gd
2772
-	# au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation
2773
-	# les configurations limitees en memoire ont un seuil plutot vers 1MPixel
2774
-	if (!defined('_IMG_GD_MAX_PIXELS')) {
2775
-		define('_IMG_GD_MAX_PIXELS',
2776
-		(isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes'])
2777
-			? $GLOBALS['meta']['max_taille_vignettes']
2778
-			: 0);
2779
-	}
2780
-
2781
-	if (!defined('_MEMORY_LIMIT_MIN')) {
2782
-		define('_MEMORY_LIMIT_MIN', 16);
2783
-	} // en Mo
2784
-	// si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard)
2785
-	// on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche
2786
-	// il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche
2787
-	if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) {
2788
-		if ($memory = trim(ini_get('memory_limit')) and $memory != -1) {
2789
-			$unit = strtolower(substr($memory, -1));
2790
-			$memory = substr($memory, 0, -1);
2791
-			switch ($unit) {
2792
-				// Le modifieur 'G' est disponible depuis PHP 5.1.0
2793
-				case 'g':
2794
-					$memory *= 1024;
2795
-				case 'm':
2796
-					$memory *= 1024;
2797
-				case 'k':
2798
-					$memory *= 1024;
2799
-			}
2800
-			if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) {
2801
-				@ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M');
2802
-				if (trim(ini_get('memory_limit')) != $m) {
2803
-					if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2804
-						define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
2805
-					} // evite une page blanche car on ne saura pas calculer la css dans ce hit
2806
-				}
2807
-			}
2808
-		} else {
2809
-			if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2810
-				define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
2811
-			}
2812
-		} // evite une page blanche car on ne saura pas calculer la css dans ce hit
2813
-	}
2814
-	// Protocoles a normaliser dans les chaines de langues
2815
-	if (!defined('_PROTOCOLES_STD')) {
2816
-		define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal');
2817
-	}
2818
-
2819
-	init_var_mode();
2651
+    static $too_late = 0;
2652
+    if ($too_late++) {
2653
+        return;
2654
+    }
2655
+
2656
+    // taille mini des login
2657
+    if (!defined('_LOGIN_TROP_COURT')) {
2658
+        define('_LOGIN_TROP_COURT', 4);
2659
+    }
2660
+
2661
+    // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2662
+    #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko
2663
+    #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels
2664
+    #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels
2665
+
2666
+    // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2667
+    #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko
2668
+    #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko
2669
+    #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels
2670
+    #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels
2671
+
2672
+    if (!defined('_PASS_LONGUEUR_MINI')) {
2673
+        define('_PASS_LONGUEUR_MINI', 6);
2674
+    }
2675
+
2676
+
2677
+    // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)
2678
+    if (!defined('_IMG_QUALITE')) {
2679
+        define('_IMG_QUALITE', 85);
2680
+    } # valeur par defaut
2681
+    if (!defined('_IMG_GD_QUALITE')) {
2682
+        define('_IMG_GD_QUALITE', _IMG_QUALITE);
2683
+    } # surcharge pour la lib GD
2684
+    if (!defined('_IMG_CONVERT_QUALITE')) {
2685
+        define('_IMG_CONVERT_QUALITE', _IMG_QUALITE);
2686
+    } # surcharge pour imagick en ligne de commande
2687
+    // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE
2688
+    if (!defined('_IMG_IMAGICK_QUALITE')) {
2689
+        define('_IMG_IMAGICK_QUALITE', 75);
2690
+    } # surcharge pour imagick en PHP
2691
+
2692
+    if (!defined('_COPIE_LOCALE_MAX_SIZE')) {
2693
+        define('_COPIE_LOCALE_MAX_SIZE', 33554432);
2694
+    } // poids en octet
2695
+
2696
+    // qq chaines standard
2697
+    if (!defined('_ACCESS_FILE_NAME')) {
2698
+        define('_ACCESS_FILE_NAME', '.htaccess');
2699
+    }
2700
+    if (!defined('_AUTH_USER_FILE')) {
2701
+        define('_AUTH_USER_FILE', '.htpasswd');
2702
+    }
2703
+    if (!defined('_SPIP_DUMP')) {
2704
+        define('_SPIP_DUMP', 'dump@nom_site@@[email protected]');
2705
+    }
2706
+    if (!defined('_CACHE_RUBRIQUES')) {
2707
+        /** Fichier cache pour le navigateur de rubrique du bandeau */
2708
+        define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2709
+    }
2710
+    if (!defined('_CACHE_RUBRIQUES_MAX')) {
2711
+        /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
2712
+        define('_CACHE_RUBRIQUES_MAX', 500);
2713
+    }
2714
+
2715
+    if (!defined('_EXTENSION_SQUELETTES')) {
2716
+        define('_EXTENSION_SQUELETTES', 'html');
2717
+    }
2718
+
2719
+    if (!defined('_DOCTYPE_ECRIRE')) {
2720
+        /** Définit le doctype de l’espace privé */
2721
+        define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n");
2722
+    }
2723
+    if (!defined('_DOCTYPE_AIDE')) {
2724
+        /** Définit le doctype de l’aide en ligne */
2725
+        define('_DOCTYPE_AIDE',
2726
+        "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>");
2727
+    }
2728
+
2729
+    if (!defined('_SPIP_SCRIPT')) {
2730
+        /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par
2731
+         * le script de l'espace public, alias index.php */
2732
+        define('_SPIP_SCRIPT', 'spip.php');
2733
+    }
2734
+    if (!defined('_SPIP_PAGE')) {
2735
+        /** Argument page, personalisable en cas de conflit avec un autre script */
2736
+        define('_SPIP_PAGE', 'page');
2737
+    }
2738
+
2739
+    // le script de l'espace prive
2740
+    // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:
2741
+    // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)
2742
+    // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html
2743
+    if (!defined('_SPIP_ECRIRE_SCRIPT')) {
2744
+        if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) {
2745
+            define('_SPIP_ECRIRE_SCRIPT', 'index.php');
2746
+        } else {
2747
+            define('_SPIP_ECRIRE_SCRIPT', '');
2748
+        }
2749
+    }
2750
+
2751
+
2752
+    if (!defined('_SPIP_AJAX')) {
2753
+        define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax']))
2754
+            ? 1
2755
+            : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));
2756
+    }
2757
+
2758
+    // La requete est-elle en ajax ?
2759
+    if (!defined('_AJAX')) {
2760
+        define('_AJAX',
2761
+            (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery
2762
+                or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery
2763
+                or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins
2764
+                or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip
2765
+            )
2766
+            and empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient
2767
+        );
2768
+    }
2769
+
2770
+    # nombre de pixels maxi pour calcul de la vignette avec gd
2771
+    # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation
2772
+    # les configurations limitees en memoire ont un seuil plutot vers 1MPixel
2773
+    if (!defined('_IMG_GD_MAX_PIXELS')) {
2774
+        define('_IMG_GD_MAX_PIXELS',
2775
+        (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes'])
2776
+            ? $GLOBALS['meta']['max_taille_vignettes']
2777
+            : 0);
2778
+    }
2779
+
2780
+    if (!defined('_MEMORY_LIMIT_MIN')) {
2781
+        define('_MEMORY_LIMIT_MIN', 16);
2782
+    } // en Mo
2783
+    // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard)
2784
+    // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche
2785
+    // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche
2786
+    if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) {
2787
+        if ($memory = trim(ini_get('memory_limit')) and $memory != -1) {
2788
+            $unit = strtolower(substr($memory, -1));
2789
+            $memory = substr($memory, 0, -1);
2790
+            switch ($unit) {
2791
+                // Le modifieur 'G' est disponible depuis PHP 5.1.0
2792
+                case 'g':
2793
+                    $memory *= 1024;
2794
+                case 'm':
2795
+                    $memory *= 1024;
2796
+                case 'k':
2797
+                    $memory *= 1024;
2798
+            }
2799
+            if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) {
2800
+                @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M');
2801
+                if (trim(ini_get('memory_limit')) != $m) {
2802
+                    if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2803
+                        define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
2804
+                    } // evite une page blanche car on ne saura pas calculer la css dans ce hit
2805
+                }
2806
+            }
2807
+        } else {
2808
+            if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2809
+                define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
2810
+            }
2811
+        } // evite une page blanche car on ne saura pas calculer la css dans ce hit
2812
+    }
2813
+    // Protocoles a normaliser dans les chaines de langues
2814
+    if (!defined('_PROTOCOLES_STD')) {
2815
+        define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal');
2816
+    }
2817
+
2818
+    init_var_mode();
2820 2819
 }
2821 2820
 
2822 2821
 /**
@@ -2850,129 +2849,129 @@  discard block
 block discarded – undo
2850 2849
  * `   var_mode` (calcul ou recalcul).
2851 2850
  */
2852 2851
 function init_var_mode() {
2853
-	static $done = false;
2854
-	if (!$done) {
2855
-
2856
-		if (isset($_GET['var_mode'])) {
2857
-			$var_mode = explode(',', $_GET['var_mode']);
2858
-			// tout le monde peut calcul/recalcul
2859
-			if (!defined('_VAR_MODE')) {
2860
-				if (in_array('recalcul', $var_mode)) {
2861
-					define('_VAR_MODE', 'recalcul');
2862
-				} elseif (in_array('calcul', $var_mode)) {
2863
-					define('_VAR_MODE', 'calcul');
2864
-				}
2865
-			}
2866
-			$var_mode = array_diff($var_mode, array('calcul', 'recalcul'));
2867
-			if ($var_mode) {
2868
-				include_spip('inc/autoriser');
2869
-				// autoriser preview si preview seulement, et sinon autoriser debug
2870
-				if (autoriser(
2871
-					($_GET['var_mode'] == 'preview')
2872
-						? 'previsualiser'
2873
-						: 'debug'
2874
-				)) {
2875
-					if (in_array('traduction', $var_mode)) {
2876
-						// forcer le calcul pour passer dans traduire
2877
-						if (!defined('_VAR_MODE')) {
2878
-							define('_VAR_MODE', 'calcul');
2879
-						}
2880
-						// et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages
2881
-						if (!defined('_VAR_NOCACHE')) {
2882
-							define('_VAR_NOCACHE', true);
2883
-						}
2884
-						$var_mode = array_diff($var_mode, array('traduction'));
2885
-					}
2886
-					if (in_array('preview', $var_mode)) {
2887
-						// basculer sur les criteres de preview dans les boucles
2888
-						if (!defined('_VAR_PREVIEW')) {
2889
-							define('_VAR_PREVIEW', true);
2890
-						}
2891
-						// forcer le calcul
2892
-						if (!defined('_VAR_MODE')) {
2893
-							define('_VAR_MODE', 'calcul');
2894
-						}
2895
-						// et ne pas enregistrer de cache
2896
-						if (!defined('_VAR_NOCACHE')) {
2897
-							define('_VAR_NOCACHE', true);
2898
-						}
2899
-						$var_mode = array_diff($var_mode, array('preview'));
2900
-					}
2901
-					if (in_array('inclure', $var_mode)) {
2902
-						// forcer le compilo et ignorer les caches existants
2903
-						if (!defined('_VAR_MODE')) {
2904
-							define('_VAR_MODE', 'calcul');
2905
-						}
2906
-						if (!defined('_VAR_INCLURE')) {
2907
-							define('_VAR_INCLURE', true);
2908
-						}
2909
-						// et ne pas enregistrer de cache
2910
-						if (!defined('_VAR_NOCACHE')) {
2911
-							define('_VAR_NOCACHE', true);
2912
-						}
2913
-						$var_mode = array_diff($var_mode, array('inclure'));
2914
-					}
2915
-					if (in_array('urls', $var_mode)) {
2916
-						// forcer le compilo et ignorer les caches existants
2917
-						if (!defined('_VAR_MODE')) {
2918
-							define('_VAR_MODE', 'calcul');
2919
-						}
2920
-						if (!defined('_VAR_URLS')) {
2921
-							define('_VAR_URLS', true);
2922
-						}
2923
-						$var_mode = array_diff($var_mode, array('urls'));
2924
-					}
2925
-					if (in_array('images', $var_mode)) {
2926
-						// forcer le compilo et ignorer les caches existants
2927
-						if (!defined('_VAR_MODE')) {
2928
-							define('_VAR_MODE', 'calcul');
2929
-						}
2930
-						// indiquer qu'on doit recalculer les images
2931
-						if (!defined('_VAR_IMAGES')) {
2932
-							define('_VAR_IMAGES', true);
2933
-						}
2934
-						$var_mode = array_diff($var_mode, array('images'));
2935
-					}
2936
-					if (in_array('debug', $var_mode)) {
2937
-						if (!defined('_VAR_MODE')) {
2938
-							define('_VAR_MODE', 'debug');
2939
-						}
2940
-						// et ne pas enregistrer de cache
2941
-						if (!defined('_VAR_NOCACHE')) {
2942
-							define('_VAR_NOCACHE', true);
2943
-						}
2944
-						$var_mode = array_diff($var_mode, array('debug'));
2945
-					}
2946
-					if (count($var_mode) and !defined('_VAR_MODE')) {
2947
-						define('_VAR_MODE', reset($var_mode));
2948
-					}
2949
-					if (isset($GLOBALS['visiteur_session']['nom'])) {
2950
-						spip_log($GLOBALS['visiteur_session']['nom']
2951
-							. " " . _VAR_MODE);
2952
-					}
2953
-				} // pas autorise ?
2954
-				else {
2955
-					// si on n'est pas connecte on se redirige
2956
-					if (!$GLOBALS['visiteur_session']) {
2957
-						include_spip('inc/headers');
2958
-						redirige_par_entete(generer_url_public('login',
2959
-							'url=' . rawurlencode(
2960
-								parametre_url(self(), 'var_mode', $_GET['var_mode'], '&')
2961
-							), true));
2962
-					}
2963
-					// sinon tant pis
2964
-				}
2965
-			}
2966
-		}
2967
-		if (!defined('_VAR_MODE')) {
2968
-			/**
2969
-			 * Indique le mode de calcul ou d'affichage de la page.
2970
-			 * @see init_var_mode()
2971
-			 */
2972
-			define('_VAR_MODE', false);
2973
-		}
2974
-		$done = true;
2975
-	}
2852
+    static $done = false;
2853
+    if (!$done) {
2854
+
2855
+        if (isset($_GET['var_mode'])) {
2856
+            $var_mode = explode(',', $_GET['var_mode']);
2857
+            // tout le monde peut calcul/recalcul
2858
+            if (!defined('_VAR_MODE')) {
2859
+                if (in_array('recalcul', $var_mode)) {
2860
+                    define('_VAR_MODE', 'recalcul');
2861
+                } elseif (in_array('calcul', $var_mode)) {
2862
+                    define('_VAR_MODE', 'calcul');
2863
+                }
2864
+            }
2865
+            $var_mode = array_diff($var_mode, array('calcul', 'recalcul'));
2866
+            if ($var_mode) {
2867
+                include_spip('inc/autoriser');
2868
+                // autoriser preview si preview seulement, et sinon autoriser debug
2869
+                if (autoriser(
2870
+                    ($_GET['var_mode'] == 'preview')
2871
+                        ? 'previsualiser'
2872
+                        : 'debug'
2873
+                )) {
2874
+                    if (in_array('traduction', $var_mode)) {
2875
+                        // forcer le calcul pour passer dans traduire
2876
+                        if (!defined('_VAR_MODE')) {
2877
+                            define('_VAR_MODE', 'calcul');
2878
+                        }
2879
+                        // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages
2880
+                        if (!defined('_VAR_NOCACHE')) {
2881
+                            define('_VAR_NOCACHE', true);
2882
+                        }
2883
+                        $var_mode = array_diff($var_mode, array('traduction'));
2884
+                    }
2885
+                    if (in_array('preview', $var_mode)) {
2886
+                        // basculer sur les criteres de preview dans les boucles
2887
+                        if (!defined('_VAR_PREVIEW')) {
2888
+                            define('_VAR_PREVIEW', true);
2889
+                        }
2890
+                        // forcer le calcul
2891
+                        if (!defined('_VAR_MODE')) {
2892
+                            define('_VAR_MODE', 'calcul');
2893
+                        }
2894
+                        // et ne pas enregistrer de cache
2895
+                        if (!defined('_VAR_NOCACHE')) {
2896
+                            define('_VAR_NOCACHE', true);
2897
+                        }
2898
+                        $var_mode = array_diff($var_mode, array('preview'));
2899
+                    }
2900
+                    if (in_array('inclure', $var_mode)) {
2901
+                        // forcer le compilo et ignorer les caches existants
2902
+                        if (!defined('_VAR_MODE')) {
2903
+                            define('_VAR_MODE', 'calcul');
2904
+                        }
2905
+                        if (!defined('_VAR_INCLURE')) {
2906
+                            define('_VAR_INCLURE', true);
2907
+                        }
2908
+                        // et ne pas enregistrer de cache
2909
+                        if (!defined('_VAR_NOCACHE')) {
2910
+                            define('_VAR_NOCACHE', true);
2911
+                        }
2912
+                        $var_mode = array_diff($var_mode, array('inclure'));
2913
+                    }
2914
+                    if (in_array('urls', $var_mode)) {
2915
+                        // forcer le compilo et ignorer les caches existants
2916
+                        if (!defined('_VAR_MODE')) {
2917
+                            define('_VAR_MODE', 'calcul');
2918
+                        }
2919
+                        if (!defined('_VAR_URLS')) {
2920
+                            define('_VAR_URLS', true);
2921
+                        }
2922
+                        $var_mode = array_diff($var_mode, array('urls'));
2923
+                    }
2924
+                    if (in_array('images', $var_mode)) {
2925
+                        // forcer le compilo et ignorer les caches existants
2926
+                        if (!defined('_VAR_MODE')) {
2927
+                            define('_VAR_MODE', 'calcul');
2928
+                        }
2929
+                        // indiquer qu'on doit recalculer les images
2930
+                        if (!defined('_VAR_IMAGES')) {
2931
+                            define('_VAR_IMAGES', true);
2932
+                        }
2933
+                        $var_mode = array_diff($var_mode, array('images'));
2934
+                    }
2935
+                    if (in_array('debug', $var_mode)) {
2936
+                        if (!defined('_VAR_MODE')) {
2937
+                            define('_VAR_MODE', 'debug');
2938
+                        }
2939
+                        // et ne pas enregistrer de cache
2940
+                        if (!defined('_VAR_NOCACHE')) {
2941
+                            define('_VAR_NOCACHE', true);
2942
+                        }
2943
+                        $var_mode = array_diff($var_mode, array('debug'));
2944
+                    }
2945
+                    if (count($var_mode) and !defined('_VAR_MODE')) {
2946
+                        define('_VAR_MODE', reset($var_mode));
2947
+                    }
2948
+                    if (isset($GLOBALS['visiteur_session']['nom'])) {
2949
+                        spip_log($GLOBALS['visiteur_session']['nom']
2950
+                            . " " . _VAR_MODE);
2951
+                    }
2952
+                } // pas autorise ?
2953
+                else {
2954
+                    // si on n'est pas connecte on se redirige
2955
+                    if (!$GLOBALS['visiteur_session']) {
2956
+                        include_spip('inc/headers');
2957
+                        redirige_par_entete(generer_url_public('login',
2958
+                            'url=' . rawurlencode(
2959
+                                parametre_url(self(), 'var_mode', $_GET['var_mode'], '&')
2960
+                            ), true));
2961
+                    }
2962
+                    // sinon tant pis
2963
+                }
2964
+            }
2965
+        }
2966
+        if (!defined('_VAR_MODE')) {
2967
+            /**
2968
+             * Indique le mode de calcul ou d'affichage de la page.
2969
+             * @see init_var_mode()
2970
+             */
2971
+            define('_VAR_MODE', false);
2972
+        }
2973
+        $done = true;
2974
+    }
2976 2975
 }
2977 2976
 
2978 2977
 // Annuler les magic quotes \' sur GET POST COOKIE et GLOBALS ;
@@ -2980,85 +2979,85 @@  discard block
 block discarded – undo
2980 2979
 // la commande is_readable('chemin/vers/fichier/interdit%00truc_normal')
2981 2980
 // https://code.spip.net/@spip_desinfecte
2982 2981
 function spip_desinfecte(&$t, $deep = true) {
2983
-	foreach ($t as $key => $val) {
2984
-		if (is_string($t[$key])) {
2985
-			$t[$key] = str_replace(chr(0), '-', $t[$key]);
2986
-		} // traiter aussi les "texte_plus" de article_edit
2987
-		else {
2988
-			if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') {
2989
-				spip_desinfecte($t[$key], $deep);
2990
-			}
2991
-		}
2992
-	}
2982
+    foreach ($t as $key => $val) {
2983
+        if (is_string($t[$key])) {
2984
+            $t[$key] = str_replace(chr(0), '-', $t[$key]);
2985
+        } // traiter aussi les "texte_plus" de article_edit
2986
+        else {
2987
+            if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') {
2988
+                spip_desinfecte($t[$key], $deep);
2989
+            }
2990
+        }
2991
+    }
2993 2992
 }
2994 2993
 
2995 2994
 //  retourne le statut du visiteur s'il s'annonce
2996 2995
 
2997 2996
 // https://code.spip.net/@verifier_visiteur
2998 2997
 function verifier_visiteur() {
2999
-	// Rq: pour que cette fonction marche depuis mes_options
3000
-	// il faut forcer l'init si ce n'est fait
3001
-	// mais on risque de perturber des plugins en initialisant trop tot
3002
-	// certaines constantes
3003
-	@spip_initialisation_core(
3004
-		(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3005
-		(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3006
-		(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3007
-		(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3008
-	);
3009
-
3010
-	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
3011
-	// dans un formulaire sans login (ex: #FORMULAIRE_FORUM)
3012
-	// Attention on separe bien session_nom et nom, pour eviter
3013
-	// les melanges entre donnees SQL et variables plus aleatoires
3014
-	$variables_session = array('session_nom', 'session_email');
3015
-	foreach ($variables_session as $var) {
3016
-		if (_request($var) !== null) {
3017
-			$init = true;
3018
-			break;
3019
-		}
3020
-	}
3021
-	if (isset($init)) {
3022
-		#@spip_initialisation_suite();
3023
-		$session = charger_fonction('session', 'inc');
3024
-		$session();
3025
-		include_spip('inc/texte');
3026
-		foreach ($variables_session as $var) {
3027
-			if (($a = _request($var)) !== null) {
3028
-				$GLOBALS['visiteur_session'][$var] = safehtml($a);
3029
-			}
3030
-		}
3031
-		if (!isset($GLOBALS['visiteur_session']['id_auteur'])) {
3032
-			$GLOBALS['visiteur_session']['id_auteur'] = 0;
3033
-		}
3034
-		$session($GLOBALS['visiteur_session']);
3035
-
3036
-		return 0;
3037
-	}
3038
-
3039
-	$h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3040
-	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3041
-
3042
-		$session = charger_fonction('session', 'inc');
3043
-		if ($session()) {
3044
-			return $GLOBALS['visiteur_session']['statut'];
3045
-		}
3046
-		if ($h and isset($_SERVER['PHP_AUTH_PW'])) {
3047
-			include_spip('inc/auth');
3048
-			$h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
3049
-		}
3050
-		if ($h) {
3051
-			$GLOBALS['visiteur_session'] = $h;
3052
-
3053
-			return $GLOBALS['visiteur_session']['statut'];
3054
-		}
3055
-	}
3056
-
3057
-	// au moins son navigateur nous dit la langue preferee de cet inconnu
3058
-	include_spip('inc/lang');
3059
-	utiliser_langue_visiteur();
3060
-
3061
-	return false;
2998
+    // Rq: pour que cette fonction marche depuis mes_options
2999
+    // il faut forcer l'init si ce n'est fait
3000
+    // mais on risque de perturber des plugins en initialisant trop tot
3001
+    // certaines constantes
3002
+    @spip_initialisation_core(
3003
+        (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3004
+        (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3005
+        (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3006
+        (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3007
+    );
3008
+
3009
+    // Demarrer une session NON AUTHENTIFIEE si on donne son nom
3010
+    // dans un formulaire sans login (ex: #FORMULAIRE_FORUM)
3011
+    // Attention on separe bien session_nom et nom, pour eviter
3012
+    // les melanges entre donnees SQL et variables plus aleatoires
3013
+    $variables_session = array('session_nom', 'session_email');
3014
+    foreach ($variables_session as $var) {
3015
+        if (_request($var) !== null) {
3016
+            $init = true;
3017
+            break;
3018
+        }
3019
+    }
3020
+    if (isset($init)) {
3021
+        #@spip_initialisation_suite();
3022
+        $session = charger_fonction('session', 'inc');
3023
+        $session();
3024
+        include_spip('inc/texte');
3025
+        foreach ($variables_session as $var) {
3026
+            if (($a = _request($var)) !== null) {
3027
+                $GLOBALS['visiteur_session'][$var] = safehtml($a);
3028
+            }
3029
+        }
3030
+        if (!isset($GLOBALS['visiteur_session']['id_auteur'])) {
3031
+            $GLOBALS['visiteur_session']['id_auteur'] = 0;
3032
+        }
3033
+        $session($GLOBALS['visiteur_session']);
3034
+
3035
+        return 0;
3036
+    }
3037
+
3038
+    $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3039
+    if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3040
+
3041
+        $session = charger_fonction('session', 'inc');
3042
+        if ($session()) {
3043
+            return $GLOBALS['visiteur_session']['statut'];
3044
+        }
3045
+        if ($h and isset($_SERVER['PHP_AUTH_PW'])) {
3046
+            include_spip('inc/auth');
3047
+            $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
3048
+        }
3049
+        if ($h) {
3050
+            $GLOBALS['visiteur_session'] = $h;
3051
+
3052
+            return $GLOBALS['visiteur_session']['statut'];
3053
+        }
3054
+    }
3055
+
3056
+    // au moins son navigateur nous dit la langue preferee de cet inconnu
3057
+    include_spip('inc/lang');
3058
+    utiliser_langue_visiteur();
3059
+
3060
+    return false;
3062 3061
 }
3063 3062
 
3064 3063
 
@@ -3081,21 +3080,21 @@  discard block
 block discarded – undo
3081 3080
  *     - string Langue utilisée.
3082 3081
  **/
3083 3082
 function lang_select($lang = null) {
3084
-	static $pile_langues = array();
3085
-	if (!function_exists('changer_langue')) {
3086
-		include_spip('inc/lang');
3087
-	}
3088
-	if ($lang === null) {
3089
-		$lang = array_pop($pile_langues);
3090
-	} else {
3091
-		array_push($pile_langues, $GLOBALS['spip_lang']);
3092
-	}
3093
-	if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) {
3094
-		return $lang;
3095
-	}
3096
-	changer_langue($lang);
3083
+    static $pile_langues = array();
3084
+    if (!function_exists('changer_langue')) {
3085
+        include_spip('inc/lang');
3086
+    }
3087
+    if ($lang === null) {
3088
+        $lang = array_pop($pile_langues);
3089
+    } else {
3090
+        array_push($pile_langues, $GLOBALS['spip_lang']);
3091
+    }
3092
+    if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) {
3093
+        return $lang;
3094
+    }
3095
+    changer_langue($lang);
3097 3096
 
3098
-	return $lang;
3097
+    return $lang;
3099 3098
 }
3100 3099
 
3101 3100
 /**
@@ -3112,19 +3111,19 @@  discard block
 block discarded – undo
3112 3111
  *     Identifiant de la session
3113 3112
  **/
3114 3113
 function spip_session($force = false) {
3115
-	static $session;
3116
-	if ($force or !isset($session)) {
3117
-		$s = pipeline('definir_session',
3118
-			$GLOBALS['visiteur_session']
3119
-				? serialize($GLOBALS['visiteur_session'])
3120
-				. '_' . @$_COOKIE['spip_session']
3121
-				: ''
3122
-		);
3123
-		$session = $s ? substr(md5($s), 0, 8) : '';
3124
-	}
3114
+    static $session;
3115
+    if ($force or !isset($session)) {
3116
+        $s = pipeline('definir_session',
3117
+            $GLOBALS['visiteur_session']
3118
+                ? serialize($GLOBALS['visiteur_session'])
3119
+                . '_' . @$_COOKIE['spip_session']
3120
+                : ''
3121
+        );
3122
+        $session = $s ? substr(md5($s), 0, 8) : '';
3123
+    }
3125 3124
 
3126
-	#spip_log('session: '.$session);
3127
-	return $session;
3125
+    #spip_log('session: '.$session);
3126
+    return $session;
3128 3127
 }
3129 3128
 
3130 3129
 
@@ -3143,9 +3142,9 @@  discard block
 block discarded – undo
3143 3142
  *    Lien sur une icone d'aide
3144 3143
  **/
3145 3144
 function aider($aide = '', $distante = false) {
3146
-	$aider = charger_fonction('aide', 'inc', true);
3145
+    $aider = charger_fonction('aide', 'inc', true);
3147 3146
 
3148
-	return $aider ? $aider($aide, '', array(), $distante) : '';
3147
+    return $aider ? $aider($aide, '', array(), $distante) : '';
3149 3148
 }
3150 3149
 
3151 3150
 /**
@@ -3155,24 +3154,24 @@  discard block
 block discarded – undo
3155 3154
  */
3156 3155
 function exec_info_dist() {
3157 3156
 
3158
-	include_spip('inc/autoriser');
3159
-	if (autoriser('phpinfos')) {
3160
-		$cookies_masques = ['spip_session', 'PHPSESSID'];
3161
-		$cookies_backup = [];
3162
-		foreach ($cookies_masques as $k) {
3163
-			if (!empty($_COOKIE[$k])) {
3164
-				$cookies_backup[$k] = $_COOKIE[$k];
3165
-				$_COOKIE[$k] = '******************************';
3166
-			}
3167
-		}
3168
-		phpinfo();
3169
-		foreach ($cookies_backup as $k => $v) {
3170
-			$_COOKIE[$k] = $v;
3171
-		}
3172
-	} else {
3173
-		include_spip('inc/filtres');
3174
-		sinon_interdire_acces();
3175
-	}
3157
+    include_spip('inc/autoriser');
3158
+    if (autoriser('phpinfos')) {
3159
+        $cookies_masques = ['spip_session', 'PHPSESSID'];
3160
+        $cookies_backup = [];
3161
+        foreach ($cookies_masques as $k) {
3162
+            if (!empty($_COOKIE[$k])) {
3163
+                $cookies_backup[$k] = $_COOKIE[$k];
3164
+                $_COOKIE[$k] = '******************************';
3165
+            }
3166
+        }
3167
+        phpinfo();
3168
+        foreach ($cookies_backup as $k => $v) {
3169
+            $_COOKIE[$k] = $v;
3170
+        }
3171
+    } else {
3172
+        include_spip('inc/filtres');
3173
+        sinon_interdire_acces();
3174
+    }
3176 3175
 }
3177 3176
 
3178 3177
 /**
@@ -3192,13 +3191,13 @@  discard block
 block discarded – undo
3192 3191
  *     - string si $message à false.
3193 3192
  **/
3194 3193
 function erreur_squelette($message = '', $lieu = '') {
3195
-	$debusquer = charger_fonction('debusquer', 'public');
3196
-	if (is_array($lieu)) {
3197
-		include_spip('public/compiler');
3198
-		$lieu = reconstruire_contexte_compil($lieu);
3199
-	}
3194
+    $debusquer = charger_fonction('debusquer', 'public');
3195
+    if (is_array($lieu)) {
3196
+        include_spip('public/compiler');
3197
+        $lieu = reconstruire_contexte_compil($lieu);
3198
+    }
3200 3199
 
3201
-	return $debusquer($message, $lieu);
3200
+    return $debusquer($message, $lieu);
3202 3201
 }
3203 3202
 
3204 3203
 /**
@@ -3235,109 +3234,109 @@  discard block
 block discarded – undo
3235 3234
  *     - ou tableau d'information sur le squelette.
3236 3235
  */
3237 3236
 function recuperer_fond($fond, $contexte = array(), $options = array(), $connect = '') {
3238
-	if (!function_exists('evaluer_fond')) {
3239
-		include_spip('public/assembler');
3240
-	}
3241
-	// assurer la compat avec l'ancienne syntaxe
3242
-	// (trim etait le 3eme argument, par defaut a true)
3243
-	if (!is_array($options)) {
3244
-		$options = array('trim' => $options);
3245
-	}
3246
-	if (!isset($options['trim'])) {
3247
-		$options['trim'] = true;
3248
-	}
3249
-
3250
-	if (isset($contexte['connect'])) {
3251
-		$connect = $contexte['connect'];
3252
-		unset($contexte['connect']);
3253
-	}
3254
-
3255
-	$texte = "";
3256
-	$pages = array();
3257
-	$lang_select = '';
3258
-	if (!isset($options['etoile']) or !$options['etoile']) {
3259
-		// Si on a inclus sans fixer le critere de lang, on prend la langue courante
3260
-		if (!isset($contexte['lang'])) {
3261
-			$contexte['lang'] = $GLOBALS['spip_lang'];
3262
-		}
3263
-
3264
-		if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
3265
-			$lang_select = lang_select($contexte['lang']);
3266
-		}
3267
-	}
3268
-
3269
-	if (!isset($GLOBALS['_INC_PUBLIC'])) {
3270
-		$GLOBALS['_INC_PUBLIC'] = 0;
3271
-	}
3272
-
3273
-	$GLOBALS['_INC_PUBLIC']++;
3274
-
3275
-	// fix #4235
3276
-	$cache_utilise_session_appelant	= (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null);
3277
-
3278
-
3279
-	foreach (is_array($fond) ? $fond : array($fond) as $f) {
3237
+    if (!function_exists('evaluer_fond')) {
3238
+        include_spip('public/assembler');
3239
+    }
3240
+    // assurer la compat avec l'ancienne syntaxe
3241
+    // (trim etait le 3eme argument, par defaut a true)
3242
+    if (!is_array($options)) {
3243
+        $options = array('trim' => $options);
3244
+    }
3245
+    if (!isset($options['trim'])) {
3246
+        $options['trim'] = true;
3247
+    }
3248
+
3249
+    if (isset($contexte['connect'])) {
3250
+        $connect = $contexte['connect'];
3251
+        unset($contexte['connect']);
3252
+    }
3253
+
3254
+    $texte = "";
3255
+    $pages = array();
3256
+    $lang_select = '';
3257
+    if (!isset($options['etoile']) or !$options['etoile']) {
3258
+        // Si on a inclus sans fixer le critere de lang, on prend la langue courante
3259
+        if (!isset($contexte['lang'])) {
3260
+            $contexte['lang'] = $GLOBALS['spip_lang'];
3261
+        }
3262
+
3263
+        if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
3264
+            $lang_select = lang_select($contexte['lang']);
3265
+        }
3266
+    }
3267
+
3268
+    if (!isset($GLOBALS['_INC_PUBLIC'])) {
3269
+        $GLOBALS['_INC_PUBLIC'] = 0;
3270
+    }
3271
+
3272
+    $GLOBALS['_INC_PUBLIC']++;
3273
+
3274
+    // fix #4235
3275
+    $cache_utilise_session_appelant	= (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null);
3276
+
3277
+
3278
+    foreach (is_array($fond) ? $fond : array($fond) as $f) {
3280 3279
 		
3281
-		unset($GLOBALS['cache_utilise_session']);	// fix #4235
3282
-
3283
-		$page = evaluer_fond($f, $contexte, $connect);
3284
-		if ($page === '') {
3285
-			$c = isset($options['compil']) ? $options['compil'] : '';
3286
-			$a = array('fichier' => $f);
3287
-			$erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
3288
-			erreur_squelette($erreur, $c);
3289
-			// eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
3290
-			$page = array('texte' => '', 'erreur' => $erreur);
3291
-		}
3292
-
3293
-		$page = pipeline('recuperer_fond', array(
3294
-			'args' => array('fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect),
3295
-			'data' => $page
3296
-		));
3297
-		if (isset($options['ajax']) and $options['ajax']) {
3298
-			if (!function_exists('encoder_contexte_ajax')) {
3299
-				include_spip('inc/filtres');
3300
-			}
3301
-			$page['texte'] = encoder_contexte_ajax(
3302
-				array_merge(
3303
-					$contexte,
3304
-					array('fond' => $f),
3305
-					($connect ? array('connect' => $connect) : array())
3306
-				),
3307
-				'',
3308
-				$page['texte'],
3309
-				$options['ajax']
3310
-			);
3311
-		}
3312
-
3313
-		if (isset($options['raw']) and $options['raw']) {
3314
-			$pages[] = $page;
3315
-		} else {
3316
-			$texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte'];
3317
-		}
3280
+        unset($GLOBALS['cache_utilise_session']);	// fix #4235
3281
+
3282
+        $page = evaluer_fond($f, $contexte, $connect);
3283
+        if ($page === '') {
3284
+            $c = isset($options['compil']) ? $options['compil'] : '';
3285
+            $a = array('fichier' => $f);
3286
+            $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
3287
+            erreur_squelette($erreur, $c);
3288
+            // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
3289
+            $page = array('texte' => '', 'erreur' => $erreur);
3290
+        }
3291
+
3292
+        $page = pipeline('recuperer_fond', array(
3293
+            'args' => array('fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect),
3294
+            'data' => $page
3295
+        ));
3296
+        if (isset($options['ajax']) and $options['ajax']) {
3297
+            if (!function_exists('encoder_contexte_ajax')) {
3298
+                include_spip('inc/filtres');
3299
+            }
3300
+            $page['texte'] = encoder_contexte_ajax(
3301
+                array_merge(
3302
+                    $contexte,
3303
+                    array('fond' => $f),
3304
+                    ($connect ? array('connect' => $connect) : array())
3305
+                ),
3306
+                '',
3307
+                $page['texte'],
3308
+                $options['ajax']
3309
+            );
3310
+        }
3311
+
3312
+        if (isset($options['raw']) and $options['raw']) {
3313
+            $pages[] = $page;
3314
+        } else {
3315
+            $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte'];
3316
+        }
3318 3317
 		
3319
-		// contamination de la session appelante, pour les inclusions statiques
3320
-		if (isset($page['invalideurs']['session'])){
3321
-			$cache_utilise_session_appelant = $page['invalideurs']['session'];
3322
-		}
3323
-	}
3318
+        // contamination de la session appelante, pour les inclusions statiques
3319
+        if (isset($page['invalideurs']['session'])){
3320
+            $cache_utilise_session_appelant = $page['invalideurs']['session'];
3321
+        }
3322
+    }
3324 3323
 
3325
-	// restaurer le sessionnement du contexte appelant, 
3326
-	// éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée
3327
-	if (isset($cache_utilise_session_appelant)) {
3328
-		$GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant;
3329
-	}
3324
+    // restaurer le sessionnement du contexte appelant, 
3325
+    // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée
3326
+    if (isset($cache_utilise_session_appelant)) {
3327
+        $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant;
3328
+    }
3330 3329
 
3331
-	$GLOBALS['_INC_PUBLIC']--;
3330
+    $GLOBALS['_INC_PUBLIC']--;
3332 3331
 
3333
-	if ($lang_select) {
3334
-		lang_select();
3335
-	}
3336
-	if (isset($options['raw']) and $options['raw']) {
3337
-		return is_array($fond) ? $pages : reset($pages);
3338
-	} else {
3339
-		return $options['trim'] ? ltrim($texte) : $texte;
3340
-	}
3332
+    if ($lang_select) {
3333
+        lang_select();
3334
+    }
3335
+    if (isset($options['raw']) and $options['raw']) {
3336
+        return is_array($fond) ? $pages : reset($pages);
3337
+    } else {
3338
+        return $options['trim'] ? ltrim($texte) : $texte;
3339
+    }
3341 3340
 }
3342 3341
 
3343 3342
 /**
@@ -3347,7 +3346,7 @@  discard block
 block discarded – undo
3347 3346
  * @return string
3348 3347
  */
3349 3348
 function trouve_modele($nom) {
3350
-	return trouver_fond($nom, 'modeles/');
3349
+    return trouver_fond($nom, 'modeles/');
3351 3350
 }
3352 3351
 
3353 3352
 /**
@@ -3363,21 +3362,21 @@  discard block
 block discarded – undo
3363 3362
  * @return array|string
3364 3363
  */
3365 3364
 function trouver_fond($nom, $dir = '', $pathinfo = false) {
3366
-	$f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3367
-	if (!$pathinfo) {
3368
-		return $f;
3369
-	}
3370
-	// renvoyer un tableau detaille si $pathinfo==true
3371
-	$p = pathinfo($f);
3372
-	if (!isset($p['extension']) or !$p['extension']) {
3373
-		$p['extension'] = _EXTENSION_SQUELETTES;
3374
-	}
3375
-	if (!isset($p['extension']) or !$p['filename']) {
3376
-		$p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
3377
-	}
3378
-	$p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');
3365
+    $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3366
+    if (!$pathinfo) {
3367
+        return $f;
3368
+    }
3369
+    // renvoyer un tableau detaille si $pathinfo==true
3370
+    $p = pathinfo($f);
3371
+    if (!isset($p['extension']) or !$p['extension']) {
3372
+        $p['extension'] = _EXTENSION_SQUELETTES;
3373
+    }
3374
+    if (!isset($p['extension']) or !$p['filename']) {
3375
+        $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
3376
+    }
3377
+    $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');
3379 3378
 
3380
-	return $p;
3379
+    return $p;
3381 3380
 }
3382 3381
 
3383 3382
 /**
@@ -3398,24 +3397,24 @@  discard block
 block discarded – undo
3398 3397
  *     Nom de l'exec, sinon chaîne vide.
3399 3398
  **/
3400 3399
 function tester_url_ecrire($nom) {
3401
-	static $exec = array();
3402
-	if (isset($exec[$nom])) {
3403
-		return $exec[$nom];
3404
-	}
3405
-	// tester si c'est une page en squelette
3406
-	if (trouver_fond($nom, 'prive/squelettes/contenu/')) {
3407
-		return $exec[$nom] = 'fond';
3408
-	} // compat skels orthogonaux version precedente
3409
-	elseif (trouver_fond($nom, 'prive/exec/')) {
3410
-		return $exec[$nom] = 'fond_monobloc';
3411
-	} // echafaudage d'un fond !
3412
-	elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) {
3413
-		return $exec[$nom] = 'fond';
3414
-	}
3415
-	// attention, il ne faut pas inclure l'exec ici
3416
-	// car sinon #URL_ECRIRE provoque des inclusions
3417
-	// et des define intrusifs potentiels
3418
-	return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : '');
3400
+    static $exec = array();
3401
+    if (isset($exec[$nom])) {
3402
+        return $exec[$nom];
3403
+    }
3404
+    // tester si c'est une page en squelette
3405
+    if (trouver_fond($nom, 'prive/squelettes/contenu/')) {
3406
+        return $exec[$nom] = 'fond';
3407
+    } // compat skels orthogonaux version precedente
3408
+    elseif (trouver_fond($nom, 'prive/exec/')) {
3409
+        return $exec[$nom] = 'fond_monobloc';
3410
+    } // echafaudage d'un fond !
3411
+    elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) {
3412
+        return $exec[$nom] = 'fond';
3413
+    }
3414
+    // attention, il ne faut pas inclure l'exec ici
3415
+    // car sinon #URL_ECRIRE provoque des inclusions
3416
+    // et des define intrusifs potentiels
3417
+    return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : '');
3419 3418
 }
3420 3419
 
3421 3420
 
@@ -3431,10 +3430,10 @@  discard block
 block discarded – undo
3431 3430
  * @return bool true si le module est chargé
3432 3431
  **/
3433 3432
 function charger_php_extension($module) {
3434
-	if (extension_loaded($module)) {
3435
-		return true;
3436
-	}
3437
-	return false;
3433
+    if (extension_loaded($module)) {
3434
+        return true;
3435
+    }
3436
+    return false;
3438 3437
 }
3439 3438
 
3440 3439
 
@@ -3445,8 +3444,8 @@  discard block
 block discarded – undo
3445 3444
  *     true si et seulement si la configuration autorise le code HTML5 sur le site public
3446 3445
  **/
3447 3446
 function html5_permis() {
3448
-	return (isset($GLOBALS['meta']['version_html_max'])
3449
-		and ('html5' == $GLOBALS['meta']['version_html_max']));
3447
+    return (isset($GLOBALS['meta']['version_html_max'])
3448
+        and ('html5' == $GLOBALS['meta']['version_html_max']));
3450 3449
 }
3451 3450
 
3452 3451
 /**
@@ -3456,30 +3455,30 @@  discard block
 block discarded – undo
3456 3455
  * @return array
3457 3456
  */
3458 3457
 function formats_image_acceptables($gd = null, $svg_allowed = true) {
3459
-	$formats = null;
3460
-	if (!is_null($gd)) {
3461
-		$config = ($gd ? "gd_formats" : "formats_graphiques");
3462
-		if (isset($GLOBALS['meta'][$config])) {
3463
-			$formats = $GLOBALS['meta'][$config];
3464
-			$formats = explode(',', $formats);
3465
-			$formats = array_filter($formats);
3466
-			$formats = array_map('trim', $formats);
3467
-		}
3468
-	}
3469
-	if (is_null($formats)) {
3470
-		include_spip('inc/filtres_images_lib_mini');
3471
-		$formats = _image_extensions_acceptees_en_entree();
3472
-	}
3473
-
3474
-	if ($svg_allowed) {
3475
-		if (!in_array('svg', $formats)) {
3476
-			$formats[] = 'svg';
3477
-		}
3478
-	}
3479
-	else {
3480
-		$formats = array_diff($formats, ['svg']);
3481
-	}
3482
-	return $formats;
3458
+    $formats = null;
3459
+    if (!is_null($gd)) {
3460
+        $config = ($gd ? "gd_formats" : "formats_graphiques");
3461
+        if (isset($GLOBALS['meta'][$config])) {
3462
+            $formats = $GLOBALS['meta'][$config];
3463
+            $formats = explode(',', $formats);
3464
+            $formats = array_filter($formats);
3465
+            $formats = array_map('trim', $formats);
3466
+        }
3467
+    }
3468
+    if (is_null($formats)) {
3469
+        include_spip('inc/filtres_images_lib_mini');
3470
+        $formats = _image_extensions_acceptees_en_entree();
3471
+    }
3472
+
3473
+    if ($svg_allowed) {
3474
+        if (!in_array('svg', $formats)) {
3475
+            $formats[] = 'svg';
3476
+        }
3477
+    }
3478
+    else {
3479
+        $formats = array_diff($formats, ['svg']);
3480
+    }
3481
+    return $formats;
3483 3482
 }
3484 3483
 
3485 3484
 /**
@@ -3488,21 +3487,21 @@  discard block
 block discarded – undo
3488 3487
  * @return array|bool
3489 3488
  */
3490 3489
 function spip_getimagesize($fichier) {
3491
-	if (!$imagesize = @getimagesize($fichier)) {
3490
+    if (!$imagesize = @getimagesize($fichier)) {
3492 3491
 
3493
-		include_spip("inc/svg");
3494
-		if ($attrs = svg_lire_attributs($fichier)) {
3495
-			list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs);
3496
-			$imagesize = [
3497
-				$width,
3498
-				$height,
3499
-				IMAGETYPE_SVG,
3500
-				"width=\"{$width}\" height=\"{$height}\"",
3501
-				"mime" => "image/svg+xml"
3502
-			];
3503
-		}
3504
-	}
3505
-	return $imagesize;
3492
+        include_spip("inc/svg");
3493
+        if ($attrs = svg_lire_attributs($fichier)) {
3494
+            list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs);
3495
+            $imagesize = [
3496
+                $width,
3497
+                $height,
3498
+                IMAGETYPE_SVG,
3499
+                "width=\"{$width}\" height=\"{$height}\"",
3500
+                "mime" => "image/svg+xml"
3501
+            ];
3502
+        }
3503
+    }
3504
+    return $imagesize;
3506 3505
 }
3507 3506
 
3508 3507
 
@@ -3522,7 +3521,7 @@  discard block
 block discarded – undo
3522 3521
  * @return mixed Valeur de la meta.
3523 3522
  **/
3524 3523
 function lire_meta($nom) {
3525
-	return isset($GLOBALS['meta'][$nom]) ? $GLOBALS['meta'][$nom] : null;
3524
+    return isset($GLOBALS['meta'][$nom]) ? $GLOBALS['meta'][$nom] : null;
3526 3525
 }
3527 3526
 
3528 3527
 
@@ -3544,130 +3543,130 @@  discard block
 block discarded – undo
3544 3543
  * @param string $statut
3545 3544
  */
3546 3545
 function avertir_auteurs($nom, $message, $statut = '') {
3547
-	$alertes = $GLOBALS['meta']['message_alertes_auteurs'];
3548
-	if (!$alertes
3549
-		or !is_array($alertes = unserialize($alertes))
3550
-	) {
3551
-		$alertes = array();
3552
-	}
3546
+    $alertes = $GLOBALS['meta']['message_alertes_auteurs'];
3547
+    if (!$alertes
3548
+        or !is_array($alertes = unserialize($alertes))
3549
+    ) {
3550
+        $alertes = array();
3551
+    }
3553 3552
 
3554
-	if (!isset($alertes[$statut])) {
3555
-		$alertes[$statut] = array();
3556
-	}
3557
-	$alertes[$statut][$nom] = $message;
3558
-	ecrire_meta("message_alertes_auteurs", serialize($alertes));
3553
+    if (!isset($alertes[$statut])) {
3554
+        $alertes[$statut] = array();
3555
+    }
3556
+    $alertes[$statut][$nom] = $message;
3557
+    ecrire_meta("message_alertes_auteurs", serialize($alertes));
3559 3558
 }
3560 3559
 
3561 3560
 if (PHP_VERSION_ID < 50500) {
3562
-	if (!function_exists('array_column')) {
3563
-		/**
3564
-		 * Returns the values from a single column of the input array, identified by
3565
-		 * the $columnKey.
3566
-		 *
3567
-		 * Optionally, you may provide an $indexKey to index the values in the returned
3568
-		 * array by the values from the $indexKey column in the input array.
3569
-		 *
3570
-		 * @link http://php.net/manual/fr/function.array-column.php
3571
-		 * @link https://github.com/ramsey/array_column/blob/master/src/array_column.php
3572
-		 * @copyright Copyright (c) Ben Ramsey (http://benramsey.com)
3573
-		 * @license http://opensource.org/licenses/MIT MIT
3574
-		 *
3575
-		 * @param array $input A multi-dimensional array (record set) from which to pull
3576
-		 *                     a column of values.
3577
-		 * @param mixed $columnKey The column of values to return. This value may be the
3578
-		 *                         integer key of the column you wish to retrieve, or it
3579
-		 *                         may be the string key name for an associative array.
3580
-		 * @param mixed $indexKey (Optional.) The column to use as the index/keys for
3581
-		 *                        the returned array. This value may be the integer key
3582
-		 *                        of the column, or it may be the string key name.
3583
-		 * @return array
3584
-		 */
3585
-		function array_column($input = null, $columnKey = null, $indexKey = null)
3586
-		{
3587
-			// Using func_get_args() in order to check for proper number of
3588
-			// parameters and trigger errors exactly as the built-in array_column()
3589
-			// does in PHP 5.5.
3590
-			$argc = func_num_args();
3591
-			$params = func_get_args();
3592
-
3593
-			if ($argc < 2) {
3594
-				trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING);
3595
-				return null;
3596
-			}
3597
-
3598
-			if (!is_array($params[0])) {
3599
-				trigger_error(
3600
-					'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given',
3601
-					E_USER_WARNING
3602
-				);
3603
-				return null;
3604
-			}
3605
-
3606
-			if (!is_int($params[1])
3607
-				&& !is_float($params[1])
3608
-				&& !is_string($params[1])
3609
-				&& $params[1] !== null
3610
-				&& !(is_object($params[1]) && method_exists($params[1], '__toString'))
3611
-			) {
3612
-				trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING);
3613
-				return false;
3614
-			}
3615
-
3616
-			if (isset($params[2])
3617
-				&& !is_int($params[2])
3618
-				&& !is_float($params[2])
3619
-				&& !is_string($params[2])
3620
-				&& !(is_object($params[2]) && method_exists($params[2], '__toString'))
3621
-			) {
3622
-				trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING);
3623
-				return false;
3624
-			}
3625
-
3626
-			$paramsInput = $params[0];
3627
-			$paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;
3628
-
3629
-			$paramsIndexKey = null;
3630
-			if (isset($params[2])) {
3631
-				if (is_float($params[2]) || is_int($params[2])) {
3632
-					$paramsIndexKey = (int) $params[2];
3633
-				} else {
3634
-					$paramsIndexKey = (string) $params[2];
3635
-				}
3636
-			}
3637
-
3638
-			$resultArray = array();
3639
-
3640
-			foreach ($paramsInput as $row) {
3641
-				$key = $value = null;
3642
-				$keySet = $valueSet = false;
3643
-
3644
-				if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) {
3645
-					$keySet = true;
3646
-					$key = (string) $row[$paramsIndexKey];
3647
-				}
3648
-
3649
-				if ($paramsColumnKey === null) {
3650
-					$valueSet = true;
3651
-					$value = $row;
3652
-				} elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) {
3653
-					$valueSet = true;
3654
-					$value = $row[$paramsColumnKey];
3655
-				}
3656
-
3657
-				if ($valueSet) {
3658
-					if ($keySet) {
3659
-						$resultArray[$key] = $value;
3660
-					} else {
3661
-						$resultArray[] = $value;
3662
-					}
3663
-				}
3664
-
3665
-			}
3666
-
3667
-			return $resultArray;
3668
-		}
3669
-
3670
-	}
3561
+    if (!function_exists('array_column')) {
3562
+        /**
3563
+         * Returns the values from a single column of the input array, identified by
3564
+         * the $columnKey.
3565
+         *
3566
+         * Optionally, you may provide an $indexKey to index the values in the returned
3567
+         * array by the values from the $indexKey column in the input array.
3568
+         *
3569
+         * @link http://php.net/manual/fr/function.array-column.php
3570
+         * @link https://github.com/ramsey/array_column/blob/master/src/array_column.php
3571
+         * @copyright Copyright (c) Ben Ramsey (http://benramsey.com)
3572
+         * @license http://opensource.org/licenses/MIT MIT
3573
+         *
3574
+         * @param array $input A multi-dimensional array (record set) from which to pull
3575
+         *                     a column of values.
3576
+         * @param mixed $columnKey The column of values to return. This value may be the
3577
+         *                         integer key of the column you wish to retrieve, or it
3578
+         *                         may be the string key name for an associative array.
3579
+         * @param mixed $indexKey (Optional.) The column to use as the index/keys for
3580
+         *                        the returned array. This value may be the integer key
3581
+         *                        of the column, or it may be the string key name.
3582
+         * @return array
3583
+         */
3584
+        function array_column($input = null, $columnKey = null, $indexKey = null)
3585
+        {
3586
+            // Using func_get_args() in order to check for proper number of
3587
+            // parameters and trigger errors exactly as the built-in array_column()
3588
+            // does in PHP 5.5.
3589
+            $argc = func_num_args();
3590
+            $params = func_get_args();
3591
+
3592
+            if ($argc < 2) {
3593
+                trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING);
3594
+                return null;
3595
+            }
3596
+
3597
+            if (!is_array($params[0])) {
3598
+                trigger_error(
3599
+                    'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given',
3600
+                    E_USER_WARNING
3601
+                );
3602
+                return null;
3603
+            }
3604
+
3605
+            if (!is_int($params[1])
3606
+                && !is_float($params[1])
3607
+                && !is_string($params[1])
3608
+                && $params[1] !== null
3609
+                && !(is_object($params[1]) && method_exists($params[1], '__toString'))
3610
+            ) {
3611
+                trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING);
3612
+                return false;
3613
+            }
3614
+
3615
+            if (isset($params[2])
3616
+                && !is_int($params[2])
3617
+                && !is_float($params[2])
3618
+                && !is_string($params[2])
3619
+                && !(is_object($params[2]) && method_exists($params[2], '__toString'))
3620
+            ) {
3621
+                trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING);
3622
+                return false;
3623
+            }
3624
+
3625
+            $paramsInput = $params[0];
3626
+            $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;
3627
+
3628
+            $paramsIndexKey = null;
3629
+            if (isset($params[2])) {
3630
+                if (is_float($params[2]) || is_int($params[2])) {
3631
+                    $paramsIndexKey = (int) $params[2];
3632
+                } else {
3633
+                    $paramsIndexKey = (string) $params[2];
3634
+                }
3635
+            }
3636
+
3637
+            $resultArray = array();
3638
+
3639
+            foreach ($paramsInput as $row) {
3640
+                $key = $value = null;
3641
+                $keySet = $valueSet = false;
3642
+
3643
+                if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) {
3644
+                    $keySet = true;
3645
+                    $key = (string) $row[$paramsIndexKey];
3646
+                }
3647
+
3648
+                if ($paramsColumnKey === null) {
3649
+                    $valueSet = true;
3650
+                    $value = $row;
3651
+                } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) {
3652
+                    $valueSet = true;
3653
+                    $value = $row[$paramsColumnKey];
3654
+                }
3655
+
3656
+                if ($valueSet) {
3657
+                    if ($keySet) {
3658
+                        $resultArray[$key] = $value;
3659
+                    } else {
3660
+                        $resultArray[] = $value;
3661
+                    }
3662
+                }
3663
+
3664
+            }
3665
+
3666
+            return $resultArray;
3667
+        }
3668
+
3669
+    }
3671 3670
 }
3672 3671
 
3673 3672
 /**
@@ -3681,8 +3680,8 @@  discard block
 block discarded – undo
3681 3680
  * @return string|string[]
3682 3681
  */
3683 3682
 function spip_sanitize_classname($classes) {
3684
-	if (is_array($classes)) {
3685
-		return array_map('spip_sanitize_classname', $classes);
3686
-	}
3687
-	return preg_replace("/[^ 0-9a-z_\-+@]/i", "", $classes);
3683
+    if (is_array($classes)) {
3684
+        return array_map('spip_sanitize_classname', $classes);
3685
+    }
3686
+    return preg_replace("/[^ 0-9a-z_\-+@]/i", "", $classes);
3688 3687
 }
Please login to merge, or discard this patch.
Spacing   +131 added lines, -133 removed lines patch added patch discarded remove patch
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 	if (strlen($dossier) and substr($dossier, -1) != '/') {
54 54
 		$dossier .= '/';
55 55
 	}
56
-	$f = str_replace('/', '_', $dossier) . $nom;
56
+	$f = str_replace('/', '_', $dossier).$nom;
57 57
 
58 58
 	if (function_exists($f)) {
59 59
 		return $f;
60 60
 	}
61
-	if (function_exists($g = $f . '_dist')) {
61
+	if (function_exists($g = $f.'_dist')) {
62 62
 		return $g;
63 63
 	}
64 64
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 	// passer en minuscules (cf les balises de formulaires)
80 80
 	// et inclure le fichier
81
-	if (!$inc = include_spip($dossier . ($d = strtolower($nom)))
81
+	if (!$inc = include_spip($dossier.($d = strtolower($nom)))
82 82
 		// si le fichier truc/machin/nom.php n'existe pas,
83 83
 		// la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions
84 84
 		and strlen(dirname($dossier)) and dirname($dossier) != '.'
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
 	}
98 98
 
99 99
 	// Echec : message d'erreur
100
-	spip_log("fonction $nom ($f ou $g) indisponible" .
100
+	spip_log("fonction $nom ($f ou $g) indisponible".
101 101
 		($inc ? "" : " (fichier $d absent de $dossier)"));
102 102
 
103 103
 	include_spip('inc/minipres');
104 104
 	echo minipres(_T('forum_titre_erreur'),
105
-		_T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')),
106
-		array('all_inline'=>true,'status'=>404));
105
+		_T('fichier_introuvable', array('fichier' => '<b>'.spip_htmlentities($d).'</b>')),
106
+		array('all_inline'=>true, 'status'=>404));
107 107
 	exit;
108 108
 }
109 109
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
  *     - string : chemin du fichier trouvé
149 149
  **/
150 150
 function include_spip($f, $include = true) {
151
-	return find_in_path($f . '.php', '', $include);
151
+	return find_in_path($f.'.php', '', $include);
152 152
 }
153 153
 
154 154
 /**
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
  *     - string : chemin du fichier trouvé
169 169
  **/
170 170
 function require_spip($f) {
171
-	return find_in_path($f . '.php', '', 'required');
171
+	return find_in_path($f.'.php', '', 'required');
172 172
 }
173 173
 
174 174
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 		// donc il faut l'inclure "en globals"
186 186
 		if ($f = find_in_path('mes_fonctions.php')) {
187 187
 			global $dossier_squelettes;
188
-			include_once(_ROOT_CWD . $f);
188
+			include_once(_ROOT_CWD.$f);
189 189
 		}
190 190
 
191 191
 		if (@is_readable(_CACHE_PLUGINS_FCT)) {
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	}
289 289
 
290 290
 	// appliquer notre fonction si elle existe
291
-	$fonc = 'execute_pipeline_' . strtolower($action);
291
+	$fonc = 'execute_pipeline_'.strtolower($action);
292 292
 	if (function_exists($fonc)) {
293 293
 		$val = $fonc($val);
294 294
 	} // plantage ?
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 function spip_log($message = null, $name = null) {
353 353
 	static $pre = array();
354 354
 	static $log;
355
-	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
355
+	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs);
356 356
 	if (!isset($regs[1]) or !$logname = $regs[1]) {
357 357
 		$logname = null;
358 358
 	}
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 		if (!is_string($message)) {
378 378
 			$message = print_r($message, true);
379 379
 		}
380
-		$log($pre[$niveau] . ' ' . $message, $logname);
380
+		$log($pre[$niveau].' '.$message, $logname);
381 381
 	}
382 382
 }
383 383
 
@@ -490,9 +490,9 @@  discard block
 block discarded – undo
490 490
  * @param string $sanitize_function
491 491
  * @return array|mixed|string
492 492
  */
493
-function spip_sanitize_from_request($value, $key, $sanitize_function='entites_html') {
493
+function spip_sanitize_from_request($value, $key, $sanitize_function = 'entites_html') {
494 494
 	if (is_array($value)) {
495
-		if ($key=='*') {
495
+		if ($key == '*') {
496 496
 			$key = array_keys($value);
497 497
 		}
498 498
 		if (!is_array($key)) {
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 		$a = './';
578 578
 	}
579 579
 
580
-	$regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,';
580
+	$regexp = ',^('.str_replace('[]', '\[\]', $c).'[[]?[]]?)(=.*)?$,';
581 581
 	$ajouts = array_flip(explode('|', $c));
582 582
 	$u = is_array($v) ? $v : rawurlencode($v);
583 583
 	$testv = (is_array($v) ? count($v) : strlen($v));
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 			// Ajout. Pour une variable, remplacer au meme endroit,
605 605
 			// pour un tableau ce sera fait dans la prochaine boucle
606 606
 			elseif (substr($r[1], -2) != '[]') {
607
-				$url[$n] = $r[1] . '=' . $u;
607
+				$url[$n] = $r[1].'='.$u;
608 608
 				unset($ajouts[$r[1]]);
609 609
 			}
610 610
 			// Pour les tableaux on laisse tomber les valeurs de
@@ -624,11 +624,11 @@  discard block
 block discarded – undo
624 624
 	} elseif ($testv) {
625 625
 		foreach ($ajouts as $k => $n) {
626 626
 			if (!is_array($v)) {
627
-				$url[] = $k . '=' . $u;
627
+				$url[] = $k.'='.$u;
628 628
 			} else {
629
-				$id = (substr($k, -2) == '[]') ? $k : ($k . "[]");
629
+				$id = (substr($k, -2) == '[]') ? $k : ($k."[]");
630 630
 				foreach ($v as $w) {
631
-					$url[] = $id . '=' . (is_array($w) ? 'Array' : $w);
631
+					$url[] = $id.'='.(is_array($w) ? 'Array' : $w);
632 632
 				}
633 633
 			}
634 634
 		}
@@ -639,10 +639,10 @@  discard block
 block discarded – undo
639 639
 
640 640
 	// recomposer l'adresse
641 641
 	if ($url) {
642
-		$a .= '?' . join($sep, $url);
642
+		$a .= '?'.join($sep, $url);
643 643
 	}
644 644
 
645
-	return $a . $ancre;
645
+	return $a.$ancre;
646 646
 }
647 647
 
648 648
 /**
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 			translitteration($ancre)
675 675
 		);
676 676
 	}
677
-	return $url . (strlen($ancre) ? '#' . $ancre : '');
677
+	return $url.(strlen($ancre) ? '#'.$ancre : '');
678 678
 }
679 679
 
680 680
 /**
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
  * @return bool
787 787
  */
788 788
 function test_plugin_actif($plugin) {
789
-	return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
789
+	return ($plugin and defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true : false;
790 790
 }
791 791
 
792 792
 /**
@@ -854,8 +854,7 @@  discard block
 block discarded – undo
854 854
 		// pour les chaines non traduites, assurer un service minimum
855 855
 		if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
856 856
 			$text = str_replace('_', ' ',
857
-				(($n = strpos($text, ':')) === false ? $texte :
858
-					substr($texte, $n + 1)));
857
+				(($n = strpos($text, ':')) === false ? $texte : substr($texte, $n + 1)));
859 858
 		}
860 859
 		$o['class'] = null;
861 860
 
@@ -927,7 +926,7 @@  discard block
 block discarded – undo
927 926
 		// Si des variables n'ont pas ete inserees, le signaler
928 927
 		// (chaines de langues pas a jour)
929 928
 		if ($args) {
930
-			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
929
+			spip_log("$f:  variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG);
931 930
 		}
932 931
 	}
933 932
 
@@ -951,7 +950,7 @@  discard block
 block discarded – undo
951 950
 function joli_repertoire($rep) {
952 951
 	$a = substr($rep, 0, 1);
953 952
 	if ($a <> '.' and $a <> '/') {
954
-		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
953
+		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep;
955 954
 	}
956 955
 	$rep = preg_replace(',(^\.\.\/),', '', $rep);
957 956
 
@@ -1005,7 +1004,7 @@  discard block
 block discarded – undo
1005 1004
 			$p -= ($x * 1000);
1006 1005
 		}
1007 1006
 
1008
-		return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p);
1007
+		return $s.sprintf($s ? "%07.3f ms" : "%.3f ms", $p);
1009 1008
 	}
1010 1009
 }
1011 1010
 
@@ -1074,7 +1073,7 @@  discard block
 block discarded – undo
1074 1073
 	if ($taches and count($taches) and !spip_connect()) {
1075 1074
 		return false;
1076 1075
 	}
1077
-	spip_log("cron !", 'jq' . _LOG_DEBUG);
1076
+	spip_log("cron !", 'jq'._LOG_DEBUG);
1078 1077
 	if ($genie = charger_fonction('genie', 'inc', true)) {
1079 1078
 		return $genie($taches);
1080 1079
 	}
@@ -1178,7 +1177,7 @@  discard block
 block discarded – undo
1178 1177
 
1179 1178
 	if ($queue_next_job_time == -1) {
1180 1179
 		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1181
-			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt");
1180
+			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP."job_queue_next.txt");
1182 1181
 		}
1183 1182
 		// utiliser un cache memoire si dispo
1184 1183
 		if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
@@ -1245,8 +1244,8 @@  discard block
 block discarded – undo
1245 1244
 		$src = '';
1246 1245
 	}
1247 1246
 	if ($script) {
1248
-		$script = ("/*<![CDATA[*/\n" .
1249
-			preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1247
+		$script = ("/*<![CDATA[*/\n".
1248
+			preg_replace(',</([^>]*)>,', '<\/\1>', $script).
1250 1249
 			"/*]]>*/");
1251 1250
 	}
1252 1251
 	if ($noscript) {
@@ -1332,13 +1331,13 @@  discard block
 block discarded – undo
1332 1331
 	if ($path_base == null) {
1333 1332
 		// Chemin standard depuis l'espace public
1334 1333
 		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
1335
-			_DIR_RACINE . ':' .
1336
-			_DIR_RACINE . 'squelettes-dist/:' .
1337
-			_DIR_RACINE . 'prive/:' .
1334
+			_DIR_RACINE.':'.
1335
+			_DIR_RACINE.'squelettes-dist/:'.
1336
+			_DIR_RACINE.'prive/:'.
1338 1337
 			_DIR_RESTREINT;
1339 1338
 		// Ajouter squelettes/
1340
-		if (@is_dir(_DIR_RACINE . 'squelettes')) {
1341
-			$path = _DIR_RACINE . 'squelettes/:' . $path;
1339
+		if (@is_dir(_DIR_RACINE.'squelettes')) {
1340
+			$path = _DIR_RACINE.'squelettes/:'.$path;
1342 1341
 		}
1343 1342
 		foreach (explode(':', $path) as $dir) {
1344 1343
 			if (strlen($dir) and substr($dir, -1) != '/') {
@@ -1350,7 +1349,7 @@  discard block
 block discarded – undo
1350 1349
 		// Et le(s) dossier(s) des squelettes nommes
1351 1350
 		if (strlen($GLOBALS['dossier_squelettes'])) {
1352 1351
 			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1353
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1352
+				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/');
1354 1353
 			}
1355 1354
 		}
1356 1355
 		$GLOBALS['path_sig'] = md5(serialize($path_full));
@@ -1361,7 +1360,7 @@  discard block
 block discarded – undo
1361 1360
 
1362 1361
 	if (strlen($dir_path)) {
1363 1362
 		$tete = "";
1364
-		if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1363
+		if (reset($path_base) == _DIR_RACINE.'squelettes/') {
1365 1364
 			$tete = array_shift($path_base);
1366 1365
 		}
1367 1366
 		$dirs = array_reverse(explode(':', $dir_path));
@@ -1383,7 +1382,7 @@  discard block
 block discarded – undo
1383 1382
 	// Et le(s) dossier(s) des squelettes nommes
1384 1383
 	if (strlen($GLOBALS['dossier_squelettes'])) {
1385 1384
 		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1386
-			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1385
+			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE).$d.'/');
1387 1386
 		}
1388 1387
 	}
1389 1388
 
@@ -1453,9 +1452,9 @@  discard block
 block discarded – undo
1453 1452
 	// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1454 1453
 	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1455 1454
 	if (preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1456
-	  and $file_svg_generique = substr($file,0, -strlen($m[0])) . "-xx.svg"
1455
+	  and $file_svg_generique = substr($file, 0, -strlen($m[0]))."-xx.svg"
1457 1456
 		and $f = find_in_theme("$file_svg_generique")) {
1458
-		if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) {
1457
+		if ($fsize = substr($f, 0, -6).$m[1].".svg" and file_exists($fsize)) {
1459 1458
 			return $themefiles["$subdir$file"] = $fsize;
1460 1459
 		}
1461 1460
 		else {
@@ -1469,7 +1468,7 @@  discard block
 block discarded – undo
1469 1468
 			return $themefiles["$subdir$file"] = $f;
1470 1469
 		}
1471 1470
 	}
1472
-	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1471
+	spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme');
1473 1472
 
1474 1473
 	return $themefiles["$subdir$file"] = "";
1475 1474
 }
@@ -1497,7 +1496,7 @@  discard block
 block discarded – undo
1497 1496
 function chemin_image($icone) {
1498 1497
 	static $icone_renommer;
1499 1498
 	if ($p = strpos($icone, '?')) {
1500
-		$icone = substr($icone,0, $p);
1499
+		$icone = substr($icone, 0, $p);
1501 1500
 	}
1502 1501
 	// gerer le cas d'un double appel en evitant de refaire le travail inutilement
1503 1502
 	if (strpos($icone, "/") !== false and file_exists($icone)) {
@@ -1577,8 +1576,8 @@  discard block
 block discarded – undo
1577 1576
 			return false;
1578 1577
 		}
1579 1578
 		if ($include and !isset($inc[$dirname][$file])) {
1580
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1581
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1579
+			include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1580
+			$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
1582 1581
 		}
1583 1582
 
1584 1583
 		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
@@ -1591,14 +1590,14 @@  discard block
 block discarded – undo
1591 1590
 	}
1592 1591
 
1593 1592
 	foreach (creer_chemin() as $dir) {
1594
-		if (!isset($dirs[$a = $dir . $dirname])) {
1595
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1593
+		if (!isset($dirs[$a = $dir.$dirname])) {
1594
+			$dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a);
1596 1595
 		}
1597 1596
 		if ($dirs[$a]) {
1598
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
1597
+			if (file_exists(_ROOT_CWD.($a .= $file))) {
1599 1598
 				if ($include and !isset($inc[$dirname][$file])) {
1600
-					include_once _ROOT_CWD . $a;
1601
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1599
+					include_once _ROOT_CWD.$a;
1600
+					$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
1602 1601
 				}
1603 1602
 				if (!defined('_SAUVER_CHEMIN')) {
1604 1603
 					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
@@ -1608,7 +1607,7 @@  discard block
 block discarded – undo
1608 1607
 					define('_SAUVER_CHEMIN', true);
1609 1608
 				}
1610 1609
 
1611
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1610
+				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a;
1612 1611
 			}
1613 1612
 		}
1614 1613
 	}
@@ -1634,7 +1633,7 @@  discard block
 block discarded – undo
1634 1633
 		define('_SAUVER_CHEMIN', true);
1635 1634
 	}
1636 1635
 
1637
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1636
+	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false;
1638 1637
 }
1639 1638
 
1640 1639
 function clear_path_cache() {
@@ -1703,12 +1702,12 @@  discard block
 block discarded – undo
1703 1702
 	// cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1704 1703
 	// on a pas encore inclus flock.php
1705 1704
 	if (!function_exists('preg_files')) {
1706
-		include_once _ROOT_RESTREINT . 'inc/flock.php';
1705
+		include_once _ROOT_RESTREINT.'inc/flock.php';
1707 1706
 	}
1708 1707
 
1709 1708
 	// Parcourir le chemin
1710 1709
 	foreach (creer_chemin() as $d) {
1711
-		$f = $d . $dir;
1710
+		$f = $d.$dir;
1712 1711
 		if (@is_dir($f)) {
1713 1712
 			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs);
1714 1713
 			foreach ($liste as $chemin) {
@@ -1738,9 +1737,9 @@  discard block
 block discarded – undo
1738 1737
 	static $autsanscookie = array('install', 'base_repair');
1739 1738
 
1740 1739
 	if (in_array($nom, $autsanscookie)) {
1741
-		if (test_espace_prive()){
1740
+		if (test_espace_prive()) {
1742 1741
 			include_spip('base/connect_sql');
1743
-			if (!$strict or !spip_connect()){
1742
+			if (!$strict or !spip_connect()) {
1744 1743
 				return true;
1745 1744
 			}
1746 1745
 		}
@@ -1819,7 +1818,7 @@  discard block
 block discarded – undo
1819 1818
 		return $res;
1820 1819
 	}
1821 1820
 	// Sinon c'est un raccourci ou compat SPIP < 2
1822
-	if (!function_exists($f = 'generer_url_' . $entite)) {
1821
+	if (!function_exists($f = 'generer_url_'.$entite)) {
1823 1822
 		if (!function_exists($f .= '_dist')) {
1824 1823
 			$f = '';
1825 1824
 		}
@@ -1828,8 +1827,8 @@  discard block
 block discarded – undo
1828 1827
 		$url = $f($id, $args, $ancre);
1829 1828
 		if (strlen($args)) {
1830 1829
 			$url .= strstr($url, '?')
1831
-				? '&amp;' . $args
1832
-				: '?' . $args;
1830
+				? '&amp;'.$args
1831
+				: '?'.$args;
1833 1832
 		}
1834 1833
 
1835 1834
 		return $url;
@@ -1860,8 +1859,8 @@  discard block
 block discarded – undo
1860 1859
 	include_spip('base/connect_sql');
1861 1860
 	$id_type = id_table_objet($entite, $public);
1862 1861
 
1863
-	return _DIR_RACINE . get_spip_script('./')
1864
-	. "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1862
+	return _DIR_RACINE.get_spip_script('./')
1863
+	. "?"._SPIP_PAGE."=$entite&$id_type=$i&connect=$public"
1865 1864
 	. (!$args ? '' : "&$args")
1866 1865
 	. (!$ancre ? '' : "#$ancre");
1867 1866
 }
@@ -2013,7 +2012,7 @@  discard block
 block discarded – undo
2013 2012
 			if (!empty($_SERVER['QUERY_STRING'])
2014 2013
 				and !strpos($_SERVER['REQUEST_URI'], '?')
2015 2014
 			) {
2016
-				$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2015
+				$GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
2017 2016
 			}
2018 2017
 		}
2019 2018
 	}
@@ -2040,17 +2039,17 @@  discard block
 block discarded – undo
2040 2039
 	list($myself) = explode('?', $myself);
2041 2040
 	// vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
2042 2041
 	// protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
2043
-	if (strpos($myself,'://') !== false) {
2044
-		$myself = explode('://',$myself);
2042
+	if (strpos($myself, '://') !== false) {
2043
+		$myself = explode('://', $myself);
2045 2044
 		array_shift($myself);
2046
-		$myself = implode('://',$myself);
2047
-		$myself = explode('/',$myself);
2045
+		$myself = implode('://', $myself);
2046
+		$myself = explode('/', $myself);
2048 2047
 		array_shift($myself);
2049
-		$myself = implode('/',$myself);
2048
+		$myself = implode('/', $myself);
2050 2049
 	}
2051
-	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2050
+	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/';
2052 2051
 
2053
-	$url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2052
+	$url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/');
2054 2053
 
2055 2054
 	return $url;
2056 2055
 }
@@ -2088,17 +2087,17 @@  discard block
 block discarded – undo
2088 2087
  **/
2089 2088
 function generer_url_ecrire($script = '', $args = "", $no_entities = false, $rel = false) {
2090 2089
 	if (!$rel) {
2091
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2090
+		$rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT;
2092 2091
 	} else {
2093 2092
 		if (!is_string($rel)) {
2094 2093
 			$rel = _DIR_RESTREINT ? _DIR_RESTREINT :
2095
-				('./' . _SPIP_ECRIRE_SCRIPT);
2094
+				('./'._SPIP_ECRIRE_SCRIPT);
2096 2095
 		}
2097 2096
 	}
2098 2097
 
2099 2098
 	list($script, $ancre) = array_pad(explode('#', $script), 2, null);
2100 2099
 	if ($script and ($script <> 'accueil' or $rel)) {
2101
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
2100
+		$args = "?exec=$script".(!$args ? '' : "&$args");
2102 2101
 	} elseif ($args) {
2103 2102
 		$args = "?$args";
2104 2103
 	}
@@ -2106,7 +2105,7 @@  discard block
 block discarded – undo
2106 2105
 		$args .= "#$ancre";
2107 2106
 	}
2108 2107
 
2109
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2108
+	return $rel.($no_entities ? $args : str_replace('&', '&amp;', $args));
2110 2109
 }
2111 2110
 
2112 2111
 //
@@ -2176,25 +2175,25 @@  discard block
 block discarded – undo
2176 2175
 		if (is_array($args)) {
2177 2176
 			$r = '';
2178 2177
 			foreach ($args as $k => $v) {
2179
-				$r .= '&' . $k . '=' . $v;
2178
+				$r .= '&'.$k.'='.$v;
2180 2179
 			}
2181 2180
 			$args = substr($r, 1);
2182 2181
 		}
2183 2182
 		$action .=
2184
-			(strpos($action, '?') !== false ? '&' : '?') . $args;
2183
+			(strpos($action, '?') !== false ? '&' : '?').$args;
2185 2184
 	}
2186 2185
 	if (!$no_entities) {
2187 2186
 		$action = quote_amp($action);
2188 2187
 	}
2189 2188
 
2190 2189
 	// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2191
-	return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action"));
2190
+	return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(",^/[.]/,", "/", "/$action"));
2192 2191
 }
2193 2192
 
2194 2193
 // https://code.spip.net/@generer_url_prive
2195 2194
 function generer_url_prive($script, $args = "", $no_entities = false) {
2196 2195
 
2197
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2196
+	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php');
2198 2197
 }
2199 2198
 
2200 2199
 // Pour les formulaires en methode POST,
@@ -2229,8 +2228,7 @@  discard block
 block discarded – undo
2229 2228
 	. "><div>\n"
2230 2229
 	. "<input type='hidden' name='exec' value='$script1' />"
2231 2230
 	. $corps
2232
-	. (!$submit ? '' :
2233
-		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>"))
2231
+	. (!$submit ? '' : ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo' type='submit' value=\"".entites_html($submit)."\" /></div>"))
2234 2232
 	. "</div></form>\n";
2235 2233
 }
2236 2234
 
@@ -2255,14 +2253,14 @@  discard block
 block discarded – undo
2255 2253
 		? generer_url_ecrire(_request('exec'))
2256 2254
 		: generer_url_public();
2257 2255
 
2258
-	return "\n<form action='" .
2259
-	$h .
2260
-	"'" .
2261
-	$atts .
2262
-	">\n" .
2263
-	"<div>" .
2264
-	"\n<input type='hidden' name='action' value='$script' />" .
2265
-	$corps .
2256
+	return "\n<form action='".
2257
+	$h.
2258
+	"'".
2259
+	$atts.
2260
+	">\n".
2261
+	"<div>".
2262
+	"\n<input type='hidden' name='action' value='$script' />".
2263
+	$corps.
2266 2264
 	"</div></form>";
2267 2265
 }
2268 2266
 
@@ -2290,7 +2288,7 @@  discard block
 block discarded – undo
2290 2288
 		: generer_url_public('', '', false, false);
2291 2289
 	$url = parametre_url($url, 'action', $script);
2292 2290
 	if ($args) {
2293
-		$url .= quote_amp('&' . $args);
2291
+		$url .= quote_amp('&'.$args);
2294 2292
 	}
2295 2293
 
2296 2294
 	if ($no_entities) {
@@ -2340,17 +2338,17 @@  discard block
 block discarded – undo
2340 2338
 
2341 2339
 	// le nom du repertoire plugins/ activables/desactivables
2342 2340
 	if (!defined('_DIR_PLUGINS')) {
2343
-		define('_DIR_PLUGINS', _DIR_RACINE . "plugins/");
2341
+		define('_DIR_PLUGINS', _DIR_RACINE."plugins/");
2344 2342
 	}
2345 2343
 
2346 2344
 	// le nom du repertoire des extensions/ permanentes du core, toujours actives
2347 2345
 	if (!defined('_DIR_PLUGINS_DIST')) {
2348
-		define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/");
2346
+		define('_DIR_PLUGINS_DIST', _DIR_RACINE."plugins-dist/");
2349 2347
 	}
2350 2348
 
2351 2349
 	// le nom du repertoire des librairies
2352 2350
 	if (!defined('_DIR_LIB')) {
2353
-		define('_DIR_LIB', _DIR_RACINE . "lib/");
2351
+		define('_DIR_LIB', _DIR_RACINE."lib/");
2354 2352
 	}
2355 2353
 
2356 2354
 	if (!defined('_DIR_IMG')) {
@@ -2360,29 +2358,29 @@  discard block
 block discarded – undo
2360 2358
 		define('_DIR_LOGOS', $pa);
2361 2359
 	}
2362 2360
 	if (!defined('_DIR_IMG_ICONES')) {
2363
-		define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/");
2361
+		define('_DIR_IMG_ICONES', _DIR_LOGOS."icones/");
2364 2362
 	}
2365 2363
 
2366 2364
 	if (!defined('_DIR_DUMP')) {
2367
-		define('_DIR_DUMP', $ti . "dump/");
2365
+		define('_DIR_DUMP', $ti."dump/");
2368 2366
 	}
2369 2367
 	if (!defined('_DIR_SESSIONS')) {
2370
-		define('_DIR_SESSIONS', $ti . "sessions/");
2368
+		define('_DIR_SESSIONS', $ti."sessions/");
2371 2369
 	}
2372 2370
 	if (!defined('_DIR_TRANSFERT')) {
2373
-		define('_DIR_TRANSFERT', $ti . "upload/");
2371
+		define('_DIR_TRANSFERT', $ti."upload/");
2374 2372
 	}
2375 2373
 	if (!defined('_DIR_CACHE')) {
2376
-		define('_DIR_CACHE', $ti . "cache/");
2374
+		define('_DIR_CACHE', $ti."cache/");
2377 2375
 	}
2378 2376
 	if (!defined('_DIR_CACHE_XML')) {
2379
-		define('_DIR_CACHE_XML', _DIR_CACHE . "xml/");
2377
+		define('_DIR_CACHE_XML', _DIR_CACHE."xml/");
2380 2378
 	}
2381 2379
 	if (!defined('_DIR_SKELS')) {
2382
-		define('_DIR_SKELS', _DIR_CACHE . "skel/");
2380
+		define('_DIR_SKELS', _DIR_CACHE."skel/");
2383 2381
 	}
2384 2382
 	if (!defined('_DIR_AIDE')) {
2385
-		define('_DIR_AIDE', _DIR_CACHE . "aide/");
2383
+		define('_DIR_AIDE', _DIR_CACHE."aide/");
2386 2384
 	}
2387 2385
 	if (!defined('_DIR_TMP')) {
2388 2386
 		define('_DIR_TMP', $ti);
@@ -2412,27 +2410,27 @@  discard block
 block discarded – undo
2412 2410
 	// Declaration des fichiers
2413 2411
 
2414 2412
 	if (!defined('_CACHE_PLUGINS_PATH')) {
2415
-		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php");
2413
+		define('_CACHE_PLUGINS_PATH', _DIR_CACHE."charger_plugins_chemins.php");
2416 2414
 	}
2417 2415
 	if (!defined('_CACHE_PLUGINS_OPT')) {
2418
-		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php");
2416
+		define('_CACHE_PLUGINS_OPT', _DIR_CACHE."charger_plugins_options.php");
2419 2417
 	}
2420 2418
 	if (!defined('_CACHE_PLUGINS_FCT')) {
2421
-		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php");
2419
+		define('_CACHE_PLUGINS_FCT', _DIR_CACHE."charger_plugins_fonctions.php");
2422 2420
 	}
2423 2421
 	if (!defined('_CACHE_PIPELINES')) {
2424
-		define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php");
2422
+		define('_CACHE_PIPELINES', _DIR_CACHE."charger_pipelines.php");
2425 2423
 	}
2426 2424
 	if (!defined('_CACHE_CHEMIN')) {
2427
-		define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt");
2425
+		define('_CACHE_CHEMIN', _DIR_CACHE."chemin.txt");
2428 2426
 	}
2429 2427
 
2430 2428
 	# attention .php obligatoire pour ecrire_fichier_securise
2431 2429
 	if (!defined('_FILE_META')) {
2432
-		define('_FILE_META', $ti . 'meta_cache.php');
2430
+		define('_FILE_META', $ti.'meta_cache.php');
2433 2431
 	}
2434 2432
 	if (!defined('_DIR_LOG')) {
2435
-		define('_DIR_LOG', _DIR_TMP . 'log/');
2433
+		define('_DIR_LOG', _DIR_TMP.'log/');
2436 2434
 	}
2437 2435
 	if (!defined('_FILE_LOG')) {
2438 2436
 		define('_FILE_LOG', 'spip');
@@ -2448,8 +2446,8 @@  discard block
 block discarded – undo
2448 2446
 	}
2449 2447
 	if (!defined('_FILE_CONNECT')) {
2450 2448
 		define('_FILE_CONNECT',
2451
-		(@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2452
-			: (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2449
+		(@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f
2450
+			: (@is_readable($f = _DIR_RESTREINT.'inc_connect.php') ? $f
2453 2451
 				: false)));
2454 2452
 	}
2455 2453
 
@@ -2459,7 +2457,7 @@  discard block
 block discarded – undo
2459 2457
 	}
2460 2458
 	if (!defined('_FILE_CHMOD')) {
2461 2459
 		define('_FILE_CHMOD',
2462
-		(@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2460
+		(@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f
2463 2461
 			: false));
2464 2462
 	}
2465 2463
 
@@ -2471,10 +2469,10 @@  discard block
 block discarded – undo
2471 2469
 		define('_FILE_TMP_SUFFIX', '.tmp.php');
2472 2470
 	}
2473 2471
 	if (!defined('_FILE_CONNECT_TMP')) {
2474
-		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2472
+		define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX);
2475 2473
 	}
2476 2474
 	if (!defined('_FILE_CHMOD_TMP')) {
2477
-		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2475
+		define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX);
2478 2476
 	}
2479 2477
 
2480 2478
 	// Definition des droits d'acces en ecriture
@@ -2492,13 +2490,13 @@  discard block
 block discarded – undo
2492 2490
 		define('_DEFAULT_CHARSET', 'utf-8');
2493 2491
 	}
2494 2492
 	if (!defined('_ROOT_PLUGINS')) {
2495
-		define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/");
2493
+		define('_ROOT_PLUGINS', _ROOT_RACINE."plugins/");
2496 2494
 	}
2497 2495
 	if (!defined('_ROOT_PLUGINS_DIST')) {
2498
-		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/");
2496
+		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE."plugins-dist/");
2499 2497
 	}
2500 2498
 	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2501
-		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2499
+		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2502 2500
 	}
2503 2501
 
2504 2502
 	// La taille des Log
@@ -2535,7 +2533,7 @@  discard block
 block discarded – undo
2535 2533
 	// (non surchargeable en l'etat ; attention si on utilise include_spip()
2536 2534
 	// pour le rendre surchargeable, on va provoquer un reecriture
2537 2535
 	// systematique du noyau ou une baisse de perfs => a etudier)
2538
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
2536
+	include_once _ROOT_RESTREINT.'inc/flock.php';
2539 2537
 
2540 2538
 	// charger tout de suite le path et son cache
2541 2539
 	load_path_cache();
@@ -2582,7 +2580,7 @@  discard block
 block discarded – undo
2582 2580
 		if (!empty($_SERVER['QUERY_STRING'])
2583 2581
 			and !strpos($_SERVER['REQUEST_URI'], '?')
2584 2582
 		) {
2585
-			$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2583
+			$GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
2586 2584
 		}
2587 2585
 	}
2588 2586
 
@@ -2618,7 +2616,7 @@  discard block
 block discarded – undo
2618 2616
 
2619 2617
 			if (isset($GLOBALS['meta']['adresse_site'])) {
2620 2618
 				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2621
-				$uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/';
2619
+				$uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '').'/';
2622 2620
 			} else {
2623 2621
 				$uri_ref = "";
2624 2622
 			}
@@ -2706,7 +2704,7 @@  discard block
 block discarded – undo
2706 2704
 	}
2707 2705
 	if (!defined('_CACHE_RUBRIQUES')) {
2708 2706
 		/** Fichier cache pour le navigateur de rubrique du bandeau */
2709
-		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2707
+		define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt');
2710 2708
 	}
2711 2709
 	if (!defined('_CACHE_RUBRIQUES_MAX')) {
2712 2710
 		/** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
@@ -2798,7 +2796,7 @@  discard block
 block discarded – undo
2798 2796
 					$memory *= 1024;
2799 2797
 			}
2800 2798
 			if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) {
2801
-				@ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M');
2799
+				@ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN.'M');
2802 2800
 				if (trim(ini_get('memory_limit')) != $m) {
2803 2801
 					if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2804 2802
 						define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
@@ -2948,7 +2946,7 @@  discard block
 block discarded – undo
2948 2946
 					}
2949 2947
 					if (isset($GLOBALS['visiteur_session']['nom'])) {
2950 2948
 						spip_log($GLOBALS['visiteur_session']['nom']
2951
-							. " " . _VAR_MODE);
2949
+							. " "._VAR_MODE);
2952 2950
 					}
2953 2951
 				} // pas autorise ?
2954 2952
 				else {
@@ -2956,7 +2954,7 @@  discard block
 block discarded – undo
2956 2954
 					if (!$GLOBALS['visiteur_session']) {
2957 2955
 						include_spip('inc/headers');
2958 2956
 						redirige_par_entete(generer_url_public('login',
2959
-							'url=' . rawurlencode(
2957
+							'url='.rawurlencode(
2960 2958
 								parametre_url(self(), 'var_mode', $_GET['var_mode'], '&')
2961 2959
 							), true));
2962 2960
 					}
@@ -3001,10 +2999,10 @@  discard block
 block discarded – undo
3001 2999
 	// mais on risque de perturber des plugins en initialisant trop tot
3002 3000
 	// certaines constantes
3003 3001
 	@spip_initialisation_core(
3004
-		(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3005
-		(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3006
-		(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3007
-		(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3002
+		(_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES),
3003
+		(_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES),
3004
+		(_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES),
3005
+		(_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES)
3008 3006
 	);
3009 3007
 
3010 3008
 	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
@@ -3037,7 +3035,7 @@  discard block
 block discarded – undo
3037 3035
 	}
3038 3036
 
3039 3037
 	$h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3040
-	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3038
+	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) {
3041 3039
 
3042 3040
 		$session = charger_fonction('session', 'inc');
3043 3041
 		if ($session()) {
@@ -3117,7 +3115,7 @@  discard block
 block discarded – undo
3117 3115
 		$s = pipeline('definir_session',
3118 3116
 			$GLOBALS['visiteur_session']
3119 3117
 				? serialize($GLOBALS['visiteur_session'])
3120
-				. '_' . @$_COOKIE['spip_session']
3118
+				. '_'.@$_COOKIE['spip_session']
3121 3119
 				: ''
3122 3120
 		);
3123 3121
 		$session = $s ? substr(md5($s), 0, 8) : '';
@@ -3273,12 +3271,12 @@  discard block
 block discarded – undo
3273 3271
 	$GLOBALS['_INC_PUBLIC']++;
3274 3272
 
3275 3273
 	// fix #4235
3276
-	$cache_utilise_session_appelant	= (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null);
3274
+	$cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null);
3277 3275
 
3278 3276
 
3279 3277
 	foreach (is_array($fond) ? $fond : array($fond) as $f) {
3280 3278
 		
3281
-		unset($GLOBALS['cache_utilise_session']);	// fix #4235
3279
+		unset($GLOBALS['cache_utilise_session']); // fix #4235
3282 3280
 
3283 3281
 		$page = evaluer_fond($f, $contexte, $connect);
3284 3282
 		if ($page === '') {
@@ -3317,7 +3315,7 @@  discard block
 block discarded – undo
3317 3315
 		}
3318 3316
 		
3319 3317
 		// contamination de la session appelante, pour les inclusions statiques
3320
-		if (isset($page['invalideurs']['session'])){
3318
+		if (isset($page['invalideurs']['session'])) {
3321 3319
 			$cache_utilise_session_appelant = $page['invalideurs']['session'];
3322 3320
 		}
3323 3321
 	}
@@ -3363,7 +3361,7 @@  discard block
 block discarded – undo
3363 3361
  * @return array|string
3364 3362
  */
3365 3363
 function trouver_fond($nom, $dir = '', $pathinfo = false) {
3366
-	$f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3364
+	$f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : '');
3367 3365
 	if (!$pathinfo) {
3368 3366
 		return $f;
3369 3367
 	}
@@ -3597,7 +3595,7 @@  discard block
 block discarded – undo
3597 3595
 
3598 3596
 			if (!is_array($params[0])) {
3599 3597
 				trigger_error(
3600
-					'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given',
3598
+					'array_column() expects parameter 1 to be array, '.gettype($params[0]).' given',
3601 3599
 					E_USER_WARNING
3602 3600
 				);
3603 3601
 				return null;
Please login to merge, or discard this patch.