Completed
Push — master ( 073957...bb1fc1 )
by cam
01:05
created
ecrire/inc/utils.php 2 patches
Indentation   +2247 added lines, -2248 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,71 +48,71 @@  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
-		$inc ?
108
-			_T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>'])
109
-			. '<br />'
110
-			. _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>'])
111
-			:
112
-			_T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']),
113
-		['all_inline' => true,'status' => 404]
114
-	);
115
-	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
+        $inc ?
108
+            _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>'])
109
+            . '<br />'
110
+            . _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>'])
111
+            :
112
+            _T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']),
113
+        ['all_inline' => true,'status' => 404]
114
+    );
115
+    exit;
116 116
 }
117 117
 
118 118
 /**
@@ -122,17 +122,17 @@  discard block
 block discarded – undo
122 122
  * @return bool
123 123
  */
124 124
 function include_once_check($file) {
125
-	if (file_exists($file)) {
126
-		include_once $file;
125
+    if (file_exists($file)) {
126
+        include_once $file;
127 127
 
128
-		return true;
129
-	}
130
-	$crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : '');
131
-	$crash = ($crash ?: []);
132
-	$crash[$file] = true;
133
-	ecrire_meta('message_crash_plugins', serialize($crash));
128
+        return true;
129
+    }
130
+    $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : '');
131
+    $crash = ($crash ?: []);
132
+    $crash[$file] = true;
133
+    ecrire_meta('message_crash_plugins', serialize($crash));
134 134
 
135
-	return false;
135
+    return false;
136 136
 }
137 137
 
138 138
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
  *     - string : chemin du fichier trouvé
157 157
  **/
158 158
 function include_spip($f, $include = true) {
159
-	return find_in_path($f . '.php', '', $include);
159
+    return find_in_path($f . '.php', '', $include);
160 160
 }
161 161
 
162 162
 /**
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
  *     - string : chemin du fichier trouvé
177 177
  **/
178 178
 function require_spip($f) {
179
-	return find_in_path($f . '.php', '', 'required');
179
+    return find_in_path($f . '.php', '', 'required');
180 180
 }
181 181
 
182 182
 
@@ -185,27 +185,27 @@  discard block
 block discarded – undo
185 185
  * quand on a besoin dans le PHP de filtres/fonctions qui y sont definis
186 186
  */
187 187
 function include_fichiers_fonctions() {
188
-	static $done = false;
189
-	if (!$done) {
190
-		include_spip('inc/lang');
191
-
192
-		// NB: mes_fonctions peut initialiser $dossier_squelettes (old-style)
193
-		// donc il faut l'inclure "en globals"
194
-		if ($f = find_in_path('mes_fonctions.php')) {
195
-			global $dossier_squelettes;
196
-			include_once(_ROOT_CWD . $f);
197
-		}
198
-
199
-		if (@is_readable(_CACHE_PLUGINS_FCT)) {
200
-			// chargement optimise precompile
201
-			include_once(_CACHE_PLUGINS_FCT);
202
-		}
203
-		if (test_espace_prive()) {
204
-			include_spip('inc/filtres_ecrire');
205
-		}
206
-		include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises..
207
-		$done = true;
208
-	}
188
+    static $done = false;
189
+    if (!$done) {
190
+        include_spip('inc/lang');
191
+
192
+        // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style)
193
+        // donc il faut l'inclure "en globals"
194
+        if ($f = find_in_path('mes_fonctions.php')) {
195
+            global $dossier_squelettes;
196
+            include_once(_ROOT_CWD . $f);
197
+        }
198
+
199
+        if (@is_readable(_CACHE_PLUGINS_FCT)) {
200
+            // chargement optimise precompile
201
+            include_once(_CACHE_PLUGINS_FCT);
202
+        }
203
+        if (test_espace_prive()) {
204
+            include_spip('inc/filtres_ecrire');
205
+        }
206
+        include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises..
207
+        $done = true;
208
+    }
209 209
 }
210 210
 
211 211
 /**
@@ -231,23 +231,23 @@  discard block
 block discarded – undo
231 231
  *     Les paramètres du pipeline modifiés
232 232
  **/
233 233
 function minipipe($fonc, &$val) {
234
-	// fonction
235
-	if (function_exists($fonc)) {
236
-		$val = $fonc($val);
237
-	} // Class::Methode
238
-	else {
239
-		if (
240
-			preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs)
241
-			and $methode = [$regs[1], $regs[2]]
242
-			and is_callable($methode)
243
-		) {
244
-			$val = $methode($val);
245
-		} else {
246
-			spip_log("Erreur - '$fonc' non definie !");
247
-		}
248
-	}
249
-
250
-	return $val;
234
+    // fonction
235
+    if (function_exists($fonc)) {
236
+        $val = $fonc($val);
237
+    } // Class::Methode
238
+    else {
239
+        if (
240
+            preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs)
241
+            and $methode = [$regs[1], $regs[2]]
242
+            and is_callable($methode)
243
+        ) {
244
+            $val = $methode($val);
245
+        } else {
246
+            spip_log("Erreur - '$fonc' non definie !");
247
+        }
248
+    }
249
+
250
+    return $val;
251 251
 }
252 252
 
253 253
 /**
@@ -278,46 +278,46 @@  discard block
 block discarded – undo
278 278
  *     Résultat
279 279
  */
280 280
 function pipeline($action, $val = null) {
281
-	static $charger;
282
-
283
-	// chargement initial des fonctions mises en cache, ou generation du cache
284
-	if (!$charger) {
285
-		if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) {
286
-			include_spip('inc/plugin');
287
-			// generer les fichiers php precompiles
288
-			// de chargement des plugins et des pipelines
289
-			actualise_plugins_actifs();
290
-			if (!($ok = @is_readable($charger))) {
291
-				spip_log("fichier $charger pas cree");
292
-			}
293
-		}
294
-
295
-		if ($ok) {
296
-			include_once $charger;
297
-		}
298
-	}
299
-
300
-	// appliquer notre fonction si elle existe
301
-	$fonc = 'execute_pipeline_' . strtolower($action);
302
-	if (function_exists($fonc)) {
303
-		$val = $fonc($val);
304
-	} // plantage ?
305
-	else {
306
-		spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR);
307
-	}
308
-
309
-	// si le flux est une table avec 2 cle args&data
310
-	// on ne ressort du pipe que les donnees dans 'data'
311
-	// array_key_exists pour php 4.1.0
312
-	if (
313
-		is_array($val)
314
-		and count($val) == 2
315
-		and (array_key_exists('data', $val))
316
-	) {
317
-		$val = $val['data'];
318
-	}
319
-
320
-	return $val;
281
+    static $charger;
282
+
283
+    // chargement initial des fonctions mises en cache, ou generation du cache
284
+    if (!$charger) {
285
+        if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) {
286
+            include_spip('inc/plugin');
287
+            // generer les fichiers php precompiles
288
+            // de chargement des plugins et des pipelines
289
+            actualise_plugins_actifs();
290
+            if (!($ok = @is_readable($charger))) {
291
+                spip_log("fichier $charger pas cree");
292
+            }
293
+        }
294
+
295
+        if ($ok) {
296
+            include_once $charger;
297
+        }
298
+    }
299
+
300
+    // appliquer notre fonction si elle existe
301
+    $fonc = 'execute_pipeline_' . strtolower($action);
302
+    if (function_exists($fonc)) {
303
+        $val = $fonc($val);
304
+    } // plantage ?
305
+    else {
306
+        spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR);
307
+    }
308
+
309
+    // si le flux est une table avec 2 cle args&data
310
+    // on ne ressort du pipe que les donnees dans 'data'
311
+    // array_key_exists pour php 4.1.0
312
+    if (
313
+        is_array($val)
314
+        and count($val) == 2
315
+        and (array_key_exists('data', $val))
316
+    ) {
317
+        $val = $val['data'];
318
+    }
319
+
320
+    return $val;
321 321
 }
322 322
 
323 323
 /**
@@ -361,38 +361,38 @@  discard block
 block discarded – undo
361 361
  *     paramètre est planté pour cause de compatibilité ascendante.
362 362
  */
363 363
 function spip_log($message = null, $name = null) {
364
-	static $pre = [];
365
-	static $log;
366
-	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
367
-	if (!isset($regs[1]) or !$logname = $regs[1]) {
368
-		$logname = null;
369
-	}
370
-	if (!isset($regs[2])) {
371
-		$niveau = _LOG_INFO;
372
-	}
373
-	else {
374
-		$niveau = intval($regs[2]);
375
-	}
376
-
377
-	if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) {
378
-		if (!$pre) {
379
-			$pre = [
380
-				_LOG_HS => 'HS:',
381
-				_LOG_ALERTE_ROUGE => 'ALERTE:',
382
-				_LOG_CRITIQUE => 'CRITIQUE:',
383
-				_LOG_ERREUR => 'ERREUR:',
384
-				_LOG_AVERTISSEMENT => 'WARNING:',
385
-				_LOG_INFO_IMPORTANTE => '!INFO:',
386
-				_LOG_INFO => 'info:',
387
-				_LOG_DEBUG => 'debug:'
388
-			];
389
-			$log = charger_fonction('log', 'inc');
390
-		}
391
-		if (!is_string($message)) {
392
-			$message = print_r($message, true);
393
-		}
394
-		$log($pre[$niveau] . ' ' . $message, $logname);
395
-	}
364
+    static $pre = [];
365
+    static $log;
366
+    preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
367
+    if (!isset($regs[1]) or !$logname = $regs[1]) {
368
+        $logname = null;
369
+    }
370
+    if (!isset($regs[2])) {
371
+        $niveau = _LOG_INFO;
372
+    }
373
+    else {
374
+        $niveau = intval($regs[2]);
375
+    }
376
+
377
+    if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) {
378
+        if (!$pre) {
379
+            $pre = [
380
+                _LOG_HS => 'HS:',
381
+                _LOG_ALERTE_ROUGE => 'ALERTE:',
382
+                _LOG_CRITIQUE => 'CRITIQUE:',
383
+                _LOG_ERREUR => 'ERREUR:',
384
+                _LOG_AVERTISSEMENT => 'WARNING:',
385
+                _LOG_INFO_IMPORTANTE => '!INFO:',
386
+                _LOG_INFO => 'info:',
387
+                _LOG_DEBUG => 'debug:'
388
+            ];
389
+            $log = charger_fonction('log', 'inc');
390
+        }
391
+        if (!is_string($message)) {
392
+            $message = print_r($message, true);
393
+        }
394
+        $log($pre[$niveau] . ' ' . $message, $logname);
395
+    }
396 396
 }
397 397
 
398 398
 /**
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
  * @param array $opt Tableau d'options
404 404
  **/
405 405
 function journal($phrase, $opt = []) {
406
-	$journal = charger_fonction('journal', 'inc');
407
-	$journal($phrase, $opt);
406
+    $journal = charger_fonction('journal', 'inc');
407
+    $journal($phrase, $opt);
408 408
 }
409 409
 
410 410
 
@@ -423,37 +423,37 @@  discard block
 block discarded – undo
423 423
  **/
424 424
 function _request($var, $c = false) {
425 425
 
426
-	if (is_array($c)) {
427
-		return $c[$var] ?? null;
428
-	}
429
-
430
-	if (isset($_GET[$var])) {
431
-		$a = $_GET[$var];
432
-	} elseif (isset($_POST[$var])) {
433
-		$a = $_POST[$var];
434
-	} else {
435
-		return null;
436
-	}
437
-
438
-	// Si on est en ajax et en POST tout a ete encode
439
-	// via encodeURIComponent, il faut donc repasser
440
-	// dans le charset local...
441
-	if (
442
-		defined('_AJAX')
443
-		and _AJAX
444
-		and isset($GLOBALS['meta']['charset'])
445
-		and $GLOBALS['meta']['charset'] != 'utf-8'
446
-		and is_string($a)
447
-		// check rapide mais pas fiable
448
-		and preg_match(',[\x80-\xFF],', $a)
449
-		// check fiable
450
-		and include_spip('inc/charsets')
451
-		and is_utf8($a)
452
-	) {
453
-		return importer_charset($a, 'utf-8');
454
-	}
455
-
456
-	return $a;
426
+    if (is_array($c)) {
427
+        return $c[$var] ?? null;
428
+    }
429
+
430
+    if (isset($_GET[$var])) {
431
+        $a = $_GET[$var];
432
+    } elseif (isset($_POST[$var])) {
433
+        $a = $_POST[$var];
434
+    } else {
435
+        return null;
436
+    }
437
+
438
+    // Si on est en ajax et en POST tout a ete encode
439
+    // via encodeURIComponent, il faut donc repasser
440
+    // dans le charset local...
441
+    if (
442
+        defined('_AJAX')
443
+        and _AJAX
444
+        and isset($GLOBALS['meta']['charset'])
445
+        and $GLOBALS['meta']['charset'] != 'utf-8'
446
+        and is_string($a)
447
+        // check rapide mais pas fiable
448
+        and preg_match(',[\x80-\xFF],', $a)
449
+        // check fiable
450
+        and include_spip('inc/charsets')
451
+        and is_utf8($a)
452
+    ) {
453
+        return importer_charset($a, 'utf-8');
454
+    }
455
+
456
+    return $a;
457 457
 }
458 458
 
459 459
 
@@ -471,22 +471,22 @@  discard block
 block discarded – undo
471 471
  *     - false sinon
472 472
  **/
473 473
 function set_request($var, $val = null, $c = false) {
474
-	if (is_array($c)) {
475
-		unset($c[$var]);
476
-		if ($val !== null) {
477
-			$c[$var] = $val;
478
-		}
474
+    if (is_array($c)) {
475
+        unset($c[$var]);
476
+        if ($val !== null) {
477
+            $c[$var] = $val;
478
+        }
479 479
 
480
-		return $c;
481
-	}
480
+        return $c;
481
+    }
482 482
 
483
-	unset($_GET[$var]);
484
-	unset($_POST[$var]);
485
-	if ($val !== null) {
486
-		$_GET[$var] = $val;
487
-	}
483
+    unset($_GET[$var]);
484
+    unset($_POST[$var]);
485
+    if ($val !== null) {
486
+        $_GET[$var] = $val;
487
+    }
488 488
 
489
-	return false; # n'affecte pas $c
489
+    return false; # n'affecte pas $c
490 490
 }
491 491
 
492 492
 /**
@@ -506,25 +506,25 @@  discard block
 block discarded – undo
506 506
  * @return array|mixed|string
507 507
  */
508 508
 function spip_sanitize_from_request($value, $key, $sanitize_function = 'entites_html') {
509
-	if (is_array($value)) {
510
-		if ($key == '*') {
511
-			$key = array_keys($value);
512
-		}
513
-		if (!is_array($key)) {
514
-			$key = [$key];
515
-		}
516
-		foreach ($key as $k) {
517
-			if (!empty($value[$k])) {
518
-				$value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function);
519
-			}
520
-		}
521
-		return $value;
522
-	}
523
-	// si la valeur vient des GET ou POST on la sanitize
524
-	if (!empty($value) and $value == _request($key)) {
525
-		$value = $sanitize_function($value);
526
-	}
527
-	return $value;
509
+    if (is_array($value)) {
510
+        if ($key == '*') {
511
+            $key = array_keys($value);
512
+        }
513
+        if (!is_array($key)) {
514
+            $key = [$key];
515
+        }
516
+        foreach ($key as $k) {
517
+            if (!empty($value[$k])) {
518
+                $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function);
519
+            }
520
+        }
521
+        return $value;
522
+    }
523
+    // si la valeur vient des GET ou POST on la sanitize
524
+    if (!empty($value) and $value == _request($key)) {
525
+        $value = $sanitize_function($value);
526
+    }
527
+    return $value;
528 528
 }
529 529
 
530 530
 /**
@@ -532,23 +532,22 @@  discard block
 block discarded – undo
532 532
  *
533 533
  * On est sur le web, on exclut certains protocoles,
534 534
  * notamment 'file://', 'php://' et d'autres…
535
-
536 535
  * @param string $url
537 536
  * @return bool
538 537
  */
539 538
 function tester_url_absolue($url) {
540
-	$url = trim($url ?? '');
541
-	if ($url && preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) {
542
-		if (
543
-			isset($m[1])
544
-			and $p = strtolower(rtrim($m[1], ':'))
545
-			and in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip'])
546
-		) {
547
-			return false;
548
-		}
549
-		return true;
550
-	}
551
-	return false;
539
+    $url = trim($url ?? '');
540
+    if ($url && preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) {
541
+        if (
542
+            isset($m[1])
543
+            and $p = strtolower(rtrim($m[1], ':'))
544
+            and in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip'])
545
+        ) {
546
+            return false;
547
+        }
548
+        return true;
549
+    }
550
+    return false;
552 551
 }
553 552
 
554 553
 /**
@@ -570,100 +569,100 @@  discard block
 block discarded – undo
570 569
  * @return string URL
571 570
  */
572 571
 function parametre_url($url, $c, $v = null, $sep = '&amp;') {
573
-	// requete erronnee : plusieurs variable dans $c et aucun $v
574
-	if (strpos($c, '|') !== false and is_null($v)) {
575
-		return null;
576
-	}
577
-
578
-	// lever l'#ancre
579
-	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
580
-		$url = $r[1];
581
-		$ancre = $r[2];
582
-	} else {
583
-		$ancre = '';
584
-	}
585
-
586
-	// eclater
587
-	$url = preg_split(',[?]|&amp;|&,', $url);
588
-
589
-	// recuperer la base
590
-	$a = array_shift($url);
591
-	if (!$a) {
592
-		$a = './';
593
-	}
594
-
595
-	// preparer la regexp de maniere securisee
596
-	$regexp = explode('|', $c);
597
-	foreach ($regexp as $r => $e) {
598
-		$regexp[$r] = str_replace('[]', '\[\]', preg_replace(',[^\w\d\[\]-],', '', $e));
599
-	}
600
-	$regexp = ',^(' . implode('|', $regexp) . '[[]?[]]?)(=.*)?$,';
601
-	$ajouts = array_flip(explode('|', $c));
602
-	$u = is_array($v) ? $v : rawurlencode((string) $v);
603
-	$testv = (is_array($v) ? count($v) : strlen((string) $v));
604
-	$v_read = null;
605
-	// lire les variables et agir
606
-	foreach ($url as $n => $val) {
607
-		if (preg_match($regexp, urldecode($val), $r)) {
608
-			$r = array_pad($r, 3, null);
609
-			if ($v === null) {
610
-				// c'est un tableau, on memorise les valeurs
611
-				if (substr($r[1], -2) == '[]') {
612
-					if (!$v_read) {
613
-						$v_read = [];
614
-					}
615
-					$v_read[] = $r[2] ? substr($r[2], 1) : '';
616
-				} // c'est un scalaire, on retourne direct
617
-				else {
618
-					return $r[2] ? substr($r[2], 1) : '';
619
-				}
620
-			} // suppression
621
-			elseif (!$testv) {
622
-				unset($url[$n]);
623
-			}
624
-			// Ajout. Pour une variable, remplacer au meme endroit,
625
-			// pour un tableau ce sera fait dans la prochaine boucle
626
-			elseif (substr($r[1], -2) != '[]') {
627
-				$url[$n] = $r[1] . '=' . $u;
628
-				unset($ajouts[$r[1]]);
629
-			}
630
-			// Pour les tableaux on laisse tomber les valeurs de
631
-			// départ, on remplira à l'étape suivante
632
-			else {
633
-				unset($url[$n]);
634
-			}
635
-		}
636
-	}
637
-
638
-	// traiter les parametres pas encore trouves
639
-	if (
640
-		$v === null
641
-		and $args = func_get_args()
642
-		and count($args) == 2
643
-	) {
644
-		return $v_read; // rien trouve ou un tableau
645
-	} elseif ($testv) {
646
-		foreach ($ajouts as $k => $n) {
647
-			if (!is_array($v)) {
648
-				$url[] = $k . '=' . $u;
649
-			} else {
650
-				$id = (substr($k, -2) == '[]') ? $k : ($k . '[]');
651
-				foreach ($v as $w) {
652
-					$url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w));
653
-				}
654
-			}
655
-		}
656
-	}
657
-
658
-	// eliminer les vides
659
-	$url = array_filter($url);
660
-
661
-	// recomposer l'adresse
662
-	if ($url) {
663
-		$a .= '?' . join($sep, $url);
664
-	}
665
-
666
-	return $a . $ancre;
572
+    // requete erronnee : plusieurs variable dans $c et aucun $v
573
+    if (strpos($c, '|') !== false and is_null($v)) {
574
+        return null;
575
+    }
576
+
577
+    // lever l'#ancre
578
+    if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
579
+        $url = $r[1];
580
+        $ancre = $r[2];
581
+    } else {
582
+        $ancre = '';
583
+    }
584
+
585
+    // eclater
586
+    $url = preg_split(',[?]|&amp;|&,', $url);
587
+
588
+    // recuperer la base
589
+    $a = array_shift($url);
590
+    if (!$a) {
591
+        $a = './';
592
+    }
593
+
594
+    // preparer la regexp de maniere securisee
595
+    $regexp = explode('|', $c);
596
+    foreach ($regexp as $r => $e) {
597
+        $regexp[$r] = str_replace('[]', '\[\]', preg_replace(',[^\w\d\[\]-],', '', $e));
598
+    }
599
+    $regexp = ',^(' . implode('|', $regexp) . '[[]?[]]?)(=.*)?$,';
600
+    $ajouts = array_flip(explode('|', $c));
601
+    $u = is_array($v) ? $v : rawurlencode((string) $v);
602
+    $testv = (is_array($v) ? count($v) : strlen((string) $v));
603
+    $v_read = null;
604
+    // lire les variables et agir
605
+    foreach ($url as $n => $val) {
606
+        if (preg_match($regexp, urldecode($val), $r)) {
607
+            $r = array_pad($r, 3, null);
608
+            if ($v === null) {
609
+                // c'est un tableau, on memorise les valeurs
610
+                if (substr($r[1], -2) == '[]') {
611
+                    if (!$v_read) {
612
+                        $v_read = [];
613
+                    }
614
+                    $v_read[] = $r[2] ? substr($r[2], 1) : '';
615
+                } // c'est un scalaire, on retourne direct
616
+                else {
617
+                    return $r[2] ? substr($r[2], 1) : '';
618
+                }
619
+            } // suppression
620
+            elseif (!$testv) {
621
+                unset($url[$n]);
622
+            }
623
+            // Ajout. Pour une variable, remplacer au meme endroit,
624
+            // pour un tableau ce sera fait dans la prochaine boucle
625
+            elseif (substr($r[1], -2) != '[]') {
626
+                $url[$n] = $r[1] . '=' . $u;
627
+                unset($ajouts[$r[1]]);
628
+            }
629
+            // Pour les tableaux on laisse tomber les valeurs de
630
+            // départ, on remplira à l'étape suivante
631
+            else {
632
+                unset($url[$n]);
633
+            }
634
+        }
635
+    }
636
+
637
+    // traiter les parametres pas encore trouves
638
+    if (
639
+        $v === null
640
+        and $args = func_get_args()
641
+        and count($args) == 2
642
+    ) {
643
+        return $v_read; // rien trouve ou un tableau
644
+    } elseif ($testv) {
645
+        foreach ($ajouts as $k => $n) {
646
+            if (!is_array($v)) {
647
+                $url[] = $k . '=' . $u;
648
+            } else {
649
+                $id = (substr($k, -2) == '[]') ? $k : ($k . '[]');
650
+                foreach ($v as $w) {
651
+                    $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w));
652
+                }
653
+            }
654
+        }
655
+    }
656
+
657
+    // eliminer les vides
658
+    $url = array_filter($url);
659
+
660
+    // recomposer l'adresse
661
+    if ($url) {
662
+        $a .= '?' . join($sep, $url);
663
+    }
664
+
665
+    return $a . $ancre;
667 666
 }
668 667
 
669 668
 /**
@@ -681,21 +680,21 @@  discard block
 block discarded – undo
681 680
  * @return string
682 681
  */
683 682
 function ancre_url($url, $ancre) {
684
-	// lever l'#ancre
685
-	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
686
-		$url = $r[1];
687
-	}
688
-	if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
689
-		if (!function_exists('translitteration')) {
690
-			include_spip('inc/charsets');
691
-		}
692
-		$ancre = preg_replace(
693
-			['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'],
694
-			['', '-'],
695
-			translitteration($ancre)
696
-		);
697
-	}
698
-	return $url . (strlen($ancre) ? '#' . $ancre : '');
683
+    // lever l'#ancre
684
+    if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
685
+        $url = $r[1];
686
+    }
687
+    if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
688
+        if (!function_exists('translitteration')) {
689
+            include_spip('inc/charsets');
690
+        }
691
+        $ancre = preg_replace(
692
+            ['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'],
693
+            ['', '-'],
694
+            translitteration($ancre)
695
+        );
696
+    }
697
+    return $url . (strlen($ancre) ? '#' . $ancre : '');
699 698
 }
700 699
 
701 700
 /**
@@ -705,16 +704,16 @@  discard block
 block discarded – undo
705 704
  * @return string
706 705
  */
707 706
 function nettoyer_uri($reset = null) {
708
-	static $done = false;
709
-	static $propre = '';
710
-	if (!is_null($reset)) {
711
-		return $propre = $reset;
712
-	}
713
-	if ($done) {
714
-		return $propre;
715
-	}
716
-	$done = true;
717
-	return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);
707
+    static $done = false;
708
+    static $propre = '';
709
+    if (!is_null($reset)) {
710
+        return $propre = $reset;
711
+    }
712
+    if ($done) {
713
+        return $propre;
714
+    }
715
+    $done = true;
716
+    return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);
718 717
 }
719 718
 
720 719
 /**
@@ -726,16 +725,16 @@  discard block
 block discarded – undo
726 725
  * @return string
727 726
  */
728 727
 function nettoyer_uri_var($request_uri) {
729
-	$uri1 = $request_uri;
730
-	do {
731
-		$uri = $uri1;
732
-		$uri1 = preg_replace(
733
-			',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i',
734
-			'\1',
735
-			$uri
736
-		);
737
-	} while ($uri <> $uri1);
738
-	return preg_replace(',[?&]$,', '', $uri1);
728
+    $uri1 = $request_uri;
729
+    do {
730
+        $uri = $uri1;
731
+        $uri1 = preg_replace(
732
+            ',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i',
733
+            '\1',
734
+            $uri
735
+        );
736
+    } while ($uri <> $uri1);
737
+    return preg_replace(',[?&]$,', '', $uri1);
739 738
 }
740 739
 
741 740
 
@@ -749,48 +748,48 @@  discard block
 block discarded – undo
749 748
  *    URL vers soi-même
750 749
  **/
