Completed
Push — master ( e1d1bb...c86966 )
by cam
01:10
created
ecrire/inc/utils.php 2 patches
Indentation   +2252 added lines, -2253 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 = call_user_func($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 = call_user_func($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 = call_user_func($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 = call_user_func($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,95 +569,95 @@  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
-	$regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,';
596
-	$ajouts = array_flip(explode('|', $c));
597
-	$u = is_array($v) ? $v : rawurlencode((string) $v);
598
-	$testv = (is_array($v) ? count($v) : strlen((string) $v));
599
-	$v_read = null;
600
-	// lire les variables et agir
601
-	foreach ($url as $n => $val) {
602
-		if (preg_match($regexp, urldecode($val), $r)) {
603
-			$r = array_pad($r, 3, null);
604
-			if ($v === null) {
605
-				// c'est un tableau, on memorise les valeurs
606
-				if (substr($r[1], -2) == '[]') {
607
-					if (!$v_read) {
608
-						$v_read = [];
609
-					}
610
-					$v_read[] = $r[2] ? substr($r[2], 1) : '';
611
-				} // c'est un scalaire, on retourne direct
612
-				else {
613
-					return $r[2] ? substr($r[2], 1) : '';
614
-				}
615
-			} // suppression
616
-			elseif (!$testv) {
617
-				unset($url[$n]);
618
-			}
619
-			// Ajout. Pour une variable, remplacer au meme endroit,
620
-			// pour un tableau ce sera fait dans la prochaine boucle
621
-			elseif (substr($r[1], -2) != '[]') {
622
-				$url[$n] = $r[1] . '=' . $u;
623
-				unset($ajouts[$r[1]]);
624
-			}
625
-			// Pour les tableaux on laisse tomber les valeurs de
626
-			// départ, on remplira à l'étape suivante
627
-			else {
628
-				unset($url[$n]);
629
-			}
630
-		}
631
-	}
632
-
633
-	// traiter les parametres pas encore trouves
634
-	if (
635
-		$v === null
636
-		and $args = func_get_args()
637
-		and count($args) == 2
638
-	) {
639
-		return $v_read; // rien trouve ou un tableau
640
-	} elseif ($testv) {
641
-		foreach ($ajouts as $k => $n) {
642
-			if (!is_array($v)) {
643
-				$url[] = $k . '=' . $u;
644
-			} else {
645
-				$id = (substr($k, -2) == '[]') ? $k : ($k . '[]');
646
-				foreach ($v as $w) {
647
-					$url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w));
648
-				}
649
-			}
650
-		}
651
-	}
652
-
653
-	// eliminer les vides
654
-	$url = array_filter($url);
655
-
656
-	// recomposer l'adresse
657
-	if ($url) {
658
-		$a .= '?' . join($sep, $url);
659
-	}
660
-
661
-	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
+    $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,';
595
+    $ajouts = array_flip(explode('|', $c));
596
+    $u = is_array($v) ? $v : rawurlencode((string) $v);
597
+    $testv = (is_array($v) ? count($v) : strlen((string) $v));
598
+    $v_read = null;
599
+    // lire les variables et agir
600
+    foreach ($url as $n => $val) {
601
+        if (preg_match($regexp, urldecode($val), $r)) {
602
+            $r = array_pad($r, 3, null);
603
+            if ($v === null) {
604
+                // c'est un tableau, on memorise les valeurs
605
+                if (substr($r[1], -2) == '[]') {
606
+                    if (!$v_read) {
607
+                        $v_read = [];
608
+                    }
609
+                    $v_read[] = $r[2] ? substr($r[2], 1) : '';
610
+                } // c'est un scalaire, on retourne direct
611
+                else {
612
+                    return $r[2] ? substr($r[2], 1) : '';
613
+                }
614
+            } // suppression
615
+            elseif (!$testv) {
616
+                unset($url[$n]);
617
+            }
618
+            // Ajout. Pour une variable, remplacer au meme endroit,
619
+            // pour un tableau ce sera fait dans la prochaine boucle
620
+            elseif (substr($r[1], -2) != '[]') {
621
+                $url[$n] = $r[1] . '=' . $u;
622
+                unset($ajouts[$r[1]]);
623
+            }
624
+            // Pour les tableaux on laisse tomber les valeurs de
625
+            // départ, on remplira à l'étape suivante
626
+            else {
627
+                unset($url[$n]);
628
+            }
629
+        }
630
+    }
631
+
632
+    // traiter les parametres pas encore trouves
633
+    if (
634
+        $v === null
635
+        and $args = func_get_args()
636
+        and count($args) == 2
637
+    ) {
638
+        return $v_read; // rien trouve ou un tableau
639
+    } elseif ($testv) {
640
+        foreach ($ajouts as $k => $n) {
641
+            if (!is_array($v)) {
642
+                $url[] = $k . '=' . $u;
643
+            } else {
644
+                $id = (substr($k, -2) == '[]') ? $k : ($k . '[]');
645
+                foreach ($v as $w) {
646
+                    $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w));
647
+                }
648
+            }
649
+        }
650
+    }
651
+
652
+    // eliminer les vides
653
+    $url = array_filter($url);
654
+
655
+    // recomposer l'adresse
656
+    if ($url) {
657
+        $a .= '?' . join($sep, $url);
658
+    }
659
+
660
+    return $a . $ancre;
662 661
 }
663 662
 
664 663
 /**
@@ -676,21 +675,21 @@  discard block
 block discarded – undo
676 675
  * @return string
677 676
  */
678 677
 function ancre_url($url, $ancre) {
679
-	// lever l'#ancre
680
-	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
681
-		$url = $r[1];
682
-	}
683
-	if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
684
-		if (!function_exists('translitteration')) {
685
-			include_spip('inc/charsets');
686
-		}
687
-		$ancre = preg_replace(
688
-			['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'],
689
-			['', '-'],
690
-			translitteration($ancre)
691
-		);
692
-	}
693
-	return $url . (strlen($ancre) ? '#' . $ancre : '');
678
+    // lever l'#ancre
679
+    if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
680
+        $url = $r[1];
681
+    }
682
+    if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
683
+        if (!function_exists('translitteration')) {
684
+            include_spip('inc/charsets');
685
+        }
686
+        $ancre = preg_replace(
687
+            ['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'],
688
+            ['', '-'],
689
+            translitteration($ancre)
690
+        );
691
+    }
692
+    return $url . (strlen($ancre) ? '#' . $ancre : '');
694 693
 }
695 694
 
696 695
 /**
@@ -700,16 +699,16 @@  discard block
 block discarded – undo
700 699
  * @return string
701 700
  */
702 701
 function nettoyer_uri($reset = null) {
703
-	static $done = false;
704
-	static $propre = '';
705
-	if (!is_null($reset)) {
706
-		return $propre = $reset;
707
-	}
708
-	if ($done) {
709
-		return $propre;
710
-	}
711
-	$done = true;
712
-	return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);
702
+    static $done = false;
703
+    static $propre = '';
704
+    if (!is_null($reset)) {
705
+        return $propre = $reset;
706
+    }
707
+    if ($done) {
708
+        return $propre;
709
+    }
710
+    $done = true;
711
+    return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);
713 712
 }
714 713
 
715 714
 /**
@@ -721,16 +720,16 @@  discard block
 block discarded – undo
721 720
  * @return string
722 721
  */
723 722
 function nettoyer_uri_var($request_uri) {
724
-	$uri1 = $request_uri;
725
-	do {
726
-		$uri = $uri1;
727
-		$uri1 = preg_replace(
728
-			',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i',
729
-			'\1',
730
-			$uri
731
-		);
732
-	} while ($uri <> $uri1);
733
-	return preg_replace(',[?&]$,', '', $uri1);
723
+    $uri1 = $request_uri;
724
+    do {
725
+        $uri = $uri1;
726
+        $uri1 = preg_replace(
727
+            ',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i',
728
+            '\1',
729
+            $uri
730
+        );
731
+    } while ($uri <> $uri1);
732
+    return preg_replace(',[?&]$,', '', $uri1);
734 733
 }
735 734
 
736 735
 
@@ -744,48 +743,48 @@  discard block
 block discarded – undo
744 743
  *    URL vers soi-même
745 744
  **/
746 745
 function self($amp = '&amp;', $root = false) {
747
-	$url = nettoyer_uri();
748
-	if (
749
-		!$root
750
-		and (
751
-			// si pas de profondeur on peut tronquer
752
-			$GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
753
-			// sinon c'est OK si _SET_HTML_BASE a ete force a false
754
-			or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE))
755
-	) {
756
-		$url = preg_replace(',^[^?]*/,', '', $url);
757
-	}
758
-	// ajouter le cas echeant les variables _POST['id_...']
759
-	foreach ($_POST as $v => $c) {
760
-		if (substr($v, 0, 3) == 'id_') {
761
-			$url = parametre_url($url, $v, $c, '&');
762
-		}
763
-	}
764
-
765
-	// supprimer les variables sans interet
766
-	if (test_espace_prive()) {
767
-		$url = preg_replace(',([?&])('
768
-			. 'lang|show_docs|'
769
-			. 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
770
-		$url = preg_replace(',([?&])[&]+,', '\1', $url);
771
-		$url = preg_replace(',[&]$,', '\1', $url);
772
-	}
773
-
774
-	// eviter les hacks
775
-	include_spip('inc/filtres_mini');
776
-	$url = spip_htmlspecialchars($url);
777
-
778
-	$url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url);
779
-
780
-	// &amp; ?
781
-	if ($amp != '&amp;') {
782
-		$url = str_replace('&amp;', $amp, $url);
783
-	}
784
-
785
-	// Si ca demarre par ? ou vide, donner './'
786
-	$url = preg_replace(',^([?].*)?$,', './\1', $url);
787
-
788
-	return $url;
746
+    $url = nettoyer_uri();
747
+    if (
748
+        !$root
749
+        and (
750
+            // si pas de profondeur on peut tronquer
751
+            $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
752
+            // sinon c'est OK si _SET_HTML_BASE a ete force a false
753
+            or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE))
754
+    ) {
755
+        $url = preg_replace(',^[^?]*/,', '', $url);
756
+    }
757
+    // ajouter le cas echeant les variables _POST['id_...']
758
+    foreach ($_POST as $v => $c) {
759
+        if (substr($v, 0, 3) == 'id_') {
760
+            $url = parametre_url($url, $v, $c, '&');
761
+        }
762
+    }
763
+
764
+    // supprimer les variables sans interet
765
+    if (test_espace_prive()) {
766
+        $url = preg_replace(',([?&])('
767
+            . 'lang|show_docs|'
768
+            . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
769
+        $url = preg_replace(',([?&])[&]+,', '\1', $url);
770
+        $url = preg_replace(',[&]$,', '\1', $url);
771
+    }
772
+
773
+    // eviter les hacks
774
+    include_spip('inc/filtres_mini');
775
+    $url = spip_htmlspecialchars($url);
776
+
777
+    $url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url);
778
+
779
+    // &amp; ?
780
+    if ($amp != '&amp;') {
781
+        $url = str_replace('&amp;', $amp, $url);
782
+    }
783
+
784
+    // Si ca demarre par ? ou vide, donner './'
785
+    $url = preg_replace(',^([?].*)?$,', './\1', $url);
786
+
787
+    return $url;
789 788
 }
790 789
 
791 790
 
@@ -796,7 +795,7 @@  discard block
 block discarded – undo
796 795
  *     true si c'est le cas, false sinon.
797 796
  */
798 797
 function test_espace_prive() {
799
-	return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false;
798
+    return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false;
800 799
 }
801 800
 
802 801
 /**
@@ -806,7 +805,7 @@  discard block
 block discarded – undo
806 805
  * @return bool
807 806
  */
808 807
 function test_plugin_actif($plugin) {
809
-	return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
808
+    return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
810 809
 }
811 810
 
812 811
 /**
@@ -837,52 +836,52 @@  discard block
 block discarded – undo
837 836
  *     Texte
838 837
  */
839 838
 function _T($texte, $args = [], $options = []) {
840
-	static $traduire = false;
841
-	$o = ['class' => '', 'force' => true, 'sanitize' => true];
842
-	if ($options) {
843
-		// support de l'ancien argument $class
844
-		if (is_string($options)) {
845
-			$options = ['class' => $options];
846
-		}
847
-		$o = array_merge($o, $options);
848
-	}
849
-
850
-	if (!$traduire) {
851
-		$traduire = charger_fonction('traduire', 'inc');
852
-		include_spip('inc/lang');
853
-	}
854
-
855
-	// On peut passer explicitement la langue dans le tableau
856
-	// On utilise le même nom de variable que la globale
857
-	if (isset($args['spip_lang'])) {
858
-		$lang = $args['spip_lang'];
859
-		// On l'enleve pour ne pas le passer au remplacement
860
-		unset($args['spip_lang']);
861
-	} // Sinon on prend la langue du contexte
862
-	else {
863
-		$lang = $GLOBALS['spip_lang'];
864
-	}
865
-	$text = $traduire($texte, $lang);
866
-
867
-	if ($text === null || !strlen($text)) {
868
-		if (!$o['force']) {
869
-			return '';
870
-		}
871
-
872
-		$text = $texte;
873
-
874
-		// pour les chaines non traduites, assurer un service minimum
875
-		if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
876
-			$n = strpos($text, ':');
877
-			if ($n !== false) {
878
-				$text = substr($text, $n + 1);
879
-			}
880
-			$text = str_replace('_', ' ', $text);
881
-		}
882
-		$o['class'] = null;
883
-	}
884
-
885
-	return _L($text, $args, $o);
839
+    static $traduire = false;
840
+    $o = ['class' => '', 'force' => true, 'sanitize' => true];
841
+    if ($options) {
842
+        // support de l'ancien argument $class
843
+        if (is_string($options)) {
844
+            $options = ['class' => $options];
845
+        }
846
+        $o = array_merge($o, $options);
847
+    }
848
+
849
+    if (!$traduire) {
850
+        $traduire = charger_fonction('traduire', 'inc');
851
+        include_spip('inc/lang');
852
+    }
853
+
854
+    // On peut passer explicitement la langue dans le tableau
855
+    // On utilise le même nom de variable que la globale
856
+    if (isset($args['spip_lang'])) {
857
+        $lang = $args['spip_lang'];
858
+        // On l'enleve pour ne pas le passer au remplacement
859
+        unset($args['spip_lang']);
860
+    } // Sinon on prend la langue du contexte
861
+    else {
862
+        $lang = $GLOBALS['spip_lang'];
863
+    }
864
+    $text = $traduire($texte, $lang);
865
+
866
+    if ($text === null || !strlen($text)) {
867
+        if (!$o['force']) {
868
+            return '';
869
+        }
870
+
871
+        $text = $texte;
872
+
873
+        // pour les chaines non traduites, assurer un service minimum
874
+        if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
875
+            $n = strpos($text, ':');
876
+            if ($n !== false) {
877
+                $text = substr($text, $n + 1);
878
+            }
879
+            $text = str_replace('_', ' ', $text);
880
+        }
881
+        $o['class'] = null;
882
+    }
883
+
884
+    return _L($text, $args, $o);
886 885
 }
887 886
 
888 887
 
@@ -909,53 +908,53 @@  discard block
 block discarded – undo
909 908
  *     Texte
910 909
  */
911 910
 function _L($text, $args = [], $options = []) {
912
-	$f = $text;
913
-	$defaut_options = [
914
-		'class' => null,
915
-		'sanitize' => true,
916
-	];
917
-	// support de l'ancien argument $class
918
-	if ($options and is_string($options)) {
919
-		$options = ['class' => $options];
920
-	}
921
-	if (is_array($options)) {
922
-		$options += $defaut_options;
923
-	} else {
924
-		$options = $defaut_options;
925
-	}
926
-
927
-	if (is_array($args) and count($args)) {
928
-		if (!function_exists('interdire_scripts')) {
929
-			include_spip('inc/texte');
930
-		}
931
-		if (!function_exists('echapper_html_suspect')) {
932
-			include_spip('inc/texte_mini');
933
-		}
934
-		foreach ($args as $name => $value) {
935
-			if (strpos($text, (string) "@$name@") !== false) {
936
-				if ($options['sanitize']) {
937
-					$value = echapper_html_suspect($value);
938
-					$value = interdire_scripts($value, -1);
939
-				}
940
-				if (!empty($options['class'])) {
941
-					$value = "<span class='" . $options['class'] . "'>$value</span>";
942
-				}
943
-				$text = str_replace("@$name@", $value, $text);
944
-				unset($args[$name]);
945
-			}
946
-		}
947
-		// Si des variables n'ont pas ete inserees, le signaler
948
-		// (chaines de langues pas a jour)
949
-		if ($args) {
950
-			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
951
-		}
952
-	}
953
-
954
-	if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) {
955
-		return "<span class='debug-traduction-erreur'>$text</span>";
956
-	} else {
957
-		return $text;
958
-	}
911
+    $f = $text;
912
+    $defaut_options = [
913
+        'class' => null,
914
+        'sanitize' => true,
915
+    ];
916
+    // support de l'ancien argument $class
917
+    if ($options and is_string($options)) {
918
+        $options = ['class' => $options];
919
+    }
920
+    if (is_array($options)) {
921
+        $options += $defaut_options;
922
+    } else {
923
+        $options = $defaut_options;
924
+    }
925
+
926
+    if (is_array($args) and count($args)) {
927
+        if (!function_exists('interdire_scripts')) {
928
+            include_spip('inc/texte');
929
+        }
930
+        if (!function_exists('echapper_html_suspect')) {
931
+            include_spip('inc/texte_mini');
932
+        }
933
+        foreach ($args as $name => $value) {
934
+            if (strpos($text, (string) "@$name@") !== false) {
935
+                if ($options['sanitize']) {
936
+                    $value = echapper_html_suspect($value);
937
+                    $value = interdire_scripts($value, -1);
938
+                }
939
+                if (!empty($options['class'])) {
940
+                    $value = "<span class='" . $options['class'] . "'>$value</span>";
941
+                }
942
+                $text = str_replace("@$name@", $value, $text);
943
+                unset($args[$name]);
944
+            }
945
+        }
946
+        // Si des variables n'ont pas ete inserees, le signaler
947
+        // (chaines de langues pas a jour)
948
+        if ($args) {
949
+            spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
950
+        }
951
+    }
952
+
953
+    if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) {
954
+        return "<span class='debug-traduction-erreur'>$text</span>";
955
+    } else {
956
+        return $text;
957
+    }
959 958
 }
960 959
 
961 960
 
@@ -969,13 +968,13 @@  discard block
 block discarded – undo
969 968
  * @return string
970 969
  */
971 970
 function joli_repertoire($rep) {
972
-	$a = substr($rep, 0, 1);
973
-	if ($a <> '.' and $a <> '/') {
974
-		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
975
-	}
976
-	$rep = preg_replace(',(^\.\.\/),', '', $rep);
971
+    $a = substr($rep, 0, 1);
972
+    if ($a <> '.' and $a <> '/') {
973
+        $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
974
+    }
975
+    $rep = preg_replace(',(^\.\.\/),', '', $rep);
977 976
 
978
-	return $rep;
977
+    return $rep;
979 978
 }
980 979
 
981 980
 
@@ -1000,54 +999,54 @@  discard block
 block discarded – undo
1000 999
  * @return float|int|string|void
1001 1000
  */
1002 1001
 function spip_timer($t = 'rien', $raw = false) {
1003
-	static $time;
1004
-	$a = time();
1005
-	$b = microtime();
1006
-	// microtime peut contenir les microsecondes et le temps
1007
-	$b = explode(' ', $b);
1008
-	if (count($b) == 2) {
1009
-		$a = end($b);
1010
-	} // plus precis !
1011
-	$b = reset($b);
1012
-	if (!isset($time[$t])) {
1013
-		$time[$t] = $a + $b;
1014
-	} else {
1015
-		$p = ($a + $b - $time[$t]) * 1000;
1016
-		unset($time[$t]);
1002
+    static $time;
1003
+    $a = time();
1004
+    $b = microtime();
1005
+    // microtime peut contenir les microsecondes et le temps
1006
+    $b = explode(' ', $b);
1007
+    if (count($b) == 2) {
1008
+        $a = end($b);
1009
+    } // plus precis !
1010
+    $b = reset($b);
1011
+    if (!isset($time[$t])) {
1012
+        $time[$t] = $a + $b;
1013
+    } else {
1014
+        $p = ($a + $b - $time[$t]) * 1000;
1015
+        unset($time[$t]);
1017 1016
 #			echo "'$p'";exit;
1018
-		if ($raw) {
1019
-			return $p;
1020
-		}
1021
-		if ($p < 1000) {
1022
-			$s = '';
1023
-		} else {
1024
-			$s = sprintf('%d ', $x = floor($p / 1000));
1025
-			$p -= ($x * 1000);
1026
-		}
1017
+        if ($raw) {
1018
+            return $p;
1019
+        }
1020
+        if ($p < 1000) {
1021
+            $s = '';
1022
+        } else {
1023
+            $s = sprintf('%d ', $x = floor($p / 1000));
1024
+            $p -= ($x * 1000);
1025
+        }
1027 1026
 
1028
-		return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1029
-	}
1027
+        return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1028
+    }
1030 1029
 }
1031 1030
 
1032 1031
 
1033 1032
 // Renvoie False si un fichier n'est pas plus vieux que $duree secondes,
1034 1033
 // sinon renvoie True et le date sauf si ca n'est pas souhaite
1035 1034
 function spip_touch($fichier, $duree = 0, $touch = true) {
1036
-	if ($duree) {
1037
-		clearstatcache();
1038
-		if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) {
1039
-			return false;
1040
-		}
1041
-	}
1042
-	if ($touch !== false) {
1043
-		if (!@touch($fichier)) {
1044
-			spip_unlink($fichier);
1045
-			@touch($fichier);
1046
-		};
1047
-		@chmod($fichier, _SPIP_CHMOD & ~0111);
1048
-	}
1035
+    if ($duree) {
1036
+        clearstatcache();
1037
+        if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) {
1038
+            return false;
1039
+        }
1040
+    }
1041
+    if ($touch !== false) {
1042
+        if (!@touch($fichier)) {
1043
+            spip_unlink($fichier);
1044
+            @touch($fichier);
1045
+        };
1046
+        @chmod($fichier, _SPIP_CHMOD & ~0111);
1047
+    }
1049 1048
 
1050
-	return true;
1049
+    return true;
1051 1050
 }
1052 1051
 
1053 1052
 
@@ -1058,11 +1057,11 @@  discard block
 block discarded – undo
1058 1057
  * @uses cron()
1059 1058
  **/
1060 1059
 function action_cron() {
1061
-	include_spip('inc/headers');
1062
-	http_response_code(204); // No Content
1063
-	header('Connection: close');
1064
-	define('_DIRECT_CRON_FORCE', true);
1065
-	cron();
1060
+    include_spip('inc/headers');
1061
+    http_response_code(204); // No Content
1062
+    header('Connection: close');
1063
+    define('_DIRECT_CRON_FORCE', true);
1064
+    cron();
1066 1065
 }
1067 1066
 
1068 1067
 /**
@@ -1078,26 +1077,26 @@  discard block
 block discarded – undo
1078 1077
  *     True si la tache a pu être effectuée
1079 1078
  */
1080 1079
 function cron($taches = [], $taches_old = []) {
1081
-	// si pas en mode cron force, laisser tomber.
1082
-	if (!defined('_DIRECT_CRON_FORCE')) {
1083
-		return false;
1084
-	}
1085
-	if (!is_array($taches)) {
1086
-		$taches = $taches_old;
1087
-	} // compat anciens appels
1088
-	// si taches a inserer en base et base inaccessible, laisser tomber
1089
-	// sinon on ne verifie pas la connexion tout de suite, car si ca se trouve
1090
-	// queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
1091
-	// et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
1092
-	if ($taches and count($taches) and !spip_connect()) {
1093
-		return false;
1094
-	}
1095
-	spip_log('cron !', 'jq' . _LOG_DEBUG);
1096
-	if ($genie = charger_fonction('genie', 'inc', true)) {
1097
-		return $genie($taches);
1098
-	}
1099
-
1100
-	return false;
1080
+    // si pas en mode cron force, laisser tomber.
1081
+    if (!defined('_DIRECT_CRON_FORCE')) {
1082
+        return false;
1083
+    }
1084
+    if (!is_array($taches)) {
1085
+        $taches = $taches_old;
1086
+    } // compat anciens appels
1087
+    // si taches a inserer en base et base inaccessible, laisser tomber
1088
+    // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve
1089
+    // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
1090
+    // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
1091
+    if ($taches and count($taches) and !spip_connect()) {
1092
+        return false;
1093
+    }
1094
+    spip_log('cron !', 'jq' . _LOG_DEBUG);
1095
+    if ($genie = charger_fonction('genie', 'inc', true)) {
1096
+        return $genie($taches);
1097
+    }
1098
+
1099
+    return false;
1101 1100
 }
1102 1101
 
1103 1102
 /**
@@ -1129,17 +1128,17 @@  discard block
 block discarded – undo
1129 1128
  *     Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté.
1130 1129
  */
1131 1130
 function job_queue_add(
1132
-	$function,
1133
-	$description,
1134
-	$arguments = [],
1135
-	$file = '',
1136
-	$no_duplicate = false,
1137
-	$time = 0,
1138
-	$priority = 0
1131
+    $function,
1132
+    $description,
1133
+    $arguments = [],
1134
+    $file = '',
1135
+    $no_duplicate = false,
1136
+    $time = 0,
1137
+    $priority = 0
1139 1138
 ) {
1140
-	include_spip('inc/queue');
1139
+    include_spip('inc/queue');
1141 1140
 
1142
-	return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
1141
+    return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
1143 1142
 }
1144 1143
 
1145 1144
 /**
@@ -1150,9 +1149,9 @@  discard block
 block discarded – undo
1150 1149
  * @return bool
1151 1150
  */
1152 1151
 function job_queue_remove($id_job) {
1153
-	include_spip('inc/queue');
1152
+    include_spip('inc/queue');
1154 1153
 
1155
-	return queue_remove_job($id_job);
1154
+    return queue_remove_job($id_job);
1156 1155
 }
1157 1156
 
1158 1157
 /**
@@ -1165,9 +1164,9 @@  discard block
 block discarded – undo
1165 1164
  *     or an array of simple array to link multiples objet in one time
1166 1165
  */
1167 1166
 function job_queue_link($id_job, $objets) {
1168
-	include_spip('inc/queue');
1167
+    include_spip('inc/queue');
1169 1168
 
1170
-	return queue_link_job($id_job, $objets);
1169
+    return queue_link_job($id_job, $objets);
1171 1170
 }
1172 1171
 
1173 1172
 
@@ -1187,36 +1186,36 @@  discard block
 block discarded – undo
1187 1186
  *  - `null` si la queue n'est pas encore initialisée
1188 1187
  */
1189 1188
 function queue_sleep_time_to_next_job($force = null) {
1190
-	static $queue_next_job_time = -1;
1191
-	if ($force === true) {
1192
-		$queue_next_job_time = -1;
1193
-	} elseif ($force) {
1194
-		$queue_next_job_time = $force;
1195
-	}
1196
-
1197
-	if ($queue_next_job_time == -1) {
1198
-		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1199
-			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
1200
-		}
1201
-		// utiliser un cache memoire si dispo
1202
-		if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
1203
-			$queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
1204
-		} else {
1205
-			$queue_next_job_time = null;
1206
-			if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) {
1207
-				$queue_next_job_time = intval($contenu);
1208
-			}
1209
-		}
1210
-	}
1211
-
1212
-	if (is_null($queue_next_job_time)) {
1213
-		return null;
1214
-	}
1215
-	if (!$_SERVER['REQUEST_TIME']) {
1216
-		$_SERVER['REQUEST_TIME'] = time();
1217
-	}
1218
-
1219
-	return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
1189
+    static $queue_next_job_time = -1;
1190
+    if ($force === true) {
1191
+        $queue_next_job_time = -1;
1192
+    } elseif ($force) {
1193
+        $queue_next_job_time = $force;
1194
+    }
1195
+
1196
+    if ($queue_next_job_time == -1) {
1197
+        if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1198
+            define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
1199
+        }
1200
+        // utiliser un cache memoire si dispo
1201
+        if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
1202
+            $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
1203
+        } else {
1204
+            $queue_next_job_time = null;
1205
+            if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) {
1206
+                $queue_next_job_time = intval($contenu);
1207
+            }
1208
+        }
1209
+    }
1210
+
1211
+    if (is_null($queue_next_job_time)) {
1212
+        return null;
1213
+    }
1214
+    if (!$_SERVER['REQUEST_TIME']) {
1215
+        $_SERVER['REQUEST_TIME'] = time();
1216
+    }
1217
+
1218
+    return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
1220 1219
 }
1221 1220
 
1222 1221
 
@@ -1228,11 +1227,11 @@  discard block
 block discarded – undo
1228 1227
  * @return string
1229 1228
  */
1230 1229
 function quote_amp($u) {
1231
-	return preg_replace(
1232
-		'/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i',
1233
-		'&amp;',
1234
-		$u
1235
-	);
1230
+    return preg_replace(
1231
+        '/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i',
1232
+        '&amp;',
1233
+        $u
1234
+    );
1236 1235
 }
1237 1236
 
1238 1237
 
@@ -1255,27 +1254,27 @@  discard block
 block discarded – undo
1255 1254
  *     Balise HTML `<script>` et son contenu
1256 1255
  **/
1257 1256
 function http_script($script, $src = '', $noscript = '') {
1258
-	static $done = [];
1257
+    static $done = [];
1259 1258
 
1260
-	if ($src && !isset($done[$src])) {
1261
-		$done[$src] = true;
1262
-		$src = find_in_path($src, _JAVASCRIPT);
1263
-		$src = " src='$src'";
1264
-	} else {
1265
-		$src = '';
1266
-	}
1267
-	if ($script) {
1268
-		$script = ("/*<![CDATA[*/\n" .
1269
-			preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1270
-			'/*]]>*/');
1271
-	}
1272
-	if ($noscript) {
1273
-		$noscript = "<noscript>\n\t$noscript\n</noscript>\n";
1274
-	}
1259
+    if ($src && !isset($done[$src])) {
1260
+        $done[$src] = true;
1261
+        $src = find_in_path($src, _JAVASCRIPT);
1262
+        $src = " src='$src'";
1263
+    } else {
1264
+        $src = '';
1265
+    }
1266
+    if ($script) {
1267
+        $script = ("/*<![CDATA[*/\n" .
1268
+            preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1269
+            '/*]]>*/');
1270
+    }
1271
+    if ($noscript) {
1272
+        $noscript = "<noscript>\n\t$noscript\n</noscript>\n";
1273
+    }
1275 1274
 
1276
-	return ($src or $script or $noscript)
1277
-		? "<script type='text/javascript'$src>$script</script>$noscript"
1278
-		: '';
1275
+    return ($src or $script or $noscript)
1276
+        ? "<script type='text/javascript'$src>$script</script>$noscript"
1277
+        : '';
1279 1278
 }
