Completed
Push — master ( 718d7a...c76770 )
by cam
01:03
created
ecrire/balise/formulaire_.php 1 patch
Indentation   +248 added lines, -248 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * @package SPIP\Core\Formulaires
16 16
  **/
17 17
 if (!defined('_ECRIRE_INC_VERSION')) {
18
-	return;
18
+    return;
19 19
 }
20 20
 
21 21
 include_spip('inc/filtres');
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
  *     Saisie protégée
35 35
  **/
36 36
 function protege_champ($texte) {
37
-	if (is_array($texte)) {
38
-		return array_map('protege_champ', $texte);
39
-	} elseif ($texte === null) {
40
-		return $texte;
41
-	} elseif (is_bool($texte)) {
42
-		return $texte ? '1' : '';
43
-	} elseif (is_string($texte) and $texte) {
44
-		if (strpbrk($texte, "&\"'<>") !== false) {
45
-			return spip_htmlspecialchars($texte, ENT_QUOTES);
46
-		}
47
-	}
48
-
49
-	return $texte;
37
+    if (is_array($texte)) {
38
+        return array_map('protege_champ', $texte);
39
+    } elseif ($texte === null) {
40
+        return $texte;
41
+    } elseif (is_bool($texte)) {
42
+        return $texte ? '1' : '';
43
+    } elseif (is_string($texte) and $texte) {
44
+        if (strpbrk($texte, "&\"'<>") !== false) {
45
+            return spip_htmlspecialchars($texte, ENT_QUOTES);
46
+        }
47
+    }
48
+
49
+    return $texte;
50 50
 }
51 51
 
52 52
 /**
@@ -60,17 +60,17 @@  discard block
 block discarded – undo
60 60
  *     - false : pas de squelette trouvé
61 61
  **/
62 62
 function existe_formulaire($form) {
63
-	if (substr($form, 0, 11) == 'FORMULAIRE_') {
64
-		$form = strtolower(substr($form, 11));
65
-	} else {
66
-		$form = strtolower($form);
67
-	}
63
+    if (substr($form, 0, 11) == 'FORMULAIRE_') {
64
+        $form = strtolower(substr($form, 11));
65
+    } else {
66
+        $form = strtolower($form);
67
+    }
68 68
 
69
-	if (!$form) {
70
-		return '';
71
-	} // on ne sait pas, le nom du formulaire n'est pas fourni ici
69
+    if (!$form) {
70
+        return '';
71
+    } // on ne sait pas, le nom du formulaire n'est pas fourni ici
72 72
 
73
-	return trouver_fond($form, 'formulaires/') ? $form : false;
73
+    return trouver_fond($form, 'formulaires/') ? $form : false;
74 74
 }
75 75
 
76 76
 /**
@@ -79,31 +79,31 @@  discard block
 block discarded – undo
79 79
  * @return false|array
80 80
  */
81 81
 function test_formulaire_inclus_par_modele() {
82
-	$trace = debug_backtrace(0, 20);
83
-	$trace_fonctions = array_column($trace, 'function');
84
-	$trace_fonctions = array_map('strtolower', $trace_fonctions);
85
-
86
-	// regarder si un flag a ete leve juste avant l'appel de balise_FORMULAIRE_dyn
87
-	if (
88
-		function_exists('arguments_balise_dyn_depuis_modele')
89
-		and $form = arguments_balise_dyn_depuis_modele(null, 'read')
90
-	) {
91
-		if (in_array('balise_formulaire__dyn', $trace_fonctions)) {
92
-			$k = array_search('balise_formulaire__dyn', $trace_fonctions);
93
-			if ($trace[$k]['args'][0] === $form) {
94
-				return $trace[$k]['args'];
95
-			}
96
-		}
97
-	}
98
-
99
-	// fallback qui ne repose pas sur le flag lie a l'analyse de contexte_compil,
100
-	// mais ne marche pas si executer_balise_dynamique est appelee via du php dans le squelette
101
-	if (in_array('eval', $trace_fonctions) and in_array('inclure_modele', $trace_fonctions)) {
102
-		$k = array_search('inclure_modele', $trace_fonctions);
103
-		// les arguments de recuperer_fond() passes par inclure_modele()
104
-		return $trace[$k - 1]['args'][1]['args'];
105
-	}
106
-	return false;
82
+    $trace = debug_backtrace(0, 20);
83
+    $trace_fonctions = array_column($trace, 'function');
84
+    $trace_fonctions = array_map('strtolower', $trace_fonctions);
85
+
86
+    // regarder si un flag a ete leve juste avant l'appel de balise_FORMULAIRE_dyn
87
+    if (
88
+        function_exists('arguments_balise_dyn_depuis_modele')
89
+        and $form = arguments_balise_dyn_depuis_modele(null, 'read')
90
+    ) {
91
+        if (in_array('balise_formulaire__dyn', $trace_fonctions)) {
92
+            $k = array_search('balise_formulaire__dyn', $trace_fonctions);
93
+            if ($trace[$k]['args'][0] === $form) {
94
+                return $trace[$k]['args'];
95
+            }
96
+        }
97
+    }
98
+
99
+    // fallback qui ne repose pas sur le flag lie a l'analyse de contexte_compil,
100
+    // mais ne marche pas si executer_balise_dynamique est appelee via du php dans le squelette
101
+    if (in_array('eval', $trace_fonctions) and in_array('inclure_modele', $trace_fonctions)) {
102
+        $k = array_search('inclure_modele', $trace_fonctions);
103
+        // les arguments de recuperer_fond() passes par inclure_modele()
104
+        return $trace[$k - 1]['args'][1]['args'];
105
+    }
106
+    return false;
107 107
 }
108 108
 
109 109
 /**
@@ -118,19 +118,19 @@  discard block
 block discarded – undo
118 118
  **/
119 119
 function balise_FORMULAIRE__dist($p) {
120 120
 
121
-	// Cas d'un #FORMULAIRE_TOTO inexistant : renvoyer la chaine vide.
122
-	// mais si #FORMULAIRE_{toto} on ne peut pas savoir a la compilation, continuer
123
-	if (existe_formulaire($p->nom_champ) === false) {
124
-		$p->code = "''";
125
-		$p->interdire_scripts = false;
121
+    // Cas d'un #FORMULAIRE_TOTO inexistant : renvoyer la chaine vide.
122
+    // mais si #FORMULAIRE_{toto} on ne peut pas savoir a la compilation, continuer
123
+    if (existe_formulaire($p->nom_champ) === false) {
124
+        $p->code = "''";
125
+        $p->interdire_scripts = false;
126 126
 
127
-		return $p;
128
-	}
127
+        return $p;
128
+    }
129 129
 
130
-	// sinon renvoyer un code php dynamique
131
-	$p = calculer_balise_dynamique($p, $p->nom_champ, []);
130
+    // sinon renvoyer un code php dynamique
131
+    $p = calculer_balise_dynamique($p, $p->nom_champ, []);
132 132
 
133
-	return $p;
133
+    return $p;
134 134
 }
135 135
 
136 136
 /**
@@ -150,17 +150,17 @@  discard block
 block discarded – undo
150 150
  *     - string : texte à afficher directement
151 151
  */
152 152
 function balise_FORMULAIRE__dyn($form, ...$args) {
153
-	$form = existe_formulaire($form);
154
-	if (!$form) {
155
-		return '';
156
-	}
153
+    $form = existe_formulaire($form);
154
+    if (!$form) {
155
+        return '';
156
+    }
157 157
 
158
-	$contexte = balise_FORMULAIRE__contexte($form, $args);
159
-	if (!is_array($contexte)) {
160
-		return $contexte;
161
-	}
158
+    $contexte = balise_FORMULAIRE__contexte($form, $args);
159
+    if (!is_array($contexte)) {
160
+        return $contexte;
161
+    }
162 162
 
163
-	return ["formulaires/$form", 3600, $contexte];
163
+    return ["formulaires/$form", 3600, $contexte];
164 164
 }
165 165
 
166 166
 /**
@@ -175,85 +175,85 @@  discard block
 block discarded – undo
175 175
  *     string: Formulaire non applicable (message d’explication)
176 176
  **/