751 750
 function self($amp = '&amp;', $root = false) {
752
-	$url = nettoyer_uri();
753
-	if (
754
-		!$root
755
-		and (
756
-			// si pas de profondeur on peut tronquer
757
-			$GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
758
-			// sinon c'est OK si _SET_HTML_BASE a ete force a false
759
-			or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE))
760
-	) {
761
-		$url = preg_replace(',^[^?]*/,', '', $url);
762
-	}
763
-	// ajouter le cas echeant les variables _POST['id_...']
764
-	foreach ($_POST as $v => $c) {
765
-		if (substr($v, 0, 3) == 'id_') {
766
-			$url = parametre_url($url, $v, $c, '&');
767
-		}
768
-	}
769
-
770
-	// supprimer les variables sans interet
771
-	if (test_espace_prive()) {
772
-		$url = preg_replace(',([?&])('
773
-			. 'lang|show_docs|'
774
-			. 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
775
-		$url = preg_replace(',([?&])[&]+,', '\1', $url);
776
-		$url = preg_replace(',[&]$,', '\1', $url);
777
-	}
778
-
779
-	// eviter les hacks
780
-	include_spip('inc/filtres_mini');
781
-	$url = spip_htmlspecialchars($url);
782
-
783
-	$url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url);
784
-
785
-	// &amp; ?
786
-	if ($amp != '&amp;') {
787
-		$url = str_replace('&amp;', $amp, $url);
788
-	}
789
-
790
-	// Si ca demarre par ? ou vide, donner './'
791
-	$url = preg_replace(',^([?].*)?$,', './\1', $url);
792
-
793
-	return $url;
751
+    $url = nettoyer_uri();
752
+    if (
753
+        !$root
754
+        and (
755
+            // si pas de profondeur on peut tronquer
756
+            $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
757
+            // sinon c'est OK si _SET_HTML_BASE a ete force a false
758
+            or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE))
759
+    ) {
760
+        $url = preg_replace(',^[^?]*/,', '', $url);
761
+    }
762
+    // ajouter le cas echeant les variables _POST['id_...']
763
+    foreach ($_POST as $v => $c) {
764
+        if (substr($v, 0, 3) == 'id_') {
765
+            $url = parametre_url($url, $v, $c, '&');
766
+        }
767
+    }
768
+
769
+    // supprimer les variables sans interet
770
+    if (test_espace_prive()) {
771
+        $url = preg_replace(',([?&])('
772
+            . 'lang|show_docs|'
773
+            . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
774
+        $url = preg_replace(',([?&])[&]+,', '\1', $url);
775
+        $url = preg_replace(',[&]$,', '\1', $url);
776
+    }
777
+
778
+    // eviter les hacks
779
+    include_spip('inc/filtres_mini');
780
+    $url = spip_htmlspecialchars($url);
781
+
782
+    $url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url);
783
+
784
+    // &amp; ?
785
+    if ($amp != '&amp;') {
786
+        $url = str_replace('&amp;', $amp, $url);
787
+    }
788
+
789
+    // Si ca demarre par ? ou vide, donner './'
790
+    $url = preg_replace(',^([?].*)?$,', './\1', $url);
791
+
792
+    return $url;
794 793
 }
795 794
 
796 795
 
@@ -801,7 +800,7 @@  discard block
 block discarded – undo
801 800
  *     true si c'est le cas, false sinon.
802 801
  */
803 802
 function test_espace_prive() {
804
-	return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false;
803
+    return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false;
805 804
 }
806 805
 
807 806
 /**
@@ -811,7 +810,7 @@  discard block
 block discarded – undo
811 810
  * @return bool
812 811
  */
813 812
 function test_plugin_actif($plugin) {
814
-	return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
813
+    return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
815 814
 }
816 815
 
817 816
 /**
@@ -842,52 +841,52 @@  discard block
 block discarded – undo
842 841
  *     Texte
843 842
  */
844 843
 function _T($texte, $args = [], $options = []) {
845
-	static $traduire = false;
846
-	$o = ['class' => '', 'force' => true, 'sanitize' => true];
847
-	if ($options) {
848
-		// support de l'ancien argument $class
849
-		if (is_string($options)) {
850
-			$options = ['class' => $options];
851
-		}
852
-		$o = array_merge($o, $options);
853
-	}
854
-
855
-	if (!$traduire) {
856
-		$traduire = charger_fonction('traduire', 'inc');
857
-		include_spip('inc/lang');
858
-	}
859
-
860
-	// On peut passer explicitement la langue dans le tableau
861
-	// On utilise le même nom de variable que la globale
862
-	if (isset($args['spip_lang'])) {
863
-		$lang = $args['spip_lang'];
864
-		// On l'enleve pour ne pas le passer au remplacement
865
-		unset($args['spip_lang']);
866
-	} // Sinon on prend la langue du contexte
867
-	else {
868
-		$lang = $GLOBALS['spip_lang'];
869
-	}
870
-	$text = $traduire($texte, $lang);
871
-
872
-	if ($text === null || !strlen($text)) {
873
-		if (!$o['force']) {
874
-			return '';
875
-		}
876
-
877
-		$text = $texte;
878
-
879
-		// pour les chaines non traduites, assurer un service minimum
880
-		if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
881
-			$n = strpos($text, ':');
882
-			if ($n !== false) {
883
-				$text = substr($text, $n + 1);
884
-			}
885
-			$text = str_replace('_', ' ', $text);
886
-		}
887
-		$o['class'] = null;
888
-	}
889
-
890
-	return _L($text, $args, $o);
844
+    static $traduire = false;
845
+    $o = ['class' => '', 'force' => true, 'sanitize' => true];
846
+    if ($options) {
847
+        // support de l'ancien argument $class
848
+        if (is_string($options)) {
849
+            $options = ['class' => $options];
850
+        }
851
+        $o = array_merge($o, $options);
852
+    }
853
+
854
+    if (!$traduire) {
855
+        $traduire = charger_fonction('traduire', 'inc');
856
+        include_spip('inc/lang');
857
+    }
858
+
859
+    // On peut passer explicitement la langue dans le tableau
860
+    // On utilise le même nom de variable que la globale
861
+    if (isset($args['spip_lang'])) {
862
+        $lang = $args['spip_lang'];
863
+        // On l'enleve pour ne pas le passer au remplacement
864
+        unset($args['spip_lang']);
865
+    } // Sinon on prend la langue du contexte
866
+    else {
867
+        $lang = $GLOBALS['spip_lang'];
868
+    }
869
+    $text = $traduire($texte, $lang);
870
+
871
+    if ($text === null || !strlen($text)) {
872
+        if (!$o['force']) {
873
+            return '';
874
+        }
875
+
876
+        $text = $texte;
877
+
878
+        // pour les chaines non traduites, assurer un service minimum
879
+        if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
880
+            $n = strpos($text, ':');
881
+            if ($n !== false) {
882
+                $text = substr($text, $n + 1);
883
+            }
884
+            $text = str_replace('_', ' ', $text);
885
+        }
886
+        $o['class'] = null;
887
+    }
888
+
889
+    return _L($text, $args, $o);
891 890
 }
892 891
 
893 892
 
@@ -914,53 +913,53 @@  discard block
 block discarded – undo
914 913
  *     Texte
915 914
  */
916 915
 function _L($text, $args = [], $options = []) {
917
-	$f = $text;
918
-	$defaut_options = [
919
-		'class' => null,
920
-		'sanitize' => true,
921
-	];
922
-	// support de l'ancien argument $class
923
-	if ($options and is_string($options)) {
924
-		$options = ['class' => $options];
925
-	}
926
-	if (is_array($options)) {
927
-		$options += $defaut_options;
928
-	} else {
929
-		$options = $defaut_options;
930
-	}
931
-
932
-	if (is_array($args) and count($args)) {
933
-		if (!function_exists('interdire_scripts')) {
934
-			include_spip('inc/texte');
935
-		}
936
-		if (!function_exists('echapper_html_suspect')) {
937
-			include_spip('inc/texte_mini');
938
-		}
939
-		foreach ($args as $name => $value) {
940
-			if (strpos($text, (string) "@$name@") !== false) {
941
-				if ($options['sanitize']) {
942
-					$value = echapper_html_suspect($value);
943
-					$value = interdire_scripts($value, -1);
944
-				}
945
-				if (!empty($options['class'])) {
946
-					$value = "<span class='" . $options['class'] . "'>$value</span>";
947
-				}
948
-				$text = str_replace("@$name@", $value, $text);
949
-				unset($args[$name]);
950
-			}
951
-		}
952
-		// Si des variables n'ont pas ete inserees, le signaler
953
-		// (chaines de langues pas a jour)
954
-		if ($args) {
955
-			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
956
-		}
957
-	}
958
-
959
-	if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) {
960
-		return "<span class='debug-traduction-erreur'>$text</span>";
961
-	} else {
962
-		return $text;
963
-	}
916
+    $f = $text;
917
+    $defaut_options = [
918
+        'class' => null,
919
+        'sanitize' => true,
920
+    ];
921
+    // support de l'ancien argument $class
922
+    if ($options and is_string($options)) {
923
+        $options = ['class' => $options];
924
+    }
925
+    if (is_array($options)) {
926
+        $options += $defaut_options;
927
+    } else {
928
+        $options = $defaut_options;
929
+    }
930
+
931
+    if (is_array($args) and count($args)) {
932
+        if (!function_exists('interdire_scripts')) {
933
+            include_spip('inc/texte');
934
+        }
935
+        if (!function_exists('echapper_html_suspect')) {
936
+            include_spip('inc/texte_mini');
937
+        }
938
+        foreach ($args as $name => $value) {
939
+            if (strpos($text, (string) "@$name@") !== false) {
940
+                if ($options['sanitize']) {
941
+                    $value = echapper_html_suspect($value);
942
+                    $value = interdire_scripts($value, -1);
943
+                }
944
+                if (!empty($options['class'])) {
945
+                    $value = "<span class='" . $options['class'] . "'>$value</span>";
946
+                }
947
+                $text = str_replace("@$name@", $value, $text);
948
+                unset($args[$name]);
949
+            }
950
+        }
951
+        // Si des variables n'ont pas ete inserees, le signaler
952
+        // (chaines de langues pas a jour)
953
+        if ($args) {
954
+            spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
955
+        }
956
+    }
957
+
958
+    if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) {
959
+        return "<span class='debug-traduction-erreur'>$text</span>";
960
+    } else {
961
+        return $text;
962
+    }
964 963
 }
965 964
 
966 965
 
@@ -974,13 +973,13 @@  discard block
 block discarded – undo
974 973
  * @return string
975 974
  */
976 975
 function joli_repertoire($rep) {
977
-	$a = substr($rep, 0, 1);
978
-	if ($a <> '.' and $a <> '/') {
979
-		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
980
-	}
981
-	$rep = preg_replace(',(^\.\.\/),', '', $rep);
976
+    $a = substr($rep, 0, 1);
977
+    if ($a <> '.' and $a <> '/') {
978
+        $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
979
+    }
980
+    $rep = preg_replace(',(^\.\.\/),', '', $rep);
982 981
 
983
-	return $rep;
982
+    return $rep;
984 983
 }
985 984
 
986 985
 
@@ -1005,54 +1004,54 @@  discard block
 block discarded – undo
1005 1004
  * @return float|int|string|void
1006 1005
  */
1007 1006
 function spip_timer($t = 'rien', $raw = false) {
1008
-	static $time;
1009
-	$a = time();
1010
-	$b = microtime();
1011
-	// microtime peut contenir les microsecondes et le temps
1012
-	$b = explode(' ', $b);
1013
-	if (count($b) == 2) {
1014
-		$a = end($b);
1015
-	} // plus precis !
1016
-	$b = reset($b);
1017
-	if (!isset($time[$t])) {
1018
-		$time[$t] = $a + $b;
1019
-	} else {
1020
-		$p = ($a + $b - $time[$t]) * 1000;
1021
-		unset($time[$t]);
1007
+    static $time;
1008
+    $a = time();
1009
+    $b = microtime();
1010
+    // microtime peut contenir les microsecondes et le temps
1011
+    $b = explode(' ', $b);
1012
+    if (count($b) == 2) {
1013
+        $a = end($b);
1014
+    } // plus precis !
1015
+    $b = reset($b);
1016
+    if (!isset($time[$t])) {
1017
+        $time[$t] = $a + $b;
1018
+    } else {
1019
+        $p = ($a + $b - $time[$t]) * 1000;
1020
+        unset($time[$t]);
1022 1021
 #			echo "'$p'";exit;
1023
-		if ($raw) {
1024
-			return $p;
1025
-		}
1026
-		if ($p < 1000) {
1027
-			$s = '';
1028
-		} else {
1029
-			$s = sprintf('%d ', $x = floor($p / 1000));
1030
-			$p -= ($x * 1000);
1031
-		}
1022
+        if ($raw) {
1023
+            return $p;
1024
+        }
1025
+        if ($p < 1000) {
1026
+            $s = '';
1027
+        } else {
1028
+            $s = sprintf('%d ', $x = floor($p / 1000));
1029
+            $p -= ($x * 1000);
1030
+        }
1032 1031
 
1033
-		return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1034
-	}
1032
+        return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1033
+    }
1035 1034
 }
1036 1035
 
1037 1036
 
1038 1037
 // Renvoie False si un fichier n'est pas plus vieux que $duree secondes,
1039 1038
 // sinon renvoie True et le date sauf si ca n'est pas souhaite
1040 1039
 function spip_touch($fichier, $duree = 0, $touch = true) {
1041
-	if ($duree) {
1042
-		clearstatcache();
1043
-		if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) {
1044
-			return false;
1045
-		}
1046
-	}
1047
-	if ($touch !== false) {
1048
-		if (!@touch($fichier)) {
1049
-			spip_unlink($fichier);
1050
-			@touch($fichier);
1051
-		};
1052
-		@chmod($fichier, _SPIP_CHMOD & ~0111);
1053
-	}
1040
+    if ($duree) {
1041
+        clearstatcache();
1042
+        if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) {
1043
+            return false;
1044
+        }
1045
+    }
1046
+    if ($touch !== false) {
1047
+        if (!@touch($fichier)) {
1048
+            spip_unlink($fichier);
1049
+            @touch($fichier);
1050
+        };
1051
+        @chmod($fichier, _SPIP_CHMOD & ~0111);
1052
+    }
1054 1053
 
1055
-	return true;
1054
+    return true;
1056 1055
 }
1057 1056
 
1058 1057
 
@@ -1063,11 +1062,11 @@  discard block
 block discarded – undo
1063 1062
  * @uses cron()
1064 1063
  **/
1065 1064
 function action_cron() {
1066
-	include_spip('inc/headers');
1067
-	http_response_code(204); // No Content
1068
-	header('Connection: close');
1069
-	define('_DIRECT_CRON_FORCE', true);
1070
-	cron();
1065
+    include_spip('inc/headers');
1066
+    http_response_code(204); // No Content
1067
+    header('Connection: close');
1068
+    define('_DIRECT_CRON_FORCE', true);
1069
+    cron();
1071 1070
 }
1072 1071
 
1073 1072
 /**
@@ -1083,26 +1082,26 @@  discard block
 block discarded – undo
1083 1082
  *     True si la tache a pu être effectuée
1084 1083
  */
1085 1084
 function cron($taches = [], $taches_old = []) {
1086
-	// si pas en mode cron force, laisser tomber.
1087
-	if (!defined('_DIRECT_CRON_FORCE')) {
1088
-		return false;
1089
-	}
1090
-	if (!is_array($taches)) {
1091
-		$taches = $taches_old;
1092
-	} // compat anciens appels
1093
-	// si taches a inserer en base et base inaccessible, laisser tomber
1094
-	// sinon on ne verifie pas la connexion tout de suite, car si ca se trouve
1095
-	// queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
1096
-	// et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
1097
-	if ($taches and count($taches) and !spip_connect()) {
1098
-		return false;
1099
-	}
1100
-	spip_log('cron !', 'jq' . _LOG_DEBUG);
1101
-	if ($genie = charger_fonction('genie', 'inc', true)) {
1102
-		return $genie($taches);
1103
-	}
1104
-
1105
-	return false;
1085
+    // si pas en mode cron force, laisser tomber.
1086
+    if (!defined('_DIRECT_CRON_FORCE')) {
1087
+        return false;
1088
+    }
1089
+    if (!is_array($taches)) {
1090
+        $taches = $taches_old;
1091
+    } // compat anciens appels
1092
+    // si taches a inserer en base et base inaccessible, laisser tomber
1093
+    // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve
1094
+    // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
1095
+    // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
1096
+    if ($taches and count($taches) and !spip_connect()) {
1097
+        return false;
1098
+    }
1099
+    spip_log('cron !', 'jq' . _LOG_DEBUG);
1100
+    if ($genie = charger_fonction('genie', 'inc', true)) {
1101
+        return $genie($taches);
1102
+    }
1103
+
1104
+    return false;
1106 1105
 }
1107 1106
 
1108 1107
 /**
@@ -1134,17 +1133,17 @@  discard block
 block discarded – undo
1134 1133
  *     Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté.
1135 1134
  */
1136 1135
 function job_queue_add(
1137
-	$function,
1138
-	$description,
1139
-	$arguments = [],
1140
-	$file = '',
1141
-	$no_duplicate = false,
1142
-	$time = 0,
1143
-	$priority = 0
1136
+    $function,
1137
+    $description,
1138
+    $arguments = [],
1139
+    $file = '',
1140
+    $no_duplicate = false,
1141
+    $time = 0,
1142
+    $priority = 0
1144 1143
 ) {
1145
-	include_spip('inc/queue');
1144
+    include_spip('inc/queue');
1146 1145
 
1147
-	return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
1146
+    return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
1148 1147
 }
1149 1148
 
1150 1149
 /**
@@ -1155,9 +1154,9 @@  discard block
 block discarded – undo
1155 1154
  * @return bool
1156 1155
  */
1157 1156
 function job_queue_remove($id_job) {
1158
-	include_spip('inc/queue');
1157
+    include_spip('inc/queue');
1159 1158
 
1160
-	return queue_remove_job($id_job);
1159
+    return queue_remove_job($id_job);
1161 1160
 }
1162 1161
 
1163 1162
 /**
@@ -1170,9 +1169,9 @@  discard block
 block discarded – undo
1170 1169
  *     or an array of simple array to link multiples objet in one time
1171 1170
  */
1172 1171
 function job_queue_link($id_job, $objets) {
1173
-	include_spip('inc/queue');
1172
+    include_spip('inc/queue');
1174 1173
 
1175
-	return queue_link_job($id_job, $objets);
1174
+    return queue_link_job($id_job, $objets);
1176 1175
 }
1177 1176
 
1178 1177
 
@@ -1192,36 +1191,36 @@  discard block
 block discarded – undo
1192 1191
  *  - `null` si la queue n'est pas encore initialisée
1193 1192
  */
1194 1193
 function queue_sleep_time_to_next_job($force = null) {
1195
-	static $queue_next_job_time = -1;
1196
-	if ($force === true) {
1197
-		$queue_next_job_time = -1;
1198
-	} elseif ($force) {
1199
-		$queue_next_job_time = $force;
1200
-	}
1201
-
1202
-	if ($queue_next_job_time == -1) {
1203
-		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1204
-			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
1205
-		}
1206
-		// utiliser un cache memoire si dispo
1207
-		if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
1208
-			$queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
1209
-		} else {
1210
-			$queue_next_job_time = null;
1211
-			if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) {
1212
-				$queue_next_job_time = intval($contenu);
1213
-			}
1214
-		}
1215
-	}
1216
-
1217
-	if (is_null($queue_next_job_time)) {
1218
-		return null;
1219
-	}
1220
-	if (!$_SERVER['REQUEST_TIME']) {
1221
-		$_SERVER['REQUEST_TIME'] = time();
1222
-	}
1223
-
1224
-	return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
1194
+    static $queue_next_job_time = -1;
1195
+    if ($force === true) {
1196
+        $queue_next_job_time = -1;
1197
+    } elseif ($force) {
1198
+        $queue_next_job_time = $force;
1199
+    }
1200
+
1201
+    if ($queue_next_job_time == -1) {
1202
+        if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1203
+            define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
1204
+        }
1205
+        // utiliser un cache memoire si dispo
1206
+        if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
1207
+            $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
1208
+        } else {
1209
+            $queue_next_job_time = null;
1210
+            if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) {
1211
+                $queue_next_job_time = intval($contenu);
1212
+            }
1213
+        }
1214
+    }
1215
+
1216
+    if (is_null($queue_next_job_time)) {
1217
+        return null;
1218
+    }
1219
+    if (!$_SERVER['REQUEST_TIME']) {
1220
+        $_SERVER['REQUEST_TIME'] = time();
1221
+    }
1222
+
1223
+    return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
1225 1224
 }
1226 1225
 
1227 1226
 
@@ -1233,11 +1232,11 @@  discard block
 block discarded – undo
1233 1232
  * @return string
1234 1233
  */
1235 1234
 function quote_amp($u) {
1236
-	return preg_replace(
1237
-		'/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i',
1238
-		'&amp;',
1239
-		$u
1240
-	);
1235
+    return preg_replace(
1236
+        '/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i',
1237
+        '&amp;',
1238
+        $u
1239
+    );
1241 1240
 }
1242 1241
 
1243 1242
 
@@ -1260,27 +1259,27 @@  discard block
 block discarded – undo
1260 1259
  *     Balise HTML `<script>` et son contenu
1261 1260
  **/
1262 1261
 function http_script($script, $src = '', $noscript = '') {
1263
-	static $done = [];
1262
+    static $done = [];
1264 1263
 
1265
-	if ($src && !isset($done[$src])) {
1266
-		$done[$src] = true;
1267
-		$src = find_in_path($src, _JAVASCRIPT);
1268
-		$src = " src='$src'";
1269
-	} else {
1270
-		$src = '';
1271
-	}
1272
-	if ($script) {
1273
-		$script = ("/*<![CDATA[*/\n" .
1274
-			preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1275
-			'/*]]>*/');
1276
-	}
1277
-	if ($noscript) {
1278
-		$noscript = "<noscript>\n\t$noscript\n</noscript>\n";
1279
-	}
1264
+    if ($src && !isset($done[$src])) {
1265
+        $done[$src] = true;
1266
+        $src = find_in_path($src, _JAVASCRIPT);
1267
+        $src = " src='$src'";
1268
+    } else {
1269
+        $src = '';
1270
+    }
1271
+    if ($script) {
1272
+        $script = ("/*<![CDATA[*/\n" .
1273
+            preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1274
+            '/*]]>*/');
1275
+    }
1276
+    if ($noscript) {
1277
+        $noscript = "<noscript>\n\t$noscript\n</noscript>\n";
1278
+    }
1280 1279
 
1281
-	return ($src or $script or $noscript)
1282
-		? "<script type='text/javascript'$src>$script</script>$noscript"
1283
-		: '';
1280
+    return ($src or $script or $noscript)
1281
+        ? "<script type='text/javascript'$src>$script</script>$noscript"
1282
+        : '';
1284 1283
 }
1285 1284
 
1286 1285
 
@@ -1315,7 +1314,7 @@  discard block
 block discarded – undo
1315 1314
  *     Texte échappé
1316 1315
  **/
1317 1316
 function texte_script(string $texte): string {
1318
-	return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte));
1317
+    return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte));
1319 1318
 }
1320 1319
 
1321 1320
 
@@ -1352,68 +1351,68 @@  discard block
 block discarded – undo
1352 1351
  *     Liste des chemins, par ordre de priorité.
1353 1352
  **/
1354 1353
 function _chemin($dir_path = null) {
1355
-	static $path_base = null;
1356
-	static $path_full = null;
1357
-	if ($path_base == null) {
1358
-		// Chemin standard depuis l'espace public
1359
-		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
1360
-			_DIR_RACINE . ':' .
1361
-			_DIR_RACINE . 'squelettes-dist/:' .
1362
-			_DIR_RACINE . 'prive/:' .
1363
-			_DIR_RESTREINT;
1364
-		// Ajouter squelettes/
1365
-		if (@is_dir(_DIR_RACINE . 'squelettes')) {
1366
-			$path = _DIR_RACINE . 'squelettes/:' . $path;
1367
-		}
1368
-		foreach (explode(':', $path) as $dir) {
1369
-			if (strlen($dir) and substr($dir, -1) != '/') {
1370
-				$dir .= '/';
1371
-			}
1372
-			$path_base[] = $dir;
1373
-		}
1374
-		$path_full = $path_base;
1375
-		// Et le(s) dossier(s) des squelettes nommes
1376
-		if (strlen($GLOBALS['dossier_squelettes'])) {
1377
-			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1378
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1379
-			}
1380
-		}
1381
-		$GLOBALS['path_sig'] = md5(serialize($path_full));
1382
-	}
1383
-	if ($dir_path === null) {
1384
-		return $path_full;
1385
-	}
1386
-
1387
-	if (is_array($dir_path) or strlen($dir_path)) {
1388
-		$tete = '';
1389
-		if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1390
-			$tete = array_shift($path_base);
1391
-		}
1392
-		$dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
1393
-		$dirs = array_reverse($dirs);
1394
-		foreach ($dirs as $dir_path) {
1395
-			if (substr($dir_path, -1) != '/') {
1396
-				$dir_path .= '/';
1397
-			}
1398
-			if (!in_array($dir_path, $path_base)) {
1399
-				array_unshift($path_base, $dir_path);
1400
-			}
1401
-		}
1402
-		if (strlen($tete)) {
1403
-			array_unshift($path_base, $tete);
1404
-		}
1405
-	}
1406
-	$path_full = $path_base;
1407
-	// Et le(s) dossier(s) des squelettes nommes
1408
-	if (strlen($GLOBALS['dossier_squelettes'])) {
1409
-		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1410
-			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1411
-		}
1412
-	}
1413
-
1414
-	$GLOBALS['path_sig'] = md5(serialize($path_full));
1415
-
1416
-	return $path_full;
1354
+    static $path_base = null;
1355
+    static $path_full = null;
1356
+    if ($path_base == null) {
1357
+        // Chemin standard depuis l'espace public
1358
+        $path = defined('_SPIP_PATH') ? _SPIP_PATH :
1359
+            _DIR_RACINE . ':' .
1360
+            _DIR_RACINE . 'squelettes-dist/:' .
1361
+            _DIR_RACINE . 'prive/:' .
1362
+            _DIR_RESTREINT;
1363
+        // Ajouter squelettes/
1364
+        if (@is_dir(_DIR_RACINE . 'squelettes')) {
1365
+            $path = _DIR_RACINE . 'squelettes/:' . $path;
1366
+        }
1367
+        foreach (explode(':', $path) as $dir) {
1368
+            if (strlen($dir) and substr($dir, -1) != '/') {
1369
+                $dir .= '/';
1370
+            }
1371
+            $path_base[] = $dir;
1372
+        }
1373
+        $path_full = $path_base;
1374
+        // Et le(s) dossier(s) des squelettes nommes
1375
+        if (strlen($GLOBALS['dossier_squelettes'])) {
1376
+            foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1377
+                array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1378
+            }
1379
+        }
1380
+        $GLOBALS['path_sig'] = md5(serialize($path_full));
1381
+    }
1382
+    if ($dir_path === null) {
1383
+        return $path_full;
1384
+    }
1385
+
1386
+    if (is_array($dir_path) or strlen($dir_path)) {
1387
+        $tete = '';
1388
+        if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1389
+            $tete = array_shift($path_base);
1390
+        }
1391
+        $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
1392
+        $dirs = array_reverse($dirs);
1393
+        foreach ($dirs as $dir_path) {
1394
+            if (substr($dir_path, -1) != '/') {
1395
+                $dir_path .= '/';
1396
+            }
1397
+            if (!in_array($dir_path, $path_base)) {
1398
+                array_unshift($path_base, $dir_path);
1399
+            }
1400
+        }
1401
+        if (strlen($tete)) {
1402
+            array_unshift($path_base, $tete);
1403
+        }
1404
+    }
1405
+    $path_full = $path_base;
1406
+    // Et le(s) dossier(s) des squelettes nommes
1407
+    if (strlen($GLOBALS['dossier_squelettes'])) {
1408
+        foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1409
+            array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1410
+        }
1411
+    }
1412
+
1413
+    $GLOBALS['path_sig'] = md5(serialize($path_full));
1414
+
1415
+    return $path_full;
1417 1416
 }