1280 1279
 
1281 1280
 
@@ -1310,7 +1309,7 @@  discard block
 block discarded – undo
1310 1309
  *     Texte échappé
1311 1310
  **/
1312 1311
 function texte_script(string $texte): string {
1313
-	return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte));
1312
+    return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte));
1314 1313
 }
1315 1314
 
1316 1315
 
@@ -1347,68 +1346,68 @@  discard block
 block discarded – undo
1347 1346
  *     Liste des chemins, par ordre de priorité.
1348 1347
  **/
1349 1348
 function _chemin($dir_path = null) {
1350
-	static $path_base = null;
1351
-	static $path_full = null;
1352
-	if ($path_base == null) {
1353
-		// Chemin standard depuis l'espace public
1354
-		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
1355
-			_DIR_RACINE . ':' .
1356
-			_DIR_RACINE . 'squelettes-dist/:' .
1357
-			_DIR_RACINE . 'prive/:' .
1358
-			_DIR_RESTREINT;
1359
-		// Ajouter squelettes/
1360
-		if (@is_dir(_DIR_RACINE . 'squelettes')) {
1361
-			$path = _DIR_RACINE . 'squelettes/:' . $path;
1362
-		}
1363
-		foreach (explode(':', $path) as $dir) {
1364
-			if (strlen($dir) and substr($dir, -1) != '/') {
1365
-				$dir .= '/';
1366
-			}
1367
-			$path_base[] = $dir;
1368
-		}
1369
-		$path_full = $path_base;
1370
-		// Et le(s) dossier(s) des squelettes nommes
1371
-		if (strlen($GLOBALS['dossier_squelettes'])) {
1372
-			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1373
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1374
-			}
1375
-		}
1376
-		$GLOBALS['path_sig'] = md5(serialize($path_full));
1377
-	}
1378
-	if ($dir_path === null) {
1379
-		return $path_full;
1380
-	}
1381
-
1382
-	if (is_array($dir_path) or strlen($dir_path)) {
1383
-		$tete = '';
1384
-		if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1385
-			$tete = array_shift($path_base);
1386
-		}
1387
-		$dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
1388
-		$dirs = array_reverse($dirs);
1389
-		foreach ($dirs as $dir_path) {
1390
-			if (substr($dir_path, -1) != '/') {
1391
-				$dir_path .= '/';
1392
-			}
1393
-			if (!in_array($dir_path, $path_base)) {
1394
-				array_unshift($path_base, $dir_path);
1395
-			}
1396
-		}
1397
-		if (strlen($tete)) {
1398
-			array_unshift($path_base, $tete);
1399
-		}
1400
-	}
1401
-	$path_full = $path_base;
1402
-	// Et le(s) dossier(s) des squelettes nommes
1403
-	if (strlen($GLOBALS['dossier_squelettes'])) {
1404
-		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1405
-			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1406
-		}
1407
-	}
1408
-
1409
-	$GLOBALS['path_sig'] = md5(serialize($path_full));
1410
-
1411
-	return $path_full;
1349
+    static $path_base = null;
1350
+    static $path_full = null;
1351
+    if ($path_base == null) {
1352
+        // Chemin standard depuis l'espace public
1353
+        $path = defined('_SPIP_PATH') ? _SPIP_PATH :
1354
+            _DIR_RACINE . ':' .
1355
+            _DIR_RACINE . 'squelettes-dist/:' .
1356
+            _DIR_RACINE . 'prive/:' .
1357
+            _DIR_RESTREINT;
1358
+        // Ajouter squelettes/
1359
+        if (@is_dir(_DIR_RACINE . 'squelettes')) {
1360
+            $path = _DIR_RACINE . 'squelettes/:' . $path;
1361
+        }
1362
+        foreach (explode(':', $path) as $dir) {
1363
+            if (strlen($dir) and substr($dir, -1) != '/') {
1364
+                $dir .= '/';
1365
+            }
1366
+            $path_base[] = $dir;
1367
+        }
1368
+        $path_full = $path_base;
1369
+        // Et le(s) dossier(s) des squelettes nommes
1370
+        if (strlen($GLOBALS['dossier_squelettes'])) {
1371
+            foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1372
+                array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1373
+            }
1374
+        }
1375
+        $GLOBALS['path_sig'] = md5(serialize($path_full));
1376
+    }
1377
+    if ($dir_path === null) {
1378
+        return $path_full;
1379
+    }
1380
+
1381
+    if (is_array($dir_path) or strlen($dir_path)) {
1382
+        $tete = '';
1383
+        if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1384
+            $tete = array_shift($path_base);
1385
+        }
1386
+        $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
1387
+        $dirs = array_reverse($dirs);
1388
+        foreach ($dirs as $dir_path) {
1389
+            if (substr($dir_path, -1) != '/') {
1390
+                $dir_path .= '/';
1391
+            }
1392
+            if (!in_array($dir_path, $path_base)) {
1393
+                array_unshift($path_base, $dir_path);
1394
+            }
1395
+        }
1396
+        if (strlen($tete)) {
1397
+            array_unshift($path_base, $tete);
1398
+        }
1399
+    }
1400
+    $path_full = $path_base;
1401
+    // Et le(s) dossier(s) des squelettes nommes
1402
+    if (strlen($GLOBALS['dossier_squelettes'])) {
1403
+        foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1404
+            array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1405
+        }
1406
+    }
1407
+
1408
+    $GLOBALS['path_sig'] = md5(serialize($path_full));
1409
+
1410
+    return $path_full;
1412 1411
 }
1413 1412
 
1414 1413
 /**
@@ -1421,78 +1420,78 @@  discard block
 block discarded – undo
1421 1420
  * @return array Liste de chemins
1422 1421
  **/
1423 1422
 function creer_chemin() {
1424
-	$path_a = _chemin();
1425
-	static $c = '';
1423
+    $path_a = _chemin();
1424
+    static $c = '';
1426 1425
 
1427
-	// on calcule le chemin si le dossier skel a change
1428
-	if ($c != $GLOBALS['dossier_squelettes']) {
1429
-		// assurer le non plantage lors de la montee de version :
1430
-		$c = $GLOBALS['dossier_squelettes'];
1431
-		$path_a = _chemin(''); // forcer un recalcul du chemin
1432
-	}
1426
+    // on calcule le chemin si le dossier skel a change
1427
+    if ($c != $GLOBALS['dossier_squelettes']) {
1428
+        // assurer le non plantage lors de la montee de version :
1429
+        $c = $GLOBALS['dossier_squelettes'];
1430
+        $path_a = _chemin(''); // forcer un recalcul du chemin
1431
+    }
1433 1432
 
1434
-	return $path_a;
1433
+    return $path_a;
1435 1434
 }
1436 1435
 
1437 1436
 
1438 1437
 function lister_themes_prives() {
1439
-	static $themes = null;
1440
-	if (is_null($themes)) {
1441
-		// si pas encore definie
1442
-		if (!defined('_SPIP_THEME_PRIVE')) {
1443
-			define('_SPIP_THEME_PRIVE', 'spip');
1444
-		}
1445
-		$themes = [_SPIP_THEME_PRIVE];
1446
-		// lors d'une installation neuve, prefs n'est pas definie.
1447
-		if (isset($GLOBALS['visiteur_session']['prefs'])) {
1448
-			$prefs = $GLOBALS['visiteur_session']['prefs'];
1449
-		} else {
1450
-			$prefs = [];
1451
-		}
1452
-		if (is_string($prefs)) {
1453
-			$prefs = unserialize($GLOBALS['visiteur_session']['prefs']);
1454
-		}
1455
-		if (
1456
-			((isset($prefs['theme']) and $theme = $prefs['theme'])
1457
-				or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut']))
1458
-			and $theme != _SPIP_THEME_PRIVE
1459
-		) {
1460
-			array_unshift($themes, $theme);
1461
-		} // placer le theme choisi en tete
1462
-	}
1463
-
1464
-	return $themes;
1438
+    static $themes = null;
1439
+    if (is_null($themes)) {
1440
+        // si pas encore definie
1441
+        if (!defined('_SPIP_THEME_PRIVE')) {
1442
+            define('_SPIP_THEME_PRIVE', 'spip');
1443
+        }
1444
+        $themes = [_SPIP_THEME_PRIVE];
1445
+        // lors d'une installation neuve, prefs n'est pas definie.
1446
+        if (isset($GLOBALS['visiteur_session']['prefs'])) {
1447
+            $prefs = $GLOBALS['visiteur_session']['prefs'];
1448
+        } else {
1449
+            $prefs = [];
1450
+        }
1451
+        if (is_string($prefs)) {
1452
+            $prefs = unserialize($GLOBALS['visiteur_session']['prefs']);
1453
+        }
1454
+        if (
1455
+            ((isset($prefs['theme']) and $theme = $prefs['theme'])
1456
+                or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut']))
1457
+            and $theme != _SPIP_THEME_PRIVE
1458
+        ) {
1459
+            array_unshift($themes, $theme);
1460
+        } // placer le theme choisi en tete
1461
+    }
1462
+
1463
+    return $themes;
1465 1464
 }
1466 1465
 
1467 1466
 function find_in_theme($file, $subdir = '', $include = false) {
1468
-	static $themefiles = [];
1469
-	if (isset($themefiles["$subdir$file"])) {
1470
-		return $themefiles["$subdir$file"];
1471
-	}
1472
-	// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1473
-	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1474
-	if (
1475
-		preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1476
-		and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg'
1477
-		and $f = find_in_theme("$file_svg_generique")
1478
-	) {
1479
-		if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) {
1480
-			return $themefiles["$subdir$file"] = $fsize;
1481
-		}
1482
-		else {
1483
-			return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
1484
-		}
1485
-	}
1486
-
1487
-	$themes = lister_themes_prives();
1488
-	foreach ($themes as $theme) {
1489
-		if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) {
1490
-			return $themefiles["$subdir$file"] = $f;
1491
-		}
1492
-	}
1493
-	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1494
-
1495
-	return $themefiles["$subdir$file"] = '';
1467
+    static $themefiles = [];
1468
+    if (isset($themefiles["$subdir$file"])) {
1469
+        return $themefiles["$subdir$file"];
1470
+    }
1471
+    // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1472
+    // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1473
+    if (
1474
+        preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1475
+        and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg'
1476
+        and $f = find_in_theme("$file_svg_generique")
1477
+    ) {
1478
+        if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) {
1479
+            return $themefiles["$subdir$file"] = $fsize;
1480
+        }
1481
+        else {
1482
+            return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
1483
+        }
1484
+    }
1485
+
1486
+    $themes = lister_themes_prives();
1487
+    foreach ($themes as $theme) {
1488
+        if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) {
1489
+            return $themefiles["$subdir$file"] = $f;
1490
+        }
1491
+    }
1492
+    spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1493
+
1494
+    return $themefiles["$subdir$file"] = '';
1496 1495
 }
1497 1496
 
1498 1497
 
@@ -1516,31 +1515,31 @@  discard block
 block discarded – undo
1516 1515
  *     sinon chaîne vide.
1517 1516
  **/
1518 1517
 function chemin_image($icone) {
1519
-	static $icone_renommer;
1520
-	if ($p = strpos($icone, '?')) {
1521
-		$icone = substr($icone, 0, $p);
1522
-	}
1523
-	// gerer le cas d'un double appel en evitant de refaire le travail inutilement
1524
-	if (strpos($icone, '/') !== false and file_exists($icone)) {
1525
-		return $icone;
1526
-	}
1527
-
1528
-	// si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
1529
-	if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) {
1530
-		return $f;
1531
-	}
1532
-	// sinon passer par le module de renommage
1533
-	if (is_null($icone_renommer)) {
1534
-		$icone_renommer = charger_fonction('icone_renommer', 'inc', true);
1535
-	}
1536
-	if ($icone_renommer) {
1537
-		[$icone, $fonction] = $icone_renommer($icone, '');
1538
-		if (file_exists($icone)) {
1539
-			return $icone;
1540
-		}
1541
-	}
1542
-
1543
-	return find_in_path($icone, _NOM_IMG_PACK);
1518
+    static $icone_renommer;
1519
+    if ($p = strpos($icone, '?')) {
1520
+        $icone = substr($icone, 0, $p);
1521
+    }
1522
+    // gerer le cas d'un double appel en evitant de refaire le travail inutilement
1523
+    if (strpos($icone, '/') !== false and file_exists($icone)) {
1524
+        return $icone;
1525
+    }
1526
+
1527
+    // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
1528
+    if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) {
1529
+        return $f;
1530
+    }
1531
+    // sinon passer par le module de renommage
1532
+    if (is_null($icone_renommer)) {
1533
+        $icone_renommer = charger_fonction('icone_renommer', 'inc', true);
1534
+    }
1535
+    if ($icone_renommer) {
1536
+        [$icone, $fonction] = $icone_renommer($icone, '');
1537
+        if (file_exists($icone)) {
1538
+            return $icone;
1539
+        }
1540
+    }
1541
+
1542
+    return find_in_path($icone, _NOM_IMG_PACK);
1544 1543
 }
1545 1544
 
1546 1545
 //
@@ -1578,128 +1577,128 @@  discard block
 block discarded – undo
1578 1577
  *     - false : fichier introuvable
1579 1578
  **/
1580 1579
 function find_in_path($file, $dirname = '', $include = false) {
1581
-	static $dirs = [];
1582
-	static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec
1583
-	static $c = '';
1584
-
1585
-	if (!$file and !strlen($file)) {
1586
-		return false;
1587
-	}
1588
-
1589
-	// on calcule le chemin si le dossier skel a change
1590
-	if ($c != $GLOBALS['dossier_squelettes']) {
1591
-		// assurer le non plantage lors de la montee de version :
1592
-		$c = $GLOBALS['dossier_squelettes'];
1593
-		creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
1594
-	}
1595
-
1596
-	if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) {
1597
-		if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) {
1598
-			return false;
1599
-		}
1600
-		if ($include and !isset($inc[$dirname][$file])) {
1601
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1602
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1603
-		}
1604
-
1605
-		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1606
-	}
1607
-
1608
-	$a = strrpos($file, '/');
1609
-	if ($a !== false) {
1610
-		$dirname .= substr($file, 0, ++$a);
1611
-		$file = substr($file, $a);
1612
-	}
1613
-
1614
-	foreach (creer_chemin() as $dir) {
1615
-		if (!isset($dirs[$a = $dir . $dirname])) {
1616
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1617
-		}
1618
-		if ($dirs[$a]) {
1619
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
1620
-				if ($include and !isset($inc[$dirname][$file])) {
1621
-					include_once _ROOT_CWD . $a;
1622
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1623
-				}
1624
-				if (!defined('_SAUVER_CHEMIN')) {
1625
-					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1626
-					if (is_null($GLOBALS['path_files'])) {
1627
-						return $a;
1628
-					}
1629
-					define('_SAUVER_CHEMIN', true);
1630
-				}
1631
-
1632
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1633
-			}
1634
-		}
1635
-	}
1636
-
1637
-	if ($include) {
1638
-		spip_log("include_spip $dirname$file non trouve");
1639
-		if ($include === 'required') {
1640
-			echo '<pre>',
1641
-			'<strong>Erreur Fatale</strong><br />';
1642
-			if (function_exists('debug_print_backtrace')) {
1643
-				echo debug_print_backtrace();
1644
-			}
1645
-			echo '</pre>';
1646
-			die("Erreur interne: ne peut inclure $dirname$file");
1647
-		}
1648
-	}
1649
-
1650
-	if (!defined('_SAUVER_CHEMIN')) {
1651
-		// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1652
-		if (is_null($GLOBALS['path_files'])) {
1653
-			return false;
1654
-		}
1655
-		define('_SAUVER_CHEMIN', true);
1656
-	}
1657
-
1658
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1580
+    static $dirs = [];
1581
+    static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec
1582
+    static $c = '';
1583
+
1584
+    if (!$file and !strlen($file)) {
1585
+        return false;
1586
+    }
1587
+
1588
+    // on calcule le chemin si le dossier skel a change
1589
+    if ($c != $GLOBALS['dossier_squelettes']) {
1590
+        // assurer le non plantage lors de la montee de version :
1591
+        $c = $GLOBALS['dossier_squelettes'];
1592
+        creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
1593
+    }
1594
+
1595
+    if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) {
1596
+        if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) {
1597
+            return false;
1598
+        }
1599
+        if ($include and !isset($inc[$dirname][$file])) {
1600
+            include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1601
+            $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1602
+        }
1603
+
1604
+        return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1605
+    }
1606
+
1607
+    $a = strrpos($file, '/');
1608
+    if ($a !== false) {
1609
+        $dirname .= substr($file, 0, ++$a);
1610
+        $file = substr($file, $a);
1611
+    }
1612
+
1613
+    foreach (creer_chemin() as $dir) {
1614
+        if (!isset($dirs[$a = $dir . $dirname])) {
1615
+            $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1616
+        }
1617
+        if ($dirs[$a]) {
1618
+            if (file_exists(_ROOT_CWD . ($a .= $file))) {
1619
+                if ($include and !isset($inc[$dirname][$file])) {
1620
+                    include_once _ROOT_CWD . $a;
1621
+                    $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1622
+                }
1623
+                if (!defined('_SAUVER_CHEMIN')) {
1624
+                    // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1625
+                    if (is_null($GLOBALS['path_files'])) {
1626
+                        return $a;
1627
+                    }
1628
+                    define('_SAUVER_CHEMIN', true);
1629
+                }
1630
+
1631
+                return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1632
+            }
1633
+        }
1634
+    }
1635
+
1636
+    if ($include) {
1637
+        spip_log("include_spip $dirname$file non trouve");
1638
+        if ($include === 'required') {
1639
+            echo '<pre>',
1640
+            '<strong>Erreur Fatale</strong><br />';
1641
+            if (function_exists('debug_print_backtrace')) {
1642
+                echo debug_print_backtrace();
1643
+            }
1644
+            echo '</pre>';
1645
+            die("Erreur interne: ne peut inclure $dirname$file");
1646
+        }
1647
+    }
1648
+
1649
+    if (!defined('_SAUVER_CHEMIN')) {
1650
+        // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1651
+        if (is_null($GLOBALS['path_files'])) {
1652
+            return false;
1653
+        }
1654
+        define('_SAUVER_CHEMIN', true);
1655
+    }
1656
+
1657
+    return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1659 1658
 }
1660 1659
 
1661 1660
 function clear_path_cache() {
1662
-	$GLOBALS['path_files'] = [];
1663
-	spip_unlink(_CACHE_CHEMIN);
1661
+    $GLOBALS['path_files'] = [];
1662
+    spip_unlink(_CACHE_CHEMIN);
1664 1663
 }
1665 1664
 
1666 1665
 function load_path_cache() {
1667
-	// charger le path des plugins
1668
-	if (@is_readable(_CACHE_PLUGINS_PATH)) {
1669
-		include_once(_CACHE_PLUGINS_PATH);
1670
-	}
1671
-	$GLOBALS['path_files'] = [];
1672
-	// si le visiteur est admin,
1673
-	// on ne recharge pas le cache pour forcer sa mise a jour
1674
-	if (
1675
-		// la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier
1676
-		//AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')
1677
-		// utiliser le cookie est un pis aller qui marche 'en general'
1678
-		// on blinde par un second test au moment de la lecture de la session
1679
-		// !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
1680
-		// et en ignorant ce cache en cas de recalcul explicite
1681
-		!_request('var_mode')
1682
-	) {
1683
-		// on essaye de lire directement sans verrou pour aller plus vite
1684
-		if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
1685
-			// mais si semble corrompu on relit avec un verrou
1686
-			if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1687
-				lire_fichier(_CACHE_CHEMIN, $contenu);
1688
-				if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1689
-					$GLOBALS['path_files'] = [];
1690
-				}
1691
-			}
1692
-		}
1693
-	}
1666
+    // charger le path des plugins
1667
+    if (@is_readable(_CACHE_PLUGINS_PATH)) {
1668
+        include_once(_CACHE_PLUGINS_PATH);
1669
+    }
1670
+    $GLOBALS['path_files'] = [];
1671
+    // si le visiteur est admin,
1672
+    // on ne recharge pas le cache pour forcer sa mise a jour
1673
+    if (
1674
+        // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier
1675
+        //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')
1676
+        // utiliser le cookie est un pis aller qui marche 'en general'
1677
+        // on blinde par un second test au moment de la lecture de la session
1678
+        // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
1679
+        // et en ignorant ce cache en cas de recalcul explicite
1680
+        !_request('var_mode')
1681
+    ) {
1682
+        // on essaye de lire directement sans verrou pour aller plus vite
1683
+        if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
1684
+            // mais si semble corrompu on relit avec un verrou
1685
+            if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1686
+                lire_fichier(_CACHE_CHEMIN, $contenu);
1687
+                if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1688
+                    $GLOBALS['path_files'] = [];
1689
+                }
1690
+            }
1691
+        }
1692
+    }
1694 1693
 }
1695 1694
 
1696 1695
 function save_path_cache() {
1697
-	if (
1698
-		defined('_SAUVER_CHEMIN')
1699
-		and _SAUVER_CHEMIN
1700
-	) {
1701
-		ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
1702
-	}
1696
+    if (
1697
+        defined('_SAUVER_CHEMIN')
1698
+        and _SAUVER_CHEMIN
1699
+    ) {
1700
+        ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
1701
+    }
1703 1702
 }
1704 1703
 
1705 1704
 
@@ -1719,33 +1718,33 @@  discard block
 block discarded – undo
1719 1718
  * @return array
1720 1719
  */
1721 1720
 function find_all_in_path($dir, $pattern, $recurs = false) {
1722
-	$liste_fichiers = [];
1723
-	$maxfiles = 10000;
1724
-
1725
-	// cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1726
-	// on a pas encore inclus flock.php
1727
-	if (!function_exists('preg_files')) {
1728
-		include_once _ROOT_RESTREINT . 'inc/flock.php';
1729
-	}
1730
-
1731
-	// Parcourir le chemin
1732
-	foreach (creer_chemin() as $d) {
1733
-		$f = $d . $dir;
1734
-		if (@is_dir($f)) {
1735
-			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
1736
-			foreach ($liste as $chemin) {
1737
-				$nom = basename($chemin);
1738
-				// ne prendre que les fichiers pas deja trouves
1739
-				// car find_in_path prend le premier qu'il trouve,
1740
-				// les autres sont donc masques
1741
-				if (!isset($liste_fichiers[$nom])) {
1742
-					$liste_fichiers[$nom] = $chemin;
1743
-				}
1744
-			}
1745
-		}
1746
-	}
1747
-
1748
-	return $liste_fichiers;
1721
+    $liste_fichiers = [];
1722
+    $maxfiles = 10000;
1723
+
1724
+    // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1725
+    // on a pas encore inclus flock.php
1726
+    if (!function_exists('preg_files')) {
1727
+        include_once _ROOT_RESTREINT . 'inc/flock.php';
1728
+    }
1729
+
1730
+    // Parcourir le chemin
1731
+    foreach (creer_chemin() as $d) {
1732
+        $f = $d . $dir;
1733
+        if (@is_dir($f)) {
1734
+            $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
1735
+            foreach ($liste as $chemin) {
1736
+                $nom = basename($chemin);
1737
+                // ne prendre que les fichiers pas deja trouves
1738
+                // car find_in_path prend le premier qu'il trouve,
1739
+                // les autres sont donc masques
1740
+                if (!isset($liste_fichiers[$nom])) {
1741
+                    $liste_fichiers[$nom] = $chemin;
1742
+                }
1743
+            }
1744
+        }
1745
+    }
1746
+
1747
+    return $liste_fichiers;
1749 1748
 }
1750 1749
 
1751 1750
 /**
@@ -1757,17 +1756,17 @@  discard block
 block discarded – undo
1757 1756
  * @return bool
1758 1757
  */
1759 1758
 function autoriser_sans_cookie($nom, $strict = false) {
1760
-	static $autsanscookie = ['install', 'base_repair'];
1759
+    static $autsanscookie = ['install', 'base_repair'];
1761 1760
 
1762
-	if (in_array($nom, $autsanscookie)) {
1763
-		if (test_espace_prive()) {
1764
-			include_spip('base/connect_sql');
1765
-			if (!$strict or !spip_connect()) {
1766
-				return true;
1767
-			}
1768
-		}
1769
-	}
1770
-	return false;
1761
+    if (in_array($nom, $autsanscookie)) {
1762
+        if (test_espace_prive()) {
1763
+            include_spip('base/connect_sql');
1764
+            if (!$strict or !spip_connect()) {
1765
+                return true;
1766
+            }
1767
+        }
1768
+    }
1769
+    return false;
1771 1770
 }
1772 1771
 
1773 1772
 /**
@@ -1777,56 +1776,56 @@  discard block
 block discarded – undo
1777 1776
  * @return string
1778 1777
  */
1779 1778
 function charger_fonction_url(string $quoi, string $type = '') {
1780
-	if ($type === 'defaut') {
1781
-		$objet = objet_type($quoi);
1782
-		if ($f = charger_fonction('generer_' . $objet . '_url', 'urls', true)
1783
-			// deprecated
1784
-			or $f = charger_fonction('generer_url_' . $objet, 'urls', true)
1785
-		) {
1786
-			return $f;
1787
-		}
1788
-		return '';
1789
-	}
1790
-
1791
-	if (!$type) {
1792
-		$type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut
1793
-	}
1794
-
1795
-	// inclure le module d'url
1796
-	include_spip('urls/'.$type);
1797
-
1798
-	switch ($quoi) {
1799
-		case 'page':
1800
-			if (
1801
-				 function_exists($f = "urls_{$type}_generer_url_page")
1802
-			  or function_exists($f .= "_dist")
1803
-			  // ou une fonction custom utilisateur independante du type d'url
1804
-			  or function_exists($f = "generer_url_page")
1805
-			  or function_exists($f .= "_dist")
1806
-			) {
1807
-				return $f;
1808
-			}
1809
-			// pas de compat ancienne version ici, c'est une nouvelle feature
1810
-			return '';
1811
-		case 'objet':
1812
-		case 'decoder':
1813
-		default:
1814
-			$fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url');
1815
-			if (function_exists($f = "urls_{$type}_{$fquoi}")
1816
-			  or function_exists($f .= "_dist")) {
1817
-				return $f;
1818
-			}
1819
-			// est-ce qu'on a une ancienne fonction urls_xxx_dist() ?
1820
-			// c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout
1821
-			if ($f = charger_fonction($type, 'urls', true)) {
1822
-				return $f;
1823
-			}
1824
-			// sinon on se rabat sur les urls page
1825
-			if ($type !== 'page') {
1826
-				return charger_fonction_url($quoi, 'page');
1827
-			}
1828
-			return '';
1829
-	}
1779
+    if ($type === 'defaut') {
1780
+        $objet = objet_type($quoi);
1781
+        if ($f = charger_fonction('generer_' . $objet . '_url', 'urls', true)
1782
+            // deprecated
1783
+            or $f = charger_fonction('generer_url_' . $objet, 'urls', true)
1784
+        ) {
1785
+            return $f;
1786
+        }
1787
+        return '';
1788
+    }
1789
+
1790
+    if (!$type) {
1791
+        $type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut
1792
+    }
1793
+
1794
+    // inclure le module d'url
1795
+    include_spip('urls/'.$type);
1796
+
1797
+    switch ($quoi) {
1798
+        case 'page':
1799
+            if (
1800
+                    function_exists($f = "urls_{$type}_generer_url_page")
1801
+              or function_exists($f .= "_dist")
1802
+                // ou une fonction custom utilisateur independante du type d'url
1803
+              or function_exists($f = "generer_url_page")
1804
+              or function_exists($f .= "_dist")
1805
+            ) {
1806
+                return $f;
1807
+            }
1808
+            // pas de compat ancienne version ici, c'est une nouvelle feature
1809
+            return '';
1810
+        case 'objet':
1811
+        case 'decoder':
1812
+        default:
1813
+            $fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url');
1814
+            if (function_exists($f = "urls_{$type}_{$fquoi}")
1815
+              or function_exists($f .= "_dist")) {
1816
+                return $f;
1817
+            }
1818
+            // est-ce qu'on a une ancienne fonction urls_xxx_dist() ?
1819
+            // c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout
1820
+            if ($f = charger_fonction($type, 'urls', true)) {
1821
+                return $f;
1822
+            }
1823
+            // sinon on se rabat sur les urls page
1824
+            if ($type !== 'page') {
1825
+                return charger_fonction_url($quoi, 'page');
1826
+            }
1827
+            return '';
1828
+    }
1830 1829
 }
1831 1830
 
1832 1831
 
@@ -1855,47 +1854,47 @@  discard block
 block discarded – undo
1855 1854
  *           (cas des raccourcis personalises [->spip20] : il faut implementer une fonction generer_spip_url et une fonction generer_spip_url_ecrire)
1856 1855
  */
