Completed
Push — master ( 8b5a3c...b0cbd6 )
by cam
01:56
created
ecrire/bootstrap/mitigation.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -4,18 +4,18 @@
 block discarded – undo
4 4
  * Détecteur de robot d'indexation
5 5
  */
6 6
 if (!defined('_IS_BOT')) {
7
-	define(
8
-		'_IS_BOT',
9
-		isset($_SERVER['HTTP_USER_AGENT'])
10
-		&& preg_match(
11
-			// mots generiques
12
-			',bot|slurp|crawler|spider|webvac|yandex|'
13
-			// MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot
14
-			. 'MSIE 6\.0|'
15
-			// UA plus cibles
16
-			. '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti'
17
-			. ',i',
18
-			(string)$_SERVER['HTTP_USER_AGENT']
19
-		)
20
-	);
7
+    define(
8
+        '_IS_BOT',
9
+        isset($_SERVER['HTTP_USER_AGENT'])
10
+        && preg_match(
11
+            // mots generiques
12
+            ',bot|slurp|crawler|spider|webvac|yandex|'
13
+            // MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot
14
+            . 'MSIE 6\.0|'
15
+            // UA plus cibles
16
+            . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti'
17
+            . ',i',
18
+            (string)$_SERVER['HTTP_USER_AGENT']
19
+        )
20
+    );
21 21
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 			// UA plus cibles
16 16
 			. '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti'
17 17
 			. ',i',
18
-			(string)$_SERVER['HTTP_USER_AGENT']
18
+			(string) $_SERVER['HTTP_USER_AGENT']
19 19
 		)
20 20
 	);
21 21
 }
Please login to merge, or discard this patch.
ecrire/bootstrap/proxy.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -8,48 +8,48 @@
 block discarded – undo
8 8
  */
9 9
 
10 10
 if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
11
-	if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
12
-		$_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST'];
13
-	}
14
-	if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) {
15
-		$_SERVER['HTTP_X_FORWARDED_PORT'] = 443;
16
-	}
11
+    if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
12
+        $_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST'];
13
+    }
14
+    if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) {
15
+        $_SERVER['HTTP_X_FORWARDED_PORT'] = 443;
16
+    }
17 17
 }
18 18
 
19 19
 if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
20
-	if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) && is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])) {
21
-		$_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT'];
22
-		if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
23
-			$_SERVER['HTTPS'] = 'on';
24
-			if (isset($_SERVER['REQUEST_SCHEME'])) {
25
-				$_SERVER['REQUEST_SCHEME'] = 'https';
26
-			}
27
-		}
28
-	}
29
-	$host = $_SERVER['HTTP_X_FORWARDED_HOST'];
30
-	if (str_contains((string) $host, ',')) {
31
-		$h = explode(',', (string) $host);
32
-		$host = trim(reset($h));
33
-	}
34
-	// securite sur le contenu de l'entete
35
-	$host = strtr($host, "<>?\"\{\}\$'` \r\n", '____________');
36
-	$_SERVER['HTTP_HOST'] = $host;
20
+    if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) && is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])) {
21
+        $_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT'];
22
+        if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
23
+            $_SERVER['HTTPS'] = 'on';
24
+            if (isset($_SERVER['REQUEST_SCHEME'])) {
25
+                $_SERVER['REQUEST_SCHEME'] = 'https';
26
+            }
27
+        }
28
+    }
29
+    $host = $_SERVER['HTTP_X_FORWARDED_HOST'];
30
+    if (str_contains((string) $host, ',')) {
31
+        $h = explode(',', (string) $host);
32
+        $host = trim(reset($h));
33
+    }
34
+    // securite sur le contenu de l'entete
35
+    $host = strtr($host, "<>?\"\{\}\$'` \r\n", '____________');
36
+    $_SERVER['HTTP_HOST'] = $host;
37 37
 }
38 38
 
39 39
 //
40 40
 // On note le numero IP du client dans la variable $ip
41 41
 //
42 42
 if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
43
-	$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
44
-	if (str_contains((string) $ip, ',')) {
45
-		$ip = explode(',', (string) $ip);
46
-		$ip = reset($ip);
47
-	}
48
-	// ecraser $_SERVER['REMOTE_ADDR'] si elle est en localhost
49
-	if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] === '127.0.0.1') {
50
-		$_SERVER['REMOTE_ADDR'] = $ip;
51
-	}
43
+    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
44
+    if (str_contains((string) $ip, ',')) {
45
+        $ip = explode(',', (string) $ip);
46
+        $ip = reset($ip);
47
+    }
48
+    // ecraser $_SERVER['REMOTE_ADDR'] si elle est en localhost
49
+    if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] === '127.0.0.1') {
50
+        $_SERVER['REMOTE_ADDR'] = $ip;
51
+    }
52 52
 }
53 53
 if (isset($_SERVER['REMOTE_ADDR'])) {
54
-	$ip = $_SERVER['REMOTE_ADDR'];
54
+    $ip = $_SERVER['REMOTE_ADDR'];
55 55
 }
Please login to merge, or discard this patch.
ecrire/bootstrap/inc/i18n.php 2 patches
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -28,52 +28,52 @@  discard block
 block discarded – undo
28 28
  *     texte
29 29
  */