1418 1417
 
1419 1418
 /**
@@ -1426,78 +1425,78 @@  discard block
 block discarded – undo
1426 1425
  * @return array Liste de chemins
1427 1426
  **/
1428 1427
 function creer_chemin() {
1429
-	$path_a = _chemin();
1430
-	static $c = '';
1428
+    $path_a = _chemin();
1429
+    static $c = '';
1431 1430
 
1432
-	// on calcule le chemin si le dossier skel a change
1433
-	if ($c != $GLOBALS['dossier_squelettes']) {
1434
-		// assurer le non plantage lors de la montee de version :
1435
-		$c = $GLOBALS['dossier_squelettes'];
1436
-		$path_a = _chemin(''); // forcer un recalcul du chemin
1437
-	}
1431
+    // on calcule le chemin si le dossier skel a change
1432
+    if ($c != $GLOBALS['dossier_squelettes']) {
1433
+        // assurer le non plantage lors de la montee de version :
1434
+        $c = $GLOBALS['dossier_squelettes'];
1435
+        $path_a = _chemin(''); // forcer un recalcul du chemin
1436
+    }
1438 1437
 
1439
-	return $path_a;
1438
+    return $path_a;
1440 1439
 }
1441 1440
 
1442 1441
 
1443 1442
 function lister_themes_prives() {
1444
-	static $themes = null;
1445
-	if (is_null($themes)) {
1446
-		// si pas encore definie
1447
-		if (!defined('_SPIP_THEME_PRIVE')) {
1448
-			define('_SPIP_THEME_PRIVE', 'spip');
1449
-		}
1450
-		$themes = [_SPIP_THEME_PRIVE];
1451
-		// lors d'une installation neuve, prefs n'est pas definie.
1452
-		if (isset($GLOBALS['visiteur_session']['prefs'])) {
1453
-			$prefs = $GLOBALS['visiteur_session']['prefs'];
1454
-		} else {
1455
-			$prefs = [];
1456
-		}
1457
-		if (is_string($prefs)) {
1458
-			$prefs = unserialize($GLOBALS['visiteur_session']['prefs']);
1459
-		}
1460
-		if (
1461
-			((isset($prefs['theme']) and $theme = $prefs['theme'])
1462
-				or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut']))
1463
-			and $theme != _SPIP_THEME_PRIVE
1464
-		) {
1465
-			array_unshift($themes, $theme);
1466
-		} // placer le theme choisi en tete
1467
-	}
1468
-
1469
-	return $themes;
1443
+    static $themes = null;
1444
+    if (is_null($themes)) {
1445
+        // si pas encore definie
1446
+        if (!defined('_SPIP_THEME_PRIVE')) {
1447
+            define('_SPIP_THEME_PRIVE', 'spip');
1448
+        }
1449
+        $themes = [_SPIP_THEME_PRIVE];
1450
+        // lors d'une installation neuve, prefs n'est pas definie.
1451
+        if (isset($GLOBALS['visiteur_session']['prefs'])) {
1452
+            $prefs = $GLOBALS['visiteur_session']['prefs'];
1453
+        } else {
1454
+            $prefs = [];
1455
+        }
1456
+        if (is_string($prefs)) {
1457
+            $prefs = unserialize($GLOBALS['visiteur_session']['prefs']);
1458
+        }
1459
+        if (
1460
+            ((isset($prefs['theme']) and $theme = $prefs['theme'])
1461
+                or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut']))
1462
+            and $theme != _SPIP_THEME_PRIVE
1463
+        ) {
1464
+            array_unshift($themes, $theme);
1465
+        } // placer le theme choisi en tete
1466
+    }
1467
+
1468
+    return $themes;
1470 1469
 }
1471 1470
 
1472 1471
 function find_in_theme($file, $subdir = '', $include = false) {
1473
-	static $themefiles = [];
1474
-	if (isset($themefiles["$subdir$file"])) {
1475
-		return $themefiles["$subdir$file"];
1476
-	}
1477
-	// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1478
-	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1479
-	if (
1480
-		preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1481
-		and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg'
1482
-		and $f = find_in_theme("$file_svg_generique")
1483
-	) {
1484
-		if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) {
1485
-			return $themefiles["$subdir$file"] = $fsize;
1486
-		}
1487
-		else {
1488
-			return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
1489
-		}
1490
-	}
1491
-
1492
-	$themes = lister_themes_prives();
1493
-	foreach ($themes as $theme) {
1494
-		if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) {
1495
-			return $themefiles["$subdir$file"] = $f;
1496
-		}
1497
-	}
1498
-	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1499
-
1500
-	return $themefiles["$subdir$file"] = '';
1472
+    static $themefiles = [];
1473
+    if (isset($themefiles["$subdir$file"])) {
1474
+        return $themefiles["$subdir$file"];
1475
+    }
1476
+    // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1477
+    // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1478
+    if (
1479
+        preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1480
+        and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg'
1481
+        and $f = find_in_theme("$file_svg_generique")
1482
+    ) {
1483
+        if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) {
1484
+            return $themefiles["$subdir$file"] = $fsize;
1485
+        }
1486
+        else {
1487
+            return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
1488
+        }
1489
+    }
1490
+
1491
+    $themes = lister_themes_prives();
1492
+    foreach ($themes as $theme) {
1493
+        if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) {
1494
+            return $themefiles["$subdir$file"] = $f;
1495
+        }
1496
+    }
1497
+    spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1498
+
1499
+    return $themefiles["$subdir$file"] = '';
1501 1500
 }
1502 1501
 
1503 1502
 
@@ -1521,31 +1520,31 @@  discard block
 block discarded – undo
1521 1520
  *     sinon chaîne vide.
1522 1521
  **/
1523 1522
 function chemin_image($icone) {
1524
-	static $icone_renommer;
1525
-	if ($p = strpos($icone, '?')) {
1526
-		$icone = substr($icone, 0, $p);
1527
-	}
1528
-	// gerer le cas d'un double appel en evitant de refaire le travail inutilement
1529
-	if (strpos($icone, '/') !== false and file_exists($icone)) {
1530
-		return $icone;
1531
-	}
1532
-
1533
-	// si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
1534
-	if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) {
1535
-		return $f;
1536
-	}
1537
-	// sinon passer par le module de renommage
1538
-	if (is_null($icone_renommer)) {
1539
-		$icone_renommer = charger_fonction('icone_renommer', 'inc', true);
1540
-	}
1541
-	if ($icone_renommer) {
1542
-		[$icone, $fonction] = $icone_renommer($icone, '');
1543
-		if (file_exists($icone)) {
1544
-			return $icone;
1545
-		}
1546
-	}
1547
-
1548
-	return find_in_path($icone, _NOM_IMG_PACK);
1523
+    static $icone_renommer;
1524
+    if ($p = strpos($icone, '?')) {
1525
+        $icone = substr($icone, 0, $p);
1526
+    }
1527
+    // gerer le cas d'un double appel en evitant de refaire le travail inutilement
1528
+    if (strpos($icone, '/') !== false and file_exists($icone)) {
1529
+        return $icone;
1530
+    }
1531
+
1532
+    // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
1533
+    if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) {
1534
+        return $f;
1535
+    }
1536
+    // sinon passer par le module de renommage
1537
+    if (is_null($icone_renommer)) {
1538
+        $icone_renommer = charger_fonction('icone_renommer', 'inc', true);
1539
+    }
1540
+    if ($icone_renommer) {
1541
+        [$icone, $fonction] = $icone_renommer($icone, '');
1542
+        if (file_exists($icone)) {
1543
+            return $icone;
1544
+        }
1545
+    }
1546
+
1547
+    return find_in_path($icone, _NOM_IMG_PACK);
1549 1548
 }
1550 1549
 
1551 1550
 //
@@ -1583,128 +1582,128 @@  discard block
 block discarded – undo
1583 1582
  *     - false : fichier introuvable
1584 1583
  **/
1585 1584
 function find_in_path($file, $dirname = '', $include = false) {
1586
-	static $dirs = [];
1587
-	static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec
1588
-	static $c = '';
1589
-
1590
-	if (!$file and !strlen($file)) {
1591
-		return false;
1592
-	}
1593
-
1594
-	// on calcule le chemin si le dossier skel a change
1595
-	if ($c != $GLOBALS['dossier_squelettes']) {
1596
-		// assurer le non plantage lors de la montee de version :
1597
-		$c = $GLOBALS['dossier_squelettes'];
1598
-		creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
1599
-	}
1600
-
1601
-	if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) {
1602
-		if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) {
1603
-			return false;
1604
-		}
1605
-		if ($include and !isset($inc[$dirname][$file])) {
1606
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1607
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1608
-		}
1609
-
1610
-		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1611
-	}
1612
-
1613
-	$a = strrpos($file, '/');
1614
-	if ($a !== false) {
1615
-		$dirname .= substr($file, 0, ++$a);
1616
-		$file = substr($file, $a);
1617
-	}
1618
-
1619
-	foreach (creer_chemin() as $dir) {
1620
-		if (!isset($dirs[$a = $dir . $dirname])) {
1621
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1622
-		}
1623
-		if ($dirs[$a]) {
1624
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
1625
-				if ($include and !isset($inc[$dirname][$file])) {
1626
-					include_once _ROOT_CWD . $a;
1627
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1628
-				}
1629
-				if (!defined('_SAUVER_CHEMIN')) {
1630
-					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1631
-					if (is_null($GLOBALS['path_files'])) {
1632
-						return $a;
1633
-					}
1634
-					define('_SAUVER_CHEMIN', true);
1635
-				}
1636
-
1637
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1638
-			}
1639
-		}
1640
-	}
1641
-
1642
-	if ($include) {
1643
-		spip_log("include_spip $dirname$file non trouve");
1644
-		if ($include === 'required') {
1645
-			echo '<pre>',
1646
-			'<strong>Erreur Fatale</strong><br />';
1647
-			if (function_exists('debug_print_backtrace')) {
1648
-				echo debug_print_backtrace();
1649
-			}
1650
-			echo '</pre>';
1651
-			die("Erreur interne: ne peut inclure $dirname$file");
1652
-		}
1653
-	}
1654
-
1655
-	if (!defined('_SAUVER_CHEMIN')) {
1656
-		// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1657
-		if (is_null($GLOBALS['path_files'])) {
1658
-			return false;
1659
-		}
1660
-		define('_SAUVER_CHEMIN', true);
1661
-	}
1662
-
1663
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1585
+    static $dirs = [];
1586
+    static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec
1587
+    static $c = '';
1588
+
1589
+    if (!$file and !strlen($file)) {
1590
+        return false;
1591
+    }
1592
+
1593
+    // on calcule le chemin si le dossier skel a change
1594
+    if ($c != $GLOBALS['dossier_squelettes']) {
1595
+        // assurer le non plantage lors de la montee de version :
1596
+        $c = $GLOBALS['dossier_squelettes'];
1597
+        creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
1598
+    }
1599
+
1600
+    if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) {
1601
+        if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) {
1602
+            return false;
1603
+        }
1604
+        if ($include and !isset($inc[$dirname][$file])) {
1605
+            include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1606
+            $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1607
+        }
1608
+
1609
+        return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1610
+    }
1611
+
1612
+    $a = strrpos($file, '/');
1613
+    if ($a !== false) {
1614
+        $dirname .= substr($file, 0, ++$a);
1615
+        $file = substr($file, $a);
1616
+    }
1617
+
1618
+    foreach (creer_chemin() as $dir) {
1619
+        if (!isset($dirs[$a = $dir . $dirname])) {
1620
+            $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1621
+        }
1622
+        if ($dirs[$a]) {
1623
+            if (file_exists(_ROOT_CWD . ($a .= $file))) {
1624
+                if ($include and !isset($inc[$dirname][$file])) {
1625
+                    include_once _ROOT_CWD . $a;
1626
+                    $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1627
+                }
1628
+                if (!defined('_SAUVER_CHEMIN')) {
1629
+                    // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1630
+                    if (is_null($GLOBALS['path_files'])) {
1631
+                        return $a;
1632
+                    }
1633
+                    define('_SAUVER_CHEMIN', true);
1634
+                }
1635
+
1636
+                return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1637
+            }
1638
+        }
1639
+    }
1640
+
1641
+    if ($include) {
1642
+        spip_log("include_spip $dirname$file non trouve");
1643
+        if ($include === 'required') {
1644
+            echo '<pre>',
1645
+            '<strong>Erreur Fatale</strong><br />';
1646
+            if (function_exists('debug_print_backtrace')) {
1647
+                echo debug_print_backtrace();
1648
+            }
1649
+            echo '</pre>';
1650
+            die("Erreur interne: ne peut inclure $dirname$file");
1651
+        }
1652
+    }
1653
+
1654
+    if (!defined('_SAUVER_CHEMIN')) {
1655
+        // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1656
+        if (is_null($GLOBALS['path_files'])) {
1657
+            return false;
1658
+        }
1659
+        define('_SAUVER_CHEMIN', true);
1660
+    }
1661
+
1662
+    return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1664 1663
 }
1665 1664
 
1666 1665
 function clear_path_cache() {
1667
-	$GLOBALS['path_files'] = [];
1668
-	spip_unlink(_CACHE_CHEMIN);
1666
+    $GLOBALS['path_files'] = [];
1667
+    spip_unlink(_CACHE_CHEMIN);
1669 1668
 }
1670 1669
 
1671 1670
 function load_path_cache() {
1672
-	// charger le path des plugins
1673
-	if (@is_readable(_CACHE_PLUGINS_PATH)) {
1674
-		include_once(_CACHE_PLUGINS_PATH);
1675
-	}
1676
-	$GLOBALS['path_files'] = [];
1677
-	// si le visiteur est admin,
1678
-	// on ne recharge pas le cache pour forcer sa mise a jour
1679
-	if (
1680
-		// la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier
1681
-		//AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')
1682
-		// utiliser le cookie est un pis aller qui marche 'en general'
1683
-		// on blinde par un second test au moment de la lecture de la session
1684
-		// !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
1685
-		// et en ignorant ce cache en cas de recalcul explicite
1686
-		!_request('var_mode')
1687
-	) {
1688
-		// on essaye de lire directement sans verrou pour aller plus vite
1689
-		if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
1690
-			// mais si semble corrompu on relit avec un verrou
1691
-			if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1692
-				lire_fichier(_CACHE_CHEMIN, $contenu);
1693
-				if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1694
-					$GLOBALS['path_files'] = [];
1695
-				}
1696
-			}
1697
-		}
1698
-	}
1671
+    // charger le path des plugins
1672
+    if (@is_readable(_CACHE_PLUGINS_PATH)) {
1673
+        include_once(_CACHE_PLUGINS_PATH);
1674
+    }
1675
+    $GLOBALS['path_files'] = [];
1676
+    // si le visiteur est admin,
1677
+    // on ne recharge pas le cache pour forcer sa mise a jour
1678
+    if (
1679
+        // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier
1680
+        //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')
1681
+        // utiliser le cookie est un pis aller qui marche 'en general'
1682
+        // on blinde par un second test au moment de la lecture de la session
1683
+        // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
1684
+        // et en ignorant ce cache en cas de recalcul explicite
1685
+        !_request('var_mode')
1686
+    ) {
1687
+        // on essaye de lire directement sans verrou pour aller plus vite
1688
+        if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
1689
+            // mais si semble corrompu on relit avec un verrou
1690
+            if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1691
+                lire_fichier(_CACHE_CHEMIN, $contenu);
1692
+                if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1693
+                    $GLOBALS['path_files'] = [];
1694
+                }
1695
+            }
1696
+        }
1697
+    }
1699 1698
 }
1700 1699
 
1701 1700
 function save_path_cache() {
1702
-	if (
1703
-		defined('_SAUVER_CHEMIN')
1704
-		and _SAUVER_CHEMIN
1705
-	) {
1706
-		ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
1707
-	}
1701
+    if (
1702
+        defined('_SAUVER_CHEMIN')
1703
+        and _SAUVER_CHEMIN
1704
+    ) {
1705
+        ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
1706
+    }
1708 1707
 }
1709 1708
 
1710 1709
 
@@ -1724,33 +1723,33 @@  discard block
 block discarded – undo
1724 1723
  * @return array
1725 1724
  */
1726 1725
 function find_all_in_path($dir, $pattern, $recurs = false) {
1727
-	$liste_fichiers = [];
1728
-	$maxfiles = 10000;
1729
-
1730
-	// cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1731
-	// on a pas encore inclus flock.php
1732
-	if (!function_exists('preg_files')) {
1733
-		include_once _ROOT_RESTREINT . 'inc/flock.php';
1734
-	}
1735
-
1736
-	// Parcourir le chemin
1737
-	foreach (creer_chemin() as $d) {
1738
-		$f = $d . $dir;
1739
-		if (@is_dir($f)) {
1740
-			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
1741
-			foreach ($liste as $chemin) {
1742
-				$nom = basename($chemin);
1743
-				// ne prendre que les fichiers pas deja trouves
1744
-				// car find_in_path prend le premier qu'il trouve,
1745
-				// les autres sont donc masques
1746
-				if (!isset($liste_fichiers[$nom])) {
1747
-					$liste_fichiers[$nom] = $chemin;
1748
-				}
1749
-			}
1750
-		}
1751
-	}
1752
-
1753
-	return $liste_fichiers;
1726
+    $liste_fichiers = [];
1727
+    $maxfiles = 10000;
1728
+
1729
+    // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1730
+    // on a pas encore inclus flock.php
1731
+    if (!function_exists('preg_files')) {
1732
+        include_once _ROOT_RESTREINT . 'inc/flock.php';
1733
+    }
1734
+
1735
+    // Parcourir le chemin
1736
+    foreach (creer_chemin() as $d) {
1737
+        $f = $d . $dir;
1738
+        if (@is_dir($f)) {
1739
+            $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
1740
+            foreach ($liste as $chemin) {
1741
+                $nom = basename($chemin);
1742
+                // ne prendre que les fichiers pas deja trouves
1743
+                // car find_in_path prend le premier qu'il trouve,
1744
+                // les autres sont donc masques
1745
+                if (!isset($liste_fichiers[$nom])) {
1746
+                    $liste_fichiers[$nom] = $chemin;
1747
+                }
1748
+            }
1749
+        }
1750
+    }
1751
+
1752
+    return $liste_fichiers;
1754 1753
 }
1755 1754
 
1756 1755
 /**
@@ -1762,17 +1761,17 @@  discard block
 block discarded – undo
1762 1761
  * @return bool
1763 1762
  */
1764 1763
 function autoriser_sans_cookie($nom, $strict = false) {
1765
-	static $autsanscookie = ['install', 'base_repair'];
1764
+    static $autsanscookie = ['install', 'base_repair'];
1766 1765
 
1767
-	if (in_array($nom, $autsanscookie)) {
1768
-		if (test_espace_prive()) {
1769
-			include_spip('base/connect_sql');
1770
-			if (!$strict or !spip_connect()) {
1771
-				return true;
1772
-			}
1773
-		}
1774
-	}
1775
-	return false;
1766
+    if (in_array($nom, $autsanscookie)) {
1767
+        if (test_espace_prive()) {
1768
+            include_spip('base/connect_sql');
1769
+            if (!$strict or !spip_connect()) {
1770
+                return true;
1771
+            }
1772
+        }
1773
+    }
1774
+    return false;
1776 1775
 }
1777 1776
 
1778 1777
 /**
@@ -1782,60 +1781,60 @@  discard block
 block discarded – undo
1782 1781
  * @return string
1783 1782
  */
1784 1783
 function charger_fonction_url(string $quoi, string $type = '') {
1785
-	if ($type === 'defaut') {
1786
-		$objet = objet_type($quoi);
1787
-		if (
1788
-			$f = charger_fonction('generer_' . $objet . '_url', 'urls', true)
1789
-			// deprecated
1790
-			or $f = charger_fonction('generer_url_' . $objet, 'urls', true)
1791
-		) {
1792
-			return $f;
1793
-		}
1794
-		return '';
1795
-	}
1796
-
1797
-	$url_type = $type;
1798
-	if (!$url_type) {
1799
-		$url_type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut
1800
-	}
1801
-
1802
-	// inclure le module d'url
1803
-	include_spip('urls/' . $url_type);
1804
-
1805
-	switch ($quoi) {
1806
-		case 'page':
1807
-			if (
1808
-				 function_exists($f = "urls_{$url_type}_generer_url_page")
1809
-				or function_exists($f .= '_dist')
1810
-				// ou une fonction custom utilisateur independante du type d'url
1811
-				or function_exists($f = 'generer_url_page')
1812
-				or function_exists($f .= '_dist')
1813
-			) {
1814
-				return $f;
1815
-			}
1816
-			// pas de compat ancienne version ici, c'est une nouvelle feature
1817
-			return '';
1818
-		case 'objet':
1819
-		case 'decoder':
1820
-		default:
1821
-			$fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url');
1822
-			if (
1823
-				function_exists($f = "urls_{$url_type}_{$fquoi}")
1824
-				or function_exists($f .= '_dist')
1825
-			) {
1826
-				return $f;
1827
-			}
1828
-			// est-ce qu'on a une ancienne fonction urls_xxx_dist() ?
1829
-			// c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout
1830
-			if ($f = charger_fonction($url_type, 'urls', true)) {
1831
-				return $f;
1832
-			}
1833
-			// sinon on se rabat sur les urls page si ce n'est pas un type demande explicitement
1834
-			if (!$type and $url_type !== 'page') {
1835
-				return charger_fonction_url($quoi, 'page');
1836
-			}
1837
-			return '';
1838
-	}
1784
+    if ($type === 'defaut') {
1785
+        $objet = objet_type($quoi);
1786
+        if (
1787
+            $f = charger_fonction('generer_' . $objet . '_url', 'urls', true)
1788
+            // deprecated
1789
+            or $f = charger_fonction('generer_url_' . $objet, 'urls', true)
1790
+        ) {
1791
+            return $f;
1792
+        }
1793
+        return '';
1794
+    }
1795
+
1796
+    $url_type = $type;
1797
+    if (!$url_type) {
1798
+        $url_type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut
1799
+    }
1800
+
1801
+    // inclure le module d'url
1802
+    include_spip('urls/' . $url_type);
1803
+
1804
+    switch ($quoi) {
1805
+        case 'page':
1806
+            if (
1807
+                    function_exists($f = "urls_{$url_type}_generer_url_page")
1808
+                or function_exists($f .= '_dist')
1809
+                // ou une fonction custom utilisateur independante du type d'url
1810
+                or function_exists($f = 'generer_url_page')
1811
+                or function_exists($f .= '_dist')
1812
+            ) {
1813
+                return $f;
1814
+            }
1815
+            // pas de compat ancienne version ici, c'est une nouvelle feature
1816
+            return '';
1817
+        case 'objet':
1818
+        case 'decoder':
1819
+        default:
1820
+            $fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url');
1821
+            if (
1822
+                function_exists($f = "urls_{$url_type}_{$fquoi}")
1823
+                or function_exists($f .= '_dist')
1824
+            ) {
1825
+                return $f;
1826
+            }
1827
+            // est-ce qu'on a une ancienne fonction urls_xxx_dist() ?
1828
+            // c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout
1829
+            if ($f = charger_fonction($url_type, 'urls', true)) {
1830
+                return $f;
1831
+            }
1832
+            // sinon on se rabat sur les urls page si ce n'est pas un type demande explicitement
1833
+            if (!$type and $url_type !== 'page') {
1834
+                return charger_fonction_url($quoi, 'page');
1835
+            }
1836
+            return '';
1837
+    }
1839 1838
 }
1840 1839
 
1841 1840
 
@@ -1864,48 +1863,48 @@  discard block
 block discarded – undo
1864 1863
  *           (cas des raccourcis personalises [->spip20] : il faut implementer une fonction generer_spip_url et une fonction generer_spip_url_ecrire)
1865 1864
  */
1866 1865
 function generer_objet_url($id, string $entite, string $args = '', string $ancre = '', ?bool $public = null, string $type = '', string $connect = ''): string {
1867
-	if ($public === null) {
1868
-		$public = !test_espace_prive();
1869
-	}
1870
-	$id = intval($id);
1871
-	$entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
1872
-
1873
-	if (!$public) {
1874
-		if (!$entite) {
1875
-			return '';
1876
-		}
1877
-		if (!function_exists('generer_objet_url_ecrire')) {
1878
-			include_spip('inc/urls');
1879
-		}
1880
-		$res = generer_objet_url_ecrire($id, $entite, $args, $ancre, false, $connect);
1881
-	} else {
1882
-		$f = charger_fonction_url('objet', $type ?? '');
1883
-
1884
-		// @deprecated si $entite='', on veut la fonction de passage URL ==> id
1885
-		// @see charger_fonction_url
1886
-		if (!$entite) {
1887
-			return $f;
1888
-		}
1889
-
1890
-		// mais d'abord il faut tester le cas des urls sur une
1891
-		// base distante
1892
-		if (
1893
-			$connect
1894
-			and $g = charger_fonction('connect', 'urls', true)
1895
-		) {
1896
-			$f = $g;
1897
-		}
1898
-
1899
-		$res = $f(intval($id), $entite, $args ?: '', $ancre ?: '', $connect);
1900
-	}
1901
-	if ($res) {
1902
-		return $res;
1903
-	}
1904
-
1905
-	// On a ete gentil mais la ....
1906
-	spip_log("generer_objet_url: entite $entite ($f) inconnue $type $public $connect", _LOG_ERREUR);
1907
-
1908
-	return '';
1866
+    if ($public === null) {
1867
+        $public = !test_espace_prive();
1868
+    }
1869
+    $id = intval($id);
1870
+    $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
1871
+
1872
+    if (!$public) {
1873
+        if (!$entite) {
1874
+            return '';
1875
+        }
1876
+        if (!function_exists('generer_objet_url_ecrire')) {
1877
+            include_spip('inc/urls');
1878
+        }
1879
+        $res = generer_objet_url_ecrire($id, $entite, $args, $ancre, false, $connect);
1880
+    } else {
1881
+        $f = charger_fonction_url('objet', $type ?? '');
1882
+
1883
+        // @deprecated si $entite='', on veut la fonction de passage URL ==> id
1884
+        // @see charger_fonction_url
1885
+        if (!$entite) {
1886
+            return $f;
1887
+        }
1888
+
1889
+        // mais d'abord il faut tester le cas des urls sur une
1890
+        // base distante
1891
+        if (
1892
+            $connect
1893
+            and $g = charger_fonction('connect', 'urls', true)
1894
+        ) {
1895
+            $f = $g;
1896
+        }
1897
+
1898
+        $res = $f(intval($id), $entite, $args ?: '', $ancre ?: '', $connect);
1899
+    }
1900
+    if ($res) {
1901
+        return $res;
1902
+    }
1903
+
1904
+    // On a ete gentil mais la ....
1905
+    spip_log("generer_objet_url: entite $entite ($f) inconnue $type $public $connect", _LOG_ERREUR);
1906
+
1907
+    return '';
1909 1908
 }
1910 1909
 