177 177
 function balise_FORMULAIRE__contexte($form, $args) {
178
-	// tester si ce formulaire vient d'etre poste (memes arguments)
179
-	// pour ne pas confondre 2 #FORMULAIRES_XX identiques sur une meme page
180
-	// si poste, on recupere les erreurs
181
-
182
-	$je_suis_poste = false;
183
-	if (
184
-		$post_form = _request('formulaire_action')
185
-		and $post_form == $form
186
-		and $p = _request('formulaire_action_args')
187
-		and is_array($p = decoder_contexte_ajax($p, $post_form))
188
-	) {
189
-		// enlever le faux attribut de langue masque
190
-		array_shift($p);
191
-		if (formulaire__identifier($form, $args, $p)) {
192
-			$je_suis_poste = true;
193
-		}
194
-	}
195
-
196
-	$editable = true;
197
-	$erreurs = $post = [];
198
-	if ($je_suis_poste) {
199
-		$post = traiter_formulaires_dynamiques(true);
200
-		$e = "erreurs_$form";
201
-		$erreurs = $post[$e] ?? [];
202
-		$editable = "editable_$form";
203
-		$editable = (!isset($post[$e]))
204
-			|| (is_countable($erreurs) ? count($erreurs) : 0)
205
-			|| (isset($post[$editable]) && $post[$editable]);
206
-	}
207
-
208
-	$valeurs = formulaire__charger($form, $args, $je_suis_poste);
209
-
210
-	// si $valeurs n'est pas un tableau, le formulaire n'est pas applicable
211
-	// C'est plus fort qu'editable qui est gere par le squelette
212
-	// Idealement $valeur doit etre alors un message explicatif.
213
-	if (!is_array($valeurs)) {
214
-		return is_string($valeurs) ? $valeurs : '';
215
-	}
216
-
217
-	// charger peut passer une action si le formulaire ne tourne pas sur self()
218
-	// ou une action vide si elle ne sert pas
219
-	$action = $valeurs['action'] ?? self('&amp;', true);
220
-	// bug IEx : si action finit par /
221
-	// IE croit que le <form ... action=../ > est autoferme
222
-	if (substr($action, -1) == '/') {
223
-		// on ajoute une ancre pour feinter IE, au pire ca tue l'ancre qui finit par un /
224
-		$action .= '#';
225
-	}
226
-
227
-	// recuperer la saisie en cours si erreurs
228
-	// seulement si c'est ce formulaire qui est poste
229
-	// ou si on le demande explicitement par le parametre _forcer_request = true
230
-	$dispo = ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request']));
231
-	foreach (array_keys($valeurs) as $champ) {
232
-		if ($champ[0] !== '_' and !in_array($champ, ['message_ok', 'message_erreur', 'editable'])) {
233
-			if ($dispo and (($v = _request($champ)) !== null)) {
234
-				$valeurs[$champ] = $v;
235
-			}
236
-			// nettoyer l'url des champs qui vont etre saisis
237
-			if ($action) {
238
-				$action = parametre_url($action, $champ, '');
239
-			}
240
-			// proteger les ' et les " dans les champs que l'on va injecter
241
-			$valeurs[$champ] = protege_champ($valeurs[$champ]);
242
-		}
243
-	}
244
-
245
-	if ($action) {
246
-		// nettoyer l'url
247
-		$action = parametre_url($action, 'formulaire_action', '');
248
-		$action = parametre_url($action, 'formulaire_action_args', '');
249
-		$action = parametre_url($action, 'formulaire_action_sign', '');
250
-	}
251
-
252
-	/**
253
-	 * @deprecated 4.0
254
-	 * servait pour poster sur les actions de type editer_xxx() qui ne prenaient pas d'argument autrement que par _request('arg') et pour lesquelles il fallait donc passer un hash valide
255
-	 */
256
-	/*
178
+    // tester si ce formulaire vient d'etre poste (memes arguments)
179
+    // pour ne pas confondre 2 #FORMULAIRES_XX identiques sur une meme page
180
+    // si poste, on recupere les erreurs
181
+
182
+    $je_suis_poste = false;
183
+    if (
184
+        $post_form = _request('formulaire_action')
185
+        and $post_form == $form
186
+        and $p = _request('formulaire_action_args')
187
+        and is_array($p = decoder_contexte_ajax($p, $post_form))
188
+    ) {
189
+        // enlever le faux attribut de langue masque
190
+        array_shift($p);
191
+        if (formulaire__identifier($form, $args, $p)) {
192
+            $je_suis_poste = true;
193
+        }
194
+    }
195
+
196
+    $editable = true;
197
+    $erreurs = $post = [];
198
+    if ($je_suis_poste) {
199
+        $post = traiter_formulaires_dynamiques(true);
200
+        $e = "erreurs_$form";
201
+        $erreurs = $post[$e] ?? [];
202
+        $editable = "editable_$form";
203
+        $editable = (!isset($post[$e]))
204
+            || (is_countable($erreurs) ? count($erreurs) : 0)
205
+            || (isset($post[$editable]) && $post[$editable]);
206
+    }
207
+
208
+    $valeurs = formulaire__charger($form, $args, $je_suis_poste);
209
+
210
+    // si $valeurs n'est pas un tableau, le formulaire n'est pas applicable
211
+    // C'est plus fort qu'editable qui est gere par le squelette
212
+    // Idealement $valeur doit etre alors un message explicatif.
213
+    if (!is_array($valeurs)) {
214
+        return is_string($valeurs) ? $valeurs : '';
215
+    }
216
+
217
+    // charger peut passer une action si le formulaire ne tourne pas sur self()
218
+    // ou une action vide si elle ne sert pas
219
+    $action = $valeurs['action'] ?? self('&amp;', true);
220
+    // bug IEx : si action finit par /
221
+    // IE croit que le <form ... action=../ > est autoferme
222
+    if (substr($action, -1) == '/') {
223
+        // on ajoute une ancre pour feinter IE, au pire ca tue l'ancre qui finit par un /
224
+        $action .= '#';
225
+    }
226
+
227
+    // recuperer la saisie en cours si erreurs
228
+    // seulement si c'est ce formulaire qui est poste
229
+    // ou si on le demande explicitement par le parametre _forcer_request = true
230
+    $dispo = ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request']));
231
+    foreach (array_keys($valeurs) as $champ) {
232
+        if ($champ[0] !== '_' and !in_array($champ, ['message_ok', 'message_erreur', 'editable'])) {
233
+            if ($dispo and (($v = _request($champ)) !== null)) {
234
+                $valeurs[$champ] = $v;
235
+            }
236
+            // nettoyer l'url des champs qui vont etre saisis
237
+            if ($action) {
238
+                $action = parametre_url($action, $champ, '');
239
+            }
240
+            // proteger les ' et les " dans les champs que l'on va injecter
241
+            $valeurs[$champ] = protege_champ($valeurs[$champ]);
242
+        }
243
+    }
244
+
245
+    if ($action) {
246
+        // nettoyer l'url
247
+        $action = parametre_url($action, 'formulaire_action', '');
248
+        $action = parametre_url($action, 'formulaire_action_args', '');
249
+        $action = parametre_url($action, 'formulaire_action_sign', '');
250
+    }
251
+
252
+    /**
253
+     * @deprecated 4.0
254
+     * servait pour poster sur les actions de type editer_xxx() qui ne prenaient pas d'argument autrement que par _request('arg') et pour lesquelles il fallait donc passer un hash valide
255
+     */
256
+    /*
257 257
 	if (isset($valeurs['_action'])) {
258 258
 		$securiser_action = charger_fonction('securiser_action', 'inc');
259 259
 		$secu = $securiser_action(reset($valeurs['_action']), end($valeurs['_action']), '', -1);
@@ -263,59 +263,59 @@  discard block
 block discarded – undo
263 263
 	}
264 264
 	*/
265 265
 
266
-	// empiler la lang en tant que premier argument implicite du CVT
267
-	// pour permettre de la restaurer au moment du Verifier et du Traiter
268
-	array_unshift($args, $GLOBALS['spip_lang']);
269
-
270
-	$valeurs['formulaire_args'] = encoder_contexte_ajax($args, $form);
271
-	$valeurs['erreurs'] = $erreurs;
272
-	$valeurs['action'] = $action;
273
-	$valeurs['form'] = $form;
274
-
275
-	$valeurs['formulaire_sign'] = '';
276
-	if (!empty($GLOBALS['visiteur_session']['id_auteur'])) {
277
-		$securiser_action = charger_fonction('securiser_action', 'inc');
278
-		$secu = $securiser_action($valeurs['form'], $valeurs['formulaire_args'], '', -1);
279
-		$valeurs['formulaire_sign'] = $secu['hash'];
280
-	}
281
-
282
-	if (!isset($valeurs['id'])) {
283
-		$valeurs['id'] = 'new';
284
-	}
285
-	// editable peut venir de charger() ou de traiter() sinon
286
-	if (!isset($valeurs['editable'])) {
287
-		$valeurs['editable'] = $editable;
288
-	}
289
-	// dans tous les cas, renvoyer un espace ou vide (et pas un booleen)
290
-	$valeurs['editable'] = ($valeurs['editable'] ? ' ' : '');
291
-
292
-	if ($je_suis_poste) {
293
-		$valeurs['message_erreur'] = '';
294
-		if (isset($erreurs['message_erreur'])) {
295
-			$valeurs['message_erreur'] = $erreurs['message_erreur'];
296
-		}
297
-
298
-		$valeurs['message_ok'] = '';
299
-		if (isset($post["message_ok_$form"])) {
300
-			$valeurs['message_ok'] = $post["message_ok_$form"];
301
-		} elseif (isset($erreurs['message_ok'])) {
302
-			$valeurs['message_ok'] = $erreurs['message_ok'];
303
-		}
304
-
305
-		// accessibilite : encapsuler toutes les erreurs dans un role='alert'
306
-		// uniquement si c'est une string et au premier niveau (on ne touche pas au tableaux)
307
-		// et si $k ne commence pas par un _ (c'est bien une vrai erreur sur un vrai champ)
308
-		if (html5_permis()) {
309
-			foreach ($erreurs as $k => $v) {
310
-				if (is_string($v) and strlen(trim($v)) and strpos($k, '_') !== 0) {
311
-					// on encapsule dans un span car ces messages sont en general simple, juste du texte, et deja dans un span dans le form
312
-					$valeurs['erreurs'][$k] = "<span role='alert'>" . $erreurs[$k] . '</span>';
313
-				}
314
-			}
315
-		}
316
-	}
317
-
318
-	return $valeurs;
266
+    // empiler la lang en tant que premier argument implicite du CVT
267
+    // pour permettre de la restaurer au moment du Verifier et du Traiter
268
+    array_unshift($args, $GLOBALS['spip_lang']);
269
+
270
+    $valeurs['formulaire_args'] = encoder_contexte_ajax($args, $form);
271
+    $valeurs['erreurs'] = $erreurs;
272
+    $valeurs['action'] = $action;
273
+    $valeurs['form'] = $form;
274
+
275
+    $valeurs['formulaire_sign'] = '';
276
+    if (!empty($GLOBALS['visiteur_session']['id_auteur'])) {
277
+        $securiser_action = charger_fonction('securiser_action', 'inc');
278
+        $secu = $securiser_action($valeurs['form'], $valeurs['formulaire_args'], '', -1);
279
+        $valeurs['formulaire_sign'] = $secu['hash'];
280
+    }
281
+
282
+    if (!isset($valeurs['id'])) {
283
+        $valeurs['id'] = 'new';
284
+    }
285
+    // editable peut venir de charger() ou de traiter() sinon
286
+    if (!isset($valeurs['editable'])) {
287
+        $valeurs['editable'] = $editable;
288
+    }
289
+    // dans tous les cas, renvoyer un espace ou vide (et pas un booleen)
290
+    $valeurs['editable'] = ($valeurs['editable'] ? ' ' : '');
291
+
292
+    if ($je_suis_poste) {
293
+        $valeurs['message_erreur'] = '';
294
+        if (isset($erreurs['message_erreur'])) {
295
+            $valeurs['message_erreur'] = $erreurs['message_erreur'];
296
+        }
297
+
298
+        $valeurs['message_ok'] = '';
299
+        if (isset($post["message_ok_$form"])) {
300
+            $valeurs['message_ok'] = $post["message_ok_$form"];
301
+        } elseif (isset($erreurs['message_ok'])) {
302
+            $valeurs['message_ok'] = $erreurs['message_ok'];
303
+        }
304
+
305
+        // accessibilite : encapsuler toutes les erreurs dans un role='alert'
306
+        // uniquement si c'est une string et au premier niveau (on ne touche pas au tableaux)
307
+        // et si $k ne commence pas par un _ (c'est bien une vrai erreur sur un vrai champ)
308
+        if (html5_permis()) {
309
+            foreach ($erreurs as $k => $v) {
310
+                if (is_string($v) and strlen(trim($v)) and strpos($k, '_') !== 0) {
311
+                    // on encapsule dans un span car ces messages sont en general simple, juste du texte, et deja dans un span dans le form
312
+                    $valeurs['erreurs'][$k] = "<span role='alert'>" . $erreurs[$k] . '</span>';
313
+                }
314
+            }
315
+        }
316
+    }
317
+
318
+    return $valeurs;
319 319
 }