1857 1856
 function generer_objet_url($id, string $entite, string $args = '', string $ancre = '', ?bool $public = null, string $type = '', string $connect = ''): string {
1858
-	if ($public === null) {
1859
-		$public = !test_espace_prive();
1860
-	}
1861
-	$id = intval($id);
1862
-	$entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
1863
-
1864
-	if (!$public) {
1865
-		if (!$entite) {
1866
-			return '';
1867
-		}
1868
-		if (!function_exists('generer_objet_url_ecrire')) {
1869
-			include_spip('inc/urls');
1870
-		}
1871
-		$res = generer_objet_url_ecrire($id, $entite, $args, $ancre, false, $connect);
1872
-	} else {
1873
-		$f = charger_fonction_url('objet', $type ?? '');
1874
-
1875
-		// @deprecated si $entite='', on veut la fonction de passage URL ==> id
1876
-		// @see charger_fonction_url
1877
-		if (!$entite) {
1878
-			return $f;
1879
-		}
1880
-
1881
-		// mais d'abord il faut tester le cas des urls sur une
1882
-		// base distante
1883
-		if ($connect
1884
-			and $g = charger_fonction('connect', 'urls', true)
1885
-		) {
1886
-			$f = $g;
1887
-		}
1888
-
1889
-		$res = $f(intval($id), $entite, $args ?: '', $ancre ?: '', $connect);
1890
-	}
1891
-	if ($res) {
1892
-		return $res;
1893
-	}
1894
-
1895
-	// On a ete gentil mais la ....
1896
-	spip_log("generer_objet_url: entite $entite ($f) inconnue $type $public $connect", _LOG_ERREUR);
1897
-
1898
-	return '';
1857
+    if ($public === null) {
1858
+        $public = !test_espace_prive();
1859
+    }
1860
+    $id = intval($id);
1861
+    $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
1862
+
1863
+    if (!$public) {
1864
+        if (!$entite) {
1865
+            return '';
1866
+        }
1867
+        if (!function_exists('generer_objet_url_ecrire')) {
1868
+            include_spip('inc/urls');
1869
+        }
1870
+        $res = generer_objet_url_ecrire($id, $entite, $args, $ancre, false, $connect);
1871
+    } else {
1872
+        $f = charger_fonction_url('objet', $type ?? '');
1873
+
1874
+        // @deprecated si $entite='', on veut la fonction de passage URL ==> id
1875
+        // @see charger_fonction_url
1876
+        if (!$entite) {
1877
+            return $f;
1878
+        }
1879
+
1880
+        // mais d'abord il faut tester le cas des urls sur une
1881
+        // base distante
1882
+        if ($connect
1883
+            and $g = charger_fonction('connect', 'urls', true)
1884
+        ) {
1885
+            $f = $g;
1886
+        }
1887
+
1888
+        $res = $f(intval($id), $entite, $args ?: '', $ancre ?: '', $connect);
1889
+    }
1890
+    if ($res) {
1891
+        return $res;
1892
+    }
1893
+
1894
+    // On a ete gentil mais la ....
1895
+    spip_log("generer_objet_url: entite $entite ($f) inconnue $type $public $connect", _LOG_ERREUR);
1896
+
1897
+    return '';
1899 1898
 }
1900 1899
 
1901 1900
 /**
@@ -1903,10 +1902,10 @@  discard block
 block discarded – undo
1903 1902
  * @see generer_objet_url
1904 1903
  */
1905 1904
 function generer_url_entite($id = 0, $entite = '', $args = '', $ancre = '', $public = null, $type = null){
1906
-	if ($public and is_string($public)) {
1907
-		return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', true, $type ?? '', $public);
1908
-	}
1909
-	return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', $public, $type ?? '');
1905
+    if ($public and is_string($public)) {
1906
+        return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', true, $type ?? '', $public);
1907
+    }
1908
+    return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', $public, $type ?? '');
1910 1909
 }
1911 1910
 
1912 1911
 /**
@@ -1918,19 +1917,19 @@  discard block
 block discarded – undo
1918 1917
  * @return string
1919 1918
  */
1920 1919
 function generer_objet_url_ecrire_edit($id, string $entite, string $args = '', string $ancre = ''): string {
1921
-	$id = intval($id);
1922
-	$exec = objet_info($entite, 'url_edit');
1923
-	$url = generer_url_ecrire($exec, $args);
1924
-	if (intval($id)) {
1925
-		$url = parametre_url($url, id_table_objet($entite), $id);
1926
-	} else {
1927
-		$url = parametre_url($url, 'new', 'oui');
1928
-	}
1929
-	if ($ancre) {
1930
-		$url = ancre_url($url, $ancre);
1931
-	}
1920
+    $id = intval($id);
1921
+    $exec = objet_info($entite, 'url_edit');
1922
+    $url = generer_url_ecrire($exec, $args);
1923
+    if (intval($id)) {
1924
+        $url = parametre_url($url, id_table_objet($entite), $id);
1925
+    } else {
1926
+        $url = parametre_url($url, 'new', 'oui');
1927
+    }
1928
+    if ($ancre) {
1929
+        $url = ancre_url($url, $ancre);
1930
+    }
1932 1931
 
1933
-	return $url;
1932
+    return $url;
1934 1933
 }
1935 1934
 
1936 1935
 /**
@@ -1938,18 +1937,18 @@  discard block
 block discarded – undo
1938 1937
  * @see generer_objet_url_ecrire_edit
1939 1938
  */
1940 1939
 function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = ''){
1941
-	return generer_objet_url_ecrire_edit(intval($id), $entite, $args, $ancre);
1940
+    return generer_objet_url_ecrire_edit(intval($id), $entite, $args, $ancre);
1942 1941
 }
1943 1942
 
1944 1943
 
1945 1944
 function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) {
1946
-	include_spip('base/connect_sql');
1947
-	$id_type = id_table_objet($entite, $public);
1945
+    include_spip('base/connect_sql');
1946
+    $id_type = id_table_objet($entite, $public);
1948 1947
 
1949
-	return _DIR_RACINE . get_spip_script('./')
1950
-	. '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1951
-	. (!$args ? '' : "&$args")
1952
-	. (!$ancre ? '' : "#$ancre");
1948
+    return _DIR_RACINE . get_spip_script('./')
1949
+    . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1950
+    . (!$args ? '' : "&$args")
1951
+    . (!$ancre ? '' : "#$ancre");
1953 1952
 }
1954 1953
 
1955 1954
 
@@ -1960,18 +1959,18 @@  discard block
 block discarded – undo
1960 1959
  * @return string
1961 1960
  */
1962 1961
 function urlencode_1738($url) {
1963
-	if (preg_match(',[^\x00-\x7E],sS', $url)) {
1964
-		$uri = '';
1965
-		for ($i = 0; $i < strlen($url); $i++) {
1966
-			if (ord($a = $url[$i]) > 127) {
1967
-				$a = rawurlencode($a);
1968
-			}
1969
-			$uri .= $a;
1970
-		}
1971
-		$url = $uri;
1972
-	}
1962
+    if (preg_match(',[^\x00-\x7E],sS', $url)) {
1963
+        $uri = '';
1964
+        for ($i = 0; $i < strlen($url); $i++) {
1965
+            if (ord($a = $url[$i]) > 127) {
1966
+                $a = rawurlencode($a);
1967
+            }
1968
+            $uri .= $a;
1969
+        }
1970
+        $url = $uri;
1971
+    }
1973 1972
 
1974
-	return quote_amp($url);
1973
+    return quote_amp($url);
1975 1974
 }
1976 1975
 
1977 1976
 /**
@@ -1987,14 +1986,14 @@  discard block
 block discarded – undo
1987 1986
  * @return string
1988 1987
  */
1989 1988
 function generer_objet_url_absolue($id = 0, string $entite = '', string $args = '', string $ancre = '', ?bool $public = null, string $type = '', string $connect = ''): string {
1990
-	$id = intval($id);
1991
-	$h = generer_objet_url($id, $entite, $args, $ancre, $public, $type, $connect);
1992
-	if (!preg_match(',^\w+:,', $h)) {
1993
-		include_spip('inc/filtres_mini');
1994
-		$h = url_absolue($h);
1995
-	}
1989
+    $id = intval($id);
1990
+    $h = generer_objet_url($id, $entite, $args, $ancre, $public, $type, $connect);
1991
+    if (!preg_match(',^\w+:,', $h)) {
1992
+        include_spip('inc/filtres_mini');
1993
+        $h = url_absolue($h);
1994
+    }
1996 1995
 
1997
-	return $h;
1996
+    return $h;
1998 1997
 }
1999 1998
 
2000 1999
 /**
@@ -2002,7 +2001,7 @@  discard block
 block discarded – undo
2002 2001
  * @see  generer_objet_url_absolue
2003 2002
  */
2004 2003
 function generer_url_entite_absolue($id = 0, $entite = '', $args = '', $ancre = '', $connect = null){
2005
-	return generer_objet_url_absolue(intval($id), $entite, $args, $ancre, true, '', $connect);
2004
+    return generer_objet_url_absolue(intval($id), $entite, $args, $ancre, true, '', $connect);
2006 2005
 }
2007 2006
 
2008 2007
 
@@ -2018,11 +2017,11 @@  discard block
 block discarded – undo
2018 2017
  *     true si la valeur est considérée active ; false sinon.
2019 2018
  **/
2020 2019
 function test_valeur_serveur($truc) {
2021
-	if (!$truc) {
2022
-		return false;
2023
-	}
2020
+    if (!$truc) {
2021
+        return false;
2022
+    }
2024 2023
 
2025
-	return (strtolower($truc) !== 'off');
2024
+    return (strtolower($truc) !== 'off');
2026 2025
 }
2027 2026
 
2028 2027
 //
@@ -2050,82 +2049,82 @@  discard block
 block discarded – undo
2050 2049
  */
2051 2050
 function url_de_base($profondeur = null) {
2052 2051
 
2053
-	static $url = [];
2054
-	if (is_array($profondeur)) {
2055
-		return $url = $profondeur;
2056
-	}
2057
-	if ($profondeur === false) {
2058
-		return $url;
2059
-	}
2060
-
2061
-	if (is_null($profondeur)) {
2062
-		$profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1);
2063
-	}
2064
-
2065
-	if (isset($url[$profondeur])) {
2066
-		return $url[$profondeur];
2067
-	}
2068
-
2069
-	$http = 'http';
2070
-
2071
-	if (
2072
-		isset($_SERVER['SCRIPT_URI'])
2073
-		and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https'
2074
-	) {
2075
-		$http = 'https';
2076
-	} elseif (
2077
-		isset($_SERVER['HTTPS'])
2078
-		and test_valeur_serveur($_SERVER['HTTPS'])
2079
-	) {
2080
-		$http = 'https';
2081
-	}
2082
-
2083
-	// note : HTTP_HOST contient le :port si necessaire
2084
-	$host = $_SERVER['HTTP_HOST'] ?? null;
2085
-	// si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback
2086
-	if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) {
2087
-		$host = $GLOBALS['meta']['adresse_site'];
2088
-		if ($scheme = parse_url($host, PHP_URL_SCHEME)) {
2089
-			$http = $scheme;
2090
-			$host = str_replace("{$scheme}://", '', $host);
2091
-		}
2092
-	}
2093
-	if (
2094
-		isset($_SERVER['SERVER_PORT'])
2095
-		and $port = $_SERVER['SERVER_PORT']
2096
-		and strpos($host, ':') == false
2097
-	) {
2098
-		if (!defined('_PORT_HTTP_STANDARD')) {
2099
-			define('_PORT_HTTP_STANDARD', '80');
2100
-		}
2101
-		if (!defined('_PORT_HTTPS_STANDARD')) {
2102
-			define('_PORT_HTTPS_STANDARD', '443');
2103
-		}
2104
-		if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) {
2105
-			$host .= ":$port";
2106
-		}
2107
-		if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) {
2108
-			$host .= ":$port";
2109
-		}
2110
-	}
2111
-
2112
-	if (!$GLOBALS['REQUEST_URI']) {
2113
-		if (isset($_SERVER['REQUEST_URI'])) {
2114
-			$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2115
-		} else {
2116
-			$GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2117
-			if (
2118
-				!empty($_SERVER['QUERY_STRING'])
2119
-				and !strpos($_SERVER['REQUEST_URI'], '?')
2120
-			) {
2121
-				$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2122
-			}
2123
-		}
2124
-	}
2125
-
2126
-	$url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
2127
-
2128
-	return $url[$profondeur];
2052
+    static $url = [];
2053
+    if (is_array($profondeur)) {
2054
+        return $url = $profondeur;
2055
+    }
2056
+    if ($profondeur === false) {
2057
+        return $url;
2058
+    }
2059
+
2060
+    if (is_null($profondeur)) {
2061
+        $profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1);
2062
+    }
2063
+
2064
+    if (isset($url[$profondeur])) {
2065
+        return $url[$profondeur];
2066
+    }
2067
+
2068
+    $http = 'http';
2069
+
2070
+    if (
2071
+        isset($_SERVER['SCRIPT_URI'])
2072
+        and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https'
2073
+    ) {
2074
+        $http = 'https';
2075
+    } elseif (
2076
+        isset($_SERVER['HTTPS'])
2077
+        and test_valeur_serveur($_SERVER['HTTPS'])
2078
+    ) {
2079
+        $http = 'https';
2080
+    }
2081
+
2082
+    // note : HTTP_HOST contient le :port si necessaire
2083
+    $host = $_SERVER['HTTP_HOST'] ?? null;
2084
+    // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback
2085
+    if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) {
2086
+        $host = $GLOBALS['meta']['adresse_site'];
2087
+        if ($scheme = parse_url($host, PHP_URL_SCHEME)) {
2088
+            $http = $scheme;
2089
+            $host = str_replace("{$scheme}://", '', $host);
2090
+        }
2091
+    }
2092
+    if (
2093
+        isset($_SERVER['SERVER_PORT'])
2094
+        and $port = $_SERVER['SERVER_PORT']
2095
+        and strpos($host, ':') == false
2096
+    ) {
2097
+        if (!defined('_PORT_HTTP_STANDARD')) {
2098
+            define('_PORT_HTTP_STANDARD', '80');
2099
+        }
2100
+        if (!defined('_PORT_HTTPS_STANDARD')) {
2101
+            define('_PORT_HTTPS_STANDARD', '443');
2102
+        }
2103
+        if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) {
2104
+            $host .= ":$port";
2105
+        }
2106
+        if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) {
2107
+            $host .= ":$port";
2108
+        }
2109
+    }
2110
+
2111
+    if (!$GLOBALS['REQUEST_URI']) {
2112
+        if (isset($_SERVER['REQUEST_URI'])) {
2113
+            $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2114
+        } else {
2115
+            $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2116
+            if (
2117
+                !empty($_SERVER['QUERY_STRING'])
2118
+                and !strpos($_SERVER['REQUEST_URI'], '?')
2119
+            ) {
2120
+                $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2121
+            }
2122
+        }
2123
+    }
2124
+
2125
+    $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
2126
+
2127
+    return $url[$profondeur];
2129 2128
 }
2130 2129
 
2131 2130
 /**
@@ -2138,26 +2137,26 @@  discard block
 block discarded – undo
2138 2137
  * @return string
2139 2138
  */
2140 2139
 function url_de_($http, $host, $request, $prof = 0) {
2141
-	$prof = max($prof, 0);
2140
+    $prof = max($prof, 0);
2142 2141
 
2143
-	$myself = ltrim($request, '/');
2144
-	# supprimer la chaine de GET
2145
-	[$myself] = explode('?', $myself);
2146
-	// vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
2147
-	// protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
2148
-	if (strpos($myself, '://') !== false) {
2149
-		$myself = explode('://', $myself);
2150
-		array_shift($myself);
2151
-		$myself = implode('://', $myself);
2152
-		$myself = explode('/', $myself);
2153
-		array_shift($myself);
2154
-		$myself = implode('/', $myself);
2155
-	}
2156
-	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2142
+    $myself = ltrim($request, '/');
2143
+    # supprimer la chaine de GET
2144
+    [$myself] = explode('?', $myself);
2145
+    // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
2146
+    // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
2147
+    if (strpos($myself, '://') !== false) {
2148
+        $myself = explode('://', $myself);
2149
+        array_shift($myself);
2150
+        $myself = implode('://', $myself);
2151
+        $myself = explode('/', $myself);
2152
+        array_shift($myself);
2153
+        $myself = implode('/', $myself);
2154
+    }
2155
+    $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2157 2156
 
2158
-	$url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2157
+    $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2159 2158
 
2160
-	return $url;
2159
+    return $url;
2161 2160
 }
2162 2161
 
2163 2162
 
@@ -2192,25 +2191,25 @@  discard block
 block discarded – undo
2192 2191
  * @return string URL
2193 2192
  **/
2194 2193
 function generer_url_ecrire($script = '', $args = '', $no_entities = false, $rel = false) {
2195
-	if (!$rel) {
2196
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2197
-	} else {
2198
-		if (!is_string($rel)) {
2199
-			$rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT;
2200
-		}
2201
-	}
2202
-
2203
-	[$script, $ancre] = array_pad(explode('#', $script), 2, null);
2204
-	if ($script and ($script <> 'accueil' or $rel)) {
2205
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
2206
-	} elseif ($args) {
2207
-		$args = "?$args";
2208
-	}
2209
-	if ($ancre) {
2210
-		$args .= "#$ancre";
2211
-	}
2212
-
2213
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2194
+    if (!$rel) {
2195
+        $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2196
+    } else {
2197
+        if (!is_string($rel)) {
2198
+            $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT;
2199
+        }
2200
+    }
2201
+
2202
+    [$script, $ancre] = array_pad(explode('#', $script), 2, null);
2203
+    if ($script and ($script <> 'accueil' or $rel)) {
2204
+        $args = "?exec=$script" . (!$args ? '' : "&$args");
2205
+    } elseif ($args) {
2206
+        $args = "?$args";
2207
+    }
2208
+    if ($ancre) {
2209
+        $args .= "#$ancre";
2210
+    }
2211
+
2212
+    return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2214 2213
 }
2215 2214
 
2216 2215
 //
@@ -2232,15 +2231,15 @@  discard block
 block discarded – undo
2232 2231
  *     Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut
2233 2232
  **/
2234 2233
 function get_spip_script($default = '') {
2235
-	if (!defined('_SPIP_SCRIPT')) {
2236
-		return 'spip.php';
2237
-	}
2238
-	# cas define('_SPIP_SCRIPT', '');
2239
-	if (_SPIP_SCRIPT) {
2240
-		return _SPIP_SCRIPT;
2241
-	} else {
2242
-		return $default;
2243
-	}
2234
+    if (!defined('_SPIP_SCRIPT')) {
2235
+        return 'spip.php';
2236
+    }
2237
+    # cas define('_SPIP_SCRIPT', '');
2238
+    if (_SPIP_SCRIPT) {
2239
+        return _SPIP_SCRIPT;
2240
+    } else {
2241
+        return $default;
2242
+    }
2244 2243
 }
2245 2244
 
2246 2245
 /**
@@ -2269,45 +2268,45 @@  discard block
 block discarded – undo
2269 2268
  * @return string URL
2270 2269
  **/
2271 2270
 function generer_url_public($script = '', $args = '', $no_entities = false, $rel = true, $action = '') {
2272
-	// si le script est une action (spip_pass, spip_inscription),
2273
-	// standardiser vers la nouvelle API
2274
-
2275
-	if (is_array($args)) {
2276
-		$args = http_build_query($args);
2277
-	}
2278
-
2279
-	$url = '';
2280
-	if ($f = charger_fonction_url('page')) {
2281
-		$url = $f($script, $args);
2282
-		if ($url and !$rel) {
2283
-			include_spip('inc/filtres_mini');
2284
-			$url = url_absolue($url);
2285
-		}
2286
-	}
2287
-	if (!$url) {
2288
-		if (!$action) {
2289
-			$action = get_spip_script();
2290
-		}
2291
-		if ($script) {
2292
-			$action = parametre_url($action, _SPIP_PAGE, $script, '&');
2293
-		}
2294
-		if ($args) {
2295
-			$action .= (strpos($action, '?') !== false ? '&' : '?') . $args;
2296
-		}
2297
-		// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2298
-		$url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
2299
-	}
2300
-
2301
-	if (!$no_entities) {
2302
-		$url = quote_amp($url);
2303
-	}
2304
-
2305
-	return $url;
2271
+    // si le script est une action (spip_pass, spip_inscription),
2272
+    // standardiser vers la nouvelle API
2273
+
2274
+    if (is_array($args)) {
2275
+        $args = http_build_query($args);
2276
+    }
2277
+
2278
+    $url = '';
2279
+    if ($f = charger_fonction_url('page')) {
2280
+        $url = $f($script, $args);
2281
+        if ($url and !$rel) {
2282
+            include_spip('inc/filtres_mini');
2283
+            $url = url_absolue($url);
2284
+        }
2285
+    }
2286
+    if (!$url) {
2287
+        if (!$action) {
2288
+            $action = get_spip_script();
2289
+        }
2290
+        if ($script) {
2291
+            $action = parametre_url($action, _SPIP_PAGE, $script, '&');
2292
+        }
2293
+        if ($args) {
2294
+            $action .= (strpos($action, '?') !== false ? '&' : '?') . $args;
2295
+        }
2296
+        // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2297
+        $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
2298
+    }
2299
+
2300
+    if (!$no_entities) {
2301
+        $url = quote_amp($url);
2302
+    }
2303
+
2304
+    return $url;
2306 2305
 }
2307 2306
 
2308 2307
 function generer_url_prive($script, $args = '', $no_entities = false) {
2309 2308
 
2310
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2309
+    return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2311 2310
 }
2312 2311
 
2313 2312
 // Pour les formulaires en methode POST,
@@ -2332,19 +2331,19 @@  discard block
 block discarded – undo
2332 2331
  **/