1911 1910
 /**
@@ -1913,10 +1912,10 @@  discard block
 block discarded – undo
1913 1912
  * @see generer_objet_url
1914 1913
  */
1915 1914
 function generer_url_entite($id = 0, $entite = '', $args = '', $ancre = '', $public = null, $type = null) {
1916
-	if ($public and is_string($public)) {
1917
-		return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', true, $type ?? '', $public);
1918
-	}
1919
-	return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', $public, $type ?? '');
1915
+    if ($public and is_string($public)) {
1916
+        return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', true, $type ?? '', $public);
1917
+    }
1918
+    return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', $public, $type ?? '');
1920 1919
 }
1921 1920
 
1922 1921
 /**
@@ -1928,19 +1927,19 @@  discard block
 block discarded – undo
1928 1927
  * @return string
1929 1928
  */
1930 1929
 function generer_objet_url_ecrire_edit($id, string $entite, string $args = '', string $ancre = ''): string {
1931
-	$id = intval($id);
1932
-	$exec = objet_info($entite, 'url_edit');
1933
-	$url = generer_url_ecrire($exec, $args);
1934
-	if (intval($id)) {
1935
-		$url = parametre_url($url, id_table_objet($entite), $id);
1936
-	} else {
1937
-		$url = parametre_url($url, 'new', 'oui');
1938
-	}
1939
-	if ($ancre) {
1940
-		$url = ancre_url($url, $ancre);
1941
-	}
1930
+    $id = intval($id);
1931
+    $exec = objet_info($entite, 'url_edit');
1932
+    $url = generer_url_ecrire($exec, $args);
1933
+    if (intval($id)) {
1934
+        $url = parametre_url($url, id_table_objet($entite), $id);
1935
+    } else {
1936
+        $url = parametre_url($url, 'new', 'oui');
1937
+    }
1938
+    if ($ancre) {
1939
+        $url = ancre_url($url, $ancre);
1940
+    }
1942 1941
 
1943
-	return $url;
1942
+    return $url;
1944 1943
 }
1945 1944
 
1946 1945
 /**
@@ -1948,18 +1947,18 @@  discard block
 block discarded – undo
1948 1947
  * @see generer_objet_url_ecrire_edit
1949 1948
  */
1950 1949
 function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') {
1951
-	return generer_objet_url_ecrire_edit(intval($id), $entite, $args, $ancre);
1950
+    return generer_objet_url_ecrire_edit(intval($id), $entite, $args, $ancre);
1952 1951
 }
1953 1952
 
1954 1953
 
1955 1954
 function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) {
1956
-	include_spip('base/connect_sql');
1957
-	$id_type = id_table_objet($entite, $public);
1955
+    include_spip('base/connect_sql');
1956
+    $id_type = id_table_objet($entite, $public);
1958 1957
 
1959
-	return _DIR_RACINE . get_spip_script('./')
1960
-	. '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1961
-	. (!$args ? '' : "&$args")
1962
-	. (!$ancre ? '' : "#$ancre");
1958
+    return _DIR_RACINE . get_spip_script('./')
1959
+    . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1960
+    . (!$args ? '' : "&$args")
1961
+    . (!$ancre ? '' : "#$ancre");
1963 1962
 }
1964 1963
 
1965 1964
 
@@ -1970,18 +1969,18 @@  discard block
 block discarded – undo
1970 1969
  * @return string
1971 1970
  */
1972 1971
 function urlencode_1738($url) {
1973
-	if (preg_match(',[^\x00-\x7E],sS', $url)) {
1974
-		$uri = '';
1975
-		for ($i = 0; $i < strlen($url); $i++) {
1976
-			if (ord($a = $url[$i]) > 127) {
1977
-				$a = rawurlencode($a);
1978
-			}
1979
-			$uri .= $a;
1980
-		}
1981
-		$url = $uri;
1982
-	}
1972
+    if (preg_match(',[^\x00-\x7E],sS', $url)) {
1973
+        $uri = '';
1974
+        for ($i = 0; $i < strlen($url); $i++) {
1975
+            if (ord($a = $url[$i]) > 127) {
1976
+                $a = rawurlencode($a);
1977
+            }
1978
+            $uri .= $a;
1979
+        }
1980
+        $url = $uri;
1981
+    }
1983 1982
 
1984
-	return quote_amp($url);
1983
+    return quote_amp($url);
1985 1984
 }
1986 1985
 
1987 1986
 /**
@@ -1997,14 +1996,14 @@  discard block
 block discarded – undo
1997 1996
  * @return string
1998 1997
  */
1999 1998
 function generer_objet_url_absolue($id = 0, string $entite = '', string $args = '', string $ancre = '', ?bool $public = null, string $type = '', string $connect = ''): string {
2000
-	$id = intval($id);
2001
-	$h = generer_objet_url($id, $entite, $args, $ancre, $public, $type, $connect);
2002
-	if (!preg_match(',^\w+:,', $h)) {
2003
-		include_spip('inc/filtres_mini');
2004
-		$h = url_absolue($h);
2005
-	}
1999
+    $id = intval($id);
2000
+    $h = generer_objet_url($id, $entite, $args, $ancre, $public, $type, $connect);
2001
+    if (!preg_match(',^\w+:,', $h)) {
2002
+        include_spip('inc/filtres_mini');
2003
+        $h = url_absolue($h);
2004
+    }
2006 2005
 
2007
-	return $h;
2006
+    return $h;
2008 2007
 }
2009 2008
 
2010 2009
 /**
@@ -2012,7 +2011,7 @@  discard block
 block discarded – undo
2012 2011
  * @see  generer_objet_url_absolue
2013 2012
  */
2014 2013
 function generer_url_entite_absolue($id = 0, $entite = '', $args = '', $ancre = '', $connect = null) {
2015
-	return generer_objet_url_absolue(intval($id), $entite, $args, $ancre, true, '', $connect);
2014
+    return generer_objet_url_absolue(intval($id), $entite, $args, $ancre, true, '', $connect);
2016 2015
 }
2017 2016
 
2018 2017
 
@@ -2028,11 +2027,11 @@  discard block
 block discarded – undo
2028 2027
  *     true si la valeur est considérée active ; false sinon.
2029 2028
  **/
2030 2029
 function test_valeur_serveur($truc) {
2031
-	if (!$truc) {
2032
-		return false;
2033
-	}
2030
+    if (!$truc) {
2031
+        return false;
2032
+    }
2034 2033
 
2035
-	return (strtolower($truc) !== 'off');
2034
+    return (strtolower($truc) !== 'off');
2036 2035
 }
2037 2036
 
2038 2037
 //
@@ -2060,82 +2059,82 @@  discard block
 block discarded – undo
2060 2059
  */
2061 2060
 function url_de_base($profondeur = null) {
2062 2061
 
2063
-	static $url = [];
2064
-	if (is_array($profondeur)) {
2065
-		return $url = $profondeur;
2066
-	}
2067
-	if ($profondeur === false) {
2068
-		return $url;
2069
-	}
2070
-
2071
-	if (is_null($profondeur)) {
2072
-		$profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1);
2073
-	}
2074
-
2075
-	if (isset($url[$profondeur])) {
2076
-		return $url[$profondeur];
2077
-	}
2078
-
2079
-	$http = 'http';
2080
-
2081
-	if (
2082
-		isset($_SERVER['SCRIPT_URI'])
2083
-		and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https'
2084
-	) {
2085
-		$http = 'https';
2086
-	} elseif (
2087
-		isset($_SERVER['HTTPS'])
2088
-		and test_valeur_serveur($_SERVER['HTTPS'])
2089
-	) {
2090
-		$http = 'https';
2091
-	}
2092
-
2093
-	// note : HTTP_HOST contient le :port si necessaire
2094
-	$host = $_SERVER['HTTP_HOST'] ?? null;
2095
-	// si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback
2096
-	if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) {
2097
-		$host = $GLOBALS['meta']['adresse_site'];
2098
-		if ($scheme = parse_url($host, PHP_URL_SCHEME)) {
2099
-			$http = $scheme;
2100
-			$host = str_replace("{$scheme}://", '', $host);
2101
-		}
2102
-	}
2103
-	if (
2104
-		isset($_SERVER['SERVER_PORT'])
2105
-		and $port = $_SERVER['SERVER_PORT']
2106
-		and strpos($host, ':') == false
2107
-	) {
2108
-		if (!defined('_PORT_HTTP_STANDARD')) {
2109
-			define('_PORT_HTTP_STANDARD', '80');
2110
-		}
2111
-		if (!defined('_PORT_HTTPS_STANDARD')) {
2112
-			define('_PORT_HTTPS_STANDARD', '443');
2113
-		}
2114
-		if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) {
2115
-			$host .= ":$port";
2116
-		}
2117
-		if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) {
2118
-			$host .= ":$port";
2119
-		}
2120
-	}
2121
-
2122
-	if (!$GLOBALS['REQUEST_URI']) {
2123
-		if (isset($_SERVER['REQUEST_URI'])) {
2124
-			$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2125
-		} else {
2126
-			$GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2127
-			if (
2128
-				!empty($_SERVER['QUERY_STRING'])
2129
-				and !strpos($_SERVER['REQUEST_URI'], '?')
2130
-			) {
2131
-				$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2132
-			}
2133
-		}
2134
-	}
2135
-
2136
-	$url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
2137
-
2138
-	return $url[$profondeur];
2062
+    static $url = [];
2063
+    if (is_array($profondeur)) {
2064
+        return $url = $profondeur;
2065
+    }
2066
+    if ($profondeur === false) {
2067
+        return $url;
2068
+    }
2069
+
2070
+    if (is_null($profondeur)) {
2071
+        $profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1);
2072
+    }
2073
+
2074
+    if (isset($url[$profondeur])) {
2075
+        return $url[$profondeur];
2076
+    }
2077
+
2078
+    $http = 'http';
2079
+
2080
+    if (
2081
+        isset($_SERVER['SCRIPT_URI'])
2082
+        and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https'
2083
+    ) {
2084
+        $http = 'https';
2085
+    } elseif (
2086
+        isset($_SERVER['HTTPS'])
2087
+        and test_valeur_serveur($_SERVER['HTTPS'])
2088
+    ) {
2089
+        $http = 'https';
2090
+    }
2091
+
2092
+    // note : HTTP_HOST contient le :port si necessaire
2093
+    $host = $_SERVER['HTTP_HOST'] ?? null;
2094
+    // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback
2095
+    if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) {
2096
+        $host = $GLOBALS['meta']['adresse_site'];
2097
+        if ($scheme = parse_url($host, PHP_URL_SCHEME)) {
2098
+            $http = $scheme;
2099
+            $host = str_replace("{$scheme}://", '', $host);
2100
+        }
2101
+    }
2102
+    if (
2103
+        isset($_SERVER['SERVER_PORT'])
2104
+        and $port = $_SERVER['SERVER_PORT']
2105
+        and strpos($host, ':') == false
2106
+    ) {
2107
+        if (!defined('_PORT_HTTP_STANDARD')) {
2108
+            define('_PORT_HTTP_STANDARD', '80');
2109
+        }
2110
+        if (!defined('_PORT_HTTPS_STANDARD')) {
2111
+            define('_PORT_HTTPS_STANDARD', '443');
2112
+        }
2113
+        if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) {
2114
+            $host .= ":$port";
2115
+        }
2116
+        if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) {
2117
+            $host .= ":$port";
2118
+        }
2119
+    }
2120
+
2121
+    if (!$GLOBALS['REQUEST_URI']) {
2122
+        if (isset($_SERVER['REQUEST_URI'])) {
2123
+            $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2124
+        } else {
2125
+            $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2126
+            if (
2127
+                !empty($_SERVER['QUERY_STRING'])
2128
+                and !strpos($_SERVER['REQUEST_URI'], '?')
2129
+            ) {
2130
+                $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2131
+            }
2132
+        }
2133
+    }
2134
+
2135
+    $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
2136
+
2137
+    return $url[$profondeur];
2139 2138
 }
2140 2139
 
2141 2140
 /**
@@ -2148,26 +2147,26 @@  discard block
 block discarded – undo
2148 2147
  * @return string
2149 2148
  */
2150 2149
 function url_de_($http, $host, $request, $prof = 0) {
2151
-	$prof = max($prof, 0);
2150
+    $prof = max($prof, 0);
2152 2151
 
2153
-	$myself = ltrim($request, '/');
2154
-	# supprimer la chaine de GET
2155
-	[$myself] = explode('?', $myself);
2156
-	// vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
2157
-	// protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
2158
-	if (strpos($myself, '://') !== false) {
2159
-		$myself = explode('://', $myself);
2160
-		array_shift($myself);
2161
-		$myself = implode('://', $myself);
2162
-		$myself = explode('/', $myself);
2163
-		array_shift($myself);
2164
-		$myself = implode('/', $myself);
2165
-	}
2166
-	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2152
+    $myself = ltrim($request, '/');
2153
+    # supprimer la chaine de GET
2154
+    [$myself] = explode('?', $myself);
2155
+    // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
2156
+    // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
2157
+    if (strpos($myself, '://') !== false) {
2158
+        $myself = explode('://', $myself);
2159
+        array_shift($myself);
2160
+        $myself = implode('://', $myself);
2161
+        $myself = explode('/', $myself);
2162
+        array_shift($myself);
2163
+        $myself = implode('/', $myself);
2164
+    }
2165
+    $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2167 2166
 
2168
-	$url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2167
+    $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2169 2168
 
2170
-	return $url;
2169
+    return $url;
2171 2170
 }
2172 2171
 
2173 2172
 
@@ -2202,26 +2201,26 @@  discard block
 block discarded – undo
2202 2201
  * @return string URL
2203 2202
  **/
2204 2203
 function generer_url_ecrire(?string $script = '', $args = '', $no_entities = false, $rel = false) {
2205
-	$script ??= '';
2206
-	if (!$rel) {
2207
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2208
-	} else {
2209
-		if (!is_string($rel)) {
2210
-			$rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT;
2211
-		}
2212
-	}
2213
-
2214
-	[$script, $ancre] = array_pad(explode('#', $script), 2, null);
2215
-	if ($script and ($script <> 'accueil' or $rel)) {
2216
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
2217
-	} elseif ($args) {
2218
-		$args = "?$args";
2219
-	}
2220
-	if ($ancre) {
2221
-		$args .= "#$ancre";
2222
-	}
2223
-
2224
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2204
+    $script ??= '';
2205
+    if (!$rel) {
2206
+        $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2207
+    } else {
2208
+        if (!is_string($rel)) {
2209
+            $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT;
2210
+        }
2211
+    }
2212
+
2213
+    [$script, $ancre] = array_pad(explode('#', $script), 2, null);
2214
+    if ($script and ($script <> 'accueil' or $rel)) {
2215
+        $args = "?exec=$script" . (!$args ? '' : "&$args");
2216
+    } elseif ($args) {
2217
+        $args = "?$args";
2218
+    }
2219
+    if ($ancre) {
2220
+        $args .= "#$ancre";
2221
+    }
2222
+
2223
+    return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2225 2224
 }
2226 2225
 
2227 2226
 //
@@ -2243,15 +2242,15 @@  discard block
 block discarded – undo
2243 2242
  *     Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut
2244 2243
  **/
2245 2244
 function get_spip_script($default = '') {
2246
-	if (!defined('_SPIP_SCRIPT')) {
2247
-		return 'spip.php';
2248
-	}
2249
-	# cas define('_SPIP_SCRIPT', '');
2250
-	if (_SPIP_SCRIPT) {
2251
-		return _SPIP_SCRIPT;
2252
-	} else {
2253
-		return $default;
2254
-	}
2245
+    if (!defined('_SPIP_SCRIPT')) {
2246
+        return 'spip.php';
2247
+    }
2248
+    # cas define('_SPIP_SCRIPT', '');
2249
+    if (_SPIP_SCRIPT) {
2250
+        return _SPIP_SCRIPT;
2251
+    } else {
2252
+        return $default;
2253
+    }
2255 2254
 }
2256 2255
 
2257 2256
 /**
@@ -2280,45 +2279,45 @@  discard block
 block discarded – undo
2280 2279
  * @return string URL
2281 2280
  **/
2282 2281
 function generer_url_public($script = '', $args = '', $no_entities = false, $rel = true, $action = '') {
2283
-	// si le script est une action (spip_pass, spip_inscription),
2284
-	// standardiser vers la nouvelle API
2285
-
2286
-	if (is_array($args)) {
2287
-		$args = http_build_query($args);
2288
-	}
2289
-
2290
-	$url = '';
2291
-	if ($f = charger_fonction_url('page')) {
2292
-		$url = $f($script, $args);
2293
-		if ($url and !$rel) {
2294
-			include_spip('inc/filtres_mini');
2295
-			$url = url_absolue($url);
2296
-		}
2297
-	}
2298
-	if (!$url) {
2299
-		if (!$action) {
2300
-			$action = get_spip_script();
2301
-		}
2302
-		if ($script) {
2303
-			$action = parametre_url($action, _SPIP_PAGE, $script, '&');
2304
-		}
2305
-		if ($args) {
2306
-			$action .= (strpos($action, '?') !== false ? '&' : '?') . $args;
2307
-		}
2308
-		// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2309
-		$url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
2310
-	}
2311
-
2312
-	if (!$no_entities) {
2313
-		$url = quote_amp($url);
2314
-	}
2315
-
2316
-	return $url;
2282
+    // si le script est une action (spip_pass, spip_inscription),
2283
+    // standardiser vers la nouvelle API
2284
+
2285
+    if (is_array($args)) {
2286
+        $args = http_build_query($args);
2287
+    }
2288
+
2289
+    $url = '';
2290
+    if ($f = charger_fonction_url('page')) {
2291
+        $url = $f($script, $args);
2292
+        if ($url and !$rel) {
2293
+            include_spip('inc/filtres_mini');
2294
+            $url = url_absolue($url);
2295
+        }
2296
+    }
2297
+    if (!$url) {
2298
+        if (!$action) {
2299
+            $action = get_spip_script();
2300
+        }
2301
+        if ($script) {
2302
+            $action = parametre_url($action, _SPIP_PAGE, $script, '&');
2303
+        }
2304
+        if ($args) {
2305
+            $action .= (strpos($action, '?') !== false ? '&' : '?') . $args;
2306
+        }
2307
+        // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2308
+        $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
2309
+    }
2310
+
2311
+    if (!$no_entities) {
2312
+        $url = quote_amp($url);
2313
+    }
2314
+
2315
+    return $url;
2317 2316
 }
2318 2317
 
2319 2318
 function generer_url_prive($script, $args = '', $no_entities = false) {
2320 2319
 
2321
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2320
+    return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2322 2321
 }
2323 2322
 
2324 2323
 // Pour les formulaires en methode POST,
@@ -2343,19 +2342,19 @@  discard block
 block discarded – undo
2343 2342
  **/
