Completed
Push — master ( f30f27...7c506a )
by cam
01:04
created
ecrire/inc/utils.php 2 patches
Indentation   +2226 added lines, -2227 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,66 +48,66 @@  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 = [];
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 (
82
-		!$inc = include_spip($dossier . ($d = strtolower($nom)))
83
-		// si le fichier truc/machin/nom.php n'existe pas,
84
-		// la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions
85
-		and strlen(dirname($dossier)) and dirname($dossier) != '.'
86
-	) {
87
-		include_spip(substr($dossier, 0, -1));
88
-	}
89
-	if (function_exists($f)) {
90
-		return $f;
91
-	}
92
-	if (function_exists($g)) {
93
-		return $g;
94
-	}
95
-
96
-	if ($continue) {
97
-		return $echecs[$f] = false;
98
-	}
99
-
100
-	// Echec : message d'erreur
101
-	spip_log("fonction $nom ($f ou $g) indisponible" .
102
-		($inc ? '' : " (fichier $d absent de $dossier)"));
103
-
104
-	include_spip('inc/minipres');
105
-	echo minipres(
106
-		_T('forum_titre_erreur'),
107
-		_T('fichier_introuvable', ['fichier' => '<b>' . spip_htmlentities($d) . '</b>']),
108
-		['all_inline' => true,'status' => 404]
109
-	);
110
-	exit;
51
+    static $echecs = [];
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 (
82
+        !$inc = include_spip($dossier . ($d = strtolower($nom)))
83
+        // si le fichier truc/machin/nom.php n'existe pas,
84
+        // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions
85
+        and strlen(dirname($dossier)) and dirname($dossier) != '.'
86
+    ) {
87
+        include_spip(substr($dossier, 0, -1));
88
+    }
89
+    if (function_exists($f)) {
90
+        return $f;
91
+    }
92
+    if (function_exists($g)) {
93
+        return $g;
94
+    }
95
+
96
+    if ($continue) {
97
+        return $echecs[$f] = false;
98
+    }
99
+
100
+    // Echec : message d'erreur
101
+    spip_log("fonction $nom ($f ou $g) indisponible" .
102
+        ($inc ? '' : " (fichier $d absent de $dossier)"));
103
+
104
+    include_spip('inc/minipres');
105
+    echo minipres(
106
+        _T('forum_titre_erreur'),
107
+        _T('fichier_introuvable', ['fichier' => '<b>' . spip_htmlentities($d) . '</b>']),
108
+        ['all_inline' => true,'status' => 404]
109
+    );
110
+    exit;
111 111
 }
112 112
 
113 113
 /**
@@ -117,17 +117,17 @@  discard block
 block discarded – undo
117 117
  * @return bool
118 118
  */
119 119
 function include_once_check($file) {
120
-	if (file_exists($file)) {
121
-		include_once $file;
120
+    if (file_exists($file)) {
121
+        include_once $file;
122 122
 
123
-		return true;
124
-	}
125
-	$crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : '');
126
-	$crash = ($crash ?: []);
127
-	$crash[$file] = true;
128
-	ecrire_meta('message_crash_plugins', serialize($crash));
123
+        return true;
124
+    }
125
+    $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : '');
126
+    $crash = ($crash ?: []);
127
+    $crash[$file] = true;
128
+    ecrire_meta('message_crash_plugins', serialize($crash));
129 129
 
130
-	return false;
130
+    return false;
131 131
 }
132 132
 
133 133
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
  *     - string : chemin du fichier trouvé
152 152
  **/
153 153
 function include_spip($f, $include = true) {
154
-	return find_in_path($f . '.php', '', $include);
154
+    return find_in_path($f . '.php', '', $include);
155 155
 }
156 156
 
157 157
 /**
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
  *     - string : chemin du fichier trouvé
172 172
  **/
173 173
 function require_spip($f) {
174
-	return find_in_path($f . '.php', '', 'required');
174
+    return find_in_path($f . '.php', '', 'required');
175 175
 }
176 176
 
177 177
 
@@ -180,27 +180,27 @@  discard block
 block discarded – undo
180 180
  * quand on a besoin dans le PHP de filtres/fonctions qui y sont definis
181 181
  */
182 182
 function include_fichiers_fonctions() {
183
-	static $done = false;
184
-	if (!$done) {
185
-		include_spip('inc/lang');
186
-
187
-		// NB: mes_fonctions peut initialiser $dossier_squelettes (old-style)
188
-		// donc il faut l'inclure "en globals"
189
-		if ($f = find_in_path('mes_fonctions.php')) {
190
-			global $dossier_squelettes;
191
-			include_once(_ROOT_CWD . $f);
192
-		}
193
-
194
-		if (@is_readable(_CACHE_PLUGINS_FCT)) {
195
-			// chargement optimise precompile
196
-			include_once(_CACHE_PLUGINS_FCT);
197
-		}
198
-		if (test_espace_prive()) {
199
-			include_spip('inc/filtres_ecrire');
200
-		}
201
-		include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises..
202
-		$done = true;
203
-	}
183
+    static $done = false;
184
+    if (!$done) {
185
+        include_spip('inc/lang');
186
+
187
+        // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style)
188
+        // donc il faut l'inclure "en globals"
189
+        if ($f = find_in_path('mes_fonctions.php')) {
190
+            global $dossier_squelettes;
191
+            include_once(_ROOT_CWD . $f);
192
+        }
193
+
194
+        if (@is_readable(_CACHE_PLUGINS_FCT)) {
195
+            // chargement optimise precompile
196
+            include_once(_CACHE_PLUGINS_FCT);
197
+        }
198
+        if (test_espace_prive()) {
199
+            include_spip('inc/filtres_ecrire');
200
+        }
201
+        include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises..
202
+        $done = true;
203
+    }
204 204
 }
205 205
 
206 206
 /**
@@ -226,23 +226,23 @@  discard block
 block discarded – undo
226 226
  *     Les paramètres du pipeline modifiés
227 227
  **/
228 228
 function minipipe($fonc, &$val) {
229
-	// fonction
230
-	if (function_exists($fonc)) {
231
-		$val = call_user_func($fonc, $val);
232
-	} // Class::Methode
233
-	else {
234
-		if (
235
-			preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs)
236
-			and $methode = [$regs[1], $regs[2]]
237
-			and is_callable($methode)
238
-		) {
239
-			$val = call_user_func($methode, $val);
240
-		} else {
241
-			spip_log("Erreur - '$fonc' non definie !");
242
-		}
243
-	}
244
-
245
-	return $val;
229
+    // fonction
230
+    if (function_exists($fonc)) {
231
+        $val = call_user_func($fonc, $val);
232
+    } // Class::Methode
233
+    else {
234
+        if (
235
+            preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs)
236
+            and $methode = [$regs[1], $regs[2]]
237
+            and is_callable($methode)
238
+        ) {
239
+            $val = call_user_func($methode, $val);
240
+        } else {
241
+            spip_log("Erreur - '$fonc' non definie !");
242
+        }
243
+    }
244
+
245
+    return $val;
246 246
 }
247 247
 
248 248
 /**
@@ -273,46 +273,46 @@  discard block
 block discarded – undo
273 273
  *     Résultat
274 274
  */
275 275
 function pipeline($action, $val = null) {
276
-	static $charger;
277
-
278
-	// chargement initial des fonctions mises en cache, ou generation du cache
279
-	if (!$charger) {
280
-		if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) {
281
-			include_spip('inc/plugin');
282
-			// generer les fichiers php precompiles
283
-			// de chargement des plugins et des pipelines
284
-			actualise_plugins_actifs();
285
-			if (!($ok = @is_readable($charger))) {
286
-				spip_log("fichier $charger pas cree");
287
-			}
288
-		}
289
-
290
-		if ($ok) {
291
-			include_once $charger;
292
-		}
293
-	}
294
-
295
-	// appliquer notre fonction si elle existe
296
-	$fonc = 'execute_pipeline_' . strtolower($action);
297
-	if (function_exists($fonc)) {
298
-		$val = $fonc($val);
299
-	} // plantage ?
300
-	else {
301
-		spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR);
302
-	}
303
-
304
-	// si le flux est une table avec 2 cle args&data
305
-	// on ne ressort du pipe que les donnees dans 'data'
306
-	// array_key_exists pour php 4.1.0
307
-	if (
308
-		is_array($val)
309
-		and count($val) == 2
310
-		and (array_key_exists('data', $val))
311
-	) {
312
-		$val = $val['data'];
313
-	}
314
-
315
-	return $val;
276
+    static $charger;
277
+
278
+    // chargement initial des fonctions mises en cache, ou generation du cache
279
+    if (!$charger) {
280
+        if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) {
281
+            include_spip('inc/plugin');
282
+            // generer les fichiers php precompiles
283
+            // de chargement des plugins et des pipelines
284
+            actualise_plugins_actifs();
285
+            if (!($ok = @is_readable($charger))) {
286
+                spip_log("fichier $charger pas cree");
287
+            }
288
+        }
289
+
290
+        if ($ok) {
291
+            include_once $charger;
292
+        }
293
+    }
294
+
295
+    // appliquer notre fonction si elle existe
296
+    $fonc = 'execute_pipeline_' . strtolower($action);
297
+    if (function_exists($fonc)) {
298
+        $val = $fonc($val);
299
+    } // plantage ?
300
+    else {
301
+        spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR);
302
+    }
303
+
304
+    // si le flux est une table avec 2 cle args&data
305
+    // on ne ressort du pipe que les donnees dans 'data'
306
+    // array_key_exists pour php 4.1.0
307
+    if (
308
+        is_array($val)
309
+        and count($val) == 2
310
+        and (array_key_exists('data', $val))
311
+    ) {
312
+        $val = $val['data'];
313
+    }
314
+
315
+    return $val;
316 316
 }
317 317
 
318 318
 /**
@@ -356,38 +356,38 @@  discard block
 block discarded – undo
356 356
  *     paramètre est planté pour cause de compatibilité ascendante.
357 357
  */
358 358
 function spip_log($message = null, $name = null) {
359
-	static $pre = [];
360
-	static $log;
361
-	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
362
-	if (!isset($regs[1]) or !$logname = $regs[1]) {
363
-		$logname = null;
364
-	}
365
-	if (!isset($regs[2])) {
366
-		$niveau = _LOG_INFO;
367
-	}
368
-	else {
369
-		$niveau = intval($regs[2]);
370
-	}
371
-
372
-	if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) {
373
-		if (!$pre) {
374
-			$pre = [
375
-				_LOG_HS => 'HS:',
376
-				_LOG_ALERTE_ROUGE => 'ALERTE:',
377
-				_LOG_CRITIQUE => 'CRITIQUE:',
378
-				_LOG_ERREUR => 'ERREUR:',
379
-				_LOG_AVERTISSEMENT => 'WARNING:',
380
-				_LOG_INFO_IMPORTANTE => '!INFO:',
381
-				_LOG_INFO => 'info:',
382
-				_LOG_DEBUG => 'debug:'
383
-			];
384
-			$log = charger_fonction('log', 'inc');
385
-		}
386
-		if (!is_string($message)) {
387
-			$message = print_r($message, true);
388
-		}
389
-		$log($pre[$niveau] . ' ' . $message, $logname);
390
-	}
359
+    static $pre = [];
360
+    static $log;
361
+    preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
362
+    if (!isset($regs[1]) or !$logname = $regs[1]) {
363
+        $logname = null;
364
+    }
365
+    if (!isset($regs[2])) {
366
+        $niveau = _LOG_INFO;
367
+    }
368
+    else {
369
+        $niveau = intval($regs[2]);
370
+    }
371
+
372
+    if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) {
373
+        if (!$pre) {
374
+            $pre = [
375
+                _LOG_HS => 'HS:',
376
+                _LOG_ALERTE_ROUGE => 'ALERTE:',
377
+                _LOG_CRITIQUE => 'CRITIQUE:',
378
+                _LOG_ERREUR => 'ERREUR:',
379
+                _LOG_AVERTISSEMENT => 'WARNING:',
380
+                _LOG_INFO_IMPORTANTE => '!INFO:',
381
+                _LOG_INFO => 'info:',
382
+                _LOG_DEBUG => 'debug:'
383
+            ];
384
+            $log = charger_fonction('log', 'inc');
385
+        }
386
+        if (!is_string($message)) {
387
+            $message = print_r($message, true);
388
+        }
389
+        $log($pre[$niveau] . ' ' . $message, $logname);
390
+    }
391 391
 }
392 392
 
393 393
 /**
@@ -398,8 +398,8 @@  discard block
 block discarded – undo
398 398
  * @param array $opt Tableau d'options
399 399
  **/
400 400
 function journal($phrase, $opt = []) {
401
-	$journal = charger_fonction('journal', 'inc');
402
-	$journal($phrase, $opt);
401
+    $journal = charger_fonction('journal', 'inc');
402
+    $journal($phrase, $opt);
403 403
 }
404 404
 
405 405
 
@@ -418,37 +418,37 @@  discard block
 block discarded – undo
418 418
  **/
419 419
 function _request($var, $c = false) {
420 420
 
421
-	if (is_array($c)) {
422
-		return $c[$var] ?? null;
423
-	}
424
-
425
-	if (isset($_GET[$var])) {
426
-		$a = $_GET[$var];
427
-	} elseif (isset($_POST[$var])) {
428
-		$a = $_POST[$var];
429
-	} else {
430
-		return null;
431
-	}
432
-
433
-	// Si on est en ajax et en POST tout a ete encode
434
-	// via encodeURIComponent, il faut donc repasser
435
-	// dans le charset local...
436
-	if (
437
-		defined('_AJAX')
438
-		and _AJAX
439
-		and isset($GLOBALS['meta']['charset'])
440
-		and $GLOBALS['meta']['charset'] != 'utf-8'
441
-		and is_string($a)
442
-		// check rapide mais pas fiable
443
-		and preg_match(',[\x80-\xFF],', $a)
444
-		// check fiable
445
-		and include_spip('inc/charsets')
446
-		and is_utf8($a)
447
-	) {
448
-		return importer_charset($a, 'utf-8');
449
-	}
450
-
451
-	return $a;
421
+    if (is_array($c)) {
422
+        return $c[$var] ?? null;
423
+    }
424
+
425
+    if (isset($_GET[$var])) {
426
+        $a = $_GET[$var];
427
+    } elseif (isset($_POST[$var])) {
428
+        $a = $_POST[$var];
429
+    } else {
430
+        return null;
431
+    }
432
+
433
+    // Si on est en ajax et en POST tout a ete encode
434
+    // via encodeURIComponent, il faut donc repasser
435
+    // dans le charset local...
436
+    if (
437
+        defined('_AJAX')
438
+        and _AJAX
439
+        and isset($GLOBALS['meta']['charset'])
440
+        and $GLOBALS['meta']['charset'] != 'utf-8'
441
+        and is_string($a)
442
+        // check rapide mais pas fiable
443
+        and preg_match(',[\x80-\xFF],', $a)
444
+        // check fiable
445
+        and include_spip('inc/charsets')
446
+        and is_utf8($a)
447
+    ) {
448
+        return importer_charset($a, 'utf-8');
449
+    }
450
+
451
+    return $a;
452 452
 }
453 453
 
454 454
 
@@ -466,22 +466,22 @@  discard block
 block discarded – undo
466 466
  *     - false sinon
467 467
  **/
468 468
 function set_request($var, $val = null, $c = false) {
469
-	if (is_array($c)) {
470
-		unset($c[$var]);
471
-		if ($val !== null) {
472
-			$c[$var] = $val;
473
-		}
469
+    if (is_array($c)) {
470
+        unset($c[$var]);
471
+        if ($val !== null) {
472
+            $c[$var] = $val;
473
+        }
474 474
 
475
-		return $c;
476
-	}
475
+        return $c;
476
+    }
477 477
 
478
-	unset($_GET[$var]);
479
-	unset($_POST[$var]);
480
-	if ($val !== null) {
481
-		$_GET[$var] = $val;
482
-	}
478
+    unset($_GET[$var]);
479
+    unset($_POST[$var]);
480
+    if ($val !== null) {
481
+        $_GET[$var] = $val;
482
+    }
483 483
 
484
-	return false; # n'affecte pas $c
484
+    return false; # n'affecte pas $c
485 485
 }
486 486
 
487 487
 /**
@@ -501,25 +501,25 @@  discard block
 block discarded – undo
501 501
  * @return array|mixed|string
502 502
  */
503 503
 function spip_sanitize_from_request($value, $key, $sanitize_function = 'entites_html') {
504
-	if (is_array($value)) {
505
-		if ($key == '*') {
506
-			$key = array_keys($value);
507
-		}
508
-		if (!is_array($key)) {
509
-			$key = [$key];
510
-		}
511
-		foreach ($key as $k) {
512
-			if (!empty($value[$k])) {
513
-				$value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function);
514
-			}
515
-		}
516
-		return $value;
517
-	}
518
-	// si la valeur vient des GET ou POST on la sanitize
519
-	if (!empty($value) and $value == _request($key)) {
520
-		$value = $sanitize_function($value);
521
-	}
522
-	return $value;
504
+    if (is_array($value)) {
505
+        if ($key == '*') {
506
+            $key = array_keys($value);
507
+        }
508
+        if (!is_array($key)) {
509
+            $key = [$key];
510
+        }
511
+        foreach ($key as $k) {
512
+            if (!empty($value[$k])) {
513
+                $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function);
514
+            }
515
+        }
516
+        return $value;
517
+    }
518
+    // si la valeur vient des GET ou POST on la sanitize
519
+    if (!empty($value) and $value == _request($key)) {
520
+        $value = $sanitize_function($value);
521
+    }
522
+    return $value;
523 523
 }
524 524
 
525 525
 /**
@@ -527,23 +527,22 @@  discard block
 block discarded – undo
527 527
  *
528 528
  * On est sur le web, on exclut certains protocoles,
529 529
  * notamment 'file://', 'php://' et d'autres…
530
-
531 530
  * @param string $url
532 531
  * @return bool
533 532
  */
534 533
 function tester_url_absolue($url) {
535
-	$url = trim($url);
536
-	if (preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) {
537
-		if (
538
-			isset($m[1])
539
-			and $p = strtolower(rtrim($m[1], ':'))
540
-			and in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip'])
541
-		) {
542
-			return false;
543
-		}
544
-		return true;
545
-	}
546
-	return false;
534
+    $url = trim($url);
535
+    if (preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) {
536
+        if (
537
+            isset($m[1])
538
+            and $p = strtolower(rtrim($m[1], ':'))
539
+            and in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip'])
540
+        ) {
541
+            return false;
542
+        }
543
+        return true;
544
+    }
545
+    return false;
547 546
 }
548 547
 
549 548
 /**
@@ -565,95 +564,95 @@  discard block
 block discarded – undo
565 564
  * @return string URL
566 565
  */
567 566
 function parametre_url($url, $c, $v = null, $sep = '&amp;') {
568
-	// requete erronnee : plusieurs variable dans $c et aucun $v
569
-	if (strpos($c, '|') !== false and is_null($v)) {
570
-		return null;
571
-	}
572
-
573
-	// lever l'#ancre
574
-	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
575
-		$url = $r[1];
576
-		$ancre = $r[2];
577
-	} else {
578
-		$ancre = '';
579
-	}
580
-
581
-	// eclater
582
-	$url = preg_split(',[?]|&amp;|&,', $url);
583
-
584
-	// recuperer la base
585
-	$a = array_shift($url);
586
-	if (!$a) {
587
-		$a = './';
588
-	}
589
-
590
-	$regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,';
591
-	$ajouts = array_flip(explode('|', $c));
592
-	$u = is_array($v) ? $v : rawurlencode((string) $v);
593
-	$testv = (is_array($v) ? count($v) : strlen((string) $v));
594
-	$v_read = null;
595
-	// lire les variables et agir
596
-	foreach ($url as $n => $val) {
597
-		if (preg_match($regexp, urldecode($val), $r)) {
598
-			$r = array_pad($r, 3, null);
599
-			if ($v === null) {
600
-				// c'est un tableau, on memorise les valeurs
601
-				if (substr($r[1], -2) == '[]') {
602
-					if (!$v_read) {
603
-						$v_read = [];
604
-					}
605
-					$v_read[] = $r[2] ? substr($r[2], 1) : '';
606
-				} // c'est un scalaire, on retourne direct
607
-				else {
608
-					return $r[2] ? substr($r[2], 1) : '';
609
-				}
610
-			} // suppression
611
-			elseif (!$testv) {
612
-				unset($url[$n]);
613
-			}
614
-			// Ajout. Pour une variable, remplacer au meme endroit,
615
-			// pour un tableau ce sera fait dans la prochaine boucle
616
-			elseif (substr($r[1], -2) != '[]') {
617
-				$url[$n] = $r[1] . '=' . $u;
618
-				unset($ajouts[$r[1]]);
619
-			}
620
-			// Pour les tableaux on laisse tomber les valeurs de
621
-			// départ, on remplira à l'étape suivante
622
-			else {
623
-				unset($url[$n]);
624
-			}
625
-		}
626
-	}
627
-
628
-	// traiter les parametres pas encore trouves
629
-	if (
630
-		$v === null
631
-		and $args = func_get_args()
632
-		and count($args) == 2
633
-	) {
634
-		return $v_read; // rien trouve ou un tableau
635
-	} elseif ($testv) {
636
-		foreach ($ajouts as $k => $n) {
637
-			if (!is_array($v)) {
638
-				$url[] = $k . '=' . $u;
639
-			} else {
640
-				$id = (substr($k, -2) == '[]') ? $k : ($k . '[]');
641
-				foreach ($v as $w) {
642
-					$url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w));
643
-				}
644
-			}
645
-		}
646
-	}
647
-
648
-	// eliminer les vides
649
-	$url = array_filter($url);
650
-
651
-	// recomposer l'adresse
652
-	if ($url) {
653
-		$a .= '?' . join($sep, $url);
654
-	}
655
-
656
-	return $a . $ancre;
567
+    // requete erronnee : plusieurs variable dans $c et aucun $v
568
+    if (strpos($c, '|') !== false and is_null($v)) {
569
+        return null;
570
+    }
571
+
572
+    // lever l'#ancre
573
+    if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
574
+        $url = $r[1];
575
+        $ancre = $r[2];
576
+    } else {
577
+        $ancre = '';
578
+    }
579
+
580
+    // eclater
581
+    $url = preg_split(',[?]|&amp;|&,', $url);
582
+
583
+    // recuperer la base
584
+    $a = array_shift($url);
585
+    if (!$a) {
586
+        $a = './';
587
+    }
588
+
589
+    $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,';
590
+    $ajouts = array_flip(explode('|', $c));
591
+    $u = is_array($v) ? $v : rawurlencode((string) $v);
592
+    $testv = (is_array($v) ? count($v) : strlen((string) $v));
593
+    $v_read = null;
594
+    // lire les variables et agir
595
+    foreach ($url as $n => $val) {
596
+        if (preg_match($regexp, urldecode($val), $r)) {
597
+            $r = array_pad($r, 3, null);
598
+            if ($v === null) {
599
+                // c'est un tableau, on memorise les valeurs
600
+                if (substr($r[1], -2) == '[]') {
601
+                    if (!$v_read) {
602
+                        $v_read = [];
603
+                    }
604
+                    $v_read[] = $r[2] ? substr($r[2], 1) : '';
605
+                } // c'est un scalaire, on retourne direct
606
+                else {
607
+                    return $r[2] ? substr($r[2], 1) : '';
608
+                }
609
+            } // suppression
610
+            elseif (!$testv) {
611
+                unset($url[$n]);
612
+            }
613
+            // Ajout. Pour une variable, remplacer au meme endroit,
614
+            // pour un tableau ce sera fait dans la prochaine boucle
615
+            elseif (substr($r[1], -2) != '[]') {
616
+                $url[$n] = $r[1] . '=' . $u;
617
+                unset($ajouts[$r[1]]);
618
+            }
619
+            // Pour les tableaux on laisse tomber les valeurs de
620
+            // départ, on remplira à l'étape suivante
621
+            else {
622
+                unset($url[$n]);
623
+            }
624
+        }
625
+    }
626
+
627
+    // traiter les parametres pas encore trouves
628
+    if (
629
+        $v === null
630
+        and $args = func_get_args()
631
+        and count($args) == 2
632
+    ) {
633
+        return $v_read; // rien trouve ou un tableau
634
+    } elseif ($testv) {
635
+        foreach ($ajouts as $k => $n) {
636
+            if (!is_array($v)) {
637
+                $url[] = $k . '=' . $u;
638
+            } else {
639
+                $id = (substr($k, -2) == '[]') ? $k : ($k . '[]');
640
+                foreach ($v as $w) {
641
+                    $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w));
642
+                }
643
+            }
644
+        }
645
+    }
646
+
647
+    // eliminer les vides
648
+    $url = array_filter($url);
649
+
650
+    // recomposer l'adresse
651
+    if ($url) {
652
+        $a .= '?' . join($sep, $url);
653
+    }
654
+
655
+    return $a . $ancre;
657 656
 }
658 657
 
659 658
 /**
@@ -671,21 +670,21 @@  discard block
 block discarded – undo
671 670
  * @return string
672 671
  */
673 672
 function ancre_url($url, $ancre) {
674
-	// lever l'#ancre
675
-	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
676
-		$url = $r[1];
677
-	}
678
-	if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
679
-		if (!function_exists('translitteration')) {
680
-			include_spip('inc/charsets');
681
-		}
682
-		$ancre = preg_replace(
683
-			['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'],
684
-			['', '-'],
685
-			translitteration($ancre)
686
-		);
687
-	}
688
-	return $url . (strlen($ancre) ? '#' . $ancre : '');
673
+    // lever l'#ancre
674
+    if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
675
+        $url = $r[1];
676
+    }
677
+    if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
678
+        if (!function_exists('translitteration')) {
679
+            include_spip('inc/charsets');
680
+        }
681
+        $ancre = preg_replace(
682
+            ['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'],
683
+            ['', '-'],
684
+            translitteration($ancre)
685
+        );
686
+    }
687
+    return $url . (strlen($ancre) ? '#' . $ancre : '');
689 688
 }
690 689
 
691 690
 /**
@@ -695,16 +694,16 @@  discard block
 block discarded – undo
695 694
  * @return string
696 695
  */
697 696
 function nettoyer_uri($reset = null) {
698
-	static $done = false;
699
-	static $propre = '';
700
-	if (!is_null($reset)) {
701
-		return $propre = $reset;
702
-	}
703
-	if ($done) {
704
-		return $propre;
705
-	}
706
-	$done = true;
707
-	return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);
697
+    static $done = false;
698
+    static $propre = '';
699
+    if (!is_null($reset)) {
700
+        return $propre = $reset;
701
+    }
702
+    if ($done) {
703
+        return $propre;
704
+    }
705
+    $done = true;
706
+    return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);
708 707
 }
709 708
 
710 709
 /**
@@ -716,16 +715,16 @@  discard block
 block discarded – undo
716 715
  * @return string
717 716
  */