320 320
 
321 321
 /**
@@ -327,51 +327,51 @@  discard block
 block discarded – undo
327 327
  * @return array
328 328
  */
329 329
 function formulaire__charger($form, $args, $poste) {
330
-	if ($charger_valeurs = charger_fonction('charger', "formulaires/$form", true)) {
331
-		$valeurs = $charger_valeurs(...$args);
332
-	} else {
333
-		$valeurs = [];
334
-	}
335
-
336
-	$valeurs = pipeline(
337
-		'formulaire_charger',
338
-		[
339
-			'args' => ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste],
340
-			'data' => $valeurs
341
-		]
342
-	);
343
-
344
-	// prise en charge CVT multi etape
345
-	if (is_array($valeurs) and isset($valeurs['_etapes'])) {
346
-		include_spip('inc/cvt_multietapes');
347
-		$valeurs = cvtmulti_formulaire_charger_etapes(
348
-			['form' => $form, 'args' => $args, 'je_suis_poste' => $poste],
349
-			$valeurs
350
-		);
351
-	}
352
-
353
-	// si $valeurs et false ou une chaine, pas de formulaire, donc pas de pipeline !
354
-	if (is_array($valeurs)) {
355
-		if (!isset($valeurs['_pipelines'])) {
356
-			$valeurs['_pipelines'] = [];
357
-		}
358
-		// l'ancien argument _pipeline devient maintenant _pipelines
359
-		// reinjectons le vieux _pipeline au debut de _pipelines
360
-		if (isset($valeurs['_pipeline'])) {
361
-			$pipe = is_array($valeurs['_pipeline']) ? reset($valeurs['_pipeline']) : $valeurs['_pipeline'];
362
-			$args = is_array($valeurs['_pipeline']) ? end($valeurs['_pipeline']) : [];
363
-
364
-			$pipelines = [$pipe => $args];
365
-			$valeurs['_pipelines'] = array_merge($pipelines, $valeurs['_pipelines']);
366
-		}
367
-
368
-		// et enfin, ajoutons systematiquement un pipeline sur le squelette du formulaire
369
-		// qui constitue le cas le plus courant d'utilisation du pipeline recuperer_fond
370
-		// (performance, cela evite de s'injecter dans recuperer_fond utilise pour *tous* les squelettes)
371
-		$valeurs['_pipelines']['formulaire_fond'] = ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste];
372
-	}
373
-
374
-	return $valeurs;
330
+    if ($charger_valeurs = charger_fonction('charger', "formulaires/$form", true)) {
331
+        $valeurs = $charger_valeurs(...$args);
332
+    } else {
333
+        $valeurs = [];
334
+    }
335
+
336
+    $valeurs = pipeline(
337
+        'formulaire_charger',
338
+        [
339
+            'args' => ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste],
340
+            'data' => $valeurs
341
+        ]
342
+    );
343
+
344
+    // prise en charge CVT multi etape
345
+    if (is_array($valeurs) and isset($valeurs['_etapes'])) {
346
+        include_spip('inc/cvt_multietapes');
347
+        $valeurs = cvtmulti_formulaire_charger_etapes(
348
+            ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste],
349
+            $valeurs
350
+        );
351
+    }
352
+
353
+    // si $valeurs et false ou une chaine, pas de formulaire, donc pas de pipeline !
354
+    if (is_array($valeurs)) {
355
+        if (!isset($valeurs['_pipelines'])) {
356
+            $valeurs['_pipelines'] = [];
357
+        }
358
+        // l'ancien argument _pipeline devient maintenant _pipelines
359
+        // reinjectons le vieux _pipeline au debut de _pipelines
360
+        if (isset($valeurs['_pipeline'])) {
361
+            $pipe = is_array($valeurs['_pipeline']) ? reset($valeurs['_pipeline']) : $valeurs['_pipeline'];
362
+            $args = is_array($valeurs['_pipeline']) ? end($valeurs['_pipeline']) : [];
363
+
364
+            $pipelines = [$pipe => $args];
365
+            $valeurs['_pipelines'] = array_merge($pipelines, $valeurs['_pipelines']);
366
+        }
367
+
368
+        // et enfin, ajoutons systematiquement un pipeline sur le squelette du formulaire
369
+        // qui constitue le cas le plus courant d'utilisation du pipeline recuperer_fond
370
+        // (performance, cela evite de s'injecter dans recuperer_fond utilise pour *tous* les squelettes)
371
+        $valeurs['_pipelines']['formulaire_fond'] = ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste];
372
+    }
373
+
374
+    return $valeurs;
375 375
 }
376 376
 
377 377
 /**
@@ -390,9 +390,9 @@  discard block
 block discarded – undo
390 390
  * @return bool
391 391
  */
392 392
 function formulaire__identifier($form, $args, $p) {
393
-	if ($identifier_args = charger_fonction('identifier', "formulaires/$form", true)) {
394
-		return $identifier_args(...$args) === $identifier_args(...$p);
395
-	}
393
+    if ($identifier_args = charger_fonction('identifier', "formulaires/$form", true)) {
394
+        return $identifier_args(...$args) === $identifier_args(...$p);
395
+    }
396 396
 
397
-	return $args === $p;
397
+    return $args === $p;
398 398
 }
Please login to merge, or discard this patch.
config/ecran_securite.php 3 patches
Indentation   +439 added lines, -439 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
  * Test utilisateur
16 16
  */
17 17
 if (isset($_GET['test_ecran_securite'])) {
18
-	$ecran_securite_raison = 'test ' . _ECRAN_SECURITE;
18
+    $ecran_securite_raison = 'test ' . _ECRAN_SECURITE;
19 19
 }
20 20
 
21 21
 if (file_exists($f = __DIR__ . DIRECTORY_SEPARATOR  . 'ecran_securite_options.php')) {
22
-	include ($f);
22
+    include ($f);
23 23
 }
24 24
 
25 25
 /*
@@ -29,222 +29,222 @@  discard block
 block discarded – undo
29 29
  * le load depasse ECRAN_SECURITE_LOAD)
30 30
  */
31 31
 if (!defined('_IS_BOT') and isset($_GET['var_isbot'])) {
32
-	define('_IS_BOT', $_GET['var_isbot'] ? true : false);
32
+    define('_IS_BOT', $_GET['var_isbot'] ? true : false);
33 33
 }
34 34
 
35 35
 /*
36 36
  * Détecteur de robot d'indexation
37 37
  */
