Completed
Push — master ( 8b5a3c...b0cbd6 )
by cam
01:56
created
ecrire/bootstrap/inc/sanitize.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@  discard block
 block discarded – undo
9 9
  * @param bool $deep = true : appliquer récursivement
10 10
 **/
11 11
 function spip_desinfecte(&$t, $deep = true) {
12
-	foreach ($t as $key => $val) {
13
-		if (is_string($t[$key])) {
14
-			$t[$key] = str_replace(chr(0), '-', $t[$key]);
15
-		} // traiter aussi les "texte_plus" de article_edit
16
-		else {
17
-			if ($deep && is_array($t[$key]) && $key !== 'GLOBALS') {
18
-				spip_desinfecte($t[$key], $deep);
19
-			}
20
-		}
21
-	}
12
+    foreach ($t as $key => $val) {
13
+        if (is_string($t[$key])) {
14
+            $t[$key] = str_replace(chr(0), '-', $t[$key]);
15
+        } // traiter aussi les "texte_plus" de article_edit
16
+        else {
17
+            if ($deep && is_array($t[$key]) && $key !== 'GLOBALS') {
18
+                spip_desinfecte($t[$key], $deep);
19
+            }
20
+        }
21
+    }
22 22
 }
23 23
 
24 24
 /**
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
  * @return string|string[]
33 33
  */
34 34
 function spip_sanitize_classname($classes) {
35
-	if (is_array($classes)) {
36
-		return array_map('spip_sanitize_classname', $classes);
37
-	}
38
-	return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes);
35
+    if (is_array($classes)) {
36
+        return array_map('spip_sanitize_classname', $classes);
37
+    }
38
+    return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes);
39 39
 }
Please login to merge, or discard this patch.
ecrire/bootstrap/inc/jobs.php 2 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@  discard block
 block discarded – undo
7 7
  * @uses cron()
8 8
  **/
9 9
 function action_cron() {
10
-	include_spip('inc/headers');
11
-	http_response_code(204); // No Content
12
-	header('Connection: close');
13
-	define('_DIRECT_CRON_FORCE', true);
14
-	cron();
10
+    include_spip('inc/headers');
11
+    http_response_code(204); // No Content
12
+    header('Connection: close');
13
+    define('_DIRECT_CRON_FORCE', true);
14
+    cron();
15 15
 }
16 16
 
17 17
 /**
@@ -27,26 +27,26 @@  discard block
 block discarded – undo
27 27
  *     True si la tache a pu être effectuée
28 28
  */
29 29
 function cron($taches = [], $taches_old = []) {
30
-	// si pas en mode cron force, laisser tomber.
31
-	if (!defined('_DIRECT_CRON_FORCE')) {
32
-		return false;
33
-	}
34
-	if (!is_array($taches)) {
35
-		$taches = $taches_old;
36
-	} // compat anciens appels
37
-	// si taches a inserer en base et base inaccessible, laisser tomber
38
-	// sinon on ne verifie pas la connexion tout de suite, car si ca se trouve
39
-	// queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
40
-	// et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
41
-	if ($taches && count($taches) && !spip_connect()) {
42
-		return false;
43
-	}
44
-	spip_log('cron !', 'jq' . _LOG_DEBUG);
45
-	if ($genie = charger_fonction('genie', 'inc', true)) {
46
-		return $genie($taches);
47
-	}
30
+    // si pas en mode cron force, laisser tomber.
31
+    if (!defined('_DIRECT_CRON_FORCE')) {
32
+        return false;
33
+    }
34
+    if (!is_array($taches)) {
35
+        $taches = $taches_old;
36
+    } // compat anciens appels
37
+    // si taches a inserer en base et base inaccessible, laisser tomber
38
+    // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve
39
+    // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
40
+    // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
41
+    if ($taches && count($taches) && !spip_connect()) {
42
+        return false;
43
+    }
44
+    spip_log('cron !', 'jq' . _LOG_DEBUG);
45
+    if ($genie = charger_fonction('genie', 'inc', true)) {
46
+        return $genie($taches);
47
+    }
48 48
 
49
-	return false;
49
+    return false;
50 50
 }
51 51
 
52 52
 /**
@@ -78,17 +78,17 @@  discard block
 block discarded – undo
78 78
  *     Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté.
79 79
  */
80 80
 function job_queue_add(
81
-	$function,
82
-	$description,
83
-	$arguments = [],
84
-	$file = '',
85
-	$no_duplicate = false,
86
-	$time = 0,
87
-	$priority = 0
81
+    $function,
82
+    $description,
83
+    $arguments = [],
84
+    $file = '',
85
+    $no_duplicate = false,
86
+    $time = 0,
87
+    $priority = 0
88 88
 ) {
89
-	include_spip('inc/queue');
89
+    include_spip('inc/queue');
90 90
 
91
-	return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
91
+    return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
92 92
 }
93 93
 
94 94
 /**
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
  * @return bool
100 100
  */
101 101
 function job_queue_remove($id_job) {
102
-	include_spip('inc/queue');
102
+    include_spip('inc/queue');
103 103
 
104
-	return queue_remove_job($id_job);
104
+    return queue_remove_job($id_job);
105 105
 }
106 106
 
107 107
 /**
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
  *     or an array of simple array to link multiples objet in one time
115 115
  */
116 116
 function job_queue_link($id_job, $objets) {
117
-	include_spip('inc/queue');
117
+    include_spip('inc/queue');
118 118
 
119
-	return queue_link_job($id_job, $objets);
119
+    return queue_link_job($id_job, $objets);
120 120
 }
121 121
 
122 122
 
@@ -135,35 +135,35 @@  discard block
 block discarded – undo
135 135
  *  - `null` si la queue n'est pas encore initialisée
136 136
  */
137 137
 function queue_sleep_time_to_next_job($force = null) {
138
-	static $queue_next_job_time = -1;
139
-	if ($force === true) {
140
-		$queue_next_job_time = -1;
141
-	} elseif ($force) {
142
-		$queue_next_job_time = $force;
143
-	}
138
+    static $queue_next_job_time = -1;
139
+    if ($force === true) {
140
+        $queue_next_job_time = -1;
141
+    } elseif ($force) {
142
+        $queue_next_job_time = $force;
143
+    }
144 144
 
145
-	if ($queue_next_job_time == -1) {
146
-		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
147
-			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
148
-		}
149
-		// utiliser un cache memoire si dispo
150
-		if (function_exists('cache_get') && defined('_MEMOIZE_MEMORY') && _MEMOIZE_MEMORY) {
151
-			$queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
152
-		} else {
153
-			$queue_next_job_time = null;
154
-			$contenu = null;
155
-			if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) {
156
-				$queue_next_job_time = intval($contenu);
157
-			}
158
-		}
159
-	}
145
+    if ($queue_next_job_time == -1) {
146
+        if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
147
+            define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
148
+        }
149
+        // utiliser un cache memoire si dispo
150
+        if (function_exists('cache_get') && defined('_MEMOIZE_MEMORY') && _MEMOIZE_MEMORY) {
151
+            $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
152
+        } else {
153
+            $queue_next_job_time = null;
154
+            $contenu = null;
155
+            if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) {
156
+                $queue_next_job_time = intval($contenu);
157
+            }
158
+        }
159
+    }
160 160
 
161
-	if (is_null($queue_next_job_time)) {
162
-		return null;
163
-	}
164
-	if (!$_SERVER['REQUEST_TIME']) {
165
-		$_SERVER['REQUEST_TIME'] = time();
166
-	}
161
+    if (is_null($queue_next_job_time)) {
162
+        return null;
163
+    }
164
+    if (!$_SERVER['REQUEST_TIME']) {
165
+        $_SERVER['REQUEST_TIME'] = time();
166
+    }
167 167
 
168
-	return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
168
+    return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
169 169
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	if ($taches && count($taches) && !spip_connect()) {
42 42
 		return false;
43 43
 	}
44
-	spip_log('cron !', 'jq' . _LOG_DEBUG);
44
+	spip_log('cron !', 'jq'._LOG_DEBUG);
45 45
 	if ($genie = charger_fonction('genie', 'inc', true)) {
46 46
 		return $genie($taches);
47 47
 	}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 
145 145
 	if ($queue_next_job_time == -1) {
146 146
 		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
147
-			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt');
147
+			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP.'job_queue_next.txt');
148 148
 		}
149 149
 		// utiliser un cache memoire si dispo
150 150
 		if (function_exists('cache_get') && defined('_MEMOIZE_MEMORY') && _MEMOIZE_MEMORY) {
Please login to merge, or discard this patch.
ecrire/bootstrap/inc/logging.php 3 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -41,38 +41,38 @@  discard block
 block discarded – undo
41 41
  *     paramètre est planté pour cause de compatibilité ascendante.
42 42
  */
43 43
 function spip_log($message = null, $name = null) {
44
-	static $pre = [];
45
-	static $log;
46
-	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
47
-	if (!isset($regs[1]) || !$logname = $regs[1]) {
48
-		$logname = null;
49
-	}
50
-	if (!isset($regs[2])) {
51
-		$niveau = _LOG_INFO;
52
-	}
53
-	else {
54
-		$niveau = intval($regs[2]);
55
-	}
44
+    static $pre = [];
45
+    static $log;
46
+    preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
47
+    if (!isset($regs[1]) || !$logname = $regs[1]) {
48
+        $logname = null;
49
+    }
50
+    if (!isset($regs[2])) {
51
+        $niveau = _LOG_INFO;
52
+    }
53
+    else {
54
+        $niveau = intval($regs[2]);
55
+    }
56 56
 
57
-	if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) {
58
-		if (!$pre) {
59
-			$pre = [
60
-				_LOG_HS => 'HS:',
61
-				_LOG_ALERTE_ROUGE => 'ALERTE:',
62
-				_LOG_CRITIQUE => 'CRITIQUE:',
63
-				_LOG_ERREUR => 'ERREUR:',
64
-				_LOG_AVERTISSEMENT => 'WARNING:',
65
-				_LOG_INFO_IMPORTANTE => '!INFO:',
66
-				_LOG_INFO => 'info:',
67
-				_LOG_DEBUG => 'debug:'
68
-			];
69
-			$log = charger_fonction('log', 'inc');
70
-		}
71
-		if (!is_string($message)) {
72
-			$message = print_r($message, true);
73
-		}
74
-		$log($pre[$niveau] . ' ' . $message, $logname);
75
-	}
57
+    if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) {
58
+        if (!$pre) {
59
+            $pre = [
60
+                _LOG_HS => 'HS:',
61
+                _LOG_ALERTE_ROUGE => 'ALERTE:',
62
+                _LOG_CRITIQUE => 'CRITIQUE:',
63
+                _LOG_ERREUR => 'ERREUR:',
64
+                _LOG_AVERTISSEMENT => 'WARNING:',
65
+                _LOG_INFO_IMPORTANTE => '!INFO:',
66
+                _LOG_INFO => 'info:',
67
+                _LOG_DEBUG => 'debug:'
68
+            ];
69
+            $log = charger_fonction('log', 'inc');
70
+        }
71
+        if (!is_string($message)) {
72
+            $message = print_r($message, true);
73
+        }
74
+        $log($pre[$niveau] . ' ' . $message, $logname);
75
+    }
76 76
 }
77 77
 
78 78
 
@@ -84,6 +84,6 @@  discard block
 block discarded – undo
84 84
  * @param array $opt Tableau d'options
85 85
  **/
86 86
 function journal($phrase, $opt = []) {
87
-	$journal = charger_fonction('journal', 'inc');
88
-	$journal($phrase, $opt);
87
+    $journal = charger_fonction('journal', 'inc');
88
+    $journal($phrase, $opt);
89 89
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 function spip_log($message = null, $name = null) {
44 44
 	static $pre = [];
45 45
 	static $log;
46
-	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
46
+	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs);
47 47
 	if (!isset($regs[1]) || !$logname = $regs[1]) {
48 48
 		$logname = null;
49 49
 	}
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		if (!is_string($message)) {
72 72
 			$message = print_r($message, true);
73 73
 		}
74
-		$log($pre[$niveau] . ' ' . $message, $logname);
74
+		$log($pre[$niveau].' '.$message, $logname);
75 75
 	}
76 76
 }
77 77
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,8 +49,7 @@
 block discarded – undo
49 49
 	}
50 50
 	if (!isset($regs[2])) {
51 51
 		$niveau = _LOG_INFO;
52
-	}
53
-	else {
52
+	} else {
54 53
 		$niveau = intval($regs[2]);
55 54
 	}
56 55
 
Please login to merge, or discard this patch.
ecrire/bootstrap/inc/request.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -16,37 +16,37 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 function _request($var, $c = false) {
18 18
 
19
-	if (is_array($c)) {
20
-		return $c[$var] ?? null;
21
-	}
19
+    if (is_array($c)) {
20
+        return $c[$var] ?? null;
21
+    }
22 22
 
23
-	if (isset($_GET[$var])) {
24
-		$a = $_GET[$var];
25
-	} elseif (isset($_POST[$var])) {
26
-		$a = $_POST[$var];
27
-	} else {
28
-		return null;
29
-	}
23
+    if (isset($_GET[$var])) {
24
+        $a = $_GET[$var];
25
+    } elseif (isset($_POST[$var])) {
26
+        $a = $_POST[$var];
27
+    } else {
28
+        return null;
29
+    }
30 30
 
31
-	// Si on est en ajax et en POST tout a ete encode
32
-	// via encodeURIComponent, il faut donc repasser
33
-	// dans le charset local...
34
-	if (
35
-		defined('_AJAX')
36
-		&& _AJAX
37
-		&& isset($GLOBALS['meta']['charset'])
38
-		&& $GLOBALS['meta']['charset'] != 'utf-8'
39
-		// check rapide mais pas fiable
40
-		&& is_string($a)
41
-		&& preg_match(',[\x80-\xFF],', $a)
42
-		// check fiable
43
-		&& include_spip('inc/charsets')
44
-		&& is_utf8($a)
45
-	) {
46
-		return importer_charset($a, 'utf-8');
47
-	}
31
+    // Si on est en ajax et en POST tout a ete encode
32
+    // via encodeURIComponent, il faut donc repasser
33
+    // dans le charset local...
34
+    if (
35
+        defined('_AJAX')
36
+        && _AJAX
37
+        && isset($GLOBALS['meta']['charset'])
38
+        && $GLOBALS['meta']['charset'] != 'utf-8'
39
+        // check rapide mais pas fiable
40
+        && is_string($a)
41
+        && preg_match(',[\x80-\xFF],', $a)
42
+        // check fiable
43
+        && include_spip('inc/charsets')
44
+        && is_utf8($a)
45
+    ) {
46
+        return importer_charset($a, 'utf-8');
47
+    }
48 48
 
49
-	return $a;
49
+    return $a;
50 50
 }
51 51
 
52 52
 
@@ -64,22 +64,22 @@  discard block
 block discarded – undo
64 64
  *     - false sinon
65 65
  **/
66 66
 function set_request($var, $val = null, $c = false) {
67
-	if (is_array($c)) {
68
-		unset($c[$var]);
69
-		if ($val !== null) {
70
-			$c[$var] = $val;
71
-		}
67
+    if (is_array($c)) {
68
+        unset($c[$var]);
69
+        if ($val !== null) {
70
+            $c[$var] = $val;
71
+        }
72 72
 
73
-		return $c;
74
-	}
73
+        return $c;
74
+    }
75 75
 
76
-	unset($_GET[$var]);
77
-	unset($_POST[$var]);
78
-	if ($val !== null) {
79
-		$_GET[$var] = $val;
80
-	}
76
+    unset($_GET[$var]);
77
+    unset($_POST[$var]);
78
+    if ($val !== null) {
79
+        $_GET[$var] = $val;
80
+    }
81 81
 
82
-	return false; # n'affecte pas $c
82
+    return false; # n'affecte pas $c
83 83
 }
84 84
 
85 85
 /**
@@ -99,23 +99,23 @@  discard block
 block discarded – undo
99 99
  * @return array|mixed|string
100 100
  */
101 101
 function spip_sanitize_from_request($value, $key, $sanitize_function = 'entites_html') {
102
-	if (is_array($value)) {
103
-		if ($key == '*') {
104
-			$key = array_keys($value);
105
-		}
106
-		if (!is_array($key)) {
107
-			$key = [$key];
108
-		}
109
-		foreach ($key as $k) {
110
-			if (!empty($value[$k])) {
111
-				$value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function);
112
-			}
113
-		}
114
-		return $value;
115
-	}
116
-	// si la valeur vient des GET ou POST on la sanitize
117
-	if (!empty($value) && $value == _request($key)) {
118
-		$value = $sanitize_function($value);
119
-	}
120
-	return $value;
102
+    if (is_array($value)) {
103
+        if ($key == '*') {
104
+            $key = array_keys($value);
105
+        }
106
+        if (!is_array($key)) {
107
+            $key = [$key];
108
+        }
109
+        foreach ($key as $k) {
110
+            if (!empty($value[$k])) {
111
+                $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function);
112
+            }
113
+        }
114
+        return $value;
115
+    }
116
+    // si la valeur vient des GET ou POST on la sanitize
117
+    if (!empty($value) && $value == _request($key)) {
118
+        $value = $sanitize_function($value);
119
+    }
120
+    return $value;
121 121
 }