718 717
 function nettoyer_uri_var($request_uri) {
719
-	$uri1 = $request_uri;
720
-	do {
721
-		$uri = $uri1;
722
-		$uri1 = preg_replace(
723
-			',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i',
724
-			'\1',
725
-			$uri
726
-		);
727
-	} while ($uri <> $uri1);
728
-	return preg_replace(',[?&]$,', '', $uri1);
718
+    $uri1 = $request_uri;
719
+    do {
720
+        $uri = $uri1;
721
+        $uri1 = preg_replace(
722
+            ',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i',
723
+            '\1',
724
+            $uri
725
+        );
726
+    } while ($uri <> $uri1);
727
+    return preg_replace(',[?&]$,', '', $uri1);
729 728
 }
730 729
 
731 730
 
@@ -739,48 +738,48 @@  discard block
 block discarded – undo
739 738
  *    URL vers soi-même
740 739
  **/
741 740
 function self($amp = '&amp;', $root = false) {
742
-	$url = nettoyer_uri();
743
-	if (
744
-		!$root
745
-		and (
746
-			// si pas de profondeur on peut tronquer
747
-			$GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
748
-			// sinon c'est OK si _SET_HTML_BASE a ete force a false
749
-			or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE))
750
-	) {
751
-		$url = preg_replace(',^[^?]*/,', '', $url);
752
-	}
753
-	// ajouter le cas echeant les variables _POST['id_...']
754
-	foreach ($_POST as $v => $c) {
755
-		if (substr($v, 0, 3) == 'id_') {
756
-			$url = parametre_url($url, $v, $c, '&');
757
-		}
758
-	}
759
-
760
-	// supprimer les variables sans interet
761
-	if (test_espace_prive()) {
762
-		$url = preg_replace(',([?&])('
763
-			. 'lang|show_docs|'
764
-			. 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
765
-		$url = preg_replace(',([?&])[&]+,', '\1', $url);
766
-		$url = preg_replace(',[&]$,', '\1', $url);
767
-	}
768
-
769
-	// eviter les hacks
770
-	include_spip('inc/filtres_mini');
771
-	$url = spip_htmlspecialchars($url);
772
-
773
-	$url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url);
774
-
775
-	// &amp; ?
776
-	if ($amp != '&amp;') {
777
-		$url = str_replace('&amp;', $amp, $url);
778
-	}
779
-
780
-	// Si ca demarre par ? ou vide, donner './'
781
-	$url = preg_replace(',^([?].*)?$,', './\1', $url);
782
-
783
-	return $url;
741
+    $url = nettoyer_uri();
742
+    if (
743
+        !$root
744
+        and (
745
+            // si pas de profondeur on peut tronquer
746
+            $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
747
+            // sinon c'est OK si _SET_HTML_BASE a ete force a false
748
+            or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE))
749
+    ) {
750
+        $url = preg_replace(',^[^?]*/,', '', $url);
751
+    }
752
+    // ajouter le cas echeant les variables _POST['id_...']
753
+    foreach ($_POST as $v => $c) {
754
+        if (substr($v, 0, 3) == 'id_') {
755
+            $url = parametre_url($url, $v, $c, '&');
756
+        }
757
+    }
758
+
759
+    // supprimer les variables sans interet
760
+    if (test_espace_prive()) {
761
+        $url = preg_replace(',([?&])('
762
+            . 'lang|show_docs|'
763
+            . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
764
+        $url = preg_replace(',([?&])[&]+,', '\1', $url);
765
+        $url = preg_replace(',[&]$,', '\1', $url);
766
+    }
767
+
768
+    // eviter les hacks
769
+    include_spip('inc/filtres_mini');
770
+    $url = spip_htmlspecialchars($url);
771
+
772
+    $url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url);
773
+
774
+    // &amp; ?
775
+    if ($amp != '&amp;') {
776
+        $url = str_replace('&amp;', $amp, $url);
777
+    }
778
+
779
+    // Si ca demarre par ? ou vide, donner './'
780
+    $url = preg_replace(',^([?].*)?$,', './\1', $url);
781
+
782
+    return $url;
784 783
 }
785 784
 
786 785
 
@@ -791,7 +790,7 @@  discard block
 block discarded – undo
791 790
  *     true si c'est le cas, false sinon.
792 791
  */
793 792
 function test_espace_prive() {
794
-	return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false;
793
+    return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false;
795 794
 }
796 795
 
797 796
 /**
@@ -801,7 +800,7 @@  discard block
 block discarded – undo
801 800
  * @return bool
802 801
  */
803 802
 function test_plugin_actif($plugin) {
804
-	return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
803
+    return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
805 804
 }
806 805
 
807 806
 /**
@@ -832,52 +831,52 @@  discard block
 block discarded – undo
832 831
  *     Texte
833 832
  */
834 833
 function _T($texte, $args = [], $options = []) {
835
-	static $traduire = false;
836
-	$o = ['class' => '', 'force' => true, 'sanitize' => true];
837
-	if ($options) {
838
-		// support de l'ancien argument $class
839
-		if (is_string($options)) {
840
-			$options = ['class' => $options];
841
-		}
842
-		$o = array_merge($o, $options);
843
-	}
844
-
845
-	if (!$traduire) {
846
-		$traduire = charger_fonction('traduire', 'inc');
847
-		include_spip('inc/lang');
848
-	}
849
-
850
-	// On peut passer explicitement la langue dans le tableau
851
-	// On utilise le même nom de variable que la globale
852
-	if (isset($args['spip_lang'])) {
853
-		$lang = $args['spip_lang'];
854
-		// On l'enleve pour ne pas le passer au remplacement
855
-		unset($args['spip_lang']);
856
-	} // Sinon on prend la langue du contexte
857
-	else {
858
-		$lang = $GLOBALS['spip_lang'];
859
-	}
860
-	$text = $traduire($texte, $lang);
861
-
862
-	if ($text === null || !strlen($text)) {
863
-		if (!$o['force']) {
864
-			return '';
865
-		}
866
-
867
-		$text = $texte;
868
-
869
-		// pour les chaines non traduites, assurer un service minimum
870
-		if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
871
-			$n = strpos($text, ':');
872
-			if ($n !== false) {
873
-				$text = substr($text, $n + 1);
874
-			}
875
-			$text = str_replace('_', ' ', $text);
876
-		}
877
-		$o['class'] = null;
878
-	}
879
-
880
-	return _L($text, $args, $o);
834
+    static $traduire = false;
835
+    $o = ['class' => '', 'force' => true, 'sanitize' => true];
836
+    if ($options) {
837
+        // support de l'ancien argument $class
838
+        if (is_string($options)) {
839
+            $options = ['class' => $options];
840
+        }
841
+        $o = array_merge($o, $options);
842
+    }
843
+
844
+    if (!$traduire) {
845
+        $traduire = charger_fonction('traduire', 'inc');
846
+        include_spip('inc/lang');
847
+    }
848
+
849
+    // On peut passer explicitement la langue dans le tableau
850
+    // On utilise le même nom de variable que la globale
851
+    if (isset($args['spip_lang'])) {
852
+        $lang = $args['spip_lang'];
853
+        // On l'enleve pour ne pas le passer au remplacement
854
+        unset($args['spip_lang']);
855
+    } // Sinon on prend la langue du contexte
856
+    else {
857
+        $lang = $GLOBALS['spip_lang'];
858
+    }
859
+    $text = $traduire($texte, $lang);
860
+
861
+    if ($text === null || !strlen($text)) {
862
+        if (!$o['force']) {
863
+            return '';
864
+        }
865
+
866
+        $text = $texte;
867
+
868
+        // pour les chaines non traduites, assurer un service minimum
869
+        if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
870
+            $n = strpos($text, ':');
871
+            if ($n !== false) {
872
+                $text = substr($text, $n + 1);
873
+            }
874
+            $text = str_replace('_', ' ', $text);
875
+        }
876
+        $o['class'] = null;
877
+    }
878
+
879
+    return _L($text, $args, $o);
881 880
 }
882 881
 
883 882
 
@@ -904,53 +903,53 @@  discard block
 block discarded – undo
904 903
  *     Texte
905 904
  */
906 905
 function _L($text, $args = [], $options = []) {
907
-	$f = $text;
908
-	$defaut_options = [
909
-		'class' => null,
910
-		'sanitize' => true,
911
-	];
912
-	// support de l'ancien argument $class
913
-	if ($options and is_string($options)) {
914
-		$options = ['class' => $options];
915
-	}
916
-	if (is_array($options)) {
917
-		$options += $defaut_options;
918
-	} else {
919
-		$options = $defaut_options;
920
-	}
921
-
922
-	if (is_array($args) and count($args)) {
923
-		if (!function_exists('interdire_scripts')) {
924
-			include_spip('inc/texte');
925
-		}
926
-		if (!function_exists('echapper_html_suspect')) {
927
-			include_spip('inc/texte_mini');
928
-		}
929
-		foreach ($args as $name => $value) {
930
-			if (strpos($text, (string) "@$name@") !== false) {
931
-				if ($options['sanitize']) {
932
-					$value = echapper_html_suspect($value);
933
-					$value = interdire_scripts($value, -1);
934
-				}
935
-				if (!empty($options['class'])) {
936
-					$value = "<span class='" . $options['class'] . "'>$value</span>";
937
-				}
938
-				$text = str_replace("@$name@", $value, $text);
939
-				unset($args[$name]);
940
-			}
941
-		}
942
-		// Si des variables n'ont pas ete inserees, le signaler
943
-		// (chaines de langues pas a jour)
944
-		if ($args) {
945
-			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
946
-		}
947
-	}
948
-
949
-	if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) {
950
-		return "<span class='debug-traduction-erreur'>$text</span>";
951
-	} else {
952
-		return $text;
953
-	}
906
+    $f = $text;
907
+    $defaut_options = [
908
+        'class' => null,
909
+        'sanitize' => true,
910
+    ];
911
+    // support de l'ancien argument $class
912
+    if ($options and is_string($options)) {
913
+        $options = ['class' => $options];
914
+    }
915
+    if (is_array($options)) {
916
+        $options += $defaut_options;
917
+    } else {
918
+        $options = $defaut_options;
919
+    }
920
+
921
+    if (is_array($args) and count($args)) {
922
+        if (!function_exists('interdire_scripts')) {
923
+            include_spip('inc/texte');
924
+        }
925
+        if (!function_exists('echapper_html_suspect')) {
926
+            include_spip('inc/texte_mini');
927
+        }
928
+        foreach ($args as $name => $value) {
929
+            if (strpos($text, (string) "@$name@") !== false) {
930
+                if ($options['sanitize']) {
931
+                    $value = echapper_html_suspect($value);
932
+                    $value = interdire_scripts($value, -1);
933
+                }
934
+                if (!empty($options['class'])) {
935
+                    $value = "<span class='" . $options['class'] . "'>$value</span>";
936
+                }
937
+                $text = str_replace("@$name@", $value, $text);
938
+                unset($args[$name]);
939
+            }
940
+        }
941
+        // Si des variables n'ont pas ete inserees, le signaler
942
+        // (chaines de langues pas a jour)
943
+        if ($args) {
944
+            spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
945
+        }
946
+    }
947
+
948
+    if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) {
949
+        return "<span class='debug-traduction-erreur'>$text</span>";
950
+    } else {
951
+        return $text;
952
+    }
954 953
 }
955 954
 
956 955
 
@@ -964,13 +963,13 @@  discard block
 block discarded – undo
964 963
  * @return string
965 964
  */
966 965
 function joli_repertoire($rep) {
967
-	$a = substr($rep, 0, 1);
968
-	if ($a <> '.' and $a <> '/') {
969
-		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
970
-	}
971
-	$rep = preg_replace(',(^\.\.\/),', '', $rep);
966
+    $a = substr($rep, 0, 1);
967
+    if ($a <> '.' and $a <> '/') {
968
+        $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
969
+    }
970
+    $rep = preg_replace(',(^\.\.\/),', '', $rep);
972 971
 
973
-	return $rep;
972
+    return $rep;
974 973
 }
975 974
 
976 975
 
@@ -995,33 +994,33 @@  discard block
 block discarded – undo
995 994
  * @return float|int|string|void
996 995
  */
997 996
 function spip_timer($t = 'rien', $raw = false) {
998
-	static $time;
999
-	$a = time();
1000
-	$b = microtime();
1001
-	// microtime peut contenir les microsecondes et le temps
1002
-	$b = explode(' ', $b);
1003
-	if (count($b) == 2) {
1004
-		$a = end($b);
1005
-	} // plus precis !
1006
-	$b = reset($b);
1007
-	if (!isset($time[$t])) {
1008
-		$time[$t] = $a + $b;
1009
-	} else {
1010
-		$p = ($a + $b - $time[$t]) * 1000;
1011
-		unset($time[$t]);
997
+    static $time;
998
+    $a = time();
999
+    $b = microtime();
1000
+    // microtime peut contenir les microsecondes et le temps
1001
+    $b = explode(' ', $b);
1002
+    if (count($b) == 2) {
1003
+        $a = end($b);
1004
+    } // plus precis !
1005
+    $b = reset($b);
1006
+    if (!isset($time[$t])) {
1007
+        $time[$t] = $a + $b;
1008
+    } else {
1009
+        $p = ($a + $b - $time[$t]) * 1000;
1010
+        unset($time[$t]);
1012 1011
 #			echo "'$p'";exit;
1013
-		if ($raw) {
1014
-			return $p;
1015
-		}
1016
-		if ($p < 1000) {
1017
-			$s = '';
1018
-		} else {
1019
-			$s = sprintf('%d ', $x = floor($p / 1000));
1020
-			$p -= ($x * 1000);
1021
-		}
1012
+        if ($raw) {
1013
+            return $p;
1014
+        }
1015
+        if ($p < 1000) {
1016
+            $s = '';
1017
+        } else {
1018
+            $s = sprintf('%d ', $x = floor($p / 1000));
1019
+            $p -= ($x * 1000);
1020
+        }
1022 1021
 
1023
-		return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1024
-	}
1022
+        return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1023
+    }
1025 1024
 }
1026 1025
 
1027 1026
 
@@ -1029,21 +1028,21 @@  discard block
 block discarded – undo
1029 1028
 // sinon renvoie True et le date sauf si ca n'est pas souhaite
1030 1029
 // https://code.spip.net/@spip_touch
1031 1030
 function spip_touch($fichier, $duree = 0, $touch = true) {
1032
-	if ($duree) {
1033
-		clearstatcache();
1034
-		if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) {
1035
-			return false;
1036
-		}
1037
-	}
1038
-	if ($touch !== false) {
1039
-		if (!@touch($fichier)) {
1040
-			spip_unlink($fichier);
1041
-			@touch($fichier);
1042
-		};
1043
-		@chmod($fichier, _SPIP_CHMOD & ~0111);
1044
-	}
1031
+    if ($duree) {
1032
+        clearstatcache();
1033
+        if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) {
1034
+            return false;
1035
+        }
1036
+    }
1037
+    if ($touch !== false) {
1038
+        if (!@touch($fichier)) {
1039
+            spip_unlink($fichier);
1040
+            @touch($fichier);
1041
+        };
1042
+        @chmod($fichier, _SPIP_CHMOD & ~0111);
1043
+    }
1045 1044
 
1046
-	return true;
1045
+    return true;
1047 1046
 }
1048 1047
 
1049 1048
 
@@ -1054,11 +1053,11 @@  discard block
 block discarded – undo
1054 1053
  * @uses cron()
1055 1054
  **/
1056 1055
 function action_cron() {
1057
-	include_spip('inc/headers');
1058
-	http_response_code(204); // No Content
1059
-	header('Connection: close');
1060
-	define('_DIRECT_CRON_FORCE', true);
1061
-	cron();
1056
+    include_spip('inc/headers');
1057
+    http_response_code(204); // No Content
1058
+    header('Connection: close');
1059
+    define('_DIRECT_CRON_FORCE', true);
1060
+    cron();
1062 1061
 }
1063 1062
 
1064 1063
 /**
@@ -1074,26 +1073,26 @@  discard block
 block discarded – undo
1074 1073
  *     True si la tache a pu être effectuée
1075 1074
  */
1076 1075
 function cron($taches = [], $taches_old = []) {
1077
-	// si pas en mode cron force, laisser tomber.
1078
-	if (!defined('_DIRECT_CRON_FORCE')) {
1079
-		return false;
1080
-	}
1081
-	if (!is_array($taches)) {
1082
-		$taches = $taches_old;
1083
-	} // compat anciens appels
1084
-	// si taches a inserer en base et base inaccessible, laisser tomber
1085
-	// sinon on ne verifie pas la connexion tout de suite, car si ca se trouve
1086
-	// queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
1087
-	// et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
1088
-	if ($taches and count($taches) and !spip_connect()) {
1089
-		return false;
1090
-	}
1091
-	spip_log('cron !', 'jq' . _LOG_DEBUG);
1092
-	if ($genie = charger_fonction('genie', 'inc', true)) {
1093
-		return $genie($taches);
1094
-	}
1095
-
1096
-	return false;
1076
+    // si pas en mode cron force, laisser tomber.
1077
+    if (!defined('_DIRECT_CRON_FORCE')) {
1078
+        return false;
1079
+    }
1080
+    if (!is_array($taches)) {
1081
+        $taches = $taches_old;
1082
+    } // compat anciens appels
1083
+    // si taches a inserer en base et base inaccessible, laisser tomber
1084
+    // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve
1085
+    // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
1086
+    // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
1087
+    if ($taches and count($taches) and !spip_connect()) {
1088
+        return false;
1089
+    }
1090
+    spip_log('cron !', 'jq' . _LOG_DEBUG);
1091
+    if ($genie = charger_fonction('genie', 'inc', true)) {
1092
+        return $genie($taches);
1093
+    }
1094
+
1095
+    return false;
1097 1096
 }
1098 1097
 
1099 1098
 /**
@@ -1125,17 +1124,17 @@  discard block
 block discarded – undo
1125 1124
  *     Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté.
1126 1125
  */
1127 1126
 function job_queue_add(
1128
-	$function,
1129
-	$description,
1130
-	$arguments = [],
1131
-	$file = '',
1132
-	$no_duplicate = false,
1133
-	$time = 0,
1134
-	$priority = 0
1127
+    $function,
1128
+    $description,
1129
+    $arguments = [],
1130
+    $file = '',
1131
+    $no_duplicate = false,
1132
+    $time = 0,
1133
+    $priority = 0
1135 1134
 ) {
1136
-	include_spip('inc/queue');
1135
+    include_spip('inc/queue');
1137 1136
 
1138
-	return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
1137
+    return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
1139 1138
 }
1140 1139
 
1141 1140
 /**
@@ -1146,9 +1145,9 @@  discard block
 block discarded – undo
1146 1145
  * @return bool
1147 1146
  */
1148 1147
 function job_queue_remove($id_job) {
1149
-	include_spip('inc/queue');
1148
+    include_spip('inc/queue');
1150 1149
 
1151
-	return queue_remove_job($id_job);
1150
+    return queue_remove_job($id_job);
1152 1151
 }
1153 1152
 
1154 1153
 /**
@@ -1161,9 +1160,9 @@  discard block
 block discarded – undo
1161 1160
  *     or an array of simple array to link multiples objet in one time
1162 1161
  */
1163 1162
 function job_queue_link($id_job, $objets) {
1164
-	include_spip('inc/queue');
1163
+    include_spip('inc/queue');
1165 1164
 
1166
-	return queue_link_job($id_job, $objets);
1165
+    return queue_link_job($id_job, $objets);
1167 1166
 }
1168 1167
 
1169 1168
 
@@ -1183,36 +1182,36 @@  discard block
 block discarded – undo
1183 1182
  *  - `null` si la queue n'est pas encore initialisée
1184 1183
  */
1185 1184
 function queue_sleep_time_to_next_job($force = null) {
1186
-	static $queue_next_job_time = -1;
1187
-	if ($force === true) {
1188
-		$queue_next_job_time = -1;
1189
-	} elseif ($force) {
1190
-		$queue_next_job_time = $force;
1191
-	}
1192
-
1193
-	if ($queue_next_job_time == -1) {
1194
-		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1195
-			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
1196
-		}
1197
-		// utiliser un cache memoire si dispo
1198
-		if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
1199
-			$queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
1200
-		} else {
1201
-			$queue_next_job_time = null;
1202
-			if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) {
1203
-				$queue_next_job_time = intval($contenu);
1204
-			}
1205
-		}
1206
-	}
1207
-
1208
-	if (is_null($queue_next_job_time)) {
1209
-		return null;
1210
-	}
1211
-	if (!$_SERVER['REQUEST_TIME']) {
1212
-		$_SERVER['REQUEST_TIME'] = time();
1213
-	}
1214
-
1215
-	return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
1185
+    static $queue_next_job_time = -1;
1186
+    if ($force === true) {
1187
+        $queue_next_job_time = -1;
1188
+    } elseif ($force) {
1189
+        $queue_next_job_time = $force;
1190
+    }
1191
+
1192
+    if ($queue_next_job_time == -1) {
1193
+        if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1194
+            define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
1195
+        }
1196
+        // utiliser un cache memoire si dispo
1197
+        if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
1198
+            $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
1199
+        } else {
1200
+            $queue_next_job_time = null;
1201
+            if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) {
1202
+                $queue_next_job_time = intval($contenu);
1203
+            }
1204
+        }
1205
+    }
1206
+
1207
+    if (is_null($queue_next_job_time)) {
1208
+        return null;
1209
+    }
1210
+    if (!$_SERVER['REQUEST_TIME']) {
1211
+        $_SERVER['REQUEST_TIME'] = time();
1212
+    }
1213
+
1214
+    return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
1216 1215
 }
1217 1216
 
1218 1217
 
@@ -1224,11 +1223,11 @@  discard block
 block discarded – undo
1224 1223
  * @return string
1225 1224
  */
1226 1225
 function quote_amp($u) {
1227
-	return preg_replace(
1228
-		'/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i',
1229
-		'&amp;',
1230
-		$u
1231
-	);
1226
+    return preg_replace(
1227
+        '/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i',
1228
+        '&amp;',
1229
+        $u
1230
+    );
1232 1231
 }
1233 1232
 
1234 1233
 
@@ -1251,27 +1250,27 @@  discard block
 block discarded – undo
1251 1250
  *     Balise HTML `<script>` et son contenu
1252 1251
  **/
1253 1252
 function http_script($script, $src = '', $noscript = '') {
1254
-	static $done = [];
1253
+    static $done = [];
1255 1254
 
1256
-	if ($src && !isset($done[$src])) {
1257
-		$done[$src] = true;
1258
-		$src = find_in_path($src, _JAVASCRIPT);
1259
-		$src = " src='$src'";
1260
-	} else {
1261
-		$src = '';
1262
-	}
1263
-	if ($script) {
1264
-		$script = ("/*<![CDATA[*/\n" .
1265
-			preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1266
-			'/*]]>*/');
1267
-	}
1268
-	if ($noscript) {
1269
-		$noscript = "<noscript>\n\t$noscript\n</noscript>\n";
1270
-	}
1255
+    if ($src && !isset($done[$src])) {
1256
+        $done[$src] = true;
1257
+        $src = find_in_path($src, _JAVASCRIPT);
1258
+        $src = " src='$src'";
1259
+    } else {
1260
+        $src = '';
1261
+    }
1262
+    if ($script) {
1263
+        $script = ("/*<![CDATA[*/\n" .
1264
+            preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1265
+            '/*]]>*/');
1266
+    }
1267
+    if ($noscript) {
1268
+        $noscript = "<noscript>\n\t$noscript\n</noscript>\n";
1269
+    }
1271 1270
 
1272
-	return ($src or $script or $noscript)
1273
-		? "<script type='text/javascript'$src>$script</script>$noscript"
1274
-		: '';
1271
+    return ($src or $script or $noscript)
1272
+        ? "<script type='text/javascript'$src>$script</script>$noscript"
1273
+        : '';
1275 1274
 }
1276 1275
 
1277 1276
 
@@ -1306,7 +1305,7 @@  discard block
 block discarded – undo
1306 1305
  *     Texte échappé
1307 1306
  **/
1308 1307
 function texte_script(string $texte): string {
1309
-	return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte));
1308
+    return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte));
1310 1309
 }
1311 1310
 
1312 1311
 
@@ -1343,68 +1342,68 @@  discard block
 block discarded – undo
1343 1342
  *     Liste des chemins, par ordre de priorité.
1344 1343
  **/
1345 1344
 function _chemin($dir_path = null) {
1346
-	static $path_base = null;
1347
-	static $path_full = null;
1348
-	if ($path_base == null) {
1349
-		// Chemin standard depuis l'espace public
1350
-		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
1351
-			_DIR_RACINE . ':' .
1352
-			_DIR_RACINE . 'squelettes-dist/:' .
1353
-			_DIR_RACINE . 'prive/:' .
1354
-			_DIR_RESTREINT;
1355
-		// Ajouter squelettes/
1356
-		if (@is_dir(_DIR_RACINE . 'squelettes')) {
1357
-			$path = _DIR_RACINE . 'squelettes/:' . $path;
1358
-		}
1359
-		foreach (explode(':', $path) as $dir) {
1360
-			if (strlen($dir) and substr($dir, -1) != '/') {
1361
-				$dir .= '/';
1362
-			}
1363
-			$path_base[] = $dir;
1364
-		}
1365
-		$path_full = $path_base;
1366
-		// Et le(s) dossier(s) des squelettes nommes
1367
-		if (strlen($GLOBALS['dossier_squelettes'])) {
1368
-			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1369
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1370
-			}
1371
-		}
1372
-		$GLOBALS['path_sig'] = md5(serialize($path_full));
1373
-	}
1374
-	if ($dir_path === null) {
1375
-		return $path_full;
1376
-	}
1377
-
1378
-	if (is_array($dir_path) or strlen($dir_path)) {
1379
-		$tete = '';
1380
-		if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1381
-			$tete = array_shift($path_base);
1382
-		}
1383
-		$dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
1384
-		$dirs = array_reverse($dirs);
1385
-		foreach ($dirs as $dir_path) {
1386
-			if (substr($dir_path, -1) != '/') {
1387
-				$dir_path .= '/';
1388
-			}
1389
-			if (!in_array($dir_path, $path_base)) {
1390
-				array_unshift($path_base, $dir_path);
1391
-			}
1392
-		}
1393
-		if (strlen($tete)) {
1394
-			array_unshift($path_base, $tete);
1395
-		}
1396
-	}
1397
-	$path_full = $path_base;
1398
-	// Et le(s) dossier(s) des squelettes nommes
1399
-	if (strlen($GLOBALS['dossier_squelettes'])) {
1400
-		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1401
-			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1402
-		}
1403
-	}
1404
-
1405
-	$GLOBALS['path_sig'] = md5(serialize($path_full));
1406
-
1407
-	return $path_full;
1345
+    static $path_base = null;
1346
+    static $path_full = null;
1347
+    if ($path_base == null) {
1348
+        // Chemin standard depuis l'espace public
1349
+        $path = defined('_SPIP_PATH') ? _SPIP_PATH :
1350
+            _DIR_RACINE . ':' .
1351
+            _DIR_RACINE . 'squelettes-dist/:' .
1352
+            _DIR_RACINE . 'prive/:' .
1353
+            _DIR_RESTREINT;
1354
+        // Ajouter squelettes/
1355
+        if (@is_dir(_DIR_RACINE . 'squelettes')) {
1356
+            $path = _DIR_RACINE . 'squelettes/:' . $path;
1357
+        }
1358
+        foreach (explode(':', $path) as $dir) {
1359
+            if (strlen($dir) and substr($dir, -1) != '/') {
1360
+                $dir .= '/';
1361
+            }
1362
+            $path_base[] = $dir;
1363
+        }
1364
+        $path_full = $path_base;
1365
+        // Et le(s) dossier(s) des squelettes nommes
1366
+        if (strlen($GLOBALS['dossier_squelettes'])) {
1367
+            foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1368
+                array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1369
+            }
1370
+        }
1371
+        $GLOBALS['path_sig'] = md5(serialize($path_full));
1372
+    }
1373
+    if ($dir_path === null) {
1374
+        return $path_full;
1375
+    }
1376
+
1377
+    if (is_array($dir_path) or strlen($dir_path)) {
1378
+        $tete = '';
1379
+        if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1380
+            $tete = array_shift($path_base);
1381
+        }
1382
+        $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
1383
+        $dirs = array_reverse($dirs);
1384
+        foreach ($dirs as $dir_path) {
1385
+            if (substr($dir_path, -1) != '/') {
1386
+                $dir_path .= '/';
1387
+            }
1388
+            if (!in_array($dir_path, $path_base)) {
1389
+                array_unshift($path_base, $dir_path);
1390
+            }
1391
+        }
1392
+        if (strlen($tete)) {
1393
+            array_unshift($path_base, $tete);
1394
+        }
1395
+    }
1396
+    $path_full = $path_base;
1397
+    // Et le(s) dossier(s) des squelettes nommes
1398
+    if (strlen($GLOBALS['dossier_squelettes'])) {
1399
+        foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1400
+            array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1401
+        }
1402
+    }
1403
+
1404
+    $GLOBALS['path_sig'] = md5(serialize($path_full));
1405
+
1406
+    return $path_full;
1408 1407
 }