38 38
 if (!defined('_IS_BOT')) {
39
-	define(
40
-		'_IS_BOT',
41
-		isset($_SERVER['HTTP_USER_AGENT'])
42
-			and preg_match(
43
-				','
44
-					. implode('|', array(
45
-						// mots generiques
46
-						'bot',
47
-						'slurp',
48
-						'crawler',
49
-						'crwlr',
50
-						'java',
51
-						'monitoring',
52
-						'spider',
53
-						'webvac',
54
-						'yandex',
55
-						'MSIE 6\.0', // botnet 99,9% du temps
56
-						// UA plus cibles
57
-						'200please',
58
-						'80legs',
59
-						'a6-indexer',
60
-						'aboundex',
61
-						'accoona',
62
-						'acrylicapps',
63
-						'addthis',
64
-						'adressendeutschland',
65
-						'alexa',
66
-						'altavista',
67
-						'analyticsseo',
68
-						'antennapod',
69
-						'arachnys',
70
-						'archive',
71
-						'argclrint',
72
-						'aspseek',
73
-						'baidu',
74
-						'begunadvertising',
75
-						'bing',
76
-						'bloglines',
77
-						'buck',
78
-						'browsershots',
79
-						'bubing',
80
-						'butterfly',
81
-						'changedetection',
82
-						'charlotte',
83
-						'chilkat',
84
-						'china',
85
-						'coccoc',
86
-						'crowsnest',
87
-						'dataminr',
88
-						'daumoa',
89
-						'dlvr\.it',
90
-						'dlweb',
91
-						'drupal',
92
-						'ec2linkfinder',
93
-						'eset\.com',
94
-						'estyle',
95
-						'exalead',
96
-						'ezooms',
97
-						'facebookexternalhit',
98
-						'facebookplatform',
99
-						'fairshare',
100
-						'feedfetcher',
101
-						'feedfetcher-google',
102
-						'feedly',
103
-						'fetch',
104
-						'flipboardproxy',
105
-						'genieo',
106
-						'google',
107
-						'go-http-client',
108
-						'grapeshot',
109
-						'hatena-useragent',
110
-						'head',
111
-						'hosttracker',
112
-						'hubspot',
113
-						'ia_archiver',
114
-						'ichiro',
115
-						'iltrovatore-setaccio',
116
-						'immediatenet',
117
-						'ina',
118
-						'inoreader',
119
-						'infegyatlas',
120
-						'infohelfer',
121
-						'instapaper',
122
-						'jabse',
123
-						'james',
124
-						'jersey',
125
-						'kumkie',
126
-						'linkdex',
127
-						'linkfluence',
128
-						'linkwalker',
129
-						'litefinder',
130
-						'loadimpactpageanalyzer',
131
-						'ltx71',
132
-						'luminate',
133
-						'lycos',
134
-						'lycosa',
135
-						'mediapartners-google',
136
-						'msai',
137
-						'myapp',
138
-						'nativehost',
139
-						'najdi',
140
-						'netcraftsurveyagent',
141
-						'netestate',
142
-						'netseer',
143
-						'netnewswire',
144
-						'newspaper',
145
-						'newsblur',
146
-						'nuhk',
147
-						'nuzzel',
148
-						'okhttp',
149
-						'otmedia',
150
-						'owlin',
151
-						'owncloud',
152
-						'panscient',
153
-						'paper\.li',
154
-						'parsijoo',
155
-						'protopage',
156
-						'plukkie',
157
-						'proximic',
158
-						'pubsub',
159
-						'python',
160
-						'qirina',
161
-						'qoshe',
162
-						'qualidator',
163
-						'qwantify',
164
-						'rambler',
165
-						'readability',
166
-						'ruby',
167
-						'sbsearch',
168
-						'scoop\.it',
169
-						'scooter',
170
-						'scoutjet',
171
-						'scrapy',
172
-						'scrubby',
173
-						'scrubbybloglines',
174
-						'shareaholic',
175
-						'shopwiki',
176
-						'simplepie',
177
-						'sistrix',
178
-						'sitechecker',
179
-						'siteexplorer',
180
-						'snapshot',
181
-						'sogou',
182
-						'special_archiver',
183
-						'speedy',
184
-						'spinn3r',
185
-						'spreadtrum',
186
-						'steeler',
187
-						'subscriber',
188
-						'suma',
189
-						'superdownloads',
190
-						'svenska-webbsido',
191
-						'teoma',
192
-						'the knowledge AI',
193
-						'thumbshots',
194
-						'tineye',
195
-						'traackr',
196
-						'trendiction',
197
-						'trendsmap',
198
-						'tweetedtimes',
199
-						'tweetmeme',
200
-						'universalfeedparser',
201
-						'uaslinkchecker',
202
-						'undrip',
203
-						'unwindfetchor',
204
-						'upday',
205
-						'vedma',
206
-						'vkshare',
207
-						'vm',
208
-						'wch',
209
-						'webalta',
210
-						'webcookies',
211
-						'webparser',
212
-						'webthumbnail',
213
-						'wesee',
214
-						'wise-guys',
215
-						'woko',
216
-						'wordpress',
217
-						'wotbox',
218
-						'y!j-bri',
219
-						'y!j-bro',
220
-						'y!j-brw',
221
-						'y!j-bsc',
222
-						'yahoo',
223
-						'yahoo!',
224
-						'yahooysmcm',
225
-						'ymobactus',
226
-						'yats',
227
-						'yeti',
228
-						'zeerch'
229
-					)) . ',i',
230
-				(string)$_SERVER['HTTP_USER_AGENT']
231
-			)
232
-	);
39
+    define(
40
+        '_IS_BOT',
41
+        isset($_SERVER['HTTP_USER_AGENT'])
42
+            and preg_match(
43
+                ','
44
+                    . implode('|', array(
45
+                        // mots generiques
46
+                        'bot',
47
+                        'slurp',
48
+                        'crawler',
49
+                        'crwlr',
50
+                        'java',
51
+                        'monitoring',
52
+                        'spider',
53
+                        'webvac',
54
+                        'yandex',
55
+                        'MSIE 6\.0', // botnet 99,9% du temps
56
+                        // UA plus cibles
57
+                        '200please',
58
+                        '80legs',
59
+                        'a6-indexer',
60
+                        'aboundex',
61
+                        'accoona',
62
+                        'acrylicapps',
63
+                        'addthis',
64
+                        'adressendeutschland',
65
+                        'alexa',
66
+                        'altavista',
67
+                        'analyticsseo',
68
+                        'antennapod',
69
+                        'arachnys',
70
+                        'archive',
71
+                        'argclrint',
72
+                        'aspseek',
73
+                        'baidu',
74
+                        'begunadvertising',
75
+                        'bing',
76
+                        'bloglines',
77
+                        'buck',
78
+                        'browsershots',
79
+                        'bubing',
80
+                        'butterfly',
81
+                        'changedetection',
82
+                        'charlotte',
83
+                        'chilkat',
84
+                        'china',
85
+                        'coccoc',
86
+                        'crowsnest',
87
+                        'dataminr',
88
+                        'daumoa',
89
+                        'dlvr\.it',
90
+                        'dlweb',
91
+                        'drupal',
92
+                        'ec2linkfinder',
93
+                        'eset\.com',
94
+                        'estyle',
95
+                        'exalead',
96
+                        'ezooms',
97
+                        'facebookexternalhit',
98
+                        'facebookplatform',
99
+                        'fairshare',
100
+                        'feedfetcher',
101
+                        'feedfetcher-google',
102
+                        'feedly',
103
+                        'fetch',
104
+                        'flipboardproxy',
105
+                        'genieo',
106
+                        'google',
107
+                        'go-http-client',
108
+                        'grapeshot',
109
+                        'hatena-useragent',
110
+                        'head',
111
+                        'hosttracker',
112
+                        'hubspot',
113
+                        'ia_archiver',
114
+                        'ichiro',
115
+                        'iltrovatore-setaccio',
116
+                        'immediatenet',
117
+                        'ina',
118
+                        'inoreader',
119
+                        'infegyatlas',
120
+                        'infohelfer',
121
+                        'instapaper',
122
+                        'jabse',
123
+                        'james',
124
+                        'jersey',
125
+                        'kumkie',
126
+                        'linkdex',
127
+                        'linkfluence',
128
+                        'linkwalker',
129
+                        'litefinder',
130
+                        'loadimpactpageanalyzer',
131
+                        'ltx71',
132
+                        'luminate',
133
+                        'lycos',
134
+                        'lycosa',
135
+                        'mediapartners-google',
136
+                        'msai',
137
+                        'myapp',
138
+                        'nativehost',
139
+                        'najdi',
140
+                        'netcraftsurveyagent',
141
+                        'netestate',
142
+                        'netseer',
143
+                        'netnewswire',
144
+                        'newspaper',
145
+                        'newsblur',
146
+                        'nuhk',
147
+                        'nuzzel',
148
+                        'okhttp',
149
+                        'otmedia',
150
+                        'owlin',
151
+                        'owncloud',
152
+                        'panscient',
153
+                        'paper\.li',
154
+                        'parsijoo',
155
+                        'protopage',
156
+                        'plukkie',
157
+                        'proximic',
158
+                        'pubsub',
159
+                        'python',
160
+                        'qirina',
161
+                        'qoshe',
162
+                        'qualidator',
163
+                        'qwantify',
164
+                        'rambler',
165
+                        'readability',
166
+                        'ruby',
167
+                        'sbsearch',
168
+                        'scoop\.it',
169
+                        'scooter',
170
+                        'scoutjet',
171
+                        'scrapy',
172
+                        'scrubby',
173
+                        'scrubbybloglines',
174
+                        'shareaholic',
175
+                        'shopwiki',
176
+                        'simplepie',
177
+                        'sistrix',
178
+                        'sitechecker',
179
+                        'siteexplorer',
180
+                        'snapshot',
181
+                        'sogou',
182
+                        'special_archiver',
183
+                        'speedy',
184
+                        'spinn3r',
185
+                        'spreadtrum',
186
+                        'steeler',
187
+                        'subscriber',
188
+                        'suma',
189
+                        'superdownloads',
190
+                        'svenska-webbsido',
191
+                        'teoma',
192
+                        'the knowledge AI',
193
+                        'thumbshots',
194
+                        'tineye',
195
+                        'traackr',
196
+                        'trendiction',
197
+                        'trendsmap',
198
+                        'tweetedtimes',
199
+                        'tweetmeme',
200
+                        'universalfeedparser',
201
+                        'uaslinkchecker',
202
+                        'undrip',
203
+                        'unwindfetchor',
204
+                        'upday',
205
+                        'vedma',
206
+                        'vkshare',
207
+                        'vm',
208
+                        'wch',
209
+                        'webalta',
210
+                        'webcookies',
211
+                        'webparser',
212
+                        'webthumbnail',
213
+                        'wesee',
214
+                        'wise-guys',
215
+                        'woko',
216
+                        'wordpress',
217
+                        'wotbox',
218
+                        'y!j-bri',
219
+                        'y!j-bro',
220
+                        'y!j-brw',
221
+                        'y!j-bsc',
222
+                        'yahoo',
223
+                        'yahoo!',
224
+                        'yahooysmcm',
225
+                        'ymobactus',
226
+                        'yats',
227
+                        'yeti',
228
+                        'zeerch'
229
+                    )) . ',i',
230
+                (string)$_SERVER['HTTP_USER_AGENT']
231
+            )
232
+    );
233 233
 }
234 234
 if (!defined('_IS_BOT_FRIEND')) {
235
-	define(
236
-		'_IS_BOT_FRIEND',
237
-		isset($_SERVER['HTTP_USER_AGENT'])
238
-			and preg_match(
239
-				',' . implode('|', array(
240
-					'facebookexternalhit',
241
-					'twitterbot',
242
-					'flipboardproxy',
243
-					'wordpress'
244
-				)) . ',i',
245
-				(string)$_SERVER['HTTP_USER_AGENT']
246
-			)
247
-	);
235
+    define(
236
+        '_IS_BOT_FRIEND',
237
+        isset($_SERVER['HTTP_USER_AGENT'])
238
+            and preg_match(
239
+                ',' . implode('|', array(
240
+                    'facebookexternalhit',
241
+                    'twitterbot',
242
+                    'flipboardproxy',
243
+                    'wordpress'
244
+                )) . ',i',
245
+                (string)$_SERVER['HTTP_USER_AGENT']
246
+            )
247
+    );
248 248
 }
249 249
 
250 250
 /*
@@ -256,28 +256,28 @@  discard block
 block discarded – undo
256 256
  */
257 257
 $_exceptions = array('id_table', 'id_base', 'id_parent', 'id_article_pdf');
258 258
 foreach ($_GET as $var => $val) {
259
-	if (
260
-		$_GET[$var] and strncmp($var, "id_", 3) == 0
261
-		and !in_array($var, $_exceptions)
262
-	) {
263
-		$_GET[$var] = is_array($_GET[$var]) ? @array_map('intval', $_GET[$var]) : intval($_GET[$var]);
264
-	}
259
+    if (
260
+        $_GET[$var] and strncmp($var, "id_", 3) == 0
261
+        and !in_array($var, $_exceptions)
262
+    ) {
263
+        $_GET[$var] = is_array($_GET[$var]) ? @array_map('intval', $_GET[$var]) : intval($_GET[$var]);
264
+    }
265 265
 }
266 266
 foreach ($_POST as $var => $val) {
267
-	if (
268
-		$_POST[$var] and strncmp($var, "id_", 3) == 0
269
-		and !in_array($var, $_exceptions)
270
-	) {
271
-		$_POST[$var] = is_array($_POST[$var]) ? @array_map('intval', $_POST[$var]) : intval($_POST[$var]);
272
-	}
267
+    if (
268
+        $_POST[$var] and strncmp($var, "id_", 3) == 0
269
+        and !in_array($var, $_exceptions)
270
+    ) {
271
+        $_POST[$var] = is_array($_POST[$var]) ? @array_map('intval', $_POST[$var]) : intval($_POST[$var]);
272
+    }
273 273
 }
274 274
 foreach ($GLOBALS as $var => $val) {
275
-	if (
276
-		$GLOBALS[$var] and strncmp($var, "id_", 3) == 0
277
-		and !in_array($var, $_exceptions)
278
-	) {
279
-		$GLOBALS[$var] = is_array($GLOBALS[$var]) ? @array_map('intval', $GLOBALS[$var]) : intval($GLOBALS[$var]);
280
-	}
275
+    if (
276
+        $GLOBALS[$var] and strncmp($var, "id_", 3) == 0
277
+        and !in_array($var, $_exceptions)
278
+    ) {
279
+        $GLOBALS[$var] = is_array($GLOBALS[$var]) ? @array_map('intval', $GLOBALS[$var]) : intval($GLOBALS[$var]);
280
+    }
281 281
 }