2333 2332
 function generer_form_ecrire($script, $corps, $atts = '', $submit = '') {
2334 2333
 
2335
-	$script1 = explode('&', $script);
2336
-	$script1 = reset($script1);
2334
+    $script1 = explode('&', $script);
2335
+    $script1 = reset($script1);
2337 2336
 
2338
-	return "<form action='"
2339
-	. ($script ? generer_url_ecrire($script) : '')
2340
-	. "' "
2341
-	. ($atts ?: " method='post'")
2342
-	. "><div>\n"
2343
-	. "<input type='hidden' name='exec' value='$script1' />"
2344
-	. $corps
2345
-	. (!$submit ? '' :
2346
-		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
2347
-	. "</div></form>\n";
2337
+    return "<form action='"
2338
+    . ($script ? generer_url_ecrire($script) : '')
2339
+    . "' "
2340
+    . ($atts ?: " method='post'")
2341
+    . "><div>\n"
2342
+    . "<input type='hidden' name='exec' value='$script1' />"
2343
+    . $corps
2344
+    . (!$submit ? '' :
2345
+        ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
2346
+    . "</div></form>\n";
2348 2347
 }
2349 2348
 
2350 2349
 /**
@@ -2361,22 +2360,22 @@  discard block
 block discarded – undo
2361 2360
  * @return string
2362 2361
  */
2363 2362
 function generer_form_action($script, $corps, $atts = '', $public = false) {
2364
-	// si l'on est dans l'espace prive, on garde dans l'url
2365
-	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2366
-	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
2367
-	$h = (_DIR_RACINE and !$public)
2368
-		? generer_url_ecrire(_request('exec'))
2369
-		: generer_url_public();
2363
+    // si l'on est dans l'espace prive, on garde dans l'url
2364
+    // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2365
+    // ou non de proceder a l'authentification (cas typique de l'install par exemple)
2366
+    $h = (_DIR_RACINE and !$public)
2367
+        ? generer_url_ecrire(_request('exec'))
2368
+        : generer_url_public();
2370 2369
 
2371
-	return "\n<form action='" .
2372
-	$h .
2373
-	"'" .
2374
-	$atts .
2375
-	">\n" .
2376
-	'<div>' .
2377
-	"\n<input type='hidden' name='action' value='$script' />" .
2378
-	$corps .
2379
-	'</div></form>';
2370
+    return "\n<form action='" .
2371
+    $h .
2372
+    "'" .
2373
+    $atts .
2374
+    ">\n" .
2375
+    '<div>' .
2376
+    "\n<input type='hidden' name='action' value='$script' />" .
2377
+    $corps .
2378
+    '</div></form>';
2380 2379
 }
2381 2380
 
2382 2381
 /**
@@ -2395,22 +2394,22 @@  discard block
 block discarded – undo
2395 2394
  *     URL
2396 2395
  */
2397 2396
 function generer_url_action($script, $args = '', $no_entities = false, $public = false) {
2398
-	// si l'on est dans l'espace prive, on garde dans l'url
2399
-	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2400
-	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
2401
-	$url = (_DIR_RACINE and !$public)
2402
-		? generer_url_ecrire(_request('exec'))
2403
-		: generer_url_public('', '', false, false);
2404
-	$url = parametre_url($url, 'action', $script);
2405
-	if ($args) {
2406
-		$url .= quote_amp('&' . $args);
2407
-	}
2397
+    // si l'on est dans l'espace prive, on garde dans l'url
2398
+    // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2399
+    // ou non de proceder a l'authentification (cas typique de l'install par exemple)
2400
+    $url = (_DIR_RACINE and !$public)
2401
+        ? generer_url_ecrire(_request('exec'))
2402
+        : generer_url_public('', '', false, false);
2403
+    $url = parametre_url($url, 'action', $script);
2404
+    if ($args) {
2405
+        $url .= quote_amp('&' . $args);
2406
+    }
2408 2407
 
2409
-	if ($no_entities) {
2410
-		$url = str_replace('&amp;', '&', $url);
2411
-	}
2408
+    if ($no_entities) {
2409
+        $url = str_replace('&amp;', '&', $url);
2410
+    }
2412 2411
 
2413
-	return $url;
2412
+    return $url;
2414 2413
 }
2415 2414
 
2416 2415
 
@@ -2429,23 +2428,23 @@  discard block
 block discarded – undo
2429 2428
  *     URL
2430 2429
  */
2431 2430
 function generer_url_api(string $script, string $path, string $args, bool $no_entities = false, ?bool $public = null) {
2432
-	if (is_null($public)) {
2433
-		$public = (_DIR_RACINE ? false : '');
2434
-	}
2435
-	if (substr($script, -4) !== '.api') {
2436
-		$script .= '.api';
2437
-	}
2438
-	$url =
2439
-		(($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './')
2440
-	. $script . '/'
2441
-	. ($path ? trim($path, '/') : '')
2442
-	. ($args ? "?" . quote_amp($args) : '');
2431
+    if (is_null($public)) {
2432
+        $public = (_DIR_RACINE ? false : '');
2433
+    }
2434
+    if (substr($script, -4) !== '.api') {
2435
+        $script .= '.api';
2436
+    }
2437
+    $url =
2438
+        (($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './')
2439
+    . $script . '/'
2440
+    . ($path ? trim($path, '/') : '')
2441
+    . ($args ? "?" . quote_amp($args) : '');
2443 2442
 
2444
-	if ($no_entities) {
2445
-		$url = str_replace('&amp;', '&', $url);
2446
-	}
2443
+    if ($no_entities) {
2444
+        $url = str_replace('&amp;', '&', $url);
2445
+    }
2447 2446
 
2448
-	return $url;
2447
+    return $url;
2449 2448
 }
2450 2449
 
2451 2450
 
@@ -2458,8 +2457,8 @@  discard block
 block discarded – undo
2458 2457
  * @param string $ta Répertoire temporaire accessible
2459 2458
  */
2460 2459
 function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) {
2461
-	spip_initialisation_core($pi, $pa, $ti, $ta);
2462
-	spip_initialisation_suite();
2460
+    spip_initialisation_core($pi, $pa, $ti, $ta);
2461
+    spip_initialisation_suite();
2463 2462
 }
2464 2463
 
2465 2464
 /**
@@ -2479,322 +2478,322 @@  discard block
 block discarded – undo
2479 2478
  * @param string $ta Répertoire temporaire accessible
2480 2479
  */
2481 2480
 function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) {
2482
-	static $too_late = 0;
2483
-	if ($too_late++) {
2484
-		return;
2485
-	}
2486
-
2487
-	// Declaration des repertoires
2488
-
2489
-	// le nom du repertoire plugins/ activables/desactivables
2490
-	if (!defined('_DIR_PLUGINS')) {
2491
-		define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
2492
-	}
2493
-
2494
-	// le nom du repertoire des extensions/ permanentes du core, toujours actives
2495
-	if (!defined('_DIR_PLUGINS_DIST')) {
2496
-		define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
2497
-	}
2498
-
2499
-	// le nom du repertoire des librairies
2500
-	if (!defined('_DIR_LIB')) {
2501
-		define('_DIR_LIB', _DIR_RACINE . 'lib/');
2502
-	}
2503
-
2504
-	if (!defined('_DIR_IMG')) {
2505
-		define('_DIR_IMG', $pa);
2506
-	}
2507
-	if (!defined('_DIR_LOGOS')) {
2508
-		define('_DIR_LOGOS', $pa);
2509
-	}
2510
-	if (!defined('_DIR_IMG_ICONES')) {
2511
-		define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
2512
-	}
2513
-
2514
-	if (!defined('_DIR_DUMP')) {
2515
-		define('_DIR_DUMP', $ti . 'dump/');
2516
-	}
2517
-	if (!defined('_DIR_SESSIONS')) {
2518
-		define('_DIR_SESSIONS', $ti . 'sessions/');
2519
-	}
2520
-	if (!defined('_DIR_TRANSFERT')) {
2521
-		define('_DIR_TRANSFERT', $ti . 'upload/');
2522
-	}
2523
-	if (!defined('_DIR_CACHE')) {
2524
-		define('_DIR_CACHE', $ti . 'cache/');
2525
-	}
2526
-	if (!defined('_DIR_CACHE_XML')) {
2527
-		define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
2528
-	}
2529
-	if (!defined('_DIR_SKELS')) {
2530
-		define('_DIR_SKELS', _DIR_CACHE . 'skel/');
2531
-	}
2532
-	if (!defined('_DIR_AIDE')) {
2533
-		define('_DIR_AIDE', _DIR_CACHE . 'aide/');
2534
-	}
2535
-	if (!defined('_DIR_TMP')) {
2536
-		define('_DIR_TMP', $ti);
2537
-	}
2538
-
2539
-	if (!defined('_DIR_VAR')) {
2540
-		define('_DIR_VAR', $ta);
2541
-	}
2542
-
2543
-	if (!defined('_DIR_ETC')) {
2544
-		define('_DIR_ETC', $pi);
2545
-	}
2546
-	if (!defined('_DIR_CONNECT')) {
2547
-		define('_DIR_CONNECT', $pi);
2548
-	}
2549
-	if (!defined('_DIR_CHMOD')) {
2550
-		define('_DIR_CHMOD', $pi);
2551
-	}
2552
-
2553
-	if (!isset($GLOBALS['test_dirs'])) {
2554
-		// Pas $pi car il est bon de le mettre hors ecriture apres intstall
2555
-		// il sera rajoute automatiquement si besoin a l'etape 2 de l'install
2556
-	$GLOBALS['test_dirs'] = [$pa, $ti, $ta];
2557
-	}
2558
-
2559
-	// Declaration des fichiers
2560
-
2561
-	if (!defined('_CACHE_PLUGINS_PATH')) {
2562
-		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
2563
-	}
2564
-	if (!defined('_CACHE_PLUGINS_OPT')) {
2565
-		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
2566
-	}
2567
-	if (!defined('_CACHE_PLUGINS_FCT')) {
2568
-		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
2569
-	}
2570
-	if (!defined('_CACHE_PIPELINES')) {
2571
-		define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
2572
-	}
2573
-	if (!defined('_CACHE_CHEMIN')) {
2574
-		define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
2575
-	}
2576
-
2577
-	# attention .php obligatoire pour ecrire_fichier_securise
2578
-	if (!defined('_FILE_META')) {
2579
-		define('_FILE_META', $ti . 'meta_cache.php');
2580
-	}
2581
-	if (!defined('_DIR_LOG')) {
2582
-		define('_DIR_LOG', _DIR_TMP . 'log/');
2583
-	}
2584
-	if (!defined('_FILE_LOG')) {
2585
-		define('_FILE_LOG', 'spip');
2586
-	}
2587
-	if (!defined('_FILE_LOG_SUFFIX')) {
2588
-		define('_FILE_LOG_SUFFIX', '.log');
2589
-	}
2590
-
2591
-	// Le fichier de connexion a la base de donnees
2592
-	// tient compte des anciennes versions (inc_connect...)
2593
-	if (!defined('_FILE_CONNECT_INS')) {
2594
-		define('_FILE_CONNECT_INS', 'connect');
2595
-	}
2596
-	if (!defined('_FILE_CONNECT')) {
2597
-		define(
2598
-			'_FILE_CONNECT',
2599
-			(@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2600
-			: (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2601
-			: false))
2602
-		);
2603
-	}
2604
-
2605
-	// Le fichier de reglages des droits
2606
-	if (!defined('_FILE_CHMOD_INS')) {
2607
-		define('_FILE_CHMOD_INS', 'chmod');
2608
-	}
2609
-	if (!defined('_FILE_CHMOD')) {
2610
-		define(
2611
-			'_FILE_CHMOD',
2612
-			(@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2613
-			: false)
2614
-		);
2615
-	}
2616
-
2617
-	if (!defined('_FILE_LDAP')) {
2618
-		define('_FILE_LDAP', 'ldap.php');
2619
-	}
2620
-
2621
-	if (!defined('_FILE_TMP_SUFFIX')) {
2622
-		define('_FILE_TMP_SUFFIX', '.tmp.php');
2623
-	}
2624
-	if (!defined('_FILE_CONNECT_TMP')) {
2625
-		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2626
-	}
2627
-	if (!defined('_FILE_CHMOD_TMP')) {
2628
-		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2629
-	}
2630
-
2631
-	// Definition des droits d'acces en ecriture
2632
-	if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) {
2633
-		include_once _FILE_CHMOD;
2634
-	}
2635
-
2636
-	// Se mefier des fichiers mal remplis!
2637
-	if (!defined('_SPIP_CHMOD')) {
2638
-		define('_SPIP_CHMOD', 0777);
2639
-	}
2640
-
2641
-	if (!defined('_DEFAULT_CHARSET')) {
2642
-		/** Le charset par défaut lors de l'installation */
2643
-		define('_DEFAULT_CHARSET', 'utf-8');
2644
-	}
2645
-	if (!defined('_ROOT_PLUGINS')) {
2646
-		define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/');
2647
-	}
2648
-	if (!defined('_ROOT_PLUGINS_DIST')) {
2649
-		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/');
2650
-	}
2651
-	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2652
-		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2653
-	}
2654
-
2655
-	// La taille des Log
2656
-	if (!defined('_MAX_LOG')) {
2657
-		define('_MAX_LOG', 100);
2658
-	}
2659
-
2660
-	// Sommes-nous dans l'empire du Mal ?
2661
-	// (ou sous le signe du Pingouin, ascendant GNU ?)
2662
-	if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) {
2663
-		if (!defined('_OS_SERVEUR')) {
2664
-			define('_OS_SERVEUR', 'windows');
2665
-		}
2666
-		if (!defined('_SPIP_LOCK_MODE')) {
2667
-			define('_SPIP_LOCK_MODE', 1);
2668
-		} // utiliser le flock php
2669
-	} else {
2670
-		if (!defined('_OS_SERVEUR')) {
2671
-			define('_OS_SERVEUR', '');
2672
-		}
2673
-		if (!defined('_SPIP_LOCK_MODE')) {
2674
-			define('_SPIP_LOCK_MODE', 1);
2675
-		} // utiliser le flock php
2676
-		#if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
2677
-	}
2678
-
2679
-	// Langue par defaut
2680
-	if (!defined('_LANGUE_PAR_DEFAUT')) {
2681
-		define('_LANGUE_PAR_DEFAUT', 'fr');
2682
-	}
2683
-
2684
-	//
2685
-	// Module de lecture/ecriture/suppression de fichiers utilisant flock()
2686
-	// (non surchargeable en l'etat ; attention si on utilise include_spip()
2687
-	// pour le rendre surchargeable, on va provoquer un reecriture
2688
-	// systematique du noyau ou une baisse de perfs => a etudier)
2689
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
2690
-
2691
-	// charger tout de suite le path et son cache
2692
-	load_path_cache();
2693
-
2694
-	// *********** traiter les variables ************
2695
-
2696
-	//
2697
-	// Securite
2698
-	//
2699
-
2700
-	// Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
2701
-	if (isset($_REQUEST['GLOBALS'])) {
2702
-		die();
2703
-	}
2704
-	// nettoyer les magic quotes \' et les caracteres nuls %00
2705
-	spip_desinfecte($_GET);
2706
-	spip_desinfecte($_POST);
2707
-	spip_desinfecte($_COOKIE);
2708
-	spip_desinfecte($_REQUEST);
2709
-
2710
-	// appliquer le cookie_prefix
2711
-	if ($GLOBALS['cookie_prefix'] != 'spip') {
2712
-		include_spip('inc/cookie');
2713
-		recuperer_cookies_spip($GLOBALS['cookie_prefix']);
2714
-	}
2715
-
2716
-	//
2717
-	// Capacites php (en fonction de la version)
2718
-	//
2719
-	$GLOBALS['flag_ob'] = (function_exists('ob_start')
2720
-		&& function_exists('ini_get')
2721
-		&& !strstr(@ini_get('disable_functions'), 'ob_'));
2722
-	$GLOBALS['flag_sapi_name'] = function_exists('php_sapi_name');
2723
-	$GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != '');
2724
-	$GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] ||
2725
-		(get_cfg_var('upload_max_filesize') > 0));
2726
-
2727
-
2728
-	// Compatibilite avec serveurs ne fournissant pas $REQUEST_URI
2729
-	if (isset($_SERVER['REQUEST_URI'])) {
2730
-		$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2731
-	} else {
2732
-		$GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2733
-		if (
2734
-			!empty($_SERVER['QUERY_STRING'])
2735
-			and !strpos($_SERVER['REQUEST_URI'], '?')
2736
-		) {
2737
-			$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2738
-		}
2739
-	}
2740
-
2741
-	// Duree de validite de l'alea pour les cookies et ce qui s'ensuit.
2742
-	if (!defined('_RENOUVELLE_ALEA')) {
2743
-		define('_RENOUVELLE_ALEA', 12 * 3600);
2744
-	}
2745
-	if (!defined('_DUREE_COOKIE_ADMIN')) {
2746
-		define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600);
2747
-	}
2748
-
2749
-	// charger les meta si possible et renouveller l'alea au besoin
2750
-	// charge aussi effacer_meta et ecrire_meta
2751
-	$inc_meta = charger_fonction('meta', 'inc');
2752
-	$inc_meta();
2753
-
2754
-	// nombre de repertoires depuis la racine
2755
-	// on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
2756
-	// ou a defaut celle donnee en meta ; (mais si celle-ci est fausse
2757
-	// le calcul est faux)
2758
-	if (!_DIR_RESTREINT) {
2759
-		$GLOBALS['profondeur_url'] = 1;
2760
-	} else {
2761
-		$uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : '';
2762
-		$uri_ref = $_SERVER['SCRIPT_NAME'];
2763
-		if (
2764
-			!$uri_ref
2765
-			// si on est appele avec un autre ti, on est sans doute en mutu
2766
-			// si jamais c'est de la mutu avec sous rep, on est perdu si on se fie
2767
-			// a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer
2768
-			// s'en remettre a l'adresse du site. alea jacta est.
2769
-			or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES
2770
-		) {
2771
-			if (isset($GLOBALS['meta']['adresse_site'])) {
2772
-				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2773
-				$uri_ref = ($uri_ref['path'] ?? '') . '/';
2774
-			} else {
2775
-				$uri_ref = '';
2776
-			}
2777
-		}
2778
-		if (!$uri or !$uri_ref) {
2779
-			$GLOBALS['profondeur_url'] = 0;
2780
-		} else {
2781
-			$GLOBALS['profondeur_url'] = max(
2782
-				0,
2783
-				substr_count($uri[0], '/')
2784
-				- substr_count($uri_ref, '/')
2785
-			);
2786
-		}
2787
-	}
2788
-	// s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
2789
-	if (_FILE_CONNECT) {
2790
-		if (
2791
-			verifier_visiteur() == '0minirezo'
2792
-			// si c'est un admin sans cookie admin, il faut ignorer le cache chemin !
2793
-			and !isset($_COOKIE['spip_admin'])
2794
-		) {
2795
-			clear_path_cache();
2796
-		}
2797
-	}
2481
+    static $too_late = 0;
2482
+    if ($too_late++) {
2483
+        return;
2484
+    }
2485
+
2486
+    // Declaration des repertoires
2487
+
2488
+    // le nom du repertoire plugins/ activables/desactivables
2489
+    if (!defined('_DIR_PLUGINS')) {
2490
+        define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
2491
+    }
2492
+
2493
+    // le nom du repertoire des extensions/ permanentes du core, toujours actives
2494
+    if (!defined('_DIR_PLUGINS_DIST')) {
2495
+        define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
2496
+    }
2497
+
2498
+    // le nom du repertoire des librairies
2499
+    if (!defined('_DIR_LIB')) {
2500
+        define('_DIR_LIB', _DIR_RACINE . 'lib/');
2501
+    }
2502
+
2503
+    if (!defined('_DIR_IMG')) {
2504
+        define('_DIR_IMG', $pa);
2505
+    }
2506
+    if (!defined('_DIR_LOGOS')) {
2507
+        define('_DIR_LOGOS', $pa);
2508
+    }
2509
+    if (!defined('_DIR_IMG_ICONES')) {
2510
+        define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
2511
+    }
2512
+
2513
+    if (!defined('_DIR_DUMP')) {
2514
+        define('_DIR_DUMP', $ti . 'dump/');
2515
+    }
2516
+    if (!defined('_DIR_SESSIONS')) {
2517
+        define('_DIR_SESSIONS', $ti . 'sessions/');
2518
+    }
2519
+    if (!defined('_DIR_TRANSFERT')) {
2520
+        define('_DIR_TRANSFERT', $ti . 'upload/');
2521
+    }
2522
+    if (!defined('_DIR_CACHE')) {
2523
+        define('_DIR_CACHE', $ti . 'cache/');
2524
+    }
2525
+    if (!defined('_DIR_CACHE_XML')) {
2526
+        define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
2527
+    }
2528
+    if (!defined('_DIR_SKELS')) {
2529
+        define('_DIR_SKELS', _DIR_CACHE . 'skel/');
2530
+    }
2531
+    if (!defined('_DIR_AIDE')) {
2532
+        define('_DIR_AIDE', _DIR_CACHE . 'aide/');
2533
+    }
2534
+    if (!defined('_DIR_TMP')) {
2535
+        define('_DIR_TMP', $ti);
2536
+    }
2537
+
2538
+    if (!defined('_DIR_VAR')) {
2539
+        define('_DIR_VAR', $ta);
2540
+    }
2541
+
2542
+    if (!defined('_DIR_ETC')) {
2543
+        define('_DIR_ETC', $pi);
2544
+    }
2545
+    if (!defined('_DIR_CONNECT')) {
2546
+        define('_DIR_CONNECT', $pi);
2547
+    }
2548
+    if (!defined('_DIR_CHMOD')) {
2549
+        define('_DIR_CHMOD', $pi);
2550
+    }
2551
+
2552
+    if (!isset($GLOBALS['test_dirs'])) {
2553
+        // Pas $pi car il est bon de le mettre hors ecriture apres intstall
2554
+        // il sera rajoute automatiquement si besoin a l'etape 2 de l'install
2555
+    $GLOBALS['test_dirs'] = [$pa, $ti, $ta];
2556
+    }
2557
+
2558
+    // Declaration des fichiers
2559
+
2560
+    if (!defined('_CACHE_PLUGINS_PATH')) {
2561
+        define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
2562
+    }
2563
+    if (!defined('_CACHE_PLUGINS_OPT')) {
2564
+        define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
2565
+    }
2566
+    if (!defined('_CACHE_PLUGINS_FCT')) {
2567
+        define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
2568
+    }
2569
+    if (!defined('_CACHE_PIPELINES')) {
2570
+        define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
2571
+    }
2572
+    if (!defined('_CACHE_CHEMIN')) {
2573
+        define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
2574
+    }
2575
+
2576
+    # attention .php obligatoire pour ecrire_fichier_securise
2577
+    if (!defined('_FILE_META')) {
2578
+        define('_FILE_META', $ti . 'meta_cache.php');
2579
+    }
2580
+    if (!defined('_DIR_LOG')) {
2581
+        define('_DIR_LOG', _DIR_TMP . 'log/');
2582
+    }
2583
+    if (!defined('_FILE_LOG')) {
2584
+        define('_FILE_LOG', 'spip');
2585
+    }
2586
+    if (!defined('_FILE_LOG_SUFFIX')) {
2587
+        define('_FILE_LOG_SUFFIX', '.log');
2588
+    }
2589
+
2590
+    // Le fichier de connexion a la base de donnees
2591
+    // tient compte des anciennes versions (inc_connect...)
2592
+    if (!defined('_FILE_CONNECT_INS')) {
2593
+        define('_FILE_CONNECT_INS', 'connect');
2594
+    }
2595
+    if (!defined('_FILE_CONNECT')) {
2596
+        define(
2597
+            '_FILE_CONNECT',
2598
+            (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2599
+            : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2600
+            : false))
2601
+        );
2602
+    }
2603
+
2604
+    // Le fichier de reglages des droits
2605
+    if (!defined('_FILE_CHMOD_INS')) {
2606
+        define('_FILE_CHMOD_INS', 'chmod');
2607
+    }
2608
+    if (!defined('_FILE_CHMOD')) {
2609
+        define(
2610
+            '_FILE_CHMOD',
2611
+            (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2612
+            : false)
2613
+        );
2614
+    }
2615
+
2616
+    if (!defined('_FILE_LDAP')) {
2617
+        define('_FILE_LDAP', 'ldap.php');
2618
+    }
2619
+
2620
+    if (!defined('_FILE_TMP_SUFFIX')) {
2621
+        define('_FILE_TMP_SUFFIX', '.tmp.php');
2622
+    }
2623
+    if (!defined('_FILE_CONNECT_TMP')) {
2624
+        define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2625
+    }
2626
+    if (!defined('_FILE_CHMOD_TMP')) {
2627
+        define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2628
+    }
2629
+
2630
+    // Definition des droits d'acces en ecriture
2631
+    if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) {
2632
+        include_once _FILE_CHMOD;
2633
+    }
2634
+
2635
+    // Se mefier des fichiers mal remplis!
2636
+    if (!defined('_SPIP_CHMOD')) {
2637
+        define('_SPIP_CHMOD', 0777);
2638
+    }
2639
+
2640
+    if (!defined('_DEFAULT_CHARSET')) {
2641
+        /** Le charset par défaut lors de l'installation */
2642
+        define('_DEFAULT_CHARSET', 'utf-8');
2643
+    }
2644
+    if (!defined('_ROOT_PLUGINS')) {
2645
+        define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/');
2646
+    }
2647
+    if (!defined('_ROOT_PLUGINS_DIST')) {
2648
+        define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/');
2649
+    }
2650
+    if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2651
+        define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2652
+    }
2653
+
2654
+    // La taille des Log
2655
+    if (!defined('_MAX_LOG')) {
2656
+        define('_MAX_LOG', 100);
2657
+    }
2658
+
2659
+    // Sommes-nous dans l'empire du Mal ?
2660
+    // (ou sous le signe du Pingouin, ascendant GNU ?)
2661
+    if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) {
2662
+        if (!defined('_OS_SERVEUR')) {
2663
+            define('_OS_SERVEUR', 'windows');
2664
+        }
2665
+        if (!defined('_SPIP_LOCK_MODE')) {
2666
+            define('_SPIP_LOCK_MODE', 1);
2667
+        } // utiliser le flock php
2668
+    } else {
2669
+        if (!defined('_OS_SERVEUR')) {
2670
+            define('_OS_SERVEUR', '');
2671
+        }
2672
+        if (!defined('_SPIP_LOCK_MODE')) {
2673
+            define('_SPIP_LOCK_MODE', 1);
2674
+        } // utiliser le flock php
2675
+        #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
2676
+    }
2677
+
2678
+    // Langue par defaut
2679
+    if (!defined('_LANGUE_PAR_DEFAUT')) {
2680
+        define('_LANGUE_PAR_DEFAUT', 'fr');
2681
+    }
2682
+
2683
+    //
2684
+    // Module de lecture/ecriture/suppression de fichiers utilisant flock()
2685
+    // (non surchargeable en l'etat ; attention si on utilise include_spip()
2686
+    // pour le rendre surchargeable, on va provoquer un reecriture
2687
+    // systematique du noyau ou une baisse de perfs => a etudier)
2688
+    include_once _ROOT_RESTREINT . 'inc/flock.php';
2689
+
2690
+    // charger tout de suite le path et son cache
2691
+    load_path_cache();
2692
+
2693
+    // *********** traiter les variables ************
2694
+
2695
+    //
2696
+    // Securite
2697
+    //
2698
+
2699
+    // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
2700
+    if (isset($_REQUEST['GLOBALS'])) {
2701
+        die();
2702
+    }
2703
+    // nettoyer les magic quotes \' et les caracteres nuls %00
2704
+    spip_desinfecte($_GET);
2705
+    spip_desinfecte($_POST);
2706
+    spip_desinfecte($_COOKIE);
2707
+    spip_desinfecte($_REQUEST);
2708
+
2709
+    // appliquer le cookie_prefix
2710
+    if ($GLOBALS['cookie_prefix'] != 'spip') {
2711
+        include_spip('inc/cookie');
2712
+        recuperer_cookies_spip($GLOBALS['cookie_prefix']);
2713
+    }
2714
+
2715
+    //
2716
+    // Capacites php (en fonction de la version)
2717
+    //
2718
+    $GLOBALS['flag_ob'] = (function_exists('ob_start')
2719
+        && function_exists('ini_get')
2720
+        && !strstr(@ini_get('disable_functions'), 'ob_'));
2721
+    $GLOBALS['flag_sapi_name'] = function_exists('php_sapi_name');
2722
+    $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != '');
2723
+    $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] ||
2724
+        (get_cfg_var('upload_max_filesize') > 0));
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
+    }
2798 2797
 }
2799 2798
 
2800 2799
 /**
@@ -2803,157 +2802,157 @@  discard block
 block discarded – undo
2803 2802
  *
2804 2803
  */
2805 2804
 function spip_initialisation_suite() {
2806
-	static $too_late = 0;
2807
-	if ($too_late++) {
2808
-		return;
2809
-	}
2810
-
2811
-	// taille mini des login
2812
-	if (!defined('_LOGIN_TROP_COURT')) {
2813
-		define('_LOGIN_TROP_COURT', 4);
2814
-	}
2815
-
2816
-	// la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2817
-	#if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko
2818
-	#if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels
2819
-	#if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels
2820
-
2821
-	// la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2822
-	#if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko
2823
-	#if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko
2824
-	#if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels
2825
-	#if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels
2826
-
2827
-	if (!defined('_PASS_LONGUEUR_MINI')) {
2828
-		define('_PASS_LONGUEUR_MINI', 6);
2829
-	}
2830
-
2831
-	// largeur maximale des images dans l'administration
2832
-	if (!defined('_IMG_ADMIN_MAX_WIDTH')) {
2833
-		define('_IMG_ADMIN_MAX_WIDTH', 768);
2834
-	}
2835
-
2836
-	// Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)
2837
-	if (!defined('_IMG_QUALITE')) {
2838
-		define('_IMG_QUALITE', 85);
2839
-	} # valeur par defaut
2840
-	if (!defined('_IMG_GD_QUALITE')) {
2841
-		define('_IMG_GD_QUALITE', _IMG_QUALITE);
2842
-	} # surcharge pour la lib GD
2843
-	if (!defined('_IMG_CONVERT_QUALITE')) {
2844
-		define('_IMG_CONVERT_QUALITE', _IMG_QUALITE);
2845
-	} # surcharge pour imagick en ligne de commande
2846
-	// Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE
2847
-	if (!defined('_IMG_IMAGICK_QUALITE')) {
2848
-		define('_IMG_IMAGICK_QUALITE', 75);
2849
-	} # surcharge pour imagick en PHP
2850
-
2851
-	if (!defined('_COPIE_LOCALE_MAX_SIZE')) {
2852
-		define('_COPIE_LOCALE_MAX_SIZE', 33_554_432);
2853
-	} // poids en octet
2854
-
2855
-	// qq chaines standard
2856
-	if (!defined('_ACCESS_FILE_NAME')) {
2857
-		define('_ACCESS_FILE_NAME', '.htaccess');
2858
-	}
2859
-	if (!defined('_AUTH_USER_FILE')) {
2860
-		define('_AUTH_USER_FILE', '.htpasswd');
2861
-	}
2862
-	if (!defined('_SPIP_DUMP')) {
2863
-		define('_SPIP_DUMP', 'dump@nom_site@@[email protected]');
2864
-	}
2865
-	if (!defined('_CACHE_RUBRIQUES')) {
2866
-		/** Fichier cache pour le navigateur de rubrique du bandeau */
2867
-		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2868
-	}
2869
-	if (!defined('_CACHE_RUBRIQUES_MAX')) {
2870
-		/** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
2871
-		define('_CACHE_RUBRIQUES_MAX', 500);
2872
-	}
2873
-
2874
-	if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) {
2875
-		/**
2876
-		 * Basculer les contextes ajax en fichier si la longueur d’url est trop grande
2877
-		 * @var int Nombre de caractères */
2878
-		define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000);
2879
-	}
2880
-
2881
-	if (!defined('_EXTENSION_SQUELETTES')) {
2882
-		define('_EXTENSION_SQUELETTES', 'html');
2883
-	}
2884
-
2885
-	if (!defined('_DOCTYPE_ECRIRE')) {
2886
-		/** Définit le doctype de l’espace privé */
2887
-		define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n");
2888
-	}
2889
-	if (!defined('_DOCTYPE_AIDE')) {
2890
-		/** Définit le doctype de l’aide en ligne */
2891
-		define(
2892
-			'_DOCTYPE_AIDE',
2893
-			"<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"
2894
-		);
2895
-	}
2896
-
2897
-	if (!defined('_SPIP_SCRIPT')) {
2898
-		/** L'adresse de base du site ; on peut mettre '' si la racine est gerée par
2899
-		 * le script de l'espace public, alias index.php */
2900
-		define('_SPIP_SCRIPT', 'spip.php');
2901
-	}
2902
-	if (!defined('_SPIP_PAGE')) {
2903
-		/** Argument page, personalisable en cas de conflit avec un autre script */
2904
-		define('_SPIP_PAGE', 'page');
2905
-	}
2906
-
2907
-	// le script de l'espace prive
2908
-	// Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:
2909
-	// les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)
2910
-	// meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html
2911
-	if (!defined('_SPIP_ECRIRE_SCRIPT')) {
2912
-		if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) {
2913
-			define('_SPIP_ECRIRE_SCRIPT', 'index.php');
2914
-		} else {
2915
-			define('_SPIP_ECRIRE_SCRIPT', '');
2916
-		}
2917
-	}
2918
-
2919
-
2920
-	if (!defined('_SPIP_AJAX')) {
2921
-		define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax']))
2922
-			? 1
2923
-			: (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));
2924
-	}
2925
-
2926
-	// La requete est-elle en ajax ?
2927
-	if (!defined('_AJAX')) {
2928
-		define(
2929
-			'_AJAX',
2930
-			(isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery
2931
-				or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery
2932
-				or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins
2933
-				or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip
2934
-			)
2935
-			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
2936
-		);
2937
-	}
2938
-
2939
-	# nombre de pixels maxi pour calcul de la vignette avec gd
2940
-	# au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation
2941
-	# les configurations limitees en memoire ont un seuil plutot vers 1MPixel
2942
-	if (!defined('_IMG_GD_MAX_PIXELS')) {
2943
-		define(
2944
-			'_IMG_GD_MAX_PIXELS',
2945
-			(isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes'])
2946
-			? $GLOBALS['meta']['max_taille_vignettes']
2947
-			: 0
2948
-		);
2949
-	}
2950
-
2951
-	// Protocoles a normaliser dans les chaines de langues
2952
-	if (!defined('_PROTOCOLES_STD')) {
2953
-		define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal');
2954
-	}
2955
-
2956
-	init_var_mode();
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();
2957 2956
 }
2958 2957
 
2959 2958
 /**
@@ -2987,219 +2986,219 @@  discard block
 block discarded – undo
2987 2986
  * `   var_mode` (calcul ou recalcul).
2988 2987
  */
2989 2988
 function init_var_mode() {
2990
-	static $done = false;
2991
-	if (!$done) {
2992
-		if (isset($_GET['var_mode'])) {
2993
-			$var_mode = explode(',', $_GET['var_mode']);
2994
-			// tout le monde peut calcul/recalcul
2995
-			if (!defined('_VAR_MODE')) {
2996
-				if (in_array('recalcul', $var_mode)) {
2997
-					define('_VAR_MODE', 'recalcul');
2998
-				} elseif (in_array('calcul', $var_mode)) {
2999
-					define('_VAR_MODE', 'calcul');
3000
-				}
3001
-			}
3002
-			$var_mode = array_diff($var_mode, ['calcul', 'recalcul']);
3003
-			if ($var_mode) {
3004
-				include_spip('inc/autoriser');
3005
-				// autoriser preview si preview seulement, et sinon autoriser debug
3006
-				if (
3007
-					autoriser(
3008
-						($_GET['var_mode'] == 'preview')
3009
-						? 'previsualiser'
3010
-						: 'debug'
3011
-					)
3012
-				) {
3013
-					if (in_array('traduction', $var_mode)) {
3014
-						// forcer le calcul pour passer dans traduire
3015
-						if (!defined('_VAR_MODE')) {
3016
-							define('_VAR_MODE', 'calcul');
3017
-						}
3018
-						// et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages
3019
-						if (!defined('_VAR_NOCACHE')) {
3020
-							define('_VAR_NOCACHE', true);
3021
-						}
3022
-						$var_mode = array_diff($var_mode, ['traduction']);
3023
-					}
3024
-					if (in_array('preview', $var_mode)) {
3025
-						// basculer sur les criteres de preview dans les boucles
3026
-						if (!defined('_VAR_PREVIEW')) {
3027
-							define('_VAR_PREVIEW', true);
3028
-						}
3029
-						// forcer le calcul
3030
-						if (!defined('_VAR_MODE')) {
3031
-							define('_VAR_MODE', 'calcul');
3032
-						}
3033
-						// et ne pas enregistrer de cache
3034
-						if (!defined('_VAR_NOCACHE')) {
3035
-							define('_VAR_NOCACHE', true);
3036
-						}
3037
-						$var_mode = array_diff($var_mode, ['preview']);
3038
-					}
3039
-					if (in_array('inclure', $var_mode)) {
3040
-						// forcer le compilo et ignorer les caches existants
3041
-						if (!defined('_VAR_MODE')) {
3042
-							define('_VAR_MODE', 'calcul');
3043
-						}
3044
-						if (!defined('_VAR_INCLURE')) {
3045
-							define('_VAR_INCLURE', true);
3046
-						}
3047
-						// et ne pas enregistrer de cache
3048
-						if (!defined('_VAR_NOCACHE')) {
3049
-							define('_VAR_NOCACHE', true);
3050
-						}
3051
-						$var_mode = array_diff($var_mode, ['inclure']);
3052
-					}
3053
-					if (in_array('urls', $var_mode)) {
3054
-						// forcer le compilo et ignorer les caches existants
3055
-						if (!defined('_VAR_MODE')) {
3056
-							define('_VAR_MODE', 'calcul');
3057
-						}
3058
-						if (!defined('_VAR_URLS')) {
3059
-							define('_VAR_URLS', true);
3060
-						}
3061
-						$var_mode = array_diff($var_mode, ['urls']);
3062
-					}
3063
-					if (in_array('images', $var_mode)) {
3064
-						// forcer le compilo et ignorer les caches existants
3065
-						if (!defined('_VAR_MODE')) {
3066
-							define('_VAR_MODE', 'calcul');
3067
-						}
3068
-						// indiquer qu'on doit recalculer les images
3069
-						if (!defined('_VAR_IMAGES')) {
3070
-							define('_VAR_IMAGES', true);
3071
-						}
3072
-						$var_mode = array_diff($var_mode, ['images']);
3073
-					}
3074
-					if (in_array('debug', $var_mode)) {
3075
-						if (!defined('_VAR_MODE')) {
3076
-							define('_VAR_MODE', 'debug');
3077
-						}
3078
-						// et ne pas enregistrer de cache
3079
-						if (!defined('_VAR_NOCACHE')) {
3080
-							define('_VAR_NOCACHE', true);
3081
-						}
3082
-						$var_mode = array_diff($var_mode, ['debug']);
3083
-					}
3084
-					if (count($var_mode) and !defined('_VAR_MODE')) {
3085
-						define('_VAR_MODE', reset($var_mode));
3086
-					}
3087
-					if (isset($GLOBALS['visiteur_session']['nom'])) {
3088
-						spip_log($GLOBALS['visiteur_session']['nom']
3089
-							. ' ' . _VAR_MODE);
3090
-					}
3091
-				} // pas autorise ?
3092
-				else {
3093
-					// si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger
3094
-					if (
3095
-						!$GLOBALS['visiteur_session']
3096
-						and !empty($_SERVER['HTTP_HOST'])
3097
-						and !empty($_SERVER['REQUEST_METHOD'])
3098
-						and $_SERVER['REQUEST_METHOD'] === 'GET'
3099
-					) {
3100
-						$self = self('&', true);
3101
-						if (strpos($self, 'page=login') === false) {
3102
-							include_spip('inc/headers');
3103
-							$redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&');
3104
-							redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true));
3105
-						}
3106
-					}
3107
-					// sinon tant pis
3108
-				}
3109
-			}
3110
-		}
3111
-		if (!defined('_VAR_MODE')) {
3112
-			/**
3113
-			 * Indique le mode de calcul ou d'affichage de la page.
3114
-			 * @see init_var_mode()
3115
-			 */
3116
-			define('_VAR_MODE', false);
3117
-		}
3118
-		$done = true;
3119
-	}
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
+    }
3120 3119
 }