1409 1408
 
1410 1409
 /**
@@ -1417,78 +1416,78 @@  discard block
 block discarded – undo
1417 1416
  * @return array Liste de chemins
1418 1417
  **/
1419 1418
 function creer_chemin() {
1420
-	$path_a = _chemin();
1421
-	static $c = '';
1419
+    $path_a = _chemin();
1420
+    static $c = '';
1422 1421
 
1423
-	// on calcule le chemin si le dossier skel a change
1424
-	if ($c != $GLOBALS['dossier_squelettes']) {
1425
-		// assurer le non plantage lors de la montee de version :
1426
-		$c = $GLOBALS['dossier_squelettes'];
1427
-		$path_a = _chemin(''); // forcer un recalcul du chemin
1428
-	}
1422
+    // on calcule le chemin si le dossier skel a change
1423
+    if ($c != $GLOBALS['dossier_squelettes']) {
1424
+        // assurer le non plantage lors de la montee de version :
1425
+        $c = $GLOBALS['dossier_squelettes'];
1426
+        $path_a = _chemin(''); // forcer un recalcul du chemin
1427
+    }
1429 1428
 
1430
-	return $path_a;
1429
+    return $path_a;
1431 1430
 }
1432 1431
 
1433 1432
 
1434 1433
 function lister_themes_prives() {
1435
-	static $themes = null;
1436
-	if (is_null($themes)) {
1437
-		// si pas encore definie
1438
-		if (!defined('_SPIP_THEME_PRIVE')) {
1439
-			define('_SPIP_THEME_PRIVE', 'spip');
1440
-		}
1441
-		$themes = [_SPIP_THEME_PRIVE];
1442
-		// lors d'une installation neuve, prefs n'est pas definie.
1443
-		if (isset($GLOBALS['visiteur_session']['prefs'])) {
1444
-			$prefs = $GLOBALS['visiteur_session']['prefs'];
1445
-		} else {
1446
-			$prefs = [];
1447
-		}
1448
-		if (is_string($prefs)) {
1449
-			$prefs = unserialize($GLOBALS['visiteur_session']['prefs']);
1450
-		}
1451
-		if (
1452
-			((isset($prefs['theme']) and $theme = $prefs['theme'])
1453
-				or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut']))
1454
-			and $theme != _SPIP_THEME_PRIVE
1455
-		) {
1456
-			array_unshift($themes, $theme);
1457
-		} // placer le theme choisi en tete
1458
-	}
1459
-
1460
-	return $themes;
1434
+    static $themes = null;
1435
+    if (is_null($themes)) {
1436
+        // si pas encore definie
1437
+        if (!defined('_SPIP_THEME_PRIVE')) {
1438
+            define('_SPIP_THEME_PRIVE', 'spip');
1439
+        }
1440
+        $themes = [_SPIP_THEME_PRIVE];
1441
+        // lors d'une installation neuve, prefs n'est pas definie.
1442
+        if (isset($GLOBALS['visiteur_session']['prefs'])) {
1443
+            $prefs = $GLOBALS['visiteur_session']['prefs'];
1444
+        } else {
1445
+            $prefs = [];
1446
+        }
1447
+        if (is_string($prefs)) {
1448
+            $prefs = unserialize($GLOBALS['visiteur_session']['prefs']);
1449
+        }
1450
+        if (
1451
+            ((isset($prefs['theme']) and $theme = $prefs['theme'])
1452
+                or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut']))
1453
+            and $theme != _SPIP_THEME_PRIVE
1454
+        ) {
1455
+            array_unshift($themes, $theme);
1456
+        } // placer le theme choisi en tete
1457
+    }
1458
+
1459
+    return $themes;
1461 1460
 }
1462 1461
 
1463 1462
 function find_in_theme($file, $subdir = '', $include = false) {
1464
-	static $themefiles = [];
1465
-	if (isset($themefiles["$subdir$file"])) {
1466
-		return $themefiles["$subdir$file"];
1467
-	}
1468
-	// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1469
-	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1470
-	if (
1471
-		preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1472
-		and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg'
1473
-		and $f = find_in_theme("$file_svg_generique")
1474
-	) {
1475
-		if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) {
1476
-			return $themefiles["$subdir$file"] = $fsize;
1477
-		}
1478
-		else {
1479
-			return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
1480
-		}
1481
-	}
1482
-
1483
-	$themes = lister_themes_prives();
1484
-	foreach ($themes as $theme) {
1485
-		if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) {
1486
-			return $themefiles["$subdir$file"] = $f;
1487
-		}
1488
-	}
1489
-	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1490
-
1491
-	return $themefiles["$subdir$file"] = '';
1463
+    static $themefiles = [];
1464
+    if (isset($themefiles["$subdir$file"])) {
1465
+        return $themefiles["$subdir$file"];
1466
+    }
1467
+    // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1468
+    // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1469
+    if (
1470
+        preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1471
+        and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg'
1472
+        and $f = find_in_theme("$file_svg_generique")
1473
+    ) {
1474
+        if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) {
1475
+            return $themefiles["$subdir$file"] = $fsize;
1476
+        }
1477
+        else {
1478
+            return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
1479
+        }
1480
+    }
1481
+
1482
+    $themes = lister_themes_prives();
1483
+    foreach ($themes as $theme) {
1484
+        if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) {
1485
+            return $themefiles["$subdir$file"] = $f;
1486
+        }
1487
+    }
1488
+    spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1489
+
1490
+    return $themefiles["$subdir$file"] = '';
1492 1491
 }
1493 1492
 
1494 1493
 
@@ -1512,31 +1511,31 @@  discard block
 block discarded – undo
1512 1511
  *     sinon chaîne vide.
1513 1512
  **/
1514 1513
 function chemin_image($icone) {
1515
-	static $icone_renommer;
1516
-	if ($p = strpos($icone, '?')) {
1517
-		$icone = substr($icone, 0, $p);
1518
-	}
1519
-	// gerer le cas d'un double appel en evitant de refaire le travail inutilement
1520
-	if (strpos($icone, '/') !== false and file_exists($icone)) {
1521
-		return $icone;
1522
-	}
1523
-
1524
-	// si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
1525
-	if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) {
1526
-		return $f;
1527
-	}
1528
-	// sinon passer par le module de renommage
1529
-	if (is_null($icone_renommer)) {
1530
-		$icone_renommer = charger_fonction('icone_renommer', 'inc', true);
1531
-	}
1532
-	if ($icone_renommer) {
1533
-		[$icone, $fonction] = $icone_renommer($icone, '');
1534
-		if (file_exists($icone)) {
1535
-			return $icone;
1536
-		}
1537
-	}
1538
-
1539
-	return find_in_path($icone, _NOM_IMG_PACK);
1514
+    static $icone_renommer;
1515
+    if ($p = strpos($icone, '?')) {
1516
+        $icone = substr($icone, 0, $p);
1517
+    }
1518
+    // gerer le cas d'un double appel en evitant de refaire le travail inutilement
1519
+    if (strpos($icone, '/') !== false and file_exists($icone)) {
1520
+        return $icone;
1521
+    }
1522
+
1523
+    // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
1524
+    if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) {
1525
+        return $f;
1526
+    }
1527
+    // sinon passer par le module de renommage
1528
+    if (is_null($icone_renommer)) {
1529
+        $icone_renommer = charger_fonction('icone_renommer', 'inc', true);
1530
+    }
1531
+    if ($icone_renommer) {
1532
+        [$icone, $fonction] = $icone_renommer($icone, '');
1533
+        if (file_exists($icone)) {
1534
+            return $icone;
1535
+        }
1536
+    }
1537
+
1538
+    return find_in_path($icone, _NOM_IMG_PACK);
1540 1539
 }
1541 1540
 
1542 1541
 //
@@ -1574,128 +1573,128 @@  discard block
 block discarded – undo
1574 1573
  *     - false : fichier introuvable
1575 1574
  **/
1576 1575
 function find_in_path($file, $dirname = '', $include = false) {
1577
-	static $dirs = [];
1578
-	static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec
1579
-	static $c = '';
1580
-
1581
-	if (!$file and !strlen($file)) {
1582
-		return false;
1583
-	}
1584
-
1585
-	// on calcule le chemin si le dossier skel a change
1586
-	if ($c != $GLOBALS['dossier_squelettes']) {
1587
-		// assurer le non plantage lors de la montee de version :
1588
-		$c = $GLOBALS['dossier_squelettes'];
1589
-		creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
1590
-	}
1591
-
1592
-	if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) {
1593
-		if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) {
1594
-			return false;
1595
-		}
1596
-		if ($include and !isset($inc[$dirname][$file])) {
1597
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1598
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1599
-		}
1600
-
1601
-		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1602
-	}
1603
-
1604
-	$a = strrpos($file, '/');
1605
-	if ($a !== false) {
1606
-		$dirname .= substr($file, 0, ++$a);
1607
-		$file = substr($file, $a);
1608
-	}
1609
-
1610
-	foreach (creer_chemin() as $dir) {
1611
-		if (!isset($dirs[$a = $dir . $dirname])) {
1612
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1613
-		}
1614
-		if ($dirs[$a]) {
1615
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
1616
-				if ($include and !isset($inc[$dirname][$file])) {
1617
-					include_once _ROOT_CWD . $a;
1618
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1619
-				}
1620
-				if (!defined('_SAUVER_CHEMIN')) {
1621
-					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1622
-					if (is_null($GLOBALS['path_files'])) {
1623
-						return $a;
1624
-					}
1625
-					define('_SAUVER_CHEMIN', true);
1626
-				}
1627
-
1628
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1629
-			}
1630
-		}
1631
-	}
1632
-
1633
-	if ($include) {
1634
-		spip_log("include_spip $dirname$file non trouve");
1635
-		if ($include === 'required') {
1636
-			echo '<pre>',
1637
-			'<strong>Erreur Fatale</strong><br />';
1638
-			if (function_exists('debug_print_backtrace')) {
1639
-				echo debug_print_backtrace();
1640
-			}
1641
-			echo '</pre>';
1642
-			die("Erreur interne: ne peut inclure $dirname$file");
1643
-		}
1644
-	}
1645
-
1646
-	if (!defined('_SAUVER_CHEMIN')) {
1647
-		// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1648
-		if (is_null($GLOBALS['path_files'])) {
1649
-			return false;
1650
-		}
1651
-		define('_SAUVER_CHEMIN', true);
1652
-	}
1653
-
1654
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1576
+    static $dirs = [];
1577
+    static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec
1578
+    static $c = '';
1579
+
1580
+    if (!$file and !strlen($file)) {
1581
+        return false;
1582
+    }
1583
+
1584
+    // on calcule le chemin si le dossier skel a change
1585
+    if ($c != $GLOBALS['dossier_squelettes']) {
1586
+        // assurer le non plantage lors de la montee de version :
1587
+        $c = $GLOBALS['dossier_squelettes'];
1588
+        creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
1589
+    }
1590
+
1591
+    if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) {
1592
+        if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) {
1593
+            return false;
1594
+        }
1595
+        if ($include and !isset($inc[$dirname][$file])) {
1596
+            include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1597
+            $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1598
+        }
1599
+
1600
+        return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1601
+    }
1602
+
1603
+    $a = strrpos($file, '/');
1604
+    if ($a !== false) {
1605
+        $dirname .= substr($file, 0, ++$a);
1606
+        $file = substr($file, $a);
1607
+    }
1608
+
1609
+    foreach (creer_chemin() as $dir) {
1610
+        if (!isset($dirs[$a = $dir . $dirname])) {
1611
+            $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1612
+        }
1613
+        if ($dirs[$a]) {
1614
+            if (file_exists(_ROOT_CWD . ($a .= $file))) {
1615
+                if ($include and !isset($inc[$dirname][$file])) {
1616
+                    include_once _ROOT_CWD . $a;
1617
+                    $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1618
+                }
1619
+                if (!defined('_SAUVER_CHEMIN')) {
1620
+                    // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1621
+                    if (is_null($GLOBALS['path_files'])) {
1622
+                        return $a;
1623
+                    }
1624
+                    define('_SAUVER_CHEMIN', true);
1625
+                }
1626
+
1627
+                return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1628
+            }
1629
+        }
1630
+    }
1631
+
1632
+    if ($include) {
1633
+        spip_log("include_spip $dirname$file non trouve");
1634
+        if ($include === 'required') {
1635
+            echo '<pre>',
1636
+            '<strong>Erreur Fatale</strong><br />';
1637
+            if (function_exists('debug_print_backtrace')) {
1638
+                echo debug_print_backtrace();
1639
+            }
1640
+            echo '</pre>';
1641
+            die("Erreur interne: ne peut inclure $dirname$file");
1642
+        }
1643
+    }
1644
+
1645
+    if (!defined('_SAUVER_CHEMIN')) {
1646
+        // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1647
+        if (is_null($GLOBALS['path_files'])) {
1648
+            return false;
1649
+        }
1650
+        define('_SAUVER_CHEMIN', true);
1651
+    }
1652
+
1653
+    return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1655 1654
 }
1656 1655
 
1657 1656
 function clear_path_cache() {
1658
-	$GLOBALS['path_files'] = [];
1659
-	spip_unlink(_CACHE_CHEMIN);
1657
+    $GLOBALS['path_files'] = [];
1658
+    spip_unlink(_CACHE_CHEMIN);
1660 1659
 }
1661 1660
 
1662 1661
 function load_path_cache() {
1663
-	// charger le path des plugins
1664
-	if (@is_readable(_CACHE_PLUGINS_PATH)) {
1665
-		include_once(_CACHE_PLUGINS_PATH);
1666
-	}
1667
-	$GLOBALS['path_files'] = [];
1668
-	// si le visiteur est admin,
1669
-	// on ne recharge pas le cache pour forcer sa mise a jour
1670
-	if (
1671
-		// la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier
1672
-		//AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')
1673
-		// utiliser le cookie est un pis aller qui marche 'en general'
1674
-		// on blinde par un second test au moment de la lecture de la session
1675
-		// !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
1676
-		// et en ignorant ce cache en cas de recalcul explicite
1677
-		!_request('var_mode')
1678
-	) {
1679
-		// on essaye de lire directement sans verrou pour aller plus vite
1680
-		if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
1681
-			// mais si semble corrompu on relit avec un verrou
1682
-			if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1683
-				lire_fichier(_CACHE_CHEMIN, $contenu);
1684
-				if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1685
-					$GLOBALS['path_files'] = [];
1686
-				}
1687
-			}
1688
-		}
1689
-	}
1662
+    // charger le path des plugins
1663
+    if (@is_readable(_CACHE_PLUGINS_PATH)) {
1664
+        include_once(_CACHE_PLUGINS_PATH);
1665
+    }
1666
+    $GLOBALS['path_files'] = [];
1667
+    // si le visiteur est admin,
1668
+    // on ne recharge pas le cache pour forcer sa mise a jour
1669
+    if (
1670
+        // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier
1671
+        //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')
1672
+        // utiliser le cookie est un pis aller qui marche 'en general'
1673
+        // on blinde par un second test au moment de la lecture de la session
1674
+        // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
1675
+        // et en ignorant ce cache en cas de recalcul explicite
1676
+        !_request('var_mode')
1677
+    ) {
1678
+        // on essaye de lire directement sans verrou pour aller plus vite
1679
+        if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
1680
+            // mais si semble corrompu on relit avec un verrou
1681
+            if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1682
+                lire_fichier(_CACHE_CHEMIN, $contenu);
1683
+                if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1684
+                    $GLOBALS['path_files'] = [];
1685
+                }
1686
+            }
1687
+        }
1688
+    }
1690 1689
 }
1691 1690
 
1692 1691
 function save_path_cache() {
1693
-	if (
1694
-		defined('_SAUVER_CHEMIN')
1695
-		and _SAUVER_CHEMIN
1696
-	) {
1697
-		ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
1698
-	}
1692
+    if (
1693
+        defined('_SAUVER_CHEMIN')
1694
+        and _SAUVER_CHEMIN
1695
+    ) {
1696
+        ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
1697
+    }
1699 1698
 }
1700 1699
 
1701 1700
 
@@ -1715,33 +1714,33 @@  discard block
 block discarded – undo
1715 1714
  * @return array
1716 1715
  */
1717 1716
 function find_all_in_path($dir, $pattern, $recurs = false) {
1718
-	$liste_fichiers = [];
1719
-	$maxfiles = 10000;
1720
-
1721
-	// cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1722
-	// on a pas encore inclus flock.php
1723
-	if (!function_exists('preg_files')) {
1724
-		include_once _ROOT_RESTREINT . 'inc/flock.php';
1725
-	}
1726
-
1727
-	// Parcourir le chemin
1728
-	foreach (creer_chemin() as $d) {
1729
-		$f = $d . $dir;
1730
-		if (@is_dir($f)) {
1731
-			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
1732
-			foreach ($liste as $chemin) {
1733
-				$nom = basename($chemin);
1734
-				// ne prendre que les fichiers pas deja trouves
1735
-				// car find_in_path prend le premier qu'il trouve,
1736
-				// les autres sont donc masques
1737
-				if (!isset($liste_fichiers[$nom])) {
1738
-					$liste_fichiers[$nom] = $chemin;
1739
-				}
1740
-			}
1741
-		}
1742
-	}
1743
-
1744
-	return $liste_fichiers;
1717
+    $liste_fichiers = [];
1718
+    $maxfiles = 10000;
1719
+
1720
+    // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1721
+    // on a pas encore inclus flock.php
1722
+    if (!function_exists('preg_files')) {
1723
+        include_once _ROOT_RESTREINT . 'inc/flock.php';
1724
+    }
1725
+
1726
+    // Parcourir le chemin
1727
+    foreach (creer_chemin() as $d) {
1728
+        $f = $d . $dir;
1729
+        if (@is_dir($f)) {
1730
+            $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
1731
+            foreach ($liste as $chemin) {
1732
+                $nom = basename($chemin);
1733
+                // ne prendre que les fichiers pas deja trouves
1734
+                // car find_in_path prend le premier qu'il trouve,
1735
+                // les autres sont donc masques
1736
+                if (!isset($liste_fichiers[$nom])) {
1737
+                    $liste_fichiers[$nom] = $chemin;
1738
+                }
1739
+            }
1740
+        }
1741
+    }
1742
+
1743
+    return $liste_fichiers;
1745 1744
 }
1746 1745
 
1747 1746
 /**
@@ -1753,17 +1752,17 @@  discard block
 block discarded – undo
1753 1752
  * @return bool
1754 1753
  */
1755 1754
 function autoriser_sans_cookie($nom, $strict = false) {
1756
-	static $autsanscookie = ['install', 'base_repair'];
1755
+    static $autsanscookie = ['install', 'base_repair'];
1757 1756
 
1758
-	if (in_array($nom, $autsanscookie)) {
1759
-		if (test_espace_prive()) {
1760
-			include_spip('base/connect_sql');
1761
-			if (!$strict or !spip_connect()) {
1762
-				return true;
1763
-			}
1764
-		}
1765
-	}
1766
-	return false;
1757
+    if (in_array($nom, $autsanscookie)) {
1758
+        if (test_espace_prive()) {
1759
+            include_spip('base/connect_sql');
1760
+            if (!$strict or !spip_connect()) {
1761
+                return true;
1762
+            }
1763
+        }
1764
+    }
1765
+    return false;
1767 1766
 }
1768 1767
 
1769 1768
 /**
@@ -1789,96 +1788,96 @@  discard block
 block discarded – undo
1789 1788
  *           (cas des raccourcis personalises [->spip20] : il faut implementer une fonction generer_url_spip et une fonction generer_url_ecrire_spip)
1790 1789
  */
1791 1790
 function generer_url_entite($id = '', $entite = '', $args = '', $ancre = '', $public = null, $type = null) {
1792
-	if ($public === null) {
1793
-		$public = !test_espace_prive();
1794
-	}
1795
-	$entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
1796
-
1797
-	if (!$public) {
1798
-		if (!$entite) {
1799
-			return '';
1800
-		}
1801
-		if (!function_exists('generer_url_ecrire_objet')) {
1802
-			include_spip('inc/urls');
1803
-		}
1804
-		$res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false);
1805
-	} else {
1806
-		if ($type === null) {
1807
-			$type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut
1808
-		}
1809
-
1810
-		$f = charger_fonction($type, 'urls', true);
1811
-		// se rabattre sur les urls page si les urls perso non dispo
1812
-		if (!$f) {
1813
-			$f = charger_fonction('page', 'urls', true);
1814
-		}
1815
-
1816
-		// si $entite='', on veut la fonction de passage URL ==> id
1817
-		// sinon on veut effectuer le passage id ==> URL
1818
-		if (!$entite) {
1819
-			return $f;
1820
-		}
1821
-
1822
-		// mais d'abord il faut tester le cas des urls sur une
1823
-		// base distante
1824
-		if (
1825
-			is_string($public)
1826
-			and $g = charger_fonction('connect', 'urls', true)
1827
-		) {
1828
-			$f = $g;
1829
-		}
1830
-
1831
-		$res = $f(intval($id), $entite, $args, $ancre, $public);
1832
-	}
1833
-	if ($res) {
1834
-		return $res;
1835
-	}
1836
-	// Sinon c'est un raccourci ou compat SPIP < 2
1837
-	if (!function_exists($f = 'generer_url_' . $entite)) {
1838
-		if (!function_exists($f .= '_dist')) {
1839
-			$f = '';
1840
-		}
1841
-	}
1842
-	if ($f) {
1843
-		$url = $f($id, $args, $ancre);
1844
-		if (strlen($args)) {
1845
-			$url .= strstr($url, '?')
1846
-				? '&amp;' . $args
1847
-				: '?' . $args;
1848
-		}
1849
-
1850
-		return $url;
1851
-	}
1852
-	// On a ete gentil mais la ....
1853
-	spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public");
1854
-
1855
-	return '';
1791
+    if ($public === null) {
1792
+        $public = !test_espace_prive();
1793
+    }
1794
+    $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
1795
+
1796
+    if (!$public) {
1797
+        if (!$entite) {
1798
+            return '';
1799
+        }
1800
+        if (!function_exists('generer_url_ecrire_objet')) {
1801
+            include_spip('inc/urls');
1802
+        }
1803
+        $res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false);
1804
+    } else {
1805
+        if ($type === null) {
1806
+            $type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut
1807
+        }
1808
+
1809
+        $f = charger_fonction($type, 'urls', true);
1810
+        // se rabattre sur les urls page si les urls perso non dispo
1811
+        if (!$f) {
1812
+            $f = charger_fonction('page', 'urls', true);
1813
+        }
1814
+
1815
+        // si $entite='', on veut la fonction de passage URL ==> id
1816
+        // sinon on veut effectuer le passage id ==> URL
1817
+        if (!$entite) {
1818
+            return $f;
1819
+        }
1820
+
1821
+        // mais d'abord il faut tester le cas des urls sur une
1822
+        // base distante
1823
+        if (
1824
+            is_string($public)
1825
+            and $g = charger_fonction('connect', 'urls', true)
1826
+        ) {
1827
+            $f = $g;
1828
+        }
1829
+
1830
+        $res = $f(intval($id), $entite, $args, $ancre, $public);
1831
+    }
1832
+    if ($res) {
1833
+        return $res;
1834
+    }
1835
+    // Sinon c'est un raccourci ou compat SPIP < 2
1836
+    if (!function_exists($f = 'generer_url_' . $entite)) {
1837
+        if (!function_exists($f .= '_dist')) {
1838
+            $f = '';
1839
+        }
1840
+    }
1841
+    if ($f) {
1842
+        $url = $f($id, $args, $ancre);
1843
+        if (strlen($args)) {
1844
+            $url .= strstr($url, '?')
1845
+                ? '&amp;' . $args
1846
+                : '?' . $args;
1847
+        }
1848
+
1849
+        return $url;
1850
+    }
1851
+    // On a ete gentil mais la ....
1852
+    spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public");
1853
+
1854
+    return '';
1856 1855
 }
1857 1856
 
1858 1857
 function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') {
1859
-	$exec = objet_info($entite, 'url_edit');
1860
-	$url = generer_url_ecrire($exec, $args);
1861
-	if (intval($id)) {
1862
-		$url = parametre_url($url, id_table_objet($entite), $id);
1863
-	} else {
1864
-		$url = parametre_url($url, 'new', 'oui');
1865
-	}
1866
-	if ($ancre) {
1867
-		$url = ancre_url($url, $ancre);
1868
-	}
1858
+    $exec = objet_info($entite, 'url_edit');
1859
+    $url = generer_url_ecrire($exec, $args);
1860
+    if (intval($id)) {
1861
+        $url = parametre_url($url, id_table_objet($entite), $id);
1862
+    } else {
1863
+        $url = parametre_url($url, 'new', 'oui');
1864
+    }
1865
+    if ($ancre) {
1866
+        $url = ancre_url($url, $ancre);
1867
+    }
1869 1868
 
1870
-	return $url;
1869
+    return $url;
1871 1870
 }
1872 1871
 
1873 1872
 // https://code.spip.net/@urls_connect_dist