30 30
 function _T($texte, $args = [], $options = []) {
31
-	static $traduire = false;
32
-	$o = ['class' => '', 'force' => true, 'sanitize' => true];
33
-	if ($options) {
34
-		// support de l'ancien argument $class
35
-		if (is_string($options)) {
36
-			$options = ['class' => $options];
37
-		}
38
-		$o = array_merge($o, $options);
39
-	}
31
+    static $traduire = false;
32
+    $o = ['class' => '', 'force' => true, 'sanitize' => true];
33
+    if ($options) {
34
+        // support de l'ancien argument $class
35
+        if (is_string($options)) {
36
+            $options = ['class' => $options];
37
+        }
38
+        $o = array_merge($o, $options);
39
+    }
40 40
 
41
-	if (!$traduire) {
42
-		$traduire = charger_fonction('traduire', 'inc');
43
-		include_spip('inc/lang');
44
-	}
41
+    if (!$traduire) {
42
+        $traduire = charger_fonction('traduire', 'inc');
43
+        include_spip('inc/lang');
44
+    }
45 45
 
46
-	// On peut passer explicitement la langue dans le tableau
47
-	// On utilise le même nom de variable que la globale
48
-	if (isset($args['spip_lang'])) {
49
-		$lang = $args['spip_lang'];
50
-		// On l'enleve pour ne pas le passer au remplacement
51
-		unset($args['spip_lang']);
52
-	} // Sinon on prend la langue du contexte
53
-	else {
54
-		$lang = $GLOBALS['spip_lang'];
55
-	}
56
-	$text = $traduire($texte, $lang);
46
+    // On peut passer explicitement la langue dans le tableau
47
+    // On utilise le même nom de variable que la globale
48
+    if (isset($args['spip_lang'])) {
49
+        $lang = $args['spip_lang'];
50
+        // On l'enleve pour ne pas le passer au remplacement
51
+        unset($args['spip_lang']);
52
+    } // Sinon on prend la langue du contexte
53
+    else {
54
+        $lang = $GLOBALS['spip_lang'];
55
+    }
56
+    $text = $traduire($texte, $lang);
57 57
 
58
-	if ($text === null || !strlen($text)) {
59
-		if (!$o['force']) {
60
-			return '';
61
-		}
58
+    if ($text === null || !strlen($text)) {
59
+        if (!$o['force']) {
60
+            return '';
61
+        }
62 62
 
63
-		$text = $texte;
63
+        $text = $texte;
64 64
 
65
-		// pour les chaines non traduites, assurer un service minimum
66
-		if (!$GLOBALS['test_i18n'] && _request('var_mode') != 'traduction') {
67
-			$n = strpos($text, ':');
68
-			if ($n !== false) {
69
-				$text = substr($text, $n + 1);
70
-			}
71
-			$text = str_replace('_', ' ', $text);
72
-		}
73
-		$o['class'] = null;
74
-	}
65
+        // pour les chaines non traduites, assurer un service minimum
66
+        if (!$GLOBALS['test_i18n'] && _request('var_mode') != 'traduction') {
67
+            $n = strpos($text, ':');
68
+            if ($n !== false) {
69
+                $text = substr($text, $n + 1);
70
+            }
71
+            $text = str_replace('_', ' ', $text);
72
+        }
73
+        $o['class'] = null;
74
+    }
75 75
 
76
-	return _L($text, $args, $o);
76
+    return _L($text, $args, $o);
77 77
 }
78 78
 
79 79
 
@@ -100,53 +100,53 @@  discard block
 block discarded – undo
100 100
  *     texte
101 101
  */
102 102
 function _L($text, $args = [], $options = []) {
103
-	$f = $text;
104
-	$defaut_options = [
105
-		'class' => null,
106
-		'sanitize' => true,
107
-	];
108
-	// support de l'ancien argument $class
109
-	if ($options && is_string($options)) {
110
-		$options = ['class' => $options];
111
-	}
112
-	if (is_array($options)) {
113
-		$options += $defaut_options;
114
-	} else {
115
-		$options = $defaut_options;
116
-	}
103
+    $f = $text;
104
+    $defaut_options = [
105
+        'class' => null,
106
+        'sanitize' => true,
107
+    ];
108
+    // support de l'ancien argument $class
109
+    if ($options && is_string($options)) {
110
+        $options = ['class' => $options];
111
+    }
112
+    if (is_array($options)) {
113
+        $options += $defaut_options;
114
+    } else {
115
+        $options = $defaut_options;
116
+    }
117 117
 
118
-	if (is_array($args) && count($args)) {
119
-		if (!function_exists('interdire_scripts')) {
120
-			include_spip('inc/texte');
121
-		}
122
-		if (!function_exists('echapper_html_suspect')) {
123
-			include_spip('inc/texte_mini');
124
-		}
125
-		foreach ($args as $name => $value) {
126
-			if (str_contains($text, (string) "@$name@")) {
127
-				if ($options['sanitize']) {
128
-					$value = echapper_html_suspect($value);
129
-					$value = interdire_scripts($value, -1);
130
-				}
131
-				if (!empty($options['class'])) {
132
-					$value = "<span class='" . $options['class'] . "'>$value</span>";
133
-				}
134
-				$text = str_replace("@$name@", (string) $value, (string) $text);
135
-				unset($args[$name]);
136
-			}
137
-		}
138
-		// Si des variables n'ont pas ete inserees, le signaler
139
-		// (chaines de langues pas a jour)
140
-		if ($args) {
141
-			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
142
-		}
143
-	}
118
+    if (is_array($args) && count($args)) {
119
+        if (!function_exists('interdire_scripts')) {
120
+            include_spip('inc/texte');
121
+        }
122
+        if (!function_exists('echapper_html_suspect')) {
123
+            include_spip('inc/texte_mini');
124
+        }
125
+        foreach ($args as $name => $value) {
126
+            if (str_contains($text, (string) "@$name@")) {
127
+                if ($options['sanitize']) {
128
+                    $value = echapper_html_suspect($value);
129
+                    $value = interdire_scripts($value, -1);
130
+                }
131
+                if (!empty($options['class'])) {
132
+                    $value = "<span class='" . $options['class'] . "'>$value</span>";
133
+                }
134
+                $text = str_replace("@$name@", (string) $value, (string) $text);
135
+                unset($args[$name]);
136
+            }
137
+        }
138
+        // Si des variables n'ont pas ete inserees, le signaler
139
+        // (chaines de langues pas a jour)
140
+        if ($args) {
141
+            spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
142
+        }
143
+    }
144 144
 
145
-	if (($GLOBALS['test_i18n'] || _request('var_mode') == 'traduction') && is_null($options['class'])) {
146
-		return "<span class='debug-traduction-erreur'>$text</span>";
147
-	} else {
148
-		return $text;
149
-	}
145
+    if (($GLOBALS['test_i18n'] || _request('var_mode') == 'traduction') && is_null($options['class'])) {
146
+        return "<span class='debug-traduction-erreur'>$text</span>";
147
+    } else {
148
+        return $text;
149
+    }
150 150
 }
151 151
 
152 152
 
@@ -169,19 +169,19 @@  discard block
 block discarded – undo
169 169
  *     - string Langue utilisée.
170 170
  **/
171 171
 function lang_select($lang = null) {
172
-	static $pile_langues = [];
173
-	if (!function_exists('changer_langue')) {
174
-		include_spip('inc/lang');
175
-	}
176
-	if ($lang === null) {
177
-		$lang = array_pop($pile_langues);
178
-	} else {
179
-		array_push($pile_langues, $GLOBALS['spip_lang']);
180
-	}
181
-	if (isset($GLOBALS['spip_lang']) && $lang == $GLOBALS['spip_lang']) {
182
-		return $lang;
183
-	}
184
-	changer_langue($lang);
172
+    static $pile_langues = [];
173
+    if (!function_exists('changer_langue')) {
174
+        include_spip('inc/lang');
175
+    }
176
+    if ($lang === null) {
177
+        $lang = array_pop($pile_langues);
178
+    } else {
179
+        array_push($pile_langues, $GLOBALS['spip_lang']);
180
+    }
181
+    if (isset($GLOBALS['spip_lang']) && $lang == $GLOBALS['spip_lang']) {
182
+        return $lang;
183
+    }
184
+    changer_langue($lang);
185 185
 
186
-	return $lang;
186
+    return $lang;
187 187
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 					$value = interdire_scripts($value, -1);
130 130
 				}