2344 2343
 function generer_form_ecrire($script, $corps, $atts = '', $submit = '') {
2345 2344
 
2346
-	$script1 = explode('&', $script);
2347
-	$script1 = reset($script1);
2345
+    $script1 = explode('&', $script);
2346
+    $script1 = reset($script1);
2348 2347
 
2349
-	return "<form action='"
2350
-	. ($script ? generer_url_ecrire($script) : '')
2351
-	. "' "
2352
-	. ($atts ?: " method='post'")
2353
-	. "><div>\n"
2354
-	. "<input type='hidden' name='exec' value='$script1' />"
2355
-	. $corps
2356
-	. (!$submit ? '' :
2357
-		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
2358
-	. "</div></form>\n";
2348
+    return "<form action='"
2349
+    . ($script ? generer_url_ecrire($script) : '')
2350
+    . "' "
2351
+    . ($atts ?: " method='post'")
2352
+    . "><div>\n"
2353
+    . "<input type='hidden' name='exec' value='$script1' />"
2354
+    . $corps
2355
+    . (!$submit ? '' :
2356
+        ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
2357
+    . "</div></form>\n";
2359 2358
 }
2360 2359
 
2361 2360
 /**
@@ -2372,22 +2371,22 @@  discard block
 block discarded – undo
2372 2371
  * @return string
2373 2372
  */
2374 2373
 function generer_form_action($script, $corps, $atts = '', $public = false) {
2375
-	// si l'on est dans l'espace prive, on garde dans l'url
2376
-	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2377
-	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
2378
-	$h = (_DIR_RACINE and !$public)
2379
-		? generer_url_ecrire(_request('exec'))
2380
-		: generer_url_public();
2374
+    // si l'on est dans l'espace prive, on garde dans l'url
2375
+    // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2376
+    // ou non de proceder a l'authentification (cas typique de l'install par exemple)
2377
+    $h = (_DIR_RACINE and !$public)
2378
+        ? generer_url_ecrire(_request('exec'))
2379
+        : generer_url_public();
2381 2380
 
2382
-	return "\n<form action='" .
2383
-	$h .
2384
-	"'" .
2385
-	$atts .
2386
-	">\n" .
2387
-	'<div>' .
2388
-	"\n<input type='hidden' name='action' value='$script' />" .
2389
-	$corps .
2390
-	'</div></form>';
2381
+    return "\n<form action='" .
2382
+    $h .
2383
+    "'" .
2384
+    $atts .
2385
+    ">\n" .
2386
+    '<div>' .
2387
+    "\n<input type='hidden' name='action' value='$script' />" .
2388
+    $corps .
2389
+    '</div></form>';
2391 2390
 }
2392 2391
 
2393 2392
 /**
@@ -2406,22 +2405,22 @@  discard block
 block discarded – undo
2406 2405
  *     URL
2407 2406
  */
2408 2407
 function generer_url_action($script, $args = '', $no_entities = false, $public = false) {
2409
-	// si l'on est dans l'espace prive, on garde dans l'url
2410
-	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2411
-	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
2412
-	$url = (_DIR_RACINE and !$public)
2413
-		? generer_url_ecrire(_request('exec'))
2414
-		: generer_url_public('', '', false, false);
2415
-	$url = parametre_url($url, 'action', $script);
2416
-	if ($args) {
2417
-		$url .= quote_amp('&' . $args);
2418
-	}
2408
+    // si l'on est dans l'espace prive, on garde dans l'url
2409
+    // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2410
+    // ou non de proceder a l'authentification (cas typique de l'install par exemple)
2411
+    $url = (_DIR_RACINE and !$public)
2412
+        ? generer_url_ecrire(_request('exec'))
2413
+        : generer_url_public('', '', false, false);
2414
+    $url = parametre_url($url, 'action', $script);
2415
+    if ($args) {
2416
+        $url .= quote_amp('&' . $args);
2417
+    }
2419 2418
 
2420
-	if ($no_entities) {
2421
-		$url = str_replace('&amp;', '&', $url);
2422
-	}
2419
+    if ($no_entities) {
2420
+        $url = str_replace('&amp;', '&', $url);
2421
+    }
2423 2422
 
2424
-	return $url;
2423
+    return $url;
2425 2424
 }
2426 2425
 
2427 2426
 
@@ -2440,23 +2439,23 @@  discard block
 block discarded – undo
2440 2439
  *     URL
2441 2440
  */
2442 2441
 function generer_url_api(string $script, string $path, string $args, bool $no_entities = false, ?bool $public = null) {
2443
-	if (is_null($public)) {
2444
-		$public = (_DIR_RACINE ? false : '');
2445
-	}
2446
-	if (substr($script, -4) !== '.api') {
2447
-		$script .= '.api';
2448
-	}
2449
-	$url =
2450
-		(($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './')
2451
-	. $script . '/'
2452
-	. ($path ? trim($path, '/') : '')
2453
-	. ($args ? '?' . quote_amp($args) : '');
2442
+    if (is_null($public)) {
2443
+        $public = (_DIR_RACINE ? false : '');
2444
+    }
2445
+    if (substr($script, -4) !== '.api') {
2446
+        $script .= '.api';
2447
+    }
2448
+    $url =
2449
+        (($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './')
2450
+    . $script . '/'
2451
+    . ($path ? trim($path, '/') : '')
2452
+    . ($args ? '?' . quote_amp($args) : '');
2454 2453
 
2455
-	if ($no_entities) {
2456
-		$url = str_replace('&amp;', '&', $url);
2457
-	}
2454
+    if ($no_entities) {
2455
+        $url = str_replace('&amp;', '&', $url);
2456
+    }
2458 2457
 
2459
-	return $url;
2458
+    return $url;
2460 2459
 }
2461 2460
 
2462 2461
 
@@ -2469,8 +2468,8 @@  discard block
 block discarded – undo
2469 2468
  * @param string $ta Répertoire temporaire accessible
2470 2469
  */
2471 2470
 function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) {
2472
-	spip_initialisation_core($pi, $pa, $ti, $ta);
2473
-	spip_initialisation_suite();
2471
+    spip_initialisation_core($pi, $pa, $ti, $ta);
2472
+    spip_initialisation_suite();
2474 2473
 }
2475 2474
 
2476 2475
 /**
@@ -2490,310 +2489,310 @@  discard block
 block discarded – undo
2490 2489
  * @param string $ta Répertoire temporaire accessible
2491 2490
  */
2492 2491
 function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) {
2493
-	static $too_late = 0;
2494
-	if ($too_late++) {
2495
-		return;
2496
-	}
2497
-
2498
-	// Declaration des repertoires
2499
-
2500
-	// le nom du repertoire plugins/ activables/desactivables
2501
-	if (!defined('_DIR_PLUGINS')) {
2502
-		define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
2503
-	}
2504
-
2505
-	// le nom du repertoire des extensions/ permanentes du core, toujours actives
2506
-	if (!defined('_DIR_PLUGINS_DIST')) {
2507
-		define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
2508
-	}
2509
-
2510
-	// le nom du repertoire des librairies
2511
-	if (!defined('_DIR_LIB')) {
2512
-		define('_DIR_LIB', _DIR_RACINE . 'lib/');
2513
-	}
2514
-
2515
-	if (!defined('_DIR_IMG')) {
2516
-		define('_DIR_IMG', $pa);
2517
-	}
2518
-	if (!defined('_DIR_LOGOS')) {
2519
-		define('_DIR_LOGOS', $pa);
2520
-	}
2521
-	if (!defined('_DIR_IMG_ICONES')) {
2522
-		define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
2523
-	}
2524
-
2525
-	if (!defined('_DIR_DUMP')) {
2526
-		define('_DIR_DUMP', $ti . 'dump/');
2527
-	}
2528
-	if (!defined('_DIR_SESSIONS')) {
2529
-		define('_DIR_SESSIONS', $ti . 'sessions/');
2530
-	}
2531
-	if (!defined('_DIR_TRANSFERT')) {
2532
-		define('_DIR_TRANSFERT', $ti . 'upload/');
2533
-	}
2534
-	if (!defined('_DIR_CACHE')) {
2535
-		define('_DIR_CACHE', $ti . 'cache/');
2536
-	}
2537
-	if (!defined('_DIR_CACHE_XML')) {
2538
-		define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
2539
-	}
2540
-	if (!defined('_DIR_SKELS')) {
2541
-		define('_DIR_SKELS', _DIR_CACHE . 'skel/');
2542
-	}
2543
-	if (!defined('_DIR_AIDE')) {
2544
-		define('_DIR_AIDE', _DIR_CACHE . 'aide/');
2545
-	}
2546
-	if (!defined('_DIR_TMP')) {
2547
-		define('_DIR_TMP', $ti);
2548
-	}
2549
-
2550
-	if (!defined('_DIR_VAR')) {
2551
-		define('_DIR_VAR', $ta);
2552
-	}
2553
-
2554
-	if (!defined('_DIR_ETC')) {
2555
-		define('_DIR_ETC', $pi);
2556
-	}
2557
-	if (!defined('_DIR_CONNECT')) {
2558
-		define('_DIR_CONNECT', $pi);
2559
-	}
2560
-	if (!defined('_DIR_CHMOD')) {
2561
-		define('_DIR_CHMOD', $pi);
2562
-	}
2563
-
2564
-	if (!isset($GLOBALS['test_dirs'])) {
2565
-		// Pas $pi car il est bon de le mettre hors ecriture apres intstall
2566
-		// il sera rajoute automatiquement si besoin a l'etape 2 de l'install
2567
-	$GLOBALS['test_dirs'] = [$pa, $ti, $ta];
2568
-	}
2569
-
2570
-	// Declaration des fichiers
2571
-
2572
-	if (!defined('_CACHE_PLUGINS_PATH')) {
2573
-		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
2574
-	}
2575
-	if (!defined('_CACHE_PLUGINS_OPT')) {
2576
-		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
2577
-	}
2578
-	if (!defined('_CACHE_PLUGINS_FCT')) {
2579
-		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
2580
-	}
2581
-	if (!defined('_CACHE_PIPELINES')) {
2582
-		define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
2583
-	}
2584
-	if (!defined('_CACHE_CHEMIN')) {
2585
-		define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
2586
-	}
2587
-
2588
-	# attention .php obligatoire pour ecrire_fichier_securise
2589
-	if (!defined('_FILE_META')) {
2590
-		define('_FILE_META', $ti . 'meta_cache.php');
2591
-	}
2592
-	if (!defined('_DIR_LOG')) {
2593
-		define('_DIR_LOG', _DIR_TMP . 'log/');
2594
-	}
2595
-	if (!defined('_FILE_LOG')) {
2596
-		define('_FILE_LOG', 'spip');
2597
-	}
2598
-	if (!defined('_FILE_LOG_SUFFIX')) {
2599
-		define('_FILE_LOG_SUFFIX', '.log');
2600
-	}
2601
-
2602
-	// Le fichier de connexion a la base de donnees
2603
-	// tient compte des anciennes versions (inc_connect...)
2604
-	if (!defined('_FILE_CONNECT_INS')) {
2605
-		define('_FILE_CONNECT_INS', 'connect');
2606
-	}
2607
-	if (!defined('_FILE_CONNECT')) {
2608
-		define(
2609
-			'_FILE_CONNECT',
2610
-			(@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2611
-			: (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2612
-			: false))
2613
-		);
2614
-	}
2615
-
2616
-	// Le fichier de reglages des droits
2617
-	if (!defined('_FILE_CHMOD_INS')) {
2618
-		define('_FILE_CHMOD_INS', 'chmod');
2619
-	}
2620
-	if (!defined('_FILE_CHMOD')) {
2621
-		define(
2622
-			'_FILE_CHMOD',
2623
-			(@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2624
-			: false)
2625
-		);
2626
-	}
2627
-
2628
-	if (!defined('_FILE_LDAP')) {
2629
-		define('_FILE_LDAP', 'ldap.php');
2630
-	}
2631
-
2632
-	if (!defined('_FILE_TMP_SUFFIX')) {
2633
-		define('_FILE_TMP_SUFFIX', '.tmp.php');
2634
-	}
2635
-	if (!defined('_FILE_CONNECT_TMP')) {
2636
-		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2637
-	}
2638
-	if (!defined('_FILE_CHMOD_TMP')) {
2639
-		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2640
-	}
2641
-
2642
-	// Definition des droits d'acces en ecriture
2643
-	if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) {
2644
-		include_once _FILE_CHMOD;
2645
-	}
2646
-
2647
-	// Se mefier des fichiers mal remplis!
2648
-	if (!defined('_SPIP_CHMOD')) {
2649
-		define('_SPIP_CHMOD', 0777);
2650
-	}
2651
-
2652
-	if (!defined('_DEFAULT_CHARSET')) {
2653
-		/** Le charset par défaut lors de l'installation */
2654
-		define('_DEFAULT_CHARSET', 'utf-8');
2655
-	}
2656
-	if (!defined('_ROOT_PLUGINS')) {
2657
-		define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/');
2658
-	}
2659
-	if (!defined('_ROOT_PLUGINS_DIST')) {
2660
-		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/');
2661
-	}
2662
-	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2663
-		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2664
-	}
2665
-
2666
-	// La taille des Log
2667
-	if (!defined('_MAX_LOG')) {
2668
-		define('_MAX_LOG', 100);
2669
-	}
2670
-
2671
-	// Sommes-nous dans l'empire du Mal ?
2672
-	// (ou sous le signe du Pingouin, ascendant GNU ?)
2673
-	if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) {
2674
-		if (!defined('_OS_SERVEUR')) {
2675
-			define('_OS_SERVEUR', 'windows');
2676
-		}
2677
-		if (!defined('_SPIP_LOCK_MODE')) {
2678
-			define('_SPIP_LOCK_MODE', 1);
2679
-		} // utiliser le flock php
2680
-	} else {
2681
-		if (!defined('_OS_SERVEUR')) {
2682
-			define('_OS_SERVEUR', '');
2683
-		}
2684
-		if (!defined('_SPIP_LOCK_MODE')) {
2685
-			define('_SPIP_LOCK_MODE', 1);
2686
-		} // utiliser le flock php
2687
-		#if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
2688
-	}
2689
-
2690
-	// Langue par defaut
2691
-	if (!defined('_LANGUE_PAR_DEFAUT')) {
2692
-		define('_LANGUE_PAR_DEFAUT', 'fr');
2693
-	}
2694
-
2695
-	//
2696
-	// Module de lecture/ecriture/suppression de fichiers utilisant flock()
2697
-	// (non surchargeable en l'etat ; attention si on utilise include_spip()
2698
-	// pour le rendre surchargeable, on va provoquer un reecriture
2699
-	// systematique du noyau ou une baisse de perfs => a etudier)
2700
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
2701
-
2702
-	// charger tout de suite le path et son cache
2703
-	load_path_cache();
2704
-
2705
-	// *********** traiter les variables ************
2706
-
2707
-	//
2708
-	// Securite
2709
-	//
2710
-
2711
-	// Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
2712
-	if (isset($_REQUEST['GLOBALS'])) {
2713
-		die();
2714
-	}
2715
-	// nettoyer les magic quotes \' et les caracteres nuls %00
2716
-	spip_desinfecte($_GET);
2717
-	spip_desinfecte($_POST);
2718
-	spip_desinfecte($_COOKIE);
2719
-	spip_desinfecte($_REQUEST);
2720
-
2721
-	// appliquer le cookie_prefix
2722
-	if ($GLOBALS['cookie_prefix'] != 'spip') {
2723
-		include_spip('inc/cookie');
2724
-		recuperer_cookies_spip($GLOBALS['cookie_prefix']);
2725
-	}
2726
-
2727
-	// Compatibilite avec serveurs ne fournissant pas $REQUEST_URI
2728
-	if (isset($_SERVER['REQUEST_URI'])) {
2729
-		$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2730
-	} else {
2731
-		$GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2732
-		if (
2733
-			!empty($_SERVER['QUERY_STRING'])
2734
-			and !strpos($_SERVER['REQUEST_URI'], '?')
2735
-		) {
2736
-			$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2737
-		}
2738
-	}
2739
-
2740
-	// Duree de validite de l'alea pour les cookies et ce qui s'ensuit.
2741
-	if (!defined('_RENOUVELLE_ALEA')) {
2742
-		define('_RENOUVELLE_ALEA', 12 * 3600);
2743
-	}
2744
-	if (!defined('_DUREE_COOKIE_ADMIN')) {
2745
-		define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600);
2746
-	}
2747
-
2748
-	// charger les meta si possible et renouveller l'alea au besoin
2749
-	// charge aussi effacer_meta et ecrire_meta
2750
-	$inc_meta = charger_fonction('meta', 'inc');
2751
-	$inc_meta();
2752
-
2753
-	// nombre de repertoires depuis la racine
2754
-	// on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
2755
-	// ou a defaut celle donnee en meta ; (mais si celle-ci est fausse
2756
-	// le calcul est faux)
2757
-	if (!_DIR_RESTREINT) {
2758
-		$GLOBALS['profondeur_url'] = 1;
2759
-	} else {
2760
-		$uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : '';
2761
-		$uri_ref = $_SERVER['SCRIPT_NAME'];
2762
-		if (
2763
-			!$uri_ref
2764
-			// si on est appele avec un autre ti, on est sans doute en mutu
2765
-			// si jamais c'est de la mutu avec sous rep, on est perdu si on se fie
2766
-			// a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer
2767
-			// s'en remettre a l'adresse du site. alea jacta est.
2768
-			or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES
2769
-		) {
2770
-			if (isset($GLOBALS['meta']['adresse_site'])) {
2771
-				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2772
-				$uri_ref = ($uri_ref['path'] ?? '') . '/';
2773
-			} else {
2774
-				$uri_ref = '';
2775
-			}
2776
-		}
2777
-		if (!$uri or !$uri_ref) {
2778
-			$GLOBALS['profondeur_url'] = 0;
2779
-		} else {
2780
-			$GLOBALS['profondeur_url'] = max(
2781
-				0,
2782
-				substr_count($uri[0], '/')
2783
-				- substr_count($uri_ref, '/')
2784
-			);
2785
-		}
2786
-	}
2787
-	// s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
2788
-	if (_FILE_CONNECT) {
2789
-		if (
2790
-			verifier_visiteur() == '0minirezo'
2791
-			// si c'est un admin sans cookie admin, il faut ignorer le cache chemin !
2792
-			and !isset($_COOKIE['spip_admin'])
2793
-		) {
2794
-			clear_path_cache();
2795
-		}
2796
-	}
2492
+    static $too_late = 0;
2493
+    if ($too_late++) {
2494
+        return;
2495
+    }
2496
+
2497
+    // Declaration des repertoires
2498
+
2499
+    // le nom du repertoire plugins/ activables/desactivables
2500
+    if (!defined('_DIR_PLUGINS')) {
2501
+        define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
2502
+    }
2503
+
2504
+    // le nom du repertoire des extensions/ permanentes du core, toujours actives
2505
+    if (!defined('_DIR_PLUGINS_DIST')) {
2506
+        define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
2507
+    }
2508
+
2509
+    // le nom du repertoire des librairies
2510
+    if (!defined('_DIR_LIB')) {
2511
+        define('_DIR_LIB', _DIR_RACINE . 'lib/');
2512
+    }
2513
+
2514
+    if (!defined('_DIR_IMG')) {
2515
+        define('_DIR_IMG', $pa);
2516
+    }
2517
+    if (!defined('_DIR_LOGOS')) {
2518
+        define('_DIR_LOGOS', $pa);
2519
+    }
2520
+    if (!defined('_DIR_IMG_ICONES')) {
2521
+        define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
2522
+    }
2523
+
2524
+    if (!defined('_DIR_DUMP')) {
2525
+        define('_DIR_DUMP', $ti . 'dump/');
2526
+    }
2527
+    if (!defined('_DIR_SESSIONS')) {
2528
+        define('_DIR_SESSIONS', $ti . 'sessions/');
2529
+    }
2530
+    if (!defined('_DIR_TRANSFERT')) {
2531
+        define('_DIR_TRANSFERT', $ti . 'upload/');
2532
+    }
2533
+    if (!defined('_DIR_CACHE')) {
2534
+        define('_DIR_CACHE', $ti . 'cache/');
2535
+    }
2536
+    if (!defined('_DIR_CACHE_XML')) {
2537
+        define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
2538
+    }
2539
+    if (!defined('_DIR_SKELS')) {
2540
+        define('_DIR_SKELS', _DIR_CACHE . 'skel/');
2541
+    }
2542
+    if (!defined('_DIR_AIDE')) {
2543
+        define('_DIR_AIDE', _DIR_CACHE . 'aide/');
2544
+    }
2545
+    if (!defined('_DIR_TMP')) {
2546
+        define('_DIR_TMP', $ti);
2547
+    }
2548
+
2549
+    if (!defined('_DIR_VAR')) {
2550
+        define('_DIR_VAR', $ta);
2551
+    }
2552
+
2553
+    if (!defined('_DIR_ETC')) {
2554
+        define('_DIR_ETC', $pi);
2555
+    }
2556
+    if (!defined('_DIR_CONNECT')) {
2557
+        define('_DIR_CONNECT', $pi);
2558
+    }
2559
+    if (!defined('_DIR_CHMOD')) {
2560
+        define('_DIR_CHMOD', $pi);
2561
+    }
2562
+
2563
+    if (!isset($GLOBALS['test_dirs'])) {
2564
+        // Pas $pi car il est bon de le mettre hors ecriture apres intstall
2565
+        // il sera rajoute automatiquement si besoin a l'etape 2 de l'install
2566
+    $GLOBALS['test_dirs'] = [$pa, $ti, $ta];
2567
+    }
2568
+
2569
+    // Declaration des fichiers
2570
+
2571
+    if (!defined('_CACHE_PLUGINS_PATH')) {
2572
+        define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
2573
+    }
2574
+    if (!defined('_CACHE_PLUGINS_OPT')) {
2575
+        define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
2576
+    }
2577
+    if (!defined('_CACHE_PLUGINS_FCT')) {
2578
+        define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
2579
+    }
2580
+    if (!defined('_CACHE_PIPELINES')) {
2581
+        define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
2582
+    }
2583
+    if (!defined('_CACHE_CHEMIN')) {
2584
+        define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
2585
+    }
2586
+
2587
+    # attention .php obligatoire pour ecrire_fichier_securise
2588
+    if (!defined('_FILE_META')) {
2589
+        define('_FILE_META', $ti . 'meta_cache.php');
2590
+    }
2591
+    if (!defined('_DIR_LOG')) {
2592
+        define('_DIR_LOG', _DIR_TMP . 'log/');
2593
+    }
2594
+    if (!defined('_FILE_LOG')) {
2595
+        define('_FILE_LOG', 'spip');
2596
+    }
2597
+    if (!defined('_FILE_LOG_SUFFIX')) {
2598
+        define('_FILE_LOG_SUFFIX', '.log');
2599
+    }
2600
+
2601
+    // Le fichier de connexion a la base de donnees
2602
+    // tient compte des anciennes versions (inc_connect...)
2603
+    if (!defined('_FILE_CONNECT_INS')) {
2604
+        define('_FILE_CONNECT_INS', 'connect');
2605
+    }
2606
+    if (!defined('_FILE_CONNECT')) {
2607
+        define(
2608
+            '_FILE_CONNECT',
2609
+            (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2610
+            : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2611
+            : false))
2612
+        );
2613
+    }
2614
+
2615
+    // Le fichier de reglages des droits
2616
+    if (!defined('_FILE_CHMOD_INS')) {
2617
+        define('_FILE_CHMOD_INS', 'chmod');
2618
+    }
2619
+    if (!defined('_FILE_CHMOD')) {
2620
+        define(
2621
+            '_FILE_CHMOD',
2622
+            (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2623
+            : false)
2624
+        );
2625
+    }
2626
+
2627
+    if (!defined('_FILE_LDAP')) {
2628
+        define('_FILE_LDAP', 'ldap.php');
2629
+    }
2630
+
2631
+    if (!defined('_FILE_TMP_SUFFIX')) {
2632
+        define('_FILE_TMP_SUFFIX', '.tmp.php');
2633
+    }
2634
+    if (!defined('_FILE_CONNECT_TMP')) {
2635
+        define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2636
+    }
2637
+    if (!defined('_FILE_CHMOD_TMP')) {
2638
+        define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2639
+    }
2640
+
2641
+    // Definition des droits d'acces en ecriture
2642
+    if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) {
2643
+        include_once _FILE_CHMOD;
2644
+    }
2645
+
2646
+    // Se mefier des fichiers mal remplis!
2647
+    if (!defined('_SPIP_CHMOD')) {
2648
+        define('_SPIP_CHMOD', 0777);
2649
+    }
2650
+
2651
+    if (!defined('_DEFAULT_CHARSET')) {
2652
+        /** Le charset par défaut lors de l'installation */
2653
+        define('_DEFAULT_CHARSET', 'utf-8');
2654
+    }
2655
+    if (!defined('_ROOT_PLUGINS')) {
2656
+        define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/');
2657
+    }
2658
+    if (!defined('_ROOT_PLUGINS_DIST')) {
2659
+        define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/');
2660
+    }
2661
+    if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2662
+        define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2663
+    }
2664
+
2665
+    // La taille des Log
2666
+    if (!defined('_MAX_LOG')) {
2667
+        define('_MAX_LOG', 100);
2668
+    }
2669
+
2670
+    // Sommes-nous dans l'empire du Mal ?
2671
+    // (ou sous le signe du Pingouin, ascendant GNU ?)
2672
+    if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) {
2673
+        if (!defined('_OS_SERVEUR')) {
2674
+            define('_OS_SERVEUR', 'windows');
2675
+        }
2676
+        if (!defined('_SPIP_LOCK_MODE')) {
2677
+            define('_SPIP_LOCK_MODE', 1);
2678
+        } // utiliser le flock php
2679
+    } else {
2680
+        if (!defined('_OS_SERVEUR')) {
2681
+            define('_OS_SERVEUR', '');
2682
+        }
2683
+        if (!defined('_SPIP_LOCK_MODE')) {
2684
+            define('_SPIP_LOCK_MODE', 1);
2685
+        } // utiliser le flock php
2686
+        #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
2687
+    }
2688
+
2689
+    // Langue par defaut
2690
+    if (!defined('_LANGUE_PAR_DEFAUT')) {
2691
+        define('_LANGUE_PAR_DEFAUT', 'fr');
2692
+    }
2693
+
2694
+    //
2695
+    // Module de lecture/ecriture/suppression de fichiers utilisant flock()
2696
+    // (non surchargeable en l'etat ; attention si on utilise include_spip()
2697
+    // pour le rendre surchargeable, on va provoquer un reecriture
2698
+    // systematique du noyau ou une baisse de perfs => a etudier)
2699
+    include_once _ROOT_RESTREINT . 'inc/flock.php';
2700
+
2701
+    // charger tout de suite le path et son cache
2702
+    load_path_cache();
2703
+
2704
+    // *********** traiter les variables ************
2705
+
2706
+    //
2707
+    // Securite
2708
+    //
2709
+
2710
+    // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
2711
+    if (isset($_REQUEST['GLOBALS'])) {
2712
+        die();
2713
+    }
2714
+    // nettoyer les magic quotes \' et les caracteres nuls %00
2715
+    spip_desinfecte($_GET);
2716
+    spip_desinfecte($_POST);
2717
+    spip_desinfecte($_COOKIE);
2718
+    spip_desinfecte($_REQUEST);
2719
+
2720
+    // appliquer le cookie_prefix
2721
+    if ($GLOBALS['cookie_prefix'] != 'spip') {
2722
+        include_spip('inc/cookie');
2723
+        recuperer_cookies_spip($GLOBALS['cookie_prefix']);
2724
+    }
2725
+
2726
+    // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI
2727
+    if (isset($_SERVER['REQUEST_URI'])) {
2728
+        $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2729
+    } else {
2730
+        $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2731
+        if (
2732
+            !empty($_SERVER['QUERY_STRING'])
2733
+            and !strpos($_SERVER['REQUEST_URI'], '?')
2734
+        ) {
2735
+            $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2736
+        }
2737
+    }
2738
+
2739
+    // Duree de validite de l'alea pour les cookies et ce qui s'ensuit.
2740
+    if (!defined('_RENOUVELLE_ALEA')) {
2741
+        define('_RENOUVELLE_ALEA', 12 * 3600);
2742
+    }
2743
+    if (!defined('_DUREE_COOKIE_ADMIN')) {
2744
+        define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600);
2745
+    }
2746
+
2747
+    // charger les meta si possible et renouveller l'alea au besoin
2748
+    // charge aussi effacer_meta et ecrire_meta
2749
+    $inc_meta = charger_fonction('meta', 'inc');
2750
+    $inc_meta();
2751
+
2752
+    // nombre de repertoires depuis la racine
2753
+    // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
2754
+    // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse
2755
+    // le calcul est faux)
2756
+    if (!_DIR_RESTREINT) {
2757
+        $GLOBALS['profondeur_url'] = 1;
2758
+    } else {
2759
+        $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : '';
2760
+        $uri_ref = $_SERVER['SCRIPT_NAME'];
2761
+        if (
2762
+            !$uri_ref
2763
+            // si on est appele avec un autre ti, on est sans doute en mutu
2764
+            // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie
2765
+            // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer
2766
+            // s'en remettre a l'adresse du site. alea jacta est.
2767
+            or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES
2768
+        ) {
2769
+            if (isset($GLOBALS['meta']['adresse_site'])) {
2770
+                $uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2771
+                $uri_ref = ($uri_ref['path'] ?? '') . '/';
2772
+            } else {
2773
+                $uri_ref = '';
2774
+            }
2775
+        }
2776
+        if (!$uri or !$uri_ref) {
2777
+            $GLOBALS['profondeur_url'] = 0;
2778
+        } else {
2779
+            $GLOBALS['profondeur_url'] = max(
2780
+                0,
2781
+                substr_count($uri[0], '/')
2782
+                - substr_count($uri_ref, '/')
2783
+            );
2784
+        }
2785
+    }
2786
+    // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
2787
+    if (_FILE_CONNECT) {
2788
+        if (
2789
+            verifier_visiteur() == '0minirezo'
2790
+            // si c'est un admin sans cookie admin, il faut ignorer le cache chemin !
2791
+            and !isset($_COOKIE['spip_admin'])
2792
+        ) {
2793
+            clear_path_cache();
2794
+        }
2795
+    }
2797 2796
 }
2798 2797
 
2799 2798
 /**
@@ -2802,157 +2801,157 @@  discard block
 block discarded – undo
2802 2801
  *
2803 2802
  */