Please login to merge, or discard this patch.
ecrire/bootstrap/inc/urls.php 2 patches
Indentation   +500 added lines, -501 removed lines patch added patch discarded remove patch
@@ -8,11 +8,11 @@  discard block
 block discarded – undo
8 8
  * @return string
9 9
  */
10 10
 function quote_amp($u) {
11
-	return preg_replace(
12
-		'/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i',
13
-		'&amp;',
14
-		$u
15
-	);
11
+    return preg_replace(
12
+        '/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i',
13
+        '&amp;',
14
+        $u
15
+    );
16 16
 }
17 17
 
18 18
 /**
@@ -20,23 +20,22 @@  discard block
 block discarded – undo
20 20
  *
21 21
  * On est sur le web, on exclut certains protocoles,
22 22
  * notamment 'file://', 'php://' et d'autres…
23
-
24 23
  * @param string $url
25 24
  * @return bool
26 25
  */
27 26
 function tester_url_absolue($url) {
28
-	$url = trim($url ?? '');
29
-	if ($url && preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) {
30
-		if (
31
-			isset($m[1])
32
-			&& ($p = strtolower(rtrim($m[1], ':')))
33
-			&& in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip'])
34
-		) {
35
-			return false;
36
-		}
37
-		return true;
38
-	}
39
-	return false;
27
+    $url = trim($url ?? '');
28
+    if ($url && preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) {
29
+        if (
30
+            isset($m[1])
31
+            && ($p = strtolower(rtrim($m[1], ':')))
32
+            && in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip'])
33
+        ) {
34
+            return false;
35
+        }
36
+        return true;
37
+    }
38
+    return false;
40 39
 }
41 40
 
42 41
 /**
@@ -58,100 +57,100 @@  discard block
 block discarded – undo
58 57
  * @return string URL
59 58
  */
60 59
 function parametre_url($url, $c, $v = null, $sep = '&amp;') {
61
-	// requete erronnee : plusieurs variable dans $c et aucun $v
62
-	if (str_contains($c, '|') && is_null($v)) {
63
-		return null;
64
-	}
65
-
66
-	// lever l'#ancre
67
-	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
68
-		$url = $r[1];
69
-		$ancre = $r[2];
70
-	} else {
71
-		$ancre = '';
72
-	}
73
-
74
-	// eclater
75
-	$url = preg_split(',[?]|&amp;|&,', $url);
76
-
77
-	// recuperer la base
78
-	$a = array_shift($url);
79
-	if (!$a) {
80
-		$a = './';
81
-	}
82
-
83
-	// preparer la regexp de maniere securisee
84
-	$regexp = explode('|', $c);
85
-	foreach ($regexp as $r => $e) {
86
-		$regexp[$r] = str_replace('[]', '\[\]', preg_replace(',[^\w\d\[\]-],', '', $e));
87
-	}
88
-	$regexp = ',^(' . implode('|', $regexp) . '[[]?[]]?)(=.*)?$,';
89
-	$ajouts = array_flip(explode('|', $c));
90
-	$u = is_array($v) ? $v : rawurlencode((string) $v);
91
-	$testv = (is_array($v) ? count($v) : strlen((string) $v));
92
-	$v_read = null;
93
-	// lire les variables et agir
94
-	foreach ($url as $n => $val) {
95
-		if (preg_match($regexp, urldecode($val), $r)) {
96
-			$r = array_pad($r, 3, null);
97
-			if ($v === null) {
98
-				// c'est un tableau, on memorise les valeurs
99
-				if (str_ends_with($r[1], '[]')) {
100
-					if (!$v_read) {
101
-						$v_read = [];
102
-					}
103
-					$v_read[] = $r[2] ? substr($r[2], 1) : '';
104
-				} // c'est un scalaire, on retourne direct
105
-				else {
106
-					return $r[2] ? substr($r[2], 1) : '';
107
-				}
108
-			} // suppression
109
-			elseif (!$testv) {
110
-				unset($url[$n]);
111
-			}
112
-			// Ajout. Pour une variable, remplacer au meme endroit,
113
-			// pour un tableau ce sera fait dans la prochaine boucle
114
-			elseif (!str_ends_with($r[1], '[]')) {
115
-				$url[$n] = $r[1] . '=' . $u;
116
-				unset($ajouts[$r[1]]);
117
-			}
118
-			// Pour les tableaux on laisse tomber les valeurs de
119
-			// départ, on remplira à l'étape suivante
120
-			else {
121
-				unset($url[$n]);
122
-			}
123
-		}
124
-	}
125
-
126
-	// traiter les parametres pas encore trouves
127
-	if (
128
-		$v === null
129
-		&& ($args = func_get_args())
130
-		&& count($args) == 2
131
-	) {
132
-		return $v_read; // rien trouve ou un tableau
133
-	} elseif ($testv) {
134
-		foreach ($ajouts as $k => $n) {
135
-			if (!is_array($v)) {
136
-				$url[] = $k . '=' . $u;
137
-			} else {
138
-				$id = (str_ends_with($k, '[]')) ? $k : ($k . '[]');
139
-				foreach ($v as $w) {
140
-					$url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w));
141
-				}
142
-			}
143
-		}
144
-	}
145
-
146
-	// eliminer les vides
147
-	$url = array_filter($url);
148
-
149
-	// recomposer l'adresse
150
-	if ($url) {
151
-		$a .= '?' . join($sep, $url);
152
-	}
153
-
154
-	return $a . $ancre;
60
+    // requete erronnee : plusieurs variable dans $c et aucun $v
61
+    if (str_contains($c, '|') && is_null($v)) {
62
+        return null;
63
+    }
64
+
65
+    // lever l'#ancre
66
+    if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
67
+        $url = $r[1];
68
+        $ancre = $r[2];
69
+    } else {
70
+        $ancre = '';
71
+    }
72
+
73
+    // eclater
74
+    $url = preg_split(',[?]|&amp;|&,', $url);
75
+
76
+    // recuperer la base
77
+    $a = array_shift($url);
78
+    if (!$a) {
79
+        $a = './';
80
+    }
81
+
82
+    // preparer la regexp de maniere securisee
83
+    $regexp = explode('|', $c);
84
+    foreach ($regexp as $r => $e) {
85
+        $regexp[$r] = str_replace('[]', '\[\]', preg_replace(',[^\w\d\[\]-],', '', $e));
86
+    }
87
+    $regexp = ',^(' . implode('|', $regexp) . '[[]?[]]?)(=.*)?$,';
88
+    $ajouts = array_flip(explode('|', $c));
89
+    $u = is_array($v) ? $v : rawurlencode((string) $v);
90
+    $testv = (is_array($v) ? count($v) : strlen((string) $v));
91
+    $v_read = null;
92
+    // lire les variables et agir
93
+    foreach ($url as $n => $val) {
94
+        if (preg_match($regexp, urldecode($val), $r)) {
95
+            $r = array_pad($r, 3, null);
96
+            if ($v === null) {
97
+                // c'est un tableau, on memorise les valeurs
98
+                if (str_ends_with($r[1], '[]')) {
99
+                    if (!$v_read) {
100
+                        $v_read = [];
101
+                    }
102
+                    $v_read[] = $r[2] ? substr($r[2], 1) : '';
103
+                } // c'est un scalaire, on retourne direct
104
+                else {
105
+                    return $r[2] ? substr($r[2], 1) : '';
106
+                }
107
+            } // suppression
108
+            elseif (!$testv) {
109
+                unset($url[$n]);
110
+            }
111
+            // Ajout. Pour une variable, remplacer au meme endroit,
112
+            // pour un tableau ce sera fait dans la prochaine boucle
113
+            elseif (!str_ends_with($r[1], '[]')) {
114
+                $url[$n] = $r[1] . '=' . $u;
115
+                unset($ajouts[$r[1]]);
116
+            }
117
+            // Pour les tableaux on laisse tomber les valeurs de
118
+            // départ, on remplira à l'étape suivante
119
+            else {
120
+                unset($url[$n]);
121
+            }
122
+        }
123
+    }
124
+
125
+    // traiter les parametres pas encore trouves
126
+    if (
127
+        $v === null
128
+        && ($args = func_get_args())
129
+        && count($args) == 2
130
+    ) {
131
+        return $v_read; // rien trouve ou un tableau
132
+    } elseif ($testv) {
133
+        foreach ($ajouts as $k => $n) {
134
+            if (!is_array($v)) {
135
+                $url[] = $k . '=' . $u;
136
+            } else {
137
+                $id = (str_ends_with($k, '[]')) ? $k : ($k . '[]');
138
+                foreach ($v as $w) {
139
+                    $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w));
140
+                }
141
+            }
142
+        }
143
+    }
144
+
145
+    // eliminer les vides
146
+    $url = array_filter($url);
147
+
148
+    // recomposer l'adresse
149
+    if ($url) {
150
+        $a .= '?' . join($sep, $url);
151
+    }
152
+
153
+    return $a . $ancre;
155 154
 }
156 155
 
157 156
 /**
@@ -166,22 +165,22 @@  discard block
 block discarded – undo
166 165
  * @uses translitteration()
167 166
  */
168 167
 function ancre_url(string $url, ?string $ancre = ''): string {
169
-	$ancre ??= '';
170
-	// lever l'#ancre
171
-	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
172
-		$url = $r[1];
173
-	}
174
-	if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
175
-		if (!function_exists('translitteration')) {
176
-			include_spip('inc/charsets');
177
-		}
178
-		$ancre = preg_replace(
179
-			['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'],
180
-			['', '-'],
181
-			translitteration($ancre)
182
-		);
183
-	}
184
-	return $url . (strlen($ancre) ? '#' . $ancre : '');
168
+    $ancre ??= '';
169
+    // lever l'#ancre
170
+    if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
171
+        $url = $r[1];
172
+    }
173
+    if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
174
+        if (!function_exists('translitteration')) {
175
+            include_spip('inc/charsets');
176
+        }
177
+        $ancre = preg_replace(
178
+            ['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'],
179
+            ['', '-'],
180
+            translitteration($ancre)
181
+        );
182
+    }
183
+    return $url . (strlen($ancre) ? '#' . $ancre : '');
185 184
 }
186 185
 
187 186
 /**
@@ -191,16 +190,16 @@  discard block
 block discarded – undo
191 190
  * @return string
192 191
  */
193 192
 function nettoyer_uri($reset = null) {
194
-	static $done = false;
195
-	static $propre = '';
196
-	if (!is_null($reset)) {
197
-		return $propre = $reset;
198
-	}
199
-	if ($done) {
200
-		return $propre;
201
-	}
202
-	$done = true;
203
-	return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);
193
+    static $done = false;
194
+    static $propre = '';
195
+    if (!is_null($reset)) {
196
+        return $propre = $reset;
197
+    }
198
+    if ($done) {
199
+        return $propre;
200
+    }
201
+    $done = true;
202
+    return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);
204 203
 }
205 204
 
206 205
 /**
@@ -215,36 +214,36 @@  discard block
 block discarded – undo
215 214
  * @return string
216 215
  */
217 216
 function nettoyer_uri_var($request_uri) {
218
-	static $preg_nettoyer;
219
-	if (!defined('_CONTEXTE_IGNORE_LISTE_VARIABLES')) {
220
-		/** @var array<string> Liste (regexp) de noms de variables à ignorer d’une URI */
221
-		define('_CONTEXTE_IGNORE_LISTE_VARIABLES', ['^var_', '^PHPSESSID$', '^fbclid$', '^utm_']);
222
-	}
223
-	if (empty($preg_nettoyer)) {
224
-		$preg_nettoyer_vars = _CONTEXTE_IGNORE_LISTE_VARIABLES;
225
-		foreach ($preg_nettoyer_vars as &$var) {
226
-			if (str_starts_with($var, '^')) {
227
-				$var = substr($var, 1);
228
-			} else {
229
-				$var = '[^=&]*' . $var;
230
-			}
231
-			if (str_ends_with($var, '$')) {
232
-				$var = substr($var, 0, -1);
233
-			} else {
234
-				$var .= '[^=&]*';
235
-			}
236
-		}
237
-		$preg_nettoyer = ',([?&])(' . implode('|', $preg_nettoyer_vars) . ')=[^&]*(&|$),i';
238
-	}
239
-	if (empty($request_uri)) {
240
-		return $request_uri;
241
-	}
242
-	$uri1 = $request_uri;
243
-	do {
244
-		$uri = $uri1;
245
-		$uri1 = preg_replace($preg_nettoyer, '\1', $uri);
246
-	} while ($uri <> $uri1);
247
-	return rtrim($uri1, '?&');
217
+    static $preg_nettoyer;
218
+    if (!defined('_CONTEXTE_IGNORE_LISTE_VARIABLES')) {
219
+        /** @var array<string> Liste (regexp) de noms de variables à ignorer d’une URI */
220
+        define('_CONTEXTE_IGNORE_LISTE_VARIABLES', ['^var_', '^PHPSESSID$', '^fbclid$', '^utm_']);
221
+    }
222
+    if (empty($preg_nettoyer)) {
223
+        $preg_nettoyer_vars = _CONTEXTE_IGNORE_LISTE_VARIABLES;
224
+        foreach ($preg_nettoyer_vars as &$var) {
225
+            if (str_starts_with($var, '^')) {
226
+                $var = substr($var, 1);
227
+            } else {
228
+                $var = '[^=&]*' . $var;
229
+            }
230
+            if (str_ends_with($var, '$')) {
231
+                $var = substr($var, 0, -1);
232
+            } else {
233
+                $var .= '[^=&]*';
234
+            }
235
+        }
236
+        $preg_nettoyer = ',([?&])(' . implode('|', $preg_nettoyer_vars) . ')=[^&]*(&|$),i';
237
+    }
238
+    if (empty($request_uri)) {
239
+        return $request_uri;
240
+    }
241
+    $uri1 = $request_uri;
242
+    do {
243
+        $uri = $uri1;
244
+        $uri1 = preg_replace($preg_nettoyer, '\1', $uri);
245
+    } while ($uri <> $uri1);
246
+    return rtrim($uri1, '?&');
248 247
 }
249 248
 
250 249
 
@@ -258,49 +257,49 @@  discard block
 block discarded – undo
258 257
  *    URL vers soi-même
259 258
  **/
260 259
 function self($amp = '&amp;', $root = false) {
261
-	$url = nettoyer_uri();
262
-	if (
263
-		!$root
264
-		&& (
265
-			// si pas de profondeur on peut tronquer
266
-			$GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
267
-			// sinon c'est OK si _SET_HTML_BASE a ete force a false
268
-			|| defined('_SET_HTML_BASE') && !_SET_HTML_BASE
269
-		)
270
-	) {
271
-		$url = preg_replace(',^[^?]*/,', '', $url);
272
-	}
273
-	// ajouter le cas echeant les variables _POST['id_...']
274
-	foreach ($_POST as $v => $c) {
275
-		if (str_starts_with($v, 'id_')) {
276
-			$url = parametre_url($url, $v, $c, '&');
277
-		}
278
-	}
279
-
280
-	// supprimer les variables sans interet
281
-	if (test_espace_prive()) {
282
-		$url = preg_replace(',([?&])('
283
-			. 'lang|show_docs|'
284
-			. 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
285
-		$url = preg_replace(',([?&])[&]+,', '\1', $url);
286
-		$url = preg_replace(',[&]$,', '\1', $url);
287
-	}
288
-
289
-	// eviter les hacks
290
-	include_spip('inc/filtres_mini');
291
-	$url = spip_htmlspecialchars($url);
292
-
293
-	$url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url);
294
-
295
-	// &amp; ?
296
-	if ($amp != '&amp;') {
297
-		$url = str_replace('&amp;', $amp, $url);
298
-	}
299
-
300
-	// Si ca demarre par ? ou vide, donner './'
301
-	$url = preg_replace(',^([?].*)?$,', './\1', $url);
302
-
303
-	return $url;
260
+    $url = nettoyer_uri();
261
+    if (
262
+        !$root
263
+        && (
264
+            // si pas de profondeur on peut tronquer
265
+            $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
266
+            // sinon c'est OK si _SET_HTML_BASE a ete force a false
267
+            || defined('_SET_HTML_BASE') && !_SET_HTML_BASE
268
+        )
269
+    ) {
270
+        $url = preg_replace(',^[^?]*/,', '', $url);
271
+    }
272
+    // ajouter le cas echeant les variables _POST['id_...']
273
+    foreach ($_POST as $v => $c) {
274
+        if (str_starts_with($v, 'id_')) {
275
+            $url = parametre_url($url, $v, $c, '&');
276
+        }
277
+    }
278
+
279
+    // supprimer les variables sans interet
280
+    if (test_espace_prive()) {
281
+        $url = preg_replace(',([?&])('
282
+            . 'lang|show_docs|'
283
+            . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
284
+        $url = preg_replace(',([?&])[&]+,', '\1', $url);
285
+        $url = preg_replace(',[&]$,', '\1', $url);
286
+    }
287
+
288
+    // eviter les hacks
289
+    include_spip('inc/filtres_mini');
290
+    $url = spip_htmlspecialchars($url);
291
+
292
+    $url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url);
293
+
294
+    // &amp; ?
295
+    if ($amp != '&amp;') {
296
+        $url = str_replace('&amp;', $amp, $url);
297
+    }
298
+
299
+    // Si ca demarre par ? ou vide, donner './'
300
+    $url = preg_replace(',^([?].*)?$,', './\1', $url);
301
+
302
+    return $url;
304 303
 }