1874 1873
 function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) {
1875
-	include_spip('base/connect_sql');
1876
-	$id_type = id_table_objet($entite, $public);
1874
+    include_spip('base/connect_sql');
1875
+    $id_type = id_table_objet($entite, $public);
1877 1876
 
1878
-	return _DIR_RACINE . get_spip_script('./')
1879
-	. '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1880
-	. (!$args ? '' : "&$args")
1881
-	. (!$ancre ? '' : "#$ancre");
1877
+    return _DIR_RACINE . get_spip_script('./')
1878
+    . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1879
+    . (!$args ? '' : "&$args")
1880
+    . (!$ancre ? '' : "#$ancre");
1882 1881
 }
1883 1882
 
1884 1883
 
@@ -1889,32 +1888,32 @@  discard block
 block discarded – undo
1889 1888
  * @return string
1890 1889
  */
1891 1890
 function urlencode_1738($url) {
1892
-	if (preg_match(',[^\x00-\x7E],sS', $url)) {
1893
-		$uri = '';
1894
-		for ($i = 0; $i < strlen($url); $i++) {
1895
-			if (ord($a = $url[$i]) > 127) {
1896
-				$a = rawurlencode($a);
1897
-			}
1898
-			$uri .= $a;
1899
-		}
1900
-		$url = $uri;
1901
-	}
1891
+    if (preg_match(',[^\x00-\x7E],sS', $url)) {
1892
+        $uri = '';
1893
+        for ($i = 0; $i < strlen($url); $i++) {
1894
+            if (ord($a = $url[$i]) > 127) {
1895
+                $a = rawurlencode($a);
1896
+            }
1897
+            $uri .= $a;
1898
+        }
1899
+        $url = $uri;
1900
+    }
1902 1901
 
1903
-	return quote_amp($url);
1902
+    return quote_amp($url);
1904 1903
 }
1905 1904
 
1906 1905
 // https://code.spip.net/@generer_url_entite_absolue
1907 1906
 function generer_url_entite_absolue($id = '', $entite = '', $args = '', $ancre = '', $connect = null) {
1908
-	if (!$connect) {
1909
-		$connect = true;
1910
-	}
1911
-	$h = generer_url_entite($id, $entite, $args, $ancre, $connect);
1912
-	if (!preg_match(',^\w+:,', $h)) {
1913
-		include_spip('inc/filtres_mini');
1914
-		$h = url_absolue($h);
1915
-	}
1907
+    if (!$connect) {
1908
+        $connect = true;
1909
+    }
1910
+    $h = generer_url_entite($id, $entite, $args, $ancre, $connect);
1911
+    if (!preg_match(',^\w+:,', $h)) {
1912
+        include_spip('inc/filtres_mini');
1913
+        $h = url_absolue($h);
1914
+    }
1916 1915
 
1917
-	return $h;
1916
+    return $h;
1918 1917
 }
1919 1918
 
1920 1919
 
@@ -1930,11 +1929,11 @@  discard block
 block discarded – undo
1930 1929
  *     true si la valeur est considérée active ; false sinon.
1931 1930
  **/
1932 1931
 function test_valeur_serveur($truc) {
1933
-	if (!$truc) {
1934
-		return false;
1935
-	}
1932
+    if (!$truc) {
1933
+        return false;
1934
+    }
1936 1935
 
1937
-	return (strtolower($truc) !== 'off');
1936
+    return (strtolower($truc) !== 'off');
1938 1937
 }
1939 1938
 
1940 1939
 //
@@ -1962,82 +1961,82 @@  discard block
 block discarded – undo
1962 1961
  */
1963 1962
 function url_de_base($profondeur = null) {
1964 1963
 
1965
-	static $url = [];
1966
-	if (is_array($profondeur)) {
1967
-		return $url = $profondeur;
1968
-	}
1969
-	if ($profondeur === false) {
1970
-		return $url;
1971
-	}
1972
-
1973
-	if (is_null($profondeur)) {
1974
-		$profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1);
1975
-	}
1976
-
1977
-	if (isset($url[$profondeur])) {
1978
-		return $url[$profondeur];
1979
-	}
1980
-
1981
-	$http = 'http';
1982
-
1983
-	if (
1984
-		isset($_SERVER['SCRIPT_URI'])
1985
-		and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https'
1986
-	) {
1987
-		$http = 'https';
1988
-	} elseif (
1989
-		isset($_SERVER['HTTPS'])
1990
-		and test_valeur_serveur($_SERVER['HTTPS'])
1991
-	) {
1992
-		$http = 'https';
1993
-	}
1994
-
1995
-	// note : HTTP_HOST contient le :port si necessaire
1996
-	$host = $_SERVER['HTTP_HOST'] ?? null;
1997
-	// si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback
1998
-	if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) {
1999
-		$host = $GLOBALS['meta']['adresse_site'];
2000
-		if ($scheme = parse_url($host, PHP_URL_SCHEME)) {
2001
-			$http = $scheme;
2002
-			$host = str_replace("{$scheme}://", '', $host);
2003
-		}
2004
-	}
2005
-	if (
2006
-		isset($_SERVER['SERVER_PORT'])
2007
-		and $port = $_SERVER['SERVER_PORT']
2008
-		and strpos($host, ':') == false
2009
-	) {
2010
-		if (!defined('_PORT_HTTP_STANDARD')) {
2011
-			define('_PORT_HTTP_STANDARD', '80');
2012
-		}
2013
-		if (!defined('_PORT_HTTPS_STANDARD')) {
2014
-			define('_PORT_HTTPS_STANDARD', '443');
2015
-		}
2016
-		if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) {
2017
-			$host .= ":$port";
2018
-		}
2019
-		if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) {
2020
-			$host .= ":$port";
2021
-		}
2022
-	}
2023
-
2024
-	if (!$GLOBALS['REQUEST_URI']) {
2025
-		if (isset($_SERVER['REQUEST_URI'])) {
2026
-			$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2027
-		} else {
2028
-			$GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2029
-			if (
2030
-				!empty($_SERVER['QUERY_STRING'])
2031
-				and !strpos($_SERVER['REQUEST_URI'], '?')
2032
-			) {
2033
-				$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2034
-			}
2035
-		}
2036
-	}
2037
-
2038
-	$url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
2039
-
2040
-	return $url[$profondeur];
1964
+    static $url = [];
1965
+    if (is_array($profondeur)) {
1966
+        return $url = $profondeur;
1967
+    }
1968
+    if ($profondeur === false) {
1969
+        return $url;
1970
+    }
1971
+
1972
+    if (is_null($profondeur)) {
1973
+        $profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1);
1974
+    }
1975
+
1976
+    if (isset($url[$profondeur])) {
1977
+        return $url[$profondeur];
1978
+    }
1979
+
1980
+    $http = 'http';
1981
+
1982
+    if (
1983
+        isset($_SERVER['SCRIPT_URI'])
1984
+        and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https'
1985
+    ) {
1986
+        $http = 'https';
1987
+    } elseif (
1988
+        isset($_SERVER['HTTPS'])
1989
+        and test_valeur_serveur($_SERVER['HTTPS'])
1990
+    ) {
1991
+        $http = 'https';
1992
+    }
1993
+
1994
+    // note : HTTP_HOST contient le :port si necessaire
1995
+    $host = $_SERVER['HTTP_HOST'] ?? null;
1996
+    // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback
1997
+    if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) {
1998
+        $host = $GLOBALS['meta']['adresse_site'];
1999
+        if ($scheme = parse_url($host, PHP_URL_SCHEME)) {
2000
+            $http = $scheme;
2001
+            $host = str_replace("{$scheme}://", '', $host);
2002
+        }
2003
+    }
2004
+    if (
2005
+        isset($_SERVER['SERVER_PORT'])
2006
+        and $port = $_SERVER['SERVER_PORT']
2007
+        and strpos($host, ':') == false
2008
+    ) {
2009
+        if (!defined('_PORT_HTTP_STANDARD')) {
2010
+            define('_PORT_HTTP_STANDARD', '80');
2011
+        }
2012
+        if (!defined('_PORT_HTTPS_STANDARD')) {
2013
+            define('_PORT_HTTPS_STANDARD', '443');
2014
+        }
2015
+        if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) {
2016
+            $host .= ":$port";
2017
+        }
2018
+        if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) {
2019
+            $host .= ":$port";
2020
+        }
2021
+    }
2022
+
2023
+    if (!$GLOBALS['REQUEST_URI']) {
2024
+        if (isset($_SERVER['REQUEST_URI'])) {
2025
+            $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2026
+        } else {
2027
+            $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2028
+            if (
2029
+                !empty($_SERVER['QUERY_STRING'])
2030
+                and !strpos($_SERVER['REQUEST_URI'], '?')
2031
+            ) {
2032
+                $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2033
+            }
2034
+        }
2035
+    }
2036
+
2037
+    $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
2038
+
2039
+    return $url[$profondeur];
2041 2040
 }
2042 2041
 
2043 2042
 /**
@@ -2050,26 +2049,26 @@  discard block
 block discarded – undo
2050 2049
  * @return string
2051 2050
  */
2052 2051
 function url_de_($http, $host, $request, $prof = 0) {
2053
-	$prof = max($prof, 0);
2052
+    $prof = max($prof, 0);
2054 2053
 
2055
-	$myself = ltrim($request, '/');
2056
-	# supprimer la chaine de GET
2057
-	[$myself] = explode('?', $myself);
2058
-	// vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
2059
-	// protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
2060
-	if (strpos($myself, '://') !== false) {
2061
-		$myself = explode('://', $myself);
2062
-		array_shift($myself);
2063
-		$myself = implode('://', $myself);
2064
-		$myself = explode('/', $myself);
2065
-		array_shift($myself);
2066
-		$myself = implode('/', $myself);
2067
-	}
2068
-	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2054
+    $myself = ltrim($request, '/');
2055
+    # supprimer la chaine de GET
2056
+    [$myself] = explode('?', $myself);
2057
+    // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
2058
+    // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
2059
+    if (strpos($myself, '://') !== false) {
2060
+        $myself = explode('://', $myself);
2061
+        array_shift($myself);
2062
+        $myself = implode('://', $myself);
2063
+        $myself = explode('/', $myself);
2064
+        array_shift($myself);
2065
+        $myself = implode('/', $myself);
2066
+    }
2067
+    $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2069 2068
 
2070
-	$url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2069
+    $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2071 2070
 
2072
-	return $url;
2071
+    return $url;
2073 2072
 }
2074 2073
 
2075 2074
 
@@ -2104,25 +2103,25 @@  discard block
 block discarded – undo
2104 2103
  * @return string URL
2105 2104
  **/
2106 2105
 function generer_url_ecrire($script = '', $args = '', $no_entities = false, $rel = false) {
2107
-	if (!$rel) {
2108
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2109
-	} else {
2110
-		if (!is_string($rel)) {
2111
-			$rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT;
2112
-		}
2113
-	}
2114
-
2115
-	[$script, $ancre] = array_pad(explode('#', $script), 2, null);
2116
-	if ($script and ($script <> 'accueil' or $rel)) {
2117
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
2118
-	} elseif ($args) {
2119
-		$args = "?$args";
2120
-	}
2121
-	if ($ancre) {
2122
-		$args .= "#$ancre";
2123
-	}
2124
-
2125
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2106
+    if (!$rel) {
2107
+        $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2108
+    } else {
2109
+        if (!is_string($rel)) {
2110
+            $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT;
2111
+        }
2112
+    }
2113
+
2114
+    [$script, $ancre] = array_pad(explode('#', $script), 2, null);
2115
+    if ($script and ($script <> 'accueil' or $rel)) {
2116
+        $args = "?exec=$script" . (!$args ? '' : "&$args");
2117
+    } elseif ($args) {
2118
+        $args = "?$args";
2119
+    }
2120
+    if ($ancre) {
2121
+        $args .= "#$ancre";
2122
+    }
2123
+
2124
+    return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2126 2125
 }
2127 2126
 
2128 2127
 //
@@ -2144,15 +2143,15 @@  discard block
 block discarded – undo
2144 2143
  *     Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut
2145 2144
  **/
2146 2145
 function get_spip_script($default = '') {
2147
-	if (!defined('_SPIP_SCRIPT')) {
2148
-		return 'spip.php';
2149
-	}
2150
-	# cas define('_SPIP_SCRIPT', '');
2151
-	if (_SPIP_SCRIPT) {
2152
-		return _SPIP_SCRIPT;
2153
-	} else {
2154
-		return $default;
2155
-	}
2146
+    if (!defined('_SPIP_SCRIPT')) {
2147
+        return 'spip.php';
2148
+    }
2149
+    # cas define('_SPIP_SCRIPT', '');
2150
+    if (_SPIP_SCRIPT) {
2151
+        return _SPIP_SCRIPT;
2152
+    } else {
2153
+        return $default;
2154
+    }
2156 2155
 }
2157 2156
 
2158 2157
 /**
@@ -2181,39 +2180,39 @@  discard block
 block discarded – undo
2181 2180
  * @return string URL
2182 2181
  **/
2183 2182
 function generer_url_public($script = '', $args = '', $no_entities = false, $rel = true, $action = '') {
2184
-	// si le script est une action (spip_pass, spip_inscription),
2185
-	// standardiser vers la nouvelle API
2186
-
2187
-	if (!$action) {
2188
-		$action = get_spip_script();
2189
-	}
2190
-	if ($script) {
2191
-		$action = parametre_url($action, _SPIP_PAGE, $script, '&');
2192
-	}
2193
-
2194
-	if ($args) {
2195
-		if (is_array($args)) {
2196
-			$r = '';
2197
-			foreach ($args as $k => $v) {
2198
-				$r .= '&' . $k . '=' . $v;
2199
-			}
2200
-			$args = substr($r, 1);
2201
-		}
2202
-		$action .=
2203
-			(strpos($action, '?') !== false ? '&' : '?') . $args;
2204
-	}
2205
-	if (!$no_entities) {
2206
-		$action = quote_amp($action);
2207
-	}
2208
-
2209
-	// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2210
-	return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
2183
+    // si le script est une action (spip_pass, spip_inscription),
2184
+    // standardiser vers la nouvelle API
2185
+
2186
+    if (!$action) {
2187
+        $action = get_spip_script();
2188
+    }
2189
+    if ($script) {
2190
+        $action = parametre_url($action, _SPIP_PAGE, $script, '&');
2191
+    }
2192
+
2193
+    if ($args) {
2194
+        if (is_array($args)) {
2195
+            $r = '';
2196
+            foreach ($args as $k => $v) {
2197
+                $r .= '&' . $k . '=' . $v;
2198
+            }
2199
+            $args = substr($r, 1);
2200
+        }
2201
+        $action .=
2202
+            (strpos($action, '?') !== false ? '&' : '?') . $args;
2203
+    }
2204
+    if (!$no_entities) {
2205
+        $action = quote_amp($action);
2206
+    }
2207
+
2208
+    // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2209
+    return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
2211 2210
 }
2212 2211
 
2213 2212
 // https://code.spip.net/@generer_url_prive
2214 2213
 function generer_url_prive($script, $args = '', $no_entities = false) {
2215 2214
 
2216
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2215
+    return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2217 2216
 }
2218 2217
 
2219 2218
 // Pour les formulaires en methode POST,
@@ -2238,19 +2237,19 @@  discard block
 block discarded – undo
2238 2237
  **/