2804 2803
 function spip_initialisation_suite() {
2805
-	static $too_late = 0;
2806
-	if ($too_late++) {
2807
-		return;
2808
-	}
2809
-
2810
-	// taille mini des login
2811
-	if (!defined('_LOGIN_TROP_COURT')) {
2812
-		define('_LOGIN_TROP_COURT', 4);
2813
-	}
2814
-
2815
-	// la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2816
-	#if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko
2817
-	#if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels
2818
-	#if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels
2819
-
2820
-	// la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2821
-	#if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko
2822
-	#if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko
2823
-	#if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels
2824
-	#if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels
2825
-
2826
-	if (!defined('_PASS_LONGUEUR_MINI')) {
2827
-		define('_PASS_LONGUEUR_MINI', 6);
2828
-	}
2829
-
2830
-	// largeur maximale des images dans l'administration
2831
-	if (!defined('_IMG_ADMIN_MAX_WIDTH')) {
2832
-		define('_IMG_ADMIN_MAX_WIDTH', 768);
2833
-	}
2834
-
2835
-	// Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)
2836
-	if (!defined('_IMG_QUALITE')) {
2837
-		define('_IMG_QUALITE', 85);
2838
-	} # valeur par defaut
2839
-	if (!defined('_IMG_GD_QUALITE')) {
2840
-		define('_IMG_GD_QUALITE', _IMG_QUALITE);
2841
-	} # surcharge pour la lib GD
2842
-	if (!defined('_IMG_CONVERT_QUALITE')) {
2843
-		define('_IMG_CONVERT_QUALITE', _IMG_QUALITE);
2844
-	} # surcharge pour imagick en ligne de commande
2845
-	// Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE
2846
-	if (!defined('_IMG_IMAGICK_QUALITE')) {
2847
-		define('_IMG_IMAGICK_QUALITE', 75);
2848
-	} # surcharge pour imagick en PHP
2849
-
2850
-	if (!defined('_COPIE_LOCALE_MAX_SIZE')) {
2851
-		define('_COPIE_LOCALE_MAX_SIZE', 33_554_432);
2852
-	} // poids en octet
2853
-
2854
-	// qq chaines standard
2855
-	if (!defined('_ACCESS_FILE_NAME')) {
2856
-		define('_ACCESS_FILE_NAME', '.htaccess');
2857
-	}
2858
-	if (!defined('_AUTH_USER_FILE')) {
2859
-		define('_AUTH_USER_FILE', '.htpasswd');
2860
-	}
2861
-	if (!defined('_SPIP_DUMP')) {
2862
-		define('_SPIP_DUMP', 'dump@nom_site@@[email protected]');
2863
-	}
2864
-	if (!defined('_CACHE_RUBRIQUES')) {
2865
-		/** Fichier cache pour le navigateur de rubrique du bandeau */
2866
-		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2867
-	}
2868
-	if (!defined('_CACHE_RUBRIQUES_MAX')) {
2869
-		/** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
2870
-		define('_CACHE_RUBRIQUES_MAX', 500);
2871
-	}
2872
-
2873
-	if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) {
2874
-		/**
2875
-		 * Basculer les contextes ajax en fichier si la longueur d’url est trop grande
2876
-		 * @var int Nombre de caractères */
2877
-		define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000);
2878
-	}
2879
-
2880
-	if (!defined('_EXTENSION_SQUELETTES')) {
2881
-		define('_EXTENSION_SQUELETTES', 'html');
2882
-	}
2883
-
2884
-	if (!defined('_DOCTYPE_ECRIRE')) {
2885
-		/** Définit le doctype de l’espace privé */
2886
-		define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n");
2887
-	}
2888
-	if (!defined('_DOCTYPE_AIDE')) {
2889
-		/** Définit le doctype de l’aide en ligne */
2890
-		define(
2891
-			'_DOCTYPE_AIDE',
2892
-			"<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"
2893
-		);
2894
-	}
2895
-
2896
-	if (!defined('_SPIP_SCRIPT')) {
2897
-		/** L'adresse de base du site ; on peut mettre '' si la racine est gerée par
2898
-		 * le script de l'espace public, alias index.php */
2899
-		define('_SPIP_SCRIPT', 'spip.php');
2900
-	}
2901
-	if (!defined('_SPIP_PAGE')) {
2902
-		/** Argument page, personalisable en cas de conflit avec un autre script */
2903
-		define('_SPIP_PAGE', 'page');
2904
-	}
2905
-
2906
-	// le script de l'espace prive
2907
-	// Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:
2908
-	// les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)
2909
-	// meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html
2910
-	if (!defined('_SPIP_ECRIRE_SCRIPT')) {
2911
-		if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) {
2912
-			define('_SPIP_ECRIRE_SCRIPT', 'index.php');
2913
-		} else {
2914
-			define('_SPIP_ECRIRE_SCRIPT', '');
2915
-		}
2916
-	}
2917
-
2918
-
2919
-	if (!defined('_SPIP_AJAX')) {
2920
-		define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax']))
2921
-			? 1
2922
-			: (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));
2923
-	}
2924
-
2925
-	// La requete est-elle en ajax ?
2926
-	if (!defined('_AJAX')) {
2927
-		define(
2928
-			'_AJAX',
2929
-			(isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery
2930
-				or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery
2931
-				or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins
2932
-				or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip
2933
-			)
2934
-			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
2935
-		);
2936
-	}
2937
-
2938
-	# nombre de pixels maxi pour calcul de la vignette avec gd
2939
-	# au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation
2940
-	# les configurations limitees en memoire ont un seuil plutot vers 1MPixel
2941
-	if (!defined('_IMG_GD_MAX_PIXELS')) {
2942
-		define(
2943
-			'_IMG_GD_MAX_PIXELS',
2944
-			(isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes'])
2945
-			? $GLOBALS['meta']['max_taille_vignettes']
2946
-			: 0
2947
-		);
2948
-	}
2949
-
2950
-	// Protocoles a normaliser dans les chaines de langues
2951
-	if (!defined('_PROTOCOLES_STD')) {
2952
-		define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal');
2953
-	}
2954
-
2955
-	init_var_mode();
2804
+    static $too_late = 0;
2805
+    if ($too_late++) {
2806
+        return;
2807
+    }
2808
+
2809
+    // taille mini des login
2810
+    if (!defined('_LOGIN_TROP_COURT')) {
2811
+        define('_LOGIN_TROP_COURT', 4);
2812
+    }
2813
+
2814
+    // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2815
+    #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko
2816
+    #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels
2817
+    #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels
2818
+
2819
+    // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2820
+    #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko
2821
+    #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko
2822
+    #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels
2823
+    #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels
2824
+
2825
+    if (!defined('_PASS_LONGUEUR_MINI')) {
2826
+        define('_PASS_LONGUEUR_MINI', 6);
2827
+    }
2828
+
2829
+    // largeur maximale des images dans l'administration
2830
+    if (!defined('_IMG_ADMIN_MAX_WIDTH')) {
2831
+        define('_IMG_ADMIN_MAX_WIDTH', 768);
2832
+    }
2833
+
2834
+    // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)
2835
+    if (!defined('_IMG_QUALITE')) {
2836
+        define('_IMG_QUALITE', 85);
2837
+    } # valeur par defaut
2838
+    if (!defined('_IMG_GD_QUALITE')) {
2839
+        define('_IMG_GD_QUALITE', _IMG_QUALITE);
2840
+    } # surcharge pour la lib GD
2841
+    if (!defined('_IMG_CONVERT_QUALITE')) {
2842
+        define('_IMG_CONVERT_QUALITE', _IMG_QUALITE);
2843
+    } # surcharge pour imagick en ligne de commande
2844
+    // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE
2845
+    if (!defined('_IMG_IMAGICK_QUALITE')) {
2846
+        define('_IMG_IMAGICK_QUALITE', 75);
2847
+    } # surcharge pour imagick en PHP
2848
+
2849
+    if (!defined('_COPIE_LOCALE_MAX_SIZE')) {
2850
+        define('_COPIE_LOCALE_MAX_SIZE', 33_554_432);
2851
+    } // poids en octet
2852
+
2853
+    // qq chaines standard
2854
+    if (!defined('_ACCESS_FILE_NAME')) {
2855
+        define('_ACCESS_FILE_NAME', '.htaccess');
2856
+    }
2857
+    if (!defined('_AUTH_USER_FILE')) {
2858
+        define('_AUTH_USER_FILE', '.htpasswd');
2859
+    }
2860
+    if (!defined('_SPIP_DUMP')) {
2861
+        define('_SPIP_DUMP', 'dump@nom_site@@[email protected]');
2862
+    }
2863
+    if (!defined('_CACHE_RUBRIQUES')) {
2864
+        /** Fichier cache pour le navigateur de rubrique du bandeau */
2865
+        define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2866
+    }
2867
+    if (!defined('_CACHE_RUBRIQUES_MAX')) {
2868
+        /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
2869
+        define('_CACHE_RUBRIQUES_MAX', 500);
2870
+    }
2871
+
2872
+    if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) {
2873
+        /**
2874
+         * Basculer les contextes ajax en fichier si la longueur d’url est trop grande
2875
+         * @var int Nombre de caractères */
2876
+        define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000);
2877
+    }
2878
+
2879
+    if (!defined('_EXTENSION_SQUELETTES')) {
2880
+        define('_EXTENSION_SQUELETTES', 'html');
2881
+    }
2882
+
2883
+    if (!defined('_DOCTYPE_ECRIRE')) {
2884
+        /** Définit le doctype de l’espace privé */
2885
+        define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n");
2886
+    }
2887
+    if (!defined('_DOCTYPE_AIDE')) {
2888
+        /** Définit le doctype de l’aide en ligne */
2889
+        define(
2890
+            '_DOCTYPE_AIDE',
2891
+            "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"
2892
+        );
2893
+    }
2894
+
2895
+    if (!defined('_SPIP_SCRIPT')) {
2896
+        /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par
2897
+         * le script de l'espace public, alias index.php */
2898
+        define('_SPIP_SCRIPT', 'spip.php');
2899
+    }
2900
+    if (!defined('_SPIP_PAGE')) {
2901
+        /** Argument page, personalisable en cas de conflit avec un autre script */
2902
+        define('_SPIP_PAGE', 'page');
2903
+    }
2904
+
2905
+    // le script de l'espace prive
2906
+    // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:
2907
+    // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)
2908
+    // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html
2909
+    if (!defined('_SPIP_ECRIRE_SCRIPT')) {
2910
+        if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) {
2911
+            define('_SPIP_ECRIRE_SCRIPT', 'index.php');
2912
+        } else {
2913
+            define('_SPIP_ECRIRE_SCRIPT', '');
2914
+        }
2915
+    }
2916
+
2917
+
2918
+    if (!defined('_SPIP_AJAX')) {
2919
+        define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax']))
2920
+            ? 1
2921
+            : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));
2922
+    }
2923
+
2924
+    // La requete est-elle en ajax ?
2925
+    if (!defined('_AJAX')) {
2926
+        define(
2927
+            '_AJAX',
2928
+            (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery
2929
+                or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery
2930
+                or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins
2931
+                or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip
2932
+            )
2933
+            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
2934
+        );
2935
+    }
2936
+
2937
+    # nombre de pixels maxi pour calcul de la vignette avec gd
2938
+    # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation
2939
+    # les configurations limitees en memoire ont un seuil plutot vers 1MPixel
2940
+    if (!defined('_IMG_GD_MAX_PIXELS')) {
2941
+        define(
2942
+            '_IMG_GD_MAX_PIXELS',
2943
+            (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes'])
2944
+            ? $GLOBALS['meta']['max_taille_vignettes']
2945
+            : 0
2946
+        );
2947
+    }
2948
+
2949
+    // Protocoles a normaliser dans les chaines de langues
2950
+    if (!defined('_PROTOCOLES_STD')) {
2951
+        define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal');
2952
+    }
2953
+
2954
+    init_var_mode();
2956 2955
 }
2957 2956
 
2958 2957
 /**
@@ -2986,136 +2985,136 @@  discard block
 block discarded – undo
2986 2985
  * `   var_mode` (calcul ou recalcul).
2987 2986
  */
2988 2987
 function init_var_mode() {
2989
-	static $done = false;
2990
-	if (!$done) {
2991
-		if (isset($_GET['var_mode'])) {
2992
-			$var_mode = explode(',', $_GET['var_mode']);
2993
-			// tout le monde peut calcul/recalcul
2994
-			if (!defined('_VAR_MODE')) {
2995
-				if (in_array('recalcul', $var_mode)) {
2996
-					define('_VAR_MODE', 'recalcul');
2997
-				} elseif (in_array('calcul', $var_mode)) {
2998
-					define('_VAR_MODE', 'calcul');
2999
-				}
3000
-			}
3001
-			$var_mode = array_diff($var_mode, ['calcul', 'recalcul']);
3002
-			if ($var_mode) {
3003
-				include_spip('inc/autoriser');
3004
-				// autoriser preview si preview seulement, et sinon autoriser debug
3005
-				if (
3006
-					autoriser(
3007
-						($_GET['var_mode'] == 'preview')
3008
-						? 'previsualiser'
3009
-						: 'debug'
3010
-					)
3011
-				) {
3012
-					if (in_array('traduction', $var_mode)) {
3013
-						// forcer le calcul pour passer dans traduire
3014
-						if (!defined('_VAR_MODE')) {
3015
-							define('_VAR_MODE', 'calcul');
3016
-						}
3017
-						// et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages
3018
-						if (!defined('_VAR_NOCACHE')) {
3019
-							define('_VAR_NOCACHE', true);
3020
-						}
3021
-						$var_mode = array_diff($var_mode, ['traduction']);
3022
-					}
3023
-					if (in_array('preview', $var_mode)) {
3024
-						// basculer sur les criteres de preview dans les boucles
3025
-						if (!defined('_VAR_PREVIEW')) {
3026
-							define('_VAR_PREVIEW', true);
3027
-						}
3028
-						// forcer le calcul
3029
-						if (!defined('_VAR_MODE')) {
3030
-							define('_VAR_MODE', 'calcul');
3031
-						}
3032
-						// et ne pas enregistrer de cache
3033
-						if (!defined('_VAR_NOCACHE')) {
3034
-							define('_VAR_NOCACHE', true);
3035
-						}
3036
-						$var_mode = array_diff($var_mode, ['preview']);
3037
-					}
3038
-					if (in_array('inclure', $var_mode)) {
3039
-						// forcer le compilo et ignorer les caches existants
3040
-						if (!defined('_VAR_MODE')) {
3041
-							define('_VAR_MODE', 'calcul');
3042
-						}
3043
-						if (!defined('_VAR_INCLURE')) {
3044
-							define('_VAR_INCLURE', true);
3045
-						}
3046
-						// et ne pas enregistrer de cache
3047
-						if (!defined('_VAR_NOCACHE')) {
3048
-							define('_VAR_NOCACHE', true);
3049
-						}
3050
-						$var_mode = array_diff($var_mode, ['inclure']);
3051
-					}
3052
-					if (in_array('urls', $var_mode)) {
3053
-						// forcer le compilo et ignorer les caches existants
3054
-						if (!defined('_VAR_MODE')) {
3055
-							define('_VAR_MODE', 'calcul');
3056
-						}
3057
-						if (!defined('_VAR_URLS')) {
3058
-							define('_VAR_URLS', true);
3059
-						}
3060
-						$var_mode = array_diff($var_mode, ['urls']);
3061
-					}
3062
-					if (in_array('images', $var_mode)) {
3063
-						// forcer le compilo et ignorer les caches existants
3064
-						if (!defined('_VAR_MODE')) {
3065
-							define('_VAR_MODE', 'calcul');
3066
-						}
3067
-						// indiquer qu'on doit recalculer les images
3068
-						if (!defined('_VAR_IMAGES')) {
3069
-							define('_VAR_IMAGES', true);
3070
-						}
3071
-						$var_mode = array_diff($var_mode, ['images']);
3072
-					}
3073
-					if (in_array('debug', $var_mode)) {
3074
-						if (!defined('_VAR_MODE')) {
3075
-							define('_VAR_MODE', 'debug');
3076
-						}
3077
-						// et ne pas enregistrer de cache
3078
-						if (!defined('_VAR_NOCACHE')) {
3079
-							define('_VAR_NOCACHE', true);
3080
-						}
3081
-						$var_mode = array_diff($var_mode, ['debug']);
3082
-					}
3083
-					if (count($var_mode) and !defined('_VAR_MODE')) {
3084
-						define('_VAR_MODE', reset($var_mode));
3085
-					}
3086
-					if (isset($GLOBALS['visiteur_session']['nom'])) {
3087
-						spip_log($GLOBALS['visiteur_session']['nom']
3088
-							. ' ' . _VAR_MODE);
3089
-					}
3090
-				} // pas autorise ?
3091
-				else {
3092
-					// si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger
3093
-					if (
3094
-						!$GLOBALS['visiteur_session']
3095
-						and !empty($_SERVER['HTTP_HOST'])
3096
-						and !empty($_SERVER['REQUEST_METHOD'])
3097
-						and $_SERVER['REQUEST_METHOD'] === 'GET'
3098
-					) {
3099
-						$self = self('&', true);
3100
-						if (strpos($self, 'page=login') === false) {
3101
-							include_spip('inc/headers');
3102
-							$redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&');
3103
-							redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true));
3104
-						}
3105
-					}
3106
-					// sinon tant pis
3107
-				}
3108
-			}
3109
-		}
3110
-		if (!defined('_VAR_MODE')) {
3111
-			/**
3112
-			 * Indique le mode de calcul ou d'affichage de la page.
3113
-			 * @see init_var_mode()
3114
-			 */
3115
-			define('_VAR_MODE', false);
3116
-		}
3117
-		$done = true;
3118
-	}
2988
+    static $done = false;
2989
+    if (!$done) {
2990
+        if (isset($_GET['var_mode'])) {
2991
+            $var_mode = explode(',', $_GET['var_mode']);
2992
+            // tout le monde peut calcul/recalcul
2993
+            if (!defined('_VAR_MODE')) {
2994
+                if (in_array('recalcul', $var_mode)) {
2995
+                    define('_VAR_MODE', 'recalcul');
2996
+                } elseif (in_array('calcul', $var_mode)) {
2997
+                    define('_VAR_MODE', 'calcul');
2998
+                }
2999
+            }
3000
+            $var_mode = array_diff($var_mode, ['calcul', 'recalcul']);
3001
+            if ($var_mode) {
3002
+                include_spip('inc/autoriser');
3003
+                // autoriser preview si preview seulement, et sinon autoriser debug
3004
+                if (
3005
+                    autoriser(
3006
+                        ($_GET['var_mode'] == 'preview')
3007
+                        ? 'previsualiser'
3008
+                        : 'debug'
3009
+                    )
3010
+                ) {
3011
+                    if (in_array('traduction', $var_mode)) {
3012
+                        // forcer le calcul pour passer dans traduire
3013
+                        if (!defined('_VAR_MODE')) {
3014
+                            define('_VAR_MODE', 'calcul');
3015
+                        }
3016
+                        // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages
3017
+                        if (!defined('_VAR_NOCACHE')) {
3018
+                            define('_VAR_NOCACHE', true);
3019
+                        }
3020
+                        $var_mode = array_diff($var_mode, ['traduction']);
3021
+                    }
3022
+                    if (in_array('preview', $var_mode)) {
3023
+                        // basculer sur les criteres de preview dans les boucles
3024
+                        if (!defined('_VAR_PREVIEW')) {
3025
+                            define('_VAR_PREVIEW', true);
3026
+                        }
3027
+                        // forcer le calcul
3028
+                        if (!defined('_VAR_MODE')) {
3029
+                            define('_VAR_MODE', 'calcul');
3030
+                        }
3031
+                        // et ne pas enregistrer de cache
3032
+                        if (!defined('_VAR_NOCACHE')) {
3033
+                            define('_VAR_NOCACHE', true);
3034
+                        }
3035
+                        $var_mode = array_diff($var_mode, ['preview']);
3036
+                    }
3037
+                    if (in_array('inclure', $var_mode)) {
3038
+                        // forcer le compilo et ignorer les caches existants
3039
+                        if (!defined('_VAR_MODE')) {
3040
+                            define('_VAR_MODE', 'calcul');
3041
+                        }
3042
+                        if (!defined('_VAR_INCLURE')) {
3043
+                            define('_VAR_INCLURE', true);
3044
+                        }
3045
+                        // et ne pas enregistrer de cache
3046
+                        if (!defined('_VAR_NOCACHE')) {
3047
+                            define('_VAR_NOCACHE', true);
3048
+                        }
3049
+                        $var_mode = array_diff($var_mode, ['inclure']);
3050
+                    }
3051
+                    if (in_array('urls', $var_mode)) {
3052
+                        // forcer le compilo et ignorer les caches existants
3053
+                        if (!defined('_VAR_MODE')) {
3054
+                            define('_VAR_MODE', 'calcul');
3055
+                        }
3056
+                        if (!defined('_VAR_URLS')) {
3057
+                            define('_VAR_URLS', true);
3058
+                        }
3059
+                        $var_mode = array_diff($var_mode, ['urls']);
3060
+                    }
3061
+                    if (in_array('images', $var_mode)) {
3062
+                        // forcer le compilo et ignorer les caches existants
3063
+                        if (!defined('_VAR_MODE')) {
3064
+                            define('_VAR_MODE', 'calcul');
3065
+                        }
3066
+                        // indiquer qu'on doit recalculer les images
3067
+                        if (!defined('_VAR_IMAGES')) {
3068
+                            define('_VAR_IMAGES', true);
3069
+                        }
3070
+                        $var_mode = array_diff($var_mode, ['images']);
3071
+                    }
3072
+                    if (in_array('debug', $var_mode)) {
3073
+                        if (!defined('_VAR_MODE')) {
3074
+                            define('_VAR_MODE', 'debug');
3075
+                        }
3076
+                        // et ne pas enregistrer de cache
3077
+                        if (!defined('_VAR_NOCACHE')) {
3078
+                            define('_VAR_NOCACHE', true);
3079
+                        }
3080
+                        $var_mode = array_diff($var_mode, ['debug']);
3081
+                    }
3082
+                    if (count($var_mode) and !defined('_VAR_MODE')) {
3083
+                        define('_VAR_MODE', reset($var_mode));
3084
+                    }
3085
+                    if (isset($GLOBALS['visiteur_session']['nom'])) {
3086
+                        spip_log($GLOBALS['visiteur_session']['nom']
3087
+                            . ' ' . _VAR_MODE);
3088
+                    }
3089
+                } // pas autorise ?
3090
+                else {
3091
+                    // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger
3092
+                    if (
3093
+                        !$GLOBALS['visiteur_session']
3094
+                        and !empty($_SERVER['HTTP_HOST'])
3095
+                        and !empty($_SERVER['REQUEST_METHOD'])
3096
+                        and $_SERVER['REQUEST_METHOD'] === 'GET'
3097
+                    ) {
3098
+                        $self = self('&', true);
3099
+                        if (strpos($self, 'page=login') === false) {
3100
+                            include_spip('inc/headers');
3101
+                            $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&');
3102
+                            redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true));
3103
+                        }
3104
+                    }
3105
+                    // sinon tant pis
3106
+                }
3107
+            }
3108
+        }
3109
+        if (!defined('_VAR_MODE')) {
3110
+            /**
3111
+             * Indique le mode de calcul ou d'affichage de la page.
3112
+             * @see init_var_mode()
3113
+             */
3114
+            define('_VAR_MODE', false);
3115
+        }
3116
+        $done = true;
3117
+    }
3119 3118
 }
3120 3119
 
3121 3120
 /**
@@ -3127,16 +3126,16 @@  discard block
 block discarded – undo
3127 3126
  * @param bool $deep = true : appliquer récursivement
3128 3127
 **/
3129 3128
 function spip_desinfecte(&$t, $deep = true) {
3130
-	foreach ($t as $key => $val) {
3131
-		if (is_string($t[$key])) {
3132
-			$t[$key] = str_replace(chr(0), '-', $t[$key]);
3133
-		} // traiter aussi les "texte_plus" de article_edit
3134
-		else {
3135
-			if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') {
3136
-				spip_desinfecte($t[$key], $deep);
3137
-			}
3138
-		}
3139
-	}
3129
+    foreach ($t as $key => $val) {
3130
+        if (is_string($t[$key])) {
3131
+            $t[$key] = str_replace(chr(0), '-', $t[$key]);
3132
+        } // traiter aussi les "texte_plus" de article_edit
3133
+        else {
3134
+            if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') {
3135
+                spip_desinfecte($t[$key], $deep);
3136
+            }
3137
+        }
3138
+    }
3140 3139
 }
3141 3140
 
3142 3141
 /**
@@ -3149,64 +3148,64 @@  discard block
 block discarded – undo
3149 3148
  * @return string|0|false
3150 3149
 **/