305 304
 
306 305
 /**
@@ -325,48 +324,48 @@  discard block
 block discarded – undo
325 324
  *   url codee ou fonction de decodage
326 325
  */
327 326
 function generer_objet_url($id, string $entite, string $args = '', string $ancre = '', ?bool $public = null, string $type = '', string $connect = ''): string {
328
-	if ($public === null) {
329
-		$public = !test_espace_prive();
330
-	}
331
-	$id = intval($id);
332
-	$entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
333
-
334
-	if (!$public) {
335
-		if (!$entite) {
336
-			return '';
337
-		}
338
-		if (!function_exists('generer_objet_url_ecrire')) {
339
-			include_spip('inc/urls');
340
-		}
341
-		$res = generer_objet_url_ecrire($id, $entite, $args, $ancre, false, $connect);
342
-	} else {
343
-		$f = charger_fonction_url('objet', $type ?? '');
344
-
345
-		// @deprecated si $entite='', on veut la fonction de passage URL ==> id
346
-		// @see charger_fonction_url
347
-		if (!$entite) {
348
-			return $f;
349
-		}
350
-
351
-		// mais d'abord il faut tester le cas des urls sur une
352
-		// base distante
353
-		if (
354
-			$connect
355
-			&& ($g = charger_fonction('connect', 'urls', true))
356
-		) {
357
-			$f = $g;
358
-		}
359
-
360
-		$res = $f(intval($id), $entite, $args ?: '', $ancre ?: '', $connect);
361
-	}
362
-	if ($res) {
363
-		return $res;
364
-	}
365
-
366
-	// On a ete gentil mais la ....
367
-	spip_log("generer_objet_url: entite $entite " . ($public ? "($f)" : '') . " inconnue $type $public $connect", _LOG_ERREUR);
368
-
369
-	return '';
327
+    if ($public === null) {
328
+        $public = !test_espace_prive();
329
+    }
330
+    $id = intval($id);
331
+    $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
332
+
333
+    if (!$public) {
334
+        if (!$entite) {
335
+            return '';
336
+        }
337
+        if (!function_exists('generer_objet_url_ecrire')) {
338
+            include_spip('inc/urls');
339
+        }
340
+        $res = generer_objet_url_ecrire($id, $entite, $args, $ancre, false, $connect);
341
+    } else {
342
+        $f = charger_fonction_url('objet', $type ?? '');
343
+
344
+        // @deprecated si $entite='', on veut la fonction de passage URL ==> id
345
+        // @see charger_fonction_url
346
+        if (!$entite) {
347
+            return $f;
348
+        }
349
+
350
+        // mais d'abord il faut tester le cas des urls sur une
351
+        // base distante
352
+        if (
353
+            $connect
354
+            && ($g = charger_fonction('connect', 'urls', true))
355
+        ) {
356
+            $f = $g;
357
+        }
358
+
359
+        $res = $f(intval($id), $entite, $args ?: '', $ancre ?: '', $connect);
360
+    }
361
+    if ($res) {
362
+        return $res;
363
+    }
364
+
365
+    // On a ete gentil mais la ....
366
+    spip_log("generer_objet_url: entite $entite " . ($public ? "($f)" : '') . " inconnue $type $public $connect", _LOG_ERREUR);
367
+
368
+    return '';
370 369
 }
371 370
 
372 371
 /**
@@ -374,11 +373,11 @@  discard block
 block discarded – undo
374 373
  * @see generer_objet_url
375 374
  */
376 375
 function generer_url_entite($id = 0, $entite = '', $args = '', $ancre = '', $public = null, $type = null) {
377
-	trigger_deprecation('spip', '4.1', 'Using "%s" is deprecated, use "%s" instead', __FUNCTION__, 'generer_objet_url');
378
-	if ($public && is_string($public)) {
379
-		return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', true, $type ?? '', $public);
380
-	}
381
-	return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', $public, $type ?? '');
376
+    trigger_deprecation('spip', '4.1', 'Using "%s" is deprecated, use "%s" instead', __FUNCTION__, 'generer_objet_url');
377
+    if ($public && is_string($public)) {
378
+        return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', true, $type ?? '', $public);
379
+    }
380
+    return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', $public, $type ?? '');
382 381
 }
383 382
 
384 383
 /**
@@ -386,19 +385,19 @@  discard block
 block discarded – undo
386 385
  * @param int|string|null $id
387 386
  */
388 387
 function generer_objet_url_ecrire_edit($id, string $entite, string $args = '', string $ancre = ''): string {
389
-	$id = intval($id);
390
-	$exec = objet_info($entite, 'url_edit');
391
-	$url = generer_url_ecrire($exec, $args);
392
-	if (intval($id)) {
393
-		$url = parametre_url($url, id_table_objet($entite), $id);
394
-	} else {
395
-		$url = parametre_url($url, 'new', 'oui');
396
-	}
397
-	if ($ancre) {
398
-		$url = ancre_url($url, $ancre);
399
-	}
400
-
401
-	return $url;
388
+    $id = intval($id);
389
+    $exec = objet_info($entite, 'url_edit');
390
+    $url = generer_url_ecrire($exec, $args);
391
+    if (intval($id)) {
392
+        $url = parametre_url($url, id_table_objet($entite), $id);
393
+    } else {
394
+        $url = parametre_url($url, 'new', 'oui');
395
+    }
396
+    if ($ancre) {
397
+        $url = ancre_url($url, $ancre);
398
+    }
399
+
400
+    return $url;
402 401
 }
403 402
 
404 403
 /**
@@ -406,19 +405,19 @@  discard block
 block discarded – undo
406 405
  * @see generer_objet_url_ecrire_edit
407 406
  */
408 407
 function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') {
409
-	trigger_deprecation('spip', '4.1', 'Using "%s" is deprecated, use "%s" instead', __FUNCTION__, 'generer_objet_url_ecrire_edit');
410
-	return generer_objet_url_ecrire_edit(intval($id), $entite, $args, $ancre);
408
+    trigger_deprecation('spip', '4.1', 'Using "%s" is deprecated, use "%s" instead', __FUNCTION__, 'generer_objet_url_ecrire_edit');
409
+    return generer_objet_url_ecrire_edit(intval($id), $entite, $args, $ancre);
411 410
 }
412 411
 
413 412
 
414 413
 function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) {
415
-	include_spip('base/connect_sql');
416
-	$id_type = id_table_objet($entite, $public);
414
+    include_spip('base/connect_sql');
415
+    $id_type = id_table_objet($entite, $public);
417 416
 
418
-	return _DIR_RACINE . get_spip_script('./')
419
-	. '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
420
-	. (!$args ? '' : "&$args")
421
-	. (!$ancre ? '' : "#$ancre");
417
+    return _DIR_RACINE . get_spip_script('./')
418
+    . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
419
+    . (!$args ? '' : "&$args")
420
+    . (!$ancre ? '' : "#$ancre");
422 421
 }
423 422
 
424 423
 
@@ -429,18 +428,18 @@  discard block
 block discarded – undo
429 428
  * @return string
430 429
  */
431 430
 function urlencode_1738($url) {
432
-	if (preg_match(',[^\x00-\x7E],sS', $url)) {
433
-		$uri = '';
434
-		for ($i = 0; $i < strlen($url); $i++) {
435
-			if (ord($a = $url[$i]) > 127) {
436
-				$a = rawurlencode($a);
437
-			}
438
-			$uri .= $a;
439
-		}
440
-		$url = $uri;
441
-	}
442
-
443
-	return quote_amp($url);
431
+    if (preg_match(',[^\x00-\x7E],sS', $url)) {
432
+        $uri = '';
433
+        for ($i = 0; $i < strlen($url); $i++) {
434
+            if (ord($a = $url[$i]) > 127) {
435
+                $a = rawurlencode($a);
436
+            }
437
+            $uri .= $a;
438
+        }
439
+        $url = $uri;
440
+    }
441
+
442
+    return quote_amp($url);
444 443
 }
445 444
 
446 445
 /**
@@ -449,14 +448,14 @@  discard block
 block discarded – undo
449 448
  * @param int|string|null $id
450 449
  */
451 450
 function generer_objet_url_absolue($id = 0, string $entite = '', string $args = '', string $ancre = '', ?bool $public = null, string $type = '', string $connect = ''): string {
452
-	$id = intval($id);
453
-	$h = generer_objet_url($id, $entite, $args, $ancre, $public, $type, $connect);
454
-	if (!preg_match(',^\w+:,', $h)) {
455
-		include_spip('inc/filtres_mini');
456
-		$h = url_absolue($h);
457
-	}
458
-
459
-	return $h;
451
+    $id = intval($id);
452
+    $h = generer_objet_url($id, $entite, $args, $ancre, $public, $type, $connect);
453
+    if (!preg_match(',^\w+:,', $h)) {
454
+        include_spip('inc/filtres_mini');
455
+        $h = url_absolue($h);
456
+    }
457
+
458
+    return $h;
460 459
 }
461 460
 
462 461
 /**
@@ -464,8 +463,8 @@  discard block
 block discarded – undo
464 463
  * @see  generer_objet_url_absolue
465 464
  */
466 465
 function generer_url_entite_absolue($id = 0, $entite = '', $args = '', $ancre = '', $connect = null) {
467
-	trigger_deprecation('spip', '4.1', 'Using "%s" is deprecated, use "%s" instead', __FUNCTION__, 'generer_objet_url_absolue');
468
-	return generer_objet_url_absolue(intval($id), $entite, $args, $ancre, true, '', $connect ?? '');
466
+    trigger_deprecation('spip', '4.1', 'Using "%s" is deprecated, use "%s" instead', __FUNCTION__, 'generer_objet_url_absolue');
467
+    return generer_objet_url_absolue(intval($id), $entite, $args, $ancre, true, '', $connect ?? '');
469 468
 }
470 469
 
471 470
 
@@ -494,89 +493,89 @@  discard block
 block discarded – undo
494 493
  */
495 494
 function url_de_base($profondeur = null) {
496 495
 
497
-	static $url = [];
498
-	if (is_array($profondeur)) {
499
-		return $url = $profondeur;
500
-	}
501
-	if ($profondeur === false) {
502
-		return $url;
503
-	}
504
-
505
-	if (is_null($profondeur)) {
506
-		$profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1);
507
-	}
508
-
509
-	if (isset($url[$profondeur])) {
510
-		return $url[$profondeur];
511
-	}
512
-
513
-	$http = 'http';
514
-
515
-	if (
516
-		isset($_SERVER['SCRIPT_URI'])
517
-		&& str_starts_with($_SERVER['SCRIPT_URI'], 'https')
518
-	) {
519
-		$http = 'https';
520
-	} elseif (
521
-		isset($_SERVER['HTTPS'])
522
-		&& test_valeur_serveur($_SERVER['HTTPS'])
523
-	) {
524
-		$http = 'https';
525
-	}
526
-
527
-	// note : HTTP_HOST contient le :port si necessaire
528
-	if ($host = $_SERVER['HTTP_HOST'] ?? null) {
529
-		// Filtrer $host pour proteger d'attaques d'entete HTTP
530
-		$host = (filter_var($host, FILTER_SANITIZE_URL) ?: null);
531
-	}
532
-
533
-	// si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback
534
-	if (is_null($host) && isset($GLOBALS['meta']['adresse_site'])) {
535
-		$host = $GLOBALS['meta']['adresse_site'];
536
-		if ($scheme = parse_url($host, PHP_URL_SCHEME)) {
537
-			$http = $scheme;
538
-			$host = str_replace("{$scheme}://", '', $host);
539
-		}
540
-	}
541
-	if (
542
-		isset($_SERVER['SERVER_PORT'])
543
-		&& ($port = $_SERVER['SERVER_PORT'])
544
-		&& !str_contains($host, ':')
545
-	) {
546
-		if (!defined('_PORT_HTTP_STANDARD')) {
547
-			define('_PORT_HTTP_STANDARD', '80');
548
-		}
549
-		if (!defined('_PORT_HTTPS_STANDARD')) {
550
-			define('_PORT_HTTPS_STANDARD', '443');
551
-		}
552
-		if ($http == 'http' && !in_array($port, explode(',', _PORT_HTTP_STANDARD))) {
553
-			$host .= ":$port";
554
-		}
555
-		if ($http == 'https' && !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) {
556
-			$host .= ":$port";
557
-		}
558
-	}
559
-
560
-	if (!$GLOBALS['REQUEST_URI']) {
561
-		if (isset($_SERVER['REQUEST_URI'])) {
562
-			$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
563
-		} else {
564
-			$GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
565
-			if (
566
-				!empty($_SERVER['QUERY_STRING'])
567
-				&& !str_contains($_SERVER['REQUEST_URI'], '?')
568
-			) {
569
-				$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
570
-			}
571
-		}
572
-	}
573
-
574
-	// Et nettoyer l'url
575
-	$GLOBALS['REQUEST_URI'] = (filter_var($GLOBALS['REQUEST_URI'], FILTER_SANITIZE_URL) ?: '');
576
-
577
-	$url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
578
-
579
-	return $url[$profondeur];
496
+    static $url = [];
497
+    if (is_array($profondeur)) {
498
+        return $url = $profondeur;
499
+    }
500
+    if ($profondeur === false) {
501
+        return $url;
502
+    }
503
+
504
+    if (is_null($profondeur)) {
505
+        $profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1);
506
+    }
507
+
508
+    if (isset($url[$profondeur])) {
509
+        return $url[$profondeur];
510
+    }
511
+
512
+    $http = 'http';
513
+
514
+    if (
515
+        isset($_SERVER['SCRIPT_URI'])
516
+        && str_starts_with($_SERVER['SCRIPT_URI'], 'https')
517
+    ) {
518
+        $http = 'https';
519
+    } elseif (
520
+        isset($_SERVER['HTTPS'])
521
+        && test_valeur_serveur($_SERVER['HTTPS'])
522
+    ) {
523
+        $http = 'https';
524
+    }
525
+
526
+    // note : HTTP_HOST contient le :port si necessaire
527
+    if ($host = $_SERVER['HTTP_HOST'] ?? null) {
528
+        // Filtrer $host pour proteger d'attaques d'entete HTTP
529
+        $host = (filter_var($host, FILTER_SANITIZE_URL) ?: null);
530
+    }
531
+
532
+    // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback
533
+    if (is_null($host) && isset($GLOBALS['meta']['adresse_site'])) {
534
+        $host = $GLOBALS['meta']['adresse_site'];
535
+        if ($scheme = parse_url($host, PHP_URL_SCHEME)) {
536
+            $http = $scheme;
537
+            $host = str_replace("{$scheme}://", '', $host);
538
+        }
539
+    }
540
+    if (
541
+        isset($_SERVER['SERVER_PORT'])
542
+        && ($port = $_SERVER['SERVER_PORT'])
543
+        && !str_contains($host, ':')
544
+    ) {
545
+        if (!defined('_PORT_HTTP_STANDARD')) {
546
+            define('_PORT_HTTP_STANDARD', '80');
547
+        }
548
+        if (!defined('_PORT_HTTPS_STANDARD')) {
549
+            define('_PORT_HTTPS_STANDARD', '443');
550
+        }
551
+        if ($http == 'http' && !in_array($port, explode(',', _PORT_HTTP_STANDARD))) {
552
+            $host .= ":$port";
553
+        }
554
+        if ($http == 'https' && !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) {
555
+            $host .= ":$port";
556
+        }
557
+    }
558
+
559
+    if (!$GLOBALS['REQUEST_URI']) {
560
+        if (isset($_SERVER['REQUEST_URI'])) {
561
+            $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
562
+        } else {
563
+            $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
564
+            if (
565
+                !empty($_SERVER['QUERY_STRING'])
566
+                && !str_contains($_SERVER['REQUEST_URI'], '?')
567
+            ) {
568
+                $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
569
+            }
570
+        }
571
+    }
572
+
573
+    // Et nettoyer l'url
574
+    $GLOBALS['REQUEST_URI'] = (filter_var($GLOBALS['REQUEST_URI'], FILTER_SANITIZE_URL) ?: '');
575
+
576
+    $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
577
+
578
+    return $url[$profondeur];
580 579
 }