2239 2238
 function generer_form_ecrire($script, $corps, $atts = '', $submit = '') {
2240 2239
 
2241
-	$script1 = explode('&', $script);
2242
-	$script1 = reset($script1);
2240
+    $script1 = explode('&', $script);
2241
+    $script1 = reset($script1);
2243 2242
 
2244
-	return "<form action='"
2245
-	. ($script ? generer_url_ecrire($script) : '')
2246
-	. "' "
2247
-	. ($atts ?: " method='post'")
2248
-	. "><div>\n"
2249
-	. "<input type='hidden' name='exec' value='$script1' />"
2250
-	. $corps
2251
-	. (!$submit ? '' :
2252
-		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
2253
-	. "</div></form>\n";
2243
+    return "<form action='"
2244
+    . ($script ? generer_url_ecrire($script) : '')
2245
+    . "' "
2246
+    . ($atts ?: " method='post'")
2247
+    . "><div>\n"
2248
+    . "<input type='hidden' name='exec' value='$script1' />"
2249
+    . $corps
2250
+    . (!$submit ? '' :
2251
+        ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
2252
+    . "</div></form>\n";
2254 2253
 }
2255 2254
 
2256 2255
 /**
@@ -2267,22 +2266,22 @@  discard block
 block discarded – undo
2267 2266
  * @return string
2268 2267
  */
2269 2268
 function generer_form_action($script, $corps, $atts = '', $public = false) {
2270
-	// si l'on est dans l'espace prive, on garde dans l'url
2271
-	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2272
-	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
2273
-	$h = (_DIR_RACINE and !$public)
2274
-		? generer_url_ecrire(_request('exec'))
2275
-		: generer_url_public();
2269
+    // si l'on est dans l'espace prive, on garde dans l'url
2270
+    // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2271
+    // ou non de proceder a l'authentification (cas typique de l'install par exemple)
2272
+    $h = (_DIR_RACINE and !$public)
2273
+        ? generer_url_ecrire(_request('exec'))
2274
+        : generer_url_public();
2276 2275
 
2277
-	return "\n<form action='" .
2278
-	$h .
2279
-	"'" .
2280
-	$atts .
2281
-	">\n" .
2282
-	'<div>' .
2283
-	"\n<input type='hidden' name='action' value='$script' />" .
2284
-	$corps .
2285
-	'</div></form>';
2276
+    return "\n<form action='" .
2277
+    $h .
2278
+    "'" .
2279
+    $atts .
2280
+    ">\n" .
2281
+    '<div>' .
2282
+    "\n<input type='hidden' name='action' value='$script' />" .
2283
+    $corps .
2284
+    '</div></form>';
2286 2285
 }
2287 2286
 
2288 2287
 /**
@@ -2301,22 +2300,22 @@  discard block
 block discarded – undo
2301 2300
  *     URL
2302 2301
  */
2303 2302
 function generer_url_action($script, $args = '', $no_entities = false, $public = false) {
2304
-	// si l'on est dans l'espace prive, on garde dans l'url
2305
-	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2306
-	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
2307
-	$url = (_DIR_RACINE and !$public)
2308
-		? generer_url_ecrire(_request('exec'))
2309
-		: generer_url_public('', '', false, false);
2310
-	$url = parametre_url($url, 'action', $script);
2311
-	if ($args) {
2312
-		$url .= quote_amp('&' . $args);
2313
-	}
2303
+    // si l'on est dans l'espace prive, on garde dans l'url
2304
+    // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2305
+    // ou non de proceder a l'authentification (cas typique de l'install par exemple)
2306
+    $url = (_DIR_RACINE and !$public)
2307
+        ? generer_url_ecrire(_request('exec'))
2308
+        : generer_url_public('', '', false, false);
2309
+    $url = parametre_url($url, 'action', $script);
2310
+    if ($args) {
2311
+        $url .= quote_amp('&' . $args);
2312
+    }
2314 2313
 
2315
-	if ($no_entities) {
2316
-		$url = str_replace('&amp;', '&', $url);
2317
-	}
2314
+    if ($no_entities) {
2315
+        $url = str_replace('&amp;', '&', $url);
2316
+    }
2318 2317
 
2319
-	return $url;
2318
+    return $url;
2320 2319
 }
2321 2320
 
2322 2321
 
@@ -2329,8 +2328,8 @@  discard block
 block discarded – undo
2329 2328
  * @param string $ta Répertoire temporaire accessible
2330 2329
  */
2331 2330
 function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) {
2332
-	spip_initialisation_core($pi, $pa, $ti, $ta);
2333
-	spip_initialisation_suite();
2331
+    spip_initialisation_core($pi, $pa, $ti, $ta);
2332
+    spip_initialisation_suite();
2334 2333
 }
2335 2334
 
2336 2335
 /**
@@ -2350,322 +2349,322 @@  discard block
 block discarded – undo
2350 2349
  * @param string $ta Répertoire temporaire accessible
2351 2350
  */
2352 2351
 function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) {
2353
-	static $too_late = 0;
2354
-	if ($too_late++) {
2355
-		return;
2356
-	}
2357
-
2358
-	// Declaration des repertoires
2359
-
2360
-	// le nom du repertoire plugins/ activables/desactivables
2361
-	if (!defined('_DIR_PLUGINS')) {
2362
-		define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
2363
-	}
2364
-
2365
-	// le nom du repertoire des extensions/ permanentes du core, toujours actives
2366
-	if (!defined('_DIR_PLUGINS_DIST')) {
2367
-		define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
2368
-	}
2369
-
2370
-	// le nom du repertoire des librairies
2371
-	if (!defined('_DIR_LIB')) {
2372
-		define('_DIR_LIB', _DIR_RACINE . 'lib/');
2373
-	}
2374
-
2375
-	if (!defined('_DIR_IMG')) {
2376
-		define('_DIR_IMG', $pa);
2377
-	}
2378
-	if (!defined('_DIR_LOGOS')) {
2379
-		define('_DIR_LOGOS', $pa);
2380
-	}
2381
-	if (!defined('_DIR_IMG_ICONES')) {
2382
-		define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
2383
-	}
2384
-
2385
-	if (!defined('_DIR_DUMP')) {
2386
-		define('_DIR_DUMP', $ti . 'dump/');
2387
-	}
2388
-	if (!defined('_DIR_SESSIONS')) {
2389
-		define('_DIR_SESSIONS', $ti . 'sessions/');
2390
-	}
2391
-	if (!defined('_DIR_TRANSFERT')) {
2392
-		define('_DIR_TRANSFERT', $ti . 'upload/');
2393
-	}
2394
-	if (!defined('_DIR_CACHE')) {
2395
-		define('_DIR_CACHE', $ti . 'cache/');
2396
-	}
2397
-	if (!defined('_DIR_CACHE_XML')) {
2398
-		define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
2399
-	}
2400
-	if (!defined('_DIR_SKELS')) {
2401
-		define('_DIR_SKELS', _DIR_CACHE . 'skel/');
2402
-	}
2403
-	if (!defined('_DIR_AIDE')) {
2404
-		define('_DIR_AIDE', _DIR_CACHE . 'aide/');
2405
-	}
2406
-	if (!defined('_DIR_TMP')) {
2407
-		define('_DIR_TMP', $ti);
2408
-	}
2409
-
2410
-	if (!defined('_DIR_VAR')) {
2411
-		define('_DIR_VAR', $ta);
2412
-	}
2413
-
2414
-	if (!defined('_DIR_ETC')) {
2415
-		define('_DIR_ETC', $pi);
2416
-	}
2417
-	if (!defined('_DIR_CONNECT')) {
2418
-		define('_DIR_CONNECT', $pi);
2419
-	}
2420
-	if (!defined('_DIR_CHMOD')) {
2421
-		define('_DIR_CHMOD', $pi);
2422
-	}
2423
-
2424
-	if (!isset($GLOBALS['test_dirs'])) {
2425
-		// Pas $pi car il est bon de le mettre hors ecriture apres intstall
2426
-		// il sera rajoute automatiquement si besoin a l'etape 2 de l'install
2427
-	$GLOBALS['test_dirs'] = [$pa, $ti, $ta];
2428
-	}
2429
-
2430
-	// Declaration des fichiers
2431
-
2432
-	if (!defined('_CACHE_PLUGINS_PATH')) {
2433
-		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
2434
-	}
2435
-	if (!defined('_CACHE_PLUGINS_OPT')) {
2436
-		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
2437
-	}
2438
-	if (!defined('_CACHE_PLUGINS_FCT')) {
2439
-		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
2440
-	}
2441
-	if (!defined('_CACHE_PIPELINES')) {
2442
-		define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
2443
-	}
2444
-	if (!defined('_CACHE_CHEMIN')) {
2445
-		define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
2446
-	}
2447
-
2448
-	# attention .php obligatoire pour ecrire_fichier_securise
2449
-	if (!defined('_FILE_META')) {
2450
-		define('_FILE_META', $ti . 'meta_cache.php');
2451
-	}
2452
-	if (!defined('_DIR_LOG')) {
2453
-		define('_DIR_LOG', _DIR_TMP . 'log/');
2454
-	}
2455
-	if (!defined('_FILE_LOG')) {
2456
-		define('_FILE_LOG', 'spip');
2457
-	}
2458
-	if (!defined('_FILE_LOG_SUFFIX')) {
2459
-		define('_FILE_LOG_SUFFIX', '.log');
2460
-	}
2461
-
2462
-	// Le fichier de connexion a la base de donnees
2463
-	// tient compte des anciennes versions (inc_connect...)
2464
-	if (!defined('_FILE_CONNECT_INS')) {
2465
-		define('_FILE_CONNECT_INS', 'connect');
2466
-	}
2467
-	if (!defined('_FILE_CONNECT')) {
2468
-		define(
2469
-			'_FILE_CONNECT',
2470
-			(@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2471
-			: (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2472
-			: false))
2473
-		);
2474
-	}
2475
-
2476
-	// Le fichier de reglages des droits
2477
-	if (!defined('_FILE_CHMOD_INS')) {
2478
-		define('_FILE_CHMOD_INS', 'chmod');
2479
-	}
2480
-	if (!defined('_FILE_CHMOD')) {
2481
-		define(
2482
-			'_FILE_CHMOD',
2483
-			(@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2484
-			: false)
2485
-		);
2486
-	}
2487
-
2488
-	if (!defined('_FILE_LDAP')) {
2489
-		define('_FILE_LDAP', 'ldap.php');
2490
-	}
2491
-
2492
-	if (!defined('_FILE_TMP_SUFFIX')) {
2493
-		define('_FILE_TMP_SUFFIX', '.tmp.php');
2494
-	}
2495
-	if (!defined('_FILE_CONNECT_TMP')) {
2496
-		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2497
-	}
2498
-	if (!defined('_FILE_CHMOD_TMP')) {
2499
-		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2500
-	}
2501
-
2502
-	// Definition des droits d'acces en ecriture
2503
-	if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) {
2504
-		include_once _FILE_CHMOD;
2505
-	}
2506
-
2507
-	// Se mefier des fichiers mal remplis!
2508
-	if (!defined('_SPIP_CHMOD')) {
2509
-		define('_SPIP_CHMOD', 0777);
2510
-	}
2511
-
2512
-	if (!defined('_DEFAULT_CHARSET')) {
2513
-		/** Le charset par défaut lors de l'installation */
2514
-		define('_DEFAULT_CHARSET', 'utf-8');
2515
-	}
2516
-	if (!defined('_ROOT_PLUGINS')) {
2517
-		define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/');
2518
-	}
2519
-	if (!defined('_ROOT_PLUGINS_DIST')) {
2520
-		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/');
2521
-	}
2522
-	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2523
-		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2524
-	}
2525
-
2526
-	// La taille des Log
2527
-	if (!defined('_MAX_LOG')) {
2528
-		define('_MAX_LOG', 100);
2529
-	}
2530
-
2531
-	// Sommes-nous dans l'empire du Mal ?
2532
-	// (ou sous le signe du Pingouin, ascendant GNU ?)
2533
-	if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) {
2534
-		if (!defined('_OS_SERVEUR')) {
2535
-			define('_OS_SERVEUR', 'windows');
2536
-		}
2537
-		if (!defined('_SPIP_LOCK_MODE')) {
2538
-			define('_SPIP_LOCK_MODE', 1);
2539
-		} // utiliser le flock php
2540
-	} else {
2541
-		if (!defined('_OS_SERVEUR')) {
2542
-			define('_OS_SERVEUR', '');
2543
-		}
2544
-		if (!defined('_SPIP_LOCK_MODE')) {
2545
-			define('_SPIP_LOCK_MODE', 1);
2546
-		} // utiliser le flock php
2547
-		#if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
2548
-	}
2549
-
2550
-	// Langue par defaut
2551
-	if (!defined('_LANGUE_PAR_DEFAUT')) {
2552
-		define('_LANGUE_PAR_DEFAUT', 'fr');
2553
-	}
2554
-
2555
-	//
2556
-	// Module de lecture/ecriture/suppression de fichiers utilisant flock()
2557
-	// (non surchargeable en l'etat ; attention si on utilise include_spip()
2558
-	// pour le rendre surchargeable, on va provoquer un reecriture
2559
-	// systematique du noyau ou une baisse de perfs => a etudier)
2560
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
2561
-
2562
-	// charger tout de suite le path et son cache
2563
-	load_path_cache();
2564
-
2565
-	// *********** traiter les variables ************
2566
-
2567
-	//
2568
-	// Securite
2569
-	//
2570
-
2571
-	// Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
2572
-	if (isset($_REQUEST['GLOBALS'])) {
2573
-		die();
2574
-	}
2575
-	// nettoyer les magic quotes \' et les caracteres nuls %00
2576
-	spip_desinfecte($_GET);
2577
-	spip_desinfecte($_POST);
2578
-	spip_desinfecte($_COOKIE);
2579
-	spip_desinfecte($_REQUEST);
2580
-
2581
-	// appliquer le cookie_prefix
2582
-	if ($GLOBALS['cookie_prefix'] != 'spip') {
2583
-		include_spip('inc/cookie');
2584
-		recuperer_cookies_spip($GLOBALS['cookie_prefix']);
2585
-	}
2586
-
2587
-	//
2588
-	// Capacites php (en fonction de la version)
2589
-	//
2590
-	$GLOBALS['flag_ob'] = (function_exists('ob_start')
2591
-		&& function_exists('ini_get')
2592
-		&& !strstr(@ini_get('disable_functions'), 'ob_'));
2593
-	$GLOBALS['flag_sapi_name'] = function_exists('php_sapi_name');
2594
-	$GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != '');
2595
-	$GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] ||
2596
-		(get_cfg_var('upload_max_filesize') > 0));
2597
-
2598
-
2599
-	// Compatibilite avec serveurs ne fournissant pas $REQUEST_URI
2600
-	if (isset($_SERVER['REQUEST_URI'])) {
2601
-		$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2602
-	} else {
2603
-		$GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2604
-		if (
2605
-			!empty($_SERVER['QUERY_STRING'])
2606
-			and !strpos($_SERVER['REQUEST_URI'], '?')
2607
-		) {
2608
-			$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2609
-		}
2610
-	}
2611
-
2612
-	// Duree de validite de l'alea pour les cookies et ce qui s'ensuit.
2613
-	if (!defined('_RENOUVELLE_ALEA')) {
2614
-		define('_RENOUVELLE_ALEA', 12 * 3600);
2615
-	}
2616
-	if (!defined('_DUREE_COOKIE_ADMIN')) {
2617
-		define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600);
2618
-	}
2619
-
2620
-	// charger les meta si possible et renouveller l'alea au besoin
2621
-	// charge aussi effacer_meta et ecrire_meta
2622
-	$inc_meta = charger_fonction('meta', 'inc');
2623
-	$inc_meta();
2624
-
2625
-	// nombre de repertoires depuis la racine
2626
-	// on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
2627
-	// ou a defaut celle donnee en meta ; (mais si celle-ci est fausse
2628
-	// le calcul est faux)
2629
-	if (!_DIR_RESTREINT) {
2630
-		$GLOBALS['profondeur_url'] = 1;
2631
-	} else {
2632
-		$uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : '';
2633
-		$uri_ref = $_SERVER['SCRIPT_NAME'];
2634
-		if (
2635
-			!$uri_ref
2636
-			// si on est appele avec un autre ti, on est sans doute en mutu
2637
-			// si jamais c'est de la mutu avec sous rep, on est perdu si on se fie
2638
-			// a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer
2639
-			// s'en remettre a l'adresse du site. alea jacta est.
2640
-			or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES
2641
-		) {
2642
-			if (isset($GLOBALS['meta']['adresse_site'])) {
2643
-				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2644
-				$uri_ref = ($uri_ref['path'] ?? '') . '/';
2645
-			} else {
2646
-				$uri_ref = '';
2647
-			}
2648
-		}
2649
-		if (!$uri or !$uri_ref) {
2650
-			$GLOBALS['profondeur_url'] = 0;
2651
-		} else {
2652
-			$GLOBALS['profondeur_url'] = max(
2653
-				0,
2654
-				substr_count($uri[0], '/')
2655
-				- substr_count($uri_ref, '/')
2656
-			);
2657
-		}
2658
-	}
2659
-	// s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
2660
-	if (_FILE_CONNECT) {
2661
-		if (
2662
-			verifier_visiteur() == '0minirezo'
2663
-			// si c'est un admin sans cookie admin, il faut ignorer le cache chemin !
2664
-			and !isset($_COOKIE['spip_admin'])
2665
-		) {
2666
-			clear_path_cache();
2667
-		}
2668
-	}
2352
+    static $too_late = 0;
2353
+    if ($too_late++) {
2354
+        return;
2355
+    }
2356
+
2357
+    // Declaration des repertoires
2358
+
2359
+    // le nom du repertoire plugins/ activables/desactivables
2360
+    if (!defined('_DIR_PLUGINS')) {
2361
+        define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
2362
+    }
2363
+
2364
+    // le nom du repertoire des extensions/ permanentes du core, toujours actives
2365
+    if (!defined('_DIR_PLUGINS_DIST')) {
2366
+        define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
2367
+    }
2368
+
2369
+    // le nom du repertoire des librairies
2370
+    if (!defined('_DIR_LIB')) {
2371
+        define('_DIR_LIB', _DIR_RACINE . 'lib/');
2372
+    }
2373
+
2374
+    if (!defined('_DIR_IMG')) {
2375
+        define('_DIR_IMG', $pa);
2376
+    }
2377
+    if (!defined('_DIR_LOGOS')) {
2378
+        define('_DIR_LOGOS', $pa);
2379
+    }
2380
+    if (!defined('_DIR_IMG_ICONES')) {
2381
+        define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
2382
+    }
2383
+
2384
+    if (!defined('_DIR_DUMP')) {
2385
+        define('_DIR_DUMP', $ti . 'dump/');
2386
+    }
2387
+    if (!defined('_DIR_SESSIONS')) {
2388
+        define('_DIR_SESSIONS', $ti . 'sessions/');
2389
+    }
2390
+    if (!defined('_DIR_TRANSFERT')) {
2391
+        define('_DIR_TRANSFERT', $ti . 'upload/');
2392
+    }
2393
+    if (!defined('_DIR_CACHE')) {
2394
+        define('_DIR_CACHE', $ti . 'cache/');
2395
+    }
2396
+    if (!defined('_DIR_CACHE_XML')) {
2397
+        define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
2398
+    }
2399
+    if (!defined('_DIR_SKELS')) {
2400
+        define('_DIR_SKELS', _DIR_CACHE . 'skel/');
2401
+    }
2402
+    if (!defined('_DIR_AIDE')) {
2403
+        define('_DIR_AIDE', _DIR_CACHE . 'aide/');
2404
+    }
2405
+    if (!defined('_DIR_TMP')) {
2406
+        define('_DIR_TMP', $ti);
2407
+    }
2408
+
2409
+    if (!defined('_DIR_VAR')) {
2410
+        define('_DIR_VAR', $ta);
2411
+    }
2412
+
2413
+    if (!defined('_DIR_ETC')) {
2414
+        define('_DIR_ETC', $pi);
2415
+    }
2416
+    if (!defined('_DIR_CONNECT')) {
2417
+        define('_DIR_CONNECT', $pi);
2418
+    }
2419
+    if (!defined('_DIR_CHMOD')) {
2420
+        define('_DIR_CHMOD', $pi);
2421
+    }
2422
+
2423
+    if (!isset($GLOBALS['test_dirs'])) {
2424
+        // Pas $pi car il est bon de le mettre hors ecriture apres intstall
2425
+        // il sera rajoute automatiquement si besoin a l'etape 2 de l'install
2426
+    $GLOBALS['test_dirs'] = [$pa, $ti, $ta];
2427
+    }
2428
+
2429
+    // Declaration des fichiers
2430
+
2431
+    if (!defined('_CACHE_PLUGINS_PATH')) {
2432
+        define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
2433
+    }
2434
+    if (!defined('_CACHE_PLUGINS_OPT')) {
2435
+        define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
2436
+    }
2437
+    if (!defined('_CACHE_PLUGINS_FCT')) {
2438
+        define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
2439
+    }
2440
+    if (!defined('_CACHE_PIPELINES')) {
2441
+        define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
2442
+    }
2443
+    if (!defined('_CACHE_CHEMIN')) {
2444
+        define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
2445
+    }
2446
+
2447
+    # attention .php obligatoire pour ecrire_fichier_securise
2448
+    if (!defined('_FILE_META')) {
2449
+        define('_FILE_META', $ti . 'meta_cache.php');
2450
+    }
2451
+    if (!defined('_DIR_LOG')) {
2452
+        define('_DIR_LOG', _DIR_TMP . 'log/');
2453
+    }
2454
+    if (!defined('_FILE_LOG')) {
2455
+        define('_FILE_LOG', 'spip');
2456
+    }
2457
+    if (!defined('_FILE_LOG_SUFFIX')) {
2458
+        define('_FILE_LOG_SUFFIX', '.log');
2459
+    }
2460
+
2461
+    // Le fichier de connexion a la base de donnees
2462
+    // tient compte des anciennes versions (inc_connect...)
2463
+    if (!defined('_FILE_CONNECT_INS')) {
2464
+        define('_FILE_CONNECT_INS', 'connect');
2465
+    }
2466
+    if (!defined('_FILE_CONNECT')) {
2467
+        define(
2468
+            '_FILE_CONNECT',
2469
+            (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2470
+            : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2471
+            : false))
2472
+        );
2473
+    }
2474
+
2475
+    // Le fichier de reglages des droits
2476
+    if (!defined('_FILE_CHMOD_INS')) {
2477
+        define('_FILE_CHMOD_INS', 'chmod');
2478
+    }
2479
+    if (!defined('_FILE_CHMOD')) {
2480
+        define(
2481
+            '_FILE_CHMOD',
2482
+            (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2483
+            : false)
2484
+        );
2485
+    }
2486
+
2487
+    if (!defined('_FILE_LDAP')) {
2488
+        define('_FILE_LDAP', 'ldap.php');
2489
+    }
2490
+
2491
+    if (!defined('_FILE_TMP_SUFFIX')) {
2492
+        define('_FILE_TMP_SUFFIX', '.tmp.php');
2493
+    }
2494
+    if (!defined('_FILE_CONNECT_TMP')) {
2495
+        define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2496
+    }
2497
+    if (!defined('_FILE_CHMOD_TMP')) {
2498
+        define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2499
+    }
2500
+
2501
+    // Definition des droits d'acces en ecriture
2502
+    if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) {
2503
+        include_once _FILE_CHMOD;
2504
+    }
2505
+
2506
+    // Se mefier des fichiers mal remplis!
2507
+    if (!defined('_SPIP_CHMOD')) {
2508
+        define('_SPIP_CHMOD', 0777);
2509
+    }
2510
+
2511
+    if (!defined('_DEFAULT_CHARSET')) {
2512
+        /** Le charset par défaut lors de l'installation */
2513
+        define('_DEFAULT_CHARSET', 'utf-8');
2514
+    }
2515
+    if (!defined('_ROOT_PLUGINS')) {
2516
+        define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/');
2517
+    }
2518
+    if (!defined('_ROOT_PLUGINS_DIST')) {
2519
+        define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/');
2520
+    }
2521
+    if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2522
+        define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2523
+    }
2524
+
2525
+    // La taille des Log
2526
+    if (!defined('_MAX_LOG')) {
2527
+        define('_MAX_LOG', 100);
2528
+    }
2529
+
2530
+    // Sommes-nous dans l'empire du Mal ?
2531
+    // (ou sous le signe du Pingouin, ascendant GNU ?)
2532
+    if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) {
2533
+        if (!defined('_OS_SERVEUR')) {
2534
+            define('_OS_SERVEUR', 'windows');
2535
+        }
2536
+        if (!defined('_SPIP_LOCK_MODE')) {
2537
+            define('_SPIP_LOCK_MODE', 1);
2538
+        } // utiliser le flock php
2539
+    } else {
2540
+        if (!defined('_OS_SERVEUR')) {
2541
+            define('_OS_SERVEUR', '');
2542
+        }
2543
+        if (!defined('_SPIP_LOCK_MODE')) {
2544
+            define('_SPIP_LOCK_MODE', 1);
2545
+        } // utiliser le flock php
2546
+        #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
2547
+    }
2548
+
2549
+    // Langue par defaut
2550
+    if (!defined('_LANGUE_PAR_DEFAUT')) {
2551
+        define('_LANGUE_PAR_DEFAUT', 'fr');
2552
+    }
2553
+
2554
+    //
2555
+    // Module de lecture/ecriture/suppression de fichiers utilisant flock()
2556
+    // (non surchargeable en l'etat ; attention si on utilise include_spip()
2557
+    // pour le rendre surchargeable, on va provoquer un reecriture
2558
+    // systematique du noyau ou une baisse de perfs => a etudier)
2559
+    include_once _ROOT_RESTREINT . 'inc/flock.php';
2560
+
2561
+    // charger tout de suite le path et son cache
2562
+    load_path_cache();
2563
+
2564
+    // *********** traiter les variables ************
2565
+
2566
+    //
2567
+    // Securite
2568
+    //
2569
+
2570
+    // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
2571
+    if (isset($_REQUEST['GLOBALS'])) {
2572
+        die();
2573
+    }
2574
+    // nettoyer les magic quotes \' et les caracteres nuls %00
2575
+    spip_desinfecte($_GET);
2576
+    spip_desinfecte($_POST);
2577
+    spip_desinfecte($_COOKIE);
2578
+    spip_desinfecte($_REQUEST);
2579
+
2580
+    // appliquer le cookie_prefix
2581
+    if ($GLOBALS['cookie_prefix'] != 'spip') {
2582
+        include_spip('inc/cookie');
2583
+        recuperer_cookies_spip($GLOBALS['cookie_prefix']);
2584
+    }
2585
+
2586
+    //
2587
+    // Capacites php (en fonction de la version)
2588
+    //
2589
+    $GLOBALS['flag_ob'] = (function_exists('ob_start')
2590
+        && function_exists('ini_get')
2591
+        && !strstr(@ini_get('disable_functions'), 'ob_'));
2592
+    $GLOBALS['flag_sapi_name'] = function_exists('php_sapi_name');
2593
+    $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != '');
2594
+    $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] ||
2595
+        (get_cfg_var('upload_max_filesize') > 0));
2596
+
2597
+
2598
+    // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI
2599
+    if (isset($_SERVER['REQUEST_URI'])) {
2600
+        $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2601
+    } else {
2602
+        $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2603
+        if (
2604
+            !empty($_SERVER['QUERY_STRING'])
2605
+            and !strpos($_SERVER['REQUEST_URI'], '?')
2606
+        ) {
2607
+            $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2608
+        }
2609
+    }
2610
+
2611
+    // Duree de validite de l'alea pour les cookies et ce qui s'ensuit.
2612
+    if (!defined('_RENOUVELLE_ALEA')) {
2613
+        define('_RENOUVELLE_ALEA', 12 * 3600);
2614
+    }
2615
+    if (!defined('_DUREE_COOKIE_ADMIN')) {
2616
+        define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600);
2617
+    }
2618
+
2619
+    // charger les meta si possible et renouveller l'alea au besoin
2620
+    // charge aussi effacer_meta et ecrire_meta
2621
+    $inc_meta = charger_fonction('meta', 'inc');
2622
+    $inc_meta();
2623
+
2624
+    // nombre de repertoires depuis la racine
2625
+    // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
2626
+    // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse
2627
+    // le calcul est faux)
2628
+    if (!_DIR_RESTREINT) {
2629
+        $GLOBALS['profondeur_url'] = 1;
2630
+    } else {
2631
+        $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : '';
2632
+        $uri_ref = $_SERVER['SCRIPT_NAME'];
2633
+        if (
2634
+            !$uri_ref
2635
+            // si on est appele avec un autre ti, on est sans doute en mutu
2636
+            // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie
2637
+            // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer
2638
+            // s'en remettre a l'adresse du site. alea jacta est.
2639
+            or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES
2640
+        ) {
2641
+            if (isset($GLOBALS['meta']['adresse_site'])) {
2642
+                $uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2643
+                $uri_ref = ($uri_ref['path'] ?? '') . '/';
2644
+            } else {
2645
+                $uri_ref = '';
2646
+            }
2647
+        }
2648
+        if (!$uri or !$uri_ref) {
2649
+            $GLOBALS['profondeur_url'] = 0;
2650
+        } else {
2651
+            $GLOBALS['profondeur_url'] = max(
2652
+                0,
2653
+                substr_count($uri[0], '/')
2654
+                - substr_count($uri_ref, '/')
2655
+            );
2656
+        }
2657
+    }
2658
+    // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
2659
+    if (_FILE_CONNECT) {
2660
+        if (
2661
+            verifier_visiteur() == '0minirezo'
2662
+            // si c'est un admin sans cookie admin, il faut ignorer le cache chemin !
2663
+            and !isset($_COOKIE['spip_admin'])
2664
+        ) {
2665
+            clear_path_cache();
2666
+        }
2667
+    }
2669 2668
 }
2670 2669
 
2671 2670
 /**
@@ -2674,190 +2673,190 @@  discard block
 block discarded – undo
2674 2673
  *
2675 2674
  */
2676 2675
 function spip_initialisation_suite() {
2677
-	static $too_late = 0;
2678
-	if ($too_late++) {
2679
-		return;
2680
-	}
2681
-
2682
-	// taille mini des login
2683
-	if (!defined('_LOGIN_TROP_COURT')) {
2684
-		define('_LOGIN_TROP_COURT', 4);
2685
-	}
2686
-
2687
-	// la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2688
-	#if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko
2689
-	#if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels
2690
-	#if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels
2691
-
2692
-	// la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2693
-	#if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko
2694
-	#if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko
2695
-	#if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels
2696
-	#if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels
2697
-
2698
-	if (!defined('_PASS_LONGUEUR_MINI')) {
2699
-		define('_PASS_LONGUEUR_MINI', 6);
2700
-	}
2701
-
2702
-	// largeur maximale des images dans l'administration
2703
-	if (!defined('_IMG_ADMIN_MAX_WIDTH')) {
2704
-		define('_IMG_ADMIN_MAX_WIDTH', 768);
2705
-	}
2706
-
2707
-	// Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)
2708
-	if (!defined('_IMG_QUALITE')) {
2709
-		define('_IMG_QUALITE', 85);
2710
-	} # valeur par defaut
2711
-	if (!defined('_IMG_GD_QUALITE')) {
2712
-		define('_IMG_GD_QUALITE', _IMG_QUALITE);
2713
-	} # surcharge pour la lib GD
2714
-	if (!defined('_IMG_CONVERT_QUALITE')) {
2715
-		define('_IMG_CONVERT_QUALITE', _IMG_QUALITE);
2716
-	} # surcharge pour imagick en ligne de commande
2717
-	// Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE
2718
-	if (!defined('_IMG_IMAGICK_QUALITE')) {
2719
-		define('_IMG_IMAGICK_QUALITE', 75);
2720
-	} # surcharge pour imagick en PHP
2721
-
2722
-	if (!defined('_COPIE_LOCALE_MAX_SIZE')) {
2723
-		define('_COPIE_LOCALE_MAX_SIZE', 33_554_432);
2724
-	} // poids en octet
2725
-
2726
-	// qq chaines standard
2727
-	if (!defined('_ACCESS_FILE_NAME')) {
2728
-		define('_ACCESS_FILE_NAME', '.htaccess');
2729
-	}
2730
-	if (!defined('_AUTH_USER_FILE')) {
2731
-		define('_AUTH_USER_FILE', '.htpasswd');
2732
-	}
2733
-	if (!defined('_SPIP_DUMP')) {
2734
-		define('_SPIP_DUMP', 'dump@nom_site@@[email protected]');
2735
-	}
2736
-	if (!defined('_CACHE_RUBRIQUES')) {
2737
-		/** Fichier cache pour le navigateur de rubrique du bandeau */
2738
-		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2739
-	}
2740
-	if (!defined('_CACHE_RUBRIQUES_MAX')) {
2741
-		/** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
2742
-		define('_CACHE_RUBRIQUES_MAX', 500);
2743
-	}
2744
-
2745
-	if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) {
2746
-		/**
2747
-		 * Basculer les contextes ajax en fichier si la longueur d’url est trop grande
2748
-		 * @var int Nombre de caractères */
2749
-		define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000);
2750
-	}
2751
-
2752
-	if (!defined('_EXTENSION_SQUELETTES')) {
2753
-		define('_EXTENSION_SQUELETTES', 'html');
2754
-	}
2755
-
2756
-	if (!defined('_DOCTYPE_ECRIRE')) {
2757
-		/** Définit le doctype de l’espace privé */
2758
-		define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n");
2759
-	}
2760
-	if (!defined('_DOCTYPE_AIDE')) {
2761
-		/** Définit le doctype de l’aide en ligne */
2762
-		define(
2763
-			'_DOCTYPE_AIDE',
2764
-			"<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"
2765
-		);
2766
-	}
2767
-
2768
-	if (!defined('_SPIP_SCRIPT')) {
2769
-		/** L'adresse de base du site ; on peut mettre '' si la racine est gerée par
2770
-		 * le script de l'espace public, alias index.php */
2771
-		define('_SPIP_SCRIPT', 'spip.php');
2772
-	}
2773
-	if (!defined('_SPIP_PAGE')) {
2774
-		/** Argument page, personalisable en cas de conflit avec un autre script */
2775
-		define('_SPIP_PAGE', 'page');
2776
-	}
2777
-
2778
-	// le script de l'espace prive
2779
-	// Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:
2780
-	// les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)
2781
-	// meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html
2782
-	if (!defined('_SPIP_ECRIRE_SCRIPT')) {
2783
-		if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) {
2784
-			define('_SPIP_ECRIRE_SCRIPT', 'index.php');
2785
-		} else {
2786
-			define('_SPIP_ECRIRE_SCRIPT', '');
2787
-		}
2788
-	}
2789
-
2790
-
2791
-	if (!defined('_SPIP_AJAX')) {
2792
-		define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax']))
2793
-			? 1
2794
-			: (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));
2795
-	}
2796
-
2797
-	// La requete est-elle en ajax ?
2798
-	if (!defined('_AJAX')) {
2799
-		define(
2800
-			'_AJAX',
2801
-			(isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery
2802
-				or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery
2803
-				or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins
2804
-				or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip
2805
-			)
2806
-			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
2807
-		);
2808
-	}
2809
-
2810
-	# nombre de pixels maxi pour calcul de la vignette avec gd
2811
-	# au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation
2812
-	# les configurations limitees en memoire ont un seuil plutot vers 1MPixel
2813
-	if (!defined('_IMG_GD_MAX_PIXELS')) {
2814
-		define(
2815
-			'_IMG_GD_MAX_PIXELS',
2816
-			(isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes'])
2817
-			? $GLOBALS['meta']['max_taille_vignettes']
2818
-			: 0
2819
-		);
2820
-	}
2821
-
2822
-	if (!defined('_MEMORY_LIMIT_MIN')) {
2823
-		define('_MEMORY_LIMIT_MIN', 16);
2824
-	} // en Mo
2825
-	// si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard)
2826
-	// on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche
2827
-	// il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche
2828
-	if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) {
2829
-		if ($memory = trim(ini_get('memory_limit')) and $memory != -1) {
2830
-			$unit = strtolower(substr($memory, -1));
2831
-			$memory = substr($memory, 0, -1);
2832
-			switch ($unit) {
2833
-				// Le modifieur 'G' est disponible depuis PHP 5.1.0
2834
-				case 'g':
2835
-					$memory *= 1024;
2836
-				case 'm':
2837
-					$memory *= 1024;
2838
-				case 'k':
2839
-					$memory *= 1024;
2840
-			}
2841
-			if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) {
2842
-				@ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M');
2843
-				if (trim(ini_get('memory_limit')) != $m) {
2844
-					if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2845
-						define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
2846
-					} // evite une page blanche car on ne saura pas calculer la css dans ce hit
2847
-				}
2848
-			}
2849
-		} else {
2850
-			if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2851
-				define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
2852
-			}
2853
-		} // evite une page blanche car on ne saura pas calculer la css dans ce hit
2854
-	}
2855
-	// Protocoles a normaliser dans les chaines de langues
2856
-	if (!defined('_PROTOCOLES_STD')) {
2857
-		define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal');
2858
-	}
2859
-
2860
-	init_var_mode();
2676
+    static $too_late = 0;
2677
+    if ($too_late++) {
2678
+        return;
2679
+    }
2680
+
2681
+    // taille mini des login
2682
+    if (!defined('_LOGIN_TROP_COURT')) {
2683
+        define('_LOGIN_TROP_COURT', 4);
2684
+    }
2685
+
2686
+    // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2687
+    #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko
2688
+    #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels
2689
+    #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels
2690
+
2691
+    // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2692
+    #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko
2693
+    #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko
2694
+    #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels
2695
+    #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels
2696
+
2697
+    if (!defined('_PASS_LONGUEUR_MINI')) {
2698
+        define('_PASS_LONGUEUR_MINI', 6);
2699
+    }
2700
+
2701
+    // largeur maximale des images dans l'administration
2702
+    if (!defined('_IMG_ADMIN_MAX_WIDTH')) {
2703
+        define('_IMG_ADMIN_MAX_WIDTH', 768);
2704
+    }
2705
+
2706
+    // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)
2707
+    if (!defined('_IMG_QUALITE')) {
2708
+        define('_IMG_QUALITE', 85);
2709
+    } # valeur par defaut
2710
+    if (!defined('_IMG_GD_QUALITE')) {
2711
+        define('_IMG_GD_QUALITE', _IMG_QUALITE);
2712
+    } # surcharge pour la lib GD
2713
+    if (!defined('_IMG_CONVERT_QUALITE')) {
2714
+        define('_IMG_CONVERT_QUALITE', _IMG_QUALITE);
2715
+    } # surcharge pour imagick en ligne de commande
2716
+    // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE
2717
+    if (!defined('_IMG_IMAGICK_QUALITE')) {
2718
+        define('_IMG_IMAGICK_QUALITE', 75);
2719
+    } # surcharge pour imagick en PHP
2720
+
2721
+    if (!defined('_COPIE_LOCALE_MAX_SIZE')) {
2722
+        define('_COPIE_LOCALE_MAX_SIZE', 33_554_432);
2723
+    } // poids en octet
2724
+
2725
+    // qq chaines standard
2726
+    if (!defined('_ACCESS_FILE_NAME')) {
2727
+        define('_ACCESS_FILE_NAME', '.htaccess');
2728
+    }
2729
+    if (!defined('_AUTH_USER_FILE')) {
2730
+        define('_AUTH_USER_FILE', '.htpasswd');
2731
+    }
2732
+    if (!defined('_SPIP_DUMP')) {
2733
+        define('_SPIP_DUMP', 'dump@nom_site@@[email protected]');
2734
+    }
2735
+    if (!defined('_CACHE_RUBRIQUES')) {
2736
+        /** Fichier cache pour le navigateur de rubrique du bandeau */
2737
+        define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2738
+    }
2739
+    if (!defined('_CACHE_RUBRIQUES_MAX')) {
2740
+        /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
2741
+        define('_CACHE_RUBRIQUES_MAX', 500);
2742
+    }
2743
+
2744
+    if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) {
2745
+        /**
2746
+         * Basculer les contextes ajax en fichier si la longueur d’url est trop grande
2747
+         * @var int Nombre de caractères */
2748
+        define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000);
2749
+    }
2750
+
2751
+    if (!defined('_EXTENSION_SQUELETTES')) {
2752
+        define('_EXTENSION_SQUELETTES', 'html');
2753
+    }
2754
+
2755
+    if (!defined('_DOCTYPE_ECRIRE')) {
2756
+        /** Définit le doctype de l’espace privé */
2757
+        define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n");
2758
+    }
2759
+    if (!defined('_DOCTYPE_AIDE')) {
2760
+        /** Définit le doctype de l’aide en ligne */
2761
+        define(
2762
+            '_DOCTYPE_AIDE',
2763
+            "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"
2764
+        );
2765
+    }
2766
+
2767
+    if (!defined('_SPIP_SCRIPT')) {
2768
+        /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par
2769
+         * le script de l'espace public, alias index.php */
2770
+        define('_SPIP_SCRIPT', 'spip.php');
2771
+    }
2772
+    if (!defined('_SPIP_PAGE')) {
2773
+        /** Argument page, personalisable en cas de conflit avec un autre script */
2774
+        define('_SPIP_PAGE', 'page');
2775
+    }
2776
+
2777
+    // le script de l'espace prive
2778
+    // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:
2779
+    // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)
2780
+    // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html
2781
+    if (!defined('_SPIP_ECRIRE_SCRIPT')) {
2782
+        if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) {
2783
+            define('_SPIP_ECRIRE_SCRIPT', 'index.php');
2784
+        } else {
2785
+            define('_SPIP_ECRIRE_SCRIPT', '');
2786
+        }
2787
+    }
2788
+
2789
+
2790
+    if (!defined('_SPIP_AJAX')) {
2791
+        define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax']))
2792
+            ? 1
2793
+            : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));
2794
+    }
2795
+
2796
+    // La requete est-elle en ajax ?
2797
+    if (!defined('_AJAX')) {
2798
+        define(
2799
+            '_AJAX',
2800
+            (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery
2801
+                or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery
2802
+                or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins
2803
+                or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip
2804
+            )
2805
+            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
2806
+        );
2807
+    }
2808
+
2809
+    # nombre de pixels maxi pour calcul de la vignette avec gd
2810
+    # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation
2811
+    # les configurations limitees en memoire ont un seuil plutot vers 1MPixel
2812
+    if (!defined('_IMG_GD_MAX_PIXELS')) {
2813
+        define(
2814
+            '_IMG_GD_MAX_PIXELS',
2815
+            (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes'])
2816
+            ? $GLOBALS['meta']['max_taille_vignettes']
2817
+            : 0
2818
+        );
2819
+    }
2820
+
2821
+    if (!defined('_MEMORY_LIMIT_MIN')) {
2822
+        define('_MEMORY_LIMIT_MIN', 16);
2823
+    } // en Mo
2824
+    // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard)
2825
+    // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche
2826
+    // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche
2827
+    if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) {
2828
+        if ($memory = trim(ini_get('memory_limit')) and $memory != -1) {
2829
+            $unit = strtolower(substr($memory, -1));
2830
+            $memory = substr($memory, 0, -1);
2831
+            switch ($unit) {
2832
+                // Le modifieur 'G' est disponible depuis PHP 5.1.0
2833
+                case 'g':
2834
+                    $memory *= 1024;
2835
+                case 'm':
2836
+                    $memory *= 1024;
2837
+                case 'k':
2838
+                    $memory *= 1024;
2839
+            }
2840
+            if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) {
2841
+                @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M');
2842
+                if (trim(ini_get('memory_limit')) != $m) {
2843
+                    if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2844
+                        define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
2845
+                    } // evite une page blanche car on ne saura pas calculer la css dans ce hit
2846
+                }
2847
+            }
2848
+        } else {
2849
+            if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2850
+                define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
2851
+            }
2852
+        } // evite une page blanche car on ne saura pas calculer la css dans ce hit
2853
+    }
2854
+    // Protocoles a normaliser dans les chaines de langues
2855
+    if (!defined('_PROTOCOLES_STD')) {
2856
+        define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal');
2857
+    }
2858
+
2859
+    init_var_mode();
2861 2860
 }