3121 3120
 
3122 3121
 // Annuler les magic quotes \' sur GET POST COOKIE et GLOBALS ;
3123 3122
 // supprimer aussi les eventuels caracteres nuls %00, qui peuvent tromper
3124 3123
 // la commande is_readable('chemin/vers/fichier/interdit%00truc_normal')
3125 3124
 function spip_desinfecte(&$t, $deep = true) {
3126
-	foreach ($t as $key => $val) {
3127
-		if (is_string($t[$key])) {
3128
-			$t[$key] = str_replace(chr(0), '-', $t[$key]);
3129
-		} // traiter aussi les "texte_plus" de article_edit
3130
-		else {
3131
-			if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') {
3132
-				spip_desinfecte($t[$key], $deep);
3133
-			}
3134
-		}
3135
-	}
3125
+    foreach ($t as $key => $val) {
3126
+        if (is_string($t[$key])) {
3127
+            $t[$key] = str_replace(chr(0), '-', $t[$key]);
3128
+        } // traiter aussi les "texte_plus" de article_edit
3129
+        else {
3130
+            if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') {
3131
+                spip_desinfecte($t[$key], $deep);
3132
+            }
3133
+        }
3134
+    }
3136 3135
 }
3137 3136
 
3138 3137
 //  retourne le statut du visiteur s'il s'annonce
3139 3138
 
3140 3139
 function verifier_visiteur() {
3141
-	// Rq: pour que cette fonction marche depuis mes_options
3142
-	// il faut forcer l'init si ce n'est fait
3143
-	// mais on risque de perturber des plugins en initialisant trop tot
3144
-	// certaines constantes
3145
-	@spip_initialisation_core(
3146
-		(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3147
-		(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3148
-		(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3149
-		(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3150
-	);
3151
-
3152
-	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
3153
-	// dans un formulaire sans login (ex: #FORMULAIRE_FORUM)
3154
-	// Attention on separe bien session_nom et nom, pour eviter
3155
-	// les melanges entre donnees SQL et variables plus aleatoires
3156
-	$variables_session = ['session_nom', 'session_email'];
3157
-	foreach ($variables_session as $var) {
3158
-		if (_request($var) !== null) {
3159
-			$init = true;
3160
-			break;
3161
-		}
3162
-	}
3163
-	if (isset($init)) {
3164
-		#@spip_initialisation_suite();
3165
-		$session = charger_fonction('session', 'inc');
3166
-		$session();
3167
-		include_spip('inc/texte');
3168
-		foreach ($variables_session as $var) {
3169
-			if (($a = _request($var)) !== null) {
3170
-				$GLOBALS['visiteur_session'][$var] = safehtml($a);
3171
-			}
3172
-		}
3173
-		if (!isset($GLOBALS['visiteur_session']['id_auteur'])) {
3174
-			$GLOBALS['visiteur_session']['id_auteur'] = 0;
3175
-		}
3176
-		$session($GLOBALS['visiteur_session']);
3177
-
3178
-		return 0;
3179
-	}
3180
-
3181
-	$h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3182
-	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3183
-		$session = charger_fonction('session', 'inc');
3184
-		if ($session()) {
3185
-			return $GLOBALS['visiteur_session']['statut'];
3186
-		}
3187
-		if ($h and isset($_SERVER['PHP_AUTH_PW'])) {
3188
-			include_spip('inc/auth');
3189
-			$h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
3190
-		}
3191
-		if ($h) {
3192
-			$GLOBALS['visiteur_session'] = $h;
3193
-
3194
-			return $GLOBALS['visiteur_session']['statut'];
3195
-		}
3196
-	}
3197
-
3198
-	// au moins son navigateur nous dit la langue preferee de cet inconnu
3199
-	include_spip('inc/lang');
3200
-	utiliser_langue_visiteur();
3201
-
3202
-	return false;
3140
+    // Rq: pour que cette fonction marche depuis mes_options
3141
+    // il faut forcer l'init si ce n'est fait
3142
+    // mais on risque de perturber des plugins en initialisant trop tot
3143
+    // certaines constantes
3144
+    @spip_initialisation_core(
3145
+        (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3146
+        (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3147
+        (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3148
+        (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3149
+    );
3150
+
3151
+    // Demarrer une session NON AUTHENTIFIEE si on donne son nom
3152
+    // dans un formulaire sans login (ex: #FORMULAIRE_FORUM)
3153
+    // Attention on separe bien session_nom et nom, pour eviter
3154
+    // les melanges entre donnees SQL et variables plus aleatoires
3155
+    $variables_session = ['session_nom', 'session_email'];
3156
+    foreach ($variables_session as $var) {
3157
+        if (_request($var) !== null) {
3158
+            $init = true;
3159
+            break;
3160
+        }
3161
+    }
3162
+    if (isset($init)) {
3163
+        #@spip_initialisation_suite();
3164
+        $session = charger_fonction('session', 'inc');
3165
+        $session();
3166
+        include_spip('inc/texte');
3167
+        foreach ($variables_session as $var) {
3168
+            if (($a = _request($var)) !== null) {
3169
+                $GLOBALS['visiteur_session'][$var] = safehtml($a);
3170
+            }
3171
+        }
3172
+        if (!isset($GLOBALS['visiteur_session']['id_auteur'])) {
3173
+            $GLOBALS['visiteur_session']['id_auteur'] = 0;
3174
+        }
3175
+        $session($GLOBALS['visiteur_session']);
3176
+
3177
+        return 0;
3178
+    }
3179
+
3180
+    $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3181
+    if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3182
+        $session = charger_fonction('session', 'inc');
3183
+        if ($session()) {
3184
+            return $GLOBALS['visiteur_session']['statut'];
3185
+        }
3186
+        if ($h and isset($_SERVER['PHP_AUTH_PW'])) {
3187
+            include_spip('inc/auth');
3188
+            $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
3189
+        }
3190
+        if ($h) {
3191
+            $GLOBALS['visiteur_session'] = $h;
3192
+
3193
+            return $GLOBALS['visiteur_session']['statut'];
3194
+        }
3195
+    }
3196
+
3197
+    // au moins son navigateur nous dit la langue preferee de cet inconnu
3198
+    include_spip('inc/lang');
3199
+    utiliser_langue_visiteur();
3200
+
3201
+    return false;
3203 3202
 }
3204 3203
 
3205 3204
 
@@ -3222,21 +3221,21 @@  discard block
 block discarded – undo
3222 3221
  *     - string Langue utilisée.
3223 3222
  **/
3224 3223
 function lang_select($lang = null) {
3225
-	static $pile_langues = [];
3226
-	if (!function_exists('changer_langue')) {
3227
-		include_spip('inc/lang');
3228
-	}
3229
-	if ($lang === null) {
3230
-		$lang = array_pop($pile_langues);
3231
-	} else {
3232
-		array_push($pile_langues, $GLOBALS['spip_lang']);
3233
-	}
3234
-	if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) {
3235
-		return $lang;
3236
-	}
3237
-	changer_langue($lang);
3224
+    static $pile_langues = [];
3225
+    if (!function_exists('changer_langue')) {
3226
+        include_spip('inc/lang');
3227
+    }
3228
+    if ($lang === null) {
3229
+        $lang = array_pop($pile_langues);
3230
+    } else {
3231
+        array_push($pile_langues, $GLOBALS['spip_lang']);
3232
+    }
3233
+    if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) {
3234
+        return $lang;
3235
+    }
3236
+    changer_langue($lang);
3238 3237
 
3239
-	return $lang;
3238
+    return $lang;
3240 3239
 }
3241 3240
 
3242 3241
 /**
@@ -3253,20 +3252,20 @@  discard block
 block discarded – undo
3253 3252
  *     Identifiant de la session
3254 3253
  **/
3255 3254
 function spip_session($force = false) {
3256
-	static $session;
3257
-	if ($force or !isset($session)) {
3258
-		$s = pipeline(
3259
-			'definir_session',
3260
-			$GLOBALS['visiteur_session']
3261
-				? serialize($GLOBALS['visiteur_session'])
3262
-				. '_' . @$_COOKIE['spip_session']
3263
-				: ''
3264
-		);
3265
-		$session = $s ? substr(md5($s), 0, 8) : '';
3266
-	}
3255
+    static $session;
3256
+    if ($force or !isset($session)) {
3257
+        $s = pipeline(
3258
+            'definir_session',
3259
+            $GLOBALS['visiteur_session']
3260
+                ? serialize($GLOBALS['visiteur_session'])
3261
+                . '_' . @$_COOKIE['spip_session']
3262
+                : ''
3263
+        );
3264
+        $session = $s ? substr(md5($s), 0, 8) : '';
3265
+    }
3267 3266
 
3268
-	#spip_log('session: '.$session);
3269
-	return $session;
3267
+    #spip_log('session: '.$session);
3268
+    return $session;
3270 3269
 }
3271 3270
 
3272 3271
 
@@ -3285,9 +3284,9 @@  discard block
 block discarded – undo
3285 3284
  *    Lien sur une icone d'aide
3286 3285
  **/
3287 3286
 function aider($aide = '', $distante = false) {
3288
-	$aider = charger_fonction('aide', 'inc', true);
3287
+    $aider = charger_fonction('aide', 'inc', true);
3289 3288
 
3290
-	return $aider ? $aider($aide, '', [], $distante) : '';
3289
+    return $aider ? $aider($aide, '', [], $distante) : '';
3291 3290
 }
3292 3291
 
3293 3292
 /**
@@ -3297,24 +3296,24 @@  discard block
 block discarded – undo
3297 3296
  */
3298 3297
 function exec_info_dist() {
3299 3298
 
3300
-	include_spip('inc/autoriser');
3301
-	if (autoriser('phpinfos')) {
3302
-		$cookies_masques = ['spip_session', 'PHPSESSID'];
3303
-		$cookies_backup = [];
3304
-		foreach ($cookies_masques as $k) {
3305
-			if (!empty($_COOKIE[$k])) {
3306
-				$cookies_backup[$k] = $_COOKIE[$k];
3307
-				$_COOKIE[$k] = '******************************';
3308
-			}
3309
-		}
3310
-		phpinfo();
3311
-		foreach ($cookies_backup as $k => $v) {
3312
-			$_COOKIE[$k] = $v;
3313
-		}
3314
-	} else {
3315
-		include_spip('inc/filtres');
3316
-		sinon_interdire_acces();
3317
-	}
3299
+    include_spip('inc/autoriser');
3300
+    if (autoriser('phpinfos')) {
3301
+        $cookies_masques = ['spip_session', 'PHPSESSID'];
3302
+        $cookies_backup = [];
3303
+        foreach ($cookies_masques as $k) {
3304
+            if (!empty($_COOKIE[$k])) {
3305
+                $cookies_backup[$k] = $_COOKIE[$k];
3306
+                $_COOKIE[$k] = '******************************';
3307
+            }
3308
+        }
3309
+        phpinfo();
3310
+        foreach ($cookies_backup as $k => $v) {
3311
+            $_COOKIE[$k] = $v;
3312
+        }
3313
+    } else {
3314
+        include_spip('inc/filtres');
3315
+        sinon_interdire_acces();
3316
+    }
3318 3317
 }
3319 3318
 
3320 3319
 /**
@@ -3334,13 +3333,13 @@  discard block
 block discarded – undo
3334 3333
  *     - string si $message à false.
3335 3334
  **/
3336 3335
 function erreur_squelette($message = '', $lieu = '') {
3337
-	$debusquer = charger_fonction('debusquer', 'public');
3338
-	if (is_array($lieu)) {
3339
-		include_spip('public/compiler');
3340
-		$lieu = reconstruire_contexte_compil($lieu);
3341
-	}
3336
+    $debusquer = charger_fonction('debusquer', 'public');
3337
+    if (is_array($lieu)) {
3338
+        include_spip('public/compiler');
3339
+        $lieu = reconstruire_contexte_compil($lieu);
3340
+    }
3342 3341
 
3343
-	return $debusquer($message, $lieu);
3342
+    return $debusquer($message, $lieu);
3344 3343
 }
3345 3344
 
3346 3345
 /**
@@ -3377,108 +3376,108 @@  discard block
 block discarded – undo
3377 3376
  *     - ou tableau d'information sur le squelette.
3378 3377
  */
3379 3378
 function recuperer_fond($fond, $contexte = [], $options = [], string $connect = '') {
3380
-	if (!function_exists('evaluer_fond')) {
3381
-		include_spip('public/assembler');
3382
-	}
3383
-	// assurer la compat avec l'ancienne syntaxe
3384
-	// (trim etait le 3eme argument, par defaut a true)
3385
-	if (!is_array($options)) {
3386
-		$options = ['trim' => $options];
3387
-	}
3388
-	if (!isset($options['trim'])) {
3389
-		$options['trim'] = true;
3390
-	}
3391
-
3392
-	if (isset($contexte['connect'])) {
3393
-		$connect = $contexte['connect'];
3394
-		unset($contexte['connect']);
3395
-	}
3396
-
3397
-	$texte = '';
3398
-	$pages = [];
3399
-	$lang_select = '';
3400
-	if (!isset($options['etoile']) or !$options['etoile']) {
3401
-		// Si on a inclus sans fixer le critere de lang, on prend la langue courante
3402
-		if (!isset($contexte['lang'])) {
3403
-			$contexte['lang'] = $GLOBALS['spip_lang'];
3404
-		}
3405
-
3406
-		if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
3407
-			$lang_select = lang_select($contexte['lang']);
3408
-		}
3409
-	}
3410
-
3411
-	if (!isset($GLOBALS['_INC_PUBLIC'])) {
3412
-		$GLOBALS['_INC_PUBLIC'] = 0;
3413
-	}
3414
-
3415
-	$GLOBALS['_INC_PUBLIC']++;
3416
-
3417
-	// fix #4235
3418
-	$cache_utilise_session_appelant	= ($GLOBALS['cache_utilise_session'] ?? null);
3419
-
3420
-
3421
-	foreach (is_array($fond) ? $fond : [$fond] as $f) {
3422
-		unset($GLOBALS['cache_utilise_session']);	// fix #4235
3423
-
3424
-		$page = evaluer_fond($f, $contexte, $connect);
3425
-		if ($page === '') {
3426
-			$c = $options['compil'] ?? '';
3427
-			$a = ['fichier' => $f];
3428
-			$erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
3429
-			erreur_squelette($erreur, $c);
3430
-			// eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
3431
-			$page = ['texte' => '', 'erreur' => $erreur];
3432
-		}
3433
-
3434
-		$page = pipeline('recuperer_fond', [
3435
-			'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect],
3436
-			'data' => $page
3437
-		]);
3438
-		if (isset($options['ajax']) and $options['ajax']) {
3439
-			if (!function_exists('encoder_contexte_ajax')) {
3440
-				include_spip('inc/filtres');
3441
-			}
3442
-			$page['texte'] = encoder_contexte_ajax(
3443
-				array_merge(
3444
-					$contexte,
3445
-					['fond' => $f],
3446
-					($connect ? ['connect' => $connect] : [])
3447
-				),
3448
-				'',
3449
-				$page['texte'],
3450
-				$options['ajax']
3451
-			);
3452
-		}
3453
-
3454
-		if (isset($options['raw']) and $options['raw']) {
3455
-			$pages[] = $page;
3456
-		} else {
3457
-			$texte .= $options['trim'] ? rtrim($page['texte'] ?? '') : $page['texte'];
3458
-		}
3459
-
3460
-		// contamination de la session appelante, pour les inclusions statiques
3461
-		if (isset($page['invalideurs']['session'])) {
3462
-			$cache_utilise_session_appelant = $page['invalideurs']['session'];
3463
-		}
3464
-	}
3465
-
3466
-	// restaurer le sessionnement du contexte appelant,
3467
-	// éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée
3468
-	if (isset($cache_utilise_session_appelant)) {
3469
-		$GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant;
3470
-	}
3471
-
3472
-	$GLOBALS['_INC_PUBLIC']--;
3473
-
3474
-	if ($lang_select) {
3475
-		lang_select();
3476
-	}
3477
-	if (isset($options['raw']) and $options['raw']) {
3478
-		return is_array($fond) ? $pages : reset($pages);
3479
-	} else {
3480
-		return $options['trim'] ? ltrim($texte) : $texte;
3481
-	}
3379
+    if (!function_exists('evaluer_fond')) {
3380
+        include_spip('public/assembler');
3381
+    }
3382
+    // assurer la compat avec l'ancienne syntaxe
3383
+    // (trim etait le 3eme argument, par defaut a true)
3384
+    if (!is_array($options)) {
3385
+        $options = ['trim' => $options];
3386
+    }
3387
+    if (!isset($options['trim'])) {
3388
+        $options['trim'] = true;
3389
+    }
3390
+
3391
+    if (isset($contexte['connect'])) {
3392
+        $connect = $contexte['connect'];
3393
+        unset($contexte['connect']);
3394
+    }
3395
+
3396
+    $texte = '';
3397
+    $pages = [];
3398
+    $lang_select = '';
3399
+    if (!isset($options['etoile']) or !$options['etoile']) {
3400
+        // Si on a inclus sans fixer le critere de lang, on prend la langue courante
3401
+        if (!isset($contexte['lang'])) {
3402
+            $contexte['lang'] = $GLOBALS['spip_lang'];
3403
+        }
3404
+
3405
+        if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
3406
+            $lang_select = lang_select($contexte['lang']);
3407
+        }
3408
+    }
3409
+
3410
+    if (!isset($GLOBALS['_INC_PUBLIC'])) {
3411
+        $GLOBALS['_INC_PUBLIC'] = 0;
3412
+    }
3413
+
3414
+    $GLOBALS['_INC_PUBLIC']++;
3415
+
3416
+    // fix #4235
3417
+    $cache_utilise_session_appelant	= ($GLOBALS['cache_utilise_session'] ?? null);
3418
+
3419
+
3420
+    foreach (is_array($fond) ? $fond : [$fond] as $f) {
3421
+        unset($GLOBALS['cache_utilise_session']);	// fix #4235
3422
+
3423
+        $page = evaluer_fond($f, $contexte, $connect);
3424
+        if ($page === '') {
3425
+            $c = $options['compil'] ?? '';
3426
+            $a = ['fichier' => $f];
3427
+            $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
3428
+            erreur_squelette($erreur, $c);
3429
+            // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
3430
+            $page = ['texte' => '', 'erreur' => $erreur];
3431
+        }
3432
+
3433
+        $page = pipeline('recuperer_fond', [
3434
+            'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect],
3435
+            'data' => $page
3436
+        ]);
3437
+        if (isset($options['ajax']) and $options['ajax']) {
3438
+            if (!function_exists('encoder_contexte_ajax')) {
3439
+                include_spip('inc/filtres');
3440
+            }
3441
+            $page['texte'] = encoder_contexte_ajax(
3442
+                array_merge(
3443
+                    $contexte,
3444
+                    ['fond' => $f],
3445
+                    ($connect ? ['connect' => $connect] : [])
3446
+                ),
3447
+                '',
3448
+                $page['texte'],
3449
+                $options['ajax']
3450
+            );
3451
+        }
3452
+
3453
+        if (isset($options['raw']) and $options['raw']) {
3454
+            $pages[] = $page;
3455
+        } else {
3456
+            $texte .= $options['trim'] ? rtrim($page['texte'] ?? '') : $page['texte'];
3457
+        }
3458
+
3459
+        // contamination de la session appelante, pour les inclusions statiques
3460
+        if (isset($page['invalideurs']['session'])) {
3461
+            $cache_utilise_session_appelant = $page['invalideurs']['session'];
3462
+        }
3463
+    }
3464
+
3465
+    // restaurer le sessionnement du contexte appelant,
3466
+    // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée
3467
+    if (isset($cache_utilise_session_appelant)) {
3468
+        $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant;
3469
+    }
3470
+
3471
+    $GLOBALS['_INC_PUBLIC']--;
3472
+
3473
+    if ($lang_select) {
3474
+        lang_select();
3475
+    }
3476
+    if (isset($options['raw']) and $options['raw']) {
3477
+        return is_array($fond) ? $pages : reset($pages);
3478
+    } else {
3479
+        return $options['trim'] ? ltrim($texte) : $texte;
3480
+    }
3482 3481
 }
3483 3482
 
3484 3483
 /**
@@ -3488,7 +3487,7 @@  discard block
 block discarded – undo
3488 3487
  * @return string
3489 3488
  */
3490 3489
 function trouve_modele($nom) {
3491
-	return trouver_fond($nom, 'modeles/');
3490
+    return trouver_fond($nom, 'modeles/');
3492 3491
 }
3493 3492
 
3494 3493
 /**
@@ -3504,21 +3503,21 @@  discard block
 block discarded – undo
3504 3503
  * @return array|string
3505 3504
  */
3506 3505
 function trouver_fond($nom, $dir = '', $pathinfo = false) {
3507
-	$f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3508
-	if (!$pathinfo) {
3509
-		return $f;
3510
-	}
3511
-	// renvoyer un tableau detaille si $pathinfo==true
3512
-	$p = pathinfo($f);
3513
-	if (!isset($p['extension']) or !$p['extension']) {
3514
-		$p['extension'] = _EXTENSION_SQUELETTES;
3515
-	}
3516
-	if (!isset($p['extension']) or !$p['filename']) {
3517
-		$p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
3518
-	}
3519
-	$p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');
3506
+    $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3507
+    if (!$pathinfo) {
3508
+        return $f;
3509
+    }
3510
+    // renvoyer un tableau detaille si $pathinfo==true
3511
+    $p = pathinfo($f);
3512
+    if (!isset($p['extension']) or !$p['extension']) {
3513
+        $p['extension'] = _EXTENSION_SQUELETTES;
3514
+    }
3515
+    if (!isset($p['extension']) or !$p['filename']) {
3516
+        $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
3517
+    }
3518
+    $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');
3520 3519
 
3521
-	return $p;
3520
+    return $p;
3522 3521
 }
3523 3522
 
3524 3523
 /**
@@ -3538,21 +3537,21 @@  discard block
 block discarded – undo
3538 3537
  *     Nom de l'exec, sinon chaîne vide.
3539 3538
  **/
3540 3539
 function tester_url_ecrire($nom) {
3541
-	static $exec = [];
3542
-	if (isset($exec[$nom])) {
3543
-		return $exec[$nom];
3544
-	}
3545
-	// tester si c'est une page en squelette
3546
-	if (trouver_fond($nom, 'prive/squelettes/contenu/')) {
3547
-		return $exec[$nom] = 'fond';
3548
-	} // echafaudage d'un fond !
3549
-	elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) {
3550
-		return $exec[$nom] = 'fond';
3551
-	}
3552
-	// attention, il ne faut pas inclure l'exec ici
3553
-	// car sinon #URL_ECRIRE provoque des inclusions
3554
-	// et des define intrusifs potentiels
3555
-	return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : '');
3540
+    static $exec = [];
3541
+    if (isset($exec[$nom])) {
3542
+        return $exec[$nom];
3543
+    }
3544
+    // tester si c'est une page en squelette
3545
+    if (trouver_fond($nom, 'prive/squelettes/contenu/')) {
3546
+        return $exec[$nom] = 'fond';
3547
+    } // echafaudage d'un fond !
3548
+    elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) {
3549
+        return $exec[$nom] = 'fond';
3550
+    }
3551
+    // attention, il ne faut pas inclure l'exec ici
3552
+    // car sinon #URL_ECRIRE provoque des inclusions
3553
+    // et des define intrusifs potentiels
3554
+    return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : '');
3556 3555
 }
3557 3556
 
3558 3557
 /**
@@ -3562,8 +3561,8 @@  discard block
 block discarded – undo
3562 3561
  *     true si la constante _VERSION_HTML n'est pas définie ou égale à html5
3563 3562
  **/
3564 3563
 function html5_permis() {
3565
-	return (!defined('_VERSION_HTML')
3566
-		or _VERSION_HTML !== 'html4');
3564
+    return (!defined('_VERSION_HTML')
3565
+        or _VERSION_HTML !== 'html4');
3567 3566
 }
3568 3567
 
3569 3568
 /**
@@ -3573,30 +3572,30 @@  discard block
 block discarded – undo
3573 3572
  * @return array
3574 3573
  */
3575 3574
 function formats_image_acceptables($gd = null, $svg_allowed = true) {
3576
-	$formats = null;
3577
-	if (!is_null($gd)) {
3578
-		$config = ($gd ? 'gd_formats' : 'formats_graphiques');
3579
-		if (isset($GLOBALS['meta'][$config])) {
3580
-			$formats = $GLOBALS['meta'][$config];
3581
-			$formats = explode(',', $formats);
3582
-			$formats = array_filter($formats);
3583
-			$formats = array_map('trim', $formats);
3584
-		}
3585
-	}
3586
-	if (is_null($formats)) {
3587
-		include_spip('inc/filtres_images_lib_mini');
3588
-		$formats = _image_extensions_acceptees_en_entree();
3589
-	}
3590
-
3591
-	if ($svg_allowed) {
3592
-		if (!in_array('svg', $formats)) {
3593
-			$formats[] = 'svg';
3594
-		}
3595
-	}
3596
-	else {
3597
-		$formats = array_diff($formats, ['svg']);
3598
-	}
3599
-	return $formats;
3575
+    $formats = null;
3576
+    if (!is_null($gd)) {
3577
+        $config = ($gd ? 'gd_formats' : 'formats_graphiques');
3578
+        if (isset($GLOBALS['meta'][$config])) {
3579
+            $formats = $GLOBALS['meta'][$config];
3580
+            $formats = explode(',', $formats);
3581
+            $formats = array_filter($formats);
3582
+            $formats = array_map('trim', $formats);
3583
+        }
3584
+    }
3585
+    if (is_null($formats)) {
3586
+        include_spip('inc/filtres_images_lib_mini');
3587
+        $formats = _image_extensions_acceptees_en_entree();
3588
+    }
3589
+
3590
+    if ($svg_allowed) {
3591
+        if (!in_array('svg', $formats)) {
3592
+            $formats[] = 'svg';
3593
+        }
3594
+    }
3595
+    else {
3596
+        $formats = array_diff($formats, ['svg']);
3597
+    }
3598
+    return $formats;
3600 3599
 }
3601 3600
 
3602 3601
 /**
@@ -3605,20 +3604,20 @@  discard block
 block discarded – undo
3605 3604
  * @return array|bool
3606 3605
  */
3607 3606
 function spip_getimagesize($fichier) {
3608
-	if (!$imagesize = @getimagesize($fichier)) {
3609
-		include_spip('inc/svg');
3610
-		if ($attrs = svg_lire_attributs($fichier)) {
3611
-			[$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
3612
-			$imagesize = [
3613
-				$width,
3614
-				$height,
3615
-				IMAGETYPE_SVG,
3616
-				"width=\"{$width}\" height=\"{$height}\"",
3617
-				'mime' => 'image/svg+xml'
3618
-			];
3619
-		}
3620
-	}
3621
-	return $imagesize;
3607
+    if (!$imagesize = @getimagesize($fichier)) {
3608
+        include_spip('inc/svg');
3609
+        if ($attrs = svg_lire_attributs($fichier)) {
3610
+            [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
3611
+            $imagesize = [
3612
+                $width,
3613
+                $height,
3614
+                IMAGETYPE_SVG,
3615
+                "width=\"{$width}\" height=\"{$height}\"",
3616
+                'mime' => 'image/svg+xml'
3617
+            ];
3618
+        }
3619
+    }
3620
+    return $imagesize;
3622 3621
 }
3623 3622
 
3624 3623
 /**
@@ -3632,19 +3631,19 @@  discard block
 block discarded – undo
3632 3631
  * @param string $statut
3633 3632
  */
3634 3633
 function avertir_auteurs($nom, $message, $statut = '') {
3635
-	$alertes = $GLOBALS['meta']['message_alertes_auteurs'];
3636
-	if (
3637
-		!$alertes
3638
-		or !is_array($alertes = unserialize($alertes))
3639
-	) {
3640
-		$alertes = [];
3641
-	}
3634
+    $alertes = $GLOBALS['meta']['message_alertes_auteurs'];
3635
+    if (
3636
+        !$alertes
3637
+        or !is_array($alertes = unserialize($alertes))
3638
+    ) {
3639
+        $alertes = [];
3640
+    }
3642 3641
 
3643
-	if (!isset($alertes[$statut])) {
3644
-		$alertes[$statut] = [];
3645
-	}
3646
-	$alertes[$statut][$nom] = $message;
3647
-	ecrire_meta('message_alertes_auteurs', serialize($alertes));
3642
+    if (!isset($alertes[$statut])) {
3643
+        $alertes[$statut] = [];
3644
+    }
3645
+    $alertes[$statut][$nom] = $message;
3646
+    ecrire_meta('message_alertes_auteurs', serialize($alertes));
3648 3647
 }
3649 3648
 
3650 3649
 /**
@@ -3658,10 +3657,10 @@  discard block
 block discarded – undo
3658 3657
  * @return string|string[]
3659 3658
  */
3660 3659
 function spip_sanitize_classname($classes) {
3661
-	if (is_array($classes)) {
3662
-		return array_map('spip_sanitize_classname', $classes);
3663
-	}
3664
-	return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes);
3660
+    if (is_array($classes)) {
3661
+        return array_map('spip_sanitize_classname', $classes);
3662
+    }
3663
+    return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes);
3665 3664
 }
3666 3665
 
3667 3666
 
@@ -3686,32 +3685,32 @@  discard block
 block discarded – undo
3686 3685
  *    Avec operateur : bool.
3687 3686
  **/