282 282
 
283 283
 /*
@@ -290,116 +290,116 @@  discard block
 block discarded – undo
290 290
  * Contrôle de quelques variables (XSS)
291 291
  */
292 292
 foreach (array('lang', 'var_recherche', 'aide', 'var_lang_r', 'lang_r', 'var_ajax_ancre', 'nom_fichier') as $var) {
293
-	if (isset($_GET[$var])) {
294
-		$_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_GET[$var]);
295
-	}
296
-	if (isset($_POST[$var])) {
297
-		$_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_POST[$var]);
298
-	}
293
+    if (isset($_GET[$var])) {
294
+        $_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_GET[$var]);
295
+    }
296
+    if (isset($_POST[$var])) {
297
+        $_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_POST[$var]);
298
+    }
299 299
 }
300 300
 
301 301
 /*
302 302
  * Filtre l'accès à spip_acces_doc (injection SQL en 1.8.2x)
303 303
  */
304 304
 if (isset($_SERVER['REQUEST_URI'])) {
305
-	if (preg_match(',^(.*/)?spip_acces_doc\.,', (string)$_SERVER['REQUEST_URI'])) {
306
-		$file = addslashes((string)$_GET['file']);
307
-	}
305
+    if (preg_match(',^(.*/)?spip_acces_doc\.,', (string)$_SERVER['REQUEST_URI'])) {
306
+        $file = addslashes((string)$_GET['file']);
307
+    }
308 308
 }
309 309
 
310 310
 /*
311 311
  * Pas d'inscription abusive
312 312
  */
313 313
 if (
314
-	isset($_REQUEST['mode']) and isset($_REQUEST['page'])
315
-	and !in_array($_REQUEST['mode'], array("6forum", "1comite"))
316
-	and $_REQUEST['page'] == "identifiants"
314
+    isset($_REQUEST['mode']) and isset($_REQUEST['page'])
315
+    and !in_array($_REQUEST['mode'], array("6forum", "1comite"))
316
+    and $_REQUEST['page'] == "identifiants"
317 317
 ) {
318
-	$ecran_securite_raison = "identifiants";
318
+    $ecran_securite_raison = "identifiants";
319 319
 }
320 320
 
321 321
 /*
322 322
  * Agenda joue à l'injection php
323 323
  */
324 324
 if (
325
-	isset($_REQUEST['partie_cal'])
326
-	and $_REQUEST['partie_cal'] !== htmlentities((string)$_REQUEST['partie_cal'])
325
+    isset($_REQUEST['partie_cal'])
326
+    and $_REQUEST['partie_cal'] !== htmlentities((string)$_REQUEST['partie_cal'])
327 327
 ) {
328
-	$ecran_securite_raison = "partie_cal";
328
+    $ecran_securite_raison = "partie_cal";
329 329
 }
330 330
 if (
331
-	isset($_REQUEST['echelle'])
332
-	and $_REQUEST['echelle'] !== htmlentities((string)$_REQUEST['echelle'])
331
+    isset($_REQUEST['echelle'])
332
+    and $_REQUEST['echelle'] !== htmlentities((string)$_REQUEST['echelle'])
333 333
 ) {
334
-	$ecran_securite_raison = "echelle";
334
+    $ecran_securite_raison = "echelle";
335 335
 }
336 336
 
337 337
 /*
338 338
  * Espace privé
339 339
  */
340 340
 if (
341
-	isset($_REQUEST['exec'])
342
-	and !preg_match(',^[\w-]+$,', (string)$_REQUEST['exec'])
341
+    isset($_REQUEST['exec'])
342
+    and !preg_match(',^[\w-]+$,', (string)$_REQUEST['exec'])
343 343
 ) {
344
-	$ecran_securite_raison = "exec";
344
+    $ecran_securite_raison = "exec";
345 345
 }
346 346
 if (
347
-	isset($_REQUEST['cherche_auteur'])
348
-	and preg_match(',[<],', (string)$_REQUEST['cherche_auteur'])
347
+    isset($_REQUEST['cherche_auteur'])
348
+    and preg_match(',[<],', (string)$_REQUEST['cherche_auteur'])
349 349
 ) {
350
-	$ecran_securite_raison = "cherche_auteur";
350
+    $ecran_securite_raison = "cherche_auteur";
351 351
 }
352 352
 if (
353
-	isset($_REQUEST['exec'])
354
-	and $_REQUEST['exec'] == 'auteurs'
355
-	and isset($_REQUEST['recherche'])
356
-	and preg_match(',[<],', (string)$_REQUEST['recherche'])
353
+    isset($_REQUEST['exec'])
354
+    and $_REQUEST['exec'] == 'auteurs'
355
+    and isset($_REQUEST['recherche'])
356
+    and preg_match(',[<],', (string)$_REQUEST['recherche'])
357 357
 ) {
358
-	$ecran_securite_raison = "recherche";
358
+    $ecran_securite_raison = "recherche";
359 359
 }
360 360
 if (
361
-	isset($_REQUEST['exec'])
362
-	and $_REQUEST['exec'] == 'info_plugin'
363
-	and isset($_REQUEST['plugin'])
364
-	and preg_match(',[<],', (string)$_REQUEST['plugin'])
361
+    isset($_REQUEST['exec'])
362
+    and $_REQUEST['exec'] == 'info_plugin'
363
+    and isset($_REQUEST['plugin'])
364
+    and preg_match(',[<],', (string)$_REQUEST['plugin'])
365 365
 ) {
366
-	$ecran_securite_raison = "plugin";
366
+    $ecran_securite_raison = "plugin";
367 367
 }
368 368
 if (
369
-	isset($_REQUEST['exec'])
370
-	and $_REQUEST['exec'] == 'puce_statut'
371
-	and isset($_REQUEST['id'])
372
-	and !intval($_REQUEST['id'])
369
+    isset($_REQUEST['exec'])
370
+    and $_REQUEST['exec'] == 'puce_statut'
371
+    and isset($_REQUEST['id'])
372
+    and !intval($_REQUEST['id'])
373 373
 ) {
374
-	$ecran_securite_raison = "puce_statut";
374
+    $ecran_securite_raison = "puce_statut";
375 375
 }
376 376
 if (
377
-	isset($_REQUEST['action'])
378
-	and $_REQUEST['action'] == 'configurer'
377
+    isset($_REQUEST['action'])
378
+    and $_REQUEST['action'] == 'configurer'
379 379
 ) {
380
-	if (
381
-		@file_exists('inc_version.php')
382
-		or @file_exists('ecrire/inc_version.php')
383
-	) {
384
-		function action_configurer() {
385
-			include_spip('inc/autoriser');
386
-			if (!autoriser('configurer', _request('configuration'))) {
387
-				include_spip('inc/minipres');
388
-				echo minipres(_T('info_acces_interdit'));
389
-				exit;
390
-			}
391
-			require _DIR_RESTREINT . 'action/configurer.php';
392
-			action_configurer_dist();
393
-		}
394
-	}
380
+    if (
381
+        @file_exists('inc_version.php')
382
+        or @file_exists('ecrire/inc_version.php')
383
+    ) {
384
+        function action_configurer() {
385
+            include_spip('inc/autoriser');
386
+            if (!autoriser('configurer', _request('configuration'))) {
387
+                include_spip('inc/minipres');
388
+                echo minipres(_T('info_acces_interdit'));
389
+                exit;
390
+            }
391
+            require _DIR_RESTREINT . 'action/configurer.php';
392
+            action_configurer_dist();
393
+        }
394
+    }
395 395
 }
396 396
 if (
397
-	isset($_REQUEST['action'])
398
-	and $_REQUEST['action'] == 'ordonner_liens_documents'
399
-	and isset($_REQUEST['ordre'])
400
-	and is_string($_REQUEST['ordre'])
397
+    isset($_REQUEST['action'])
398
+    and $_REQUEST['action'] == 'ordonner_liens_documents'
399
+    and isset($_REQUEST['ordre'])
400
+    and is_string($_REQUEST['ordre'])
401 401
 ) {
402
-	$ecran_securite_raison = "ordre a la chaine";
402
+    $ecran_securite_raison = "ordre a la chaine";
403 403
 }
404 404
 
405 405
 
@@ -407,29 +407,29 @@  discard block
 block discarded – undo