581 580
 
582 581
 /**
@@ -589,26 +588,26 @@  discard block
 block discarded – undo
589 588
  * @return string
590 589
  */
591 590
 function url_de_($http, $host, $request, $prof = 0) {
592
-	$prof = max($prof, 0);
593
-
594
-	$myself = ltrim($request, '/');
595
-	# supprimer la chaine de GET
596
-	[$myself] = explode('?', $myself);
597
-	// vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
598
-	// protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
599
-	if (str_contains($myself, '://')) {
600
-		$myself = explode('://', $myself);
601
-		array_shift($myself);
602
-		$myself = implode('://', $myself);
603
-		$myself = explode('/', $myself);
604
-		array_shift($myself);
605
-		$myself = implode('/', $myself);
606
-	}
607
-	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
608
-
609
-	$url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
610
-
611
-	return $url;
591
+    $prof = max($prof, 0);
592
+
593
+    $myself = ltrim($request, '/');
594
+    # supprimer la chaine de GET
595
+    [$myself] = explode('?', $myself);
596
+    // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
597
+    // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
598
+    if (str_contains($myself, '://')) {
599
+        $myself = explode('://', $myself);
600
+        array_shift($myself);
601
+        $myself = implode('://', $myself);
602
+        $myself = explode('/', $myself);
603
+        array_shift($myself);
604
+        $myself = implode('/', $myself);
605
+    }
606
+    $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
607
+
608
+    $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
609
+
610
+    return $url;
612 611
 }
613 612
 
614 613
 
@@ -643,26 +642,26 @@  discard block
 block discarded – undo
643 642
  * @return string URL
644 643
  **/
645 644
 function generer_url_ecrire(?string $script = '', $args = '', $no_entities = false, $rel = false) {
646
-	$script ??= '';
647
-	if (!$rel) {
648
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
649
-	} else {
650
-		if (!is_string($rel)) {
651
-			$rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT;
652
-		}
653
-	}
654
-
655
-	[$script, $ancre] = array_pad(explode('#', $script), 2, null);
656
-	if ($script && ($script <> 'accueil' || $rel)) {
657
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
658
-	} elseif ($args) {
659
-		$args = "?$args";
660
-	}
661
-	if ($ancre) {
662
-		$args .= "#$ancre";
663
-	}
664
-
665
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
645
+    $script ??= '';
646
+    if (!$rel) {
647
+        $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
648
+    } else {
649
+        if (!is_string($rel)) {
650
+            $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT;
651
+        }
652
+    }
653
+
654
+    [$script, $ancre] = array_pad(explode('#', $script), 2, null);
655
+    if ($script && ($script <> 'accueil' || $rel)) {
656
+        $args = "?exec=$script" . (!$args ? '' : "&$args");
657
+    } elseif ($args) {
658
+        $args = "?$args";
659
+    }
660
+    if ($ancre) {
661
+        $args .= "#$ancre";
662
+    }
663
+
664
+    return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
666 665
 }
667 666
 
668 667
 //
@@ -684,15 +683,15 @@  discard block
 block discarded – undo
684 683
  *     Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut
685 684
  **/
686 685
 function get_spip_script($default = '') {
687
-	if (!defined('_SPIP_SCRIPT')) {
688
-		return 'spip.php';
689
-	}
690
-	# cas define('_SPIP_SCRIPT', '');
691
-	if (_SPIP_SCRIPT) {
692
-		return _SPIP_SCRIPT;
693
-	} else {
694
-		return $default;
695
-	}
686
+    if (!defined('_SPIP_SCRIPT')) {
687
+        return 'spip.php';
688
+    }
689
+    # cas define('_SPIP_SCRIPT', '');
690
+    if (_SPIP_SCRIPT) {
691
+        return _SPIP_SCRIPT;
692
+    } else {
693
+        return $default;
694
+    }
696 695
 }
697 696
 
698 697
 /**
@@ -721,45 +720,45 @@  discard block
 block discarded – undo
721 720
  * @return string URL
722 721
  **/
723 722
 function generer_url_public($script = '', $args = '', $no_entities = false, $rel = true, $action = '') {
724
-	// si le script est une action (spip_pass, spip_inscription),
725
-	// standardiser vers la nouvelle API
726
-
727
-	if (is_array($args)) {
728
-		$args = http_build_query($args);
729
-	}
730
-
731
-	$url = '';
732
-	if ($f = charger_fonction_url('page')) {
733
-		$url = $f($script, $args);
734
-		if ($url && !$rel) {
735
-			include_spip('inc/filtres_mini');
736
-			$url = url_absolue($url);
737
-		}
738
-	}
739
-	if (!$url) {
740
-		if (!$action) {
741
-			$action = get_spip_script();
742
-		}
743
-		if ($script) {
744
-			$action = parametre_url($action, _SPIP_PAGE, $script, '&');
745
-		}
746
-		if ($args) {
747
-			$action .= (str_contains($action, '?') ? '&' : '?') . $args;
748
-		}
749
-		// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
750
-		$url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
751
-	}
752
-
753
-	if (!$no_entities) {
754
-		$url = quote_amp($url);
755
-	}
756
-
757
-	return $url;
723
+    // si le script est une action (spip_pass, spip_inscription),
724
+    // standardiser vers la nouvelle API
725
+
726
+    if (is_array($args)) {
727
+        $args = http_build_query($args);
728
+    }
729
+
730
+    $url = '';
731
+    if ($f = charger_fonction_url('page')) {
732
+        $url = $f($script, $args);
733
+        if ($url && !$rel) {
734
+            include_spip('inc/filtres_mini');
735
+            $url = url_absolue($url);
736
+        }
737
+    }
738
+    if (!$url) {
739
+        if (!$action) {
740
+            $action = get_spip_script();
741
+        }
742
+        if ($script) {
743
+            $action = parametre_url($action, _SPIP_PAGE, $script, '&');
744
+        }
745
+        if ($args) {
746
+            $action .= (str_contains($action, '?') ? '&' : '?') . $args;
747
+        }
748
+        // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
749
+        $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
750
+    }
751
+
752
+    if (!$no_entities) {
753
+        $url = quote_amp($url);
754
+    }
755
+
756
+    return $url;
758 757
 }
759 758
 
760 759
 function generer_url_prive($script, $args = '', $no_entities = false) {
761 760
 
762
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
761
+    return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
763 762
 }
764 763
 
765 764
 
@@ -779,22 +778,22 @@  discard block
 block discarded – undo
779 778
  *     URL
780 779
  */
781 780
 function generer_url_action($script, $args = '', $no_entities = false, $public = false) {
782
-	// si l'on est dans l'espace prive, on garde dans l'url
783
-	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
784
-	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
785
-	$url = (_DIR_RACINE && !$public)
786
-		? generer_url_ecrire(_request('exec'))
787
-		: generer_url_public('', '', false, false);
788
-	$url = parametre_url($url, 'action', $script);
789
-	if ($args) {
790
-		$url .= quote_amp('&' . $args);
791
-	}
792
-
793
-	if ($no_entities) {
794
-		$url = str_replace('&amp;', '&', $url);
795
-	}
796
-
797
-	return $url;
781
+    // si l'on est dans l'espace prive, on garde dans l'url
782
+    // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
783
+    // ou non de proceder a l'authentification (cas typique de l'install par exemple)
784
+    $url = (_DIR_RACINE && !$public)
785
+        ? generer_url_ecrire(_request('exec'))
786
+        : generer_url_public('', '', false, false);
787
+    $url = parametre_url($url, 'action', $script);
788
+    if ($args) {
789
+        $url .= quote_amp('&' . $args);
790
+    }
791
+
792
+    if ($no_entities) {
793
+        $url = str_replace('&amp;', '&', $url);
794
+    }
795
+
796
+    return $url;
798 797
 }
799 798
 
800 799
 
@@ -813,21 +812,21 @@  discard block
 block discarded – undo
813 812
  *     URL
814 813
  */
815 814
 function generer_url_api(string $script, string $path, string $args, bool $no_entities = false, ?bool $public = null) {
816
-	if (is_null($public)) {
817
-		$public = (_DIR_RACINE ? false : true);
818
-	}
819
-	if (!str_ends_with($script, '.api')) {
820
-		$script .= '.api';
821
-	}
822
-	$url =
823
-		(($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './')
824
-	. $script . '/'
825
-	. ($path ? trim($path, '/') : '')
826
-	. ($args ? '?' . quote_amp($args) : '');
827
-
828
-	if ($no_entities) {
829
-		$url = str_replace('&amp;', '&', $url);
830
-	}
831
-
832
-	return $url;
815
+    if (is_null($public)) {
816
+        $public = (_DIR_RACINE ? false : true);
817
+    }
818
+    if (!str_ends_with($script, '.api')) {
819
+        $script .= '.api';
820
+    }
821
+    $url =
822
+        (($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './')
823
+    . $script . '/'
824
+    . ($path ? trim($path, '/') : '')
825
+    . ($args ? '?' . quote_amp($args) : '');
826
+
827
+    if ($no_entities) {
828
+        $url = str_replace('&amp;', '&', $url);
829
+    }
830
+
831
+    return $url;
833 832
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	foreach ($regexp as $r => $e) {
86 86
 		$regexp[$r] = str_replace('[]', '\[\]', preg_replace(',[^\w\d\[\]-],', '', $e));
87 87
 	}
88
-	$regexp = ',^(' . implode('|', $regexp) . '[[]?[]]?)(=.*)?$,';
88
+	$regexp = ',^('.implode('|', $regexp).'[[]?[]]?)(=.*)?$,';
89 89
 	$ajouts = array_flip(explode('|', $c));
90 90
 	$u = is_array($v) ? $v : rawurlencode((string) $v);
91 91
 	$testv = (is_array($v) ? count($v) : strlen((string) $v));
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 			// Ajout. Pour une variable, remplacer au meme endroit,
113 113
 			// pour un tableau ce sera fait dans la prochaine boucle
114 114
 			elseif (!str_ends_with($r[1], '[]')) {
115
-				$url[$n] = $r[1] . '=' . $u;
115
+				$url[$n] = $r[1].'='.$u;
116 116
 				unset($ajouts[$r[1]]);
117 117
 			}
118 118
 			// Pour les tableaux on laisse tomber les valeurs de
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
 	} elseif ($testv) {
134 134
 		foreach ($ajouts as $k => $n) {
135 135
 			if (!is_array($v)) {
136
-				$url[] = $k . '=' . $u;
136
+				$url[] = $k.'='.$u;
137 137
 			} else {
138
-				$id = (str_ends_with($k, '[]')) ? $k : ($k . '[]');
138
+				$id = (str_ends_with($k, '[]')) ? $k : ($k.'[]');
139 139
 				foreach ($v as $w) {
140
-					$url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w));
140
+					$url[] = $id.'='.(is_array($w) ? 'Array' : rawurlencode($w));
141 141
 				}
142 142
 			}
143 143
 		}
@@ -148,10 +148,10 @@  discard block
 block discarded – undo
148 148
 
149 149
 	// recomposer l'adresse
150 150
 	if ($url) {
151
-		$a .= '?' . join($sep, $url);
151
+		$a .= '?'.join($sep, $url);
152 152
 	}
153 153
 
154
-	return $a . $ancre;
154
+	return $a.$ancre;
155 155
 }
156 156
 
157 157
 /**
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 			translitteration($ancre)
182 182
 		);
183 183
 	}
184
-	return $url . (strlen($ancre) ? '#' . $ancre : '');
184
+	return $url.(strlen($ancre) ? '#'.$ancre : '');
185 185
 }
186 186
 
187 187
 /**
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 			if (str_starts_with($var, '^')) {
227 227
 				$var = substr($var, 1);
228 228
 			} else {
229
-				$var = '[^=&]*' . $var;
229
+				$var = '[^=&]*'.$var;
230 230
 			}
231 231
 			if (str_ends_with($var, '$')) {
232 232
 				$var = substr($var, 0, -1);
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 				$var .= '[^=&]*';
235 235
 			}
236 236
 		}
237
-		$preg_nettoyer = ',([?&])(' . implode('|', $preg_nettoyer_vars) . ')=[^&]*(&|$),i';
237
+		$preg_nettoyer = ',([?&])('.implode('|', $preg_nettoyer_vars).')=[^&]*(&|$),i';
238 238
 	}
239 239
 	if (empty($request_uri)) {
240 240
 		return $request_uri;
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 	}
365 365
 
366 366
 	// On a ete gentil mais la ....
367
-	spip_log("generer_objet_url: entite $entite " . ($public ? "($f)" : '') . " inconnue $type $public $connect", _LOG_ERREUR);
367
+	spip_log("generer_objet_url: entite $entite ".($public ? "($f)" : '')." inconnue $type $public $connect", _LOG_ERREUR);
368 368
 
369 369
 	return '';
370 370
 }
@@ -415,8 +415,8 @@  discard block
 block discarded – undo
415 415
 	include_spip('base/connect_sql');
416 416
 	$id_type = id_table_objet($entite, $public);
417 417
 
418
-	return _DIR_RACINE . get_spip_script('./')
419
-	. '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
418
+	return _DIR_RACINE.get_spip_script('./')
419
+	. '?'._SPIP_PAGE."=$entite&$id_type=$i&connect=$public"
420 420
 	. (!$args ? '' : "&$args")
421 421
 	. (!$ancre ? '' : "#$ancre");
422 422
 }
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 				!empty($_SERVER['QUERY_STRING'])
567 567
 				&& !str_contains($_SERVER['REQUEST_URI'], '?')
568 568
 			) {
569
-				$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
569
+				$GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
570 570
 			}
571 571
 		}
572 572
 	}
@@ -604,9 +604,9 @@  discard block
 block discarded – undo
604 604
 		array_shift($myself);
605 605
 		$myself = implode('/', $myself);
606 606
 	}
607
-	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
607
+	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/';
608 608
 
609
-	$url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
609
+	$url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/');
610 610
 
611 611
 	return $url;
612 612
 }
@@ -645,16 +645,16 @@  discard block
 block discarded – undo
645 645
 function generer_url_ecrire(?string $script = '', $args = '', $no_entities = false, $rel = false) {
646 646
 	$script ??= '';
647 647
 	if (!$rel) {
648
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
648
+		$rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT;
649 649
 	} else {
650 650
 		if (!is_string($rel)) {
651
-			$rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT;
651
+			$rel = _DIR_RESTREINT ?: './'._SPIP_ECRIRE_SCRIPT;
652 652
 		}
653 653
 	}
654 654
 
655 655
 	[$script, $ancre] = array_pad(explode('#', $script), 2, null);
656 656
 	if ($script && ($script <> 'accueil' || $rel)) {
657
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
657
+		$args = "?exec=$script".(!$args ? '' : "&$args");
658 658
 	} elseif ($args) {
659 659
 		$args = "?$args";
660 660
 	}
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 		$args .= "#$ancre";
663 663
 	}
664 664
 
665
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
665
+	return $rel.($no_entities ? $args : str_replace('&', '&amp;', $args));
666 666
 }
667 667
 
668 668
 //
@@ -744,10 +744,10 @@  discard block
 block discarded – undo
744 744
 			$action = parametre_url($action, _SPIP_PAGE, $script, '&');
745 745
 		}
746 746
 		if ($args) {
747
-			$action .= (str_contains($action, '?') ? '&' : '?') . $args;
747
+			$action .= (str_contains($action, '?') ? '&' : '?').$args;
748 748
 		}
749 749
 		// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
750
-		$url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action"));
750
+		$url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(',^/[.]/,', '/', "/$action"));
751 751
 	}
752 752
 
753 753
 	if (!$no_entities) {
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 
760 760
 function generer_url_prive($script, $args = '', $no_entities = false) {
761 761
 
762
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
762
+	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php');
763 763
 }
764 764
 
765 765
 
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 		: generer_url_public('', '', false, false);
788 788
 	$url = parametre_url($url, 'action', $script);
789 789
 	if ($args) {
790
-		$url .= quote_amp('&' . $args);
790
+		$url .= quote_amp('&'.$args);
791 791
 	}
792 792
 
793 793
 	if ($no_entities) {
@@ -821,9 +821,9 @@  discard block
 block discarded – undo
821 821
 	}
822 822
 	$url =
823 823
 		(($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './')
824
-	. $script . '/'
824
+	. $script.'/'
825 825
 	. ($path ? trim($path, '/') : '')
826
-	. ($args ? '?' . quote_amp($args) : '');
826
+	. ($args ? '?'.quote_amp($args) : '');
827 827
 
828 828
 	if ($no_entities) {
829 829
 		$url = str_replace('&amp;', '&', $url);
Please login to merge, or discard this patch.
ecrire/inc/utils.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_once dirname(__DIR__) . '/bootstrap/functions.php';
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,4 +19,4 @@
 block discarded – undo
19 19
 	return;
20 20
 }
21 21
 
22
-include_once dirname(__DIR__) . '/bootstrap/functions.php';
22
+include_once dirname(__DIR__).'/bootstrap/functions.php';
Please login to merge, or discard this patch.
ecrire/bootstrap/config/initial.php 2 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
 define('_ECRIRE_INC_VERSION', '1');
15 15
 
16 16
 if (!defined('_DIR_RESTREINT_ABS')) {
17
-	/** le nom du repertoire ecrire/ */
18
-	define('_DIR_RESTREINT_ABS', 'ecrire/');
17
+    /** le nom du repertoire ecrire/ */
18
+    define('_DIR_RESTREINT_ABS', 'ecrire/');
19 19
 }