3688 3687
 function spip_version_compare($v1, $v2, $op = null) {
3689
-	$v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1));
3690
-	$v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2));
3691
-	$v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule
3692
-	$v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule
3693
-
3694
-	$v1 = explode('.', $v1);
3695
-	$v2 = explode('.', $v2);
3696
-	// $v1 est toujours une version, donc sans etoile
3697
-	while (count($v1) < count($v2)) {
3698
-		$v1[] = '0';
3699
-	}
3700
-
3701
-	// $v2 peut etre une borne, donc accepte l'etoile
3702
-	$etoile = false;
3703
-	foreach ($v1 as $k => $v) {
3704
-		if (!isset($v2[$k])) {
3705
-			$v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0';
3706
-		} else {
3707
-			if ($v2[$k] == '*') {
3708
-				$etoile = true;
3709
-				$v2[$k] = $v;
3710
-			}
3711
-		}
3712
-	}
3713
-	$v1 = implode('.', $v1);
3714
-	$v2 = implode('.', $v2);
3715
-
3716
-	return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2);
3688
+    $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1));
3689
+    $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2));
3690
+    $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule
3691
+    $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule
3692
+
3693
+    $v1 = explode('.', $v1);
3694
+    $v2 = explode('.', $v2);
3695
+    // $v1 est toujours une version, donc sans etoile
3696
+    while (count($v1) < count($v2)) {
3697
+        $v1[] = '0';
3698
+    }
3699
+
3700
+    // $v2 peut etre une borne, donc accepte l'etoile
3701
+    $etoile = false;
3702
+    foreach ($v1 as $k => $v) {
3703
+        if (!isset($v2[$k])) {
3704
+            $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0';
3705
+        } else {
3706
+            if ($v2[$k] == '*') {
3707
+                $etoile = true;
3708
+                $v2[$k] = $v;
3709
+            }
3710
+        }
3711
+    }
3712
+    $v1 = implode('.', $v1);
3713
+    $v2 = implode('.', $v2);
3714
+
3715
+    return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2);
3717 3716
 }
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,7 +98,7 @@  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');
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 			.'<br />'
110 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
 
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 		$a = './';
593 593
 	}
594 594
 
595
-	$regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,';
595
+	$regexp = ',^('.str_replace('[]', '\[\]', $c).'[[]?[]]?)(=.*)?$,';
596 596
 	$ajouts = array_flip(explode('|', $c));
597 597
 	$u = is_array($v) ? $v : rawurlencode((string) $v);
598 598
 	$testv = (is_array($v) ? count($v) : strlen((string) $v));
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 			// Ajout. Pour une variable, remplacer au meme endroit,
620 620
 			// pour un tableau ce sera fait dans la prochaine boucle
621 621
 			elseif (substr($r[1], -2) != '[]') {
622
-				$url[$n] = $r[1] . '=' . $u;
622
+				$url[$n] = $r[1].'='.$u;
623 623
 				unset($ajouts[$r[1]]);
624 624
 			}
625 625
 			// Pour les tableaux on laisse tomber les valeurs de
@@ -640,11 +640,11 @@  discard block
 block discarded – undo
640 640
 	} elseif ($testv) {
641 641
 		foreach ($ajouts as $k => $n) {
642 642
 			if (!is_array($v)) {
643
-				$url[] = $k . '=' . $u;
643
+				$url[] = $k.'='.$u;
644 644
 			} else {
645
-				$id = (substr($k, -2) == '[]') ? $k : ($k . '[]');
645
+				$id = (substr($k, -2) == '[]') ? $k : ($k.'[]');
646 646
 				foreach ($v as $w) {
647
-					$url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w));
647
+					$url[] = $id.'='.(is_array($w) ? 'Array' : rawurlencode($w));
648 648
 				}
649 649
 			}
650 650
 		}
@@ -655,10 +655,10 @@  discard block
 block discarded – undo
655 655
 
656 656
 	// recomposer l'adresse
657 657
 	if ($url) {
658
-		$a .= '?' . join($sep, $url);
658
+		$a .= '?'.join($sep, $url);
659 659
 	}
660 660
 
661
-	return $a . $ancre;
661
+	return $a.$ancre;
662 662
 }
663 663
 
664 664
 /**
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 			translitteration($ancre)
691 691
 		);
692 692
 	}
693
-	return $url . (strlen($ancre) ? '#' . $ancre : '');
693
+	return $url.(strlen($ancre) ? '#'.$ancre : '');
694 694
 }
695 695
 
696 696
 /**
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
  * @return bool
807 807
  */
808 808
 function test_plugin_actif($plugin) {
809
-	return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
809
+	return ($plugin and defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true : false;
810 810
 }
811 811
 
812 812
 /**
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
 					$value = interdire_scripts($value, -1);
939 939
 				}
940 940
 				if (!empty($options['class'])) {
941
-					$value = "<span class='" . $options['class'] . "'>$value</span>";
941
+					$value = "<span class='".$options['class']."'>$value</span>";
942 942
 				}
943 943
 				$text = str_replace("@$name@", $value, $text);
944 944
 				unset($args[$name]);
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
 		// Si des variables n'ont pas ete inserees, le signaler
948 948
 		// (chaines de langues pas a jour)
949 949
 		if ($args) {
950
-			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
950
+			spip_log("$f:  variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG);
951 951
 		}
952 952
 	}
953 953
 
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
 function joli_repertoire($rep) {
972 972
 	$a = substr($rep, 0, 1);
973 973
 	if ($a <> '.' and $a <> '/') {
974
-		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
974
+		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep;
975 975
 	}
976 976
 	$rep = preg_replace(',(^\.\.\/),', '', $rep);
977 977
 
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 			$p -= ($x * 1000);
1026 1026
 		}
1027 1027
 
1028
-		return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1028
+		return $s.sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
1029 1029
 	}
1030 1030
 }
1031 1031
 
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
 	if ($taches and count($taches) and !spip_connect()) {
1093 1093
 		return false;
1094 1094
 	}
1095
-	spip_log('cron !', 'jq' . _LOG_DEBUG);
1095
+	spip_log('cron !', 'jq'._LOG_DEBUG);
1096 1096
 	if ($genie = charger_fonction('genie', 'inc', true)) {
1097 1097
 		return $genie($taches);
1098 1098
 	}
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 
1197 1197
 	if ($queue_next_job_time == -1) {
1198 1198
 		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1199
-			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
1199
+			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP.'job_queue_next.txt');
1200 1200
 		}
1201 1201
 		// utiliser un cache memoire si dispo
1202 1202
 		if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
@@ -1265,8 +1265,8 @@  discard block
 block discarded – undo
1265 1265
 		$src = '';
1266 1266
 	}
1267 1267
 	if ($script) {
1268
-		$script = ("/*<![CDATA[*/\n" .
1269
-			preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1268
+		$script = ("/*<![CDATA[*/\n".
1269
+			preg_replace(',</([^>]*)>,', '<\/\1>', $script).
1270 1270
 			'/*]]>*/');
1271 1271
 	}
1272 1272
 	if ($noscript) {
@@ -1352,13 +1352,13 @@  discard block
 block discarded – undo
1352 1352
 	if ($path_base == null) {
1353 1353
 		// Chemin standard depuis l'espace public
1354 1354
 		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
1355
-			_DIR_RACINE . ':' .
1356
-			_DIR_RACINE . 'squelettes-dist/:' .
1357
-			_DIR_RACINE . 'prive/:' .
1355
+			_DIR_RACINE.':'.
1356
+			_DIR_RACINE.'squelettes-dist/:'.
1357
+			_DIR_RACINE.'prive/:'.
1358 1358
 			_DIR_RESTREINT;
1359 1359
 		// Ajouter squelettes/
1360
-		if (@is_dir(_DIR_RACINE . 'squelettes')) {
1361
-			$path = _DIR_RACINE . 'squelettes/:' . $path;
1360
+		if (@is_dir(_DIR_RACINE.'squelettes')) {
1361
+			$path = _DIR_RACINE.'squelettes/:'.$path;
1362 1362
 		}
1363 1363
 		foreach (explode(':', $path) as $dir) {
1364 1364
 			if (strlen($dir) and substr($dir, -1) != '/') {
@@ -1370,7 +1370,7 @@  discard block
 block discarded – undo
1370 1370
 		// Et le(s) dossier(s) des squelettes nommes
1371 1371
 		if (strlen($GLOBALS['dossier_squelettes'])) {
1372 1372
 			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1373
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1373
+				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/');
1374 1374
 			}
1375 1375
 		}
1376 1376
 		$GLOBALS['path_sig'] = md5(serialize($path_full));
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
 
1382 1382
 	if (is_array($dir_path) or strlen($dir_path)) {
1383 1383
 		$tete = '';
1384
-		if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1384
+		if (reset($path_base) == _DIR_RACINE.'squelettes/') {
1385 1385
 			$tete = array_shift($path_base);
1386 1386
 		}
1387 1387
 		$dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
@@ -1402,7 +1402,7 @@  discard block
 block discarded – undo
1402 1402
 	// Et le(s) dossier(s) des squelettes nommes
1403 1403
 	if (strlen($GLOBALS['dossier_squelettes'])) {
1404 1404
 		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1405
-			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1405
+			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE).$d.'/');
1406 1406
 		}
1407 1407
 	}
1408 1408
 
@@ -1473,14 +1473,14 @@  discard block
 block discarded – undo
1473 1473
 	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1474 1474
 	if (
1475 1475
 		preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1476
-		and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg'
1476
+		and $file_svg_generique = substr($file, 0, -strlen($m[0])).'-xx.svg'
1477 1477
 		and $f = find_in_theme("$file_svg_generique")
1478 1478
 	) {
1479
-		if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) {
1479
+		if ($fsize = substr($f, 0, -6).$m[1].'.svg' and file_exists($fsize)) {
1480 1480
 			return $themefiles["$subdir$file"] = $fsize;
1481 1481
 		}
1482 1482
 		else {
1483
-			return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
1483
+			return $themefiles["$subdir$file"] = "$f?".$m[1].'px';
1484 1484
 		}
1485 1485
 	}
1486 1486
 
@@ -1490,7 +1490,7 @@  discard block
 block discarded – undo
1490 1490
 			return $themefiles["$subdir$file"] = $f;
1491 1491
 		}
1492 1492
 	}
1493
-	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1493
+	spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme');
1494 1494
 
1495 1495
 	return $themefiles["$subdir$file"] = '';
1496 1496
 }
@@ -1598,8 +1598,8 @@  discard block
 block discarded – undo
1598 1598
 			return false;
1599 1599
 		}
1600 1600
 		if ($include and !isset($inc[$dirname][$file])) {
1601
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1602
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1601
+			include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1602
+			$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
1603 1603
 		}
1604 1604
 
1605 1605
 		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
@@ -1612,14 +1612,14 @@  discard block
 block discarded – undo
1612 1612
 	}
1613 1613
 
1614 1614
 	foreach (creer_chemin() as $dir) {
1615
-		if (!isset($dirs[$a = $dir . $dirname])) {
1616
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1615
+		if (!isset($dirs[$a = $dir.$dirname])) {
1616
+			$dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a);
1617 1617
 		}
1618 1618
 		if ($dirs[$a]) {
1619
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
1619
+			if (file_exists(_ROOT_CWD.($a .= $file))) {
1620 1620
 				if ($include and !isset($inc[$dirname][$file])) {
1621
-					include_once _ROOT_CWD . $a;
1622
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1621
+					include_once _ROOT_CWD.$a;
1622
+					$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
1623 1623
 				}
1624 1624
 				if (!defined('_SAUVER_CHEMIN')) {
1625 1625
 					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
@@ -1629,7 +1629,7 @@  discard block
 block discarded – undo
1629 1629
 					define('_SAUVER_CHEMIN', true);
1630 1630
 				}
1631 1631
 
1632
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1632
+				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a;
1633 1633
 			}
1634 1634
 		}
1635 1635
 	}
@@ -1655,7 +1655,7 @@  discard block
 block discarded – undo
1655 1655
 		define('_SAUVER_CHEMIN', true);
1656 1656
 	}
1657 1657
 
1658
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1658
+	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false;
1659 1659
 }
1660 1660
 
1661 1661
 function clear_path_cache() {
@@ -1725,12 +1725,12 @@  discard block
 block discarded – undo
1725 1725
 	// cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1726 1726
 	// on a pas encore inclus flock.php
1727 1727
 	if (!function_exists('preg_files')) {
1728
-		include_once _ROOT_RESTREINT . 'inc/flock.php';
1728
+		include_once _ROOT_RESTREINT.'inc/flock.php';
1729 1729
 	}
1730 1730
 
1731 1731
 	// Parcourir le chemin
1732 1732
 	foreach (creer_chemin() as $d) {
1733
-		$f = $d . $dir;
1733
+		$f = $d.$dir;
1734 1734
 		if (@is_dir($f)) {
1735 1735
 			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
1736 1736
 			foreach ($liste as $chemin) {
@@ -1779,9 +1779,9 @@  discard block
 block discarded – undo
1779 1779
 function charger_fonction_url(string $quoi, string $type = '') {
1780 1780
 	if ($type === 'defaut') {
1781 1781
 		$objet = objet_type($quoi);
1782
-		if ($f = charger_fonction('generer_' . $objet . '_url', 'urls', true)
1782
+		if ($f = charger_fonction('generer_'.$objet.'_url', 'urls', true)
1783 1783
 			// deprecated
1784
-			or $f = charger_fonction('generer_url_' . $objet, 'urls', true)
1784
+			or $f = charger_fonction('generer_url_'.$objet, 'urls', true)
1785 1785
 		) {
1786 1786
 			return $f;
1787 1787
 		}
@@ -1902,7 +1902,7 @@  discard block
 block discarded – undo
1902 1902
  * @deprecated 4.1
1903 1903
  * @see generer_objet_url
1904 1904
  */
1905
-function generer_url_entite($id = 0, $entite = '', $args = '', $ancre = '', $public = null, $type = null){
1905
+function generer_url_entite($id = 0, $entite = '', $args = '', $ancre = '', $public = null, $type = null) {
1906 1906
 	if ($public and is_string($public)) {
1907 1907
 		return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', true, $type ?? '', $public);
1908 1908
 	}
@@ -1937,7 +1937,7 @@  discard block
 block discarded – undo
1937 1937
  * @deprecated 4.1
1938 1938
  * @see generer_objet_url_ecrire_edit
1939 1939
  */
1940
-function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = ''){
1940
+function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') {
1941 1941
 	return generer_objet_url_ecrire_edit(intval($id), $entite, $args, $ancre);
1942 1942
 }
1943 1943
 
@@ -1946,8 +1946,8 @@  discard block
 block discarded – undo
1946 1946
 	include_spip('base/connect_sql');
1947 1947
 	$id_type = id_table_objet($entite, $public);
1948 1948
 
1949
-	return _DIR_RACINE . get_spip_script('./')
1950
-	. '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1949
+	return _DIR_RACINE.get_spip_script('./')
1950
+	. '?'._SPIP_PAGE."=$entite&$id_type=$i&connect=$public"
1951 1951
 	. (!$args ? '' : "&$args")
1952 1952
 	. (!$ancre ? '' : "#$ancre");
1953 1953
 }
@@ -2001,7 +2001,7 @@  discard block
 block discarded – undo
2001 2001
  * @deprecated 4.1
2002 2002
  * @see  generer_objet_url_absolue
2003 2003
  */
2004
-function generer_url_entite_absolue($id = 0, $entite = '', $args = '', $ancre = '', $connect = null){
2004
+function generer_url_entite_absolue($id = 0, $entite = '', $args = '', $ancre = '', $connect = null) {
2005 2005
 	return generer_objet_url_absolue(intval($id), $entite, $args, $ancre, true, '', $connect);
2006 2006
 }
2007 2007
 
@@ -2118,7 +2118,7 @@  discard block
 block discarded – undo
2118 2118
 				!empty($_SERVER['QUERY_STRING'])
2119 2119
 				and !strpos($_SERVER['REQUEST_URI'], '?')
2120 2120
 			) {
2121
-				$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2121
+				$GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
2122 2122
 			}
2123 2123
 		}
2124 2124
 	}
@@ -2153,9 +2153,9 @@  discard block
 block discarded – undo
2153 2153
 		array_shift($myself);
2154 2154
 		$myself = implode('/', $myself);
2155 2155
 	}
2156
-	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
2156
+	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/';
2157 2157
 
2158
-	$url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
2158
+	$url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/');
2159 2159
 
2160 2160
 	return $url;
2161 2161
 }
@@ -2193,16 +2193,16 @@  discard block
 block discarded – undo
2193 2193
  **/
2194 2194
 function generer_url_ecrire($script = '', $args = '', $no_entities = false, $rel = false) {
2195 2195
 	if (!$rel) {
2196
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2196
+		$rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT;
2197 2197
 	} else {
2198 2198
 		if (!is_string($rel)) {
2199
-			$rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT;
2199
+			$rel = _DIR_RESTREINT ?: './'._SPIP_ECRIRE_SCRIPT;
2200 2200
 		}
2201 2201
 	}
2202 2202
 
2203 2203
 	[$script, $ancre] = array_pad(explode('#', $script), 2, null);
2204 2204
 	if ($script and ($script <> 'accueil' or $rel)) {
2205
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
2205
+		$args = "?exec=$script".(!$args ? '' : "&$args");
2206 2206
 	} elseif ($args) {
2207 2207
 		$args = "?$args";
2208 2208
 	}
@@ -2210,7 +2210,7 @@  discard block
 block discarded – undo
2210 2210
 		$args .= "#$ancre";
2211 2211
 	}
2212 2212
 
2213
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2213
+	return $rel.($no_entities ? $args : str_replace('&', '&amp;', $args));
2214 2214
 }
2215 2215
 
2216 2216
 //
@@ -2292,10 +2292,10 @@  discard block
 block discarded – undo
2292 2292
 			$action = parametre_url($action, _SPIP_PAGE, $script, '&');
2293 2293
 		}
2294 2294
 		if ($args) {
2295
-			$action .= (strpos($action, '?') !== false ? '&' : '?') . $args;
2295
+			$action .= (strpos($action, '?') !== false ? '&' : '?').$args;
2296 2296
 		}
2297 2297
 		// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2298
-		$url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
2298
+		$url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(',^/[.]/,', '/', "/$action"));
2299 2299
 	}
2300 2300
 
2301 2301
 	if (!$no_entities) {
@@ -2307,7 +2307,7 @@  discard block
 block discarded – undo
2307 2307
 
2308 2308
 function generer_url_prive($script, $args = '', $no_entities = false) {
2309 2309
 
2310
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2310
+	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php');
2311 2311
 }
2312 2312
 
2313 2313
 // Pour les formulaires en methode POST,
@@ -2342,8 +2342,7 @@  discard block
 block discarded – undo
2342 2342
 	. "><div>\n"
2343 2343
 	. "<input type='hidden' name='exec' value='$script1' />"
2344 2344
 	. $corps
2345
-	. (!$submit ? '' :
2346
-		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
2345
+	. (!$submit ? '' : ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo submit btn' type='submit' value=\"".entites_html($submit).'" /></div>'))
2347 2346
 	. "</div></form>\n";
2348 2347
 }
2349 2348
 
@@ -2368,14 +2367,14 @@  discard block
 block discarded – undo
2368 2367
 		? generer_url_ecrire(_request('exec'))
2369 2368
 		: generer_url_public();
2370 2369
 
2371
-	return "\n<form action='" .
2372
-	$h .
2373
-	"'" .
2374
-	$atts .
2375
-	">\n" .
2376
-	'<div>' .
2377
-	"\n<input type='hidden' name='action' value='$script' />" .
2378
-	$corps .
2370
+	return "\n<form action='".
2371
+	$h.
2372
+	"'".
2373
+	$atts.
2374
+	">\n".
2375
+	'<div>'.
2376
+	"\n<input type='hidden' name='action' value='$script' />".
2377
+	$corps.
2379 2378
 	'</div></form>';
2380 2379
 }
2381 2380
 
@@ -2403,7 +2402,7 @@  discard block
 block discarded – undo
2403 2402
 		: generer_url_public('', '', false, false);
2404 2403
 	$url = parametre_url($url, 'action', $script);
2405 2404
 	if ($args) {
2406
-		$url .= quote_amp('&' . $args);
2405
+		$url .= quote_amp('&'.$args);
2407 2406
 	}
2408 2407
 
2409 2408
 	if ($no_entities) {
@@ -2437,9 +2436,9 @@  discard block
 block discarded – undo
2437 2436
 	}
2438 2437
 	$url =
2439 2438
 		(($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './')
2440
-	. $script . '/'
2439
+	. $script.'/'
2441 2440
 	. ($path ? trim($path, '/') : '')
2442
-	. ($args ? "?" . quote_amp($args) : '');
2441
+	. ($args ? "?".quote_amp($args) : '');
2443 2442
 
2444 2443
 	if ($no_entities) {
2445 2444
 		$url = str_replace('&amp;', '&', $url);
@@ -2488,17 +2487,17 @@  discard block
 block discarded – undo
2488 2487
 
2489 2488
 	// le nom du repertoire plugins/ activables/desactivables
2490 2489
 	if (!defined('_DIR_PLUGINS')) {
2491
-		define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
2490
+		define('_DIR_PLUGINS', _DIR_RACINE.'plugins/');
2492 2491
 	}
2493 2492
 
2494 2493
 	// le nom du repertoire des extensions/ permanentes du core, toujours actives
2495 2494
 	if (!defined('_DIR_PLUGINS_DIST')) {
2496
-		define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
2495
+		define('_DIR_PLUGINS_DIST', _DIR_RACINE.'plugins-dist/');
2497 2496
 	}
2498 2497
 
2499 2498
 	// le nom du repertoire des librairies
2500 2499
 	if (!defined('_DIR_LIB')) {
2501
-		define('_DIR_LIB', _DIR_RACINE . 'lib/');
2500
+		define('_DIR_LIB', _DIR_RACINE.'lib/');
2502 2501
 	}
2503 2502
 
2504 2503
 	if (!defined('_DIR_IMG')) {
@@ -2508,29 +2507,29 @@  discard block
 block discarded – undo
2508 2507
 		define('_DIR_LOGOS', $pa);
2509 2508
 	}
2510 2509
 	if (!defined('_DIR_IMG_ICONES')) {
2511
-		define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
2510
+		define('_DIR_IMG_ICONES', _DIR_LOGOS.'icones/');
2512 2511
 	}
2513 2512
 
2514 2513
 	if (!defined('_DIR_DUMP')) {
2515
-		define('_DIR_DUMP', $ti . 'dump/');
2514
+		define('_DIR_DUMP', $ti.'dump/');
2516 2515
 	}
2517 2516
 	if (!defined('_DIR_SESSIONS')) {
2518
-		define('_DIR_SESSIONS', $ti . 'sessions/');
2517
+		define('_DIR_SESSIONS', $ti.'sessions/');
2519 2518
 	}
2520 2519
 	if (!defined('_DIR_TRANSFERT')) {
2521
-		define('_DIR_TRANSFERT', $ti . 'upload/');
2520
+		define('_DIR_TRANSFERT', $ti.'upload/');
2522 2521
 	}
2523 2522
 	if (!defined('_DIR_CACHE')) {
2524
-		define('_DIR_CACHE', $ti . 'cache/');
2523
+		define('_DIR_CACHE', $ti.'cache/');
2525 2524
 	}
2526 2525
 	if (!defined('_DIR_CACHE_XML')) {
2527
-		define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
2526
+		define('_DIR_CACHE_XML', _DIR_CACHE.'xml/');
2528 2527
 	}
2529 2528
 	if (!defined('_DIR_SKELS')) {
2530
-		define('_DIR_SKELS', _DIR_CACHE . 'skel/');
2529
+		define('_DIR_SKELS', _DIR_CACHE.'skel/');
2531 2530
 	}
2532 2531
 	if (!defined('_DIR_AIDE')) {
2533
-		define('_DIR_AIDE', _DIR_CACHE . 'aide/');
2532
+		define('_DIR_AIDE', _DIR_CACHE.'aide/');
2534 2533
 	}
2535 2534
 	if (!defined('_DIR_TMP')) {
2536 2535
 		define('_DIR_TMP', $ti);
@@ -2559,27 +2558,27 @@  discard block
 block discarded – undo
2559 2558
 	// Declaration des fichiers
2560 2559
 
2561 2560
 	if (!defined('_CACHE_PLUGINS_PATH')) {
2562
-		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
2561
+		define('_CACHE_PLUGINS_PATH', _DIR_CACHE.'charger_plugins_chemins.php');
2563 2562
 	}
2564 2563
 	if (!defined('_CACHE_PLUGINS_OPT')) {
2565
-		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
2564
+		define('_CACHE_PLUGINS_OPT', _DIR_CACHE.'charger_plugins_options.php');
2566 2565
 	}
2567 2566
 	if (!defined('_CACHE_PLUGINS_FCT')) {
2568
-		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
2567
+		define('_CACHE_PLUGINS_FCT', _DIR_CACHE.'charger_plugins_fonctions.php');
2569 2568
 	}
2570 2569
 	if (!defined('_CACHE_PIPELINES')) {
2571
-		define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
2570
+		define('_CACHE_PIPELINES', _DIR_CACHE.'charger_pipelines.php');
2572 2571
 	}
2573 2572
 	if (!defined('_CACHE_CHEMIN')) {
2574
-		define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
2573
+		define('_CACHE_CHEMIN', _DIR_CACHE.'chemin.txt');
2575 2574
 	}
2576 2575
 
2577 2576
 	# attention .php obligatoire pour ecrire_fichier_securise
2578 2577
 	if (!defined('_FILE_META')) {
2579
-		define('_FILE_META', $ti . 'meta_cache.php');
2578
+		define('_FILE_META', $ti.'meta_cache.php');
2580 2579
 	}
2581 2580
 	if (!defined('_DIR_LOG')) {
2582
-		define('_DIR_LOG', _DIR_TMP . 'log/');
2581
+		define('_DIR_LOG', _DIR_TMP.'log/');
2583 2582
 	}
2584 2583
 	if (!defined('_FILE_LOG')) {
2585 2584
 		define('_FILE_LOG', 'spip');
@@ -2596,8 +2595,8 @@  discard block
 block discarded – undo
2596 2595
 	if (!defined('_FILE_CONNECT')) {
2597 2596
 		define(
2598 2597
 			'_FILE_CONNECT',
2599
-			(@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2600
-			: (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2598
+			(@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f
2599
+			: (@is_readable($f = _DIR_RESTREINT.'inc_connect.php') ? $f
2601 2600
 			: false))
2602 2601
 		);
2603 2602
 	}
@@ -2609,7 +2608,7 @@  discard block
 block discarded – undo
2609 2608
 	if (!defined('_FILE_CHMOD')) {
2610 2609
 		define(
2611 2610
 			'_FILE_CHMOD',
2612
-			(@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2611
+			(@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f
2613 2612
 			: false)
2614 2613
 		);
2615 2614
 	}
@@ -2622,10 +2621,10 @@  discard block
 block discarded – undo
2622 2621
 		define('_FILE_TMP_SUFFIX', '.tmp.php');
2623 2622
 	}
2624 2623
 	if (!defined('_FILE_CONNECT_TMP')) {
2625
-		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2624
+		define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX);
2626 2625
 	}
2627 2626
 	if (!defined('_FILE_CHMOD_TMP')) {
2628
-		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2627
+		define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX);
2629 2628
 	}
2630 2629
 
2631 2630
 	// Definition des droits d'acces en ecriture
@@ -2643,13 +2642,13 @@  discard block
 block discarded – undo
2643 2642
 		define('_DEFAULT_CHARSET', 'utf-8');
2644 2643
 	}
2645 2644
 	if (!defined('_ROOT_PLUGINS')) {
2646
-		define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/');
2645
+		define('_ROOT_PLUGINS', _ROOT_RACINE.'plugins/');
2647 2646
 	}
2648 2647
 	if (!defined('_ROOT_PLUGINS_DIST')) {
2649
-		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/');
2648
+		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE.'plugins-dist/');
2650 2649
 	}
2651 2650
 	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2652
-		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2651
+		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2653 2652
 	}
2654 2653
 
2655 2654
 	// La taille des Log
@@ -2686,7 +2685,7 @@  discard block
 block discarded – undo
2686 2685
 	// (non surchargeable en l'etat ; attention si on utilise include_spip()
2687 2686
 	// pour le rendre surchargeable, on va provoquer un reecriture
2688 2687
 	// systematique du noyau ou une baisse de perfs => a etudier)
2689
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
2688
+	include_once _ROOT_RESTREINT.'inc/flock.php';
2690 2689
 
2691 2690
 	// charger tout de suite le path et son cache
2692 2691
 	load_path_cache();
@@ -2734,7 +2733,7 @@  discard block
 block discarded – undo
2734 2733
 			!empty($_SERVER['QUERY_STRING'])
2735 2734
 			and !strpos($_SERVER['REQUEST_URI'], '?')
2736 2735
 		) {
2737
-			$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2736
+			$GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
2738 2737
 		}
2739 2738
 	}
2740 2739
 
@@ -2770,7 +2769,7 @@  discard block
 block discarded – undo
2770 2769
 		) {
2771 2770
 			if (isset($GLOBALS['meta']['adresse_site'])) {
2772 2771
 				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2773
-				$uri_ref = ($uri_ref['path'] ?? '') . '/';
2772
+				$uri_ref = ($uri_ref['path'] ?? '').'/';
2774 2773
 			} else {
2775 2774
 				$uri_ref = '';
2776 2775
 			}
@@ -2864,7 +2863,7 @@  discard block
 block discarded – undo
2864 2863
 	}
2865 2864
 	if (!defined('_CACHE_RUBRIQUES')) {
2866 2865
 		/** Fichier cache pour le navigateur de rubrique du bandeau */
2867
-		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2866
+		define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt');
2868 2867
 	}