407 407
  * Bloque les requêtes contenant %00 (manipulation d'include)
408 408
  */
409 409
 if (strpos(
410
-	(function_exists('get_magic_quotes_gpc') and @get_magic_quotes_gpc())
411
-		? stripslashes(serialize($_REQUEST))
412
-		: serialize($_REQUEST),
413
-	chr(0)
410
+    (function_exists('get_magic_quotes_gpc') and @get_magic_quotes_gpc())
411
+        ? stripslashes(serialize($_REQUEST))
412
+        : serialize($_REQUEST),
413
+    chr(0)
414 414
 ) !== false) {
415
-	$ecran_securite_raison = "%00";
415
+    $ecran_securite_raison = "%00";
416 416
 }
417 417
 
418 418
 /*
419 419
  * Bloque les requêtes fond=formulaire_
420 420
  */
421 421
 if (
422
-	isset($_REQUEST['fond'])
423
-	and preg_match(',^formulaire_,i', $_REQUEST['fond'])
422
+    isset($_REQUEST['fond'])
423
+    and preg_match(',^formulaire_,i', $_REQUEST['fond'])
424 424
 ) {
425
-	$ecran_securite_raison = "fond=formulaire_";
425
+    $ecran_securite_raison = "fond=formulaire_";
426 426
 }
427 427
 
428 428
 /*
429 429
  * Bloque les requêtes du type ?GLOBALS[type_urls]=toto (bug vieux php)
430 430
  */
431 431
 if (isset($_REQUEST['GLOBALS'])) {
432
-	$ecran_securite_raison = "GLOBALS[GLOBALS]";
432
+    $ecran_securite_raison = "GLOBALS[GLOBALS]";
433 433
 }
434 434
 
435 435
 /*
@@ -438,14 +438,14 @@  discard block
 block discarded – undo
438 438
  * les paginations entremélées
439 439
  */
440 440
 if (_IS_BOT) {
441
-	if (
442
-		(isset($_REQUEST['echelle']) and isset($_REQUEST['partie_cal']) and isset($_REQUEST['type']))
443
-		or (strpos((string)$_SERVER['REQUEST_URI'], 'debut_') and preg_match(',[?&]debut_.*&debut_,', (string)$_SERVER['REQUEST_URI']))
444
-		or (isset($_REQUEST['calendrier_annee']) and strpos((string)$_SERVER['REQUEST_URI'], 'debut_'))
445
-		or (isset($_REQUEST['calendrier_annee']) and preg_match(',[?&]calendrier_annee=.*&calendrier_annee=,', (string)$_SERVER['REQUEST_URI']))
446
-	) {
447
-		$ecran_securite_raison = "robot agenda/double pagination";
448
-	}
441
+    if (
442
+        (isset($_REQUEST['echelle']) and isset($_REQUEST['partie_cal']) and isset($_REQUEST['type']))
443
+        or (strpos((string)$_SERVER['REQUEST_URI'], 'debut_') and preg_match(',[?&]debut_.*&debut_,', (string)$_SERVER['REQUEST_URI']))
444
+        or (isset($_REQUEST['calendrier_annee']) and strpos((string)$_SERVER['REQUEST_URI'], 'debut_'))
445
+        or (isset($_REQUEST['calendrier_annee']) and preg_match(',[?&]calendrier_annee=.*&calendrier_annee=,', (string)$_SERVER['REQUEST_URI']))
446
+    ) {
447
+        $ecran_securite_raison = "robot agenda/double pagination";
448
+    }
449 449
 }
450 450
 
451 451
 /*
@@ -453,82 +453,82 @@  discard block
 block discarded – undo
453 453
  * Bloque un XSS sur une page inexistante
454 454
  */
455 455
 if (isset($_REQUEST['page'])) {
456
-	if ($_REQUEST['page'] == 'test_cfg') {
457
-		$ecran_securite_raison = "test_cfg";
458
-	}
459
-	if ($_REQUEST['page'] !== htmlspecialchars((string)$_REQUEST['page'])) {
460
-		$ecran_securite_raison = "xsspage";
461
-	}
462
-	if (
463
-		$_REQUEST['page'] == '404'
464
-		and isset($_REQUEST['erreur'])
465
-	) {
466
-		$ecran_securite_raison = "xss404";
467
-	}
456
+    if ($_REQUEST['page'] == 'test_cfg') {
457
+        $ecran_securite_raison = "test_cfg";
458
+    }
459
+    if ($_REQUEST['page'] !== htmlspecialchars((string)$_REQUEST['page'])) {
460
+        $ecran_securite_raison = "xsspage";
461
+    }
462
+    if (
463
+        $_REQUEST['page'] == '404'
464
+        and isset($_REQUEST['erreur'])
465
+    ) {
466
+        $ecran_securite_raison = "xss404";
467
+    }
468 468
 }
469 469
 
470 470
 /*
471 471
  * XSS par array
472 472
  */
473 473
 foreach (array('var_login') as $var) {
474
-	if (isset($_REQUEST[$var]) and is_array($_REQUEST[$var])) {
475
-		$ecran_securite_raison = "xss " . $var;
476
-	}
474
+    if (isset($_REQUEST[$var]) and is_array($_REQUEST[$var])) {
475
+        $ecran_securite_raison = "xss " . $var;
476
+    }
477 477
 }
478 478
 
479 479
 /*
480 480
  * Parade antivirale contre un cheval de troie
481 481
  */
482 482
 if (!function_exists('tmp_lkojfghx')) {
483
-	function tmp_lkojfghx() {}
484
-	function tmp_lkojfghx2($a = 0, $b = 0, $c = 0, $d = 0) {
485
-		// si jamais on est arrivé ici sur une erreur php
486
-		// et qu'un autre gestionnaire d'erreur est défini, l'appeller
487
-		if ($b && $GLOBALS['tmp_xhgfjokl']) {
488
-			call_user_func($GLOBALS['tmp_xhgfjokl'], $a, $b, $c, $d);
489
-		}
490
-	}
483
+    function tmp_lkojfghx() {}
484
+    function tmp_lkojfghx2($a = 0, $b = 0, $c = 0, $d = 0) {
485
+        // si jamais on est arrivé ici sur une erreur php
486
+        // et qu'un autre gestionnaire d'erreur est défini, l'appeller
487
+        if ($b && $GLOBALS['tmp_xhgfjokl']) {
488
+            call_user_func($GLOBALS['tmp_xhgfjokl'], $a, $b, $c, $d);
489
+        }
490
+    }
491 491
 }
492 492
 if (isset($_POST['tmp_lkojfghx3'])) {
493
-	$ecran_securite_raison = "gumblar";
493
+    $ecran_securite_raison = "gumblar";
494 494
 }
495 495
 
496 496
 /*
497 497
  * Outils XML mal sécurisés < 2.0.9
498 498
  */
499 499
 if (isset($_REQUEST['transformer_xml'])) {
500
-	$ecran_securite_raison = "transformer_xml";
500
+    $ecran_securite_raison = "transformer_xml";
501 501
 }
502 502
 
503 503
 /*
504 504
  * Outils XML mal sécurisés again
505 505
  */
506 506
 if (isset($_REQUEST['var_url']) and $_REQUEST['var_url'] and isset($_REQUEST['exec']) and $_REQUEST['exec'] == 'valider_xml') {
507
-	$url = trim($_REQUEST['var_url']);
508
-	if (
509
-		strncmp($url, '/', 1) == 0
510
-		or (($p = strpos($url, '..')) !== false and strpos($url, '..', $p + 3) !== false)
511
-		or (($p = strpos($url, '..')) !== false and strpos($url, 'IMG', $p + 3) !== false)
512
-		or (strpos($url, '://') !== false or strpos($url, ':\\') !== false)
513
-	) {
514
-		$ecran_securite_raison = 'URL interdite pour var_url';
515
-	}
507
+    $url = trim($_REQUEST['var_url']);
508
+    if (
509
+        strncmp($url, '/', 1) == 0
510
+        or (($p = strpos($url, '..')) !== false and strpos($url, '..', $p + 3) !== false)
511
+        or (($p = strpos($url, '..')) !== false and strpos($url, 'IMG', $p + 3) !== false)
512
+        or (strpos($url, '://') !== false or strpos($url, ':\\') !== false)
513
+    ) {
514
+        $ecran_securite_raison = 'URL interdite pour var_url';
515
+    }
516 516
 }
517 517
 
518 518
 /*
519 519
  * Sauvegarde mal securisée < 2.0.9
520 520
  */
521 521
 if (
522
-	isset($_REQUEST['nom_sauvegarde'])
523
-	and strstr((string)$_REQUEST['nom_sauvegarde'], '/')
522
+    isset($_REQUEST['nom_sauvegarde'])
523
+    and strstr((string)$_REQUEST['nom_sauvegarde'], '/')
524 524
 ) {
525
-	$ecran_securite_raison = 'nom_sauvegarde manipulee';
525
+    $ecran_securite_raison = 'nom_sauvegarde manipulee';
526 526
 }
527 527
 if (
528
-	isset($_REQUEST['znom_sauvegarde'])
529
-	and strstr((string)$_REQUEST['znom_sauvegarde'], '/')
528
+    isset($_REQUEST['znom_sauvegarde'])
529
+    and strstr((string)$_REQUEST['znom_sauvegarde'], '/')
530 530
 ) {
531
-	$ecran_securite_raison = 'znom_sauvegarde manipulee';
531
+    $ecran_securite_raison = 'znom_sauvegarde manipulee';
532 532
 }
533 533
 
534 534
 
@@ -537,57 +537,57 @@  discard block
 block discarded – undo
537 537
  * on vérifie 'page' pour ne pas bloquer ... drupal
538 538
  */
539 539
 if (
540
-	isset($_REQUEST['op']) and isset($_REQUEST['page'])
541
-	and $_REQUEST['op'] !== preg_replace('/[^\\-\w]/', '', $_REQUEST['op'])
540
+    isset($_REQUEST['op']) and isset($_REQUEST['page'])
541
+    and $_REQUEST['op'] !== preg_replace('/[^\\-\w]/', '', $_REQUEST['op'])
542 542
 ) {
543
-	$ecran_securite_raison = 'op';
543
+    $ecran_securite_raison = 'op';
544 544
 }
545 545
 
546 546
 /*
547 547
  * Forms & Table ne se méfiait pas assez des uploads de fichiers
548 548
  */
549 549
 if (count($_FILES)) {
550
-	foreach ($_FILES as $k => $v) {
551
-		if (
552
-			preg_match(',^fichier_\d+$,', $k)
553
-			and preg_match(',\.php,i', $v['name'])
554
-		) {
555
-			unset($_FILES[$k]);
556
-		}
557
-	}
550
+    foreach ($_FILES as $k => $v) {
551
+        if (
552
+            preg_match(',^fichier_\d+$,', $k)
553
+            and preg_match(',\.php,i', $v['name'])
554
+        ) {
555
+            unset($_FILES[$k]);
556
+        }
557
+    }
558 558
 }
559 559
 /*
560 560
  * et Contact trop laxiste avec une variable externe
561 561
  * on bloque pas le post pour eviter de perdre des donnees mais on unset la variable et c'est tout
562 562
  */
563 563
 if (isset($_REQUEST['pj_enregistrees_nom']) and $_REQUEST['pj_enregistrees_nom']) {
564
-	unset($_REQUEST['pj_enregistrees_nom']);
565
-	unset($_GET['pj_enregistrees_nom']);
566
-	unset($_POST['pj_enregistrees_nom']);
564
+    unset($_REQUEST['pj_enregistrees_nom']);
565
+    unset($_GET['pj_enregistrees_nom']);
566
+    unset($_POST['pj_enregistrees_nom']);
567 567
 }
568 568
 
569 569
 /*
570 570
  * reinstall=oui un peu trop permissif
571 571
  */
572 572
 if (
573
-	isset($_REQUEST['reinstall'])
574
-	and $_REQUEST['reinstall'] == 'oui'
573
+    isset($_REQUEST['reinstall'])
574
+    and $_REQUEST['reinstall'] == 'oui'
575 575
 ) {
576
-	$ecran_securite_raison = 'reinstall=oui';
576
+    $ecran_securite_raison = 'reinstall=oui';
577 577
 }
578 578
 
579 579
 /*
580 580
  * Pas d'action pendant l'install
581 581
  */
582 582
 if (isset($_REQUEST['exec']) and $_REQUEST['exec'] === 'install' and isset($_REQUEST['action'])) {
583
-	$ecran_securite_raison = 'install&action impossibles';
583
+    $ecran_securite_raison = 'install&action impossibles';
584 584
 }
585 585
 
586 586
 /*
587 587
  * Échappement xss referer
588 588
  */
589 589
 if (isset($_SERVER['HTTP_REFERER'])) {
590
-	$_SERVER['HTTP_REFERER'] = strtr($_SERVER['HTTP_REFERER'], '<>"\'', '[]##');
590
+    $_SERVER['HTTP_REFERER'] = strtr($_SERVER['HTTP_REFERER'], '<>"\'', '[]##');
591 591
 }
592 592
 
593 593
 
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
  * Echappement HTTP_X_FORWARDED_HOST
596 596
  */
597 597
 if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
598
-	$_SERVER['HTTP_X_FORWARDED_HOST'] = strtr($_SERVER['HTTP_X_FORWARDED_HOST'], "<>?\"\{\}\$'` \r\n", '____________');
598
+    $_SERVER['HTTP_X_FORWARDED_HOST'] = strtr($_SERVER['HTTP_X_FORWARDED_HOST'], "<>?\"\{\}\$'` \r\n", '____________');
599 599
 }