20 20
 
21 21
 /** Chemin relatif pour aller dans ecrire
@@ -36,26 +36,26 @@  discard block
 block discarded – undo
36 36
 # Par defaut ces 4 noms seront suffixes par _DIR_RACINE (cf plus bas)
37 37
 # mais on peut les mettre ailleurs et changer completement les noms
38 38
 if (!defined('_NOM_TEMPORAIRES_INACCESSIBLES')) {
39
-	/** Nom du repertoire des fichiers Temporaires Inaccessibles par http:// */
40
-	define('_NOM_TEMPORAIRES_INACCESSIBLES', 'tmp/');
39
+    /** Nom du repertoire des fichiers Temporaires Inaccessibles par http:// */
40
+    define('_NOM_TEMPORAIRES_INACCESSIBLES', 'tmp/');
41 41
 }
42 42
 if (!defined('_NOM_TEMPORAIRES_ACCESSIBLES')) {
43
-	/** Nom du repertoire des fichiers Temporaires Accessibles par http:// */
44
-	define('_NOM_TEMPORAIRES_ACCESSIBLES', 'local/');
43
+    /** Nom du repertoire des fichiers Temporaires Accessibles par http:// */
44
+    define('_NOM_TEMPORAIRES_ACCESSIBLES', 'local/');
45 45
 }
46 46
 if (!defined('_NOM_PERMANENTS_INACCESSIBLES')) {
47
-	/** Nom du repertoire des fichiers Permanents Inaccessibles par http:// */
48
-	define('_NOM_PERMANENTS_INACCESSIBLES', 'config/');
47
+    /** Nom du repertoire des fichiers Permanents Inaccessibles par http:// */
48
+    define('_NOM_PERMANENTS_INACCESSIBLES', 'config/');
49 49
 }
50 50
 if (!defined('_NOM_PERMANENTS_ACCESSIBLES')) {
51
-	/** Nom du repertoire des fichiers Permanents Accessibles par http:// */
52
-	define('_NOM_PERMANENTS_ACCESSIBLES', 'IMG/');
51
+    /** Nom du repertoire des fichiers Permanents Accessibles par http:// */
52
+    define('_NOM_PERMANENTS_ACCESSIBLES', 'IMG/');
53 53
 }
54 54
 
55 55
 // Icones
56 56
 if (!defined('_NOM_IMG_PACK')) {
57
-	/** Nom du dossier images */
58
-	define('_NOM_IMG_PACK', 'images/');
57
+    /** Nom du dossier images */
58
+    define('_NOM_IMG_PACK', 'images/');
59 59
 }
60 60
 /** le chemin http (relatif) vers les images standard */
61 61
 define('_DIR_IMG_PACK', (_DIR_RACINE . 'prive/' . _NOM_IMG_PACK));
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 define('_ROOT_IMG_PACK', dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'prive' . DIRECTORY_SEPARATOR . _NOM_IMG_PACK);
65 65
 
66 66
 if (!defined('_JAVASCRIPT')) {
67
-	/** Nom du repertoire des  bibliotheques JavaScript */
68
-	// utilisable avec #CHEMIN et find_in_path
69
-	define('_JAVASCRIPT', 'javascript/');
67
+    /** Nom du repertoire des  bibliotheques JavaScript */
68
+    // utilisable avec #CHEMIN et find_in_path
69
+    define('_JAVASCRIPT', 'javascript/');
70 70
 }
71 71
 
72 72
 /** le nom du repertoire des  bibliotheques JavaScript du prive */
@@ -74,35 +74,35 @@  discard block
 block discarded – undo
74 74
 
75 75
 /** Le nom du fichier de personnalisation */
76 76
 if (!defined('_NOM_CONFIG')) {
77
-	define('_NOM_CONFIG', 'mes_options');
77
+    define('_NOM_CONFIG', 'mes_options');
78 78
 }
79 79
 
80 80
 // Son emplacement absolu si on le trouve
81 81
 if (@file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php')) {
82
-	/** Emplacement absolu du fichier d'option */
83
-	define('_FILE_OPTIONS', $f);
82
+    /** Emplacement absolu du fichier d'option */
83
+    define('_FILE_OPTIONS', $f);
84 84
 } else {
85
-	define('_FILE_OPTIONS', '');
85
+    define('_FILE_OPTIONS', '');
86 86
 }
87 87
 
88 88
 if (!defined('MODULES_IDIOMES')) {
89
-	/**
90
-	 * Modules par défaut pour la traduction.
91
-	 *
92
-	 * Constante utilisée par le compilateur et le décompilateur
93
-	 * sa valeur etant traitée par inc_traduire_dist
94
-	 */
95
-	define('MODULES_IDIOMES', 'public|spip|ecrire');
89
+    /**
90
+     * Modules par défaut pour la traduction.
91
+     *
92
+     * Constante utilisée par le compilateur et le décompilateur
93
+     * sa valeur etant traitée par inc_traduire_dist
94
+     */
95
+    define('MODULES_IDIOMES', 'public|spip|ecrire');
96 96
 }
97 97
 
98 98
 if (!defined('_IS_CLI')) {
99
-	define(
100
-		'_IS_CLI',
101
-		!isset($_SERVER['HTTP_HOST'])
102
-		&& !strlen((string) $_SERVER['DOCUMENT_ROOT'])
103
-		&& !empty($_SERVER['argv'])
104
-		&& empty($_SERVER['REQUEST_METHOD'])
105
-	);
99
+    define(
100
+        '_IS_CLI',
101
+        !isset($_SERVER['HTTP_HOST'])
102
+        && !strlen((string) $_SERVER['DOCUMENT_ROOT'])
103
+        && !empty($_SERVER['argv'])
104
+        && empty($_SERVER['REQUEST_METHOD'])
105
+    );
106 106
 }
107 107
 
108 108
 // Definir les niveaux de log
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
 define('_DIR_RACINE', _DIR_RESTREINT ? '' : '../');
27 27
 
28 28
 /** chemin absolu vers la racine */
29
-define('_ROOT_RACINE', dirname(__DIR__, 3) . DIRECTORY_SEPARATOR);
29
+define('_ROOT_RACINE', dirname(__DIR__, 3).DIRECTORY_SEPARATOR);
30 30
 /** chemin absolu vers le repertoire de travail */
31
-define('_ROOT_CWD', getcwd() . DIRECTORY_SEPARATOR);
31
+define('_ROOT_CWD', getcwd().DIRECTORY_SEPARATOR);
32 32
 /** chemin absolu vers ecrire */
33
-define('_ROOT_RESTREINT', _ROOT_CWD . _DIR_RESTREINT);
33
+define('_ROOT_RESTREINT', _ROOT_CWD._DIR_RESTREINT);
34 34
 
35 35
 # Le nom des 4 repertoires modifiables par les scripts lances par httpd
36 36
 # Par defaut ces 4 noms seront suffixes par _DIR_RACINE (cf plus bas)
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 	define('_NOM_IMG_PACK', 'images/');
59 59
 }
60 60
 /** le chemin http (relatif) vers les images standard */
61
-define('_DIR_IMG_PACK', (_DIR_RACINE . 'prive/' . _NOM_IMG_PACK));
61
+define('_DIR_IMG_PACK', (_DIR_RACINE.'prive/'._NOM_IMG_PACK));
62 62
 
63 63
 /** le chemin php (absolu) vers les images standard (pour hebergement centralise) */
64
-define('_ROOT_IMG_PACK', dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'prive' . DIRECTORY_SEPARATOR . _NOM_IMG_PACK);
64
+define('_ROOT_IMG_PACK', dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'prive'.DIRECTORY_SEPARATOR._NOM_IMG_PACK);
65 65
 
66 66
 if (!defined('_JAVASCRIPT')) {
67 67
 	/** Nom du repertoire des  bibliotheques JavaScript */
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 }
71 71
 
72 72
 /** le nom du repertoire des  bibliotheques JavaScript du prive */
73
-define('_DIR_JAVASCRIPT', (_DIR_RACINE . 'prive/' . _JAVASCRIPT));
73
+define('_DIR_JAVASCRIPT', (_DIR_RACINE.'prive/'._JAVASCRIPT));
74 74
 
75 75
 /** Le nom du fichier de personnalisation */
76 76
 if (!defined('_NOM_CONFIG')) {
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 }
79 79
 
80 80
 // Son emplacement absolu si on le trouve