3151 3150
 function verifier_visiteur() {
3152
-	@spip_initialisation_core(
3153
-		(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3154
-		(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3155
-		(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3156
-		(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3157
-	);
3158
-
3159
-	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
3160
-	// dans un formulaire sans login (ex: #FORMULAIRE_FORUM)
3161
-	// Attention on separe bien session_nom et nom, pour eviter
3162
-	// les melanges entre donnees SQL et variables plus aleatoires
3163
-	$variables_session = ['session_nom', 'session_email'];
3164
-	foreach ($variables_session as $var) {
3165
-		if (_request($var) !== null) {
3166
-			$init = true;
3167
-			break;
3168
-		}
3169
-	}
3170
-	if (isset($init)) {
3171
-		#@spip_initialisation_suite();
3172
-		$session = charger_fonction('session', 'inc');
3173
-		$session();
3174
-		include_spip('inc/texte');
3175
-		foreach ($variables_session as $var) {
3176
-			if (($a = _request($var)) !== null) {
3177
-				$GLOBALS['visiteur_session'][$var] = safehtml($a);
3178
-			}
3179
-		}
3180
-		if (!isset($GLOBALS['visiteur_session']['id_auteur'])) {
3181
-			$GLOBALS['visiteur_session']['id_auteur'] = 0;
3182
-		}
3183
-		$session($GLOBALS['visiteur_session']);
3184
-
3185
-		return 0;
3186
-	}
3187
-
3188
-	$h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3189
-	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3190
-		$session = charger_fonction('session', 'inc');
3191
-		if ($session()) {
3192
-			return $GLOBALS['visiteur_session']['statut'];
3193
-		}
3194
-		if ($h and isset($_SERVER['PHP_AUTH_PW'])) {
3195
-			include_spip('inc/auth');
3196
-			$h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
3197
-		}
3198
-		if ($h) {
3199
-			$GLOBALS['visiteur_session'] = $h;
3200
-
3201
-			return $GLOBALS['visiteur_session']['statut'];
3202
-		}
3203
-	}
3204
-
3205
-	// au moins son navigateur nous dit la langue preferee de cet inconnu
3206
-	include_spip('inc/lang');
3207
-	utiliser_langue_visiteur();
3208
-
3209
-	return false;
3151
+    @spip_initialisation_core(
3152
+        (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3153
+        (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3154
+        (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3155
+        (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3156
+    );
3157
+
3158
+    // Demarrer une session NON AUTHENTIFIEE si on donne son nom
3159
+    // dans un formulaire sans login (ex: #FORMULAIRE_FORUM)
3160
+    // Attention on separe bien session_nom et nom, pour eviter
3161
+    // les melanges entre donnees SQL et variables plus aleatoires
3162
+    $variables_session = ['session_nom', 'session_email'];
3163
+    foreach ($variables_session as $var) {
3164
+        if (_request($var) !== null) {
3165
+            $init = true;
3166
+            break;
3167
+        }
3168
+    }
3169
+    if (isset($init)) {
3170
+        #@spip_initialisation_suite();
3171
+        $session = charger_fonction('session', 'inc');
3172
+        $session();
3173
+        include_spip('inc/texte');
3174
+        foreach ($variables_session as $var) {
3175
+            if (($a = _request($var)) !== null) {
3176
+                $GLOBALS['visiteur_session'][$var] = safehtml($a);
3177
+            }
3178
+        }
3179
+        if (!isset($GLOBALS['visiteur_session']['id_auteur'])) {
3180
+            $GLOBALS['visiteur_session']['id_auteur'] = 0;
3181
+        }
3182
+        $session($GLOBALS['visiteur_session']);
3183
+
3184
+        return 0;
3185
+    }
3186
+
3187
+    $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3188
+    if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3189
+        $session = charger_fonction('session', 'inc');
3190
+        if ($session()) {
3191
+            return $GLOBALS['visiteur_session']['statut'];
3192
+        }
3193
+        if ($h and isset($_SERVER['PHP_AUTH_PW'])) {
3194
+            include_spip('inc/auth');
3195
+            $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
3196
+        }
3197
+        if ($h) {
3198
+            $GLOBALS['visiteur_session'] = $h;
3199
+
3200
+            return $GLOBALS['visiteur_session']['statut'];
3201
+        }
3202
+    }
3203
+
3204
+    // au moins son navigateur nous dit la langue preferee de cet inconnu
3205
+    include_spip('inc/lang');
3206
+    utiliser_langue_visiteur();
3207
+
3208
+    return false;
3210 3209
 }
3211 3210
 
3212 3211
 
@@ -3229,21 +3228,21 @@  discard block
 block discarded – undo
3229 3228
  *     - string Langue utilisée.
3230 3229
  **/
3231 3230
 function lang_select($lang = null) {
3232
-	static $pile_langues = [];
3233
-	if (!function_exists('changer_langue')) {
3234
-		include_spip('inc/lang');
3235
-	}
3236
-	if ($lang === null) {
3237
-		$lang = array_pop($pile_langues);
3238
-	} else {
3239
-		array_push($pile_langues, $GLOBALS['spip_lang']);
3240
-	}
3241
-	if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) {
3242
-		return $lang;
3243
-	}
3244
-	changer_langue($lang);
3231
+    static $pile_langues = [];
3232
+    if (!function_exists('changer_langue')) {
3233
+        include_spip('inc/lang');
3234
+    }
3235
+    if ($lang === null) {
3236
+        $lang = array_pop($pile_langues);
3237
+    } else {
3238
+        array_push($pile_langues, $GLOBALS['spip_lang']);
3239
+    }
3240
+    if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) {
3241
+        return $lang;
3242
+    }
3243
+    changer_langue($lang);
3245 3244
 
3246
-	return $lang;
3245
+    return $lang;
3247 3246
 }
3248 3247
 
3249 3248
 /**
@@ -3260,20 +3259,20 @@  discard block
 block discarded – undo
3260 3259
  *     Identifiant de la session
3261 3260
  **/
3262 3261
 function spip_session($force = false) {
3263
-	static $session;
3264
-	if ($force or !isset($session)) {
3265
-		$s = pipeline(
3266
-			'definir_session',
3267
-			$GLOBALS['visiteur_session']
3268
-				? serialize($GLOBALS['visiteur_session'])
3269
-				. '_' . @$_COOKIE['spip_session']
3270
-				: ''
3271
-		);
3272
-		$session = $s ? substr(md5($s), 0, 8) : '';
3273
-	}
3262
+    static $session;
3263
+    if ($force or !isset($session)) {
3264
+        $s = pipeline(
3265
+            'definir_session',
3266
+            $GLOBALS['visiteur_session']
3267
+                ? serialize($GLOBALS['visiteur_session'])
3268
+                . '_' . @$_COOKIE['spip_session']
3269
+                : ''
3270
+        );
3271
+        $session = $s ? substr(md5($s), 0, 8) : '';
3272
+    }
3274 3273
 
3275
-	#spip_log('session: '.$session);
3276
-	return $session;
3274
+    #spip_log('session: '.$session);
3275
+    return $session;
3277 3276
 }
3278 3277
 
3279 3278
 
@@ -3292,9 +3291,9 @@  discard block
 block discarded – undo
3292 3291
  *    Lien sur une icone d'aide
3293 3292
  **/
3294 3293
 function aider($aide = '', $distante = false) {
3295
-	$aider = charger_fonction('aide', 'inc', true);
3294
+    $aider = charger_fonction('aide', 'inc', true);
3296 3295
 
3297
-	return $aider ? $aider($aide, '', [], $distante) : '';
3296
+    return $aider ? $aider($aide, '', [], $distante) : '';
3298 3297
 }
3299 3298
 
3300 3299
 /**
@@ -3304,24 +3303,24 @@  discard block
 block discarded – undo
3304 3303
  */
3305 3304
 function exec_info_dist() {
3306 3305
 
3307
-	include_spip('inc/autoriser');
3308
-	if (autoriser('phpinfos')) {
3309
-		$cookies_masques = ['spip_session', 'PHPSESSID'];
3310
-		$cookies_backup = [];
3311
-		foreach ($cookies_masques as $k) {
3312
-			if (!empty($_COOKIE[$k])) {
3313
-				$cookies_backup[$k] = $_COOKIE[$k];
3314
-				$_COOKIE[$k] = '******************************';
3315
-			}
3316
-		}
3317
-		phpinfo();
3318
-		foreach ($cookies_backup as $k => $v) {
3319
-			$_COOKIE[$k] = $v;
3320
-		}
3321
-	} else {
3322
-		include_spip('inc/filtres');
3323
-		sinon_interdire_acces();
3324
-	}
3306
+    include_spip('inc/autoriser');
3307
+    if (autoriser('phpinfos')) {
3308
+        $cookies_masques = ['spip_session', 'PHPSESSID'];
3309
+        $cookies_backup = [];
3310
+        foreach ($cookies_masques as $k) {
3311
+            if (!empty($_COOKIE[$k])) {
3312
+                $cookies_backup[$k] = $_COOKIE[$k];
3313
+                $_COOKIE[$k] = '******************************';
3314
+            }
3315
+        }
3316
+        phpinfo();
3317
+        foreach ($cookies_backup as $k => $v) {
3318
+            $_COOKIE[$k] = $v;
3319
+        }
3320
+    } else {
3321
+        include_spip('inc/filtres');
3322
+        sinon_interdire_acces();
3323
+    }
3325 3324
 }
3326 3325
 
3327 3326
 /**
@@ -3341,13 +3340,13 @@  discard block
 block discarded – undo
3341 3340
  *     - string si $message à false.
3342 3341
  **/
3343 3342
 function erreur_squelette($message = '', $lieu = '') {
3344
-	$debusquer = charger_fonction('debusquer', 'public');
3345
-	if (is_array($lieu)) {
3346
-		include_spip('public/compiler');
3347
-		$lieu = reconstruire_contexte_compil($lieu);
3348
-	}
3343
+    $debusquer = charger_fonction('debusquer', 'public');
3344
+    if (is_array($lieu)) {
3345
+        include_spip('public/compiler');
3346
+        $lieu = reconstruire_contexte_compil($lieu);
3347
+    }
3349 3348
 
3350
-	return $debusquer($message, $lieu);
3349
+    return $debusquer($message, $lieu);
3351 3350
 }
3352 3351
 
3353 3352
 /**
@@ -3384,108 +3383,108 @@  discard block
 block discarded – undo
3384 3383
  *     - ou tableau d'information sur le squelette.
3385 3384
  */
3386 3385
 function recuperer_fond($fond, $contexte = [], $options = [], string $connect = '') {
3387
-	if (!function_exists('evaluer_fond')) {
3388
-		include_spip('public/assembler');
3389
-	}
3390
-	// assurer la compat avec l'ancienne syntaxe
3391
-	// (trim etait le 3eme argument, par defaut a true)
3392
-	if (!is_array($options)) {
3393
-		$options = ['trim' => $options];
3394
-	}
3395
-	if (!isset($options['trim'])) {
3396
-		$options['trim'] = true;
3397
-	}
3398
-
3399
-	if (isset($contexte['connect'])) {
3400
-		$connect = $contexte['connect'];
3401
-		unset($contexte['connect']);
3402
-	}
3403
-
3404
-	$texte = '';
3405
-	$pages = [];
3406
-	$lang_select = '';
3407
-	if (!isset($options['etoile']) or !$options['etoile']) {
3408
-		// Si on a inclus sans fixer le critere de lang, on prend la langue courante
3409
-		if (!isset($contexte['lang'])) {
3410
-			$contexte['lang'] = $GLOBALS['spip_lang'];
3411
-		}
3412
-
3413
-		if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
3414
-			$lang_select = lang_select($contexte['lang']);
3415
-		}
3416
-	}
3417
-
3418
-	if (!isset($GLOBALS['_INC_PUBLIC'])) {
3419
-		$GLOBALS['_INC_PUBLIC'] = 0;
3420
-	}
3421
-
3422
-	$GLOBALS['_INC_PUBLIC']++;
3423
-
3424
-	// fix #4235
3425
-	$cache_utilise_session_appelant	= ($GLOBALS['cache_utilise_session'] ?? null);
3426
-
3427
-
3428
-	foreach (is_array($fond) ? $fond : [$fond] as $f) {
3429
-		unset($GLOBALS['cache_utilise_session']);	// fix #4235
3430
-
3431
-		$page = evaluer_fond($f, $contexte, $connect);
3432
-		if ($page === '') {
3433
-			$c = $options['compil'] ?? '';
3434
-			$a = ['fichier' => $f];
3435
-			$erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
3436
-			erreur_squelette($erreur, $c);
3437
-			// eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
3438
-			$page = ['texte' => '', 'erreur' => $erreur];
3439
-		}
3440
-
3441
-		$page = pipeline('recuperer_fond', [
3442
-			'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect],
3443
-			'data' => $page
3444
-		]);
3445
-		if (isset($options['ajax']) and $options['ajax']) {
3446
-			if (!function_exists('encoder_contexte_ajax')) {
3447
-				include_spip('inc/filtres');
3448
-			}
3449
-			$page['texte'] = encoder_contexte_ajax(
3450
-				array_merge(
3451
-					$contexte,
3452
-					['fond' => $f],
3453
-					($connect ? ['connect' => $connect] : [])
3454
-				),
3455
-				'',
3456
-				$page['texte'],
3457
-				$options['ajax']
3458
-			);
3459
-		}
3460
-
3461
-		if (isset($options['raw']) and $options['raw']) {
3462
-			$pages[] = $page;
3463
-		} else {
3464
-			$texte .= $options['trim'] ? rtrim($page['texte'] ?? '') : $page['texte'];
3465
-		}
3466
-
3467
-		// contamination de la session appelante, pour les inclusions statiques
3468
-		if (isset($page['invalideurs']['session'])) {
3469
-			$cache_utilise_session_appelant = $page['invalideurs']['session'];
3470
-		}
3471
-	}
3472
-
3473
-	// restaurer le sessionnement du contexte appelant,
3474
-	// éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée
3475
-	if (isset($cache_utilise_session_appelant)) {
3476
-		$GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant;
3477
-	}
3478
-
3479
-	$GLOBALS['_INC_PUBLIC']--;
3480
-
3481
-	if ($lang_select) {
3482
-		lang_select();
3483
-	}
3484
-	if (isset($options['raw']) and $options['raw']) {
3485
-		return is_array($fond) ? $pages : reset($pages);
3486
-	} else {
3487
-		return $options['trim'] ? ltrim($texte) : $texte;
3488
-	}
3386
+    if (!function_exists('evaluer_fond')) {
3387
+        include_spip('public/assembler');
3388
+    }
3389
+    // assurer la compat avec l'ancienne syntaxe
3390
+    // (trim etait le 3eme argument, par defaut a true)
3391
+    if (!is_array($options)) {
3392
+        $options = ['trim' => $options];
3393
+    }
3394
+    if (!isset($options['trim'])) {
3395
+        $options['trim'] = true;
3396
+    }
3397
+
3398
+    if (isset($contexte['connect'])) {
3399
+        $connect = $contexte['connect'];
3400
+        unset($contexte['connect']);
3401
+    }
3402
+
3403
+    $texte = '';
3404
+    $pages = [];
3405
+    $lang_select = '';
3406
+    if (!isset($options['etoile']) or !$options['etoile']) {
3407
+        // Si on a inclus sans fixer le critere de lang, on prend la langue courante
3408
+        if (!isset($contexte['lang'])) {
3409
+            $contexte['lang'] = $GLOBALS['spip_lang'];
3410
+        }
3411
+
3412
+        if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
3413
+            $lang_select = lang_select($contexte['lang']);
3414
+        }
3415
+    }
3416
+
3417
+    if (!isset($GLOBALS['_INC_PUBLIC'])) {
3418
+        $GLOBALS['_INC_PUBLIC'] = 0;
3419
+    }
3420
+
3421
+    $GLOBALS['_INC_PUBLIC']++;
3422
+
3423
+    // fix #4235
3424
+    $cache_utilise_session_appelant	= ($GLOBALS['cache_utilise_session'] ?? null);
3425
+
3426
+
3427
+    foreach (is_array($fond) ? $fond : [$fond] as $f) {
3428
+        unset($GLOBALS['cache_utilise_session']);	// fix #4235
3429
+
3430
+        $page = evaluer_fond($f, $contexte, $connect);
3431
+        if ($page === '') {
3432
+            $c = $options['compil'] ?? '';
3433
+            $a = ['fichier' => $f];
3434
+            $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
3435
+            erreur_squelette($erreur, $c);
3436
+            // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
3437
+            $page = ['texte' => '', 'erreur' => $erreur];
3438
+        }
3439
+
3440
+        $page = pipeline('recuperer_fond', [
3441
+            'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect],
3442
+            'data' => $page
3443
+        ]);
3444
+        if (isset($options['ajax']) and $options['ajax']) {
3445
+            if (!function_exists('encoder_contexte_ajax')) {
3446
+                include_spip('inc/filtres');
3447
+            }
3448
+            $page['texte'] = encoder_contexte_ajax(
3449
+                array_merge(
3450
+                    $contexte,
3451
+                    ['fond' => $f],
3452
+                    ($connect ? ['connect' => $connect] : [])
3453
+                ),
3454
+                '',
3455
+                $page['texte'],
3456
+                $options['ajax']
3457
+            );
3458
+        }
3459
+
3460
+        if (isset($options['raw']) and $options['raw']) {
3461
+            $pages[] = $page;
3462
+        } else {
3463
+            $texte .= $options['trim'] ? rtrim($page['texte'] ?? '') : $page['texte'];
3464
+        }
3465
+
3466
+        // contamination de la session appelante, pour les inclusions statiques
3467
+        if (isset($page['invalideurs']['session'])) {
3468
+            $cache_utilise_session_appelant = $page['invalideurs']['session'];
3469
+        }
3470
+    }
3471
+
3472
+    // restaurer le sessionnement du contexte appelant,
3473
+    // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée
3474
+    if (isset($cache_utilise_session_appelant)) {
3475
+        $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant;
3476
+    }
3477
+
3478
+    $GLOBALS['_INC_PUBLIC']--;
3479
+
3480
+    if ($lang_select) {
3481
+        lang_select();
3482
+    }
3483
+    if (isset($options['raw']) and $options['raw']) {
3484
+        return is_array($fond) ? $pages : reset($pages);
3485
+    } else {
3486
+        return $options['trim'] ? ltrim($texte) : $texte;
3487
+    }
3489 3488
 }
3490 3489
 
3491 3490
 /**
@@ -3495,7 +3494,7 @@  discard block
 block discarded – undo
3495 3494
  * @return string
3496 3495
  */
3497 3496
 function trouve_modele($nom) {
3498
-	return trouver_fond($nom, 'modeles/');
3497
+    return trouver_fond($nom, 'modeles/');
3499 3498
 }
3500 3499
 
3501 3500
 /**
@@ -3511,21 +3510,21 @@  discard block
 block discarded – undo
3511 3510
  * @return array|string
3512 3511
  */
3513 3512
 function trouver_fond($nom, $dir = '', $pathinfo = false) {
3514
-	$f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3515
-	if (!$pathinfo) {
3516
-		return $f;
3517
-	}
3518
-	// renvoyer un tableau detaille si $pathinfo==true
3519
-	$p = pathinfo($f);
3520
-	if (!isset($p['extension']) or !$p['extension']) {
3521
-		$p['extension'] = _EXTENSION_SQUELETTES;
3522
-	}
3523
-	if (!isset($p['extension']) or !$p['filename']) {
3524
-		$p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
3525
-	}
3526
-	$p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');
3513
+    $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3514
+    if (!$pathinfo) {
3515
+        return $f;
3516
+    }
3517
+    // renvoyer un tableau detaille si $pathinfo==true
3518
+    $p = pathinfo($f);
3519
+    if (!isset($p['extension']) or !$p['extension']) {
3520
+        $p['extension'] = _EXTENSION_SQUELETTES;
3521
+    }
3522
+    if (!isset($p['extension']) or !$p['filename']) {
3523
+        $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
3524
+    }
3525
+    $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');
3527 3526
 
3528
-	return $p;
3527
+    return $p;
3529 3528
 }
3530 3529
 
3531 3530
 /**
@@ -3545,21 +3544,21 @@  discard block
 block discarded – undo
3545 3544
  *     Nom de l'exec, sinon chaîne vide.
3546 3545
  **/
3547 3546
 function tester_url_ecrire($nom) {
3548
-	static $exec = [];
3549
-	if (isset($exec[$nom])) {
3550
-		return $exec[$nom];
3551
-	}
3552
-	// tester si c'est une page en squelette
3553
-	if (trouver_fond($nom, 'prive/squelettes/contenu/')) {
3554
-		return $exec[$nom] = 'fond';
3555
-	} // echafaudage d'un fond !
3556
-	elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) {
3557
-		return $exec[$nom] = 'fond';
3558
-	}
3559
-	// attention, il ne faut pas inclure l'exec ici
3560
-	// car sinon #URL_ECRIRE provoque des inclusions
3561
-	// et des define intrusifs potentiels
3562
-	return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : '');
3547
+    static $exec = [];
3548
+    if (isset($exec[$nom])) {
3549
+        return $exec[$nom];
3550
+    }
3551
+    // tester si c'est une page en squelette
3552
+    if (trouver_fond($nom, 'prive/squelettes/contenu/')) {
3553
+        return $exec[$nom] = 'fond';
3554
+    } // echafaudage d'un fond !
3555
+    elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) {
3556
+        return $exec[$nom] = 'fond';
3557
+    }
3558
+    // attention, il ne faut pas inclure l'exec ici
3559
+    // car sinon #URL_ECRIRE provoque des inclusions
3560
+    // et des define intrusifs potentiels
3561
+    return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : '');
3563 3562
 }
3564 3563
 
3565 3564
 /**
@@ -3569,8 +3568,8 @@  discard block
 block discarded – undo
3569 3568
  *     true si la constante _VERSION_HTML n'est pas définie ou égale à html5
3570 3569
  **/
3571 3570
 function html5_permis() {
3572
-	return (!defined('_VERSION_HTML')
3573
-		or _VERSION_HTML !== 'html4');
3571
+    return (!defined('_VERSION_HTML')
3572
+        or _VERSION_HTML !== 'html4');
3574 3573
 }
3575 3574
 
3576 3575
 /**
@@ -3580,30 +3579,30 @@  discard block
 block discarded – undo
3580 3579
  * @return array
3581 3580
  */
3582 3581
 function formats_image_acceptables($gd = null, $svg_allowed = true) {
3583
-	$formats = null;
3584
-	if (!is_null($gd)) {
3585
-		$config = ($gd ? 'gd_formats' : 'formats_graphiques');
3586
-		if (isset($GLOBALS['meta'][$config])) {
3587
-			$formats = $GLOBALS['meta'][$config];
3588
-			$formats = explode(',', $formats);
3589
-			$formats = array_filter($formats);
3590
-			$formats = array_map('trim', $formats);
3591
-		}
3592
-	}
3593
-	if (is_null($formats)) {
3594
-		include_spip('inc/filtres_images_lib_mini');
3595
-		$formats = _image_extensions_acceptees_en_entree();
3596
-	}
3597
-
3598
-	if ($svg_allowed) {
3599
-		if (!in_array('svg', $formats)) {
3600
-			$formats[] = 'svg';
3601
-		}
3602
-	}
3603
-	else {
3604
-		$formats = array_diff($formats, ['svg']);
3605
-	}
3606
-	return $formats;
3582
+    $formats = null;
3583
+    if (!is_null($gd)) {
3584
+        $config = ($gd ? 'gd_formats' : 'formats_graphiques');
3585
+        if (isset($GLOBALS['meta'][$config])) {
3586
+            $formats = $GLOBALS['meta'][$config];
3587
+            $formats = explode(',', $formats);
3588
+            $formats = array_filter($formats);
3589
+            $formats = array_map('trim', $formats);
3590
+        }
3591
+    }
3592
+    if (is_null($formats)) {
3593
+        include_spip('inc/filtres_images_lib_mini');
3594
+        $formats = _image_extensions_acceptees_en_entree();
3595
+    }
3596
+
3597
+    if ($svg_allowed) {
3598
+        if (!in_array('svg', $formats)) {
3599
+            $formats[] = 'svg';
3600
+        }
3601
+    }
3602
+    else {
3603
+        $formats = array_diff($formats, ['svg']);
3604
+    }
3605
+    return $formats;
3607 3606
 }
3608 3607
 
3609 3608
 /**
@@ -3612,20 +3611,20 @@  discard block
 block discarded – undo
3612 3611
  * @return array|bool
3613 3612
  */
3614 3613
 function spip_getimagesize($fichier) {
3615
-	if (!$imagesize = @getimagesize($fichier)) {
3616
-		include_spip('inc/svg');
3617
-		if ($attrs = svg_lire_attributs($fichier)) {
3618
-			[$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
3619
-			$imagesize = [
3620
-				$width,
3621
-				$height,
3622
-				IMAGETYPE_SVG,
3623
-				"width=\"{$width}\" height=\"{$height}\"",
3624
-				'mime' => 'image/svg+xml'
3625
-			];
3626
-		}
3627
-	}
3628
-	return $imagesize;
3614
+    if (!$imagesize = @getimagesize($fichier)) {
3615
+        include_spip('inc/svg');
3616
+        if ($attrs = svg_lire_attributs($fichier)) {
3617
+            [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
3618
+            $imagesize = [
3619
+                $width,
3620
+                $height,
3621
+                IMAGETYPE_SVG,
3622
+                "width=\"{$width}\" height=\"{$height}\"",
3623
+                'mime' => 'image/svg+xml'
3624
+            ];
3625
+        }
3626
+    }
3627
+    return $imagesize;
3629 3628
 }
3630 3629
 
3631 3630
 /**
@@ -3639,19 +3638,19 @@  discard block
 block discarded – undo
3639 3638
  * @param string $statut
3640 3639
  */
3641 3640
 function avertir_auteurs($nom, $message, $statut = '') {
3642
-	$alertes = $GLOBALS['meta']['message_alertes_auteurs'];
3643
-	if (
3644
-		!$alertes
3645
-		or !is_array($alertes = unserialize($alertes))
3646
-	) {
3647
-		$alertes = [];
3648
-	}
3641
+    $alertes = $GLOBALS['meta']['message_alertes_auteurs'];
3642
+    if (
3643
+        !$alertes
3644
+        or !is_array($alertes = unserialize($alertes))
3645
+    ) {
3646
+        $alertes = [];
3647
+    }
3649 3648
 
3650
-	if (!isset($alertes[$statut])) {
3651
-		$alertes[$statut] = [];
3652
-	}
3653
-	$alertes[$statut][$nom] = $message;
3654
-	ecrire_meta('message_alertes_auteurs', serialize($alertes));
3649
+    if (!isset($alertes[$statut])) {
3650
+        $alertes[$statut] = [];
3651
+    }
3652
+    $alertes[$statut][$nom] = $message;
3653
+    ecrire_meta('message_alertes_auteurs', serialize($alertes));
3655 3654
 }
3656 3655
 
3657 3656
 /**
@@ -3665,10 +3664,10 @@  discard block
 block discarded – undo
3665 3664
  * @return string|string[]
3666 3665
  */
3667 3666
 function spip_sanitize_classname($classes) {
3668
-	if (is_array($classes)) {
3669
-		return array_map('spip_sanitize_classname', $classes);
3670
-	}
3671
-	return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes);
3667
+    if (is_array($classes)) {
3668
+        return array_map('spip_sanitize_classname', $classes);
3669
+    }
3670
+    return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes);
3672 3671
 }
3673 3672
 
3674 3673
 
@@ -3693,32 +3692,32 @@  discard block
 block discarded – undo
3693 3692
  *    Avec operateur : bool.
3694 3693
  **/
3695 3694
 function spip_version_compare($v1, $v2, $op = null) {
3696
-	$v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1));
3697
-	$v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2));
3698
-	$v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule
3699
-	$v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule
3700
-
3701
-	$v1 = explode('.', $v1);
3702
-	$v2 = explode('.', $v2);
3703
-	// $v1 est toujours une version, donc sans etoile
3704
-	while (count($v1) < count($v2)) {
3705
-		$v1[] = '0';
3706
-	}
3707
-
3708
-	// $v2 peut etre une borne, donc accepte l'etoile
3709
-	$etoile = false;
3710
-	foreach ($v1 as $k => $v) {
3711
-		if (!isset($v2[$k])) {
3712
-			$v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0';
3713
-		} else {
3714
-			if ($v2[$k] == '*') {
3715
-				$etoile = true;
3716
-				$v2[$k] = $v;
3717
-			}
3718
-		}
3719
-	}
3720
-	$v1 = implode('.', $v1);
3721
-	$v2 = implode('.', $v2);
3722
-
3723
-	return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2);
3695
+    $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1));
3696
+    $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2));
3697
+    $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule
3698
+    $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule
3699
+
3700
+    $v1 = explode('.', $v1);
3701
+    $v2 = explode('.', $v2);
3702
+    // $v1 est toujours une version, donc sans etoile
3703
+    while (count($v1) < count($v2)) {
3704
+        $v1[] = '0';
3705
+    }
3706
+
3707
+    // $v2 peut etre une borne, donc accepte l'etoile
3708
+    $etoile = false;
3709
+    foreach ($v1 as $k => $v) {
3710
+        if (!isset($v2[$k])) {
3711
+            $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0';
3712
+        } else {
3713
+            if ($v2[$k] == '*') {
3714
+                $etoile = true;
3715
+                $v2[$k] = $v;
3716
+            }
3717
+        }
3718
+    }
3719
+    $v1 = implode('.', $v1);
3720
+    $v2 = implode('.', $v2);
3721
+
3722
+    return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2);
3724 3723
 }
Please login to merge, or discard this patch.
Spacing   +122 added lines, -123 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,19 +98,19 @@  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 107
 		$inc ?
108
-			_T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>'])
108
+			_T('fonction_introuvable', ['fonction' => '<code>'.spip_htmlentities($f).'</code>'])
109 109
 			. '<br />'
110
-			. _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>'])
110
+			. _T('fonction_introuvable', ['fonction' => '<code>'.spip_htmlentities($g).'</code>'])
111 111
 			:
112
-			_T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']),
113
-		['all_inline' => true,'status' => 404]
112
+			_T('fichier_introuvable', ['fichier' => '<code>'.spip_htmlentities($d).'</code>']),
113
+		['all_inline' => true, 'status' => 404]
114 114
 	);
115 115
 	exit;
116 116
 }
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
  *     - string : chemin du fichier trouvé
157 157
  **/
158 158
 function include_spip($f, $include = true) {
159
-	return find_in_path($f . '.php', '', $include);
159
+	return find_in_path($f.'.php', '', $include);
160 160
 }
161 161
 
162 162
 /**
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
  *     - string : chemin du fichier trouvé
177 177
  **/
178 178
 function require_spip($f) {
179
-	return find_in_path($f . '.php', '', 'required');
179
+	return find_in_path($f.'.php', '', 'required');
180 180
 }
181 181
 
182 182
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 		// donc il faut l'inclure "en globals"
194 194
 		if ($f = find_in_path('mes_fonctions.php')) {
195 195
 			global $dossier_squelettes;
196
-			include_once(_ROOT_CWD . $f);
196
+			include_once(_ROOT_CWD.$f);
197 197
 		}
198 198
 
199 199
 		if (@is_readable(_CACHE_PLUGINS_FCT)) {
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	}
299 299
 
300 300
 	// appliquer notre fonction si elle existe
301
-	$fonc = 'execute_pipeline_' . strtolower($action);
301
+	$fonc = 'execute_pipeline_'.strtolower($action);
302 302
 	if (function_exists($fonc)) {
303 303
 		$val = $fonc($val);
304 304
 	} // plantage ?
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 function spip_log($message = null, $name = null) {
364 364
 	static $pre = [];
365 365
 	static $log;
366
-	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
366
+	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs);
367 367
 	if (!isset($regs[1]) or !$logname = $regs[1]) {
368 368
 		$logname = null;
369 369
 	}
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 		if (!is_string($message)) {
392 392
 			$message = print_r($message, true);
393 393
 		}
394
-		$log($pre[$niveau] . ' ' . $message, $logname);
394
+		$log($pre[$niveau].' '.$message, $logname);
395 395
 	}
396 396
 }
397 397
 
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 	foreach ($regexp as $r => $e) {
598 598
 		$regexp[$r] = str_replace('[]', '\[\]', preg_replace(',[^\w\d\[\]-],', '', $e));
599 599
 	}
600
-	$regexp = ',^(' . implode('|', $regexp) . '[[]?[]]?)(=.*)?$,';
600
+	$regexp = ',^('.implode('|', $regexp).'[[]?[]]?)(=.*)?$,';
601 601
 	$ajouts = array_flip(explode('|', $c));
602 602
 	$u = is_array($v) ? $v : rawurlencode((string) $v);
603 603
 	$testv = (is_array($v) ? count($v) : strlen((string) $v));
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 			// Ajout. Pour une variable, remplacer au meme endroit,
625 625
 			// pour un tableau ce sera fait dans la prochaine boucle
626 626
 			elseif (substr($r[1], -2) != '[]') {
627
-				$url[$n] = $r[1] . '=' . $u;
627
+				$url[$n] = $r[1].'='.$u;
628 628
 				unset($ajouts[$r[1]]);
629 629
 			}
630 630
 			// Pour les tableaux on laisse tomber les valeurs de
@@ -645,11 +645,11 @@  discard block
 block discarded – undo
645 645
 	} elseif ($testv) {
646 646
 		foreach ($ajouts as $k => $n) {
647 647
 			if (!is_array($v)) {
648
-				$url[] = $k . '=' . $u;
648
+				$url[] = $k.'='.$u;
649 649
 			} else {
650
-				$id = (substr($k, -2) == '[]') ? $k : ($k . '[]');
650
+				$id = (substr($k, -2) == '[]') ? $k : ($k.'[]');
651 651
 				foreach ($v as $w) {
652
-					$url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w));
652
+					$url[] = $id.'='.(is_array($w) ? 'Array' : rawurlencode($w));
653 653
 				}
654 654
 			}
655 655
 		}
@@ -660,10 +660,10 @@  discard block
 block discarded – undo
660 660
 
661 661
 	// recomposer l'adresse
662 662
 	if ($url) {
663
-		$a .= '?' . join($sep, $url);
663
+		$a .= '?'.join($sep, $url);
664 664
 	}
665 665
 
666
-	return $a . $ancre;
666
+	return $a.$ancre;
667 667
 }
668 668
 
669 669
 /**
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 			translitteration($ancre)
696 696
 		);
697 697
 	}
698
-	return $url . (strlen($ancre) ? '#' . $ancre : '');
698
+	return $url.(strlen($ancre) ? '#'.$ancre : '');
699 699
 }
700 700
 
701 701
 /**
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
  * @return bool
812 812
  */