2869 2868
 	if (!defined('_CACHE_RUBRIQUES_MAX')) {
2870 2869
 		/** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
@@ -3086,7 +3085,7 @@  discard block
 block discarded – undo
3086 3085
 					}
3087 3086
 					if (isset($GLOBALS['visiteur_session']['nom'])) {
3088 3087
 						spip_log($GLOBALS['visiteur_session']['nom']
3089
-							. ' ' . _VAR_MODE);
3088
+							. ' '._VAR_MODE);
3090 3089
 					}
3091 3090
 				} // pas autorise ?
3092 3091
 				else {
@@ -3101,7 +3100,7 @@  discard block
 block discarded – undo
3101 3100
 						if (strpos($self, 'page=login') === false) {
3102 3101
 							include_spip('inc/headers');
3103 3102
 							$redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&');
3104
-							redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true));
3103
+							redirige_par_entete(generer_url_public('login', 'url='.rawurlencode($redirect), true));
3105 3104
 						}
3106 3105
 					}
3107 3106
 					// sinon tant pis
@@ -3143,10 +3142,10 @@  discard block
 block discarded – undo
3143 3142
 	// mais on risque de perturber des plugins en initialisant trop tot
3144 3143
 	// certaines constantes
3145 3144
 	@spip_initialisation_core(
3146
-		(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
3147
-		(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
3148
-		(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
3149
-		(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
3145
+		(_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES),
3146
+		(_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES),
3147
+		(_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES),
3148
+		(_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES)
3150 3149
 	);
3151 3150
 
3152 3151
 	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
@@ -3179,7 +3178,7 @@  discard block
 block discarded – undo
3179 3178
 	}
3180 3179
 
3181 3180
 	$h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
3182
-	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
3181
+	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) {
3183 3182
 		$session = charger_fonction('session', 'inc');
3184 3183
 		if ($session()) {
3185 3184
 			return $GLOBALS['visiteur_session']['statut'];
@@ -3259,7 +3258,7 @@  discard block
 block discarded – undo
3259 3258
 			'definir_session',
3260 3259
 			$GLOBALS['visiteur_session']
3261 3260
 				? serialize($GLOBALS['visiteur_session'])
3262
-				. '_' . @$_COOKIE['spip_session']
3261
+				. '_'.@$_COOKIE['spip_session']
3263 3262
 				: ''
3264 3263
 		);
3265 3264
 		$session = $s ? substr(md5($s), 0, 8) : '';
@@ -3415,11 +3414,11 @@  discard block
 block discarded – undo
3415 3414
 	$GLOBALS['_INC_PUBLIC']++;
3416 3415
 
3417 3416
 	// fix #4235
3418
-	$cache_utilise_session_appelant	= ($GLOBALS['cache_utilise_session'] ?? null);
3417
+	$cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null);
3419 3418
 
3420 3419
 
3421 3420
 	foreach (is_array($fond) ? $fond : [$fond] as $f) {
3422
-		unset($GLOBALS['cache_utilise_session']);	// fix #4235
3421
+		unset($GLOBALS['cache_utilise_session']); // fix #4235
3423 3422
 
3424 3423
 		$page = evaluer_fond($f, $contexte, $connect);
3425 3424
 		if ($page === '') {
@@ -3504,7 +3503,7 @@  discard block
 block discarded – undo
3504 3503
  * @return array|string
3505 3504
  */
3506 3505
 function trouver_fond($nom, $dir = '', $pathinfo = false) {
3507
-	$f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3506
+	$f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : '');
3508 3507
 	if (!$pathinfo) {
3509 3508
 		return $f;
3510 3509
 	}
Please login to merge, or discard this patch.
ecrire/inc/texte_mini.php 1 patch
Indentation   +389 added lines, -389 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
 include_spip('inc/filtres');
23 23
 include_spip('inc/lang');
@@ -39,21 +39,21 @@  discard block
 block discarded – undo
39 39
  **/
40 40
 function definir_puce() {
41 41
 
42
-	// Attention au sens, qui n'est pas defini de la meme facon dans
43
-	// l'espace prive (spip_lang est la langue de l'interface, lang_dir
44
-	// celle du texte) et public (spip_lang est la langue du texte)
45
-	$dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']);
42
+    // Attention au sens, qui n'est pas defini de la meme facon dans
43
+    // l'espace prive (spip_lang est la langue de l'interface, lang_dir
44
+    // celle du texte) et public (spip_lang est la langue du texte)
45
+    $dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']);
46 46
 
47
-	$p = 'puce' . (test_espace_prive() ? '_prive' : '');
48
-	if ($dir == 'rtl') {
49
-		$p .= '_rtl';
50
-	}
47
+    $p = 'puce' . (test_espace_prive() ? '_prive' : '');
48
+    if ($dir == 'rtl') {
49
+        $p .= '_rtl';
50
+    }
51 51
 
52
-	if (!isset($GLOBALS[$p])) {
53
-		$GLOBALS[$p] = '<span class="spip-puce ' . $dir . '"><b>–</b></span>';
54
-	}
52
+    if (!isset($GLOBALS[$p])) {
53
+        $GLOBALS[$p] = '<span class="spip-puce ' . $dir . '"><b>–</b></span>';
54
+    }
55 55
 
56
-	return $GLOBALS[$p];
56
+    return $GLOBALS[$p];
57 57
 }
58 58
 
59 59
 
@@ -61,14 +61,14 @@  discard block
 block discarded – undo
61 61
 // dont on souhaite qu'ils provoquent un saut de paragraphe
62 62
 
63 63
 if (!defined('_BALISES_BLOCS')) {
64
-	define(
65
-		'_BALISES_BLOCS',
66
-		'address|applet|article|aside|blockquote|button|center|d[ltd]|div|fieldset|fig(ure|caption)|footer|form|h[1-6r]|hgroup|head|header|iframe|li|map|marquee|nav|noscript|object|ol|pre|section|t(able|[rdh]|body|foot|extarea)|ul|script|style'
67
-	);
64
+    define(
65
+        '_BALISES_BLOCS',
66
+        'address|applet|article|aside|blockquote|button|center|d[ltd]|div|fieldset|fig(ure|caption)|footer|form|h[1-6r]|hgroup|head|header|iframe|li|map|marquee|nav|noscript|object|ol|pre|section|t(able|[rdh]|body|foot|extarea)|ul|script|style'
67
+    );
68 68
 }
69 69
 
70 70
 if (!defined('_BALISES_BLOCS_REGEXP')) {
71
-	define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS');
71
+    define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS');
72 72
 }
73 73
 
74 74
 //
@@ -79,106 +79,106 @@  discard block
 block discarded – undo
79 79
 // une $source differente ; le script detecte automagiquement si ce qu'on
80 80
 // echappe est un div ou un span
81 81
 function code_echappement($rempl, $source = '', $no_transform = false, $mode = null) {
82
-	if (!strlen($rempl)) {
83
-		return '';
84
-	}
85
-
86
-	// Tester si on echappe en span ou en div
87
-	if (is_null($mode) or !in_array($mode, ['div', 'span'])) {
88
-		$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span';
89
-	}
90
-
91
-	// Decouper en morceaux, base64 a des probleme selon la taille de la pile
92
-	$taille = 30000;
93
-	$return = '';
94
-	for ($i = 0; $i < strlen($rempl); $i += $taille) {
95
-		// Convertir en base64 et cacher dans un attribut
96
-		// utiliser les " pour eviter le re-encodage de ' et &#8217
97
-		$base64 = base64_encode(substr($rempl, $i, $taille));
98
-		$return .= "<$mode class=\"base64$source\" title=\"$base64\"></$mode>";
99
-	}
100
-
101
-	return $return;
82
+    if (!strlen($rempl)) {
83
+        return '';
84
+    }
85
+
86
+    // Tester si on echappe en span ou en div
87
+    if (is_null($mode) or !in_array($mode, ['div', 'span'])) {
88
+        $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span';
89
+    }
90
+
91
+    // Decouper en morceaux, base64 a des probleme selon la taille de la pile
92
+    $taille = 30000;
93
+    $return = '';
94
+    for ($i = 0; $i < strlen($rempl); $i += $taille) {
95
+        // Convertir en base64 et cacher dans un attribut
96
+        // utiliser les " pour eviter le re-encodage de ' et &#8217
97
+        $base64 = base64_encode(substr($rempl, $i, $taille));
98
+        $return .= "<$mode class=\"base64$source\" title=\"$base64\"></$mode>";
99
+    }
100
+
101
+    return $return;
102 102
 }
103 103
 
104 104
 
105 105
 // Echapper les <html>...</ html>
106 106
 function traiter_echap_html_dist($regs) {
107
-	return $regs[3];
107
+    return $regs[3];
108 108
 }
109 109
 
110 110
 // Echapper les <pre>...</ pre>
111 111
 function traiter_echap_pre_dist($regs) {
112
-	// echapper les <code> dans <pre>
113
-	$pre = $regs[3];
114
-
115
-	// echapper les < dans <code>
116
-	// on utilise _PROTEGE_BLOCS pour simplifier le code et la maintenance, mais on est interesse que par <code>
117
-	if (
118
-		strpos($pre, '<') !== false
119
-		and preg_match_all(_PROTEGE_BLOCS, $pre, $matches, PREG_SET_ORDER)
120
-	) {
121
-		foreach ($matches as $m) {
122
-			if ($m[1] === 'code') {
123
-				$code = '<code' . $m[2] . '>' . spip_htmlspecialchars($m[3]) . '</code>';
124
-				$pre = str_replace($m[0], $code, $pre);
125
-			}
126
-		}
127
-	}
128
-	return "<pre>$pre</pre>";
112
+    // echapper les <code> dans <pre>
113
+    $pre = $regs[3];
114
+
115
+    // echapper les < dans <code>
116
+    // on utilise _PROTEGE_BLOCS pour simplifier le code et la maintenance, mais on est interesse que par <code>
117
+    if (
118
+        strpos($pre, '<') !== false
119
+        and preg_match_all(_PROTEGE_BLOCS, $pre, $matches, PREG_SET_ORDER)
120
+    ) {
121
+        foreach ($matches as $m) {
122
+            if ($m[1] === 'code') {
123
+                $code = '<code' . $m[2] . '>' . spip_htmlspecialchars($m[3]) . '</code>';
124
+                $pre = str_replace($m[0], $code, $pre);
125
+            }
126
+        }
127
+    }
128
+    return "<pre>$pre</pre>";
129 129
 }
130 130
 
131 131
 // Echapper les <code>...</ code>
132 132
 function traiter_echap_code_dist($regs) {
133
-	[, , $att, $corps] = $regs;
134
-	$echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code !
135
-
136
-	// ne pas mettre le <div...> s'il n'y a qu'une ligne
137
-	if (is_int(strpos($echap, "\n"))) {
138
-		// supprimer les sauts de ligne debut/fin
139
-		// (mais pas les espaces => ascii art).
140
-		$echap = preg_replace("/^[\n\r]+|[\n\r]+$/s", '', $echap);
141
-		$echap = nl2br($echap);
142
-		$echap = "<div style='text-align: left;' "
143
-			. "class='spip_code' dir='ltr'><code$att>"
144
-			. $echap . '</code></div>';
145
-	} else {
146
-		$echap = "<code$att class='spip_code' dir='ltr'>" . $echap . '</code>';
147
-	}
148
-
149
-	$echap = str_replace("\t", '&nbsp; &nbsp; &nbsp; &nbsp; ', $echap);
150
-	$echap = str_replace('  ', ' &nbsp;', $echap);
151
-
152
-	return $echap;
133
+    [, , $att, $corps] = $regs;
134
+    $echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code !
135
+
136
+    // ne pas mettre le <div...> s'il n'y a qu'une ligne
137
+    if (is_int(strpos($echap, "\n"))) {
138
+        // supprimer les sauts de ligne debut/fin
139
+        // (mais pas les espaces => ascii art).
140
+        $echap = preg_replace("/^[\n\r]+|[\n\r]+$/s", '', $echap);
141
+        $echap = nl2br($echap);
142
+        $echap = "<div style='text-align: left;' "
143
+            . "class='spip_code' dir='ltr'><code$att>"
144
+            . $echap . '</code></div>';
145
+    } else {
146
+        $echap = "<code$att class='spip_code' dir='ltr'>" . $echap . '</code>';
147
+    }
148
+
149
+    $echap = str_replace("\t", '&nbsp; &nbsp; &nbsp; &nbsp; ', $echap);
150
+    $echap = str_replace('  ', ' &nbsp;', $echap);
151
+
152
+    return $echap;
153 153
 }
154 154
 
155 155
 // Echapper les <cadre>...</ cadre> aka <frame>...</ frame>
156 156
 function traiter_echap_cadre_dist($regs) {
157
-	$echap = trim(entites_html($regs[3]));
158
-	// compter les lignes un peu plus finement qu'avec les \n
159
-	$lignes = explode("\n", trim($echap));
160
-	$n = 0;
161
-	foreach ($lignes as $l) {
162
-		$n += floor(strlen($l) / 60) + 1;
163
-	}
164
-	$n = max($n, 2);
165
-	$echap = "\n<textarea readonly='readonly' cols='40' rows='$n' class='spip_cadre' dir='ltr'>$echap</textarea>";
166
-
167
-	return $echap;
157
+    $echap = trim(entites_html($regs[3]));
158
+    // compter les lignes un peu plus finement qu'avec les \n
159
+    $lignes = explode("\n", trim($echap));
160
+    $n = 0;
161
+    foreach ($lignes as $l) {
162
+        $n += floor(strlen($l) / 60) + 1;
163
+    }
164
+    $n = max($n, 2);
165
+    $echap = "\n<textarea readonly='readonly' cols='40' rows='$n' class='spip_cadre' dir='ltr'>$echap</textarea>";
166
+
167
+    return $echap;
168 168
 }
169 169
 
170 170
 function traiter_echap_frame_dist($regs) {
171
-	return traiter_echap_cadre_dist($regs);
171
+    return traiter_echap_cadre_dist($regs);
172 172
 }
173 173
 
174 174
 function traiter_echap_script_dist($regs) {
175
-	// rendre joli (et inactif) si c'est un script language=php
176
-	if (preg_match(',<script\b[^>]+php,ims', $regs[0])) {
177
-		return highlight_string($regs[0], true);
178
-	}
175
+    // rendre joli (et inactif) si c'est un script language=php
176
+    if (preg_match(',<script\b[^>]+php,ims', $regs[0])) {
177
+        return highlight_string($regs[0], true);
178
+    }
179 179
 
180
-	// Cas normal : le script passe tel quel
181
-	return $regs[0];
180
+    // Cas normal : le script passe tel quel
181
+    return $regs[0];
182 182
 }
183 183
 
184 184
 define('_PROTEGE_BLOCS', ',<(html|pre|code|cadre|frame|script|style)(\s[^>]*)?>(.*)</\1>,UimsS');
@@ -196,67 +196,67 @@  discard block
 block discarded – undo
196 196
  * @return string|string[]
197 197
  */
198 198
 function echappe_html(
199
-	$letexte,
200
-	$source = '',
201
-	$no_transform = false,
202
-	$preg = '',
203
-	$callback_prefix = ''
199
+    $letexte,
200
+    $source = '',
201
+    $no_transform = false,
202
+    $preg = '',
203
+    $callback_prefix = ''
204 204
 ) {
205
-	if (!is_string($letexte) or !strlen($letexte)) {
206
-		return $letexte;
207
-	}
208
-
209
-	if (
210
-		($preg or strpos($letexte, '<') !== false)
211
-		and preg_match_all($preg ?: _PROTEGE_BLOCS, $letexte, $matches, PREG_SET_ORDER)
212
-	) {
213
-		foreach ($matches as $regs) {
214
-			// echappements tels quels ?
215
-			if ($no_transform) {
216
-				$echap = $regs[0];
217
-			} // sinon les traiter selon le cas
218
-			else {
219
-				if (
220
-					function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1]))
221
-					or function_exists($f = $f . '_dist')
222
-				) {
223
-					$echap = $f($regs);
224
-				}
225
-			}
226
-
227
-			$p = strpos($letexte, (string) $regs[0]);
228
-			$letexte = substr_replace($letexte, code_echappement($echap, $source, $no_transform), $p, strlen($regs[0]));
229
-		}
230
-	}
231
-
232
-	if ($no_transform) {
233
-		return $letexte;
234
-	}
235
-
236
-	// Echapper le php pour faire joli (ici, c'est pas pour la securite)
237
-	// seulement si on a echappe les <script>
238
-	// (derogatoire car on ne peut pas faire passer < ? ... ? >
239
-	// dans une callback autonommee
240
-	if (strpos($preg ?: _PROTEGE_BLOCS, 'script') !== false) {
241
-		if (
242
-			strpos($letexte, '<' . '?') !== false and preg_match_all(
243
-				',<[?].*($|[?]>),UisS',
244
-				$letexte,
245
-				$matches,
246
-				PREG_SET_ORDER
247
-			)
248
-		) {
249
-			foreach ($matches as $regs) {
250
-				$letexte = str_replace(
251
-					$regs[0],
252
-					code_echappement(highlight_string($regs[0], true), $source),
253
-					$letexte
254
-				);
255
-			}
256
-		}
257
-	}
258
-
259
-	return $letexte;
205
+    if (!is_string($letexte) or !strlen($letexte)) {
206
+        return $letexte;
207
+    }
208
+
209
+    if (
210
+        ($preg or strpos($letexte, '<') !== false)
211
+        and preg_match_all($preg ?: _PROTEGE_BLOCS, $letexte, $matches, PREG_SET_ORDER)
212
+    ) {
213
+        foreach ($matches as $regs) {
214
+            // echappements tels quels ?
215
+            if ($no_transform) {
216
+                $echap = $regs[0];
217
+            } // sinon les traiter selon le cas
218
+            else {
219
+                if (
220
+                    function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1]))
221
+                    or function_exists($f = $f . '_dist')
222
+                ) {
223
+                    $echap = $f($regs);
224
+                }
225
+            }
226
+
227
+            $p = strpos($letexte, (string) $regs[0]);
228
+            $letexte = substr_replace($letexte, code_echappement($echap, $source, $no_transform), $p, strlen($regs[0]));
229
+        }
230
+    }
231
+
232
+    if ($no_transform) {
233
+        return $letexte;
234
+    }
235
+
236
+    // Echapper le php pour faire joli (ici, c'est pas pour la securite)
237
+    // seulement si on a echappe les <script>
238
+    // (derogatoire car on ne peut pas faire passer < ? ... ? >
239
+    // dans une callback autonommee
240
+    if (strpos($preg ?: _PROTEGE_BLOCS, 'script') !== false) {
241
+        if (
242
+            strpos($letexte, '<' . '?') !== false and preg_match_all(
243
+                ',<[?].*($|[?]>),UisS',
244
+                $letexte,
245
+                $matches,
246
+                PREG_SET_ORDER
247
+            )
248
+        ) {
249
+            foreach ($matches as $regs) {
250
+                $letexte = str_replace(
251
+                    $regs[0],
252
+                    code_echappement(highlight_string($regs[0], true), $source),
253
+                    $letexte
254
+                );
255
+            }
256
+        }
257
+    }
258
+
259
+    return $letexte;
260 260
 }
261 261
 
262 262
 //
@@ -264,57 +264,57 @@  discard block
 block discarded – undo
264 264
 // Rq: $source sert a faire des echappements "a soi" qui ne sont pas nettoyes
265 265
 // par propre() : exemple dans multi et dans typo()
266 266
 function echappe_retour($letexte, $source = '', $filtre = '') {
267
-	if (strpos($letexte, (string) "base64$source")) {
268
-		# spip_log(spip_htmlspecialchars($letexte));  ## pour les curieux
269
-		$max_prof = 5;
270
-		while (
271
-			strpos($letexte, '<') !== false
272
-			and
273
-			preg_match_all(
274
-				',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
275
-				$letexte,
276
-				$regs,
277
-				PREG_SET_ORDER
278
-			)
279
-			and $max_prof--
280
-		) {
281
-			foreach ($regs as $reg) {
282
-				$rempl = base64_decode(extraire_attribut($reg[0], 'title'));
283
-				// recherche d'attributs supplementaires
284
-				$at = [];
285
-				foreach (['lang', 'dir'] as $attr) {
286
-					if ($a = extraire_attribut($reg[0], $attr)) {
287
-						$at[$attr] = $a;
288
-					}
289
-				}
290
-				if ($at) {
291
-					$rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
292
-					foreach ($at as $attr => $a) {
293
-						$rempl = inserer_attribut($rempl, $attr, $a);
294
-					}
295
-				}
296
-				if ($filtre) {
297
-					$rempl = $filtre($rempl);
298
-				}
299
-				$letexte = str_replace($reg[0], $rempl, $letexte);
300
-			}
301
-		}
302
-	}
303
-
304
-	return $letexte;
267
+    if (strpos($letexte, (string) "base64$source")) {
268
+        # spip_log(spip_htmlspecialchars($letexte));  ## pour les curieux
269
+        $max_prof = 5;
270
+        while (
271
+            strpos($letexte, '<') !== false
272
+            and
273
+            preg_match_all(
274
+                ',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
275
+                $letexte,
276
+                $regs,
277
+                PREG_SET_ORDER
278
+            )
279
+            and $max_prof--
280
+        ) {
281
+            foreach ($regs as $reg) {
282
+                $rempl = base64_decode(extraire_attribut($reg[0], 'title'));
283
+                // recherche d'attributs supplementaires
284
+                $at = [];
285
+                foreach (['lang', 'dir'] as $attr) {
286
+                    if ($a = extraire_attribut($reg[0], $attr)) {
287
+                        $at[$attr] = $a;
288
+                    }
289
+                }
290
+                if ($at) {
291
+                    $rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
292
+                    foreach ($at as $attr => $a) {
293
+                        $rempl = inserer_attribut($rempl, $attr, $a);
294
+                    }
295
+                }
296
+                if ($filtre) {
297
+                    $rempl = $filtre($rempl);
298
+                }
299
+                $letexte = str_replace($reg[0], $rempl, $letexte);
300
+            }
301
+        }
302
+    }
303
+
304
+    return $letexte;
305 305
 }
306 306
 
307 307
 // Reinserer le javascript de confiance (venant des modeles)
308 308
 
309 309
 function echappe_retour_modeles($letexte, $interdire_scripts = false) {
310
-	$letexte = echappe_retour($letexte);
310
+    $letexte = echappe_retour($letexte);
311 311
 
312
-	// Dans les appels directs hors squelette, securiser aussi ici
313
-	if ($interdire_scripts) {
314
-		$letexte = interdire_scripts($letexte);
315
-	}
312
+    // Dans les appels directs hors squelette, securiser aussi ici
313
+    if ($interdire_scripts) {
314
+        $letexte = interdire_scripts($letexte);
315
+    }
316 316
 
317
-	return trim($letexte);
317
+    return trim($letexte);
318 318
 }
319 319
 
320 320
 
@@ -342,131 +342,131 @@  discard block
 block discarded – undo
342 342
  *     Texte coupé
343 343
  **/
344 344
 function couper($texte, $taille = 50, $suite = null) {
345
-	if (!($length = strlen($texte)) or $taille <= 0) {
346
-		return '';
347
-	}
348
-	$offset = 400 + 2 * $taille;
349
-	while (
350
-		$offset < $length
351
-		and strlen(preg_replace(',<(!--|\w|/)[^>]+>,Uims', '', substr($texte, 0, $offset))) < $taille
352
-	) {
353
-		$offset = 2 * $offset;
354
-	}
355
-	if (
356
-		$offset < $length
357
-		&& ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== null
358
-	) {
359
-		$p_tag_fermant = strpos($texte, '>', $offset);
360
-		if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant)) {
361
-			$offset = $p_tag_fermant + 1;
362
-		} // prolonger la coupe jusqu'au tag fermant suivant eventuel
363
-	}
364
-	$texte = substr($texte, 0, $offset); /* eviter de travailler sur 10ko pour extraire 150 caracteres */
365
-
366
-	if (!function_exists('nettoyer_raccourcis_typo')) {
367
-		include_spip('inc/lien');
368
-	}
369
-	$texte = nettoyer_raccourcis_typo($texte);
370
-
371
-	// balises de sauts de ligne et paragraphe
372
-	$texte = preg_replace('/<p( [^>]*)?' . '>/', "\r", $texte);
373
-	$texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte);
374
-
375
-	// on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
376
-	$texte = str_replace("\n\n", "\r", $texte);
377
-
378
-	// supprimer les tags
379
-	$texte = supprimer_tags($texte);
380
-	$texte = trim(str_replace("\n", ' ', $texte));
381
-	$texte .= "\n";  // marquer la fin
382
-
383
-	// corriger la longueur de coupe
384
-	// en fonction de la presence de caracteres utf
385
-	if ($GLOBALS['meta']['charset'] == 'utf-8') {
386
-		$long = charset2unicode($texte);
387
-		$long = spip_substr($long, 0, max($taille, 1));
388
-		$nbcharutf = preg_match_all('/(&#[0-9]{3,6};)/S', $long, $matches);
389
-		$taille += $nbcharutf;
390
-	}
391
-
392
-
393
-	// couper au mot precedent
394
-	$long = spip_substr($texte, 0, max($taille - 4, 1));
395
-	$u = $GLOBALS['meta']['pcre_u'];
396
-	$court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
397
-	if (is_null($suite)) {
398
-		$suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
399
-	}
400
-	$points = $suite;
401
-
402
-	// trop court ? ne pas faire de (...)
403
-	if (spip_strlen($court) < max(0.75 * $taille, 2)) {
404
-		$points = '';
405
-		$long = spip_substr($texte, 0, $taille);
406
-		$texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
407
-		// encore trop court ? couper au caractere
408
-		if (spip_strlen($texte) < 0.75 * $taille) {
409
-			$texte = $long;
410
-		}
411
-	} else {
412
-		$texte = $court;
413
-	}
414
-
415
-	if (strpos($texte, "\n")) {  // la fin est encore la : c'est qu'on n'a pas de texte de suite
416
-	$points = '';
417
-	}
418
-
419
-	// remettre les paragraphes
420
-	$texte = preg_replace("/\r+/", "\n\n", $texte);
421
-
422
-	// supprimer l'eventuelle entite finale mal coupee
423
-	$texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
424
-
425
-	return quote_amp(trim($texte)) . $points;
345
+    if (!($length = strlen($texte)) or $taille <= 0) {
346
+        return '';
347
+    }
348
+    $offset = 400 + 2 * $taille;
349
+    while (
350
+        $offset < $length
351
+        and strlen(preg_replace(',<(!--|\w|/)[^>]+>,Uims', '', substr($texte, 0, $offset))) < $taille
352
+    ) {
353
+        $offset = 2 * $offset;
354
+    }
355
+    if (
356
+        $offset < $length
357
+        && ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== null
358
+    ) {
359
+        $p_tag_fermant = strpos($texte, '>', $offset);
360
+        if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant)) {
361
+            $offset = $p_tag_fermant + 1;
362
+        } // prolonger la coupe jusqu'au tag fermant suivant eventuel
363
+    }
364
+    $texte = substr($texte, 0, $offset); /* eviter de travailler sur 10ko pour extraire 150 caracteres */
365
+
366
+    if (!function_exists('nettoyer_raccourcis_typo')) {
367
+        include_spip('inc/lien');
368
+    }
369
+    $texte = nettoyer_raccourcis_typo($texte);
370
+
371
+    // balises de sauts de ligne et paragraphe
372
+    $texte = preg_replace('/<p( [^>]*)?' . '>/', "\r", $texte);
373
+    $texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte);
374
+
375
+    // on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
376
+    $texte = str_replace("\n\n", "\r", $texte);
377
+
378
+    // supprimer les tags
379
+    $texte = supprimer_tags($texte);
380
+    $texte = trim(str_replace("\n", ' ', $texte));
381
+    $texte .= "\n";  // marquer la fin
382
+
383
+    // corriger la longueur de coupe
384
+    // en fonction de la presence de caracteres utf
385
+    if ($GLOBALS['meta']['charset'] == 'utf-8') {
386
+        $long = charset2unicode($texte);
387
+        $long = spip_substr($long, 0, max($taille, 1));
388
+        $nbcharutf = preg_match_all('/(&#[0-9]{3,6};)/S', $long, $matches);
389
+        $taille += $nbcharutf;
390
+    }
391
+
392
+
393
+    // couper au mot precedent
394
+    $long = spip_substr($texte, 0, max($taille - 4, 1));
395
+    $u = $GLOBALS['meta']['pcre_u'];
396
+    $court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
397
+    if (is_null($suite)) {
398
+        $suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
399
+    }
400
+    $points = $suite;
401
+
402
+    // trop court ? ne pas faire de (...)
403
+    if (spip_strlen($court) < max(0.75 * $taille, 2)) {
404
+        $points = '';
405
+        $long = spip_substr($texte, 0, $taille);
406
+        $texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
407
+        // encore trop court ? couper au caractere
408
+        if (spip_strlen($texte) < 0.75 * $taille) {
409
+            $texte = $long;
410
+        }
411
+    } else {
412
+        $texte = $court;
413
+    }
414
+
415
+    if (strpos($texte, "\n")) {  // la fin est encore la : c'est qu'on n'a pas de texte de suite
416
+    $points = '';
417
+    }
418
+
419
+    // remettre les paragraphes
420
+    $texte = preg_replace("/\r+/", "\n\n", $texte);
421
+
422
+    // supprimer l'eventuelle entite finale mal coupee
423
+    $texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
424
+
425
+    return quote_amp(trim($texte)) . $points;
426 426
 }
427 427
 
428 428
 
429 429
 function protege_js_modeles($t) {
430
-	if (isset($GLOBALS['visiteur_session'])) {
431
-		if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) {
432
-			if (!defined('_PROTEGE_JS_MODELES')) {
433
-				include_spip('inc/acces');
434
-				define('_PROTEGE_JS_MODELES', creer_uniqid());
435
-			}
436
-			foreach ($r as $regs) {
437
-				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
438
-			}
439
-		}
440
-		if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
441
-			if (!defined('_PROTEGE_PHP_MODELES')) {
442
-				include_spip('inc/acces');
443
-				define('_PROTEGE_PHP_MODELES', creer_uniqid());
444
-			}
445
-			foreach ($r as $regs) {
446
-				$t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
447
-			}
448
-		}
449
-	}
450
-
451
-	return $t;
430
+    if (isset($GLOBALS['visiteur_session'])) {
431
+        if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) {
432
+            if (!defined('_PROTEGE_JS_MODELES')) {
433
+                include_spip('inc/acces');
434
+                define('_PROTEGE_JS_MODELES', creer_uniqid());
435
+            }
436
+            foreach ($r as $regs) {
437
+                $t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
438
+            }
439
+        }
440
+        if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
441
+            if (!defined('_PROTEGE_PHP_MODELES')) {
442
+                include_spip('inc/acces');
443
+                define('_PROTEGE_PHP_MODELES', creer_uniqid());
444
+            }
445
+            foreach ($r as $regs) {
446
+                $t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
447
+            }
448
+        }
449
+    }
450
+
451
+    return $t;
452 452
 }
453 453
 
454 454
 
455 455
 function echapper_faux_tags($letexte) {
456
-	if (strpos($letexte, '<') === false) {
457
-		return $letexte;
458
-	}
459
-	$textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, -1, PREG_SPLIT_DELIM_CAPTURE);
460
-
461
-	$letexte = '';
462
-	while (is_countable($textMatches) ? count($textMatches) : 0) {
463
-		// un texte a echapper
464
-		$letexte .= str_replace('<', '&lt;', array_shift($textMatches));
465
-		// un tag html qui a servit a faite le split
466
-		$letexte .= array_shift($textMatches);
467
-	}
468
-
469
-	return $letexte;
456
+    if (strpos($letexte, '<') === false) {
457
+        return $letexte;
458
+    }
459
+    $textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, -1, PREG_SPLIT_DELIM_CAPTURE);
460
+
461
+    $letexte = '';
462
+    while (is_countable($textMatches) ? count($textMatches) : 0) {
463
+        // un texte a echapper
464
+        $letexte .= str_replace('<', '&lt;', array_shift($textMatches));
465
+        // un tag html qui a servit a faite le split
466
+        $letexte .= array_shift($textMatches);
467
+    }
468
+
469
+    return $letexte;
470 470
 }