2862 2861
 
2863 2862
 /**
@@ -2891,136 +2890,136 @@  discard block
 block discarded – undo
2891 2890
  * `   var_mode` (calcul ou recalcul).
2892 2891
  */
2893 2892
 function init_var_mode() {
2894
-	static $done = false;
2895
-	if (!$done) {
2896
-		if (isset($_GET['var_mode'])) {
2897
-			$var_mode = explode(',', $_GET['var_mode']);
2898
-			// tout le monde peut calcul/recalcul
2899
-			if (!defined('_VAR_MODE')) {
2900
-				if (in_array('recalcul', $var_mode)) {
2901
-					define('_VAR_MODE', 'recalcul');
2902
-				} elseif (in_array('calcul', $var_mode)) {
2903
-					define('_VAR_MODE', 'calcul');
2904
-				}
2905
-			}
2906
-			$var_mode = array_diff($var_mode, ['calcul', 'recalcul']);
2907
-			if ($var_mode) {
2908
-				include_spip('inc/autoriser');
2909
-				// autoriser preview si preview seulement, et sinon autoriser debug
2910
-				if (
2911
-					autoriser(
2912
-						($_GET['var_mode'] == 'preview')
2913
-						? 'previsualiser'
2914
-						: 'debug'
2915
-					)
2916
-				) {
2917
-					if (in_array('traduction', $var_mode)) {
2918
-						// forcer le calcul pour passer dans traduire
2919
-						if (!defined('_VAR_MODE')) {
2920
-							define('_VAR_MODE', 'calcul');
2921
-						}
2922
-						// et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages
2923
-						if (!defined('_VAR_NOCACHE')) {
2924
-							define('_VAR_NOCACHE', true);
2925
-						}
2926
-						$var_mode = array_diff($var_mode, ['traduction']);
2927
-					}
2928
-					if (in_array('preview', $var_mode)) {
2929
-						// basculer sur les criteres de preview dans les boucles
2930
-						if (!defined('_VAR_PREVIEW')) {
2931
-							define('_VAR_PREVIEW', true);
2932
-						}
2933
-						// forcer le calcul
2934
-						if (!defined('_VAR_MODE')) {
2935
-							define('_VAR_MODE', 'calcul');
2936
-						}
2937
-						// et ne pas enregistrer de cache
2938
-						if (!defined('_VAR_NOCACHE')) {
2939
-							define('_VAR_NOCACHE', true);
2940
-						}
2941
-						$var_mode = array_diff($var_mode, ['preview']);
2942
-					}
2943
-					if (in_array('inclure', $var_mode)) {
2944
-						// forcer le compilo et ignorer les caches existants
2945
-						if (!defined('_VAR_MODE')) {
2946
-							define('_VAR_MODE', 'calcul');
2947
-						}
2948
-						if (!defined('_VAR_INCLURE')) {
2949
-							define('_VAR_INCLURE', true);
2950
-						}
2951
-						// et ne pas enregistrer de cache
2952
-						if (!defined('_VAR_NOCACHE')) {
2953
-							define('_VAR_NOCACHE', true);
2954
-						}
2955
-						$var_mode = array_diff($var_mode, ['inclure']);
2956
-					}
2957
-					if (in_array('urls', $var_mode)) {
2958
-						// forcer le compilo et ignorer les caches existants
2959
-						if (!defined('_VAR_MODE')) {
2960
-							define('_VAR_MODE', 'calcul');
2961
-						}
2962
-						if (!defined('_VAR_URLS')) {
2963
-							define('_VAR_URLS', true);
2964
-						}
2965
-						$var_mode = array_diff($var_mode, ['urls']);
2966
-					}
2967
-					if (in_array('images', $var_mode)) {
2968
-						// forcer le compilo et ignorer les caches existants
2969
-						if (!defined('_VAR_MODE')) {
2970
-							define('_VAR_MODE', 'calcul');
2971
-						}
2972
-						// indiquer qu'on doit recalculer les images
2973
-						if (!defined('_VAR_IMAGES')) {
2974
-							define('_VAR_IMAGES', true);
2975
-						}
2976
-						$var_mode = array_diff($var_mode, ['images']);
2977
-					}
2978
-					if (in_array('debug', $var_mode)) {
2979
-						if (!defined('_VAR_MODE')) {
2980
-							define('_VAR_MODE', 'debug');
2981
-						}
2982
-						// et ne pas enregistrer de cache
2983
-						if (!defined('_VAR_NOCACHE')) {
2984
-							define('_VAR_NOCACHE', true);
2985
-						}
2986
-						$var_mode = array_diff($var_mode, ['debug']);
2987
-					}
2988
-					if (count($var_mode) and !defined('_VAR_MODE')) {
2989
-						define('_VAR_MODE', reset($var_mode));
2990
-					}
2991
-					if (isset($GLOBALS['visiteur_session']['nom'])) {
2992
-						spip_log($GLOBALS['visiteur_session']['nom']
2993
-							. ' ' . _VAR_MODE);
2994
-					}
2995
-				} // pas autorise ?
2996
-				else {
2997
-					// si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger
2998
-					if (
2999
-						!$GLOBALS['visiteur_session']
3000
-						and !empty($_SERVER['HTTP_HOST'])
3001
-						and !empty($_SERVER['REQUEST_METHOD'])
3002
-						and $_SERVER['REQUEST_METHOD'] === 'GET'
3003
-					) {
3004
-						$self = self('&', true);
3005
-						if (strpos($self, 'page=login') === false) {
3006
-							include_spip('inc/headers');
3007
-							$redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&');
3008
-							redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true));
3009
-						}
3010
-					}
3011
-					// sinon tant pis
3012
-				}
3013
-			}
3014
-		}
3015
-		if (!defined('_VAR_MODE')) {
3016
-			/**
3017
-			 * Indique le mode de calcul ou d'affichage de la page.
3018
-			 * @see init_var_mode()
3019
-			 */
3020
-			define('_VAR_MODE', false);
3021
-		}
3022
-		$done = true;
3023
-	}
2893
+    static $done = false;
2894
+    if (!$done) {
2895
+        if (isset($_GET['var_mode'])) {
2896
+            $var_mode = explode(',', $_GET['var_mode']);
2897
+            // tout le monde peut calcul/recalcul
2898
+            if (!defined('_VAR_MODE')) {
2899
+                if (in_array('recalcul', $var_mode)) {
2900
+                    define('_VAR_MODE', 'recalcul');
2901
+                } elseif (in_array('calcul', $var_mode)) {
2902
+                    define('_VAR_MODE', 'calcul');
2903
+                }
2904
+            }
2905
+            $var_mode = array_diff($var_mode, ['calcul', 'recalcul']);
2906
+            if ($var_mode) {
2907
+                include_spip('inc/autoriser');
2908
+                // autoriser preview si preview seulement, et sinon autoriser debug
2909
+                if (
2910
+                    autoriser(
2911
+                        ($_GET['var_mode'] == 'preview')
2912
+                        ? 'previsualiser'
2913
+                        : 'debug'
2914
+                    )
2915
+                ) {
2916
+                    if (in_array('traduction', $var_mode)) {
2917
+                        // forcer le calcul pour passer dans traduire
2918
+                        if (!defined('_VAR_MODE')) {
2919
+                            define('_VAR_MODE', 'calcul');
2920
+                        }
2921
+                        // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages
2922
+                        if (!defined('_VAR_NOCACHE')) {
2923
+                            define('_VAR_NOCACHE', true);
2924
+                        }
2925
+                        $var_mode = array_diff($var_mode, ['traduction']);
2926
+                    }
2927
+                    if (in_array('preview', $var_mode)) {
2928
+                        // basculer sur les criteres de preview dans les boucles
2929
+                        if (!defined('_VAR_PREVIEW')) {
2930
+                            define('_VAR_PREVIEW', true);
2931
+                        }
2932
+                        // forcer le calcul
2933
+                        if (!defined('_VAR_MODE')) {
2934
+                            define('_VAR_MODE', 'calcul');
2935
+                        }
2936
+                        // et ne pas enregistrer de cache
2937
+                        if (!defined('_VAR_NOCACHE')) {
2938
+                            define('_VAR_NOCACHE', true);
2939
+                        }
2940
+                        $var_mode = array_diff($var_mode, ['preview']);
2941
+                    }
2942
+                    if (in_array('inclure', $var_mode)) {
2943
+                        // forcer le compilo et ignorer les caches existants
2944
+                        if (!defined('_VAR_MODE')) {
2945
+                            define('_VAR_MODE', 'calcul');
2946
+                        }
2947
+                        if (!defined('_VAR_INCLURE')) {
2948
+                            define('_VAR_INCLURE', true);
2949
+                        }
2950
+                        // et ne pas enregistrer de cache
2951
+                        if (!defined('_VAR_NOCACHE')) {
2952
+                            define('_VAR_NOCACHE', true);
2953
+                        }
2954
+                        $var_mode = array_diff($var_mode, ['inclure']);
2955
+                    }
2956
+                    if (in_array('urls', $var_mode)) {
2957
+                        // forcer le compilo et ignorer les caches existants
2958
+                        if (!defined('_VAR_MODE')) {
2959
+                            define('_VAR_MODE', 'calcul');
2960
+                        }
2961
+                        if (!defined('_VAR_URLS')) {
2962
+                            define('_VAR_URLS', true);
2963
+                        }
2964
+                        $var_mode = array_diff($var_mode, ['urls']);
2965
+                    }
2966
+                    if (in_array('images', $var_mode)) {
2967
+                        // forcer le compilo et ignorer les caches existants
2968
+                        if (!defined('_VAR_MODE')) {
2969
+                            define('_VAR_MODE', 'calcul');
2970
+                        }
2971
+                        // indiquer qu'on doit recalculer les images
2972
+                        if (!defined('_VAR_IMAGES')) {
2973
+                            define('_VAR_IMAGES', true);
2974
+                        }
2975
+                        $var_mode = array_diff($var_mode, ['images']);
2976
+                    }
2977
+                    if (in_array('debug', $var_mode)) {
2978
+                        if (!defined('_VAR_MODE')) {
2979
+                            define('_VAR_MODE', 'debug');
2980
+                        }
2981
+                        // et ne pas enregistrer de cache
2982
+                        if (!defined('_VAR_NOCACHE')) {
2983
+                            define('_VAR_NOCACHE', true);
2984
+                        }
2985
+                        $var_mode = array_diff($var_mode, ['debug']);
2986
+                    }
2987
+                    if (count($var_mode) and !defined('_VAR_MODE')) {
2988
+                        define('_VAR_MODE', reset($var_mode));
2989
+                    }
2990
+                    if (isset($GLOBALS['visiteur_session']['nom'])) {
2991
+                        spip_log($GLOBALS['visiteur_session']['nom']
2992
+                            . ' ' . _VAR_MODE);
2993
+                    }
2994
+                } // pas autorise ?
2995
+                else {
2996
+                    // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger
2997
+                    if (
2998
+                        !$GLOBALS['visiteur_session']
2999
+                        and !empty($_SERVER['HTTP_HOST'])
3000
+                        and !empty($_SERVER['REQUEST_METHOD'])
3001
+                        and $_SERVER['REQUEST_METHOD'] === 'GET'
3002
+                    ) {
3003
+                        $self = self('&', true);
3004
+                        if (strpos($self, 'page=login') === false) {
3005
+                            include_spip('inc/headers');
3006
+                            $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&');
3007
+                            redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true));
3008
+                        }
3009
+                    }
3010
+                    // sinon tant pis
3011
+                }
3012
+            }
3013
+        }
3014
+        if (!defined('_VAR_MODE')) {
3015
+            /**
3016
+             * Indique le mode de calcul ou d'affichage de la page.
3017
+             * @see init_var_mode()
3018
+             */
3019
+            define('_VAR_MODE', false);
3020
+        }
3021
+        $done = true;
3022
+    }
3024 3023
 }
3025 3024
 
3026 3025
 // Annuler les magic quotes \' sur GET POST COOKIE et GLOBALS ;
@@ -3028,84 +3027,84 @@  discard block
 block discarded – undo
3028 3027
 // la commande is_readable('chemin/vers/fichier/interdit%00truc_normal')
3029 3028
 // https://code.spip.net/@spip_desinfecte
3030 3029
 function spip_desinfecte(&$t, $deep = true) {
3031
-	foreach ($t as $key => $val) {
3032
-		if (is_string($t[$key])) {
3033
-			$t[$key] = str_replace(chr(0), '-', $t[$key]);
3034
-		} // traiter aussi les "texte_plus" de article_edit
3035
-		else {
3036
-			if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') {
3037
-				spip_desinfecte($t[$key], $deep);
3038
-			}
3039
-		}
3040
-	}
3030
+    foreach ($t as $key => $val) {
3031
+        if (is_string($t[$key])) {
3032
+            $t[$key] = str_replace(chr(0), '-', $t[$key]);
3033
+        } // traiter aussi les "texte_plus" de article_edit
3034
+        else {
3035
+            if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') {
3036
+                spip_desinfecte($t[$key], $deep);
3037
+            }
3038
+        }
3039
+    }
3041 3040
 }
3042 3041
 
3043 3042
 //  retourne le statut du visiteur s'il s'annonce
3044 3043
 
3045 3044
 // https://code.spip.net/@verifier_visiteur