131 131
 				if (!empty($options['class'])) {
132
-					$value = "<span class='" . $options['class'] . "'>$value</span>";
132
+					$value = "<span class='".$options['class']."'>$value</span>";
133 133
 				}
134 134
 				$text = str_replace("@$name@", (string) $value, (string) $text);
135 135
 				unset($args[$name]);
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 		// Si des variables n'ont pas ete inserees, le signaler
139 139
 		// (chaines de langues pas a jour)
140 140
 		if ($args) {
141
-			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
141
+			spip_log("$f:  variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG);
142 142
 		}
143 143
 	}
144 144
 
Please login to merge, or discard this patch.
ecrire/bootstrap/inc/templating.php 2 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -18,13 +18,13 @@  discard block
 block discarded – undo
18 18
  *     - string si $message à false.
19 19
  **/
20 20
 function erreur_squelette($message = '', $lieu = '') {
21
-	$debusquer = charger_fonction('debusquer', 'public');
22
-	if (is_array($lieu)) {
23
-		include_spip('public/compiler');
24
-		$lieu = reconstruire_contexte_compil($lieu);
25
-	}
21
+    $debusquer = charger_fonction('debusquer', 'public');
22
+    if (is_array($lieu)) {
23
+        include_spip('public/compiler');
24
+        $lieu = reconstruire_contexte_compil($lieu);
25
+    }
26 26
 
27
-	return $debusquer($message, $lieu);
27
+    return $debusquer($message, $lieu);
28 28
 }
29 29
 
30 30
 /**
@@ -61,106 +61,106 @@  discard block
 block discarded – undo
61 61
  *     - ou tableau d'information sur le squelette.
62 62
  */
63 63
 function recuperer_fond($fond, $contexte = [], $options = [], string $connect = '') {
64
-	if (!function_exists('evaluer_fond')) {
65
-		include_spip('public/assembler');
66
-	}
67
-	// assurer la compat avec l'ancienne syntaxe
68
-	// (trim etait le 3eme argument, par defaut a true)
69
-	if (!is_array($options)) {
70
-		$options = ['trim' => $options];
71
-	}
72
-	if (!isset($options['trim'])) {
73
-		$options['trim'] = true;
74
-	}
75
-
76
-	if (isset($contexte['connect'])) {
77
-		$connect = $contexte['connect'];
78
-		unset($contexte['connect']);
79
-	}
80
-
81
-	$texte = '';
82
-	$pages = [];
83
-	$lang_select = '';
84
-	if (!isset($options['etoile']) || !$options['etoile']) {
85
-		// Si on a inclus sans fixer le critere de lang, on prend la langue courante
86
-		if (!isset($contexte['lang'])) {
87
-			$contexte['lang'] = $GLOBALS['spip_lang'];
88
-		}
89
-
90
-		if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
91
-			$lang_select = lang_select($contexte['lang']);
92
-		}
93
-	}
94
-
95
-	if (!isset($GLOBALS['_INC_PUBLIC'])) {
96
-		$GLOBALS['_INC_PUBLIC'] = 0;
97
-	}
98
-
99
-	$GLOBALS['_INC_PUBLIC']++;
100
-
101
-	// fix #4235
102
-	$cache_utilise_session_appelant	= ($GLOBALS['cache_utilise_session'] ?? null);
103
-
104
-
105
-	foreach (is_array($fond) ? $fond : [$fond] as $f) {
106
-		unset($GLOBALS['cache_utilise_session']);	// fix #4235
107
-
108
-		$page = evaluer_fond($f, $contexte, $connect);
109
-		if ($page === '') {
110
-			$c = $options['compil'] ?? '';
111
-			$a = ['fichier' => $f];
112
-			$erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
113
-			erreur_squelette($erreur, $c);
114
-			// eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
115
-			$page = ['texte' => '', 'erreur' => $erreur];
116
-		}
117
-
118
-		$page = pipeline('recuperer_fond', [
119
-			'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect],
120
-			'data' => $page
121
-		]);
122
-		if (isset($options['ajax']) && $options['ajax']) {
123
-			if (!function_exists('encoder_contexte_ajax')) {
124
-				include_spip('inc/filtres');
125
-			}
126
-			$page['texte'] = encoder_contexte_ajax(
127
-				array_merge(
128
-					$contexte,
129
-					['fond' => $f],
130
-					($connect ? ['connect' => $connect] : [])
131
-				),
132
-				'',
133
-				$page['texte'],
134
-				$options['ajax']
135
-			);
136
-		}
137
-
138
-		if (isset($options['raw']) && $options['raw']) {
139
-			$pages[] = $page;
140
-		} else {
141
-			$texte .= $options['trim'] ? rtrim($page['texte'] ?? '') : $page['texte'];
142
-		}
143
-
144
-		// contamination de la session appelante, pour les inclusions statiques
145
-		if (isset($page['invalideurs']['session'])) {
146
-			$cache_utilise_session_appelant = $page['invalideurs']['session'];
147
-		}
148
-	}
149
-
150
-	// restaurer le sessionnement du contexte appelant,
151
-	// éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée
152
-	if (isset($cache_utilise_session_appelant)) {
153
-		$GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant;
154
-	}
155
-
156
-	$GLOBALS['_INC_PUBLIC']--;
157
-
158
-	if ($lang_select) {
159
-		lang_select();
160
-	}
161
-	if (isset($options['raw']) && $options['raw']) {
162
-		return is_array($fond) ? $pages : reset($pages);
163
-	} else {
164
-		return $options['trim'] ? ltrim($texte) : $texte;
165
-	}
64
+    if (!function_exists('evaluer_fond')) {
65
+        include_spip('public/assembler');
66
+    }
67
+    // assurer la compat avec l'ancienne syntaxe
68
+    // (trim etait le 3eme argument, par defaut a true)
69
+    if (!is_array($options)) {
70
+        $options = ['trim' => $options];
71
+    }
72
+    if (!isset($options['trim'])) {
73
+        $options['trim'] = true;
74
+    }
75
+
76
+    if (isset($contexte['connect'])) {
77
+        $connect = $contexte['connect'];
78
+        unset($contexte['connect']);
79
+    }
80
+
81
+    $texte = '';
82
+    $pages = [];
83
+    $lang_select = '';
84
+    if (!isset($options['etoile']) || !$options['etoile']) {
85
+        // Si on a inclus sans fixer le critere de lang, on prend la langue courante
86
+        if (!isset($contexte['lang'])) {
87
+            $contexte['lang'] = $GLOBALS['spip_lang'];
88
+        }
89
+
90
+        if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
91
+            $lang_select = lang_select($contexte['lang']);
92
+        }
93
+    }
94
+
95
+    if (!isset($GLOBALS['_INC_PUBLIC'])) {
96
+        $GLOBALS['_INC_PUBLIC'] = 0;
97
+    }
98
+
99
+    $GLOBALS['_INC_PUBLIC']++;
100
+
101
+    // fix #4235
102
+    $cache_utilise_session_appelant	= ($GLOBALS['cache_utilise_session'] ?? null);
103
+
104
+
105
+    foreach (is_array($fond) ? $fond : [$fond] as $f) {
106
+        unset($GLOBALS['cache_utilise_session']);	// fix #4235
107
+
108
+        $page = evaluer_fond($f, $contexte, $connect);
109
+        if ($page === '') {
110
+            $c = $options['compil'] ?? '';
111
+            $a = ['fichier' => $f];
112
+            $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
113
+            erreur_squelette($erreur, $c);
114
+            // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
115
+            $page = ['texte' => '', 'erreur' => $erreur];
116
+        }
117
+
118
+        $page = pipeline('recuperer_fond', [
119
+            'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect],
120
+            'data' => $page
121
+        ]);
122
+        if (isset($options['ajax']) && $options['ajax']) {
123
+            if (!function_exists('encoder_contexte_ajax')) {
124
+                include_spip('inc/filtres');
125
+            }
126
+            $page['texte'] = encoder_contexte_ajax(
127
+                array_merge(
128
+                    $contexte,
129
+                    ['fond' => $f],
130
+                    ($connect ? ['connect' => $connect] : [])
131
+                ),
132
+                '',
133
+                $page['texte'],
134
+                $options['ajax']
135
+            );
136
+        }
137
+
138
+        if (isset($options['raw']) && $options['raw']) {
139
+            $pages[] = $page;
140
+        } else {
141
+            $texte .= $options['trim'] ? rtrim($page['texte'] ?? '') : $page['texte'];
142
+        }
143
+
144
+        // contamination de la session appelante, pour les inclusions statiques
145
+        if (isset($page['invalideurs']['session'])) {
146
+            $cache_utilise_session_appelant = $page['invalideurs']['session'];
147
+        }
148
+    }
149
+
150
+    // restaurer le sessionnement du contexte appelant,
151
+    // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée
152
+    if (isset($cache_utilise_session_appelant)) {
153
+        $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant;
154
+    }
155
+
156
+    $GLOBALS['_INC_PUBLIC']--;
157
+
158
+    if ($lang_select) {
159
+        lang_select();
160
+    }
161
+    if (isset($options['raw']) && $options['raw']) {
162
+        return is_array($fond) ? $pages : reset($pages);
163
+    } else {
164
+        return $options['trim'] ? ltrim($texte) : $texte;
165
+    }
166 166
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -99,11 +99,11 @@
 block discarded – undo
