Completed
Push — master ( 32470c...ffbbca )
by cam
01:36
created
ecrire/bootstrap/inc/auth.php 2 patches
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *     true si c'est le cas, false sinon.
8 8
  */
9 9
 function test_espace_prive() {
10
-	return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false;
10
+    return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false;
11 11
 }
12 12
 
13 13
 /**
@@ -19,17 +19,17 @@  discard block
 block discarded – undo
19 19
  * @return bool
20 20
  */
21 21
 function autoriser_sans_cookie($nom, $strict = false) {
22
-	static $autsanscookie = ['install', 'base_repair'];
22
+    static $autsanscookie = ['install', 'base_repair'];
23 23
 
24
-	if (in_array($nom, $autsanscookie)) {
25
-		if (test_espace_prive()) {
26
-			include_spip('base/connect_sql');
27
-			if (!$strict || !spip_connect()) {
28
-				return true;
29
-			}
30
-		}
31
-	}
32
-	return false;
24
+    if (in_array($nom, $autsanscookie)) {
25
+        if (test_espace_prive()) {
26
+            include_spip('base/connect_sql');
27
+            if (!$strict || !spip_connect()) {
28
+                return true;
29
+            }
30
+        }
31
+    }
32
+    return false;
33 33
 }
34 34
 
35 35
 
@@ -43,64 +43,64 @@  discard block
 block discarded – undo
43 43
  * @return string|0|false
44 44
 **/