81
-if (@file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php')) {
81
+if (@file_exists($f = _ROOT_RACINE._NOM_PERMANENTS_INACCESSIBLES._NOM_CONFIG.'.php')) {
82 82
 	/** Emplacement absolu du fichier d'option */
83 83
 	define('_FILE_OPTIONS', $f);
84 84
 } else {
Please login to merge, or discard this patch.
ecrire/bootstrap/inc/initialization.php 2 patches
Indentation   +591 added lines, -591 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
  * @param string $ta Répertoire temporaire accessible
10 10
  */
11 11
 function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) {
12
-	spip_initialisation_core($pi, $pa, $ti, $ta);
13
-	spip_initialisation_suite();
12
+    spip_initialisation_core($pi, $pa, $ti, $ta);
13
+    spip_initialisation_suite();
14 14
 }
15 15
 
16 16
 /**
@@ -30,313 +30,313 @@  discard block
 block discarded – undo
30 30
  * @param string $ta Répertoire temporaire accessible
31 31
  */
32 32
 function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) {
33
-	static $too_late = 0;
34
-	if ($too_late++) {
35
-		return;
36
-	}
37
-
38
-	// Declaration des repertoires
39
-
40
-	// le nom du repertoire plugins/ activables/desactivables
41
-	if (!defined('_DIR_PLUGINS')) {
42
-		define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
43
-	}
44
-
45
-	// le nom du repertoire des extensions/ permanentes du core, toujours actives
46
-	if (!defined('_DIR_PLUGINS_DIST')) {
47
-		define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
48
-	}
49
-
50
-	// le nom du repertoire des librairies
51
-	if (!defined('_DIR_LIB')) {
52
-		define('_DIR_LIB', _DIR_RACINE . 'lib/');
53
-	}
54
-
55
-	// répertoire des libs via Composer
56
-	if (!defined('_DIR_VENDOR')) {
57
-		define('_DIR_VENDOR', _DIR_RACINE . 'vendor/');
58
-	}
59
-
60
-	if (!defined('_DIR_IMG')) {
61
-		define('_DIR_IMG', $pa);
62
-	}
63
-	if (!defined('_DIR_LOGOS')) {
64
-		define('_DIR_LOGOS', $pa);
65
-	}
66
-	if (!defined('_DIR_IMG_ICONES')) {
67
-		define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
68
-	}
69
-
70
-	if (!defined('_DIR_DUMP')) {
71
-		define('_DIR_DUMP', $ti . 'dump/');
72
-	}
73
-	if (!defined('_DIR_SESSIONS')) {
74
-		define('_DIR_SESSIONS', $ti . 'sessions/');
75
-	}
76
-	if (!defined('_DIR_TRANSFERT')) {
77
-		define('_DIR_TRANSFERT', $ti . 'upload/');
78
-	}
79
-	if (!defined('_DIR_CACHE')) {
80
-		define('_DIR_CACHE', $ti . 'cache/');
81
-	}
82
-	if (!defined('_DIR_CACHE_XML')) {
83
-		define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
84
-	}
85
-	if (!defined('_DIR_SKELS')) {
86
-		define('_DIR_SKELS', _DIR_CACHE . 'skel/');
87
-	}
88
-	if (!defined('_DIR_AIDE')) {
89
-		define('_DIR_AIDE', _DIR_CACHE . 'aide/');
90
-	}
91
-	if (!defined('_DIR_TMP')) {
92
-		define('_DIR_TMP', $ti);
93
-	}
94
-
95
-	if (!defined('_DIR_VAR')) {
96
-		define('_DIR_VAR', $ta);
97
-	}
98
-
99
-	if (!defined('_DIR_ETC')) {
100
-		define('_DIR_ETC', $pi);
101
-	}
102
-	if (!defined('_DIR_CONNECT')) {
103
-		define('_DIR_CONNECT', $pi);
104
-	}
105
-	if (!defined('_DIR_CHMOD')) {
106
-		define('_DIR_CHMOD', $pi);
107
-	}
108
-
109
-	if (!isset($GLOBALS['test_dirs'])) {
110
-		// Pas $pi car il est bon de le mettre hors ecriture apres intstall
111
-		// il sera rajoute automatiquement si besoin a l'etape 2 de l'install
112
-		$GLOBALS['test_dirs'] = [$pa, $ti, $ta];
113
-	}
114
-
115
-	// Declaration des fichiers
116
-
117
-	if (!defined('_CACHE_PLUGINS_PATH')) {
118
-		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
119
-	}
120
-	if (!defined('_CACHE_PLUGINS_OPT')) {
121
-		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
122
-	}
123
-	if (!defined('_CACHE_PLUGINS_FCT')) {
124
-		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
125
-	}
126
-	if (!defined('_CACHE_PIPELINES')) {
127
-		define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
128
-	}
129
-	if (!defined('_CACHE_CHEMIN')) {
130
-		define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
131
-	}
132
-
133
-	# attention .php obligatoire pour ecrire_fichier_securise
134
-	if (!defined('_FILE_META')) {
135
-		define('_FILE_META', $ti . 'meta_cache.php');
136
-	}
137
-	if (!defined('_DIR_LOG')) {
138
-		define('_DIR_LOG', _DIR_TMP . 'log/');
139
-	}
140
-	if (!defined('_FILE_LOG')) {
141
-		define('_FILE_LOG', 'spip');
142
-	}
143
-	if (!defined('_FILE_LOG_SUFFIX')) {
144
-		define('_FILE_LOG_SUFFIX', '.log');
145
-	}
146
-
147
-	// Le fichier de connexion a la base de donnees
148
-	if (!defined('_FILE_CONNECT_INS')) {
149
-		define('_FILE_CONNECT_INS', 'connect');
150
-	}
151
-	if (!defined('_FILE_CONNECT')) {
152
-		define(
153
-			'_FILE_CONNECT',
154
-			@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f : false
155
-		);
156
-	}
157
-
158
-	// Le fichier de reglages des droits
159
-	if (!defined('_FILE_CHMOD_INS')) {
160
-		define('_FILE_CHMOD_INS', 'chmod');
161
-	}
162
-	if (!defined('_FILE_CHMOD')) {
163
-		define(
164
-			'_FILE_CHMOD',
165
-			@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f : false
166
-		);
167
-	}
168
-
169
-	if (!defined('_FILE_LDAP')) {
170
-		define('_FILE_LDAP', 'ldap.php');
171
-	}
172
-
173
-	if (!defined('_FILE_TMP_SUFFIX')) {
174
-		define('_FILE_TMP_SUFFIX', '.tmp.php');
175
-	}
176
-	if (!defined('_FILE_CONNECT_TMP')) {
177
-		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
178
-	}
179
-	if (!defined('_FILE_CHMOD_TMP')) {
180
-		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
181
-	}
182
-
183
-	// Definition des droits d'acces en ecriture
184
-	if (!defined('_SPIP_CHMOD') && _FILE_CHMOD) {
185
-		include_once _FILE_CHMOD;
186
-	}
187
-
188
-	// Se mefier des fichiers mal remplis!
189
-	if (!defined('_SPIP_CHMOD')) {
190
-		define('_SPIP_CHMOD', 0777);
191
-	}
192
-
193
-	if (!defined('_DEFAULT_CHARSET')) {
194
-		/** Le charset par défaut lors de l'installation */
195
-		define('_DEFAULT_CHARSET', 'utf-8');
196
-	}
197
-	if (!defined('_ROOT_PLUGINS')) {
198
-		define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins' . DIRECTORY_SEPARATOR);
199
-	}
200
-	if (!defined('_ROOT_PLUGINS_DIST')) {
201
-		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist' . DIRECTORY_SEPARATOR);
202
-	}
203
-	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
204
-		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
205
-	}
206
-
207
-	// La taille des Log
208
-	if (!defined('_MAX_LOG')) {
209
-		define('_MAX_LOG', 100);
210
-	}
211
-
212
-	// Sommes-nous dans l'empire du Mal ?
213
-	// (ou sous le signe du Pingouin, ascendant GNU ?)
214
-	if (isset($_SERVER['SERVER_SOFTWARE']) && str_contains($_SERVER['SERVER_SOFTWARE'], '(Win')) {
215
-		if (!defined('_OS_SERVEUR')) {
216
-			define('_OS_SERVEUR', 'windows');
217
-		}
218
-		if (!defined('_SPIP_LOCK_MODE')) {
219
-			define('_SPIP_LOCK_MODE', 1);
220
-		} // utiliser le flock php
221
-	} else {
222
-		if (!defined('_OS_SERVEUR')) {
223
-			define('_OS_SERVEUR', '');
224
-		}
225
-		if (!defined('_SPIP_LOCK_MODE')) {
226
-			define('_SPIP_LOCK_MODE', 1);
227
-		} // utiliser le flock php
228
-		#if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
229
-	}
230
-
231
-	// Langue par defaut
232
-	if (!defined('_LANGUE_PAR_DEFAUT')) {
233
-		define('_LANGUE_PAR_DEFAUT', 'fr');
234
-	}
235
-
236
-	//
237
-	// Module de lecture/ecriture/suppression de fichiers utilisant flock()
238
-	// (non surchargeable en l'etat ; attention si on utilise include_spip()
239
-	// pour le rendre surchargeable, on va provoquer un reecriture
240
-	// systematique du noyau ou une baisse de perfs => a etudier)
241
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
242
-
243
-	// charger le path des plugins
244
-	if (@is_readable(_CACHE_PLUGINS_PATH)) {
245
-		include_once(_CACHE_PLUGINS_PATH);
246
-	}
247
-
248
-	// *********** traiter les variables ************
249
-
250
-	//
251
-	// Securite
252
-	//
253
-
254
-	// Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
255
-	if (isset($_REQUEST['GLOBALS'])) {
256
-		die();
257
-	}
258
-	// nettoyer les magic quotes \' et les caracteres nuls %00
259
-	spip_desinfecte($_GET);
260
-	spip_desinfecte($_POST);
261
-	spip_desinfecte($_COOKIE);
262
-	spip_desinfecte($_REQUEST);
263
-
264
-	// appliquer le cookie_prefix
265
-	if ($GLOBALS['cookie_prefix'] != 'spip') {
266
-		include_spip('inc/cookie');
267
-		recuperer_cookies_spip($GLOBALS['cookie_prefix']);
268
-	}
269
-
270
-	// Compatibilite avec serveurs ne fournissant pas $REQUEST_URI
271
-	if (isset($_SERVER['REQUEST_URI'])) {
272
-		$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
273
-	} else {
274
-		$GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
275
-		if (
276
-			!empty($_SERVER['QUERY_STRING'])
277
-			&& !strpos($_SERVER['REQUEST_URI'], '?')
278
-		) {
279
-			$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
280
-		}
281
-	}
282
-
283
-	// Duree de validite de l'alea pour les cookies et ce qui s'ensuit.
284
-	if (!defined('_RENOUVELLE_ALEA')) {
285
-		define('_RENOUVELLE_ALEA', 12 * 3600);
286
-	}
287
-	if (!defined('_DUREE_COOKIE_ADMIN')) {
288
-		define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600);
289
-	}
290
-
291
-	// charger les meta si possible et renouveller l'alea au besoin
292
-	// charge aussi effacer_meta et ecrire_meta
293
-	$inc_meta = charger_fonction('meta', 'inc');
294
-	$inc_meta();
295
-
296
-	// nombre de repertoires depuis la racine
297
-	// on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
298
-	// ou a defaut celle donnee en meta ; (mais si celle-ci est fausse
299
-	// le calcul est faux)
300
-	if (!_DIR_RESTREINT) {
301
-		$GLOBALS['profondeur_url'] = 1;
302
-	} else {
303
-		$uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : '';
304
-		$uri_ref = $_SERVER['SCRIPT_NAME'];
305
-		if (
306
-			!$uri_ref
307
-			// si on est appele avec un autre ti, on est sans doute en mutu
308
-			// si jamais c'est de la mutu avec sous rep, on est perdu si on se fie
309
-			// a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer
310
-			// s'en remettre a l'adresse du site. alea jacta est.
311
-			|| $ti !== _NOM_TEMPORAIRES_INACCESSIBLES
312
-		) {
313
-			if (isset($GLOBALS['meta']['adresse_site'])) {
314
-				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
315
-				$uri_ref = ($uri_ref['path'] ?? '') . '/';
316
-			} else {
317
-				$uri_ref = '';
318
-			}
319
-		}
320
-		if (!$uri || !$uri_ref) {
321
-			$GLOBALS['profondeur_url'] = 0;
322
-		} else {
323
-			$GLOBALS['profondeur_url'] = max(
324
-				0,
325
-				substr_count($uri[0], '/')
326
-				- substr_count($uri_ref, '/')
327
-			);
328
-		}
329
-	}
330
-	// s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
331
-	if (_FILE_CONNECT) {
332
-		if (
333
-			verifier_visiteur() == '0minirezo'
334
-			// si c'est un admin sans cookie admin, il faut ignorer le cache chemin !
335
-			&& !isset($_COOKIE['spip_admin'])
336
-		) {
337
-			clear_path_cache();
338
-		}
339
-	}
33
+    static $too_late = 0;
34
+    if ($too_late++) {
35
+        return;
36
+    }
37
+
38
+    // Declaration des repertoires
39
+
40
+    // le nom du repertoire plugins/ activables/desactivables
41
+    if (!defined('_DIR_PLUGINS')) {
42
+        define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
43
+    }
44
+
45
+    // le nom du repertoire des extensions/ permanentes du core, toujours actives
46
+    if (!defined('_DIR_PLUGINS_DIST')) {
47
+        define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
48
+    }
49
+
50
+    // le nom du repertoire des librairies
51
+    if (!defined('_DIR_LIB')) {
52
+        define('_DIR_LIB', _DIR_RACINE . 'lib/');
53
+    }
54
+
55
+    // répertoire des libs via Composer
56
+    if (!defined('_DIR_VENDOR')) {
57
+        define('_DIR_VENDOR', _DIR_RACINE . 'vendor/');
58
+    }
59
+
60
+    if (!defined('_DIR_IMG')) {
61
+        define('_DIR_IMG', $pa);
62
+    }
63
+    if (!defined('_DIR_LOGOS')) {
64
+        define('_DIR_LOGOS', $pa);
65
+    }
66
+    if (!defined('_DIR_IMG_ICONES')) {
67
+        define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
68
+    }
69
+
70
+    if (!defined('_DIR_DUMP')) {
71
+        define('_DIR_DUMP', $ti . 'dump/');
72
+    }
73
+    if (!defined('_DIR_SESSIONS')) {
74
+        define('_DIR_SESSIONS', $ti . 'sessions/');
75
+    }
76
+    if (!defined('_DIR_TRANSFERT')) {
77
+        define('_DIR_TRANSFERT', $ti . 'upload/');
78
+    }
79
+    if (!defined('_DIR_CACHE')) {
80
+        define('_DIR_CACHE', $ti . 'cache/');
81
+    }
82
+    if (!defined('_DIR_CACHE_XML')) {
83
+        define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
84
+    }
85
+    if (!defined('_DIR_SKELS')) {
86
+        define('_DIR_SKELS', _DIR_CACHE . 'skel/');
87
+    }
88
+    if (!defined('_DIR_AIDE')) {
89
+        define('_DIR_AIDE', _DIR_CACHE . 'aide/');
90
+    }
91
+    if (!defined('_DIR_TMP')) {
92
+        define('_DIR_TMP', $ti);
93
+    }
94
+
95
+    if (!defined('_DIR_VAR')) {
96
+        define('_DIR_VAR', $ta);
97
+    }
98
+
99
+    if (!defined('_DIR_ETC')) {
100
+        define('_DIR_ETC', $pi);
101
+    }
102
+    if (!defined('_DIR_CONNECT')) {
103
+        define('_DIR_CONNECT', $pi);
104
+    }
105
+    if (!defined('_DIR_CHMOD')) {
106
+        define('_DIR_CHMOD', $pi);
107
+    }
108
+
109
+    if (!isset($GLOBALS['test_dirs'])) {
110
+        // Pas $pi car il est bon de le mettre hors ecriture apres intstall
111
+        // il sera rajoute automatiquement si besoin a l'etape 2 de l'install
112
+        $GLOBALS['test_dirs'] = [$pa, $ti, $ta];
113
+    }
114
+
115
+    // Declaration des fichiers
116
+
117
+    if (!defined('_CACHE_PLUGINS_PATH')) {
118
+        define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
119
+    }
120
+    if (!defined('_CACHE_PLUGINS_OPT')) {
121
+        define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
122
+    }
123
+    if (!defined('_CACHE_PLUGINS_FCT')) {
124
+        define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
125
+    }
126
+    if (!defined('_CACHE_PIPELINES')) {
127
+        define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
128
+    }
129
+    if (!defined('_CACHE_CHEMIN')) {
130
+        define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
131
+    }
132
+
133
+    # attention .php obligatoire pour ecrire_fichier_securise
134
+    if (!defined('_FILE_META')) {
135
+        define('_FILE_META', $ti . 'meta_cache.php');
136
+    }
137
+    if (!defined('_DIR_LOG')) {
138
+        define('_DIR_LOG', _DIR_TMP . 'log/');
139
+    }
140
+    if (!defined('_FILE_LOG')) {
141
+        define('_FILE_LOG', 'spip');
142
+    }
143
+    if (!defined('_FILE_LOG_SUFFIX')) {
144
+        define('_FILE_LOG_SUFFIX', '.log');
145
+    }
146
+
147
+    // Le fichier de connexion a la base de donnees
148
+    if (!defined('_FILE_CONNECT_INS')) {
149
+        define('_FILE_CONNECT_INS', 'connect');
150
+    }
151
+    if (!defined('_FILE_CONNECT')) {
152
+        define(
153
+            '_FILE_CONNECT',
154
+            @is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f : false
155
+        );
156
+    }
157
+
158
+    // Le fichier de reglages des droits
159
+    if (!defined('_FILE_CHMOD_INS')) {
160
+        define('_FILE_CHMOD_INS', 'chmod');
161
+    }
162
+    if (!defined('_FILE_CHMOD')) {
163
+        define(
164
+            '_FILE_CHMOD',
165
+            @is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f : false
166
+        );
167
+    }
168
+
169
+    if (!defined('_FILE_LDAP')) {
170
+        define('_FILE_LDAP', 'ldap.php');
171
+    }
172
+
173
+    if (!defined('_FILE_TMP_SUFFIX')) {
174
+        define('_FILE_TMP_SUFFIX', '.tmp.php');
175
+    }
176
+    if (!defined('_FILE_CONNECT_TMP')) {
177
+        define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
178
+    }
179
+    if (!defined('_FILE_CHMOD_TMP')) {
180
+        define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
181
+    }
182
+
183
+    // Definition des droits d'acces en ecriture
184
+    if (!defined('_SPIP_CHMOD') && _FILE_CHMOD) {
185
+        include_once _FILE_CHMOD;
186
+    }
187
+
188
+    // Se mefier des fichiers mal remplis!
189
+    if (!defined('_SPIP_CHMOD')) {
190
+        define('_SPIP_CHMOD', 0777);
191
+    }
192
+
193
+    if (!defined('_DEFAULT_CHARSET')) {
194
+        /** Le charset par défaut lors de l'installation */
195
+        define('_DEFAULT_CHARSET', 'utf-8');
196
+    }
197
+    if (!defined('_ROOT_PLUGINS')) {
198
+        define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins' . DIRECTORY_SEPARATOR);
199
+    }
200
+    if (!defined('_ROOT_PLUGINS_DIST')) {
201
+        define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist' . DIRECTORY_SEPARATOR);
202
+    }
203
+    if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
204
+        define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
205
+    }
206
+
207
+    // La taille des Log
208
+    if (!defined('_MAX_LOG')) {
209
+        define('_MAX_LOG', 100);
210
+    }
211
+
212
+    // Sommes-nous dans l'empire du Mal ?
213
+    // (ou sous le signe du Pingouin, ascendant GNU ?)
214
+    if (isset($_SERVER['SERVER_SOFTWARE']) && str_contains($_SERVER['SERVER_SOFTWARE'], '(Win')) {
215
+        if (!defined('_OS_SERVEUR')) {
216
+            define('_OS_SERVEUR', 'windows');
217
+        }
218
+        if (!defined('_SPIP_LOCK_MODE')) {
219
+            define('_SPIP_LOCK_MODE', 1);
220
+        } // utiliser le flock php
221
+    } else {
222
+        if (!defined('_OS_SERVEUR')) {
223
+            define('_OS_SERVEUR', '');
224
+        }
225
+        if (!defined('_SPIP_LOCK_MODE')) {
226
+            define('_SPIP_LOCK_MODE', 1);
227
+        } // utiliser le flock php
228
+        #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
229
+    }
230
+
231
+    // Langue par defaut
232
+    if (!defined('_LANGUE_PAR_DEFAUT')) {
233
+        define('_LANGUE_PAR_DEFAUT', 'fr');
234
+    }
235
+
236
+    //
237
+    // Module de lecture/ecriture/suppression de fichiers utilisant flock()
238
+    // (non surchargeable en l'etat ; attention si on utilise include_spip()
239
+    // pour le rendre surchargeable, on va provoquer un reecriture
240
+    // systematique du noyau ou une baisse de perfs => a etudier)
241
+    include_once _ROOT_RESTREINT . 'inc/flock.php';
242
+
243
+    // charger le path des plugins
244
+    if (@is_readable(_CACHE_PLUGINS_PATH)) {
245
+        include_once(_CACHE_PLUGINS_PATH);
246
+    }
247
+
248
+    // *********** traiter les variables ************
249
+
250
+    //
251
+    // Securite
252
+    //
253
+
254
+    // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
255
+    if (isset($_REQUEST['GLOBALS'])) {
256
+        die();
257
+    }
258
+    // nettoyer les magic quotes \' et les caracteres nuls %00
259
+    spip_desinfecte($_GET);
260
+    spip_desinfecte($_POST);
261
+    spip_desinfecte($_COOKIE);
262
+    spip_desinfecte($_REQUEST);
263
+
264
+    // appliquer le cookie_prefix
265
+    if ($GLOBALS['cookie_prefix'] != 'spip') {
266
+        include_spip('inc/cookie');
267
+        recuperer_cookies_spip($GLOBALS['cookie_prefix']);
268
+    }
269
+
270
+    // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI
271
+    if (isset($_SERVER['REQUEST_URI'])) {
272
+        $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
273
+    } else {
274
+        $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
275
+        if (
276
+            !empty($_SERVER['QUERY_STRING'])
277
+            && !strpos($_SERVER['REQUEST_URI'], '?')
278
+        ) {
279
+            $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
280
+        }
281
+    }
282
+
283
+    // Duree de validite de l'alea pour les cookies et ce qui s'ensuit.
284
+    if (!defined('_RENOUVELLE_ALEA')) {
285
+        define('_RENOUVELLE_ALEA', 12 * 3600);
286
+    }
287
+    if (!defined('_DUREE_COOKIE_ADMIN')) {
288
+        define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600);
289
+    }
290
+
291
+    // charger les meta si possible et renouveller l'alea au besoin
292
+    // charge aussi effacer_meta et ecrire_meta
293
+    $inc_meta = charger_fonction('meta', 'inc');
294
+    $inc_meta();
295
+
296
+    // nombre de repertoires depuis la racine
297
+    // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
298
+    // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse
299
+    // le calcul est faux)
300
+    if (!_DIR_RESTREINT) {
301
+        $GLOBALS['profondeur_url'] = 1;
302
+    } else {
303
+        $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : '';
304
+        $uri_ref = $_SERVER['SCRIPT_NAME'];
305
+        if (
306
+            !$uri_ref
307
+            // si on est appele avec un autre ti, on est sans doute en mutu
308
+            // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie
309
+            // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer
310
+            // s'en remettre a l'adresse du site. alea jacta est.
311
+            || $ti !== _NOM_TEMPORAIRES_INACCESSIBLES
312
+        ) {
313
+            if (isset($GLOBALS['meta']['adresse_site'])) {
314
+                $uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
315
+                $uri_ref = ($uri_ref['path'] ?? '') . '/';
316
+            } else {
317
+                $uri_ref = '';
318
+            }
319
+        }
320
+        if (!$uri || !$uri_ref) {
321
+            $GLOBALS['profondeur_url'] = 0;
322
+        } else {
323
+            $GLOBALS['profondeur_url'] = max(
324
+                0,
325
+                substr_count($uri[0], '/')
326
+                - substr_count($uri_ref, '/')
327
+            );
328
+        }
329
+    }
330
+    // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
331
+    if (_FILE_CONNECT) {
332
+        if (
333
+            verifier_visiteur() == '0minirezo'
334
+            // si c'est un admin sans cookie admin, il faut ignorer le cache chemin !
335
+            && !isset($_COOKIE['spip_admin'])
336
+        ) {
337
+            clear_path_cache();
338
+        }
339
+    }
340 340
 }