99 99
 	$GLOBALS['_INC_PUBLIC']++;
100 100
 
101 101
 	// fix #4235
102
-	$cache_utilise_session_appelant	= ($GLOBALS['cache_utilise_session'] ?? null);
102
+	$cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null);
103 103
 
104 104
 
105 105
 	foreach (is_array($fond) ? $fond : [$fond] as $f) {
106
-		unset($GLOBALS['cache_utilise_session']);	// fix #4235
106
+		unset($GLOBALS['cache_utilise_session']); // fix #4235
107 107
 
108 108
 		$page = evaluer_fond($f, $contexte, $connect);
109 109
 		if ($page === '') {
Please login to merge, or discard this patch.
ecrire/bootstrap/inc/loading.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -32,12 +32,12 @@  discard block
 block discarded – undo
32 32
 	if (strlen($dossier) && !str_ends_with($dossier, '/')) {
33 33
 		$dossier .= '/';
34 34
 	}
35
-	$f = str_replace('/', '_', $dossier) . $nom;
35
+	$f = str_replace('/', '_', $dossier).$nom;
36 36
 
37 37
 	if (function_exists($f)) {
38 38
 		return $f;
39 39
 	}
40
-	if (function_exists($g = $f . '_dist')) {
40
+	if (function_exists($g = $f.'_dist')) {
41 41
 		return $g;
42 42
 	}
43 43
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	// passer en minuscules (cf les balises de formulaires)
59 59
 	// et inclure le fichier
60 60
 	if (
61
-		!($inc = include_spip($dossier . ($d = strtolower($nom))))
61
+		!($inc = include_spip($dossier.($d = strtolower($nom))))
62 62
 		&& strlen(dirname($dossier))
63 63
 		&& dirname($dossier) != '.'
64 64
 	) {
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	}
77 77
 
78 78
 	// Echec : message d'erreur
79
-	spip_log("fonction $nom ($f ou $g) indisponible" .
79
+	spip_log("fonction $nom ($f ou $g) indisponible".
80 80
 		($inc ? '' : " (fichier $d absent de $dossier)"));
81 81
 
82 82
 	include_spip('inc/minipres');
@@ -84,12 +84,12 @@  discard block
 block discarded – undo
84 84
 	echo minipres(
85 85
 		_T('forum_titre_erreur'),
86 86
 		$inc ?
87
-			_T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>'])
87
+			_T('fonction_introuvable', ['fonction' => '<code>'.spip_htmlentities($f).'</code>'])
88 88
 			. '<br />'
89
-			. _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>'])
89
+			. _T('fonction_introuvable', ['fonction' => '<code>'.spip_htmlentities($g).'</code>'])
90 90
 			:
91
-			_T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']),
92
-		['all_inline' => true,'status' => 404]
91
+			_T('fichier_introuvable', ['fichier' => '<code>'.spip_htmlentities($d).'</code>']),
92
+		['all_inline' => true, 'status' => 404]
93 93
 	);
94 94
 	exit;
95 95
 }
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
  *     - string : chemin du fichier trouvé
136 136
  **/
137 137
 function include_spip($f, $include = true) {
138
-	return find_in_path($f . '.php', '', $include);
138
+	return find_in_path($f.'.php', '', $include);
139 139
 }
140 140
 
141 141
 /**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
  *     - string : chemin du fichier trouvé
156 156
  **/
157 157
 function require_spip($f) {
158
-	return find_in_path($f . '.php', '', 'required');
158
+	return find_in_path($f.'.php', '', 'required');
159 159
 }
160 160
 
161 161
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 		// donc il faut l'inclure "en globals"
174 174
 		if ($f = find_in_path('mes_fonctions.php')) {
175 175
 			global $dossier_squelettes;
176
-			include_once(_ROOT_CWD . $f);
176
+			include_once(_ROOT_CWD.$f);
177 177
 		}
178 178
 
179 179
 		if (@is_readable(_CACHE_PLUGINS_FCT)) {
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
 	if ($type === 'defaut') {
202 202
 		$objet = objet_type($quoi);
203 203
 		if (
204
-			($f = charger_fonction('generer_' . $objet . '_url', 'urls', true))
205
-			|| ($f = charger_fonction('generer_url_' . $objet, 'urls', true)) // deprecated
204
+			($f = charger_fonction('generer_'.$objet.'_url', 'urls', true))
205
+			|| ($f = charger_fonction('generer_url_'.$objet, 'urls', true)) // deprecated
206 206
 		) {
207 207
 			return $f;
208 208
 		}
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	}
216 216
 
217 217
 	// inclure le module d'url
218
-	include_spip('urls/' . $url_type);
218
+	include_spip('urls/'.$url_type);
219 219
 
220 220
 	switch ($quoi) {
221 221
 		case 'page':
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
  * @return array|string
278 278
  */
279 279
 function trouver_fond($nom, $dir = '', $pathinfo = false) {
280
-	$f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
280
+	$f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : '');
281 281
 	if (!$pathinfo) {
282 282
 		return $f;
283 283
 	}
Please login to merge, or discard this patch.
Indentation   +190 added lines, -190 removed lines patch added patch discarded remove patch
@@ -27,71 +27,71 @@  discard block
 block discarded – undo
27 27
  *     Nom de la fonction, ou false.
28 28
  */
29 29
 function charger_fonction($nom, $dossier = 'exec', $continue = false) {
30
-	static $echecs = [];
31
-
32
-	if (strlen($dossier) && !str_ends_with($dossier, '/')) {
33
-		$dossier .= '/';
34
-	}
35
-	$f = str_replace('/', '_', $dossier) . $nom;
36
-
37
-	if (function_exists($f)) {
38
-		return $f;
39
-	}
40
-	if (function_exists($g = $f . '_dist')) {
41
-		return $g;
42
-	}
43
-
44
-	if (isset($echecs[$f])) {
45
-		return $echecs[$f];
46
-	}
47
-	// Sinon charger le fichier de declaration si plausible
48
-
49
-	if (!preg_match(',^\w+$,', $f)) {
50
-		if ($continue) {
51
-			return false;
52
-		} //appel interne, on passe
53
-		include_spip('inc/minipres');
54
-		echo minipres();
55
-		exit;
56
-	}
57
-
58
-	// passer en minuscules (cf les balises de formulaires)
59
-	// et inclure le fichier
60
-	if (
61
-		!($inc = include_spip($dossier . ($d = strtolower($nom))))
62
-		&& strlen(dirname($dossier))
63
-		&& dirname($dossier) != '.'
64
-	) {
65
-		include_spip(substr($dossier, 0, -1));
66
-	}
67
-	if (function_exists($f)) {
68
-		return $f;
69
-	}
70
-	if (function_exists($g)) {
71
-		return $g;
72
-	}
73
-
74
-	if ($continue) {
75
-		return $echecs[$f] = false;
76
-	}
77
-
78
-	// Echec : message d'erreur
79
-	spip_log("fonction $nom ($f ou $g) indisponible" .
80
-		($inc ? '' : " (fichier $d absent de $dossier)"));
81
-
82
-	include_spip('inc/minipres');
83
-	include_spip('inc/filtres_mini');
84
-	echo minipres(
85
-		_T('forum_titre_erreur'),
86
-		$inc ?
87
-			_T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>'])
88
-			. '<br />'
89
-			. _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>'])
90
-			:
91
-			_T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']),
92
-		['all_inline' => true,'status' => 404]
93
-	);
94
-	exit;
30
+    static $echecs = [];
31
+
32
+    if (strlen($dossier) && !str_ends_with($dossier, '/')) {
33
+        $dossier .= '/';
34
+    }
35
+    $f = str_replace('/', '_', $dossier) . $nom;
36
+
37
+    if (function_exists($f)) {
38
+        return $f;
39
+    }
40
+    if (function_exists($g = $f . '_dist')) {
41
+        return $g;
42
+    }
43
+
44
+    if (isset($echecs[$f])) {
45
+        return $echecs[$f];
46
+    }
47
+    // Sinon charger le fichier de declaration si plausible
48
+
49
+    if (!preg_match(',^\w+$,', $f)) {
50
+        if ($continue) {
51
+            return false;
52
+        } //appel interne, on passe
53
+        include_spip('inc/minipres');
54
+        echo minipres();
55
+        exit;
56
+    }
57
+
58
+    // passer en minuscules (cf les balises de formulaires)
59
+    // et inclure le fichier
60
+    if (
61
+        !($inc = include_spip($dossier . ($d = strtolower($nom))))
62
+        && strlen(dirname($dossier))
63
+        && dirname($dossier) != '.'
64
+    ) {
65
+        include_spip(substr($dossier, 0, -1));
66
+    }
67
+    if (function_exists($f)) {
68
+        return $f;
69
+    }
70
+    if (function_exists($g)) {
71
+        return $g;
72
+    }
73
+
74
+    if ($continue) {
75
+        return $echecs[$f] = false;
76
+    }
77
+
78
+    // Echec : message d'erreur
79
+    spip_log("fonction $nom ($f ou $g) indisponible" .
80
+        ($inc ? '' : " (fichier $d absent de $dossier)"));
81
+
82
+    include_spip('inc/minipres');
83
+    include_spip('inc/filtres_mini');
84
+    echo minipres(
85
+        _T('forum_titre_erreur'),
86
+        $inc ?
87
+            _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>'])
88
+            . '<br />'
89
+            . _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>'])
90
+            :
91
+            _T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']),
92
+        ['all_inline' => true,'status' => 404]
93
+    );
94
+    exit;
95 95
 }
96 96
 
97 97
 /**
@@ -101,17 +101,17 @@  discard block
 block discarded – undo
101 101
  * @return bool
102 102
  */
103 103
 function include_once_check($file) {
104
-	if (file_exists($file)) {
105
-		include_once $file;
104
+    if (file_exists($file)) {
105
+        include_once $file;
106 106
 
107
-		return true;
108
-	}
109
-	$crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : '');
110
-	$crash = ($crash ?: []);
111
-	$crash[$file] = true;
112
-	ecrire_meta('message_crash_plugins', serialize($crash));
107
+        return true;
108
+    }
109
+    $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : '');
110
+    $crash = ($crash ?: []);
111
+    $crash[$file] = true;
112
+    ecrire_meta('message_crash_plugins', serialize($crash));
113 113
 
114
-	return false;
114
+    return false;
115 115
 }
116 116
 
117 117
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
  *     - string : chemin du fichier trouvé
136 136
  **/
137 137
 function include_spip($f, $include = true) {
138
-	return find_in_path($f . '.php', '', $include);
138
+    return find_in_path($f . '.php', '', $include);
139 139
 }
140 140
 
141 141
 /**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
  *     - string : chemin du fichier trouvé
156 156
  **/
157 157
 function require_spip($f) {
158
-	return find_in_path($f . '.php', '', 'required');
158
+    return find_in_path($f . '.php', '', 'required');
159 159
 }
160 160
 
161 161
 
@@ -165,27 +165,27 @@  discard block
 block discarded – undo
165 165
  * quand on a besoin dans le PHP de filtres/fonctions qui y sont definis
166 166
  */
167 167
 function include_fichiers_fonctions() {
168
-	static $done = false;
169
-	if (!$done) {
170
-		include_spip('inc/lang');
171
-
172
-		// NB: mes_fonctions peut initialiser $dossier_squelettes (old-style)
173
-		// donc il faut l'inclure "en globals"
174
-		if ($f = find_in_path('mes_fonctions.php')) {
175
-			global $dossier_squelettes;
176
-			include_once(_ROOT_CWD . $f);
177
-		}
178
-
179
-		if (@is_readable(_CACHE_PLUGINS_FCT)) {
180
-			// chargement optimise precompile
181
-			include_once(_CACHE_PLUGINS_FCT);
182
-		}
183
-		if (test_espace_prive()) {
184
-			include_spip('inc/filtres_ecrire');
185
-		}
186
-		include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises..
187
-		$done = true;
188
-	}
168
+    static $done = false;
169
+    if (!$done) {
170
+        include_spip('inc/lang');
171
+
172
+        // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style)
173
+        // donc il faut l'inclure "en globals"
174
+        if ($f = find_in_path('mes_fonctions.php')) {
175
+            global $dossier_squelettes;
176
+            include_once(_ROOT_CWD . $f);
177
+        }
178
+
179
+        if (@is_readable(_CACHE_PLUGINS_FCT)) {
180
+            // chargement optimise precompile
181
+            include_once(_CACHE_PLUGINS_FCT);
182
+        }
183
+        if (test_espace_prive()) {
184
+            include_spip('inc/filtres_ecrire');
185
+        }
186
+        include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises..
187
+        $done = true;
188
+    }
189 189
 }
190 190
 
191 191
 
@@ -198,59 +198,59 @@  discard block
 block discarded – undo
198 198
  * @return string
199 199
  */
200 200
 function charger_fonction_url(string $quoi, string $type = '') {
201
-	if ($type === 'defaut') {
202
-		$objet = objet_type($quoi);
203
-		if (
204
-			($f = charger_fonction('generer_' . $objet . '_url', 'urls', true))
205
-			|| ($f = charger_fonction('generer_url_' . $objet, 'urls', true)) // deprecated
206
-		) {
207
-			return $f;
208
-		}
209
-		return '';
210
-	}
211
-
212
-	$url_type = $type;
213
-	if (!$url_type) {
214
-		$url_type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut
215
-	}
216
-
217
-	// inclure le module d'url
218
-	include_spip('urls/' . $url_type);
219
-
220
-	switch ($quoi) {
221
-		case 'page':
222
-			if (
223
-				function_exists($f = "urls_{$url_type}_generer_url_page")
224
-				|| function_exists($f .= '_dist')
225
-				// ou une fonction custom utilisateur independante du type d'url
226
-				|| function_exists($f = 'generer_url_page')
227
-				|| function_exists($f .= '_dist')
228
-			) {
229
-				return $f;
230
-			}
231
-			// pas de compat ancienne version ici, c'est une nouvelle feature
232
-			return '';
233
-		case 'objet':
234
-		case 'decoder':
235
-		default:
236
-			$fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url');
237
-			if (
238
-				function_exists($f = "urls_{$url_type}_{$fquoi}")
239
-				|| function_exists($f .= '_dist')
240
-			) {
241
-				return $f;
242
-			}
243
-			// est-ce qu'on a une ancienne fonction urls_xxx_dist() ?
244
-			// c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout
245
-			if ($f = charger_fonction($url_type, 'urls', true)) {
246
-				return $f;
247
-			}
248
-			// sinon on se rabat sur les urls page si ce n'est pas un type demande explicitement
249
-			if (!$type && $url_type !== 'page') {
250
-				return charger_fonction_url($quoi, 'page');
251
-			}
252
-			return '';
253
-	}
201
+    if ($type === 'defaut') {
202
+        $objet = objet_type($quoi);
203
+        if (
204
+            ($f = charger_fonction('generer_' . $objet . '_url', 'urls', true))
205
+            || ($f = charger_fonction('generer_url_' . $objet, 'urls', true)) // deprecated
206
+        ) {
207
+            return $f;
208
+        }
209
+        return '';
210
+    }
211
+
212
+    $url_type = $type;
213
+    if (!$url_type) {
214
+        $url_type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut
215
+    }
216
+
217
+    // inclure le module d'url
218
+    include_spip('urls/' . $url_type);
219
+
220
+    switch ($quoi) {
221
+        case 'page':
222
+            if (
223
+                function_exists($f = "urls_{$url_type}_generer_url_page")
224
+                || function_exists($f .= '_dist')
225
+                // ou une fonction custom utilisateur independante du type d'url
226
+                || function_exists($f = 'generer_url_page')
227
+                || function_exists($f .= '_dist')
228
+            ) {
229
+                return $f;
230
+            }
231
+            // pas de compat ancienne version ici, c'est une nouvelle feature
232
+            return '';
233
+        case 'objet':
234
+        case 'decoder':
235
+        default:
236
+            $fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url');
237
+            if (
238
+                function_exists($f = "urls_{$url_type}_{$fquoi}")
239
+                || function_exists($f .= '_dist')
240
+            ) {
241
+                return $f;
242
+            }
243
+            // est-ce qu'on a une ancienne fonction urls_xxx_dist() ?
244
+            // c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout
245
+            if ($f = charger_fonction($url_type, 'urls', true)) {
246
+                return $f;
247
+            }
248
+            // sinon on se rabat sur les urls page si ce n'est pas un type demande explicitement
249
+            if (!$type && $url_type !== 'page') {
250
+                return charger_fonction_url($quoi, 'page');
251
+            }
252
+            return '';
253
+    }
254 254
 }
255 255
 
256 256
 
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
  * @return string
262 262
  */
263 263
 function trouve_modele($nom) {
264
-	return trouver_fond($nom, 'modeles/');
264
+    return trouver_fond($nom, 'modeles/');
265 265
 }
266 266
 
267 267
 /**
@@ -277,28 +277,28 @@  discard block
 block discarded – undo
277 277
  * @return array|string
278 278
  */
279 279
 function trouver_fond($nom, $dir = '', $pathinfo = false) {
280
-	$f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
281
-	if (!$pathinfo) {
282
-		return $f;
283
-	}
284
-	// renvoyer un tableau detaille si $pathinfo==true
285
-	if ($f === null) {
286
-		return [
287
-			'extension' => _EXTENSION_SQUELETTES,
288
-			'filename' => '',
289
-			'fond' => ''
290
-		];
291
-	}
292
-	$p = pathinfo($f);
293
-	if (!isset($p['extension']) || !$p['extension']) {
294
-		$p['extension'] = _EXTENSION_SQUELETTES;
295
-	}
296
-	if (!isset($p['extension']) || !$p['filename']) {
297
-		$p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
298
-	}
299
-	$p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');
300
-
301
-	return $p;
280
+    $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
281
+    if (!$pathinfo) {
282
+        return $f;
283
+    }
284
+    // renvoyer un tableau detaille si $pathinfo==true
285
+    if ($f === null) {
286
+        return [
287
+            'extension' => _EXTENSION_SQUELETTES,
288
+            'filename' => '',
289
+            'fond' => ''
290
+        ];
291
+    }
292
+    $p = pathinfo($f);
293
+    if (!isset($p['extension']) || !$p['extension']) {
294
+        $p['extension'] = _EXTENSION_SQUELETTES;
295
+    }
296
+    if (!isset($p['extension']) || !$p['filename']) {
297
+        $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
298
+    }
299
+    $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');
300
+
301
+    return $p;
302 302
 }
303 303
 
304 304
 /**
@@ -316,9 +316,9 @@  discard block
 block discarded – undo
316 316
  *    Lien sur une icone d'aide
317 317
  **/
318 318
 function aider($aide = '', $distante = false) {
319
-	$aider = charger_fonction('aide', 'inc', true);
319
+    $aider = charger_fonction('aide', 'inc', true);
320 320
 
321
-	return $aider ? $aider($aide, '', [], $distante) : '';
321
+    return $aider ? $aider($aide, '', [], $distante) : '';
322 322
 }
323 323
 
324 324
 
@@ -339,19 +339,19 @@  discard block
 block discarded – undo
339 339
  *     Nom de l'exec, sinon chaîne vide.
340 340
  **/
341 341
 function tester_url_ecrire($nom) {
342
-	static $exec = [];
343
-	if (isset($exec[$nom])) {
344
-		return $exec[$nom];
345
-	}
346
-	// tester si c'est une page en squelette
347
-	if (trouver_fond($nom, 'prive/squelettes/contenu/')) {
348
-		return $exec[$nom] = 'fond';
349
-	} // echafaudage d'un fond !
350
-	elseif (include_spip('public/styliser_par_z') && z_echafaudable($nom)) {
351
-		return $exec[$nom] = 'fond';
352
-	}
353
-	// attention, il ne faut pas inclure l'exec ici
354
-	// car sinon #URL_ECRIRE provoque des inclusions
355
-	// et des define intrusifs potentiels
356
-	return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') || charger_fonction($nom, 'exec', true)) ? $nom : '');
342
+    static $exec = [];
343
+    if (isset($exec[$nom])) {
344
+        return $exec[$nom];
345
+    }
346
+    // tester si c'est une page en squelette
347
+    if (trouver_fond($nom, 'prive/squelettes/contenu/')) {
348
+        return $exec[$nom] = 'fond';
349
+    } // echafaudage d'un fond !
350
+    elseif (include_spip('public/styliser_par_z') && z_echafaudable($nom)) {
351
+        return $exec[$nom] = 'fond';
352
+    }
353
+    // attention, il ne faut pas inclure l'exec ici
354
+    // car sinon #URL_ECRIRE provoque des inclusions
355
+    // et des define intrusifs potentiels
356
+    return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') || charger_fonction($nom, 'exec', true)) ? $nom : '');
357 357
 }
Please login to merge, or discard this patch.
ecrire/bootstrap/inc/form.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -22,19 +22,19 @@  discard block
 block discarded – undo
22 22
  **/
23 23
 function generer_form_ecrire($script, $corps, $atts = '', $submit = '') {
24 24
 
25
-	$script1 = explode('&', $script);
26
-	$script1 = reset($script1);
25
+    $script1 = explode('&', $script);
26
+    $script1 = reset($script1);
27 27
 
28
-	return "<form action='"
29
-	. ($script ? generer_url_ecrire($script) : '')
30
-	. "' "
31
-	. ($atts ?: " method='post'")
32
-	. "><div>\n"
33
-	. "<input type='hidden' name='exec' value='$script1' />"
34
-	. $corps
35
-	. (!$submit ? '' :
36
-		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
37
-	. "</div></form>\n";
28
+    return "<form action='"
29
+    . ($script ? generer_url_ecrire($script) : '')
30
+    . "' "
31
+    . ($atts ?: " method='post'")
32
+    . "><div>\n"
33
+    . "<input type='hidden' name='exec' value='$script1' />"
34
+    . $corps
35
+    . (!$submit ? '' :
36
+        ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
37
+    . "</div></form>\n";
38 38
 }
39 39
 
40 40
 /**
@@ -51,20 +51,20 @@  discard block
 block discarded – undo
51 51
  * @return string
52 52
  */
53 53
 function generer_form_action($script, $corps, $atts = '', $public = false) {
54
-	// si l'on est dans l'espace prive, on garde dans l'url
55
-	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
56
-	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
57
-	$h = (_DIR_RACINE && !$public)
58
-		? generer_url_ecrire(_request('exec'))
59
-		: generer_url_public();
54
+    // si l'on est dans l'espace prive, on garde dans l'url
55
+    // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
56
+    // ou non de proceder a l'authentification (cas typique de l'install par exemple)
57
+    $h = (_DIR_RACINE && !$public)
58
+        ? generer_url_ecrire(_request('exec'))
59
+        : generer_url_public();
60 60
 
61
-	return "\n<form action='" .
62
-	$h .
63
-	"'" .
64
-	$atts .
65
-	">\n" .
66
-	'<div>' .
67
-	"\n<input type='hidden' name='action' value='$script' />" .
68
-	$corps .
69
-	'</div></form>';
61
+    return "\n<form action='" .
62
+    $h .
63
+    "'" .
64
+    $atts .
65
+    ">\n" .
66
+    '<div>' .
67
+    "\n<input type='hidden' name='action' value='$script' />" .
68
+    $corps .
69
+    '</div></form>';
70 70
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,8 +32,7 @@  discard block
 block discarded – undo
32 32
 	. "><div>\n"
33 33
 	. "<input type='hidden' name='exec' value='$script1' />"
34 34
 	. $corps
35
-	. (!$submit ? '' :
36
-		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>'))
35
+	. (!$submit ? '' : ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo submit btn' type='submit' value=\"".entites_html($submit).'" /></div>'))
37 36
 	. "</div></form>\n";
38 37
 }
39 38
 
@@ -58,13 +57,13 @@  discard block
 block discarded – undo
58 57
 		? generer_url_ecrire(_request('exec'))
59 58
 		: generer_url_public();
60 59
 
61
-	return "\n<form action='" .
62
-	$h .
63
-	"'" .
64
-	$atts .
65
-	">\n" .
66
-	'<div>' .
67
-	"\n<input type='hidden' name='action' value='$script' />" .
68
-	$corps .
60
+	return "\n<form action='".
61
+	$h.
62
+	"'".
63
+	$atts.
64
+	">\n".
65
+	'<div>'.
66
+	"\n<input type='hidden' name='action' value='$script' />".
67
+	$corps.
69 68
 	'</div></form>';
70 69
 }
Please login to merge, or discard this patch.
ecrire/bootstrap/inc/pipeline.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -24,23 +24,23 @@  discard block
 block discarded – undo
24 24
  *     Les paramètres du pipeline modifiés
25 25
  **/
26 26
 function minipipe($fonc, &$val) {
27
-	// fonction
28
-	if (function_exists($fonc)) {
29
-		$val = $fonc($val);
30
-	} // Class::Methode
31
-	else {
32
-		if (
33
-			preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs)
34
-			&& ($methode = [$regs[1], $regs[2]])
35
-			&& is_callable($methode)
36
-		) {
37
-			$val = $methode($val);
38
-		} else {
39
-			spip_log("Erreur - '$fonc' non definie !");
40
-		}
41
-	}
27
+    // fonction
28
+    if (function_exists($fonc)) {
29
+        $val = $fonc($val);
30
+    } // Class::Methode
31
+    else {
32
+        if (
33
+            preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs)
34
+            && ($methode = [$regs[1], $regs[2]])
35
+            && is_callable($methode)
36
+        ) {
37
+            $val = $methode($val);
38
+        } else {
39
+            spip_log("Erreur - '$fonc' non definie !");
40
+        }
41
+    }
42 42
 
43
-	return $val;
43
+    return $val;
44 44
 }
45 45
 
46 46
 /**
@@ -71,44 +71,44 @@  discard block
 block discarded – undo
71 71
  *     Résultat
72 72
  */
73 73
 function pipeline($action, $val = null) {
74
-	static $charger;
74
+    static $charger;
75 75
 
76
-	// chargement initial des fonctions mises en cache, ou generation du cache
77
-	if (!$charger) {
78
-		if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) {
79
-			include_spip('inc/plugin');
80
-			// generer les fichiers php precompiles
81
-			// de chargement des plugins et des pipelines
82
-			actualise_plugins_actifs();
83
-			if (!($ok = @is_readable($charger))) {
84
-				spip_log("fichier $charger pas cree");
85
-			}
86
-		}
76
+    // chargement initial des fonctions mises en cache, ou generation du cache
77
+    if (!$charger) {
78
+        if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) {
79
+            include_spip('inc/plugin');
80
+            // generer les fichiers php precompiles
81
+            // de chargement des plugins et des pipelines
82
+            actualise_plugins_actifs();
83
+            if (!($ok = @is_readable($charger))) {
84
+                spip_log("fichier $charger pas cree");
85
+            }
86
+        }
87 87
 
88
-		if ($ok) {
89
-			include_once $charger;
90
-		}
91
-	}
88
+        if ($ok) {
89
+            include_once $charger;
90
+        }
91
+    }
92 92
 
93
-	// appliquer notre fonction si elle existe
94
-	$fonc = 'execute_pipeline_' . strtolower($action);
95
-	if (function_exists($fonc)) {
96
-		$val = $fonc($val);
97
-	} // plantage ?
98
-	else {
99
-		spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR);
100
-	}
93
+    // appliquer notre fonction si elle existe
94
+    $fonc = 'execute_pipeline_' . strtolower($action);
95
+    if (function_exists($fonc)) {
96
+        $val = $fonc($val);
97
+    } // plantage ?
98
+    else {
99
+        spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR);
100
+    }
101 101
 
102
-	// si le flux est une table avec 2 cle args&data
103
-	// on ne ressort du pipe que les donnees dans 'data'
104
-	// array_key_exists pour php 4.1.0
105
-	if (
106
-		is_array($val)
107
-		&& count($val) == 2
108
-		&& array_key_exists('data', $val)
109
-	) {
110
-		$val = $val['data'];
111
-	}
102
+    // si le flux est une table avec 2 cle args&data
103
+    // on ne ressort du pipe que les donnees dans 'data'
104
+    // array_key_exists pour php 4.1.0
105
+    if (
106
+        is_array($val)
107
+        && count($val) == 2
108
+        && array_key_exists('data', $val)
109
+    ) {
110
+        $val = $val['data'];
111
+    }
112 112
 
113
-	return $val;
113
+    return $val;
114 114
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@
 block discarded – undo
91 91
 	}
92 92
 
93 93
 	// appliquer notre fonction si elle existe
94
-	$fonc = 'execute_pipeline_' . strtolower($action);
94
+	$fonc = 'execute_pipeline_'.strtolower($action);
95 95
 	if (function_exists($fonc)) {
96 96
 		$val = $fonc($val);
97 97
 	} // plantage ?
Please login to merge, or discard this patch.
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.