600 600
 
601 601
 
@@ -603,9 +603,9 @@  discard block
 block discarded – undo
603 603
  * Pas d'erreur dans l'erreur
604 604
  */
605 605
 if (isset($_REQUEST['var_erreur']) and isset($_REQUEST['page']) and $_REQUEST['page'] === 'login') {
606
-	if (strlen($_REQUEST['var_erreur']) !== strcspn($_REQUEST['var_erreur'], '<>')) {
607
-		$ecran_securite_raison = 'var_erreur incorrecte';
608
-	}
606
+    if (strlen($_REQUEST['var_erreur']) !== strcspn($_REQUEST['var_erreur'], '<>')) {
607
+        $ecran_securite_raison = 'var_erreur incorrecte';
608
+    }
609 609
 }
610 610
 
611 611
 
@@ -613,30 +613,30 @@  discard block
 block discarded – undo
613 613
  * Réinjection des clés en html dans l'admin r19561
614 614
  */
615 615
 if (
616
-	(isset($_SERVER['REQUEST_URI']) and strpos($_SERVER['REQUEST_URI'], "ecrire/") !== false)
617
-	or isset($_REQUEST['var_memotri'])
616
+    (isset($_SERVER['REQUEST_URI']) and strpos($_SERVER['REQUEST_URI'], "ecrire/") !== false)
617
+    or isset($_REQUEST['var_memotri'])
618 618
 ) {
619
-	$zzzz = implode("", array_keys($_REQUEST));
620
-	if (strlen($zzzz) != strcspn($zzzz, '<>"\'')) {
621
-		$ecran_securite_raison = 'Cle incorrecte en $_REQUEST';
622
-	}
619
+    $zzzz = implode("", array_keys($_REQUEST));
620
+    if (strlen($zzzz) != strcspn($zzzz, '<>"\'')) {
621
+        $ecran_securite_raison = 'Cle incorrecte en $_REQUEST';
622
+    }
623 623
 }
624 624
 
625 625
 /*
626 626
  * Injection par connect
627 627
  */
628 628
 if (
629
-	isset($_REQUEST['connect'])
630
-	// cas qui permettent de sortir d'un commentaire PHP
631
-	and (
632
-		strpos($_REQUEST['connect'], "?") !== false
633
-		or strpos($_REQUEST['connect'], "<") !== false
634
-		or strpos($_REQUEST['connect'], ">") !== false
635
-		or strpos($_REQUEST['connect'], "\n") !== false
636
-		or strpos($_REQUEST['connect'], "\r") !== false
637
-	)
629
+    isset($_REQUEST['connect'])
630
+    // cas qui permettent de sortir d'un commentaire PHP
631
+    and (
632
+        strpos($_REQUEST['connect'], "?") !== false
633
+        or strpos($_REQUEST['connect'], "<") !== false
634
+        or strpos($_REQUEST['connect'], ">") !== false
635
+        or strpos($_REQUEST['connect'], "\n") !== false
636
+        or strpos($_REQUEST['connect'], "\r") !== false
637
+    )
638 638
 ) {
639
-	$ecran_securite_raison = "malformed connect argument";
639
+    $ecran_securite_raison = "malformed connect argument";
640 640
 }
641 641
 
642 642
 
@@ -644,25 +644,25 @@  discard block
 block discarded – undo
644 644
  * _oups donc
645 645
  */
646 646
 if (
647
-	isset($_REQUEST['_oups'])
648
-	and base64_decode($_REQUEST['_oups'], true) === false) {
649
-	$ecran_securite_raison = "malformed _oups argument";
647
+    isset($_REQUEST['_oups'])
648
+    and base64_decode($_REQUEST['_oups'], true) === false) {
649
+    $ecran_securite_raison = "malformed _oups argument";
650 650
 }
651 651
 
652 652
 if (
653
-	isset($_REQUEST['formulaire_action_args'])
653
+    isset($_REQUEST['formulaire_action_args'])
654 654
 ) {
655
-	foreach ($_REQUEST as $k => $v) {
656
-		if (is_string($v)
657
-		  and strpos($v, ':') !== false
658
-		  and strpos($v, '"') !==false
659
-		  and preg_match(',[bidsaO]:,', $v)
660
-		  and @unserialize($v)) {
661
-			$_REQUEST[$k] = htmlentities($v);
662
-			if (isset($_POST[$k])) $_POST[$k] = $_REQUEST[$k];
663
-			if (isset($_GET[$k])) $_GET[$k] = $_REQUEST[$k];
664
-		}
665
-	}
655
+    foreach ($_REQUEST as $k => $v) {
656
+        if (is_string($v)
657
+          and strpos($v, ':') !== false
658
+          and strpos($v, '"') !==false
659
+          and preg_match(',[bidsaO]:,', $v)
660
+          and @unserialize($v)) {
661
+            $_REQUEST[$k] = htmlentities($v);
662
+            if (isset($_POST[$k])) $_POST[$k] = $_REQUEST[$k];
663
+            if (isset($_GET[$k])) $_GET[$k] = $_REQUEST[$k];
664
+        }
665
+    }
666 666
 }
667 667
 
668 668
 
@@ -670,23 +670,23 @@  discard block
 block discarded – undo
670 670
  * S'il y a une raison de mourir, mourons
671 671
  */
672 672
 if (isset($ecran_securite_raison)) {
673
-	header("HTTP/1.0 403 Forbidden");
674
-	header("Expires: Wed, 11 Jan 1984 05:00:00 GMT");
675
-	header("Cache-Control: no-cache, must-revalidate");
676
-	header("Pragma: no-cache");
677
-	header("Content-Type: text/html");
678
-	header("Connection: close");
679
-	die("<html><title>Error 403: Forbidden</title><body><h1>Error 403</h1><p>You are not authorized to view this page ($ecran_securite_raison)</p></body></html>");
673
+    header("HTTP/1.0 403 Forbidden");
674
+    header("Expires: Wed, 11 Jan 1984 05:00:00 GMT");
675
+    header("Cache-Control: no-cache, must-revalidate");
676
+    header("Pragma: no-cache");
677
+    header("Content-Type: text/html");
678
+    header("Connection: close");
679
+    die("<html><title>Error 403: Forbidden</title><body><h1>Error 403</h1><p>You are not authorized to view this page ($ecran_securite_raison)</p></body></html>");
680 680
 }
681 681
 
682 682
 /*
683 683
  * Un filtre filtrer_entites securise
684 684
  */
685 685
 if (!function_exists('filtre_filtrer_entites_dist')) {
686
-	function filtre_filtrer_entites_dist($t) {
687
-		include_spip('inc/texte');
688
-		return interdire_scripts(filtrer_entites($t));
689
-	}
686
+    function filtre_filtrer_entites_dist($t) {
687
+        include_spip('inc/texte');
688
+        return interdire_scripts(filtrer_entites($t));
689
+    }
690 690
 }
691 691
 
692 692
 
@@ -700,35 +700,35 @@  discard block
 block discarded – undo
700 700
  * Bloque les bots quand le load déborde
701 701
  */
702 702
 if (!defined('_ECRAN_SECURITE_LOAD')) {
703
-	define('_ECRAN_SECURITE_LOAD', 4);
703
+    define('_ECRAN_SECURITE_LOAD', 4);
704 704
 }
705 705
 
706 706
 if (
707
-	defined('_ECRAN_SECURITE_LOAD')
708
-	and _ECRAN_SECURITE_LOAD > 0
709
-	and _IS_BOT
710
-	and !_IS_BOT_FRIEND
711
-	and $_SERVER['REQUEST_METHOD'] === 'GET'
712
-	and (
713
-		(function_exists('sys_getloadavg')
714
-			and $load = sys_getloadavg()
715
-			and is_array($load)
716
-			and $load = array_shift($load))
717
-		or
718
-		(@is_readable('/proc/loadavg')
719
-			and $load = file_get_contents('/proc/loadavg')
720
-			and $load = floatval($load))
721
-	)
722
-	and $load > _ECRAN_SECURITE_LOAD // eviter l'evaluation suivante si de toute facon le load est inferieur a la limite
723
-	and rand(0, (int) ($load * $load)) > _ECRAN_SECURITE_LOAD * _ECRAN_SECURITE_LOAD
707
+    defined('_ECRAN_SECURITE_LOAD')
708
+    and _ECRAN_SECURITE_LOAD > 0
709
+    and _IS_BOT
710
+    and !_IS_BOT_FRIEND
711
+    and $_SERVER['REQUEST_METHOD'] === 'GET'
712
+    and (
713
+        (function_exists('sys_getloadavg')
714
+            and $load = sys_getloadavg()
715
+            and is_array($load)
716
+            and $load = array_shift($load))
717
+        or
718
+        (@is_readable('/proc/loadavg')
719
+            and $load = file_get_contents('/proc/loadavg')
720
+            and $load = floatval($load))
721
+    )
722
+    and $load > _ECRAN_SECURITE_LOAD // eviter l'evaluation suivante si de toute facon le load est inferieur a la limite
723
+    and rand(0, (int) ($load * $load)) > _ECRAN_SECURITE_LOAD * _ECRAN_SECURITE_LOAD
724 724
 ) {
725
-	//https://webmasters.stackexchange.com/questions/65674/should-i-return-a-429-or-503-status-code-to-a-bot
726
-	header("HTTP/1.0 429 Too Many Requests");
727
-	header("Retry-After: 300");
728
-	header("Expires: Wed, 11 Jan 1984 05:00:00 GMT");
729
-	header("Cache-Control: no-cache, must-revalidate");
730
-	header("Pragma: no-cache");
731
-	header("Content-Type: text/html");
732
-	header("Connection: close");
733
-	die("<html><title>Status 429: Too Many Requests</title><body><h1>Status 429</h1><p>Too Many Requests (try again soon)</p></body></html>");
725
+    //https://webmasters.stackexchange.com/questions/65674/should-i-return-a-429-or-503-status-code-to-a-bot
726
+    header("HTTP/1.0 429 Too Many Requests");
727
+    header("Retry-After: 300");
728
+    header("Expires: Wed, 11 Jan 1984 05:00:00 GMT");
729
+    header("Cache-Control: no-cache, must-revalidate");
730
+    header("Pragma: no-cache");
731
+    header("Content-Type: text/html");
732
+    header("Connection: close");
733
+    die("<html><title>Status 429: Too Many Requests</title><body><h1>Status 429</h1><p>Too Many Requests (try again soon)</p></body></html>");
734 734
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@  discard block
 block discarded – undo
15 15
  * Test utilisateur
16 16
  */
17 17
 if (isset($_GET['test_ecran_securite'])) {
18
-	$ecran_securite_raison = 'test ' . _ECRAN_SECURITE;
18
+	$ecran_securite_raison = 'test '._ECRAN_SECURITE;
19 19
 }
20 20
 
21
-if (file_exists($f = __DIR__ . DIRECTORY_SEPARATOR  . 'ecran_securite_options.php')) {
21
+if (file_exists($f = __DIR__.DIRECTORY_SEPARATOR.'ecran_securite_options.php')) {
22 22
 	include ($f);
23 23
 }
24 24
 
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 						'yats',
227 227
 						'yeti',
228 228
 						'zeerch'
229
-					)) . ',i',
230
-				(string)$_SERVER['HTTP_USER_AGENT']
229
+					)).',i',
230
+				(string) $_SERVER['HTTP_USER_AGENT']
231 231
 			)