341 341
 
342 342
 /**
@@ -345,158 +345,158 @@  discard block
 block discarded – undo
345 345
  *
346 346
  */
347 347
 function spip_initialisation_suite() {
348
-	static $too_late = 0;
349
-	if ($too_late++) {
350
-		return;
351
-	}
352
-
353
-	// taille mini des login
354
-	if (!defined('_LOGIN_TROP_COURT')) {
355
-		define('_LOGIN_TROP_COURT', 4);
356
-	}
357
-
358
-	// la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
359
-	#if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko
360
-	#if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels
361
-	#if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels
362
-
363
-	// la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
364
-	#if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko
365
-	#if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko
366
-	#if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels
367
-	#if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels
368
-
369
-	if (!defined('_PASS_LONGUEUR_MINI')) {
370
-		define('_PASS_LONGUEUR_MINI', 6);
371
-	}
372
-
373
-	// largeur maximale des images dans l'administration
374
-	if (!defined('_IMG_ADMIN_MAX_WIDTH')) {
375
-		define('_IMG_ADMIN_MAX_WIDTH', 768);
376
-	}
377
-
378
-	// Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)
379
-	if (!defined('_IMG_QUALITE')) {
380
-		define('_IMG_QUALITE', 85);
381
-	} # valeur par defaut
382
-	if (!defined('_IMG_GD_QUALITE')) {
383
-		define('_IMG_GD_QUALITE', _IMG_QUALITE);
384
-	} # surcharge pour la lib GD
385
-	if (!defined('_IMG_CONVERT_QUALITE')) {
386
-		define('_IMG_CONVERT_QUALITE', _IMG_QUALITE);
387
-	} # surcharge pour imagick en ligne de commande
388
-	// Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE
389
-	if (!defined('_IMG_IMAGICK_QUALITE')) {
390
-		define('_IMG_IMAGICK_QUALITE', 75);
391
-	} # surcharge pour imagick en PHP
392
-
393
-	if (!defined('_COPIE_LOCALE_MAX_SIZE')) {
394
-		define('_COPIE_LOCALE_MAX_SIZE', 33_554_432);
395
-	} // poids en octet
396
-
397
-	// qq chaines standard
398
-	if (!defined('_ACCESS_FILE_NAME')) {
399
-		define('_ACCESS_FILE_NAME', '.htaccess');
400
-	}
401
-	if (!defined('_AUTH_USER_FILE')) {
402
-		define('_AUTH_USER_FILE', '.htpasswd');
403
-	}
404
-	if (!defined('_SPIP_DUMP')) {
405
-		define('_SPIP_DUMP', 'dump@nom_site@@[email protected]');
406
-	}
407
-	if (!defined('_CACHE_RUBRIQUES')) {
408
-		/** Fichier cache pour le navigateur de rubrique du bandeau */
409
-		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
410
-	}
411
-	if (!defined('_CACHE_RUBRIQUES_MAX')) {
412
-		/** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
413
-		define('_CACHE_RUBRIQUES_MAX', 500);
414
-	}
415
-
416
-	if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) {
417
-		/**
418
-		 * Basculer les contextes ajax en fichier si la longueur d’url est trop grande
419
-		 * @var int Nombre de caractères */
420
-		define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000);
421
-	}
422
-
423
-	if (!defined('_EXTENSION_SQUELETTES')) {
424
-		define('_EXTENSION_SQUELETTES', 'html');
425
-	}
426
-
427
-	if (!defined('_DOCTYPE_ECRIRE')) {
428
-		/** Définit le doctype de l’espace privé */
429
-		define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n");
430
-	}
431
-	if (!defined('_DOCTYPE_AIDE')) {
432
-		/** Définit le doctype de l’aide en ligne */
433
-		define(
434
-			'_DOCTYPE_AIDE',
435
-			"<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"
436
-		);
437
-	}
438
-
439
-	if (!defined('_SPIP_SCRIPT')) {
440
-		/** L'adresse de base du site ; on peut mettre '' si la racine est gerée par
441
-		 * le script de l'espace public, alias index.php */
442
-		define('_SPIP_SCRIPT', 'spip.php');
443
-	}
444
-	if (!defined('_SPIP_PAGE')) {
445
-		/** Argument page, personalisable en cas de conflit avec un autre script */
446
-		define('_SPIP_PAGE', 'page');
447
-	}
448
-
449
-	// le script de l'espace prive
450
-	// Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:
451
-	// les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)
452
-	// meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html
453
-	if (!defined('_SPIP_ECRIRE_SCRIPT')) {
454
-		if (!empty($_SERVER['SERVER_SOFTWARE']) && preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) {
455
-			define('_SPIP_ECRIRE_SCRIPT', 'index.php');
456
-		} else {
457
-			define('_SPIP_ECRIRE_SCRIPT', '');
458
-		}
459
-	}
460
-
461
-
462
-	if (!defined('_SPIP_AJAX')) {
463
-		define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax']))
464
-			? 1
465
-			: (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));
466
-	}
467
-
468
-	// La requete est-elle en ajax ?
469
-	if (!defined('_AJAX')) {
470
-		define(
471
-			'_AJAX',
472
-			(
473
-				isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery
474
-				|| !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuer
475
-				|| !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins
476
-				|| !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip
477
-			)
478
-			&& 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
479
-		);
480
-	}
481
-
482
-	# nombre de pixels maxi pour calcul de la vignette avec gd
483
-	# au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation
484
-	# les configurations limitees en memoire ont un seuil plutot vers 1MPixel
485
-	if (!defined('_IMG_GD_MAX_PIXELS')) {
486
-		define(
487
-			'_IMG_GD_MAX_PIXELS',
488
-			(isset($GLOBALS['meta']['max_taille_vignettes']) && $GLOBALS['meta']['max_taille_vignettes'])
489
-			? $GLOBALS['meta']['max_taille_vignettes']
490
-			: 0
491
-		);
492
-	}
493
-
494
-	// Protocoles a normaliser dans les chaines de langues
495
-	if (!defined('_PROTOCOLES_STD')) {
496
-		define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal');
497
-	}
498
-
499
-	init_var_mode();
348
+    static $too_late = 0;
349
+    if ($too_late++) {
350
+        return;
351
+    }
352
+
353
+    // taille mini des login
354
+    if (!defined('_LOGIN_TROP_COURT')) {
355
+        define('_LOGIN_TROP_COURT', 4);
356
+    }
357
+
358
+    // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
359
+    #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko
360
+    #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels
361
+    #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels
362
+
363
+    // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
364
+    #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko
365
+    #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko
366
+    #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels
367
+    #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels
368
+
369
+    if (!defined('_PASS_LONGUEUR_MINI')) {
370
+        define('_PASS_LONGUEUR_MINI', 6);
371
+    }
372
+
373
+    // largeur maximale des images dans l'administration
374
+    if (!defined('_IMG_ADMIN_MAX_WIDTH')) {
375
+        define('_IMG_ADMIN_MAX_WIDTH', 768);
376
+    }
377
+
378
+    // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)
379
+    if (!defined('_IMG_QUALITE')) {
380
+        define('_IMG_QUALITE', 85);
381
+    } # valeur par defaut
382
+    if (!defined('_IMG_GD_QUALITE')) {
383
+        define('_IMG_GD_QUALITE', _IMG_QUALITE);
384
+    } # surcharge pour la lib GD
385
+    if (!defined('_IMG_CONVERT_QUALITE')) {
386
+        define('_IMG_CONVERT_QUALITE', _IMG_QUALITE);
387
+    } # surcharge pour imagick en ligne de commande
388
+    // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE
389
+    if (!defined('_IMG_IMAGICK_QUALITE')) {
390
+        define('_IMG_IMAGICK_QUALITE', 75);
391
+    } # surcharge pour imagick en PHP
392
+
393
+    if (!defined('_COPIE_LOCALE_MAX_SIZE')) {
394
+        define('_COPIE_LOCALE_MAX_SIZE', 33_554_432);
395
+    } // poids en octet
396
+
397
+    // qq chaines standard
398
+    if (!defined('_ACCESS_FILE_NAME')) {
399
+        define('_ACCESS_FILE_NAME', '.htaccess');
400
+    }
401
+    if (!defined('_AUTH_USER_FILE')) {
402
+        define('_AUTH_USER_FILE', '.htpasswd');
403
+    }
404
+    if (!defined('_SPIP_DUMP')) {
405
+        define('_SPIP_DUMP', 'dump@nom_site@@[email protected]');
406
+    }
407
+    if (!defined('_CACHE_RUBRIQUES')) {
408
+        /** Fichier cache pour le navigateur de rubrique du bandeau */
409
+        define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
410
+    }
411
+    if (!defined('_CACHE_RUBRIQUES_MAX')) {
412
+        /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
413
+        define('_CACHE_RUBRIQUES_MAX', 500);
414
+    }
415
+
416
+    if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) {
417
+        /**
418
+         * Basculer les contextes ajax en fichier si la longueur d’url est trop grande
419
+         * @var int Nombre de caractères */
420
+        define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000);
421
+    }
422
+
423
+    if (!defined('_EXTENSION_SQUELETTES')) {
424
+        define('_EXTENSION_SQUELETTES', 'html');
425
+    }
426
+
427
+    if (!defined('_DOCTYPE_ECRIRE')) {
428
+        /** Définit le doctype de l’espace privé */
429
+        define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n");
430
+    }
431
+    if (!defined('_DOCTYPE_AIDE')) {
432
+        /** Définit le doctype de l’aide en ligne */
433
+        define(
434
+            '_DOCTYPE_AIDE',
435
+            "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"
436
+        );
437
+    }
438
+
439
+    if (!defined('_SPIP_SCRIPT')) {
440
+        /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par
441
+         * le script de l'espace public, alias index.php */
442
+        define('_SPIP_SCRIPT', 'spip.php');
443
+    }
444
+    if (!defined('_SPIP_PAGE')) {
445
+        /** Argument page, personalisable en cas de conflit avec un autre script */
446
+        define('_SPIP_PAGE', 'page');
447
+    }
448
+
449
+    // le script de l'espace prive
450
+    // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:
451
+    // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)
452
+    // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html
453
+    if (!defined('_SPIP_ECRIRE_SCRIPT')) {
454
+        if (!empty($_SERVER['SERVER_SOFTWARE']) && preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) {
455
+            define('_SPIP_ECRIRE_SCRIPT', 'index.php');
456
+        } else {
457
+            define('_SPIP_ECRIRE_SCRIPT', '');
458
+        }
459
+    }
460
+
461
+
462
+    if (!defined('_SPIP_AJAX')) {
463
+        define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax']))
464
+            ? 1
465
+            : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));
466
+    }
467
+
468
+    // La requete est-elle en ajax ?
469
+    if (!defined('_AJAX')) {
470
+        define(
471
+            '_AJAX',
472
+            (
473
+                isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery
474
+                || !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuer
475
+                || !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins
476
+                || !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip
477
+            )
478
+            && 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
479
+        );
480
+    }
481
+
482
+    # nombre de pixels maxi pour calcul de la vignette avec gd
483
+    # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation
484
+    # les configurations limitees en memoire ont un seuil plutot vers 1MPixel
485
+    if (!defined('_IMG_GD_MAX_PIXELS')) {
486
+        define(
487
+            '_IMG_GD_MAX_PIXELS',
488
+            (isset($GLOBALS['meta']['max_taille_vignettes']) && $GLOBALS['meta']['max_taille_vignettes'])
489
+            ? $GLOBALS['meta']['max_taille_vignettes']
490
+            : 0
491
+        );
492
+    }
493
+
494
+    // Protocoles a normaliser dans les chaines de langues
495
+    if (!defined('_PROTOCOLES_STD')) {
496
+        define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal');
497
+    }
498
+
499
+    init_var_mode();
500 500
 }
501 501
 
502 502
 /**
@@ -530,134 +530,134 @@  discard block
 block discarded – undo
530 530
  * `   var_mode` (calcul ou recalcul).
531 531
  */