471 471
 
472 472
 /**
@@ -479,47 +479,47 @@  discard block
 block discarded – undo
479 479
  * @return string
480 480
  */
481 481
 function echapper_html_suspect($texte, $strict = true) {
482
-	static $echapper_html_suspect;
483
-	if (!$texte or !is_string($texte)) {
484
-		return $texte;
485
-	}
486
-
487
-	if (!isset($echapper_html_suspect)) {
488
-		$echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true);
489
-	}
490
-	// si fonction personalisee, on delegue
491
-	if ($echapper_html_suspect) {
492
-		return $echapper_html_suspect($texte, $strict);
493
-	}
494
-
495
-	if (
496
-		strpos($texte, '<') === false
497
-		or strpos($texte, '=') === false
498
-	) {
499
-		return $texte;
500
-	}
501
-
502
-	// quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx=
503
-	// car sinon on declenche sur les modeles ou ressources
504
-	if (
505
-		!$strict and
506
-		(strpos($texte, 'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
507
-	) {
508
-		return $texte;
509
-	}
510
-
511
-	// on teste sur strlen car safehtml supprime le contenu dangereux
512
-	// mais il peut aussi changer des ' en " sur les attributs html,
513
-	// donc un test d'egalite est trop strict
514
-	if (strlen(safehtml($texte)) !== strlen($texte)) {
515
-		$texte = str_replace('<', '&lt;', $texte);
516
-		if (!function_exists('attribut_html')) {
517
-			include_spip('inc/filtres');
518
-		}
519
-		$texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte;
520
-	}
521
-
522
-	return $texte;
482
+    static $echapper_html_suspect;
483
+    if (!$texte or !is_string($texte)) {
484
+        return $texte;
485
+    }
486
+
487
+    if (!isset($echapper_html_suspect)) {
488
+        $echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true);
489
+    }
490
+    // si fonction personalisee, on delegue
491
+    if ($echapper_html_suspect) {
492
+        return $echapper_html_suspect($texte, $strict);
493
+    }
494
+
495
+    if (
496
+        strpos($texte, '<') === false
497
+        or strpos($texte, '=') === false
498
+    ) {
499
+        return $texte;
500
+    }
501
+
502
+    // quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx=
503
+    // car sinon on declenche sur les modeles ou ressources
504
+    if (
505
+        !$strict and
506
+        (strpos($texte, 'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
507
+    ) {
508
+        return $texte;
509
+    }
510
+
511
+    // on teste sur strlen car safehtml supprime le contenu dangereux
512
+    // mais il peut aussi changer des ' en " sur les attributs html,
513
+    // donc un test d'egalite est trop strict
514
+    if (strlen(safehtml($texte)) !== strlen($texte)) {
515
+        $texte = str_replace('<', '&lt;', $texte);
516
+        if (!function_exists('attribut_html')) {
517
+            include_spip('inc/filtres');
518
+        }
519
+        $texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte;
520
+    }
521
+
522
+    return $texte;
523 523
 }
524 524
 
525 525
 
@@ -540,30 +540,30 @@  discard block
 block discarded – undo
540 540
  *      Texte sécurisé
541 541
  **/
542 542
 function safehtml($t) {
543
-	static $safehtml;
544
-
545
-	if (!$t or !is_string($t)) {
546
-		return $t;
547
-	}
548
-	# attention safehtml nettoie deux ou trois caracteres de plus. A voir
549
-	if (strpos($t, '<') === false) {
550
-		return str_replace("\x00", '', $t);
551
-	}
552
-
553
-	if (!function_exists('interdire_scripts')) {
554
-		include_spip('inc/texte');
555
-	}
556
-	$t = interdire_scripts($t); // jolifier le php
557
-	$t = echappe_js($t);
558
-
559
-	if (!isset($safehtml)) {
560
-		$safehtml = charger_fonction('safehtml', 'inc', true);
561
-	}
562
-	if ($safehtml) {
563
-		$t = $safehtml($t);
564
-	}
565
-
566
-	return interdire_scripts($t); // interdire le php (2 precautions)
543
+    static $safehtml;
544
+
545
+    if (!$t or !is_string($t)) {
546
+        return $t;
547
+    }
548
+    # attention safehtml nettoie deux ou trois caracteres de plus. A voir
549
+    if (strpos($t, '<') === false) {
550
+        return str_replace("\x00", '', $t);
551
+    }
552
+
553
+    if (!function_exists('interdire_scripts')) {
554
+        include_spip('inc/texte');
555
+    }
556
+    $t = interdire_scripts($t); // jolifier le php
557
+    $t = echappe_js($t);
558
+
559
+    if (!isset($safehtml)) {
560
+        $safehtml = charger_fonction('safehtml', 'inc', true);
561
+    }
562
+    if ($safehtml) {
563
+        $t = $safehtml($t);
564
+    }
565
+
566
+    return interdire_scripts($t); // interdire le php (2 precautions)
567 567
 }
568 568
 
569 569
 
@@ -585,13 +585,13 @@  discard block
 block discarded – undo
585 585
  *     Texte sans les modèles d'image
586 586
  **/
587 587
 function supprime_img($letexte, $message = null) {
588
-	if ($message === null) {
589
-		$message = '(' . _T('img_indisponible') . ')';
590
-	}
591
-
592
-	return preg_replace(
593
-		',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
594
-		$message,
595
-		$letexte
596
-	);
588
+    if ($message === null) {
589
+        $message = '(' . _T('img_indisponible') . ')';
590
+    }
591
+
592
+    return preg_replace(
593
+        ',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
594
+        $message,
595
+        $letexte
596
+    );
597 597
 }
Please login to merge, or discard this patch.
ecrire/base/upgrade.php 1 patch
Indentation   +284 added lines, -284 removed lines patch added patch discarded remove patch
@@ -17,17 +17,17 @@  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
 if (!defined('_UPGRADE_TIME_OUT')) {
24
-	/**
25
-	 * Durée en secondes pour relancer les scripts de mises à jour, x secondes
26
-	 * avant que la durée d'exécution du script provoque un timeout
27
-	 *
28
-	 * @var int
29
-	 **/
30
-	define('_UPGRADE_TIME_OUT', 20);
24
+    /**
25
+     * Durée en secondes pour relancer les scripts de mises à jour, x secondes
26
+     * avant que la durée d'exécution du script provoque un timeout
27
+     *
28
+     * @var int
29
+     **/
30
+    define('_UPGRADE_TIME_OUT', 20);
31 31
 }
32 32
 
33 33
 /**
@@ -50,40 +50,40 @@  discard block
 block discarded – undo
50 50
  * @return void
51 51
  */
52 52
 function base_upgrade_dist($titre = '', $reprise = '') {
53
-	if (!$titre) {
54
-		return;
55
-	} // anti-testeur automatique
56
-	if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) {
57
-		if (!is_numeric(_request('reinstall'))) {
58
-			include_spip('base/create');
59
-			spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE);
60
-			creer_base();
61
-		}
62
-
63
-		// quand on rentre par ici, c'est toujours une mise a jour de SPIP
64
-		// lancement de l'upgrade SPIP
65
-		$res = maj_base();
66
-
67
-		if ($res) {
68
-			// on arrete tout ici !
69
-			exit;
70
-		}
71
-	}
72
-	spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE);
73
-
74
-	// supprimer quelques fichiers temporaires qui peuvent se retrouver invalides
75
-	@spip_unlink(_CACHE_RUBRIQUES);
76
-	@spip_unlink(_CACHE_PIPELINES);
77
-	@spip_unlink(_CACHE_PLUGINS_PATH);
78
-	@spip_unlink(_CACHE_PLUGINS_OPT);
79
-	@spip_unlink(_CACHE_PLUGINS_FCT);
80
-	@spip_unlink(_CACHE_CHEMIN);
81
-	@spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz');
82
-
83
-	include_spip('inc/auth');
84
-	auth_synchroniser_distant();
85
-	$config = charger_fonction('config', 'inc');
86
-	$config();
53
+    if (!$titre) {
54
+        return;
55
+    } // anti-testeur automatique
56
+    if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) {
57
+        if (!is_numeric(_request('reinstall'))) {
58
+            include_spip('base/create');
59
+            spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE);
60
+            creer_base();
61
+        }
62
+
63
+        // quand on rentre par ici, c'est toujours une mise a jour de SPIP
64
+        // lancement de l'upgrade SPIP
65
+        $res = maj_base();
66
+
67
+        if ($res) {
68
+            // on arrete tout ici !
69
+            exit;
70
+        }
71
+    }
72
+    spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE);
73
+
74
+    // supprimer quelques fichiers temporaires qui peuvent se retrouver invalides
75
+    @spip_unlink(_CACHE_RUBRIQUES);
76
+    @spip_unlink(_CACHE_PIPELINES);
77
+    @spip_unlink(_CACHE_PLUGINS_PATH);
78
+    @spip_unlink(_CACHE_PLUGINS_OPT);
79
+    @spip_unlink(_CACHE_PLUGINS_FCT);
80
+    @spip_unlink(_CACHE_CHEMIN);
81
+    @spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz');
82
+
83
+    include_spip('inc/auth');
84
+    auth_synchroniser_distant();
85
+    $config = charger_fonction('config', 'inc');
86
+    $config();
87 87
 }
88 88
 
89 89
 /**
@@ -114,51 +114,51 @@  discard block
 block discarded – undo
114 114
  */
115 115
 function maj_base($version_cible = 0, $redirect = '', $debut_page = true) {
116 116
 
117
-	$version_installee = $GLOBALS['meta']['version_installee'] ?? null;
118
-
119
-	spip_log(
120
-		"Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'],
121
-		'maj.' . _LOG_INFO_IMPORTANTE
122
-	);
123
-	if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) {
124
-		sql_replace(
125
-			'spip_meta',
126
-			[
127
-				'nom' => 'version_installee',
128
-				'valeur' => $GLOBALS['spip_version_base'],
129
-				'impt' => 'non'
130
-			]
131
-		);
132
-		return false;
133
-	}
134
-	if (!upgrade_test()) {
135
-		return true;
136
-	}
137
-
138
-	$cible = ($version_cible ?: $GLOBALS['spip_version_base']);
139
-
140
-	if ($version_installee < 2021_01_01_00) {
141
-		include_spip('maj/legacy/v21');
142
-		include_spip('maj/legacy/v30');
143
-		include_spip('maj/legacy/v31');
144
-		include_spip('maj/legacy/v32');
145
-		include_spip('maj/legacy/v40');
146
-	}
147
-
148
-	include_spip('maj/2021');
149
-
150
-	ksort($GLOBALS['maj']);
151
-	$res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page);
152
-	if ($res) {
153
-		if (!is_array($res)) {
154
-			spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR);
155
-		} else {
156
-			echo _T('avis_operation_echec') . ' ' . join(' ', $res);
157
-			echo install_fin_html();
158
-		}
159
-	}
160
-
161
-	return $res;
117
+    $version_installee = $GLOBALS['meta']['version_installee'] ?? null;
118
+
119
+    spip_log(
120
+        "Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'],
121
+        'maj.' . _LOG_INFO_IMPORTANTE
122
+    );
123
+    if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) {
124
+        sql_replace(
125
+            'spip_meta',
126
+            [
127
+                'nom' => 'version_installee',
128
+                'valeur' => $GLOBALS['spip_version_base'],
129
+                'impt' => 'non'
130
+            ]
131
+        );
132
+        return false;
133
+    }
134
+    if (!upgrade_test()) {
135
+        return true;
136
+    }
137
+
138
+    $cible = ($version_cible ?: $GLOBALS['spip_version_base']);
139
+
140
+    if ($version_installee < 2021_01_01_00) {
141
+        include_spip('maj/legacy/v21');
142
+        include_spip('maj/legacy/v30');
143
+        include_spip('maj/legacy/v31');
144
+        include_spip('maj/legacy/v32');
145
+        include_spip('maj/legacy/v40');
146
+    }
147
+
148
+    include_spip('maj/2021');
149
+
150
+    ksort($GLOBALS['maj']);
151
+    $res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page);
152
+    if ($res) {
153
+        if (!is_array($res)) {
154
+            spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR);
155
+        } else {
156
+            echo _T('avis_operation_echec') . ' ' . join(' ', $res);
157
+            echo install_fin_html();
158
+        }
159
+    }
160
+
161
+    return $res;
162 162
 }
163 163
 
164 164
 /**
@@ -200,53 +200,53 @@  discard block
 block discarded – undo
200 200
  */
201 201
 function maj_plugin($nom_meta_base_version, $version_cible, $maj, $table_meta = 'meta') {
202 202
 
203
-	if ($table_meta !== 'meta') {
204
-		installer_table_meta($table_meta);
205
-	}
206
-
207
-	$current_version = null;
208
-
209
-	if (
210
-		(!isset($GLOBALS[$table_meta][$nom_meta_base_version]))
211
-		|| (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version], $version_cible, '='))
212
-	) {
213
-		// $maj['create'] contient les directives propres a la premiere creation de base
214
-		// c'est une operation derogatoire qui fait aboutir directement dans la version_cible
215
-		if (isset($maj['create'])) {
216
-			if (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) {
217
-				// installation : on ne fait que l'operation create
218
-				$maj = ['init' => $maj['create']];
219
-				// et on lui ajoute un appel a inc/config
220
-				// pour creer les metas par defaut
221
-				$config = charger_fonction('config', 'inc');
222
-				$maj[$version_cible] = [[$config]];
223
-			}
224
-			// dans tous les cas enlever cet index du tableau
225
-			unset($maj['create']);
226
-		}
227
-		// si init, deja dans le bon ordre
228
-		if (!isset($maj['init'])) {
229
-			include_spip('inc/plugin'); // pour spip_version_compare
230
-			uksort($maj, 'spip_version_compare');
231
-		}
232
-
233
-		// la redirection se fait par defaut sur la page d'administration des plugins
234
-		// sauf lorsque nous sommes sur l'installation de SPIP
235
-		// ou define _REDIRECT_MAJ_PLUGIN
236
-		$redirect = (defined('_REDIRECT_MAJ_PLUGIN') ? _REDIRECT_MAJ_PLUGIN : generer_url_ecrire('admin_plugin'));
237
-		if (defined('_ECRIRE_INSTALL')) {
238
-			$redirect = parametre_url(generer_url_ecrire('install'), 'etape', _request('etape'));
239
-		}
240
-
241
-		$res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect);
242
-		if ($res) {
243
-			if (!is_array($res)) {
244
-				spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR);
245
-			} else {
246
-				echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>';
247
-			}
248
-		}
249
-	}
203
+    if ($table_meta !== 'meta') {
204
+        installer_table_meta($table_meta);
205
+    }
206
+
207
+    $current_version = null;
208
+
209
+    if (
210
+        (!isset($GLOBALS[$table_meta][$nom_meta_base_version]))
211
+        || (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version], $version_cible, '='))
212
+    ) {
213
+        // $maj['create'] contient les directives propres a la premiere creation de base
214
+        // c'est une operation derogatoire qui fait aboutir directement dans la version_cible
215
+        if (isset($maj['create'])) {
216
+            if (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) {
217
+                // installation : on ne fait que l'operation create
218
+                $maj = ['init' => $maj['create']];
219
+                // et on lui ajoute un appel a inc/config
220
+                // pour creer les metas par defaut
221
+                $config = charger_fonction('config', 'inc');
222
+                $maj[$version_cible] = [[$config]];
223
+            }
224
+            // dans tous les cas enlever cet index du tableau
225
+            unset($maj['create']);
226
+        }
227
+        // si init, deja dans le bon ordre
228
+        if (!isset($maj['init'])) {
229
+            include_spip('inc/plugin'); // pour spip_version_compare
230
+            uksort($maj, 'spip_version_compare');
231
+        }
232
+
233
+        // la redirection se fait par defaut sur la page d'administration des plugins
234
+        // sauf lorsque nous sommes sur l'installation de SPIP
235
+        // ou define _REDIRECT_MAJ_PLUGIN
236
+        $redirect = (defined('_REDIRECT_MAJ_PLUGIN') ? _REDIRECT_MAJ_PLUGIN : generer_url_ecrire('admin_plugin'));
237
+        if (defined('_ECRIRE_INSTALL')) {
238
+            $redirect = parametre_url(generer_url_ecrire('install'), 'etape', _request('etape'));
239
+        }
240
+
241
+        $res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect);
242
+        if ($res) {
243
+            if (!is_array($res)) {
244
+                spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR);
245
+            } else {
246
+                echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>';
247
+            }
248
+        }
249
+    }
250 250
 }
251 251
 
252 252
 /**
@@ -263,17 +263,17 @@  discard block
 block discarded – undo
263 263
  * @return void
264 264
  */
265 265
 function relance_maj($meta, $table, $redirect = '') {
266
-	include_spip('inc/headers');
267
-	if (!$redirect) {
268
-		// recuperer la valeur installee en cours
269
-		// on la tronque numeriquement, elle ne sert pas reellement
270
-		// sauf pour verifier que ce n'est pas oui ou non
271
-		// sinon is_numeric va echouer sur un numero de version 1.2.3
272
-		$installee = intval($GLOBALS[$table][$meta]);
273
-		$redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true);
274
-	}
275
-	echo redirige_formulaire($redirect);
276
-	exit();
266
+    include_spip('inc/headers');
267
+    if (!$redirect) {
268
+        // recuperer la valeur installee en cours
269
+        // on la tronque numeriquement, elle ne sert pas reellement
270
+        // sauf pour verifier que ce n'est pas oui ou non
271
+        // sinon is_numeric va echouer sur un numero de version 1.2.3
272
+        $installee = intval($GLOBALS[$table][$meta]);
273
+        $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true);
274
+    }
275
+    echo redirige_formulaire($redirect);
276
+    exit();
277 277
 }
278 278
 
279 279
 /**
@@ -286,28 +286,28 @@  discard block
 block discarded – undo
286 286
  * @return void
287 287
  */
288 288
 function maj_debut_page($installee, $meta, $table) {
289
-	static $done = false;
290
-	if ($done) {
291
-		return;
292
-	}
293
-	include_spip('inc/minipres');
294
-	if (function_exists('ini_set')) {
295
-		@ini_set('zlib.output_compression', '0'); // pour permettre l'affichage au fur et a mesure
296
-	}
297
-	$timeout = _UPGRADE_TIME_OUT * 2;
298
-	$titre = _T('titre_page_upgrade');
299
-	$balise_img = charger_filtre('balise_img');
300
-	$titre .= $balise_img(chemin_image('loader.svg'), '', 'loader');
301
-	echo(install_debut_html($titre));
302
-	// script de rechargement auto sur timeout
303
-	$redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true);
304
-	echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')');
305
-	echo "<div style='text-align: left'>\n";
306
-	if (ob_get_level()) {
307
-		ob_flush();
308
-	}
309
-	flush();
310
-	$done = true;
289
+    static $done = false;
290
+    if ($done) {
291
+        return;
292
+    }
293
+    include_spip('inc/minipres');
294
+    if (function_exists('ini_set')) {
295
+        @ini_set('zlib.output_compression', '0'); // pour permettre l'affichage au fur et a mesure
296
+    }
297
+    $timeout = _UPGRADE_TIME_OUT * 2;
298
+    $titre = _T('titre_page_upgrade');
299
+    $balise_img = charger_filtre('balise_img');
300
+    $titre .= $balise_img(chemin_image('loader.svg'), '', 'loader');
301
+    echo(install_debut_html($titre));
302
+    // script de rechargement auto sur timeout
303
+    $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true);
304
+    echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')');
305
+    echo "<div style='text-align: left'>\n";
306
+    if (ob_get_level()) {
307
+        ob_flush();
308
+    }
309
+    flush();
310
+    $done = true;
311 311
 }
312 312
 
313 313
 
@@ -351,64 +351,64 @@  discard block
 block discarded – undo
351 351
  *    - tableau vide sinon.
352 352
  */
353 353
 function maj_while($installee, $cible, $maj, $meta = '', $table = 'meta', $redirect = '', $debut_page = false) {
354
-	# inclusions pour que les procedures d'upgrade disposent des fonctions de base
355
-	include_spip('base/create');
356
-	include_spip('base/abstract_sql');
357
-	$trouver_table = charger_fonction('trouver_table', 'base');
358
-	include_spip('inc/plugin'); // pour spip_version_compare
359
-	$n = 0;
360
-	$time = time();
361
-
362
-	if (!defined('_TIME_OUT')) {
363
-		/**
364
-		 * Définir le timeout qui peut-être utilisé dans les fonctions
365
-		 * de mises à jour qui durent trop longtemps
366
-		 *
367
-		 * À utiliser tel que : `if (time() >= _TIME_OUT)`
368
-		 *
369
-		 * @var int
370
-		 */
371
-		define('_TIME_OUT', $time + _UPGRADE_TIME_OUT);
372
-	}
373
-
374
-	foreach ($maj as $v => $operations) {
375
-		// si une maj pour cette version
376
-		if (
377
-			$v == 'init' or
378
-			(spip_version_compare($v, $installee, '>')
379
-				and spip_version_compare($v, $cible, '<='))
380
-		) {
381
-			if ($debut_page) {
382
-				maj_debut_page($v, $meta, $table);
383
-			}
384
-			echo "MAJ $v";
385
-			$etape = serie_alter($v, $operations, $meta, $table, $redirect);
386
-			$trouver_table(''); // vider le cache des descriptions de table
387
-			# echec sur une etape en cours ?
388
-			# on sort
389
-			if ($etape) {
390
-				return [$v, $etape];
391
-			}
392
-			$n = time() - $time;
393
-			spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE);
394
-			if ($meta) {
395
-				ecrire_meta($meta, $installee = $v, 'oui', $table);
396
-			}
397
-			echo (_IS_CLI ? "\n" : '<br />');
398
-		}
399
-		if (time() >= _TIME_OUT) {
400
-			relance_maj($meta, $table, $redirect);
401
-		}
402
-	}
403
-	$trouver_table(''); // vider le cache des descriptions de table
404
-	// indispensable pour les chgt de versions qui n'ecrivent pas en base
405
-	// tant pis pour la redondance eventuelle avec ci-dessus
406
-	if ($meta) {
407
-		ecrire_meta($meta, $cible, 'oui', $table);
408
-	}
409
-	spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE);
410
-
411
-	return [];
354
+    # inclusions pour que les procedures d'upgrade disposent des fonctions de base
355
+    include_spip('base/create');
356
+    include_spip('base/abstract_sql');
357
+    $trouver_table = charger_fonction('trouver_table', 'base');
358
+    include_spip('inc/plugin'); // pour spip_version_compare
359
+    $n = 0;
360
+    $time = time();
361
+
362
+    if (!defined('_TIME_OUT')) {
363
+        /**
364
+         * Définir le timeout qui peut-être utilisé dans les fonctions
365
+         * de mises à jour qui durent trop longtemps
366
+         *
367
+         * À utiliser tel que : `if (time() >= _TIME_OUT)`
368
+         *
369
+         * @var int
370
+         */
371
+        define('_TIME_OUT', $time + _UPGRADE_TIME_OUT);
372
+    }
373
+
374
+    foreach ($maj as $v => $operations) {
375
+        // si une maj pour cette version
376
+        if (
377
+            $v == 'init' or
378
+            (spip_version_compare($v, $installee, '>')
379
+                and spip_version_compare($v, $cible, '<='))
380
+        ) {
381
+            if ($debut_page) {
382
+                maj_debut_page($v, $meta, $table);
383
+            }
384
+            echo "MAJ $v";
385
+            $etape = serie_alter($v, $operations, $meta, $table, $redirect);
386
+            $trouver_table(''); // vider le cache des descriptions de table
387
+            # echec sur une etape en cours ?
388
+            # on sort
389
+            if ($etape) {
390
+                return [$v, $etape];
391
+            }
392
+            $n = time() - $time;
393
+            spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE);
394
+            if ($meta) {
395
+                ecrire_meta($meta, $installee = $v, 'oui', $table);
396
+            }
397
+            echo (_IS_CLI ? "\n" : '<br />');
398
+        }
399
+        if (time() >= _TIME_OUT) {
400
+            relance_maj($meta, $table, $redirect);
401
+        }
402
+    }
403
+    $trouver_table(''); // vider le cache des descriptions de table
404
+    // indispensable pour les chgt de versions qui n'ecrivent pas en base
405
+    // tant pis pour la redondance eventuelle avec ci-dessus
406
+    if ($meta) {
407
+        ecrire_meta($meta, $cible, 'oui', $table);
408
+    }
409
+    spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE);
410
+
411
+    return [];
412 412
 }
413 413
 
414 414
 /**
@@ -431,53 +431,53 @@  discard block
 block discarded – undo
431 431
  * @return int
432 432
  */
433 433
 function serie_alter($serie, $q = [], $meta = '', $table = 'meta', $redirect = '') {
434
-	$meta2 = $meta . '_maj_' . $serie;
435
-	$etape = 0;
436
-	if (isset($GLOBALS[$table][$meta2])) {
437
-		$etape = intval($GLOBALS[$table][$meta2]);
438
-	}
439
-	foreach ($q as $i => $r) {
440
-		if ($i >= $etape) {
441
-			$msg = "maj $table $meta2 etape $i";
442
-			if (
443
-				is_array($r)
444
-				and function_exists($f = array_shift($r))
445
-			) {
446
-				// note: $r (arguments de la fonction $f) peut avoir des données tabulaires
447
-				spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE);
448
-				// pour les fonctions atomiques sql_xx
449
-				// on enregistre le meta avant de lancer la fonction,
450
-				// de maniere a eviter de boucler sur timeout
451
-				// mais pour les fonctions complexes,
452
-				// il faut les rejouer jusqu'a achevement.
453
-				// C'est a elle d'assurer qu'elles progressent a chaque rappel
454
-				if (strncmp($f, 'sql_', 4) == 0) {
455
-					ecrire_meta($meta2, $i + 1, 'non', $table);
456
-				}
457
-				echo (_IS_CLI ? '.' : " <span title='$i'>.</span>");
458
-				call_user_func_array($f, $r);
459
-				// si temps imparti depasse, on relance sans ecrire en meta
460
-				// car on est peut etre sorti sur timeout si c'est une fonction longue
461
-				if (time() >= _TIME_OUT) {
462
-					relance_maj($meta, $table, $redirect);
463
-				}
464
-				ecrire_meta($meta2, $i + 1, 'non', $table);
465
-				spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE);
466
-			} else {
467
-				if (!is_array($r)) {
468
-					spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR);
469
-				} else {
470
-					spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR);
471
-				}
472
-				// en cas d'erreur serieuse, on s'arrete
473
-				// mais on permet de passer par dessus en rechargeant la page.
474
-				return $i + 1;
475
-			}
476
-		}
477
-	}
478
-	effacer_meta($meta2, $table);
479
-
480
-	return 0;
434
+    $meta2 = $meta . '_maj_' . $serie;
435
+    $etape = 0;
436
+    if (isset($GLOBALS[$table][$meta2])) {
437
+        $etape = intval($GLOBALS[$table][$meta2]);
438
+    }
439
+    foreach ($q as $i => $r) {
440
+        if ($i >= $etape) {
441
+            $msg = "maj $table $meta2 etape $i";
442
+            if (
443
+                is_array($r)
444
+                and function_exists($f = array_shift($r))
445
+            ) {
446
+                // note: $r (arguments de la fonction $f) peut avoir des données tabulaires
447
+                spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE);
448
+                // pour les fonctions atomiques sql_xx
449
+                // on enregistre le meta avant de lancer la fonction,
450
+                // de maniere a eviter de boucler sur timeout
451
+                // mais pour les fonctions complexes,
452
+                // il faut les rejouer jusqu'a achevement.
453
+                // C'est a elle d'assurer qu'elles progressent a chaque rappel
454
+                if (strncmp($f, 'sql_', 4) == 0) {
455
+                    ecrire_meta($meta2, $i + 1, 'non', $table);
456
+                }
457
+                echo (_IS_CLI ? '.' : " <span title='$i'>.</span>");
458
+                call_user_func_array($f, $r);
459
+                // si temps imparti depasse, on relance sans ecrire en meta
460
+                // car on est peut etre sorti sur timeout si c'est une fonction longue
461
+                if (time() >= _TIME_OUT) {
462
+                    relance_maj($meta, $table, $redirect);
463
+                }
464
+                ecrire_meta($meta2, $i + 1, 'non', $table);
465
+                spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE);
466
+            } else {
467
+                if (!is_array($r)) {
468
+                    spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR);
469
+                } else {
470
+                    spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR);
471
+                }
472
+                // en cas d'erreur serieuse, on s'arrete
473
+                // mais on permet de passer par dessus en rechargeant la page.
474
+                return $i + 1;
475
+            }
476
+        }
477
+    }
478
+    effacer_meta($meta2, $table);
479
+
480
+    return 0;
481 481
 }
482 482
 
483 483
 /**
@@ -486,16 +486,16 @@  discard block
 block discarded – undo
486 486
  * @return bool True si possible.
487 487
  **/
488 488
 function upgrade_test() {
489
-	sql_drop_table('spip_test', true);
490
-	sql_create('spip_test', ['a' => 'int']);
491
-	sql_alter('TABLE spip_test ADD b INT');
492
-	sql_insertq('spip_test', ['b' => 1], ['field' => ['b' => 'int']]);
493
-	$result = sql_select('b', 'spip_test');
494
-	// ne pas garder le resultat de la requete sinon sqlite3
495
-	// ne peut pas supprimer la table spip_test lors du sql_alter qui suit
496
-	// car cette table serait alors 'verouillee'
497
-	$result = $result ? true : false;
498
-	sql_alter('TABLE spip_test DROP b');
499
-
500
-	return $result;
489
+    sql_drop_table('spip_test', true);
490
+    sql_create('spip_test', ['a' => 'int']);
491
+    sql_alter('TABLE spip_test ADD b INT');
492
+    sql_insertq('spip_test', ['b' => 1], ['field' => ['b' => 'int']]);
493
+    $result = sql_select('b', 'spip_test');
494
+    // ne pas garder le resultat de la requete sinon sqlite3
495
+    // ne peut pas supprimer la table spip_test lors du sql_alter qui suit
496
+    // car cette table serait alors 'verouillee'
497
+    $result = $result ? true : false;
498
+    sql_alter('TABLE spip_test DROP b');
499
+
500
+    return $result;
501 501
 }
Please login to merge, or discard this patch.