3046 3045
 function verifier_visiteur() {
3047
-	// Rq: pour que cette fonction marche depuis mes_options
3048
-	// il faut forcer l'init si ce n'est fait
3049
-	// mais on risque de perturber des plugins en initialisant trop tot
3050
-	// certaines constantes
3051
-	@spip_initialisation_core(
3052
-		(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3053
-		(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3054
-		(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3055
-		(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3056
-	);
3057
-
3058
-	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
3059
-	// dans un formulaire sans login (ex: #FORMULAIRE_FORUM)
3060
-	// Attention on separe bien session_nom et nom, pour eviter
3061
-	// les melanges entre donnees SQL et variables plus aleatoires
3062
-	$variables_session = ['session_nom', 'session_email'];
3063
-	foreach ($variables_session as $var) {
3064
-		if (_request($var) !== null) {
3065
-			$init = true;
3066
-			break;
3067
-		}
3068
-	}
3069
-	if (isset($init)) {
3070
-		#@spip_initialisation_suite();
3071
-		$session = charger_fonction('session', 'inc');
3072
-		$session();
3073
-		include_spip('inc/texte');
3074
-		foreach ($variables_session as $var) {
3075
-			if (($a = _request($var)) !== null) {
3076
-				$GLOBALS['visiteur_session'][$var] = safehtml($a);
3077
-			}
3078
-		}
3079
-		if (!isset($GLOBALS['visiteur_session']['id_auteur'])) {
3080
-			$GLOBALS['visiteur_session']['id_auteur'] = 0;
3081
-		}
3082
-		$session($GLOBALS['visiteur_session']);
3083
-
3084
-		return 0;
3085
-	}
3086
-
3087
-	$h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3088
-	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3089
-		$session = charger_fonction('session', 'inc');
3090
-		if ($session()) {
3091
-			return $GLOBALS['visiteur_session']['statut'];
3092
-		}
3093
-		if ($h and isset($_SERVER['PHP_AUTH_PW'])) {
3094
-			include_spip('inc/auth');
3095
-			$h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
3096
-		}
3097
-		if ($h) {
3098
-			$GLOBALS['visiteur_session'] = $h;
3099
-
3100
-			return $GLOBALS['visiteur_session']['statut'];
3101
-		}
3102
-	}
3103
-
3104
-	// au moins son navigateur nous dit la langue preferee de cet inconnu
3105
-	include_spip('inc/lang');
3106
-	utiliser_langue_visiteur();
3107
-
3108
-	return false;
3046
+    // Rq: pour que cette fonction marche depuis mes_options
3047
+    // il faut forcer l'init si ce n'est fait
3048
+    // mais on risque de perturber des plugins en initialisant trop tot
3049
+    // certaines constantes
3050
+    @spip_initialisation_core(
3051
+        (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3052
+        (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3053
+        (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3054
+        (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3055
+    );
3056
+
3057
+    // Demarrer une session NON AUTHENTIFIEE si on donne son nom
3058
+    // dans un formulaire sans login (ex: #FORMULAIRE_FORUM)
3059
+    // Attention on separe bien session_nom et nom, pour eviter
3060
+    // les melanges entre donnees SQL et variables plus aleatoires
3061
+    $variables_session = ['session_nom', 'session_email'];
3062
+    foreach ($variables_session as $var) {
3063
+        if (_request($var) !== null) {
3064
+            $init = true;
3065
+            break;
3066
+        }
3067
+    }
3068
+    if (isset($init)) {
3069
+        #@spip_initialisation_suite();
3070
+        $session = charger_fonction('session', 'inc');
3071
+        $session();
3072
+        include_spip('inc/texte');
3073
+        foreach ($variables_session as $var) {
3074
+            if (($a = _request($var)) !== null) {
3075
+                $GLOBALS['visiteur_session'][$var] = safehtml($a);
3076
+            }
3077
+        }
3078
+        if (!isset($GLOBALS['visiteur_session']['id_auteur'])) {
3079
+            $GLOBALS['visiteur_session']['id_auteur'] = 0;
3080
+        }
3081
+        $session($GLOBALS['visiteur_session']);
3082
+
3083
+        return 0;
3084
+    }
3085
+
3086
+    $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3087
+    if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3088
+        $session = charger_fonction('session', 'inc');
3089
+        if ($session()) {
3090
+            return $GLOBALS['visiteur_session']['statut'];
3091
+        }
3092
+        if ($h and isset($_SERVER['PHP_AUTH_PW'])) {
3093
+            include_spip('inc/auth');
3094
+            $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
3095
+        }
3096
+        if ($h) {
3097
+            $GLOBALS['visiteur_session'] = $h;
3098
+
3099
+            return $GLOBALS['visiteur_session']['statut'];
3100
+        }
3101
+    }
3102
+
3103
+    // au moins son navigateur nous dit la langue preferee de cet inconnu
3104
+    include_spip('inc/lang');
3105
+    utiliser_langue_visiteur();
3106
+
3107
+    return false;
3109 3108
 }
3110 3109
 
3111 3110
 
@@ -3128,21 +3127,21 @@  discard block
 block discarded – undo
3128 3127
  *     - string Langue utilisée.
3129 3128
  **/
3130 3129
 function lang_select($lang = null) {
3131
-	static $pile_langues = [];
3132
-	if (!function_exists('changer_langue')) {
3133
-		include_spip('inc/lang');
3134
-	}
3135
-	if ($lang === null) {
3136
-		$lang = array_pop($pile_langues);
3137
-	} else {
3138
-		array_push($pile_langues, $GLOBALS['spip_lang']);
3139
-	}
3140
-	if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) {
3141
-		return $lang;
3142
-	}
3143
-	changer_langue($lang);
3130
+    static $pile_langues = [];
3131
+    if (!function_exists('changer_langue')) {
3132
+        include_spip('inc/lang');
3133
+    }
3134
+    if ($lang === null) {
3135
+        $lang = array_pop($pile_langues);
3136
+    } else {
3137
+        array_push($pile_langues, $GLOBALS['spip_lang']);
3138
+    }
3139
+    if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) {
3140
+        return $lang;
3141
+    }
3142
+    changer_langue($lang);
3144 3143
 
3145
-	return $lang;
3144
+    return $lang;
3146 3145
 }
3147 3146
 
3148 3147
 /**
@@ -3159,20 +3158,20 @@  discard block
 block discarded – undo
3159 3158
  *     Identifiant de la session
3160 3159
  **/
3161 3160
 function spip_session($force = false) {
3162
-	static $session;
3163
-	if ($force or !isset($session)) {
3164
-		$s = pipeline(
3165
-			'definir_session',
3166
-			$GLOBALS['visiteur_session']
3167
-				? serialize($GLOBALS['visiteur_session'])
3168
-				. '_' . @$_COOKIE['spip_session']
3169
-				: ''
3170
-		);
3171
-		$session = $s ? substr(md5($s), 0, 8) : '';
3172
-	}
3161
+    static $session;
3162
+    if ($force or !isset($session)) {
3163
+        $s = pipeline(
3164
+            'definir_session',
3165
+            $GLOBALS['visiteur_session']
3166
+                ? serialize($GLOBALS['visiteur_session'])
3167
+                . '_' . @$_COOKIE['spip_session']
3168
+                : ''
3169
+        );
3170
+        $session = $s ? substr(md5($s), 0, 8) : '';
3171
+    }
3173 3172
 
3174
-	#spip_log('session: '.$session);
3175
-	return $session;
3173
+    #spip_log('session: '.$session);
3174
+    return $session;
3176 3175
 }
3177 3176
 
3178 3177
 
@@ -3191,9 +3190,9 @@  discard block
 block discarded – undo
3191 3190
  *    Lien sur une icone d'aide
3192 3191
  **/
3193 3192
 function aider($aide = '', $distante = false) {
3194
-	$aider = charger_fonction('aide', 'inc', true);
3193
+    $aider = charger_fonction('aide', 'inc', true);
3195 3194
 
3196
-	return $aider ? $aider($aide, '', [], $distante) : '';
3195
+    return $aider ? $aider($aide, '', [], $distante) : '';
3197 3196
 }
3198 3197
 
3199 3198
 /**
@@ -3203,24 +3202,24 @@  discard block
 block discarded – undo
3203 3202
  */
3204 3203
 function exec_info_dist() {
3205 3204
 
3206
-	include_spip('inc/autoriser');
3207
-	if (autoriser('phpinfos')) {
3208
-		$cookies_masques = ['spip_session', 'PHPSESSID'];
3209
-		$cookies_backup = [];
3210
-		foreach ($cookies_masques as $k) {
3211
-			if (!empty($_COOKIE[$k])) {
3212
-				$cookies_backup[$k] = $_COOKIE[$k];
3213
-				$_COOKIE[$k] = '******************************';
3214
-			}
3215
-		}
3216
-		phpinfo();
3217
-		foreach ($cookies_backup as $k => $v) {
3218
-			$_COOKIE[$k] = $v;
3219
-		}
3220
-	} else {
3221
-		include_spip('inc/filtres');
3222
-		sinon_interdire_acces();
3223
-	}
3205
+    include_spip('inc/autoriser');
3206
+    if (autoriser('phpinfos')) {
3207
+        $cookies_masques = ['spip_session', 'PHPSESSID'];
3208
+        $cookies_backup = [];
3209
+        foreach ($cookies_masques as $k) {
3210
+            if (!empty($_COOKIE[$k])) {
3211
+                $cookies_backup[$k] = $_COOKIE[$k];
3212
+                $_COOKIE[$k] = '******************************';
3213
+            }
3214
+        }
3215
+        phpinfo();
3216
+        foreach ($cookies_backup as $k => $v) {
3217
+            $_COOKIE[$k] = $v;
3218
+        }
3219
+    } else {
3220
+        include_spip('inc/filtres');
3221
+        sinon_interdire_acces();
3222
+    }
3224 3223
 }
3225 3224
 
3226 3225
 /**
@@ -3240,13 +3239,13 @@  discard block
 block discarded – undo
3240 3239
  *     - string si $message à false.
3241 3240
  **/
3242 3241
 function erreur_squelette($message = '', $lieu = '') {
3243
-	$debusquer = charger_fonction('debusquer', 'public');
3244
-	if (is_array($lieu)) {
3245
-		include_spip('public/compiler');
3246
-		$lieu = reconstruire_contexte_compil($lieu);
3247
-	}
3242
+    $debusquer = charger_fonction('debusquer', 'public');
3243
+    if (is_array($lieu)) {
3244
+        include_spip('public/compiler');
3245
+        $lieu = reconstruire_contexte_compil($lieu);
3246
+    }
3248 3247
 
3249
-	return $debusquer($message, $lieu);
3248
+    return $debusquer($message, $lieu);
3250 3249
 }
3251 3250
 
3252 3251
 /**
@@ -3283,108 +3282,108 @@  discard block
 block discarded – undo
3283 3282
  *     - ou tableau d'information sur le squelette.
3284 3283
  */
3285 3284
 function recuperer_fond($fond, $contexte = [], $options = [], string $connect = '') {
3286
-	if (!function_exists('evaluer_fond')) {
3287
-		include_spip('public/assembler');
3288
-	}
3289
-	// assurer la compat avec l'ancienne syntaxe
3290
-	// (trim etait le 3eme argument, par defaut a true)
3291
-	if (!is_array($options)) {
3292
-		$options = ['trim' => $options];
3293
-	}
3294
-	if (!isset($options['trim'])) {
3295
-		$options['trim'] = true;
3296
-	}
3297
-
3298
-	if (isset($contexte['connect'])) {
3299
-		$connect = $contexte['connect'];
3300
-		unset($contexte['connect']);
3301
-	}
3302
-
3303
-	$texte = '';
3304
-	$pages = [];
3305
-	$lang_select = '';
3306
-	if (!isset($options['etoile']) or !$options['etoile']) {
3307
-		// Si on a inclus sans fixer le critere de lang, on prend la langue courante
3308
-		if (!isset($contexte['lang'])) {
3309
-			$contexte['lang'] = $GLOBALS['spip_lang'];
3310
-		}
3311
-
3312
-		if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
3313
-			$lang_select = lang_select($contexte['lang']);
3314
-		}
3315
-	}
3316
-
3317
-	if (!isset($GLOBALS['_INC_PUBLIC'])) {
3318
-		$GLOBALS['_INC_PUBLIC'] = 0;
3319
-	}
3320
-
3321
-	$GLOBALS['_INC_PUBLIC']++;
3322
-
3323
-	// fix #4235
3324
-	$cache_utilise_session_appelant	= ($GLOBALS['cache_utilise_session'] ?? null);
3325
-
3326
-
3327
-	foreach (is_array($fond) ? $fond : [$fond] as $f) {
3328
-		unset($GLOBALS['cache_utilise_session']);	// fix #4235
3329
-
3330
-		$page = evaluer_fond($f, $contexte, $connect);
3331
-		if ($page === '') {
3332
-			$c = $options['compil'] ?? '';
3333
-			$a = ['fichier' => $f];
3334
-			$erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
3335
-			erreur_squelette($erreur, $c);
3336
-			// eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
3337
-			$page = ['texte' => '', 'erreur' => $erreur];
3338
-		}
3339
-
3340
-		$page = pipeline('recuperer_fond', [
3341
-			'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect],
3342
-			'data' => $page
3343
-		]);
3344
-		if (isset($options['ajax']) and $options['ajax']) {
3345
-			if (!function_exists('encoder_contexte_ajax')) {
3346
-				include_spip('inc/filtres');
3347
-			}
3348
-			$page['texte'] = encoder_contexte_ajax(
3349
-				array_merge(
3350
-					$contexte,
3351
-					['fond' => $f],
3352
-					($connect ? ['connect' => $connect] : [])
3353
-				),
3354
-				'',
3355
-				$page['texte'],
3356
-				$options['ajax']
3357
-			);
3358
-		}
3359
-
3360
-		if (isset($options['raw']) and $options['raw']) {
3361
-			$pages[] = $page;
3362
-		} else {
3363
-			$texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte'];
3364
-		}
3365
-
3366
-		// contamination de la session appelante, pour les inclusions statiques
3367
-		if (isset($page['invalideurs']['session'])) {
3368
-			$cache_utilise_session_appelant = $page['invalideurs']['session'];
3369
-		}
3370
-	}
3371
-
3372
-	// restaurer le sessionnement du contexte appelant,
3373
-	// éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée
3374
-	if (isset($cache_utilise_session_appelant)) {
3375
-		$GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant;
3376
-	}
3377
-
3378
-	$GLOBALS['_INC_PUBLIC']--;
3379
-
3380
-	if ($lang_select) {
3381
-		lang_select();
3382
-	}
3383
-	if (isset($options['raw']) and $options['raw']) {
3384
-		return is_array($fond) ? $pages : reset($pages);
3385
-	} else {
3386
-		return $options['trim'] ? ltrim($texte) : $texte;
3387
-	}
3285
+    if (!function_exists('evaluer_fond')) {
3286
+        include_spip('public/assembler');
3287
+    }
3288
+    // assurer la compat avec l'ancienne syntaxe
3289
+    // (trim etait le 3eme argument, par defaut a true)
3290
+    if (!is_array($options)) {
3291
+        $options = ['trim' => $options];
3292
+    }
3293
+    if (!isset($options['trim'])) {
3294
+        $options['trim'] = true;
3295
+    }
3296
+
3297
+    if (isset($contexte['connect'])) {
3298
+        $connect = $contexte['connect'];
3299
+        unset($contexte['connect']);
3300
+    }
3301
+
3302
+    $texte = '';
3303
+    $pages = [];
3304
+    $lang_select = '';
3305
+    if (!isset($options['etoile']) or !$options['etoile']) {
3306
+        // Si on a inclus sans fixer le critere de lang, on prend la langue courante
3307
+        if (!isset($contexte['lang'])) {
3308
+            $contexte['lang'] = $GLOBALS['spip_lang'];
3309
+        }
3310
+
3311
+        if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
3312
+            $lang_select = lang_select($contexte['lang']);
3313
+        }
3314
+    }
3315
+
3316
+    if (!isset($GLOBALS['_INC_PUBLIC'])) {
3317
+        $GLOBALS['_INC_PUBLIC'] = 0;
3318
+    }
3319
+
3320
+    $GLOBALS['_INC_PUBLIC']++;
3321
+
3322
+    // fix #4235
3323
+    $cache_utilise_session_appelant	= ($GLOBALS['cache_utilise_session'] ?? null);
3324
+
3325
+
3326
+    foreach (is_array($fond) ? $fond : [$fond] as $f) {
3327
+        unset($GLOBALS['cache_utilise_session']);	// fix #4235
3328
+
3329
+        $page = evaluer_fond($f, $contexte, $connect);
3330
+        if ($page === '') {
3331
+            $c = $options['compil'] ?? '';
3332
+            $a = ['fichier' => $f];
3333
+            $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
3334
+            erreur_squelette($erreur, $c);
3335
+            // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
3336
+            $page = ['texte' => '', 'erreur' => $erreur];
3337
+        }
3338
+
3339
+        $page = pipeline('recuperer_fond', [
3340
+            'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect],
3341
+            'data' => $page
3342
+        ]);
3343
+        if (isset($options['ajax']) and $options['ajax']) {
3344
+            if (!function_exists('encoder_contexte_ajax')) {
3345
+                include_spip('inc/filtres');
3346
+            }
3347
+            $page['texte'] = encoder_contexte_ajax(
3348
+                array_merge(
3349
+                    $contexte,
3350
+                    ['fond' => $f],
3351
+                    ($connect ? ['connect' => $connect] : [])
3352
+                ),
3353
+                '',
3354
+                $page['texte'],
3355
+                $options['ajax']
3356
+            );
3357
+        }
3358
+
3359
+        if (isset($options['raw']) and $options['raw']) {
3360
+            $pages[] = $page;
3361
+        } else {
3362
+            $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte'];
3363
+        }
3364
+
3365
+        // contamination de la session appelante, pour les inclusions statiques
3366
+        if (isset($page['invalideurs']['session'])) {
3367
+            $cache_utilise_session_appelant = $page['invalideurs']['session'];
3368
+        }
3369
+    }
3370
+
3371
+    // restaurer le sessionnement du contexte appelant,
3372
+    // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée
3373
+    if (isset($cache_utilise_session_appelant)) {
3374
+        $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant;
3375
+    }
3376
+
3377
+    $GLOBALS['_INC_PUBLIC']--;
3378
+
3379
+    if ($lang_select) {
3380
+        lang_select();
3381
+    }
3382
+    if (isset($options['raw']) and $options['raw']) {
3383
+        return is_array($fond) ? $pages : reset($pages);
3384
+    } else {
3385
+        return $options['trim'] ? ltrim($texte) : $texte;
3386
+    }
3388 3387
 }
3389 3388
 
3390 3389
 /**
@@ -3394,7 +3393,7 @@  discard block
 block discarded – undo
3394 3393
  * @return string
3395 3394
  */
3396 3395
 function trouve_modele($nom) {
3397
-	return trouver_fond($nom, 'modeles/');
3396
+    return trouver_fond($nom, 'modeles/');
3398 3397
 }
3399 3398
 
3400 3399
 /**
@@ -3410,21 +3409,21 @@  discard block
 block discarded – undo
3410 3409
  * @return array|string
3411 3410
  */
3412 3411
 function trouver_fond($nom, $dir = '', $pathinfo = false) {
3413
-	$f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3414
-	if (!$pathinfo) {
3415
-		return $f;
3416
-	}
3417
-	// renvoyer un tableau detaille si $pathinfo==true
3418
-	$p = pathinfo($f);
3419
-	if (!isset($p['extension']) or !$p['extension']) {
3420
-		$p['extension'] = _EXTENSION_SQUELETTES;
3421
-	}
3422
-	if (!isset($p['extension']) or !$p['filename']) {
3423
-		$p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
3424
-	}
3425
-	$p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');
3412
+    $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3413
+    if (!$pathinfo) {
3414
+        return $f;
3415
+    }
3416
+    // renvoyer un tableau detaille si $pathinfo==true
3417
+    $p = pathinfo($f);
3418
+    if (!isset($p['extension']) or !$p['extension']) {
3419
+        $p['extension'] = _EXTENSION_SQUELETTES;
3420
+    }
3421
+    if (!isset($p['extension']) or !$p['filename']) {
3422
+        $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
3423
+    }
3424
+    $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');
3426 3425
 
3427
-	return $p;
3426
+    return $p;
3428 3427
 }
3429 3428
 
3430 3429
 /**
@@ -3444,21 +3443,21 @@  discard block
 block discarded – undo
3444 3443
  *     Nom de l'exec, sinon chaîne vide.
3445 3444
  **/
3446 3445
 function tester_url_ecrire($nom) {
3447
-	static $exec = [];
3448
-	if (isset($exec[$nom])) {
3449
-		return $exec[$nom];
3450
-	}
3451
-	// tester si c'est une page en squelette
3452
-	if (trouver_fond($nom, 'prive/squelettes/contenu/')) {
3453
-		return $exec[$nom] = 'fond';
3454
-	} // echafaudage d'un fond !
3455
-	elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) {
3456
-		return $exec[$nom] = 'fond';
3457
-	}
3458
-	// attention, il ne faut pas inclure l'exec ici
3459
-	// car sinon #URL_ECRIRE provoque des inclusions
3460
-	// et des define intrusifs potentiels
3461
-	return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : '');
3446
+    static $exec = [];
3447
+    if (isset($exec[$nom])) {
3448
+        return $exec[$nom];
3449
+    }
3450
+    // tester si c'est une page en squelette
3451
+    if (trouver_fond($nom, 'prive/squelettes/contenu/')) {
3452
+        return $exec[$nom] = 'fond';
3453
+    } // echafaudage d'un fond !
3454
+    elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) {
3455
+        return $exec[$nom] = 'fond';
3456
+    }
3457
+    // attention, il ne faut pas inclure l'exec ici
3458
+    // car sinon #URL_ECRIRE provoque des inclusions
3459
+    // et des define intrusifs potentiels
3460
+    return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : '');
3462 3461
 }
3463 3462
 
3464 3463
 /**
@@ -3468,8 +3467,8 @@  discard block
 block discarded – undo
3468 3467
  *     true si la constante _VERSION_HTML n'est pas définie ou égale à html5
3469 3468
  **/
3470 3469
 function html5_permis() {
3471
-	return (!defined('_VERSION_HTML')
3472
-		or _VERSION_HTML !== 'html4');
3470
+    return (!defined('_VERSION_HTML')
3471
+        or _VERSION_HTML !== 'html4');
3473 3472
 }
3474 3473
 
3475 3474
 /**
@@ -3479,30 +3478,30 @@  discard block
 block discarded – undo
3479 3478
  * @return array
3480 3479
  */
3481 3480
 function formats_image_acceptables($gd = null, $svg_allowed = true) {
3482
-	$formats = null;
3483
-	if (!is_null($gd)) {
3484
-		$config = ($gd ? 'gd_formats' : 'formats_graphiques');
3485
-		if (isset($GLOBALS['meta'][$config])) {
3486
-			$formats = $GLOBALS['meta'][$config];
3487
-			$formats = explode(',', $formats);
3488
-			$formats = array_filter($formats);
3489
-			$formats = array_map('trim', $formats);
3490
-		}
3491
-	}
3492
-	if (is_null($formats)) {
3493
-		include_spip('inc/filtres_images_lib_mini');
3494
-		$formats = _image_extensions_acceptees_en_entree();
3495
-	}
3496
-
3497
-	if ($svg_allowed) {
3498
-		if (!in_array('svg', $formats)) {
3499
-			$formats[] = 'svg';
3500
-		}
3501
-	}
3502
-	else {
3503
-		$formats = array_diff($formats, ['svg']);
3504
-	}
3505
-	return $formats;
3481
+    $formats = null;
3482
+    if (!is_null($gd)) {
3483
+        $config = ($gd ? 'gd_formats' : 'formats_graphiques');
3484
+        if (isset($GLOBALS['meta'][$config])) {
3485
+            $formats = $GLOBALS['meta'][$config];
3486
+            $formats = explode(',', $formats);
3487
+            $formats = array_filter($formats);
3488
+            $formats = array_map('trim', $formats);
3489
+        }
3490
+    }
3491
+    if (is_null($formats)) {
3492
+        include_spip('inc/filtres_images_lib_mini');
3493
+        $formats = _image_extensions_acceptees_en_entree();
3494
+    }
3495
+
3496
+    if ($svg_allowed) {
3497
+        if (!in_array('svg', $formats)) {
3498
+            $formats[] = 'svg';
3499
+        }
3500
+    }
3501
+    else {
3502
+        $formats = array_diff($formats, ['svg']);
3503
+    }
3504
+    return $formats;
3506 3505
 }
3507 3506
 
3508 3507
 /**
@@ -3511,20 +3510,20 @@  discard block
 block discarded – undo
3511 3510
  * @return array|bool
3512 3511
  */
3513 3512
 function spip_getimagesize($fichier) {
3514
-	if (!$imagesize = @getimagesize($fichier)) {
3515
-		include_spip('inc/svg');
3516
-		if ($attrs = svg_lire_attributs($fichier)) {
3517
-			[$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
3518
-			$imagesize = [
3519
-				$width,
3520
-				$height,
3521
-				IMAGETYPE_SVG,
3522
-				"width=\"{$width}\" height=\"{$height}\"",
3523
-				'mime' => 'image/svg+xml'
3524
-			];
3525
-		}
3526
-	}
3527
-	return $imagesize;
3513
+    if (!$imagesize = @getimagesize($fichier)) {
3514
+        include_spip('inc/svg');
3515
+        if ($attrs = svg_lire_attributs($fichier)) {
3516
+            [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
3517
+            $imagesize = [
3518
+                $width,
3519
+                $height,
3520
+                IMAGETYPE_SVG,
3521
+                "width=\"{$width}\" height=\"{$height}\"",
3522
+                'mime' => 'image/svg+xml'
3523
+            ];
3524
+        }
3525
+    }
3526
+    return $imagesize;
3528 3527
 }
3529 3528
 
3530 3529
 /**
@@ -3538,19 +3537,19 @@  discard block
 block discarded – undo
3538 3537
  * @param string $statut
3539 3538
  */
3540 3539
 function avertir_auteurs($nom, $message, $statut = '') {
3541
-	$alertes = $GLOBALS['meta']['message_alertes_auteurs'];
3542
-	if (
3543
-		!$alertes
3544
-		or !is_array($alertes = unserialize($alertes))
3545
-	) {
3546
-		$alertes = [];
3547
-	}
3540
+    $alertes = $GLOBALS['meta']['message_alertes_auteurs'];
3541
+    if (
3542
+        !$alertes
3543
+        or !is_array($alertes = unserialize($alertes))
3544
+    ) {
3545
+        $alertes = [];
3546
+    }
3548 3547
 
3549
-	if (!isset($alertes[$statut])) {
3550
-		$alertes[$statut] = [];
3551
-	}
3552
-	$alertes[$statut][$nom] = $message;
3553
-	ecrire_meta('message_alertes_auteurs', serialize($alertes));
3548
+    if (!isset($alertes[$statut])) {
3549
+        $alertes[$statut] = [];
3550
+    }
3551
+    $alertes[$statut][$nom] = $message;
3552
+    ecrire_meta('message_alertes_auteurs', serialize($alertes));
3554 3553
 }
3555 3554
 
3556 3555
 /**
@@ -3564,10 +3563,10 @@  discard block
 block discarded – undo
3564 3563
  * @return string|string[]
3565 3564
  */
3566 3565
 function spip_sanitize_classname($classes) {
3567
-	if (is_array($classes)) {
3568
-		return array_map('spip_sanitize_classname', $classes);
3569
-	}
3570
-	return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes);
3566
+    if (is_array($classes)) {
3567
+        return array_map('spip_sanitize_classname', $classes);
3568
+    }
3569
+    return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes);
3571 3570
 }
3572 3571
 
3573 3572
 
@@ -3592,32 +3591,32 @@  discard block
 block discarded – undo
3592 3591
  *    Avec operateur : bool.
3593 3592
  **/
3594 3593
 function spip_version_compare($v1, $v2, $op = null) {
3595
-	$v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1));
3596
-	$v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2));
3597
-	$v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule
3598
-	$v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule
3599
-
3600
-	$v1 = explode('.', $v1);
3601
-	$v2 = explode('.', $v2);
3602
-	// $v1 est toujours une version, donc sans etoile
3603
-	while (count($v1) < count($v2)) {
3604
-		$v1[] = '0';
3605
-	}
3606
-
3607
-	// $v2 peut etre une borne, donc accepte l'etoile
3608
-	$etoile = false;
3609
-	foreach ($v1 as $k => $v) {
3610
-		if (!isset($v2[$k])) {
3611
-			$v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0';
3612
-		} else {
3613
-			if ($v2[$k] == '*') {
3614
-				$etoile = true;
3615
-				$v2[$k] = $v;
3616
-			}
3617
-		}
3618
-	}
3619
-	$v1 = implode('.', $v1);
3620
-	$v2 = implode('.', $v2);
3621
-
3622
-	return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2);
3594
+    $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1));
3595
+    $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2));
3596
+    $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule
3597
+    $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule
3598
+
3599
+    $v1 = explode('.', $v1);
3600
+    $v2 = explode('.', $v2);
3601
+    // $v1 est toujours une version, donc sans etoile
3602
+    while (count($v1) < count($v2)) {
3603
+        $v1[] = '0';
3604
+    }
3605
+
3606
+    // $v2 peut etre une borne, donc accepte l'etoile
3607
+    $etoile = false;
3608
+    foreach ($v1 as $k => $v) {
3609
+        if (!isset($v2[$k])) {
3610
+            $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0';
3611
+        } else {
3612
+            if ($v2[$k] == '*') {
3613
+                $etoile = true;
3614
+                $v2[$k] = $v;
3615
+            }
3616
+        }
3617
+    }
3618
+    $v1 = implode('.', $v1);
3619
+    $v2 = implode('.', $v2);
3620
+
3621
+    return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2);
3623 3622
 }
Please login to merge, or discard this patch.
Spacing   +120 added lines, -121 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
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	// passer en minuscules (cf les balises de formulaires)
80 80
 	// et inclure le fichier
81 81
 	if (
82
-		!$inc = include_spip($dossier . ($d = strtolower($nom)))
82
+		!$inc = include_spip($dossier.($d = strtolower($nom)))
83 83
 		// si le fichier truc/machin/nom.php n'existe pas,
84 84
 		// la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions
85 85
 		and strlen(dirname($dossier)) and dirname($dossier) != '.'
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 
100 100
 	// Echec : message d'erreur
101
-	spip_log("fonction $nom ($f ou $g) indisponible" .
101
+	spip_log("fonction $nom ($f ou $g) indisponible".
102 102
 		($inc ? '' : " (fichier $d absent de $dossier)"));
103 103
 
104 104
 	include_spip('inc/minipres');
105 105
 	echo minipres(
106 106
 		_T('forum_titre_erreur'),
107
-		_T('fichier_introuvable', ['fichier' => '<b>' . spip_htmlentities($d) . '</b>']),
108
-		['all_inline' => true,'status' => 404]
107
+		_T('fichier_introuvable', ['fichier' => '<b>'.spip_htmlentities($d).'</b>']),
108
+		['all_inline' => true, 'status' => 404]
109 109
 	);
110 110
 	exit;
111 111
 }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
  *     - string : chemin du fichier trouvé
152 152
  **/
153 153
 function include_spip($f, $include = true) {
154
-	return find_in_path($f . '.php', '', $include);
154
+	return find_in_path($f.'.php', '', $include);
155 155
 }
156 156
 
157 157
 /**
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
  *     - string : chemin du fichier trouvé
172 172
  **/
173 173
 function require_spip($f) {
174
-	return find_in_path($f . '.php', '', 'required');
174
+	return find_in_path($f.'.php', '', 'required');
175 175
 }
176 176
 
177 177
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		// donc il faut l'inclure "en globals"
189 189
 		if ($f = find_in_path('mes_fonctions.php')) {
190 190
 			global $dossier_squelettes;
191
-			include_once(_ROOT_CWD . $f);
191
+			include_once(_ROOT_CWD.$f);
192 192
 		}
193 193
 
194 194
 		if (@is_readable(_CACHE_PLUGINS_FCT)) {
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	}
294 294
 
295 295
 	// appliquer notre fonction si elle existe
296
-	$fonc = 'execute_pipeline_' . strtolower($action);
296
+	$fonc = 'execute_pipeline_'.strtolower($action);
297 297
 	if (function_exists($fonc)) {
298 298
 		$val = $fonc($val);
299 299
 	} // plantage ?
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 function spip_log($message = null, $name = null) {
359 359
 	static $pre = [];
360 360
 	static $log;
361
-	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
361
+	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs);
362 362
 	if (!isset($regs[1]) or !$logname = $regs[1]) {
363 363
 		$logname = null;
364 364
 	}
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 		if (!is_string($message)) {
387 387
 			$message = print_r($message, true);
388 388
 		}
389
-		$log($pre[$niveau] . ' ' . $message, $logname);
389
+		$log($pre[$niveau].' '.$message, $logname);
390 390
 	}
391 391
 }
392 392
 
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 		$a = './';
588 588
 	}
589 589
 
590
-	$regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,';
590
+	$regexp = ',^('.str_replace('[]', '\[\]', $c).'[[]?[]]?)(=.*)?$,';
591 591
 	$ajouts = array_flip(explode('|', $c));
592 592
 	$u = is_array($v) ? $v : rawurlencode((string) $v);
593 593
 	$testv = (is_array($v) ? count($v) : strlen((string) $v));
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 			// Ajout. Pour une variable, remplacer au meme endroit,
615 615
 			// pour un tableau ce sera fait dans la prochaine boucle
616 616
 			elseif (substr($r[1], -2) != '[]') {
617
-				$url[$n] = $r[1] . '=' . $u;
617
+				$url[$n] = $r[1].'='.$u;
618 618
 				unset($ajouts[$r[1]]);
619 619
 			}
620 620
 			// Pour les tableaux on laisse tomber les valeurs de
@@ -635,11 +635,11 @@  discard block
 block discarded – undo
635 635
 	} elseif ($testv) {
636 636
 		foreach ($ajouts as $k => $n) {
637 637
 			if (!is_array($v)) {
638
-				$url[] = $k . '=' . $u;
638
+				$url[] = $k.'='.$u;
639 639
 			} else {
640
-				$id = (substr($k, -2) == '[]') ? $k : ($k . '[]');
640
+				$id = (substr($k, -2) == '[]') ? $k : ($k.'[]');
641 641
 				foreach ($v as $w) {
642
-					$url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w));
642
+					$url[] = $id.'='.(is_array($w) ? 'Array' : rawurlencode($w));
643 643
 				}
644 644
 			}
645 645
 		}
@@ -650,10 +650,10 @@  discard block
 block discarded – undo
650 650
 
651 651
 	// recomposer l'adresse
652 652
 	if ($url) {
653
-		$a .= '?' . join($sep, $url);
653
+		$a .= '?'.join($sep, $url);
654 654
 	}
655 655
 
656
-	return $a . $ancre;
656
+	return $a.$ancre;
657 657
 }
658 658
 
659 659
 /**
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
 			translitteration($ancre)
686 686
 		);
687 687
 	}
688
-	return $url . (strlen($ancre) ? '#' . $ancre : '');
688
+	return $url.(strlen($ancre) ? '#'.$ancre : '');
689 689
 }
690 690
 
691 691
 /**
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
  * @return bool
802 802
  */