532 532
 function init_var_mode() {
533
-	static $done = false;
534
-	if (!$done) {
535
-		if (isset($_GET['var_mode'])) {
536
-			$var_mode = explode(',', $_GET['var_mode']);
537
-			// tout le monde peut calcul/recalcul
538
-			if (!defined('_VAR_MODE')) {
539
-				if (in_array('recalcul', $var_mode)) {
540
-					define('_VAR_MODE', 'recalcul');
541
-				} elseif (in_array('calcul', $var_mode)) {
542
-					define('_VAR_MODE', 'calcul');
543
-				}
544
-			}
545
-			$var_mode = array_diff($var_mode, ['calcul', 'recalcul']);
546
-			if ($var_mode) {
547
-				include_spip('inc/autoriser');
548
-				// autoriser preview si preview seulement, et sinon autoriser debug
549
-				if (
550
-					autoriser(
551
-						($_GET['var_mode'] == 'preview')
552
-						? 'previsualiser'
553
-						: 'debug'
554
-					)
555
-				) {
556
-					if (in_array('traduction', $var_mode)) {
557
-						// forcer le calcul pour passer dans traduire
558
-						if (!defined('_VAR_MODE')) {
559
-							define('_VAR_MODE', 'calcul');
560
-						}
561
-						// et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages
562
-						if (!defined('_VAR_NOCACHE')) {
563
-							define('_VAR_NOCACHE', true);
564
-						}
565
-						$var_mode = array_diff($var_mode, ['traduction']);
566
-					}
567
-					if (in_array('preview', $var_mode)) {
568
-						// basculer sur les criteres de preview dans les boucles
569
-						if (!defined('_VAR_PREVIEW')) {
570
-							define('_VAR_PREVIEW', true);
571
-						}
572
-						// forcer le calcul
573
-						if (!defined('_VAR_MODE')) {
574
-							define('_VAR_MODE', 'calcul');
575
-						}
576
-						// et ne pas enregistrer de cache
577
-						if (!defined('_VAR_NOCACHE')) {
578
-							define('_VAR_NOCACHE', true);
579
-						}
580
-						$var_mode = array_diff($var_mode, ['preview']);
581
-					}
582
-					if (in_array('inclure', $var_mode)) {
583
-						// forcer le compilo et ignorer les caches existants
584
-						if (!defined('_VAR_MODE')) {
585
-							define('_VAR_MODE', 'calcul');
586
-						}
587
-						if (!defined('_VAR_INCLURE')) {
588
-							define('_VAR_INCLURE', true);
589
-						}
590
-						// et ne pas enregistrer de cache
591
-						if (!defined('_VAR_NOCACHE')) {
592
-							define('_VAR_NOCACHE', true);
593
-						}
594
-						$var_mode = array_diff($var_mode, ['inclure']);
595
-					}
596
-					if (in_array('urls', $var_mode)) {
597
-						// forcer le compilo et ignorer les caches existants
598
-						if (!defined('_VAR_MODE')) {
599
-							define('_VAR_MODE', 'calcul');
600
-						}
601
-						if (!defined('_VAR_URLS')) {
602
-							define('_VAR_URLS', true);
603
-						}
604
-						$var_mode = array_diff($var_mode, ['urls']);
605
-					}
606
-					if (in_array('images', $var_mode)) {
607
-						// forcer le compilo et ignorer les caches existants
608
-						if (!defined('_VAR_MODE')) {
609
-							define('_VAR_MODE', 'calcul');
610
-						}
611
-						// indiquer qu'on doit recalculer les images
612
-						if (!defined('_VAR_IMAGES')) {
613
-							define('_VAR_IMAGES', true);
614
-						}
615
-						$var_mode = array_diff($var_mode, ['images']);
616
-					}
617
-					if (in_array('debug', $var_mode)) {
618
-						if (!defined('_VAR_MODE')) {
619
-							define('_VAR_MODE', 'debug');
620
-						}
621
-						// et ne pas enregistrer de cache
622
-						if (!defined('_VAR_NOCACHE')) {
623
-							define('_VAR_NOCACHE', true);
624
-						}
625
-						$var_mode = array_diff($var_mode, ['debug']);
626
-					}
627
-					if (count($var_mode) && !defined('_VAR_MODE')) {
628
-						define('_VAR_MODE', reset($var_mode));
629
-					}
630
-					if (isset($GLOBALS['visiteur_session']['nom'])) {
631
-						spip_log($GLOBALS['visiteur_session']['nom']
632
-							. ' ' . _VAR_MODE);
633
-					}
634
-				} // pas autorise ?
635
-				else {
636
-					// si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger
637
-					if (
638
-						!$GLOBALS['visiteur_session']
639
-						&& !empty($_SERVER['HTTP_HOST'])
640
-						&& !empty($_SERVER['REQUEST_METHOD'])
641
-						&& $_SERVER['REQUEST_METHOD'] === 'GET'
642
-					) {
643
-						$self = self('&', true);
644
-						if (!str_contains($self, 'page=login')) {
645
-							include_spip('inc/headers');
646
-							$redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&');
647
-							redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true));
648
-						}
649
-					}
650
-					// sinon tant pis
651
-				}
652
-			}
653
-		}
654
-		if (!defined('_VAR_MODE')) {
655
-			/**
656
-			 * Indique le mode de calcul ou d'affichage de la page.
657
-			 * @see init_var_mode()
658
-			 */
659
-			define('_VAR_MODE', false);
660
-		}
661
-		$done = true;
662
-	}
533
+    static $done = false;
534
+    if (!$done) {
535
+        if (isset($_GET['var_mode'])) {
536
+            $var_mode = explode(',', $_GET['var_mode']);
537
+            // tout le monde peut calcul/recalcul
538
+            if (!defined('_VAR_MODE')) {
539
+                if (in_array('recalcul', $var_mode)) {
540
+                    define('_VAR_MODE', 'recalcul');
541
+                } elseif (in_array('calcul', $var_mode)) {
542
+                    define('_VAR_MODE', 'calcul');
543
+                }
544
+            }
545
+            $var_mode = array_diff($var_mode, ['calcul', 'recalcul']);
546
+            if ($var_mode) {
547
+                include_spip('inc/autoriser');
548
+                // autoriser preview si preview seulement, et sinon autoriser debug
549
+                if (
550
+                    autoriser(
551
+                        ($_GET['var_mode'] == 'preview')
552
+                        ? 'previsualiser'
553
+                        : 'debug'
554
+                    )
555
+                ) {
556
+                    if (in_array('traduction', $var_mode)) {
557
+                        // forcer le calcul pour passer dans traduire
558
+                        if (!defined('_VAR_MODE')) {
559
+                            define('_VAR_MODE', 'calcul');
560
+                        }
561
+                        // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages
562
+                        if (!defined('_VAR_NOCACHE')) {
563
+                            define('_VAR_NOCACHE', true);
564
+                        }
565
+                        $var_mode = array_diff($var_mode, ['traduction']);
566
+                    }
567
+                    if (in_array('preview', $var_mode)) {
568
+                        // basculer sur les criteres de preview dans les boucles
569
+                        if (!defined('_VAR_PREVIEW')) {
570
+                            define('_VAR_PREVIEW', true);
571
+                        }
572
+                        // forcer le calcul
573
+                        if (!defined('_VAR_MODE')) {
574
+                            define('_VAR_MODE', 'calcul');
575
+                        }
576
+                        // et ne pas enregistrer de cache
577
+                        if (!defined('_VAR_NOCACHE')) {
578
+                            define('_VAR_NOCACHE', true);
579
+                        }
580
+                        $var_mode = array_diff($var_mode, ['preview']);
581
+                    }
582
+                    if (in_array('inclure', $var_mode)) {
583
+                        // forcer le compilo et ignorer les caches existants
584
+                        if (!defined('_VAR_MODE')) {
585
+                            define('_VAR_MODE', 'calcul');
586
+                        }
587
+                        if (!defined('_VAR_INCLURE')) {
588
+                            define('_VAR_INCLURE', true);
589
+                        }
590
+                        // et ne pas enregistrer de cache
591
+                        if (!defined('_VAR_NOCACHE')) {
592
+                            define('_VAR_NOCACHE', true);
593
+                        }
594
+                        $var_mode = array_diff($var_mode, ['inclure']);
595
+                    }
596
+                    if (in_array('urls', $var_mode)) {
597
+                        // forcer le compilo et ignorer les caches existants
598
+                        if (!defined('_VAR_MODE')) {
599
+                            define('_VAR_MODE', 'calcul');
600
+                        }
601
+                        if (!defined('_VAR_URLS')) {
602
+                            define('_VAR_URLS', true);
603
+                        }
604
+                        $var_mode = array_diff($var_mode, ['urls']);
605
+                    }
606
+                    if (in_array('images', $var_mode)) {
607
+                        // forcer le compilo et ignorer les caches existants
608
+                        if (!defined('_VAR_MODE')) {
609
+                            define('_VAR_MODE', 'calcul');
610
+                        }
611
+                        // indiquer qu'on doit recalculer les images
612
+                        if (!defined('_VAR_IMAGES')) {
613
+                            define('_VAR_IMAGES', true);
614
+                        }
615
+                        $var_mode = array_diff($var_mode, ['images']);
616
+                    }
617
+                    if (in_array('debug', $var_mode)) {
618
+                        if (!defined('_VAR_MODE')) {
619
+                            define('_VAR_MODE', 'debug');
620
+                        }
621
+                        // et ne pas enregistrer de cache
622
+                        if (!defined('_VAR_NOCACHE')) {
623
+                            define('_VAR_NOCACHE', true);
624
+                        }
625
+                        $var_mode = array_diff($var_mode, ['debug']);
626
+                    }
627
+                    if (count($var_mode) && !defined('_VAR_MODE')) {
628
+                        define('_VAR_MODE', reset($var_mode));
629
+                    }
630
+                    if (isset($GLOBALS['visiteur_session']['nom'])) {
631
+                        spip_log($GLOBALS['visiteur_session']['nom']
632
+                            . ' ' . _VAR_MODE);
633
+                    }
634
+                } // pas autorise ?
635
+                else {
636
+                    // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger
637
+                    if (
638
+                        !$GLOBALS['visiteur_session']
639
+                        && !empty($_SERVER['HTTP_HOST'])
640
+                        && !empty($_SERVER['REQUEST_METHOD'])
641
+                        && $_SERVER['REQUEST_METHOD'] === 'GET'
642
+                    ) {
643
+                        $self = self('&', true);
644
+                        if (!str_contains($self, 'page=login')) {
645
+                            include_spip('inc/headers');
646
+                            $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&');
647
+                            redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true));
648
+                        }
649
+                    }
650
+                    // sinon tant pis
651
+                }
652
+            }
653
+        }
654
+        if (!defined('_VAR_MODE')) {
655
+            /**
656
+             * Indique le mode de calcul ou d'affichage de la page.
657
+             * @see init_var_mode()
658
+             */
659
+            define('_VAR_MODE', false);
660
+        }
661
+        $done = true;
662
+    }
663 663
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -39,22 +39,22 @@  discard block
 block discarded – undo
39 39
 
40 40
 	// le nom du repertoire plugins/ activables/desactivables
41 41
 	if (!defined('_DIR_PLUGINS')) {
42
-		define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/');
42
+		define('_DIR_PLUGINS', _DIR_RACINE.'plugins/');
43 43
 	}
44 44
 
45 45
 	// le nom du repertoire des extensions/ permanentes du core, toujours actives
46 46
 	if (!defined('_DIR_PLUGINS_DIST')) {
47
-		define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/');
47
+		define('_DIR_PLUGINS_DIST', _DIR_RACINE.'plugins-dist/');
48 48
 	}
49 49
 
50 50
 	// le nom du repertoire des librairies
51 51
 	if (!defined('_DIR_LIB')) {
52
-		define('_DIR_LIB', _DIR_RACINE . 'lib/');
52
+		define('_DIR_LIB', _DIR_RACINE.'lib/');
53 53
 	}
54 54
 
55 55
 	// répertoire des libs via Composer
56 56
 	if (!defined('_DIR_VENDOR')) {
57
-		define('_DIR_VENDOR', _DIR_RACINE . 'vendor/');
57
+		define('_DIR_VENDOR', _DIR_RACINE.'vendor/');
58 58
 	}
59 59
 
60 60
 	if (!defined('_DIR_IMG')) {
@@ -64,29 +64,29 @@  discard block
 block discarded – undo
64 64
 		define('_DIR_LOGOS', $pa);
65 65
 	}
66 66
 	if (!defined('_DIR_IMG_ICONES')) {
67
-		define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/');
67
+		define('_DIR_IMG_ICONES', _DIR_LOGOS.'icones/');
68 68
 	}
69 69
 
70 70
 	if (!defined('_DIR_DUMP')) {
71
-		define('_DIR_DUMP', $ti . 'dump/');
71
+		define('_DIR_DUMP', $ti.'dump/');
72 72
 	}
73 73
 	if (!defined('_DIR_SESSIONS')) {
74
-		define('_DIR_SESSIONS', $ti . 'sessions/');
74
+		define('_DIR_SESSIONS', $ti.'sessions/');
75 75
 	}
76 76
 	if (!defined('_DIR_TRANSFERT')) {
77
-		define('_DIR_TRANSFERT', $ti . 'upload/');
77
+		define('_DIR_TRANSFERT', $ti.'upload/');
78 78
 	}
79 79
 	if (!defined('_DIR_CACHE')) {
80
-		define('_DIR_CACHE', $ti . 'cache/');
80
+		define('_DIR_CACHE', $ti.'cache/');
81 81
 	}
82 82
 	if (!defined('_DIR_CACHE_XML')) {
83
-		define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/');
83
+		define('_DIR_CACHE_XML', _DIR_CACHE.'xml/');
84 84
 	}
85 85
 	if (!defined('_DIR_SKELS')) {
86
-		define('_DIR_SKELS', _DIR_CACHE . 'skel/');
86
+		define('_DIR_SKELS', _DIR_CACHE.'skel/');
87 87
 	}
88 88
 	if (!defined('_DIR_AIDE')) {
89
-		define('_DIR_AIDE', _DIR_CACHE . 'aide/');
89
+		define('_DIR_AIDE', _DIR_CACHE.'aide/');
90 90
 	}
91 91
 	if (!defined('_DIR_TMP')) {
92 92
 		define('_DIR_TMP', $ti);
@@ -115,27 +115,27 @@  discard block
 block discarded – undo
115 115
 	// Declaration des fichiers
116 116
 
117 117
 	if (!defined('_CACHE_PLUGINS_PATH')) {
118
-		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php');
118
+		define('_CACHE_PLUGINS_PATH', _DIR_CACHE.'charger_plugins_chemins.php');
119 119
 	}
120 120
 	if (!defined('_CACHE_PLUGINS_OPT')) {
121
-		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php');
121
+		define('_CACHE_PLUGINS_OPT', _DIR_CACHE.'charger_plugins_options.php');
122 122
 	}
123 123
 	if (!defined('_CACHE_PLUGINS_FCT')) {
124
-		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php');
124
+		define('_CACHE_PLUGINS_FCT', _DIR_CACHE.'charger_plugins_fonctions.php');
125 125
 	}
126 126
 	if (!defined('_CACHE_PIPELINES')) {
127
-		define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php');
127
+		define('_CACHE_PIPELINES', _DIR_CACHE.'charger_pipelines.php');
128 128
 	}
129 129
 	if (!defined('_CACHE_CHEMIN')) {
130
-		define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt');
130
+		define('_CACHE_CHEMIN', _DIR_CACHE.'chemin.txt');
131 131
 	}
132 132
 
133 133
 	# attention .php obligatoire pour ecrire_fichier_securise
134 134
 	if (!defined('_FILE_META')) {
135
-		define('_FILE_META', $ti . 'meta_cache.php');
135
+		define('_FILE_META', $ti.'meta_cache.php');
136 136
 	}
137 137
 	if (!defined('_DIR_LOG')) {
138
-		define('_DIR_LOG', _DIR_TMP . 'log/');
138
+		define('_DIR_LOG', _DIR_TMP.'log/');
139 139
 	}
140 140
 	if (!defined('_FILE_LOG')) {
141 141
 		define('_FILE_LOG', 'spip');
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	if (!defined('_FILE_CONNECT')) {
152 152
 		define(
153 153
 			'_FILE_CONNECT',
154
-			@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f : false
154
+			@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f : false
155 155
 		);
156 156
 	}
157 157
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	if (!defined('_FILE_CHMOD')) {
163 163
 		define(
164 164
 			'_FILE_CHMOD',
165
-			@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f : false
165
+			@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f : false
166 166
 		);
167 167
 	}
168 168
 
@@ -174,10 +174,10 @@  discard block
 block discarded – undo
174 174
 		define('_FILE_TMP_SUFFIX', '.tmp.php');
175 175
 	}
176 176
 	if (!defined('_FILE_CONNECT_TMP')) {
177
-		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
177
+		define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX);
178 178
 	}
179 179
 	if (!defined('_FILE_CHMOD_TMP')) {
180
-		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
180
+		define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX);
181 181
 	}
182 182
 
183 183
 	// Definition des droits d'acces en ecriture
@@ -195,13 +195,13 @@  discard block
 block discarded – undo
195 195
 		define('_DEFAULT_CHARSET', 'utf-8');
196 196
 	}
197 197
 	if (!defined('_ROOT_PLUGINS')) {
198
-		define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins' . DIRECTORY_SEPARATOR);
198
+		define('_ROOT_PLUGINS', _ROOT_RACINE.'plugins'.DIRECTORY_SEPARATOR);
199 199
 	}
200 200
 	if (!defined('_ROOT_PLUGINS_DIST')) {
201
-		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist' . DIRECTORY_SEPARATOR);
201
+		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE.'plugins-dist'.DIRECTORY_SEPARATOR);
202 202
 	}
203 203
 	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
204
-		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
204
+		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
205 205
 	}
206 206
 
207 207
 	// La taille des Log
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	// (non surchargeable en l'etat ; attention si on utilise include_spip()
239 239
 	// pour le rendre surchargeable, on va provoquer un reecriture
240 240
 	// systematique du noyau ou une baisse de perfs => a etudier)
241
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
241
+	include_once _ROOT_RESTREINT.'inc/flock.php';
242 242
 
243 243
 	// charger le path des plugins
244 244
 	if (@is_readable(_CACHE_PLUGINS_PATH)) {
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 			!empty($_SERVER['QUERY_STRING'])
277 277
 			&& !strpos($_SERVER['REQUEST_URI'], '?')
278 278
 		) {
279
-			$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
279
+			$GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
280 280
 		}
281 281
 	}
282 282
 
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 		) {
313 313
 			if (isset($GLOBALS['meta']['adresse_site'])) {
314 314
 				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
315
-				$uri_ref = ($uri_ref['path'] ?? '') . '/';
315
+				$uri_ref = ($uri_ref['path'] ?? '').'/';
316 316
 			} else {
317 317
 				$uri_ref = '';
318 318
 			}
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 	}
407 407
 	if (!defined('_CACHE_RUBRIQUES')) {
408 408
 		/** Fichier cache pour le navigateur de rubrique du bandeau */
409
-		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
409
+		define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt');
410 410
 	}
411 411
 	if (!defined('_CACHE_RUBRIQUES_MAX')) {
412 412
 		/** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 					}
630 630
 					if (isset($GLOBALS['visiteur_session']['nom'])) {
631 631
 						spip_log($GLOBALS['visiteur_session']['nom']
632
-							. ' ' . _VAR_MODE);
632
+							. ' '._VAR_MODE);
633 633
 					}
634 634
 				} // pas autorise ?
635 635
 				else {
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
 						if (!str_contains($self, 'page=login')) {
645 645
 							include_spip('inc/headers');
646 646
 							$redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&');
647
-							redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true));
647
+							redirige_par_entete(generer_url_public('login', 'url='.rawurlencode($redirect), true));
648 648
 						}
649 649
 					}
650 650
 					// sinon tant pis
Please login to merge, or discard this patch.
ecrire/tests/Squelettes/Cache/data/squelettes/inc/maj_invalideurs.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -8,19 +8,19 @@
 block discarded – undo
8 8
  * @param string $cache_key
9 9
  * @param array $page
10 10
  */
11
- function inc_maj_invalideurs($cache_key, $page): void {
12
-	if (!isset($page['contexte']['assert_session'])) {
13
-		return;
14
-	}
11
+    function inc_maj_invalideurs($cache_key, $page): void {
12
+    if (!isset($page['contexte']['assert_session'])) {
13
+        return;
14
+    }
15 15
 
16
-	$expected_session = (bool) $page['contexte']['assert_session'];
17
-	$has_session = $page['invalideurs']['session'] ?? false;
16
+    $expected_session = (bool) $page['contexte']['assert_session'];
17
+    $has_session = $page['invalideurs']['session'] ?? false;
18 18
 
19
-	if ($expected_session) {
20
-		if (!$has_session) {
21
-			CacheSessionTest::addError('PAS de session', $page);
22
-		}
23
-	} elseif ($has_session) {
24
-		CacheSessionTest::addError(sprintf('SESSION %s', $has_session), $page);
25
-	}
19
+    if ($expected_session) {
20
+        if (!$has_session) {
21
+            CacheSessionTest::addError('PAS de session', $page);
22
+        }
23
+    } elseif ($has_session) {
24
+        CacheSessionTest::addError(sprintf('SESSION %s', $has_session), $page);
25
+    }
26 26
 }
Please login to merge, or discard this patch.