232 232
 	);
233 233
 }
@@ -236,13 +236,13 @@  discard block
 block discarded – undo
236 236
 		'_IS_BOT_FRIEND',
237 237
 		isset($_SERVER['HTTP_USER_AGENT'])
238 238
 			and preg_match(
239
-				',' . implode('|', array(
239
+				','.implode('|', array(
240 240
 					'facebookexternalhit',
241 241
 					'twitterbot',
242 242
 					'flipboardproxy',
243 243
 					'wordpress'
244
-				)) . ',i',
245
-				(string)$_SERVER['HTTP_USER_AGENT']
244
+				)).',i',
245
+				(string) $_SERVER['HTTP_USER_AGENT']
246 246
 			)
247 247
 	);
248 248
 }
@@ -291,10 +291,10 @@  discard block
 block discarded – undo
291 291
  */
292 292
 foreach (array('lang', 'var_recherche', 'aide', 'var_lang_r', 'lang_r', 'var_ajax_ancre', 'nom_fichier') as $var) {
293 293
 	if (isset($_GET[$var])) {
294
-		$_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_GET[$var]);
294
+		$_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string) $_GET[$var]);
295 295
 	}
296 296
 	if (isset($_POST[$var])) {
297
-		$_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_POST[$var]);
297
+		$_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string) $_POST[$var]);
298 298
 	}
299 299
 }
300 300
 
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
  * Filtre l'accès à spip_acces_doc (injection SQL en 1.8.2x)
303 303
  */
304 304
 if (isset($_SERVER['REQUEST_URI'])) {
305
-	if (preg_match(',^(.*/)?spip_acces_doc\.,', (string)$_SERVER['REQUEST_URI'])) {
306
-		$file = addslashes((string)$_GET['file']);
305
+	if (preg_match(',^(.*/)?spip_acces_doc\.,', (string) $_SERVER['REQUEST_URI'])) {
306
+		$file = addslashes((string) $_GET['file']);
307 307
 	}
308 308
 }
309 309
 
@@ -323,13 +323,13 @@  discard block
 block discarded – undo
323 323
  */
324 324
 if (
325 325
 	isset($_REQUEST['partie_cal'])
326
-	and $_REQUEST['partie_cal'] !== htmlentities((string)$_REQUEST['partie_cal'])
326
+	and $_REQUEST['partie_cal'] !== htmlentities((string) $_REQUEST['partie_cal'])
327 327
 ) {
328 328
 	$ecran_securite_raison = "partie_cal";
329 329
 }
330 330
 if (
331 331
 	isset($_REQUEST['echelle'])
332
-	and $_REQUEST['echelle'] !== htmlentities((string)$_REQUEST['echelle'])
332
+	and $_REQUEST['echelle'] !== htmlentities((string) $_REQUEST['echelle'])
333 333
 ) {
334 334
 	$ecran_securite_raison = "echelle";
335 335
 }
@@ -339,13 +339,13 @@  discard block
 block discarded – undo
339 339
  */
340 340
 if (
341 341
 	isset($_REQUEST['exec'])
342
-	and !preg_match(',^[\w-]+$,', (string)$_REQUEST['exec'])
342
+	and !preg_match(',^[\w-]+$,', (string) $_REQUEST['exec'])
343 343
 ) {
344 344
 	$ecran_securite_raison = "exec";
345 345
 }
346 346
 if (
347 347
 	isset($_REQUEST['cherche_auteur'])
348
-	and preg_match(',[<],', (string)$_REQUEST['cherche_auteur'])
348
+	and preg_match(',[<],', (string) $_REQUEST['cherche_auteur'])
349 349
 ) {
350 350
 	$ecran_securite_raison = "cherche_auteur";
351 351
 }
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 	isset($_REQUEST['exec'])
354 354
 	and $_REQUEST['exec'] == 'auteurs'
355 355
 	and isset($_REQUEST['recherche'])
356
-	and preg_match(',[<],', (string)$_REQUEST['recherche'])
356
+	and preg_match(',[<],', (string) $_REQUEST['recherche'])
357 357
 ) {
358 358
 	$ecran_securite_raison = "recherche";
359 359
 }
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	isset($_REQUEST['exec'])
362 362
 	and $_REQUEST['exec'] == 'info_plugin'
363 363
 	and isset($_REQUEST['plugin'])
364
-	and preg_match(',[<],', (string)$_REQUEST['plugin'])
364
+	and preg_match(',[<],', (string) $_REQUEST['plugin'])
365 365
 ) {
366 366
 	$ecran_securite_raison = "plugin";
367 367
 }
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 				echo minipres(_T('info_acces_interdit'));
389 389
 				exit;
390 390
 			}
391
-			require _DIR_RESTREINT . 'action/configurer.php';
391
+			require _DIR_RESTREINT.'action/configurer.php';
392 392
 			action_configurer_dist();
393 393
 		}
394 394
 	}
@@ -440,9 +440,9 @@  discard block
 block discarded – undo
440 440
 if (_IS_BOT) {
441 441
 	if (
442 442
 		(isset($_REQUEST['echelle']) and isset($_REQUEST['partie_cal']) and isset($_REQUEST['type']))
443
-		or (strpos((string)$_SERVER['REQUEST_URI'], 'debut_') and preg_match(',[?&]debut_.*&debut_,', (string)$_SERVER['REQUEST_URI']))
444
-		or (isset($_REQUEST['calendrier_annee']) and strpos((string)$_SERVER['REQUEST_URI'], 'debut_'))
445
-		or (isset($_REQUEST['calendrier_annee']) and preg_match(',[?&]calendrier_annee=.*&calendrier_annee=,', (string)$_SERVER['REQUEST_URI']))
443
+		or (strpos((string) $_SERVER['REQUEST_URI'], 'debut_') and preg_match(',[?&]debut_.*&debut_,', (string) $_SERVER['REQUEST_URI']))
444
+		or (isset($_REQUEST['calendrier_annee']) and strpos((string) $_SERVER['REQUEST_URI'], 'debut_'))
445
+		or (isset($_REQUEST['calendrier_annee']) and preg_match(',[?&]calendrier_annee=.*&calendrier_annee=,', (string) $_SERVER['REQUEST_URI']))
446 446
 	) {
447 447
 		$ecran_securite_raison = "robot agenda/double pagination";
448 448
 	}
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 	if ($_REQUEST['page'] == 'test_cfg') {
457 457
 		$ecran_securite_raison = "test_cfg";
458 458
 	}
459
-	if ($_REQUEST['page'] !== htmlspecialchars((string)$_REQUEST['page'])) {
459
+	if ($_REQUEST['page'] !== htmlspecialchars((string) $_REQUEST['page'])) {
460 460
 		$ecran_securite_raison = "xsspage";
461 461
 	}
462 462
 	if (
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
  */
473 473
 foreach (array('var_login') as $var) {
474 474
 	if (isset($_REQUEST[$var]) and is_array($_REQUEST[$var])) {
475
-		$ecran_securite_raison = "xss " . $var;
475
+		$ecran_securite_raison = "xss ".$var;
476 476
 	}
477 477
 }
478 478
 
@@ -520,13 +520,13 @@  discard block
 block discarded – undo
520 520
  */
521 521
 if (
522 522
 	isset($_REQUEST['nom_sauvegarde'])
523
-	and strstr((string)$_REQUEST['nom_sauvegarde'], '/')
523
+	and strstr((string) $_REQUEST['nom_sauvegarde'], '/')
524 524
 ) {
525 525
 	$ecran_securite_raison = 'nom_sauvegarde manipulee';
526 526
 }
527 527
 if (
528 528
 	isset($_REQUEST['znom_sauvegarde'])
529
-	and strstr((string)$_REQUEST['znom_sauvegarde'], '/')
529
+	and strstr((string) $_REQUEST['znom_sauvegarde'], '/')
530 530
 ) {
531 531
 	$ecran_securite_raison = 'znom_sauvegarde manipulee';
532 532
 }
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 	foreach ($_REQUEST as $k => $v) {
656 656
 		if (is_string($v)
657 657
 		  and strpos($v, ':') !== false
658
-		  and strpos($v, '"') !==false
658
+		  and strpos($v, '"') !== false
659 659
 		  and preg_match(',[bidsaO]:,', $v)
660 660
 		  and @unserialize($v)) {
661 661
 			$_REQUEST[$k] = htmlentities($v);
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -659,8 +659,12 @@
 block discarded – undo
659 659
 		  and preg_match(',[bidsaO]:,', $v)
660 660
 		  and @unserialize($v)) {
661 661
 			$_REQUEST[$k] = htmlentities($v);
662
-			if (isset($_POST[$k])) $_POST[$k] = $_REQUEST[$k];
663
-			if (isset($_GET[$k])) $_GET[$k] = $_REQUEST[$k];
662
+			if (isset($_POST[$k])) {
663
+			    $_POST[$k] = $_REQUEST[$k];
664
+			}
665
+			if (isset($_GET[$k])) {
666
+			    $_GET[$k] = $_REQUEST[$k];
667
+			}
664 668
 		}
665 669
 	}
666 670
 }
Please login to merge, or discard this patch.