813 813
 function test_plugin_actif($plugin) {
814
-	return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
814
+	return ($plugin and defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true : false;
815 815
 }
816 816
 
817 817
 /**
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 					$value = interdire_scripts($value, -1);
944 944
 				}
945 945
 				if (!empty($options['class'])) {
946
-					$value = "<span class='" . $options['class'] . "'>$value</span>";
946
+					$value = "<span class='".$options['class']."'>$value</span>";
947 947
 				}
948 948
 				$text = str_replace("@$name@", $value, $text);
949 949
 				unset($args[$name]);
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
 		// Si des variables n'ont pas ete inserees, le signaler
953 953
 		// (chaines de langues pas a jour)
954 954
 		if ($args) {
955
-			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
955
+			spip_log("$f:  variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG);
956 956
 		}
957 957
 	}
958 958
 
@@ -976,7 +976,7 @@  discard block
 block discarded – undo
976 976
 function joli_repertoire($rep) {
977 977
 	$a = substr($rep, 0, 1);
978 978
 	if ($a <> '.' and $a <> '/') {
979
-		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
979
+		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep;
980 980
 	}
981 981
 	$rep = preg_replace(',(^\.\.\/),', '', $rep);
982 982
 
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
 			$p -= ($x * 1000);
1031 1031
 		}
1032 1032
 
1033
-		return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1033
+		return $s.sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1034 1034
 	}
1035 1035
 }
1036 1036
 
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 	if ($taches and count($taches) and !spip_connect()) {
1098 1098
 		return false;
1099 1099
 	}
1100
-	spip_log('cron !', 'jq' . _LOG_DEBUG);
1100
+	spip_log('cron !', 'jq'._LOG_DEBUG);
1101 1101
 	if ($genie = charger_fonction('genie', 'inc', true)) {
1102 1102
 		return $genie($taches);
1103 1103
 	}
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
 
1202 1202
 	if ($queue_next_job_time == -1) {
1203 1203
 		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1204
-			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
1204
+			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP.'job_queue_next.txt');
1205 1205
 		}
1206 1206
 		// utiliser un cache memoire si dispo
1207 1207
 		if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
@@ -1270,8 +1270,8 @@  discard block
 block discarded – undo
1270 1270
 		$src = '';
1271 1271
 	}
1272 1272
 	if ($script) {
1273
-		$script = ("/*<![CDATA[*/\n" .
1274
-			preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1273
+		$script = ("/*<![CDATA[*/\n".
1274
+			preg_replace(',</([^>]*)>,', '<\/\1>', $script).
1275 1275
 			'/*]]>*/');
1276 1276
 	}
1277 1277
 	if ($noscript) {
@@ -1357,13 +1357,13 @@  discard block
 block discarded – undo
1357 1357
 	if ($path_base == null) {
1358 1358
 		// Chemin standard depuis l'espace public
1359 1359
 		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
1360
-			_DIR_RACINE . ':' .
1361
-			_DIR_RACINE . 'squelettes-dist/:' .
1362
-			_DIR_RACINE . 'prive/:' .
1360
+			_DIR_RACINE.':'.
1361
+			_DIR_RACINE.'squelettes-dist/:'.
1362
+			_DIR_RACINE.'prive/:'.
1363 1363
 			_DIR_RESTREINT;
1364 1364
 		// Ajouter squelettes/
1365
-		if (@is_dir(_DIR_RACINE . 'squelettes')) {
1366
-			$path = _DIR_RACINE . 'squelettes/:' . $path;
1365
+		if (@is_dir(_DIR_RACINE.'squelettes')) {
1366
+			$path = _DIR_RACINE.'squelettes/:'.$path;
1367 1367
 		}
1368 1368
 		foreach (explode(':', $path) as $dir) {
1369 1369
 			if (strlen($dir) and substr($dir, -1) != '/') {
@@ -1375,7 +1375,7 @@  discard block
 block discarded – undo
1375 1375
 		// Et le(s) dossier(s) des squelettes nommes
1376 1376
 		if (strlen($GLOBALS['dossier_squelettes'])) {
1377 1377
 			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1378
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1378
+				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/');
1379 1379
 			}
1380 1380
 		}
1381 1381
 		$GLOBALS['path_sig'] = md5(serialize($path_full));
@@ -1386,7 +1386,7 @@  discard block
 block discarded – undo
1386 1386
 
1387 1387
 	if (is_array($dir_path) or strlen($dir_path)) {
1388 1388
 		$tete = '';
1389
-		if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1389
+		if (reset($path_base) == _DIR_RACINE.'squelettes/') {
1390 1390
 			$tete = array_shift($path_base);
1391 1391
 		}
1392 1392
 		$dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
 	// Et le(s) dossier(s) des squelettes nommes
1408 1408
 	if (strlen($GLOBALS['dossier_squelettes'])) {
1409 1409
 		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1410
-			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1410
+			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE).$d.'/');
1411 1411
 		}
1412 1412
 	}
1413 1413
 
@@ -1478,14 +1478,14 @@  discard block
 block discarded – undo
1478 1478
 	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1479 1479
 	if (
1480 1480
 		preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1481
-		and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg'
1481
+		and $file_svg_generique = substr($file, 0, -strlen($m[0])).'-xx.svg'
1482 1482
 		and $f = find_in_theme("$file_svg_generique")
1483 1483
 	) {
1484
-		if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) {
1484
+		if ($fsize = substr($f, 0, -6).$m[1].'.svg' and file_exists($fsize)) {
1485 1485
 			return $themefiles["$subdir$file"] = $fsize;
1486 1486
 		}
1487 1487
 		else {
1488
-			return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
1488
+			return $themefiles["$subdir$file"] = "$f?".$m[1].'px';
1489 1489
 		}
1490 1490
 	}
1491 1491
 
@@ -1495,7 +1495,7 @@  discard block
 block discarded – undo
1495 1495
 			return $themefiles["$subdir$file"] = $f;
1496 1496
 		}
1497 1497
 	}
1498
-	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1498
+	spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme');
1499 1499
 
1500 1500
 	return $themefiles["$subdir$file"] = '';
1501 1501
 }
@@ -1603,8 +1603,8 @@  discard block
 block discarded – undo
1603 1603
 			return false;
1604 1604
 		}
1605 1605
 		if ($include and !isset($inc[$dirname][$file])) {
1606
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1607
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1606
+			include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1607
+			$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
1608 1608
 		}
1609 1609
 
1610 1610
 		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
@@ -1617,14 +1617,14 @@  discard block
 block discarded – undo
1617 1617
 	}
1618 1618
 
1619 1619
 	foreach (creer_chemin() as $dir) {
1620
-		if (!isset($dirs[$a = $dir . $dirname])) {
1621
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1620
+		if (!isset($dirs[$a = $dir.$dirname])) {
1621
+			$dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a);
1622 1622
 		}
1623 1623
 		if ($dirs[$a]) {
1624
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
1624
+			if (file_exists(_ROOT_CWD.($a .= $file))) {
1625 1625
 				if ($include and !isset($inc[$dirname][$file])) {
1626
-					include_once _ROOT_CWD . $a;
1627
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1626
+					include_once _ROOT_CWD.$a;
1627
+					$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
1628 1628
 				}
1629 1629
 				if (!defined('_SAUVER_CHEMIN')) {
1630 1630
 					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
@@ -1634,7 +1634,7 @@  discard block
 block discarded – undo
1634 1634
 					define('_SAUVER_CHEMIN', true);
1635 1635
 				}
1636 1636
 
1637
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1637
+				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a;
1638 1638
 			}
1639 1639
 		}
1640 1640
 	}
@@ -1660,7 +1660,7 @@  discard block
 block discarded – undo
1660 1660
 		define('_SAUVER_CHEMIN', true);
1661 1661
 	}
1662 1662
 
1663
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1663
+	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false;
1664 1664
 }
1665 1665
 
1666 1666
 function clear_path_cache() {
@@ -1730,12 +1730,12 @@  discard block
 block discarded – undo
1730 1730
 	// cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1731 1731
 	// on a pas encore inclus flock.php
1732 1732
 	if (!function_exists('preg_files')) {
1733
-		include_once _ROOT_RESTREINT . 'inc/flock.php';
1733
+		include_once _ROOT_RESTREINT.'inc/flock.php';
1734 1734
 	}
1735 1735
 
1736 1736
 	// Parcourir le chemin
1737 1737
 	foreach (creer_chemin() as $d) {
1738
-		$f = $d . $dir;
1738
+		$f = $d.$dir;
1739 1739
 		if (@is_dir($f)) {
1740 1740
 			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
1741 1741
 			foreach ($liste as $chemin) {
@@ -1785,9 +1785,9 @@  discard block
 block discarded – undo
1785 1785
 	if ($type === 'defaut') {
1786 1786
 		$objet = objet_type($quoi);
1787 1787
 		if (
1788
-			$f = charger_fonction('generer_' . $objet . '_url', 'urls', true)
1788
+			$f = charger_fonction('generer_'.$objet.'_url', 'urls', true)
1789 1789
 			// deprecated
1790
-			or $f = charger_fonction('generer_url_' . $objet, 'urls', true)
1790
+			or $f = charger_fonction('generer_url_'.$objet, 'urls', true)
1791 1791
 		) {
1792 1792
 			return $f;
1793 1793
 		}
@@ -1800,7 +1800,7 @@  discard block
 block discarded – undo
1800 1800
 	}
1801 1801
 
1802 1802
 	// inclure le module d'url
1803
-	include_spip('urls/' . $url_type);
1803
+	include_spip('urls/'.$url_type);
1804 1804
 
1805 1805
 	switch ($quoi) {
1806 1806
 		case 'page':
@@ -1956,8 +1956,8 @@  discard block
 block discarded – undo
1956 1956
 	include_spip('base/connect_sql');
1957 1957
 	$id_type = id_table_objet($entite, $public);
1958 1958
 
1959
-	return _DIR_RACINE . get_spip_script('./')
1960
-	. '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1959
+	return _DIR_RACINE.get_spip_script('./')
1960
+	. '?'._SPIP_PAGE."=$entite&$id_type=$i&connect=$public"
1961 1961
 	. (!$args ? '' : "&$args")
1962 1962
 	. (!$ancre ? '' : "#$ancre");
1963 1963
 }
@@ -2128,7 +2128,7 @@  discard block
 block discarded – undo
2128 2128
 				!empty($_SERVER['QUERY_STRING'])
2129 2129
 				and !strpos($_SERVER['REQUEST_URI'], '?')
2130 2130
 			) {
2131
-				$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2131
+				$GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
2132 2132
 			}
2133 2133
 		}
2134 2134
 	}
@@ -2163,9 +2163,9 @@  discard block
 block discarded – undo
2163 2163
 		array_shift($myself);
2164 2164
 		$myself = implode('/', $myself);
2165 2165
 	}
2166
-	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2166
+	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/';
2167 2167
 
2168
-	$url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2168
+	$url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/');
2169 2169
 
2170 2170
 	return $url;
2171 2171
 }
@@ -2204,16 +2204,16 @@  discard block
 block discarded – undo
2204 2204
 function generer_url_ecrire(?string $script = '', $args = '', $no_entities = false, $rel = false) {
2205 2205
 	$script ??= '';
2206 2206
 	if (!$rel) {
2207
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2207
+		$rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT;
2208 2208
 	} else {
2209 2209
 		if (!is_string($rel)) {
2210
-			$rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT;
2210
+			$rel = _DIR_RESTREINT ?: './'._SPIP_ECRIRE_SCRIPT;
2211 2211
 		}
2212 2212
 	}
2213 2213
 
2214 2214
 	[$script, $ancre] = array_pad(explode('#', $script), 2, null);
2215 2215
 	if ($script and ($script <> 'accueil' or $rel)) {
2216
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
2216
+		$args = "?exec=$script".(!$args ? '' : "&$args");
2217 2217
 	} elseif ($args) {
2218 2218
 		$args = "?$args";
2219 2219
 	}
@@ -2221,7 +2221,7 @@  discard block
 block discarded – undo
2221 2221
 		$args .= "#$ancre";
2222 2222
 	}
2223 2223
 
2224
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2224
+	return $rel.($no_entities ? $args : str_replace('&', '&amp;', $args));
2225 2225
 }
2226 2226
 
2227 2227
 //
@@ -2303,10 +2303,10 @@  discard block
 block discarded – undo
2303 2303
 			$action = parametre_url($action, _SPIP_PAGE, $script, '&');
2304 2304
 		}
2305 2305
 		if ($args) {
2306
-			$action .= (strpos($action, '?') !== false ? '&' : '?') . $args;
2306
+			$action .= (strpos($action, '?') !== false ? '&' : '?').$args;
2307 2307
 		}
2308 2308
 		// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2309
-		$url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
2309
+		$url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(',^/[.]/,', '/', "/$action"));
2310 2310
 	}
2311 2311
 
2312 2312
 	if (!$no_entities) {
@@ -2318,7 +2318,7 @@  discard block
 block discarded – undo
2318 2318
 
2319 2319
 function generer_url_prive($script, $args = '', $no_entities = false) {
2320 2320
 
2321
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2321
+	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php');
2322 2322
 }
2323 2323
 
2324 2324
 // Pour les formulaires en methode POST,
@@ -2353,8 +2353,7 @@  discard block
 block discarded – undo
2353 2353
 	. "><div>\n"
2354 2354
 	. "<input type='hidden' name='exec' value='$script1' />"
2355 2355
 	. $corps
2356
-	. (!$submit ? '' :
2357
-		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
2356
+	. (!$submit ? '' : ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo submit btn' type='submit' value=\"".entites_html($submit).'" /></div>'))
2358 2357
 	. "</div></form>\n";
2359 2358
 }
2360 2359
 
@@ -2379,14 +2378,14 @@  discard block
 block discarded – undo
2379 2378
 		? generer_url_ecrire(_request('exec'))
2380 2379
 		: generer_url_public();
2381 2380
 
2382
-	return "\n<form action='" .
2383
-	$h .
2384
-	"'" .
2385
-	$atts .
2386
-	">\n" .
2387
-	'<div>' .
2388
-	"\n<input type='hidden' name='action' value='$script' />" .
2389
-	$corps .
2381
+	return "\n<form action='".
2382
+	$h.
2383
+	"'".
2384
+	$atts.
2385
+	">\n".
2386
+	'<div>'.
2387
+	"\n<input type='hidden' name='action' value='$script' />".
2388
+	$corps.
2390 2389
 	'</div></form>';
2391 2390
 }
2392 2391
 
@@ -2414,7 +2413,7 @@  discard block
 block discarded – undo
2414 2413
 		: generer_url_public('', '', false, false);
2415 2414
 	$url = parametre_url($url, 'action', $script);
2416 2415
 	if ($args) {
2417
-		$url .= quote_amp('&' . $args);
2416
+		$url .= quote_amp('&'.$args);
2418 2417
 	}
2419 2418
 
2420 2419
 	if ($no_entities) {
@@ -2448,9 +2447,9 @@  discard block
 block discarded – undo
2448 2447
 	}
2449 2448
 	$url =
2450 2449
 		(($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './')
2451
-	. $script . '/'
2450
+	. $script.'/'
2452 2451
 	. ($path ? trim($path, '/') : '')
2453
-	. ($args ? '?' . quote_amp($args) : '');
2452
+	. ($args ? '?'.quote_amp($args) : '');
2454 2453
 
2455 2454
 	if ($no_entities) {
2456 2455
 		$url = str_replace('&amp;', '&', $url);
@@ -2499,17 +2498,17 @@  discard block
 block discarded – undo
2499 2498
 
2500 2499
 	// le nom du repertoire plugins/ activables/desactivables
2501 2500
 	if (!defined('_DIR_PLUGINS')) {
2502
-		define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
2501
+		define('_DIR_PLUGINS', _DIR_RACINE.'plugins/');
2503 2502
 	}
2504 2503
 
2505 2504
 	// le nom du repertoire des extensions/ permanentes du core, toujours actives
2506 2505
 	if (!defined('_DIR_PLUGINS_DIST')) {
2507
-		define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
2506
+		define('_DIR_PLUGINS_DIST', _DIR_RACINE.'plugins-dist/');
2508 2507
 	}
2509 2508
 
2510 2509
 	// le nom du repertoire des librairies
2511 2510
 	if (!defined('_DIR_LIB')) {
2512
-		define('_DIR_LIB', _DIR_RACINE . 'lib/');
2511
+		define('_DIR_LIB', _DIR_RACINE.'lib/');
2513 2512
 	}
2514 2513
 
2515 2514
 	if (!defined('_DIR_IMG')) {
@@ -2519,29 +2518,29 @@  discard block
 block discarded – undo
2519 2518
 		define('_DIR_LOGOS', $pa);
2520 2519
 	}
2521 2520
 	if (!defined('_DIR_IMG_ICONES')) {
2522
-		define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
2521
+		define('_DIR_IMG_ICONES', _DIR_LOGOS.'icones/');
2523 2522
 	}
2524 2523
 
2525 2524
 	if (!defined('_DIR_DUMP')) {
2526
-		define('_DIR_DUMP', $ti . 'dump/');
2525
+		define('_DIR_DUMP', $ti.'dump/');
2527 2526
 	}
2528 2527
 	if (!defined('_DIR_SESSIONS')) {
2529
-		define('_DIR_SESSIONS', $ti . 'sessions/');
2528
+		define('_DIR_SESSIONS', $ti.'sessions/');
2530 2529
 	}
2531 2530
 	if (!defined('_DIR_TRANSFERT')) {
2532
-		define('_DIR_TRANSFERT', $ti . 'upload/');
2531
+		define('_DIR_TRANSFERT', $ti.'upload/');
2533 2532
 	}
2534 2533
 	if (!defined('_DIR_CACHE')) {
2535
-		define('_DIR_CACHE', $ti . 'cache/');
2534
+		define('_DIR_CACHE', $ti.'cache/');
2536 2535
 	}
2537 2536
 	if (!defined('_DIR_CACHE_XML')) {
2538
-		define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
2537
+		define('_DIR_CACHE_XML', _DIR_CACHE.'xml/');
2539 2538
 	}
2540 2539
 	if (!defined('_DIR_SKELS')) {
2541
-		define('_DIR_SKELS', _DIR_CACHE . 'skel/');
2540
+		define('_DIR_SKELS', _DIR_CACHE.'skel/');
2542 2541
 	}
2543 2542
 	if (!defined('_DIR_AIDE')) {
2544
-		define('_DIR_AIDE', _DIR_CACHE . 'aide/');
2543
+		define('_DIR_AIDE', _DIR_CACHE.'aide/');
2545 2544
 	}
2546 2545
 	if (!defined('_DIR_TMP')) {
2547 2546
 		define('_DIR_TMP', $ti);
@@ -2570,27 +2569,27 @@  discard block
 block discarded – undo
2570 2569
 	// Declaration des fichiers
2571 2570
 
2572 2571
 	if (!defined('_CACHE_PLUGINS_PATH')) {
2573
-		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
2572
+		define('_CACHE_PLUGINS_PATH', _DIR_CACHE.'charger_plugins_chemins.php');
2574 2573
 	}
2575 2574
 	if (!defined('_CACHE_PLUGINS_OPT')) {
2576
-		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
2575
+		define('_CACHE_PLUGINS_OPT', _DIR_CACHE.'charger_plugins_options.php');
2577 2576
 	}
2578 2577
 	if (!defined('_CACHE_PLUGINS_FCT')) {
2579
-		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
2578
+		define('_CACHE_PLUGINS_FCT', _DIR_CACHE.'charger_plugins_fonctions.php');
2580 2579
 	}
2581 2580
 	if (!defined('_CACHE_PIPELINES')) {
2582
-		define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
2581
+		define('_CACHE_PIPELINES', _DIR_CACHE.'charger_pipelines.php');
2583 2582
 	}
2584 2583
 	if (!defined('_CACHE_CHEMIN')) {
2585
-		define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
2584
+		define('_CACHE_CHEMIN', _DIR_CACHE.'chemin.txt');
2586 2585
 	}
2587 2586
 
2588 2587
 	# attention .php obligatoire pour ecrire_fichier_securise
2589 2588
 	if (!defined('_FILE_META')) {
2590
-		define('_FILE_META', $ti . 'meta_cache.php');
2589
+		define('_FILE_META', $ti.'meta_cache.php');
2591 2590
 	}
2592 2591
 	if (!defined('_DIR_LOG')) {
2593
-		define('_DIR_LOG', _DIR_TMP . 'log/');
2592
+		define('_DIR_LOG', _DIR_TMP.'log/');
2594 2593
 	}
2595 2594
 	if (!defined('_FILE_LOG')) {
2596 2595
 		define('_FILE_LOG', 'spip');
@@ -2607,8 +2606,8 @@  discard block
 block discarded – undo
2607 2606
 	if (!defined('_FILE_CONNECT')) {
2608 2607
 		define(
2609 2608
 			'_FILE_CONNECT',
2610
-			(@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2611
-			: (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2609
+			(@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f
2610
+			: (@is_readable($f = _DIR_RESTREINT.'inc_connect.php') ? $f
2612 2611
 			: false))
2613 2612
 		);
2614 2613
 	}
@@ -2620,7 +2619,7 @@  discard block
 block discarded – undo
2620 2619
 	if (!defined('_FILE_CHMOD')) {
2621 2620
 		define(
2622 2621
 			'_FILE_CHMOD',
2623
-			(@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2622
+			(@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f
2624 2623
 			: false)
2625 2624
 		);
2626 2625
 	}
@@ -2633,10 +2632,10 @@  discard block
 block discarded – undo
2633 2632
 		define('_FILE_TMP_SUFFIX', '.tmp.php');
2634 2633
 	}
2635 2634
 	if (!defined('_FILE_CONNECT_TMP')) {
2636
-		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2635
+		define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX);
2637 2636
 	}
2638 2637
 	if (!defined('_FILE_CHMOD_TMP')) {
2639
-		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2638
+		define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX);
2640 2639
 	}
2641 2640
 
2642 2641
 	// Definition des droits d'acces en ecriture
@@ -2654,13 +2653,13 @@  discard block
 block discarded – undo
2654 2653
 		define('_DEFAULT_CHARSET', 'utf-8');
2655 2654
 	}
2656 2655
 	if (!defined('_ROOT_PLUGINS')) {
2657
-		define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/');
2656
+		define('_ROOT_PLUGINS', _ROOT_RACINE.'plugins/');
2658 2657
 	}
2659 2658
 	if (!defined('_ROOT_PLUGINS_DIST')) {
2660
-		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/');
2659
+		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE.'plugins-dist/');
2661 2660
 	}
2662 2661
 	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2663
-		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2662
+		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2664 2663
 	}
2665 2664
 
2666 2665
 	// La taille des Log
@@ -2697,7 +2696,7 @@  discard block
 block discarded – undo
2697 2696
 	// (non surchargeable en l'etat ; attention si on utilise include_spip()
2698 2697
 	// pour le rendre surchargeable, on va provoquer un reecriture
2699 2698
 	// systematique du noyau ou une baisse de perfs => a etudier)
2700
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
2699
+	include_once _ROOT_RESTREINT.'inc/flock.php';
2701 2700
 
2702 2701
 	// charger tout de suite le path et son cache
2703 2702
 	load_path_cache();
@@ -2733,7 +2732,7 @@  discard block
 block discarded – undo
2733 2732
 			!empty($_SERVER['QUERY_STRING'])
2734 2733
 			and !strpos($_SERVER['REQUEST_URI'], '?')
2735 2734
 		) {
2736
-			$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2735
+			$GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
2737 2736
 		}
2738 2737
 	}
2739 2738
 
@@ -2769,7 +2768,7 @@  discard block
 block discarded – undo
2769 2768
 		) {
2770 2769
 			if (isset($GLOBALS['meta']['adresse_site'])) {
2771 2770
 				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2772
-				$uri_ref = ($uri_ref['path'] ?? '') . '/';
2771
+				$uri_ref = ($uri_ref['path'] ?? '').'/';
2773 2772
 			} else {
2774 2773
 				$uri_ref = '';
2775 2774
 			}
@@ -2863,7 +2862,7 @@  discard block
 block discarded – undo
2863 2862
 	}
2864 2863
 	if (!defined('_CACHE_RUBRIQUES')) {
2865 2864
 		/** Fichier cache pour le navigateur de rubrique du bandeau */
2866
-		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2865
+		define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt');
2867 2866
 	}
2868 2867
 	if (!defined('_CACHE_RUBRIQUES_MAX')) {
2869 2868
 		/** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
@@ -3085,7 +3084,7 @@  discard block
 block discarded – undo
3085 3084
 					}
3086 3085
 					if (isset($GLOBALS['visiteur_session']['nom'])) {
3087 3086
 						spip_log($GLOBALS['visiteur_session']['nom']
3088
-							. ' ' . _VAR_MODE);
3087
+							. ' '._VAR_MODE);
3089 3088
 					}
3090 3089
 				} // pas autorise ?
3091 3090
 				else {
@@ -3100,7 +3099,7 @@  discard block
 block discarded – undo
3100 3099
 						if (strpos($self, 'page=login') === false) {
3101 3100
 							include_spip('inc/headers');
3102 3101
 							$redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&');
3103
-							redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true));
3102
+							redirige_par_entete(generer_url_public('login', 'url='.rawurlencode($redirect), true));
3104 3103
 						}
3105 3104
 					}
3106 3105
 					// sinon tant pis
@@ -3150,10 +3149,10 @@  discard block
 block discarded – undo
3150 3149
 **/
3151 3150
 function verifier_visiteur() {
3152 3151
 	@spip_initialisation_core(
3153
-		(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3154
-		(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3155
-		(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3156
-		(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3152
+		(_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES),
3153
+		(_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES),
3154
+		(_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES),
3155
+		(_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES)
3157 3156
 	);
3158 3157
 
3159 3158
 	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
@@ -3186,7 +3185,7 @@  discard block
 block discarded – undo
3186 3185
 	}
3187 3186
 
3188 3187
 	$h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3189
-	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3188
+	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) {
3190 3189
 		$session = charger_fonction('session', 'inc');
3191 3190
 		if ($session()) {
3192 3191
 			return $GLOBALS['visiteur_session']['statut'];
@@ -3266,7 +3265,7 @@  discard block
 block discarded – undo
3266 3265
 			'definir_session',
3267 3266
 			$GLOBALS['visiteur_session']
3268 3267
 				? serialize($GLOBALS['visiteur_session'])
3269
-				. '_' . @$_COOKIE['spip_session']
3268
+				. '_'.@$_COOKIE['spip_session']
3270 3269
 				: ''
3271 3270
 		);
3272 3271
 		$session = $s ? substr(md5($s), 0, 8) : '';
@@ -3422,11 +3421,11 @@  discard block
 block discarded – undo
3422 3421
 	$GLOBALS['_INC_PUBLIC']++;
3423 3422
 
3424 3423
 	// fix #4235
3425
-	$cache_utilise_session_appelant	= ($GLOBALS['cache_utilise_session'] ?? null);
3424
+	$cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null);
3426 3425
 
3427 3426
 
3428 3427
 	foreach (is_array($fond) ? $fond : [$fond] as $f) {
3429
-		unset($GLOBALS['cache_utilise_session']);	// fix #4235
3428
+		unset($GLOBALS['cache_utilise_session']); // fix #4235
3430 3429
 
3431 3430
 		$page = evaluer_fond($f, $contexte, $connect);
3432 3431
 		if ($page === '') {
@@ -3511,7 +3510,7 @@  discard block
 block discarded – undo
3511 3510
  * @return array|string
3512 3511
  */
3513 3512
 function trouver_fond($nom, $dir = '', $pathinfo = false) {
3514
-	$f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3513
+	$f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : '');
3515 3514
 	if (!$pathinfo) {
3516 3515
 		return $f;
3517 3516
 	}
Please login to merge, or discard this patch.