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