803 803
 function test_plugin_actif($plugin) {
804
-	return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
804
+	return ($plugin and defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true : false;
805 805
 }
806 806
 
807 807
 /**
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
 					$value = interdire_scripts($value, -1);
934 934
 				}
935 935
 				if (!empty($options['class'])) {
936
-					$value = "<span class='" . $options['class'] . "'>$value</span>";
936
+					$value = "<span class='".$options['class']."'>$value</span>";
937 937
 				}
938 938
 				$text = str_replace("@$name@", $value, $text);
939 939
 				unset($args[$name]);
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 		// Si des variables n'ont pas ete inserees, le signaler
943 943
 		// (chaines de langues pas a jour)
944 944
 		if ($args) {
945
-			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
945
+			spip_log("$f:  variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG);
946 946
 		}
947 947
 	}
948 948
 
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
 function joli_repertoire($rep) {
967 967
 	$a = substr($rep, 0, 1);
968 968
 	if ($a <> '.' and $a <> '/') {
969
-		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
969
+		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep;
970 970
 	}
971 971
 	$rep = preg_replace(',(^\.\.\/),', '', $rep);
972 972
 
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
 			$p -= ($x * 1000);
1021 1021
 		}
1022 1022
 
1023
-		return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1023
+		return $s.sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1024 1024
 	}
1025 1025
 }
1026 1026
 
@@ -1088,7 +1088,7 @@  discard block
 block discarded – undo
1088 1088
 	if ($taches and count($taches) and !spip_connect()) {
1089 1089
 		return false;
1090 1090
 	}
1091
-	spip_log('cron !', 'jq' . _LOG_DEBUG);
1091
+	spip_log('cron !', 'jq'._LOG_DEBUG);
1092 1092
 	if ($genie = charger_fonction('genie', 'inc', true)) {
1093 1093
 		return $genie($taches);
1094 1094
 	}
@@ -1192,7 +1192,7 @@  discard block
 block discarded – undo
1192 1192
 
1193 1193
 	if ($queue_next_job_time == -1) {
1194 1194
 		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1195
-			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
1195
+			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP.'job_queue_next.txt');
1196 1196
 		}
1197 1197
 		// utiliser un cache memoire si dispo
1198 1198
 		if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
@@ -1261,8 +1261,8 @@  discard block
 block discarded – undo
1261 1261
 		$src = '';
1262 1262
 	}
1263 1263
 	if ($script) {
1264
-		$script = ("/*<![CDATA[*/\n" .
1265
-			preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1264
+		$script = ("/*<![CDATA[*/\n".
1265
+			preg_replace(',</([^>]*)>,', '<\/\1>', $script).
1266 1266
 			'/*]]>*/');
1267 1267
 	}
1268 1268
 	if ($noscript) {
@@ -1348,13 +1348,13 @@  discard block
 block discarded – undo
1348 1348
 	if ($path_base == null) {
1349 1349
 		// Chemin standard depuis l'espace public
1350 1350
 		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
1351
-			_DIR_RACINE . ':' .
1352
-			_DIR_RACINE . 'squelettes-dist/:' .
1353
-			_DIR_RACINE . 'prive/:' .
1351
+			_DIR_RACINE.':'.
1352
+			_DIR_RACINE.'squelettes-dist/:'.
1353
+			_DIR_RACINE.'prive/:'.
1354 1354
 			_DIR_RESTREINT;
1355 1355
 		// Ajouter squelettes/
1356
-		if (@is_dir(_DIR_RACINE . 'squelettes')) {
1357
-			$path = _DIR_RACINE . 'squelettes/:' . $path;
1356
+		if (@is_dir(_DIR_RACINE.'squelettes')) {
1357
+			$path = _DIR_RACINE.'squelettes/:'.$path;
1358 1358
 		}
1359 1359
 		foreach (explode(':', $path) as $dir) {
1360 1360
 			if (strlen($dir) and substr($dir, -1) != '/') {
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
 		// Et le(s) dossier(s) des squelettes nommes
1367 1367
 		if (strlen($GLOBALS['dossier_squelettes'])) {
1368 1368
 			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1369
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1369
+				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/');
1370 1370
 			}
1371 1371
 		}
1372 1372
 		$GLOBALS['path_sig'] = md5(serialize($path_full));
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
 
1378 1378
 	if (is_array($dir_path) or strlen($dir_path)) {
1379 1379
 		$tete = '';
1380
-		if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1380
+		if (reset($path_base) == _DIR_RACINE.'squelettes/') {
1381 1381
 			$tete = array_shift($path_base);
1382 1382
 		}
1383 1383
 		$dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
@@ -1398,7 +1398,7 @@  discard block
 block discarded – undo
1398 1398
 	// Et le(s) dossier(s) des squelettes nommes
1399 1399
 	if (strlen($GLOBALS['dossier_squelettes'])) {
1400 1400
 		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1401
-			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1401
+			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE).$d.'/');
1402 1402
 		}
1403 1403
 	}
1404 1404
 
@@ -1469,14 +1469,14 @@  discard block
 block discarded – undo
1469 1469
 	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1470 1470
 	if (
1471 1471
 		preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1472
-		and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg'
1472
+		and $file_svg_generique = substr($file, 0, -strlen($m[0])).'-xx.svg'
1473 1473
 		and $f = find_in_theme("$file_svg_generique")
1474 1474
 	) {
1475
-		if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) {
1475
+		if ($fsize = substr($f, 0, -6).$m[1].'.svg' and file_exists($fsize)) {
1476 1476
 			return $themefiles["$subdir$file"] = $fsize;
1477 1477
 		}
1478 1478
 		else {
1479
-			return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
1479
+			return $themefiles["$subdir$file"] = "$f?".$m[1].'px';
1480 1480
 		}
1481 1481
 	}
1482 1482
 
@@ -1486,7 +1486,7 @@  discard block
 block discarded – undo
1486 1486
 			return $themefiles["$subdir$file"] = $f;
1487 1487
 		}
1488 1488
 	}
1489
-	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1489
+	spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme');
1490 1490
 
1491 1491
 	return $themefiles["$subdir$file"] = '';
1492 1492
 }
@@ -1594,8 +1594,8 @@  discard block
 block discarded – undo
1594 1594
 			return false;
1595 1595
 		}
1596 1596
 		if ($include and !isset($inc[$dirname][$file])) {
1597
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1598
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1597
+			include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1598
+			$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
1599 1599
 		}
1600 1600
 
1601 1601
 		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
@@ -1608,14 +1608,14 @@  discard block
 block discarded – undo
1608 1608
 	}
1609 1609
 
1610 1610
 	foreach (creer_chemin() as $dir) {
1611
-		if (!isset($dirs[$a = $dir . $dirname])) {
1612
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1611
+		if (!isset($dirs[$a = $dir.$dirname])) {
1612
+			$dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a);
1613 1613
 		}
1614 1614
 		if ($dirs[$a]) {
1615
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
1615
+			if (file_exists(_ROOT_CWD.($a .= $file))) {
1616 1616
 				if ($include and !isset($inc[$dirname][$file])) {
1617
-					include_once _ROOT_CWD . $a;
1618
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1617
+					include_once _ROOT_CWD.$a;
1618
+					$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
1619 1619
 				}
1620 1620
 				if (!defined('_SAUVER_CHEMIN')) {
1621 1621
 					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
@@ -1625,7 +1625,7 @@  discard block
 block discarded – undo
1625 1625
 					define('_SAUVER_CHEMIN', true);
1626 1626
 				}
1627 1627
 
1628
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1628
+				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a;
1629 1629
 			}
1630 1630
 		}
1631 1631
 	}
@@ -1651,7 +1651,7 @@  discard block
 block discarded – undo
1651 1651
 		define('_SAUVER_CHEMIN', true);
1652 1652
 	}
1653 1653
 
1654
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1654
+	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false;
1655 1655
 }
1656 1656
 
1657 1657
 function clear_path_cache() {
@@ -1721,12 +1721,12 @@  discard block
 block discarded – undo
1721 1721
 	// cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1722 1722
 	// on a pas encore inclus flock.php
1723 1723
 	if (!function_exists('preg_files')) {
1724
-		include_once _ROOT_RESTREINT . 'inc/flock.php';
1724
+		include_once _ROOT_RESTREINT.'inc/flock.php';
1725 1725
 	}
1726 1726
 
1727 1727
 	// Parcourir le chemin
1728 1728
 	foreach (creer_chemin() as $d) {
1729
-		$f = $d . $dir;
1729
+		$f = $d.$dir;
1730 1730
 		if (@is_dir($f)) {
1731 1731
 			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
1732 1732
 			foreach ($liste as $chemin) {
@@ -1834,7 +1834,7 @@  discard block
 block discarded – undo
1834 1834
 		return $res;
1835 1835
 	}
1836 1836
 	// Sinon c'est un raccourci ou compat SPIP < 2
1837
-	if (!function_exists($f = 'generer_url_' . $entite)) {
1837
+	if (!function_exists($f = 'generer_url_'.$entite)) {
1838 1838
 		if (!function_exists($f .= '_dist')) {
1839 1839
 			$f = '';
1840 1840
 		}
@@ -1843,8 +1843,8 @@  discard block
 block discarded – undo
1843 1843
 		$url = $f($id, $args, $ancre);
1844 1844
 		if (strlen($args)) {
1845 1845
 			$url .= strstr($url, '?')
1846
-				? '&amp;' . $args
1847
-				: '?' . $args;
1846
+				? '&amp;'.$args
1847
+				: '?'.$args;
1848 1848
 		}
1849 1849
 
1850 1850
 		return $url;
@@ -1875,8 +1875,8 @@  discard block
 block discarded – undo
1875 1875
 	include_spip('base/connect_sql');
1876 1876
 	$id_type = id_table_objet($entite, $public);
1877 1877
 
1878
-	return _DIR_RACINE . get_spip_script('./')
1879
-	. '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1878
+	return _DIR_RACINE.get_spip_script('./')
1879
+	. '?'._SPIP_PAGE."=$entite&$id_type=$i&connect=$public"
1880 1880
 	. (!$args ? '' : "&$args")
1881 1881
 	. (!$ancre ? '' : "#$ancre");
1882 1882
 }
@@ -2030,7 +2030,7 @@  discard block
 block discarded – undo
2030 2030
 				!empty($_SERVER['QUERY_STRING'])
2031 2031
 				and !strpos($_SERVER['REQUEST_URI'], '?')
2032 2032
 			) {
2033
-				$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2033
+				$GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
2034 2034
 			}
2035 2035
 		}
2036 2036
 	}
@@ -2065,9 +2065,9 @@  discard block
 block discarded – undo
2065 2065
 		array_shift($myself);
2066 2066
 		$myself = implode('/', $myself);
2067 2067
 	}
2068
-	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2068
+	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/';
2069 2069
 
2070
-	$url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2070
+	$url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/');
2071 2071
 
2072 2072
 	return $url;
2073 2073
 }
@@ -2105,16 +2105,16 @@  discard block
 block discarded – undo
2105 2105
  **/
2106 2106
 function generer_url_ecrire($script = '', $args = '', $no_entities = false, $rel = false) {
2107 2107
 	if (!$rel) {
2108
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2108
+		$rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT;
2109 2109
 	} else {
2110 2110
 		if (!is_string($rel)) {
2111
-			$rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT;
2111
+			$rel = _DIR_RESTREINT ?: './'._SPIP_ECRIRE_SCRIPT;
2112 2112
 		}
2113 2113
 	}
2114 2114
 
2115 2115
 	[$script, $ancre] = array_pad(explode('#', $script), 2, null);
2116 2116
 	if ($script and ($script <> 'accueil' or $rel)) {
2117
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
2117
+		$args = "?exec=$script".(!$args ? '' : "&$args");
2118 2118
 	} elseif ($args) {
2119 2119
 		$args = "?$args";
2120 2120
 	}
@@ -2122,7 +2122,7 @@  discard block
 block discarded – undo
2122 2122
 		$args .= "#$ancre";
2123 2123
 	}
2124 2124
 
2125
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2125
+	return $rel.($no_entities ? $args : str_replace('&', '&amp;', $args));
2126 2126
 }
2127 2127
 
2128 2128
 //
@@ -2195,25 +2195,25 @@  discard block
 block discarded – undo
2195 2195
 		if (is_array($args)) {
2196 2196
 			$r = '';
2197 2197
 			foreach ($args as $k => $v) {
2198
-				$r .= '&' . $k . '=' . $v;
2198
+				$r .= '&'.$k.'='.$v;
2199 2199
 			}
2200 2200
 			$args = substr($r, 1);
2201 2201
 		}
2202 2202
 		$action .=
2203
-			(strpos($action, '?') !== false ? '&' : '?') . $args;
2203
+			(strpos($action, '?') !== false ? '&' : '?').$args;
2204 2204
 	}
2205 2205
 	if (!$no_entities) {
2206 2206
 		$action = quote_amp($action);
2207 2207
 	}
2208 2208
 
2209 2209
 	// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2210
-	return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
2210
+	return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(',^/[.]/,', '/', "/$action"));
2211 2211
 }
2212 2212
 
2213 2213
 // https://code.spip.net/@generer_url_prive
2214 2214
 function generer_url_prive($script, $args = '', $no_entities = false) {
2215 2215
 
2216
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2216
+	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php');
2217 2217
 }
2218 2218
 
2219 2219
 // Pour les formulaires en methode POST,
@@ -2248,8 +2248,7 @@  discard block
 block discarded – undo
2248 2248
 	. "><div>\n"
2249 2249
 	. "<input type='hidden' name='exec' value='$script1' />"
2250 2250
 	. $corps
2251
-	. (!$submit ? '' :
2252
-		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
2251
+	. (!$submit ? '' : ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo submit btn' type='submit' value=\"".entites_html($submit).'" /></div>'))
2253 2252
 	. "</div></form>\n";
2254 2253
 }
2255 2254
 
@@ -2274,14 +2273,14 @@  discard block
 block discarded – undo
2274 2273
 		? generer_url_ecrire(_request('exec'))
2275 2274
 		: generer_url_public();
2276 2275
 
2277
-	return "\n<form action='" .
2278
-	$h .
2279
-	"'" .
2280
-	$atts .
2281
-	">\n" .
2282
-	'<div>' .
2283
-	"\n<input type='hidden' name='action' value='$script' />" .
2284
-	$corps .
2276
+	return "\n<form action='".
2277
+	$h.
2278
+	"'".
2279
+	$atts.
2280
+	">\n".
2281
+	'<div>'.
2282
+	"\n<input type='hidden' name='action' value='$script' />".
2283
+	$corps.
2285 2284
 	'</div></form>';
2286 2285
 }
2287 2286
 
@@ -2309,7 +2308,7 @@  discard block
 block discarded – undo
2309 2308
 		: generer_url_public('', '', false, false);
2310 2309
 	$url = parametre_url($url, 'action', $script);
2311 2310
 	if ($args) {
2312
-		$url .= quote_amp('&' . $args);
2311
+		$url .= quote_amp('&'.$args);
2313 2312
 	}
2314 2313
 
2315 2314
 	if ($no_entities) {
@@ -2359,17 +2358,17 @@  discard block
 block discarded – undo
2359 2358
 
2360 2359
 	// le nom du repertoire plugins/ activables/desactivables
2361 2360
 	if (!defined('_DIR_PLUGINS')) {
2362
-		define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
2361
+		define('_DIR_PLUGINS', _DIR_RACINE.'plugins/');
2363 2362
 	}
2364 2363
 
2365 2364
 	// le nom du repertoire des extensions/ permanentes du core, toujours actives
2366 2365
 	if (!defined('_DIR_PLUGINS_DIST')) {
2367
-		define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
2366
+		define('_DIR_PLUGINS_DIST', _DIR_RACINE.'plugins-dist/');
2368 2367
 	}
2369 2368
 
2370 2369
 	// le nom du repertoire des librairies
2371 2370
 	if (!defined('_DIR_LIB')) {
2372
-		define('_DIR_LIB', _DIR_RACINE . 'lib/');
2371
+		define('_DIR_LIB', _DIR_RACINE.'lib/');
2373 2372
 	}
2374 2373
 
2375 2374
 	if (!defined('_DIR_IMG')) {
@@ -2379,29 +2378,29 @@  discard block
 block discarded – undo
2379 2378
 		define('_DIR_LOGOS', $pa);
2380 2379
 	}
2381 2380
 	if (!defined('_DIR_IMG_ICONES')) {
2382
-		define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
2381
+		define('_DIR_IMG_ICONES', _DIR_LOGOS.'icones/');
2383 2382
 	}
2384 2383
 
2385 2384
 	if (!defined('_DIR_DUMP')) {
2386
-		define('_DIR_DUMP', $ti . 'dump/');
2385
+		define('_DIR_DUMP', $ti.'dump/');
2387 2386
 	}
2388 2387
 	if (!defined('_DIR_SESSIONS')) {
2389
-		define('_DIR_SESSIONS', $ti . 'sessions/');
2388
+		define('_DIR_SESSIONS', $ti.'sessions/');
2390 2389
 	}
2391 2390
 	if (!defined('_DIR_TRANSFERT')) {
2392
-		define('_DIR_TRANSFERT', $ti . 'upload/');
2391
+		define('_DIR_TRANSFERT', $ti.'upload/');
2393 2392
 	}
2394 2393
 	if (!defined('_DIR_CACHE')) {
2395
-		define('_DIR_CACHE', $ti . 'cache/');
2394
+		define('_DIR_CACHE', $ti.'cache/');
2396 2395
 	}
2397 2396
 	if (!defined('_DIR_CACHE_XML')) {
2398
-		define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
2397
+		define('_DIR_CACHE_XML', _DIR_CACHE.'xml/');
2399 2398
 	}
2400 2399
 	if (!defined('_DIR_SKELS')) {
2401
-		define('_DIR_SKELS', _DIR_CACHE . 'skel/');
2400
+		define('_DIR_SKELS', _DIR_CACHE.'skel/');
2402 2401
 	}
2403 2402
 	if (!defined('_DIR_AIDE')) {
2404
-		define('_DIR_AIDE', _DIR_CACHE . 'aide/');
2403
+		define('_DIR_AIDE', _DIR_CACHE.'aide/');
2405 2404
 	}
2406 2405
 	if (!defined('_DIR_TMP')) {
2407 2406
 		define('_DIR_TMP', $ti);
@@ -2430,27 +2429,27 @@  discard block
 block discarded – undo
2430 2429
 	// Declaration des fichiers
2431 2430
 
2432 2431
 	if (!defined('_CACHE_PLUGINS_PATH')) {
2433
-		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
2432
+		define('_CACHE_PLUGINS_PATH', _DIR_CACHE.'charger_plugins_chemins.php');
2434 2433
 	}
2435 2434
 	if (!defined('_CACHE_PLUGINS_OPT')) {
2436
-		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
2435
+		define('_CACHE_PLUGINS_OPT', _DIR_CACHE.'charger_plugins_options.php');
2437 2436
 	}
2438 2437
 	if (!defined('_CACHE_PLUGINS_FCT')) {
2439
-		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
2438
+		define('_CACHE_PLUGINS_FCT', _DIR_CACHE.'charger_plugins_fonctions.php');
2440 2439
 	}
2441 2440
 	if (!defined('_CACHE_PIPELINES')) {
2442
-		define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
2441
+		define('_CACHE_PIPELINES', _DIR_CACHE.'charger_pipelines.php');
2443 2442
 	}
2444 2443
 	if (!defined('_CACHE_CHEMIN')) {
2445
-		define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
2444
+		define('_CACHE_CHEMIN', _DIR_CACHE.'chemin.txt');
2446 2445
 	}
2447 2446
 
2448 2447
 	# attention .php obligatoire pour ecrire_fichier_securise
2449 2448
 	if (!defined('_FILE_META')) {
2450
-		define('_FILE_META', $ti . 'meta_cache.php');
2449
+		define('_FILE_META', $ti.'meta_cache.php');
2451 2450
 	}
2452 2451
 	if (!defined('_DIR_LOG')) {
2453
-		define('_DIR_LOG', _DIR_TMP . 'log/');
2452
+		define('_DIR_LOG', _DIR_TMP.'log/');
2454 2453
 	}
2455 2454
 	if (!defined('_FILE_LOG')) {
2456 2455
 		define('_FILE_LOG', 'spip');
@@ -2467,8 +2466,8 @@  discard block
 block discarded – undo
2467 2466
 	if (!defined('_FILE_CONNECT')) {
2468 2467
 		define(
2469 2468
 			'_FILE_CONNECT',
2470
-			(@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2471
-			: (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2469
+			(@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f
2470
+			: (@is_readable($f = _DIR_RESTREINT.'inc_connect.php') ? $f
2472 2471
 			: false))
2473 2472
 		);
2474 2473
 	}
@@ -2480,7 +2479,7 @@  discard block
 block discarded – undo
2480 2479
 	if (!defined('_FILE_CHMOD')) {
2481 2480
 		define(
2482 2481
 			'_FILE_CHMOD',
2483
-			(@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2482
+			(@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f
2484 2483
 			: false)
2485 2484
 		);
2486 2485
 	}
@@ -2493,10 +2492,10 @@  discard block
 block discarded – undo
2493 2492
 		define('_FILE_TMP_SUFFIX', '.tmp.php');
2494 2493
 	}
2495 2494
 	if (!defined('_FILE_CONNECT_TMP')) {
2496
-		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2495
+		define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX);
2497 2496
 	}
2498 2497
 	if (!defined('_FILE_CHMOD_TMP')) {
2499
-		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2498
+		define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX);
2500 2499
 	}
2501 2500
 
2502 2501
 	// Definition des droits d'acces en ecriture
@@ -2514,13 +2513,13 @@  discard block
 block discarded – undo
2514 2513
 		define('_DEFAULT_CHARSET', 'utf-8');
2515 2514
 	}
2516 2515
 	if (!defined('_ROOT_PLUGINS')) {
2517
-		define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/');
2516
+		define('_ROOT_PLUGINS', _ROOT_RACINE.'plugins/');
2518 2517
 	}
2519 2518
 	if (!defined('_ROOT_PLUGINS_DIST')) {
2520
-		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/');
2519
+		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE.'plugins-dist/');
2521 2520
 	}
2522 2521
 	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2523
-		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2522
+		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2524 2523
 	}
2525 2524
 
2526 2525
 	// La taille des Log
@@ -2557,7 +2556,7 @@  discard block
 block discarded – undo
2557 2556
 	// (non surchargeable en l'etat ; attention si on utilise include_spip()
2558 2557
 	// pour le rendre surchargeable, on va provoquer un reecriture
2559 2558
 	// systematique du noyau ou une baisse de perfs => a etudier)
2560
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
2559
+	include_once _ROOT_RESTREINT.'inc/flock.php';
2561 2560
 
2562 2561
 	// charger tout de suite le path et son cache
2563 2562
 	load_path_cache();
@@ -2605,7 +2604,7 @@  discard block
 block discarded – undo
2605 2604
 			!empty($_SERVER['QUERY_STRING'])
2606 2605
 			and !strpos($_SERVER['REQUEST_URI'], '?')
2607 2606
 		) {
2608
-			$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2607
+			$GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
2609 2608
 		}
2610 2609
 	}
2611 2610
 
@@ -2641,7 +2640,7 @@  discard block
 block discarded – undo
2641 2640
 		) {
2642 2641
 			if (isset($GLOBALS['meta']['adresse_site'])) {
2643 2642
 				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2644
-				$uri_ref = ($uri_ref['path'] ?? '') . '/';
2643
+				$uri_ref = ($uri_ref['path'] ?? '').'/';
2645 2644
 			} else {
2646 2645
 				$uri_ref = '';
2647 2646
 			}
@@ -2735,7 +2734,7 @@  discard block
 block discarded – undo
2735 2734
 	}
2736 2735
 	if (!defined('_CACHE_RUBRIQUES')) {
2737 2736
 		/** Fichier cache pour le navigateur de rubrique du bandeau */
2738
-		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2737
+		define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt');
2739 2738
 	}
2740 2739
 	if (!defined('_CACHE_RUBRIQUES_MAX')) {
2741 2740
 		/** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
@@ -2839,7 +2838,7 @@  discard block
 block discarded – undo
2839 2838
 					$memory *= 1024;
2840 2839
 			}
2841 2840
 			if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) {
2842
-				@ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M');
2841
+				@ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN.'M');
2843 2842
 				if (trim(ini_get('memory_limit')) != $m) {
2844 2843
 					if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2845 2844
 						define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
@@ -2990,7 +2989,7 @@  discard block
 block discarded – undo
2990 2989
 					}
2991 2990
 					if (isset($GLOBALS['visiteur_session']['nom'])) {
2992 2991
 						spip_log($GLOBALS['visiteur_session']['nom']
2993
-							. ' ' . _VAR_MODE);
2992
+							. ' '._VAR_MODE);
2994 2993
 					}
2995 2994
 				} // pas autorise ?
2996 2995
 				else {
@@ -3005,7 +3004,7 @@  discard block
 block discarded – undo
3005 3004
 						if (strpos($self, 'page=login') === false) {
3006 3005
 							include_spip('inc/headers');
3007 3006
 							$redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&');
3008
-							redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true));
3007
+							redirige_par_entete(generer_url_public('login', 'url='.rawurlencode($redirect), true));
3009 3008
 						}
3010 3009
 					}
3011 3010
 					// sinon tant pis
@@ -3049,10 +3048,10 @@  discard block
 block discarded – undo
3049 3048
 	// mais on risque de perturber des plugins en initialisant trop tot
3050 3049
 	// certaines constantes
3051 3050
 	@spip_initialisation_core(
3052
-		(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3053
-		(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3054
-		(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3055
-		(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3051
+		(_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES),
3052
+		(_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES),
3053
+		(_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES),
3054
+		(_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES)
3056 3055
 	);
3057 3056
 
3058 3057
 	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
@@ -3085,7 +3084,7 @@  discard block
 block discarded – undo
3085 3084
 	}
3086 3085
 
3087 3086
 	$h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3088
-	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3087
+	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) {
3089 3088
 		$session = charger_fonction('session', 'inc');
3090 3089
 		if ($session()) {
3091 3090
 			return $GLOBALS['visiteur_session']['statut'];
@@ -3165,7 +3164,7 @@  discard block
 block discarded – undo
3165 3164
 			'definir_session',
3166 3165
 			$GLOBALS['visiteur_session']
3167 3166
 				? serialize($GLOBALS['visiteur_session'])
3168
-				. '_' . @$_COOKIE['spip_session']
3167
+				. '_'.@$_COOKIE['spip_session']
3169 3168
 				: ''
3170 3169
 		);
3171 3170
 		$session = $s ? substr(md5($s), 0, 8) : '';
@@ -3321,11 +3320,11 @@  discard block
 block discarded – undo
3321 3320
 	$GLOBALS['_INC_PUBLIC']++;
3322 3321
 
3323 3322
 	// fix #4235
3324
-	$cache_utilise_session_appelant	= ($GLOBALS['cache_utilise_session'] ?? null);
3323
+	$cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null);
3325 3324
 
3326 3325
 
3327 3326
 	foreach (is_array($fond) ? $fond : [$fond] as $f) {
3328
-		unset($GLOBALS['cache_utilise_session']);	// fix #4235
3327
+		unset($GLOBALS['cache_utilise_session']); // fix #4235
3329 3328
 
3330 3329
 		$page = evaluer_fond($f, $contexte, $connect);
3331 3330
 		if ($page === '') {
@@ -3410,7 +3409,7 @@  discard block
 block discarded – undo
3410 3409
  * @return array|string
3411 3410
  */
3412 3411
 function trouver_fond($nom, $dir = '', $pathinfo = false) {
3413
-	$f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3412
+	$f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : '');
3414 3413
 	if (!$pathinfo) {
3415 3414
 		return $f;
3416 3415
 	}
Please login to merge, or discard this patch.