45 45
 function verifier_visiteur() {
46
-	@spip_initialisation_core(
47
-		(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
48
-		(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
49
-		(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
50
-		(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
51
-	);
46
+    @spip_initialisation_core(
47
+        (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
48
+        (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
49
+        (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
50
+        (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
51
+    );
52 52
 
53
-	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
54
-	// dans un formulaire sans login (ex: #FORMULAIRE_FORUM)
55
-	// Attention on separe bien session_nom et nom, pour eviter
56
-	// les melanges entre donnees SQL et variables plus aleatoires
57
-	$variables_session = ['session_nom', 'session_email'];
58
-	foreach ($variables_session as $var) {
59
-		if (_request($var) !== null) {
60
-			$init = true;
61
-			break;
62
-		}
63
-	}
64
-	if (isset($init)) {
65
-		#@spip_initialisation_suite();
66
-		$session = charger_fonction('session', 'inc');
67
-		$session();
68
-		include_spip('inc/texte');
69
-		foreach ($variables_session as $var) {
70
-			if (($a = _request($var)) !== null) {
71
-				$GLOBALS['visiteur_session'][$var] = safehtml($a);
72
-			}
73
-		}
74
-		if (!isset($GLOBALS['visiteur_session']['id_auteur'])) {
75
-			$GLOBALS['visiteur_session']['id_auteur'] = 0;
76
-		}
77
-		$session($GLOBALS['visiteur_session']);
53
+    // Demarrer une session NON AUTHENTIFIEE si on donne son nom
54
+    // dans un formulaire sans login (ex: #FORMULAIRE_FORUM)
55
+    // Attention on separe bien session_nom et nom, pour eviter
56
+    // les melanges entre donnees SQL et variables plus aleatoires
57
+    $variables_session = ['session_nom', 'session_email'];
58
+    foreach ($variables_session as $var) {
59
+        if (_request($var) !== null) {
60
+            $init = true;
61
+            break;
62
+        }
63
+    }
64
+    if (isset($init)) {
65
+        #@spip_initialisation_suite();
66
+        $session = charger_fonction('session', 'inc');
67
+        $session();
68
+        include_spip('inc/texte');
69
+        foreach ($variables_session as $var) {
70
+            if (($a = _request($var)) !== null) {
71
+                $GLOBALS['visiteur_session'][$var] = safehtml($a);
72
+            }
73
+        }
74
+        if (!isset($GLOBALS['visiteur_session']['id_auteur'])) {
75
+            $GLOBALS['visiteur_session']['id_auteur'] = 0;
76
+        }
77
+        $session($GLOBALS['visiteur_session']);
78 78
 
79
-		return 0;
80
-	}
79
+        return 0;
80
+    }
81 81
 
82
-	$h = (isset($_SERVER['PHP_AUTH_USER']) && !$GLOBALS['ignore_auth_http']);
83
-	if ($h || isset($_COOKIE['spip_session']) || isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
84
-		$session = charger_fonction('session', 'inc');
85
-		if ($session()) {
86
-			return $GLOBALS['visiteur_session']['statut'];
87
-		}
88
-		if ($h && isset($_SERVER['PHP_AUTH_PW'])) {
89
-			include_spip('inc/auth');
90
-			$h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
91
-		}
92
-		if ($h) {
93
-			$GLOBALS['visiteur_session'] = $h;
82
+    $h = (isset($_SERVER['PHP_AUTH_USER']) && !$GLOBALS['ignore_auth_http']);
83
+    if ($h || isset($_COOKIE['spip_session']) || isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
84
+        $session = charger_fonction('session', 'inc');
85
+        if ($session()) {
86
+            return $GLOBALS['visiteur_session']['statut'];
87
+        }
88
+        if ($h && isset($_SERVER['PHP_AUTH_PW'])) {
89
+            include_spip('inc/auth');
90
+            $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
91
+        }
92
+        if ($h) {
93
+            $GLOBALS['visiteur_session'] = $h;
94 94
 
95
-			return $GLOBALS['visiteur_session']['statut'];
96
-		}
97
-	}
95
+            return $GLOBALS['visiteur_session']['statut'];
96
+        }
97
+    }
98 98
 
99
-	// au moins son navigateur nous dit la langue preferee de cet inconnu
100
-	include_spip('inc/lang');
101
-	utiliser_langue_visiteur();
99
+    // au moins son navigateur nous dit la langue preferee de cet inconnu
100
+    include_spip('inc/lang');
101
+    utiliser_langue_visiteur();
102 102
 
103
-	return false;
103
+    return false;
104 104
 }
105 105
 
106 106
 
@@ -118,18 +118,18 @@  discard block
 block discarded – undo
118 118
  *     Identifiant de la session
119 119
  **/
120 120
 function spip_session($force = false) {
121
-	static $session;
122
-	if ($force || !isset($session)) {
123
-		$s = '';
124
-		if (!empty($GLOBALS['visiteur_session'])) {
125
-			include_spip('inc/session');
126
-			$cookie = lire_cookie_session();
127
-			$s = serialize($GLOBALS['visiteur_session']) . '_' . ($cookie ?: '');
128
-		}
129
-		$s = pipeline('definir_session', $s);
130
-		$session = ($s ? substr(md5($s), 0, 8) : '');
131
-	}
121
+    static $session;
122
+    if ($force || !isset($session)) {
123
+        $s = '';
124
+        if (!empty($GLOBALS['visiteur_session'])) {
125
+            include_spip('inc/session');
126
+            $cookie = lire_cookie_session();
127
+            $s = serialize($GLOBALS['visiteur_session']) . '_' . ($cookie ?: '');
128
+        }
129
+        $s = pipeline('definir_session', $s);
130
+        $session = ($s ? substr(md5($s), 0, 8) : '');
131
+    }
132 132
 
133
-	#spip_log('session: '.$session);
134
-	return $session;
133
+    #spip_log('session: '.$session);
134
+    return $session;
135 135
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 **/
45 45
 function verifier_visiteur() {
46 46
 	@spip_initialisation_core(
47
-		(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
48
-		(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
49
-		(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
50
-		(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
47
+		(_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES),
48
+		(_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES),
49
+		(_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES),
50
+		(_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES)
51 51
 	);
52 52
 
53 53
 	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	}
81 81
 
82 82
 	$h = (isset($_SERVER['PHP_AUTH_USER']) && !$GLOBALS['ignore_auth_http']);
83
-	if ($h || isset($_COOKIE['spip_session']) || isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
83
+	if ($h || isset($_COOKIE['spip_session']) || isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) {
84 84
 		$session = charger_fonction('session', 'inc');
85 85
 		if ($session()) {
86 86
 			return $GLOBALS['visiteur_session']['statut'];
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 		if (!empty($GLOBALS['visiteur_session'])) {
125 125
 			include_spip('inc/session');
126 126
 			$cookie = lire_cookie_session();
127
-			$s = serialize($GLOBALS['visiteur_session']) . '_' . ($cookie ?: '');
127
+			$s = serialize($GLOBALS['visiteur_session']).'_'.($cookie ?: '');
128 128
 		}
129 129
 		$s = pipeline('definir_session', $s);
130 130
 		$session = ($s ? substr(md5($s), 0, 8) : '');
Please login to merge, or discard this patch.
ecrire/bootstrap/inc/utils.php 2 patches
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @return bool
10 10
  */
11 11
 function test_plugin_actif($plugin) {
12
-	return ($plugin && defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
12
+    return ($plugin && defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
13 13
 }
14 14
 
15 15
 /**
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
  * @return string
23 23
  */
24 24
 function joli_repertoire($rep) {
25
-	$a = substr($rep, 0, 1);
26
-	if ($a <> '.' && $a <> '/') {
27
-		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
28
-	}
29
-	$rep = preg_replace(',(^\.\.\/),', '', $rep);
25
+    $a = substr($rep, 0, 1);
26
+    if ($a <> '.' && $a <> '/') {
27
+        $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
28
+    }
29
+    $rep = preg_replace(',(^\.\.\/),', '', $rep);
30 30
 
31
-	return $rep;
31
+    return $rep;
32 32
 }
33 33
 
34 34
 /**
@@ -52,53 +52,53 @@  discard block
 block discarded – undo
52 52
  * @return float|int|string|void
53 53
  */
54 54
 function spip_timer($t = 'rien', $raw = false) {
55
-	static $time;
56
-	$a = time();
57
-	$b = microtime();
58
-	// microtime peut contenir les microsecondes et le temps
59
-	$b = explode(' ', $b);
60
-	if (count($b) == 2) {
61
-		$a = end($b);
62
-	} // plus precis !
63
-	$b = reset($b);
64
-	if (!isset($time[$t])) {
65
-		$time[$t] = $a + $b;
66
-	} else {
67
-		$p = ($a + $b - $time[$t]) * 1000;
68
-		unset($time[$t]);
55
+    static $time;
56
+    $a = time();
57
+    $b = microtime();
58
+    // microtime peut contenir les microsecondes et le temps
59
+    $b = explode(' ', $b);
60
+    if (count($b) == 2) {
61
+        $a = end($b);
62
+    } // plus precis !
63
+    $b = reset($b);
64
+    if (!isset($time[$t])) {
65
+        $time[$t] = $a + $b;
66
+    } else {
67
+        $p = ($a + $b - $time[$t]) * 1000;
68
+        unset($time[$t]);
69 69
 #			echo "'$p'";exit;
70
-		if ($raw) {
71
-			return $p;
72
-		}
73
-		if ($p < 1000) {
74
-			$s = '';
75
-		} else {
76
-			$s = sprintf('%d ', $x = floor($p / 1000));
77
-			$p -= ($x * 1000);
78
-		}
70
+        if ($raw) {
71
+            return $p;
72
+        }
73
+        if ($p < 1000) {
74
+            $s = '';
75
+        } else {
76
+            $s = sprintf('%d ', $x = floor($p / 1000));
77
+            $p -= ($x * 1000);
78
+        }
79 79
 
80
-		return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
81
-	}
80
+        return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
81
+    }
82 82
 }
83 83
 
84 84
 // Renvoie False si un fichier n'est pas plus vieux que $duree secondes,
85 85
 // sinon renvoie True et le date sauf si ca n'est pas souhaite
86 86
 function spip_touch($fichier, $duree = 0, $touch = true) {
87
-	if ($duree) {
88
-		clearstatcache();
89
-		if (($f = @filemtime($fichier)) && $f >= time() - $duree) {
90
-			return false;
91
-		}
92
-	}
93
-	if ($touch !== false) {
94
-		if (!@touch($fichier)) {
95
-			spip_unlink($fichier);
96
-			@touch($fichier);
97
-		};
98
-		@chmod($fichier, _SPIP_CHMOD & ~0111);
99
-	}
87
+    if ($duree) {
88
+        clearstatcache();
89
+        if (($f = @filemtime($fichier)) && $f >= time() - $duree) {
90
+            return false;
91
+        }
92
+    }
93
+    if ($touch !== false) {
94
+        if (!@touch($fichier)) {
95
+            spip_unlink($fichier);
96
+            @touch($fichier);
97
+        };
98
+        @chmod($fichier, _SPIP_CHMOD & ~0111);
99
+    }
100 100
 
101
-	return true;
101
+    return true;
102 102
 }
103 103
 
104 104
 /**
@@ -120,27 +120,27 @@  discard block
 block discarded – undo
120 120
  *     Balise HTML `<script>` et son contenu
121 121
  **/
122 122
 function http_script($script, $src = '', $noscript = '') {
123
-	static $done = [];
123
+    static $done = [];
124 124
 
125
-	if ($src && !isset($done[$src])) {
126
-		$done[$src] = true;
127
-		$src = find_in_path($src, _JAVASCRIPT);
128
-		$src = " src='$src'";
129
-	} else {
130
-		$src = '';
131
-	}
132
-	if ($script) {
133
-		$script = ("/*<![CDATA[*/\n" .
134
-			preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
135
-			'/*]]>*/');
136
-	}
137
-	if ($noscript) {
138
-		$noscript = "<noscript>\n\t$noscript\n</noscript>\n";
139
-	}
125
+    if ($src && !isset($done[$src])) {
126
+        $done[$src] = true;
127
+        $src = find_in_path($src, _JAVASCRIPT);
128
+        $src = " src='$src'";
129
+    } else {
130
+        $src = '';
131
+    }
132
+    if ($script) {
133
+        $script = ("/*<![CDATA[*/\n" .
134
+            preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
135
+            '/*]]>*/');
136
+    }
137
+    if ($noscript) {
138
+        $noscript = "<noscript>\n\t$noscript\n</noscript>\n";
139
+    }
140 140
 
141
-	return ($src || $script || $noscript)
142
-		? "<script type='text/javascript'$src>$script</script>$noscript"
143
-		: '';
141
+    return ($src || $script || $noscript)
142
+        ? "<script type='text/javascript'$src>$script</script>$noscript"
143
+        : '';
144 144
 }
145 145
 
146 146
 
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
  *     texte échappé
176 176
  **/
177 177
 function texte_script(?string $texte): string {
178
-	if ($texte === null || $texte === '') {
179
-		return '';
180
-	}
181
-	return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte));
178
+    if ($texte === null || $texte === '') {
179
+        return '';
180
+    }
181
+    return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte));
182 182
 }
183 183
 
184 184
 /**
@@ -193,11 +193,11 @@  discard block
 block discarded – undo
193 193
  *     true si la valeur est considérée active ; false sinon.
194 194
  **/
195 195
 function test_valeur_serveur($truc) {
196
-	if (!$truc) {
197
-		return false;
198
-	}
196
+    if (!$truc) {
197
+        return false;
198
+    }
199 199
 
200
-	return (strtolower($truc) !== 'off');
200
+    return (strtolower($truc) !== 'off');
201 201
 }
202 202
 
203 203
 /**
@@ -207,35 +207,35 @@  discard block
 block discarded – undo
207 207
  */
208 208
 function exec_info_dist() {
209 209
 
210
-	include_spip('inc/autoriser');
211
-	if (autoriser('phpinfos')) {
212
-		$cookies_masques = ['spip_session', 'PHPSESSID'];
213
-		$cookies_backup = [];
214
-		$server_backup = ['HTTP_COOKIE' => $_SERVER['HTTP_COOKIE'] ?? []];
215
-		$env_backup = ['HTTP_COOKIE' => $_ENV['HTTP_COOKIE'] ?? []];
216
-		$mask = '******************************';
217
-		foreach ($cookies_masques as $k) {
218
-			if (!empty($_COOKIE[$k])) {
219
-				$cookies_backup[$k] = $_COOKIE[$k];
220
-				$_SERVER['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_SERVER['HTTP_COOKIE'] ?? []);
221
-				$_ENV['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_ENV['HTTP_COOKIE'] ?? []);
222
-				$_COOKIE[$k] = $mask;
223
-			}
224
-		}
225
-		phpinfo();
226
-		foreach ($cookies_backup as $k => $v) {
227
-			$_COOKIE[$k] = $v;
228
-		}
229
-		foreach ($server_backup as $k => $v) {
230
-			$_SERVER[$k] = $v;
231
-		}
232
-		foreach ($env_backup as $k => $v) {
233
-			$_ENV[$k] = $v;
234
-		}
235
-	} else {
236
-		include_spip('inc/filtres');
237
-		sinon_interdire_acces();
238
-	}
210
+    include_spip('inc/autoriser');
211
+    if (autoriser('phpinfos')) {
212
+        $cookies_masques = ['spip_session', 'PHPSESSID'];
213
+        $cookies_backup = [];
214
+        $server_backup = ['HTTP_COOKIE' => $_SERVER['HTTP_COOKIE'] ?? []];
215
+        $env_backup = ['HTTP_COOKIE' => $_ENV['HTTP_COOKIE'] ?? []];
216
+        $mask = '******************************';
217
+        foreach ($cookies_masques as $k) {
218
+            if (!empty($_COOKIE[$k])) {
219
+                $cookies_backup[$k] = $_COOKIE[$k];
220
+                $_SERVER['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_SERVER['HTTP_COOKIE'] ?? []);
221
+                $_ENV['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_ENV['HTTP_COOKIE'] ?? []);
222
+                $_COOKIE[$k] = $mask;
223
+            }
224
+        }
225
+        phpinfo();
226
+        foreach ($cookies_backup as $k => $v) {
227
+            $_COOKIE[$k] = $v;
228
+        }
229
+        foreach ($server_backup as $k => $v) {
230
+            $_SERVER[$k] = $v;
231
+        }
232
+        foreach ($env_backup as $k => $v) {
233
+            $_ENV[$k] = $v;
234
+        }
235
+    } else {
236
+        include_spip('inc/filtres');
237
+        sinon_interdire_acces();
238
+    }
239 239
 }
240 240
 
241 241
 /**
@@ -245,36 +245,36 @@  discard block
 block discarded – undo
245 245
  *     true si la constante _VERSION_HTML n'est pas définie ou égale à html5
246 246
  **/
247 247
 function html5_permis() {
248
-	return (!defined('_VERSION_HTML') || _VERSION_HTML !== 'html4');
248
+    return (!defined('_VERSION_HTML') || _VERSION_HTML !== 'html4');
249 249
 }
250 250
 
251 251
 /**
252 252
  * Lister les formats image acceptes par les lib et fonctions images
253 253
  */
254 254
 function formats_image_acceptables(?bool $gd = null, bool $svg_allowed = true): array {
255
-	$formats = null;
256
-	if (!is_null($gd)) {
257
-		$config = ($gd ? 'gd_formats' : 'formats_graphiques');
258
-		if (isset($GLOBALS['meta'][$config])) {
259
-			$formats = $GLOBALS['meta'][$config];
260
-			$formats = explode(',', $formats);
261
-			$formats = array_filter($formats);
262
-			$formats = array_map('trim', $formats);
263
-		}
264
-	}
265
-	if (is_null($formats)) {
266
-		include_spip('inc/filtres_images_lib_mini');
267
-		$formats = _image_extensions_acceptees_en_entree();
268
-	}
255
+    $formats = null;
256
+    if (!is_null($gd)) {
257
+        $config = ($gd ? 'gd_formats' : 'formats_graphiques');
258
+        if (isset($GLOBALS['meta'][$config])) {
259
+            $formats = $GLOBALS['meta'][$config];
260
+            $formats = explode(',', $formats);
261
+            $formats = array_filter($formats);
262
+            $formats = array_map('trim', $formats);
263
+        }
264
+    }
265
+    if (is_null($formats)) {
266
+        include_spip('inc/filtres_images_lib_mini');
267
+        $formats = _image_extensions_acceptees_en_entree();
268
+    }
269 269
 
270
-	if ($svg_allowed) {
271
-		if (!in_array('svg', $formats)) {
272
-			$formats[] = 'svg';
273
-		}
274
-	} else {
275
-		$formats = array_diff($formats, ['svg']);
276
-	}
277
-	return $formats;
270
+    if ($svg_allowed) {
271
+        if (!in_array('svg', $formats)) {
272
+            $formats[] = 'svg';
273
+        }
274
+    } else {
275
+        $formats = array_diff($formats, ['svg']);
276
+    }
277
+    return $formats;
278 278
 }
279 279
 
280 280
 
@@ -284,24 +284,24 @@  discard block
 block discarded – undo
284 284
  * @return array|bool
285 285
  */
286 286
 function spip_getimagesize($fichier) {
287
-	if (file_exists($fichier) && ($imagesize = @getimagesize($fichier))) {
288
-		return $imagesize;
289
-	}
287
+    if (file_exists($fichier) && ($imagesize = @getimagesize($fichier))) {
288
+        return $imagesize;
289
+    }
290 290
 
291
-	include_spip('inc/svg');
292
-	if ($attrs = svg_lire_attributs($fichier)) {
293
-		[$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
294
-		$imagesize = [
295
-			$width,
296
-			$height,
297
-			IMAGETYPE_SVG,
298
-			"width=\"{$width}\" height=\"{$height}\"",
299
-			'mime' => 'image/svg+xml'
300
-		];
301
-		return $imagesize;
302
-	}
291
+    include_spip('inc/svg');
292
+    if ($attrs = svg_lire_attributs($fichier)) {
293
+        [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
294
+        $imagesize = [
295
+            $width,
296
+            $height,
297
+            IMAGETYPE_SVG,
298
+            "width=\"{$width}\" height=\"{$height}\"",
299
+            'mime' => 'image/svg+xml'
300
+        ];
301
+        return $imagesize;
302
+    }
303 303
 
304
-	return false;
304
+    return false;
305 305
 }
306 306
 
307 307
 /**
@@ -315,18 +315,18 @@  discard block
 block discarded – undo
315 315
  * @param string $statut
316 316
  */
317 317
 function avertir_auteurs($nom, $message, $statut = '') {
318
-	$alertes = $GLOBALS['meta']['message_alertes_auteurs'];
319
-	if (
320
-		!$alertes || !is_array($alertes = unserialize($alertes))
321
-	) {
322
-		$alertes = [];
323
-	}
318
+    $alertes = $GLOBALS['meta']['message_alertes_auteurs'];
319
+    if (
320
+        !$alertes || !is_array($alertes = unserialize($alertes))
321
+    ) {
322
+        $alertes = [];
323
+    }
324 324
 
325
-	if (!isset($alertes[$statut])) {
326
-		$alertes[$statut] = [];
327
-	}
328
-	$alertes[$statut][$nom] = $message;
329
-	ecrire_meta('message_alertes_auteurs', serialize($alertes));
325
+    if (!isset($alertes[$statut])) {
326
+        $alertes[$statut] = [];
327
+    }
328
+    $alertes[$statut][$nom] = $message;
329
+    ecrire_meta('message_alertes_auteurs', serialize($alertes));
330 330
 }
331 331
 
332 332
 
@@ -351,32 +351,32 @@  discard block
 block discarded – undo
351 351
  *    Avec operateur : bool.
352 352
  **/
353 353
 function spip_version_compare($v1, $v2, $op = null) {
354
-	$v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1));
355
-	$v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2));
356
-	$v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule
357
-	$v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule
354
+    $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1));
355
+    $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2));
356
+    $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule
357
+    $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule
358 358
 
359
-	$v1 = explode('.', $v1);
360
-	$v2 = explode('.', $v2);
361
-	// $v1 est toujours une version, donc sans etoile
362
-	while (count($v1) < count($v2)) {
363
-		$v1[] = '0';
364
-	}
359
+    $v1 = explode('.', $v1);
360
+    $v2 = explode('.', $v2);
361
+    // $v1 est toujours une version, donc sans etoile
362
+    while (count($v1) < count($v2)) {
363
+        $v1[] = '0';
364
+    }
365 365
 
366
-	// $v2 peut etre une borne, donc accepte l'etoile
367
-	$etoile = false;
368
-	foreach ($v1 as $k => $v) {
369
-		if (!isset($v2[$k])) {
370
-			$v2[] = ($etoile && (is_numeric($v) || $v == 'pl' || $v == 'p')) ? $v : '0';
371
-		} else {
372
-			if ($v2[$k] == '*') {
373
-				$etoile = true;
374
-				$v2[$k] = $v;
375
-			}
376
-		}
377
-	}
378
-	$v1 = implode('.', $v1);
379
-	$v2 = implode('.', $v2);
366
+    // $v2 peut etre une borne, donc accepte l'etoile
367
+    $etoile = false;
368
+    foreach ($v1 as $k => $v) {
369
+        if (!isset($v2[$k])) {
370
+            $v2[] = ($etoile && (is_numeric($v) || $v == 'pl' || $v == 'p')) ? $v : '0';
371
+        } else {
372
+            if ($v2[$k] == '*') {
373
+                $etoile = true;
374
+                $v2[$k] = $v;
375
+            }
376
+        }
377
+    }
378
+    $v1 = implode('.', $v1);
379
+    $v2 = implode('.', $v2);
380 380
 
381
-	return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2);
381
+    return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2);
382 382
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @return bool
10 10
  */
11 11
 function test_plugin_actif($plugin) {
12
-	return ($plugin && defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
12
+	return ($plugin && defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true : false;
13 13
 }
14 14
 
15 15
 /**
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 function joli_repertoire($rep) {
25 25
 	$a = substr($rep, 0, 1);
26 26
 	if ($a <> '.' && $a <> '/') {
27
-		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
27
+		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep;
28 28
 	}
29 29
 	$rep = preg_replace(',(^\.\.\/),', '', $rep);
30 30
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			$p -= ($x * 1000);
78 78
 		}
79 79
 
80
-		return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
80
+		return $s.sprintf($s ? '%07.3f ms' : '%.3f ms', $p);
81 81
 	}
82 82
 }
83 83
 
@@ -130,8 +130,8 @@  discard block
 block discarded – undo
130 130
 		$src = '';
131 131
 	}
132 132
 	if ($script) {
133
-		$script = ("/*<![CDATA[*/\n" .
134
-			preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
133
+		$script = ("/*<![CDATA[*/\n".
134
+			preg_replace(',</([^>]*)>,', '<\/\1>', $script).
135 135
 			'/*]]>*/');
136 136
 	}
137 137
 	if ($noscript) {
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
 		foreach ($cookies_masques as $k) {
218 218
 			if (!empty($_COOKIE[$k])) {
219 219
 				$cookies_backup[$k] = $_COOKIE[$k];
220
-				$_SERVER['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_SERVER['HTTP_COOKIE'] ?? []);
221
-				$_ENV['HTTP_COOKIE'] = str_replace("$k=" . $_COOKIE[$k], "$k=$mask", $_ENV['HTTP_COOKIE'] ?? []);
220
+				$_SERVER['HTTP_COOKIE'] = str_replace("$k=".$_COOKIE[$k], "$k=$mask", $_SERVER['HTTP_COOKIE'] ?? []);
221
+				$_ENV['HTTP_COOKIE'] = str_replace("$k=".$_COOKIE[$k], "$k=$mask", $_ENV['HTTP_COOKIE'] ?? []);
222 222
 				$_COOKIE[$k] = $mask;
223 223
 			}
224 224
 		}
Please login to merge, or discard this patch.
ecrire/bootstrap/inc/path.php 3 patches
Indentation   +288 added lines, -288 removed lines patch added patch discarded remove patch
@@ -33,68 +33,68 @@  discard block
 block discarded – undo
33 33
  *     Liste des chemins, par ordre de priorité.
34 34
  **/
35 35
 function _chemin($dir_path = null) {
36
-	static $path_base = null;
37
-	static $path_full = null;
38
-	if ($path_base == null) {
39
-		// Chemin standard depuis l'espace public
40
-		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
41
-			_DIR_RACINE . ':' .
42
-			_DIR_RACINE . 'squelettes-dist/:' .
43
-			_DIR_RACINE . 'prive/:' .
44
-			_DIR_RESTREINT;
45
-		// Ajouter squelettes/
46
-		if (@is_dir(_DIR_RACINE . 'squelettes')) {
47
-			$path = _DIR_RACINE . 'squelettes/:' . $path;
48
-		}
49
-		foreach (explode(':', $path) as $dir) {
50
-			if (strlen($dir) && !str_ends_with($dir, '/')) {
51
-				$dir .= '/';
52
-			}
53
-			$path_base[] = $dir;
54
-		}
55
-		$path_full = $path_base;
56
-		// Et le(s) dossier(s) des squelettes nommes
57
-		if (strlen($GLOBALS['dossier_squelettes'])) {
58
-			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
59
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
60
-			}
61
-		}
62
-		$GLOBALS['path_sig'] = md5(serialize($path_full));
63
-	}
64
-	if ($dir_path === null) {
65
-		return $path_full;
66
-	}
67
-
68
-	if (is_array($dir_path) || strlen($dir_path)) {
69
-		$tete = '';
70
-		if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
71
-			$tete = array_shift($path_base);
72
-		}
73
-		$dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
74
-		$dirs = array_reverse($dirs);
75
-		foreach ($dirs as $dir_path) {
76
-			if (!str_ends_with($dir_path, '/')) {
77
-				$dir_path .= '/';
78
-			}
79
-			if (!in_array($dir_path, $path_base)) {
80
-				array_unshift($path_base, $dir_path);
81
-			}
82
-		}
83
-		if (strlen($tete)) {
84
-			array_unshift($path_base, $tete);
85
-		}
86
-	}
87
-	$path_full = $path_base;
88
-	// Et le(s) dossier(s) des squelettes nommes
89
-	if (strlen($GLOBALS['dossier_squelettes'])) {
90
-		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
91
-			array_unshift($path_full, ((isset($d[0]) && $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
92
-		}
93
-	}
94
-
95
-	$GLOBALS['path_sig'] = md5(serialize($path_full));
96
-
97
-	return $path_full;
36
+    static $path_base = null;
37
+    static $path_full = null;
38
+    if ($path_base == null) {
39
+        // Chemin standard depuis l'espace public
40
+        $path = defined('_SPIP_PATH') ? _SPIP_PATH :
41
+            _DIR_RACINE . ':' .
42
+            _DIR_RACINE . 'squelettes-dist/:' .
43
+            _DIR_RACINE . 'prive/:' .
44
+            _DIR_RESTREINT;
45
+        // Ajouter squelettes/
46
+        if (@is_dir(_DIR_RACINE . 'squelettes')) {
47
+            $path = _DIR_RACINE . 'squelettes/:' . $path;
48
+        }
49
+        foreach (explode(':', $path) as $dir) {
50
+            if (strlen($dir) && !str_ends_with($dir, '/')) {
51
+                $dir .= '/';
52
+            }
53
+            $path_base[] = $dir;
54
+        }
55
+        $path_full = $path_base;
56
+        // Et le(s) dossier(s) des squelettes nommes
57
+        if (strlen($GLOBALS['dossier_squelettes'])) {
58
+            foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
59
+                array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
60
+            }
61
+        }
62
+        $GLOBALS['path_sig'] = md5(serialize($path_full));
63
+    }
64
+    if ($dir_path === null) {
65
+        return $path_full;
66
+    }
67
+
68
+    if (is_array($dir_path) || strlen($dir_path)) {
69
+        $tete = '';
70
+        if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
71
+            $tete = array_shift($path_base);
72
+        }
73
+        $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
74
+        $dirs = array_reverse($dirs);
75
+        foreach ($dirs as $dir_path) {
76
+            if (!str_ends_with($dir_path, '/')) {
77
+                $dir_path .= '/';
78
+            }
79
+            if (!in_array($dir_path, $path_base)) {
80
+                array_unshift($path_base, $dir_path);
81
+            }
82
+        }
83
+        if (strlen($tete)) {
84
+            array_unshift($path_base, $tete);
85
+        }
86
+    }
87
+    $path_full = $path_base;
88
+    // Et le(s) dossier(s) des squelettes nommes
89
+    if (strlen($GLOBALS['dossier_squelettes'])) {
90
+        foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
91
+            array_unshift($path_full, ((isset($d[0]) && $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
92
+        }
93
+    }
94
+
95
+    $GLOBALS['path_sig'] = md5(serialize($path_full));
96
+
97
+    return $path_full;
98 98
 }
99 99
 
100 100
 /**
@@ -107,17 +107,17 @@  discard block
 block discarded – undo
107 107
  * @return array Liste de chemins
108 108
  **/
109 109
 function creer_chemin() {
110
-	$path_a = _chemin();
111
-	static $c = '';
110
+    $path_a = _chemin();
111
+    static $c = '';
112 112
 
113
-	// on calcule le chemin si le dossier skel a change
114
-	if ($c != $GLOBALS['dossier_squelettes']) {
115
-		// assurer le non plantage lors de la montee de version :
116
-		$c = $GLOBALS['dossier_squelettes'];
117
-		$path_a = _chemin(''); // forcer un recalcul du chemin
118
-	}
113
+    // on calcule le chemin si le dossier skel a change
114
+    if ($c != $GLOBALS['dossier_squelettes']) {
115
+        // assurer le non plantage lors de la montee de version :
116
+        $c = $GLOBALS['dossier_squelettes'];
117
+        $path_a = _chemin(''); // forcer un recalcul du chemin
118
+    }
119 119
 
120
-	return $path_a;
120
+    return $path_a;
121 121
 }
122 122
 
123 123
 
@@ -129,61 +129,61 @@  discard block
 block discarded – undo
129 129
  * @return string[] Nom des thèmes.
130 130
  */
131 131
 function lister_themes_prives(): array {
132
-	static $themes = null;
133
-	if (is_null($themes)) {
134
-		// si pas encore definie
135
-		if (!defined('_SPIP_THEME_PRIVE')) {
136
-			define('_SPIP_THEME_PRIVE', 'spip');
137
-		}
138
-		$themes = [_SPIP_THEME_PRIVE];
139
-		// Lors d'une installation neuve, prefs n'est pas definie ; sinon, c'est un tableau sérialisé
140
-		// FIXME: Aussitôt après une demande d'inscription, $prefs vaut une chaine statut_tmp;
141
-		$prefs = $GLOBALS['visiteur_session']['prefs'] ?? [];
142
-		if (is_string($prefs) && stripos($prefs, 'a:') === 0) {
143
-			$prefs = unserialize($prefs);
144
-		} else {
145
-			$prefs = [];
146
-		}
147
-
148
-		$theme = $prefs['theme'] ?? $GLOBALS['theme_prive_defaut'] ?? null;
149
-		if ($theme && $theme !== _SPIP_THEME_PRIVE) {
150
-			// placer le theme choisi en tete
151
-			array_unshift($themes, $theme);
152
-		}
153
-	}
154
-
155
-	return $themes;
132
+    static $themes = null;
133
+    if (is_null($themes)) {
134
+        // si pas encore definie
135
+        if (!defined('_SPIP_THEME_PRIVE')) {
136
+            define('_SPIP_THEME_PRIVE', 'spip');
137
+        }
138
+        $themes = [_SPIP_THEME_PRIVE];
139
+        // Lors d'une installation neuve, prefs n'est pas definie ; sinon, c'est un tableau sérialisé
140
+        // FIXME: Aussitôt après une demande d'inscription, $prefs vaut une chaine statut_tmp;
141
+        $prefs = $GLOBALS['visiteur_session']['prefs'] ?? [];
142
+        if (is_string($prefs) && stripos($prefs, 'a:') === 0) {
143
+            $prefs = unserialize($prefs);
144
+        } else {
145
+            $prefs = [];
146
+        }
147
+
148
+        $theme = $prefs['theme'] ?? $GLOBALS['theme_prive_defaut'] ?? null;
149
+        if ($theme && $theme !== _SPIP_THEME_PRIVE) {
150
+            // placer le theme choisi en tete
151
+            array_unshift($themes, $theme);
152
+        }
153
+    }
154
+
155
+    return $themes;
156 156
 }
157 157
 
158 158
 function find_in_theme($file, $subdir = '', $include = false) {
159
-	static $themefiles = [];
160
-	if (isset($themefiles["$subdir$file"])) {
161
-		return $themefiles["$subdir$file"];
162
-	}
163
-	// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
164
-	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
165
-	if (
166
-		preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
167
-		&& ($file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg')
168
-		&& ($f = find_in_theme("$file_svg_generique"))
169
-	) {
170
-		if (($fsize = substr($f, 0, -6) . $m[1] . '.svg') && file_exists($fsize)) {
171
-			return $themefiles["$subdir$file"] = $fsize;
172
-		}
173
-		else {
174
-			return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
175
-		}
176
-	}
177
-
178
-	$themes = lister_themes_prives();
179
-	foreach ($themes as $theme) {
180
-		if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) {
181
-			return $themefiles["$subdir$file"] = $f;
182
-		}
183
-	}
184
-	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
185
-
186
-	return $themefiles["$subdir$file"] = '';
159
+    static $themefiles = [];
160
+    if (isset($themefiles["$subdir$file"])) {
161
+        return $themefiles["$subdir$file"];
162
+    }
163
+    // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
164
+    // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
165
+    if (
166
+        preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
167
+        && ($file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg')
168
+        && ($f = find_in_theme("$file_svg_generique"))
169
+    ) {
170
+        if (($fsize = substr($f, 0, -6) . $m[1] . '.svg') && file_exists($fsize)) {
171
+            return $themefiles["$subdir$file"] = $fsize;
172
+        }
173
+        else {
174
+            return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
175
+        }
176
+    }
177
+
178
+    $themes = lister_themes_prives();
179
+    foreach ($themes as $theme) {
180
+        if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) {
181
+            return $themefiles["$subdir$file"] = $f;
182
+        }
183
+    }
184
+    spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
185
+
186
+    return $themefiles["$subdir$file"] = '';
187 187
 }
188 188
 
189 189
 
@@ -207,31 +207,31 @@  discard block
 block discarded – undo
207 207
  *     sinon chaîne vide.
208 208
  **/
209 209
 function chemin_image($icone) {
210
-	static $icone_renommer;
211
-	if ($p = strpos($icone, '?')) {
212
-		$icone = substr($icone, 0, $p);
213
-	}
214
-	// gerer le cas d'un double appel en evitant de refaire le travail inutilement
215
-	if (str_contains($icone, '/') && file_exists($icone)) {
216
-		return $icone;
217
-	}
218
-
219
-	// si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
220
-	if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) && ($f = find_in_theme("images/$icone"))) {
221
-		return $f;
222
-	}
223
-	// sinon passer par le module de renommage
224
-	if (is_null($icone_renommer)) {
225
-		$icone_renommer = charger_fonction('icone_renommer', 'inc', true);
226
-	}
227
-	if ($icone_renommer) {
228
-		[$icone, $fonction] = $icone_renommer($icone, '');
229
-		if (file_exists($icone)) {
230
-			return $icone;
231
-		}
232
-	}
233
-
234
-	return find_in_path($icone, _NOM_IMG_PACK);
210
+    static $icone_renommer;
211
+    if ($p = strpos($icone, '?')) {
212
+        $icone = substr($icone, 0, $p);
213
+    }
214
+    // gerer le cas d'un double appel en evitant de refaire le travail inutilement
215
+    if (str_contains($icone, '/') && file_exists($icone)) {
216
+        return $icone;
217
+    }
218
+
219
+    // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
220
+    if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) && ($f = find_in_theme("images/$icone"))) {
221
+        return $f;
222
+    }
223
+    // sinon passer par le module de renommage
224
+    if (is_null($icone_renommer)) {
225
+        $icone_renommer = charger_fonction('icone_renommer', 'inc', true);
226
+    }
227
+    if ($icone_renommer) {
228
+        [$icone, $fonction] = $icone_renommer($icone, '');
229
+        if (file_exists($icone)) {
230
+            return $icone;
231
+        }
232
+    }
233
+
234
+    return find_in_path($icone, _NOM_IMG_PACK);
235 235
 }
236 236
 
237 237
 /**
@@ -262,128 +262,128 @@  discard block
 block discarded – undo
262 262
  *     - false : fichier introuvable
263 263
  **/
264 264
 function find_in_path($file, $dirname = '', $include = false) {
265
-	static $dirs = [];
266
-	static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec
267
-	static $c = '';
268
-
269
-	if (!$file && !strlen($file)) {
270
-		return false;
271
-	}
272
-
273
-	// on calcule le chemin si le dossier skel a change
274
-	if ($c != $GLOBALS['dossier_squelettes']) {
275
-		// assurer le non plantage lors de la montee de version :
276
-		$c = $GLOBALS['dossier_squelettes'];
277
-		creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
278
-	}
279
-
280
-	if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) {
281
-		if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) {
282
-			return false;
283
-		}
284
-		if ($include && !isset($inc[$dirname][$file])) {
285
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
286
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
287
-		}
288
-
289
-		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
290
-	}
291
-
292
-	$a = strrpos($file, '/');
293
-	if ($a !== false) {
294
-		$dirname .= substr($file, 0, ++$a);
295
-		$file = substr($file, $a);
296
-	}
297
-
298
-	foreach (creer_chemin() as $dir) {
299
-		if (!isset($dirs[$a = $dir . $dirname])) {
300
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
301
-		}
302
-		if ($dirs[$a]) {
303
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
304
-				if ($include && !isset($inc[$dirname][$file])) {
305
-					include_once _ROOT_CWD . $a;
306
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
307
-				}
308
-				if (!defined('_SAUVER_CHEMIN')) {
309
-					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
310
-					if (is_null($GLOBALS['path_files'])) {
311
-						return $a;
312
-					}
313
-					define('_SAUVER_CHEMIN', true);
314
-				}
315
-
316
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
317
-			}
318
-		}
319
-	}
320
-
321
-	if ($include) {
322
-		spip_log("include_spip $dirname$file non trouve");
323
-		if ($include === 'required') {
324
-			echo '<pre>',
325
-			'<strong>Erreur Fatale</strong><br />';
326
-			if (function_exists('debug_print_backtrace')) {
327
-				debug_print_backtrace();
328
-			}
329
-			echo '</pre>';
330
-			die("Erreur interne: ne peut inclure $dirname$file");
331
-		}
332
-	}
333
-
334
-	if (!defined('_SAUVER_CHEMIN')) {
335
-		// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
336
-		if (is_null($GLOBALS['path_files'])) {
337
-			return false;
338
-		}
339
-		define('_SAUVER_CHEMIN', true);
340
-	}
341
-
342
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
265
+    static $dirs = [];
266
+    static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec
267
+    static $c = '';
268
+
269
+    if (!$file && !strlen($file)) {
270
+        return false;
271
+    }
272
+
273
+    // on calcule le chemin si le dossier skel a change
274
+    if ($c != $GLOBALS['dossier_squelettes']) {
275
+        // assurer le non plantage lors de la montee de version :
276
+        $c = $GLOBALS['dossier_squelettes'];
277
+        creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
278
+    }
279
+
280
+    if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) {
281
+        if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) {
282
+            return false;
283
+        }
284
+        if ($include && !isset($inc[$dirname][$file])) {
285
+            include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
286
+            $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
287
+        }
288
+
289
+        return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
290
+    }
291
+
292
+    $a = strrpos($file, '/');
293
+    if ($a !== false) {
294
+        $dirname .= substr($file, 0, ++$a);
295
+        $file = substr($file, $a);
296
+    }
297
+
298
+    foreach (creer_chemin() as $dir) {
299
+        if (!isset($dirs[$a = $dir . $dirname])) {
300
+            $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
301
+        }
302
+        if ($dirs[$a]) {
303
+            if (file_exists(_ROOT_CWD . ($a .= $file))) {
304
+                if ($include && !isset($inc[$dirname][$file])) {
305
+                    include_once _ROOT_CWD . $a;
306
+                    $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
307
+                }
308
+                if (!defined('_SAUVER_CHEMIN')) {
309
+                    // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
310
+                    if (is_null($GLOBALS['path_files'])) {
311
+                        return $a;
312
+                    }
313
+                    define('_SAUVER_CHEMIN', true);
314
+                }
315
+
316
+                return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
317
+            }
318
+        }
319
+    }
320
+
321
+    if ($include) {
322
+        spip_log("include_spip $dirname$file non trouve");
323
+        if ($include === 'required') {
324
+            echo '<pre>',
325
+            '<strong>Erreur Fatale</strong><br />';
326
+            if (function_exists('debug_print_backtrace')) {
327
+                debug_print_backtrace();
328
+            }
329
+            echo '</pre>';
330
+            die("Erreur interne: ne peut inclure $dirname$file");
331
+        }
332
+    }
333
+
334
+    if (!defined('_SAUVER_CHEMIN')) {
335
+        // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
336
+        if (is_null($GLOBALS['path_files'])) {
337
+            return false;
338
+        }
339
+        define('_SAUVER_CHEMIN', true);
340
+    }
341
+
342
+    return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
343 343
 }
344 344
 
345 345
 function clear_path_cache() {
346
-	$GLOBALS['path_files'] = [];
347
-	spip_unlink(_CACHE_CHEMIN);
346
+    $GLOBALS['path_files'] = [];
347
+    spip_unlink(_CACHE_CHEMIN);
348 348
 }
349 349
 
350 350
 function load_path_cache() {
351
-	// charger le path des plugins
352
-	if (@is_readable(_CACHE_PLUGINS_PATH)) {
353
-		include_once(_CACHE_PLUGINS_PATH);
354
-	}
355
-	$GLOBALS['path_files'] = [];
356
-	// si le visiteur est admin,
357
-	// on ne recharge pas le cache pour forcer sa mise a jour
358
-	if (
359
-		// la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier
360
-		//AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')
361
-		// utiliser le cookie est un pis aller qui marche 'en general'
362
-		// on blinde par un second test au moment de la lecture de la session
363
-		// !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
364
-		// et en ignorant ce cache en cas de recalcul explicite
365
-		!_request('var_mode')
366
-	) {
367
-		// on essaye de lire directement sans verrou pour aller plus vite
368
-		if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
369
-			// mais si semble corrompu on relit avec un verrou
370
-			if (!$GLOBALS['path_files'] = unserialize($contenu)) {
371
-				lire_fichier(_CACHE_CHEMIN, $contenu);
372
-				if (!$GLOBALS['path_files'] = unserialize($contenu)) {
373
-					$GLOBALS['path_files'] = [];
374
-				}
375
-			}
376
-		}
377
-	}
351
+    // charger le path des plugins
352
+    if (@is_readable(_CACHE_PLUGINS_PATH)) {
353
+        include_once(_CACHE_PLUGINS_PATH);
354
+    }
355
+    $GLOBALS['path_files'] = [];
356
+    // si le visiteur est admin,
357
+    // on ne recharge pas le cache pour forcer sa mise a jour
358
+    if (
359
+        // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier
360
+        //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')
361
+        // utiliser le cookie est un pis aller qui marche 'en general'
362
+        // on blinde par un second test au moment de la lecture de la session
363
+        // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
364
+        // et en ignorant ce cache en cas de recalcul explicite
365
+        !_request('var_mode')
366
+    ) {
367
+        // on essaye de lire directement sans verrou pour aller plus vite
368
+        if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
369
+            // mais si semble corrompu on relit avec un verrou
370
+            if (!$GLOBALS['path_files'] = unserialize($contenu)) {
371
+                lire_fichier(_CACHE_CHEMIN, $contenu);
372
+                if (!$GLOBALS['path_files'] = unserialize($contenu)) {
373
+                    $GLOBALS['path_files'] = [];
374
+                }
375
+            }
376
+        }
377
+    }
378 378
 }
379 379
 
380 380
 function save_path_cache() {
381
-	if (
382
-		defined('_SAUVER_CHEMIN')
383
-		&& _SAUVER_CHEMIN
384
-	) {
385
-		ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
386
-	}
381
+    if (
382
+        defined('_SAUVER_CHEMIN')
383
+        && _SAUVER_CHEMIN
384
+    ) {
385
+        ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
386
+    }
387 387
 }
388 388
 
389 389
 /**
@@ -402,31 +402,31 @@  discard block
 block discarded – undo
402 402
  * @return array
403 403
  */
404 404
 function find_all_in_path($dir, $pattern, $recurs = false) {
405
-	$liste_fichiers = [];
406
-	$maxfiles = 10000;
407
-
408
-	// cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
409
-	// on a pas encore inclus flock.php
410
-	if (!function_exists('preg_files')) {
411
-		include_once _ROOT_RESTREINT . 'inc/flock.php';
412
-	}
413
-
414
-	// Parcourir le chemin
415
-	foreach (creer_chemin() as $d) {
416
-		$f = $d . $dir;
417
-		if (@is_dir($f)) {
418
-			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
419
-			foreach ($liste as $chemin) {
420
-				$nom = basename($chemin);
421
-				// ne prendre que les fichiers pas deja trouves
422
-				// car find_in_path prend le premier qu'il trouve,
423
-				// les autres sont donc masques
424
-				if (!isset($liste_fichiers[$nom])) {
425
-					$liste_fichiers[$nom] = $chemin;
426
-				}
427
-			}
428
-		}
429
-	}
430
-
431
-	return $liste_fichiers;
405
+    $liste_fichiers = [];
406
+    $maxfiles = 10000;
407
+
408
+    // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
409
+    // on a pas encore inclus flock.php
410
+    if (!function_exists('preg_files')) {
411
+        include_once _ROOT_RESTREINT . 'inc/flock.php';
412
+    }
413
+
414
+    // Parcourir le chemin
415
+    foreach (creer_chemin() as $d) {
416
+        $f = $d . $dir;
417
+        if (@is_dir($f)) {
418
+            $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
419
+            foreach ($liste as $chemin) {
420
+                $nom = basename($chemin);
421
+                // ne prendre que les fichiers pas deja trouves
422
+                // car find_in_path prend le premier qu'il trouve,
423
+                // les autres sont donc masques
424
+                if (!isset($liste_fichiers[$nom])) {
425
+                    $liste_fichiers[$nom] = $chemin;
426
+                }
427
+            }
428
+        }
429
+    }
430
+
431
+    return $liste_fichiers;
432 432
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -38,13 +38,13 @@  discard block
 block discarded – undo
38 38
 	if ($path_base == null) {
39 39
 		// Chemin standard depuis l'espace public
40 40
 		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
41
-			_DIR_RACINE . ':' .
42
-			_DIR_RACINE . 'squelettes-dist/:' .
43
-			_DIR_RACINE . 'prive/:' .
41
+			_DIR_RACINE.':'.
42
+			_DIR_RACINE.'squelettes-dist/:'.
43
+			_DIR_RACINE.'prive/:'.
44 44
 			_DIR_RESTREINT;
45 45
 		// Ajouter squelettes/
46
-		if (@is_dir(_DIR_RACINE . 'squelettes')) {
47
-			$path = _DIR_RACINE . 'squelettes/:' . $path;
46
+		if (@is_dir(_DIR_RACINE.'squelettes')) {
47
+			$path = _DIR_RACINE.'squelettes/:'.$path;
48 48
 		}
49 49
 		foreach (explode(':', $path) as $dir) {
50 50
 			if (strlen($dir) && !str_ends_with($dir, '/')) {
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		// Et le(s) dossier(s) des squelettes nommes
57 57
 		if (strlen($GLOBALS['dossier_squelettes'])) {
58 58
 			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
59
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
59
+				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/');
60 60
 			}
61 61
 		}
62 62
 		$GLOBALS['path_sig'] = md5(serialize($path_full));
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
 	if (is_array($dir_path) || strlen($dir_path)) {
69 69
 		$tete = '';
70
-		if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
70
+		if (reset($path_base) == _DIR_RACINE.'squelettes/') {
71 71
 			$tete = array_shift($path_base);
72 72
 		}
73 73
 		$dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path));
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	// Et le(s) dossier(s) des squelettes nommes
89 89
 	if (strlen($GLOBALS['dossier_squelettes'])) {
90 90
 		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
91
-			array_unshift($path_full, ((isset($d[0]) && $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
91
+			array_unshift($path_full, ((isset($d[0]) && $d[0] == '/') ? '' : _DIR_RACINE).$d.'/');
92 92
 		}
93 93
 	}
94 94
 
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
 	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
165 165
 	if (
166 166
 		preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
167
-		&& ($file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg')
167
+		&& ($file_svg_generique = substr($file, 0, -strlen($m[0])).'-xx.svg')
168 168
 		&& ($f = find_in_theme("$file_svg_generique"))
169 169
 	) {
170
-		if (($fsize = substr($f, 0, -6) . $m[1] . '.svg') && file_exists($fsize)) {
170
+		if (($fsize = substr($f, 0, -6).$m[1].'.svg') && file_exists($fsize)) {
171 171
 			return $themefiles["$subdir$file"] = $fsize;
172 172
 		}
173 173
 		else {
174
-			return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
174
+			return $themefiles["$subdir$file"] = "$f?".$m[1].'px';
175 175
 		}
176 176
 	}
177 177
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 			return $themefiles["$subdir$file"] = $f;
182 182
 		}
183 183
 	}
184
-	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
184
+	spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme');
185 185
 
186 186
 	return $themefiles["$subdir$file"] = '';
187 187
 }
@@ -282,8 +282,8 @@  discard block
 block discarded – undo
282 282
 			return false;
283 283
 		}
284 284
 		if ($include && !isset($inc[$dirname][$file])) {
285
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
286
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
285
+			include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
286
+			$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
287 287
 		}
288 288
 
289 289
 		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
@@ -296,14 +296,14 @@  discard block
 block discarded – undo
296 296
 	}
297 297
 
298 298
 	foreach (creer_chemin() as $dir) {
299
-		if (!isset($dirs[$a = $dir . $dirname])) {
300
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
299
+		if (!isset($dirs[$a = $dir.$dirname])) {
300
+			$dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a);
301 301
 		}
302 302
 		if ($dirs[$a]) {
303
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
303
+			if (file_exists(_ROOT_CWD.($a .= $file))) {
304 304
 				if ($include && !isset($inc[$dirname][$file])) {
305
-					include_once _ROOT_CWD . $a;
306
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
305
+					include_once _ROOT_CWD.$a;
306
+					$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
307 307
 				}
308 308
 				if (!defined('_SAUVER_CHEMIN')) {
309 309
 					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 					define('_SAUVER_CHEMIN', true);
314 314
 				}
315 315
 
316
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
316
+				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a;
317 317
 			}
318 318
 		}
319 319
 	}
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 		define('_SAUVER_CHEMIN', true);
340 340
 	}
341 341
 
342
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
342
+	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false;
343 343
 }
344 344
 
345 345
 function clear_path_cache() {
@@ -408,12 +408,12 @@  discard block
 block discarded – undo
408 408
 	// cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
409 409
 	// on a pas encore inclus flock.php
410 410
 	if (!function_exists('preg_files')) {
411
-		include_once _ROOT_RESTREINT . 'inc/flock.php';
411
+		include_once _ROOT_RESTREINT.'inc/flock.php';
412 412
 	}
413 413
 
414 414
 	// Parcourir le chemin
415 415
 	foreach (creer_chemin() as $d) {
416
-		$f = $d . $dir;
416
+		$f = $d.$dir;
417 417
 		if (@is_dir($f)) {
418 418
 			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs);
419 419
 			foreach ($liste as $chemin) {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -169,8 +169,7 @@
 block discarded – undo
169 169
 	) {
170 170
 		if (($fsize = substr($f, 0, -6) . $m[1] . '.svg') && file_exists($fsize)) {
171 171
 			return $themefiles["$subdir$file"] = $fsize;
172
-		}
173
-		else {
172
+		} else {
174 173
 			return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px';
175 174
 		}
176 175
 	}
Please login to merge, or discard this patch.
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.