Completed
Push — master ( f2008e...da65df )
by cam
02:08
created
ecrire/inc/auth.php 2 patches
Indentation   +448 added lines, -448 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 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_spip('base/abstract_sql');
@@ -34,33 +34,33 @@  discard block
 block discarded – undo
34 34
  *  - une chaîne vide si autorisation à pénétrer dans l'espace privé.
35 35
  */
36 36
 function inc_auth_dist() {
37
-	$row = auth_mode();
37
+    $row = auth_mode();
38 38
 
39
-	if ($row) {
40
-		return auth_init_droits($row);
41
-	}
39
+    if ($row) {
40
+        return auth_init_droits($row);
41
+    }
42 42
 
43
-	if (!$GLOBALS['connect_login']) {
44
-		return auth_a_loger();
45
-	}
43
+    if (!$GLOBALS['connect_login']) {
44
+        return auth_a_loger();
45
+    }
46 46
 
47
-	// Cas ou l'auteur a ete identifie mais on n'a pas d'info sur lui
48
-	// C'est soit parce que la base est inutilisable,
49
-	// soit parce que la table des auteurs a changee (restauration etc)
50
-	// Pas la peine d'insister.
51
-	// Renvoyer le nom fautif et une URL de remise a zero
47
+    // Cas ou l'auteur a ete identifie mais on n'a pas d'info sur lui
48
+    // C'est soit parce que la base est inutilisable,
49
+    // soit parce que la table des auteurs a changee (restauration etc)
50
+    // Pas la peine d'insister.
51
+    // Renvoyer le nom fautif et une URL de remise a zero
52 52
 
53
-	if (spip_connect()) {
54
-		return [
55
-			'login' => $GLOBALS['connect_login'],
56
-			'site' => generer_url_public('', 'action=logout&logout=prive')
57
-		];
58
-	}
53
+    if (spip_connect()) {
54
+        return [
55
+            'login' => $GLOBALS['connect_login'],
56
+            'site' => generer_url_public('', 'action=logout&logout=prive')
57
+        ];
58
+    }
59 59
 
60
-	$n = (int) sql_errno();
61
-	spip_log("Erreur base de donnees $n " . sql_error());
60
+    $n = (int) sql_errno();
61
+    spip_log("Erreur base de donnees $n " . sql_error());
62 62
 
63
-	return $n ?: 1;
63
+    return $n ?: 1;
64 64
 }
65 65
 
66 66
 /**
@@ -69,15 +69,15 @@  discard block
 block discarded – undo
69 69
  */
70 70
 function auth_controler_password_auteur_connecte(#[\SensitiveParameter] string $password): bool {
71 71
 
72
-	if (
73
-		empty($GLOBALS['visiteur_session']['id_auteur'])
74
-		|| empty($GLOBALS['visiteur_session']['login'])
75
-	) {
76
-		return false;
77
-	}
72
+    if (
73
+        empty($GLOBALS['visiteur_session']['id_auteur'])
74
+        || empty($GLOBALS['visiteur_session']['login'])
75
+    ) {
76
+        return false;
77
+    }
78 78
 
79
-	$auth = auth_identifier_login($GLOBALS['visiteur_session']['login'], $password, '', true);
80
-	return is_array($auth) && $auth['id_auteur'] == $GLOBALS['visiteur_session']['id_auteur'];
79
+    $auth = auth_identifier_login($GLOBALS['visiteur_session']['login'], $password, '', true);
80
+    return is_array($auth) && $auth['id_auteur'] == $GLOBALS['visiteur_session']['id_auteur'];
81 81
 }
82 82
 
83 83
 /**
@@ -89,47 +89,47 @@  discard block
 block discarded – undo
89 89
  * @return array|string
90 90
  */
91 91
 function auth_echec($raison) {
92
-	include_spip('inc/minipres');
93
-	include_spip('inc/headers');
94
-	// pas authentifie. Pourquoi ?
95
-	if (is_string($raison)) {
96
-		// redirection vers une page d'authentification
97
-		// on ne revient pas de cette fonction
98
-		// sauf si pb de header
99
-		$raison = redirige_formulaire($raison);
100
-	} elseif (is_int($raison)) {
101
-		// erreur SQL a afficher
102
-		$raison = minipres(
103
-			_T('info_travaux_titre'),
104
-			_T('titre_probleme_technique') . '<p><tt>' . sql_errno() . ' ' . sql_error() . '</tt></p>'
105
-		);
106
-	} elseif (@$raison['statut']) {
107
-		// un simple visiteur n'a pas acces a l'espace prive
108
-		spip_log('connexion refusee a ' . @$raison['id_auteur']);
109
-		$est_connecte = (!empty($GLOBALS['visiteur_session']['login']) && !empty($GLOBALS['visiteur_session']['statut'])); // idem test balise #URL_LOGOUT
110
-		$raison = minipres(
111
-			_T('avis_erreur_connexion'),
112
-			_T('avis_erreur_visiteur')
113
-				// Lien vers le site public
114
-				. '<br /><a href="' . url_de_base() . '">' . _T('login_retour_public') . '</a>'
115
-				// Si la personne est connectée, lien de déconnexion ramenant vers la page de login
116
-				. ($est_connecte ? ' | <a href="' . generer_url_public('', 'action=logout&amp;logout=prive') . '">' . _T('icone_deconnecter') . '</a>' : '')
117
-		);
118
-	} else {
119
-		// auteur en fin de droits ...
120
-		$h = $raison['site'];
121
-		$raison = minipres(
122
-			_T('avis_erreur_connexion'),
123
-			'<br /><br /><p>'
124
-			. _T('texte_inc_auth_1', ['auth_login' => $raison['login']])
125
-			. " <a href='$h'>"
126
-			. _T('texte_inc_auth_2')
127
-			. '</a>'
128
-			. _T('texte_inc_auth_3')
129
-		);
130
-	}
131
-
132
-	return $raison;
92
+    include_spip('inc/minipres');
93
+    include_spip('inc/headers');
94
+    // pas authentifie. Pourquoi ?
95
+    if (is_string($raison)) {
96
+        // redirection vers une page d'authentification
97
+        // on ne revient pas de cette fonction
98
+        // sauf si pb de header
99
+        $raison = redirige_formulaire($raison);
100
+    } elseif (is_int($raison)) {
101
+        // erreur SQL a afficher
102
+        $raison = minipres(
103
+            _T('info_travaux_titre'),
104
+            _T('titre_probleme_technique') . '<p><tt>' . sql_errno() . ' ' . sql_error() . '</tt></p>'
105
+        );
106
+    } elseif (@$raison['statut']) {
107
+        // un simple visiteur n'a pas acces a l'espace prive
108
+        spip_log('connexion refusee a ' . @$raison['id_auteur']);
109
+        $est_connecte = (!empty($GLOBALS['visiteur_session']['login']) && !empty($GLOBALS['visiteur_session']['statut'])); // idem test balise #URL_LOGOUT
110
+        $raison = minipres(
111
+            _T('avis_erreur_connexion'),
112
+            _T('avis_erreur_visiteur')
113
+                // Lien vers le site public
114
+                . '<br /><a href="' . url_de_base() . '">' . _T('login_retour_public') . '</a>'
115
+                // Si la personne est connectée, lien de déconnexion ramenant vers la page de login
116
+                . ($est_connecte ? ' | <a href="' . generer_url_public('', 'action=logout&amp;logout=prive') . '">' . _T('icone_deconnecter') . '</a>' : '')
117
+        );
118
+    } else {
119
+        // auteur en fin de droits ...
120
+        $h = $raison['site'];
121
+        $raison = minipres(
122
+            _T('avis_erreur_connexion'),
123
+            '<br /><br /><p>'
124
+            . _T('texte_inc_auth_1', ['auth_login' => $raison['login']])
125
+            . " <a href='$h'>"
126
+            . _T('texte_inc_auth_2')
127
+            . '</a>'
128
+            . _T('texte_inc_auth_3')
129
+        );
130
+    }
131
+
132
+    return $raison;
133 133
 }
134 134
 
135 135
 /**
@@ -139,79 +139,79 @@  discard block
 block discarded – undo
139 139
  * @return array|bool|string
140 140
  */
141 141
 function auth_mode() {
142
-	//
143
-	// Initialiser variables (eviter hacks par URL)
144
-	//
145
-	$GLOBALS['connect_login'] = '';
146
-	$id_auteur = null;
147
-	$GLOBALS['auth_can_disconnect'] = false;
148
-
149
-	//
150
-	// Recuperer les donnees d'identification
151
-	//
152
-	include_spip('inc/session');
153
-	// Session valide en cours ?
154
-	if ($cookie = lire_cookie_session()) {
155
-		$session = charger_fonction('session', 'inc');
156
-		if (
157
-			($id_auteur = $session()) || $id_auteur === 0 // reprise sur restauration
158
-		) {
159
-			$GLOBALS['auth_can_disconnect'] = true;
160
-			$GLOBALS['connect_login'] = session_get('login');
161
-		} else {
162
-			unset($_COOKIE['spip_session']);
163
-		}
164
-	}
165
-
166
-	// Essayer auth http si significatif
167
-	// (ignorer les login d'intranet independants de spip)
168
-	if (!$GLOBALS['ignore_auth_http']) {
169
-		if (
170
-			isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])
171
-				&& ($r = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']))
172
-			// Si auth http differtente de basic, PHP_AUTH_PW
173
-			// est indisponible mais tentons quand meme pour
174
-			// autocreation via LDAP
175
-			|| isset($_SERVER['REMOTE_USER'])
176
-				&& ($r = lire_php_auth($_SERVER['PHP_AUTH_USER'] = $_SERVER['REMOTE_USER'], ''))
177
-		) {
178
-			if (!$id_auteur) {
179
-				$_SERVER['PHP_AUTH_PW'] = '';
180
-				$GLOBALS['auth_can_disconnect'] = true;
181
-				$GLOBALS['visiteur_session'] = $r;
182
-				$GLOBALS['connect_login'] = session_get('login');
183
-				$id_auteur = $r['id_auteur'];
184
-			} else {
185
-				// cas de la session en plus de PHP_AUTH
186
-				/*				  if ($id_auteur != $r['id_auteur']){
142
+    //
143
+    // Initialiser variables (eviter hacks par URL)
144
+    //
145
+    $GLOBALS['connect_login'] = '';
146
+    $id_auteur = null;
147
+    $GLOBALS['auth_can_disconnect'] = false;
148
+
149
+    //
150
+    // Recuperer les donnees d'identification
151
+    //
152
+    include_spip('inc/session');
153
+    // Session valide en cours ?
154
+    if ($cookie = lire_cookie_session()) {
155
+        $session = charger_fonction('session', 'inc');
156
+        if (
157
+            ($id_auteur = $session()) || $id_auteur === 0 // reprise sur restauration
158
+        ) {
159
+            $GLOBALS['auth_can_disconnect'] = true;
160
+            $GLOBALS['connect_login'] = session_get('login');
161
+        } else {
162
+            unset($_COOKIE['spip_session']);
163
+        }
164
+    }
165
+
166
+    // Essayer auth http si significatif
167
+    // (ignorer les login d'intranet independants de spip)
168
+    if (!$GLOBALS['ignore_auth_http']) {
169
+        if (
170
+            isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])
171
+                && ($r = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']))
172
+            // Si auth http differtente de basic, PHP_AUTH_PW
173
+            // est indisponible mais tentons quand meme pour
174
+            // autocreation via LDAP
175
+            || isset($_SERVER['REMOTE_USER'])
176
+                && ($r = lire_php_auth($_SERVER['PHP_AUTH_USER'] = $_SERVER['REMOTE_USER'], ''))
177
+        ) {
178
+            if (!$id_auteur) {
179
+                $_SERVER['PHP_AUTH_PW'] = '';
180
+                $GLOBALS['auth_can_disconnect'] = true;
181
+                $GLOBALS['visiteur_session'] = $r;
182
+                $GLOBALS['connect_login'] = session_get('login');
183
+                $id_auteur = $r['id_auteur'];
184
+            } else {
185
+                // cas de la session en plus de PHP_AUTH
186
+                /*				  if ($id_auteur != $r['id_auteur']){
187 187
 					spip_log("vol de session $id_auteur" . join(', ', $r));
188 188
 				unset($_COOKIE['spip_session']);
189 189
 				$id_auteur = '';
190 190
 				} */
191
-			}
192
-		} else {
193
-			// Authentification .htaccess old style, car .htaccess semble
194
-			// souvent definir *aussi* PHP_AUTH_USER et PHP_AUTH_PW
195
-			if (isset($_SERVER['REMOTE_USER'])) {
196
-				$GLOBALS['connect_login'] = $_SERVER['REMOTE_USER'];
197
-			}
198
-		}
199
-	}
200
-
201
-	$where = (is_numeric($id_auteur)
202
-		/*AND $id_auteur>0*/ // reprise lors des restaurations
203
-	) ?
204
-		"id_auteur=$id_auteur" :
205
-		(strlen((string) $GLOBALS['connect_login']) ? 'login=' . sql_quote($GLOBALS['connect_login'], '', 'text') : '');
206
-
207
-	if (!$where) {
208
-		return '';
209
-	}
210
-
211
-	// Trouver les autres infos dans la table auteurs.
212
-	// le champ 'quand' est utilise par l'agenda
213
-
214
-	return sql_fetsel('*, en_ligne AS quand', 'spip_auteurs', "$where AND statut!='5poubelle'");
191
+            }
192
+        } else {
193
+            // Authentification .htaccess old style, car .htaccess semble
194
+            // souvent definir *aussi* PHP_AUTH_USER et PHP_AUTH_PW
195
+            if (isset($_SERVER['REMOTE_USER'])) {
196
+                $GLOBALS['connect_login'] = $_SERVER['REMOTE_USER'];
197
+            }
198
+        }
199
+    }
200
+
201
+    $where = (is_numeric($id_auteur)
202
+        /*AND $id_auteur>0*/ // reprise lors des restaurations
203
+    ) ?
204
+        "id_auteur=$id_auteur" :
205
+        (strlen((string) $GLOBALS['connect_login']) ? 'login=' . sql_quote($GLOBALS['connect_login'], '', 'text') : '');
206
+
207
+    if (!$where) {
208
+        return '';
209
+    }
210
+
211
+    // Trouver les autres infos dans la table auteurs.
212
+    // le champ 'quand' est utilise par l'agenda
213
+
214
+    return sql_fetsel('*, en_ligne AS quand', 'spip_auteurs', "$where AND statut!='5poubelle'");
215 215
 }
216 216
 
217 217
 /**
@@ -229,96 +229,96 @@  discard block
 block discarded – undo
229 229
  */
230 230
 function auth_init_droits($row) {
231 231
 
232
-	include_spip('inc/autoriser');
233
-	if (!autoriser('loger', '', 0, $row)) {
234
-		return false;
235
-	}
236
-
237
-
238
-	if ($row['statut'] == 'nouveau') {
239
-		include_spip('action/inscrire_auteur');
240
-		$row = confirmer_statut_inscription($row);
241
-	}
242
-
243
-	$GLOBALS['connect_id_auteur'] = $row['id_auteur'];
244
-	$GLOBALS['connect_login'] = $row['login'];
245
-	$GLOBALS['connect_statut'] = $row['statut'];
246
-
247
-	$GLOBALS['visiteur_session'] = array_merge((array) $GLOBALS['visiteur_session'], $row);
248
-
249
-	// au cas ou : ne pas memoriser les champs sensibles
250
-	$GLOBALS['visiteur_session'] = auth_desensibiliser_session($GLOBALS['visiteur_session']);
251
-
252
-	// creer la session au besoin
253
-	include_spip('inc/session');
254
-	if (!lire_cookie_session()) {
255
-		$session = charger_fonction('session', 'inc');
256
-		$spip_session = $session($row);
257
-	}
258
-
259
-	// reinjecter les preferences_auteur apres le reset de spip_session
260
-	// car utilisees au retour par auth_loger()
261
-	$r = @unserialize($row['prefs']);
262
-	$GLOBALS['visiteur_session']['prefs'] = ($r ?: []);
263
-	// si prefs pas definies, les definir par defaut
264
-	if (!isset($GLOBALS['visiteur_session']['prefs']['couleur'])) {
265
-		$GLOBALS['visiteur_session']['prefs']['couleur'] = 2;
266
-		$GLOBALS['visiteur_session']['prefs']['display'] = 2;
267
-		$GLOBALS['visiteur_session']['prefs']['display_navigation'] = 'navigation_avec_icones';
268
-	}
269
-
270
-	$GLOBALS['visiteur_session'] = pipeline(
271
-		'preparer_visiteur_session',
272
-		['args' => ['row' => $row],
273
-		'data' => $GLOBALS['visiteur_session']]
274
-	);
275
-
276
-	// Etablir les droits selon le codage attendu
277
-	// dans ecrire/index.php ecrire/prive.php
278
-
279
-	// Pas autorise a acceder a ecrire ? renvoyer le tableau
280
-	// A noter : le premier appel a autoriser() a le bon gout
281
-	// d'initialiser $GLOBALS['visiteur_session']['restreint'],
282
-	// qui ne figure pas dans le fichier de session
283
-
284
-	if (!autoriser('ecrire')) {
285
-		return $row;
286
-	}
287
-
288
-	// autoriser('ecrire') ne laisse passer que les Admin et les Redac
289
-
290
-	auth_trace($row);
291
-
292
-	// Administrateurs
293
-	if (in_array($GLOBALS['connect_statut'], explode(',', _STATUT_AUTEUR_RUBRIQUE))) {
294
-		if (
295
-			isset($GLOBALS['visiteur_session']['restreint'])
296
-			&& is_array($GLOBALS['visiteur_session']['restreint'])
297
-		) {
298
-			$GLOBALS['connect_id_rubrique'] = $GLOBALS['visiteur_session']['restreint'];
299
-		}
300
-		if ($GLOBALS['connect_statut'] == '0minirezo') {
301
-			$GLOBALS['connect_toutes_rubriques'] = !$GLOBALS['connect_id_rubrique'];
302
-		}
303
-	}
304
-
305
-	// Pour les redacteurs, inc_version a fait l'initialisation minimale
306
-
307
-	return ''; // i.e. pas de pb.
232
+    include_spip('inc/autoriser');
233
+    if (!autoriser('loger', '', 0, $row)) {
234
+        return false;
235
+    }
236
+
237
+
238
+    if ($row['statut'] == 'nouveau') {
239
+        include_spip('action/inscrire_auteur');
240
+        $row = confirmer_statut_inscription($row);
241
+    }
242
+
243
+    $GLOBALS['connect_id_auteur'] = $row['id_auteur'];
244
+    $GLOBALS['connect_login'] = $row['login'];
245
+    $GLOBALS['connect_statut'] = $row['statut'];
246
+
247
+    $GLOBALS['visiteur_session'] = array_merge((array) $GLOBALS['visiteur_session'], $row);
248
+
249
+    // au cas ou : ne pas memoriser les champs sensibles
250
+    $GLOBALS['visiteur_session'] = auth_desensibiliser_session($GLOBALS['visiteur_session']);
251
+
252
+    // creer la session au besoin
253
+    include_spip('inc/session');
254
+    if (!lire_cookie_session()) {
255
+        $session = charger_fonction('session', 'inc');
256
+        $spip_session = $session($row);
257
+    }
258
+
259
+    // reinjecter les preferences_auteur apres le reset de spip_session
260
+    // car utilisees au retour par auth_loger()
261
+    $r = @unserialize($row['prefs']);
262
+    $GLOBALS['visiteur_session']['prefs'] = ($r ?: []);
263
+    // si prefs pas definies, les definir par defaut
264
+    if (!isset($GLOBALS['visiteur_session']['prefs']['couleur'])) {
265
+        $GLOBALS['visiteur_session']['prefs']['couleur'] = 2;
266
+        $GLOBALS['visiteur_session']['prefs']['display'] = 2;
267
+        $GLOBALS['visiteur_session']['prefs']['display_navigation'] = 'navigation_avec_icones';
268
+    }
269
+
270
+    $GLOBALS['visiteur_session'] = pipeline(
271
+        'preparer_visiteur_session',
272
+        ['args' => ['row' => $row],
273
+        'data' => $GLOBALS['visiteur_session']]
274
+    );
275
+
276
+    // Etablir les droits selon le codage attendu
277
+    // dans ecrire/index.php ecrire/prive.php
278
+
279
+    // Pas autorise a acceder a ecrire ? renvoyer le tableau
280
+    // A noter : le premier appel a autoriser() a le bon gout
281
+    // d'initialiser $GLOBALS['visiteur_session']['restreint'],
282
+    // qui ne figure pas dans le fichier de session
283
+
284
+    if (!autoriser('ecrire')) {
285
+        return $row;
286
+    }
287
+
288
+    // autoriser('ecrire') ne laisse passer que les Admin et les Redac
289
+
290
+    auth_trace($row);
291
+
292
+    // Administrateurs
293
+    if (in_array($GLOBALS['connect_statut'], explode(',', _STATUT_AUTEUR_RUBRIQUE))) {
294
+        if (
295
+            isset($GLOBALS['visiteur_session']['restreint'])
296
+            && is_array($GLOBALS['visiteur_session']['restreint'])
297
+        ) {
298
+            $GLOBALS['connect_id_rubrique'] = $GLOBALS['visiteur_session']['restreint'];
299
+        }
300
+        if ($GLOBALS['connect_statut'] == '0minirezo') {
301
+            $GLOBALS['connect_toutes_rubriques'] = !$GLOBALS['connect_id_rubrique'];
302
+        }
303
+    }
304
+
305
+    // Pour les redacteurs, inc_version a fait l'initialisation minimale
306
+
307
+    return ''; // i.e. pas de pb.
308 308
 }
309 309
 
310 310
 /**
311 311
  * Enlever les clés sensibles d'une ligne auteur
312 312
  */
313 313
 function auth_desensibiliser_session(array $auteur): array {
314
-	$cles_sensibles = ['pass', 'htpass', 'low_sec', 'alea_actuel', 'alea_futur', 'ldap_password', 'backup_cles'];
315
-	foreach ($cles_sensibles as $cle) {
316
-		if (array_key_exists($cle, $auteur)) {
317
-			unset($auteur[$cle]);
318
-		}
319
-	}
320
-
321
-	return $auteur;
314
+    $cles_sensibles = ['pass', 'htpass', 'low_sec', 'alea_actuel', 'alea_futur', 'ldap_password', 'backup_cles'];
315
+    foreach ($cles_sensibles as $cle) {
316
+        if (array_key_exists($cle, $auteur)) {
317
+            unset($auteur[$cle]);
318
+        }
319
+    }
320
+
321
+    return $auteur;
322 322
 }
323 323
 
324 324
 /**
@@ -327,23 +327,23 @@  discard block
 block discarded – undo
327 327
  * @return string
328 328
  */
329 329
 function auth_a_loger() {
330
-	$redirect = generer_url_public('login', 'url=' . rawurlencode((string) self('&', true)), true);
331
-
332
-	// un echec au "bonjour" (login initial) quand le statut est
333
-	// inconnu signale sans doute un probleme de cookies
334
-	if (isset($_GET['bonjour'])) {
335
-		$redirect = parametre_url(
336
-			$redirect,
337
-			'var_erreur',
338
-			(isset($GLOBALS['visiteur_session']['statut'])
339
-				? 'statut'
340
-				: 'cookie'
341
-			),
342
-			'&'
343
-		);
344
-	}
345
-
346
-	return $redirect;
330
+    $redirect = generer_url_public('login', 'url=' . rawurlencode((string) self('&', true)), true);
331
+
332
+    // un echec au "bonjour" (login initial) quand le statut est
333
+    // inconnu signale sans doute un probleme de cookies
334
+    if (isset($_GET['bonjour'])) {
335
+        $redirect = parametre_url(
336
+            $redirect,
337
+            'var_erreur',
338
+            (isset($GLOBALS['visiteur_session']['statut'])
339
+                ? 'statut'
340
+                : 'cookie'
341
+            ),
342
+            '&'
343
+        );
344
+    }
345
+
346
+    return $redirect;
347 347
 }
348 348
 
349 349
 /**
@@ -355,19 +355,19 @@  discard block
 block discarded – undo
355 355
  * @param null|string $date
356 356
  */
357 357
 function auth_trace($row, $date = null) {
358
-	// Indiquer la connexion. A la minute pres ca suffit.
359
-	if (!is_numeric($connect_quand = $row['quand'] ?? '')) {
360
-		$connect_quand = strtotime((string) $connect_quand);
361
-	}
358
+    // Indiquer la connexion. A la minute pres ca suffit.
359
+    if (!is_numeric($connect_quand = $row['quand'] ?? '')) {
360
+        $connect_quand = strtotime((string) $connect_quand);
361
+    }
362 362
 
363
-	$date ??= date('Y-m-d H:i:s');
363
+    $date ??= date('Y-m-d H:i:s');
364 364
 
365
-	if (abs(strtotime($date) - $connect_quand) >= 60) {
366
-		sql_updateq('spip_auteurs', ['en_ligne' => $date], 'id_auteur=' . (int) $row['id_auteur']);
367
-		$row['en_ligne'] = $date;
368
-	}
365
+    if (abs(strtotime($date) - $connect_quand) >= 60) {
366
+        sql_updateq('spip_auteurs', ['en_ligne' => $date], 'id_auteur=' . (int) $row['id_auteur']);
367
+        $row['en_ligne'] = $date;
368
+    }
369 369
 
370
-	pipeline('trig_auth_trace', ['args' => ['row' => $row, 'date' => $date]]);
370
+    pipeline('trig_auth_trace', ['args' => ['row' => $row, 'date' => $date]]);
371 371
 }
372 372
 
373 373
 
@@ -393,27 +393,27 @@  discard block
 block discarded – undo
393 393
  * @return mixed
394 394
  */
395 395
 function auth_administrer($fonction, $args, mixed $defaut = false) {
396
-	$auth_methode = array_shift($args);
397
-	$auth_methode = $auth_methode ?: 'spip'; // valeur par defaut au cas ou
398
-	if (
399
-		($auth = charger_fonction($auth_methode, 'auth', true))
400
-		&& function_exists($f = "auth_{$auth_methode}_$fonction")
401
-	) {
402
-		$res = $f(...$args);
403
-	} else {
404
-		$res = $defaut;
405
-	}
406
-	return pipeline(
407
-		'auth_administrer',
408
-		[
409
-			'args' => [
410
-				'fonction' => $fonction,
411
-				'methode' => $auth_methode,
412
-				'args' => $args
413
-			],
414
-			'data' => $res
415
-		]
416
-	);
396
+    $auth_methode = array_shift($args);
397
+    $auth_methode = $auth_methode ?: 'spip'; // valeur par defaut au cas ou
398
+    if (
399
+        ($auth = charger_fonction($auth_methode, 'auth', true))
400
+        && function_exists($f = "auth_{$auth_methode}_$fonction")
401
+    ) {
402
+        $res = $f(...$args);
403
+    } else {
404
+        $res = $defaut;
405
+    }
406
+    return pipeline(
407
+        'auth_administrer',
408
+        [
409
+            'args' => [
410
+                'fonction' => $fonction,
411
+                'methode' => $auth_methode,
412
+                'args' => $args
413
+            ],
414
+            'data' => $res
415
+        ]
416
+    );
417 417
 }
418 418
 
419 419
 /**
@@ -423,11 +423,11 @@  discard block
 block discarded – undo
423 423
  * @return array
424 424
  */
425 425
 function auth_formulaire_login($flux) {
426
-	foreach ($GLOBALS['liste_des_authentifications'] as $methode) {
427
-		$flux = auth_administrer('formulaire_login', [$methode, $flux], $flux);
428
-	}
426
+    foreach ($GLOBALS['liste_des_authentifications'] as $methode) {
427
+        $flux = auth_administrer('formulaire_login', [$methode, $flux], $flux);
428
+    }
429 429
 
430
-	return $flux;
430
+    return $flux;
431 431
 }
432 432
 
433 433
 
@@ -441,19 +441,19 @@  discard block
 block discarded – undo
441 441
  * @return string/bool
442 442
  */
443 443
 function auth_retrouver_login($login, $serveur = '') {
444
-	if (!spip_connect($serveur)) {
445
-		include_spip('inc/minipres');
446
-		echo minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'));
447
-		exit;
448
-	}
449
-
450
-	foreach ($GLOBALS['liste_des_authentifications'] as $methode) {
451
-		if ($auteur = auth_administrer('retrouver_login', [$methode, $login, $serveur])) {
452
-			return $auteur;
453
-		}
454
-	}
455
-
456
-	return false;
444
+    if (!spip_connect($serveur)) {
445
+        include_spip('inc/minipres');
446
+        echo minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'));
447
+        exit;
448
+    }
449
+
450
+    foreach ($GLOBALS['liste_des_authentifications'] as $methode) {
451
+        if ($auteur = auth_administrer('retrouver_login', [$methode, $login, $serveur])) {
452
+            return $auteur;
453
+        }
454
+    }
455
+
456
+    return false;
457 457
 }
458 458
 
459 459
 /**
@@ -468,35 +468,35 @@  discard block
 block discarded – undo
468 468
  * @return array
469 469
  */
470 470
 function auth_informer_login($login, $serveur = '') {
471
-	if (
472
-		!$login
473
-		|| !($login_base = auth_retrouver_login($login, $serveur))
474
-		|| !($row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login_base, $serveur, 'text'), '', '', '', '', $serveur))
475
-	) {
476
-		// generer de fausses infos, mais credibles, pour eviter une attaque
477
-		// https://core.spip.net/issues/1758 + https://core.spip.net/issues/3691
478
-
479
-		$row = [
480
-			'login' => $login,
481
-			'cnx' => '0',
482
-			'logo' => '',
483
-		];
484
-
485
-		return $row;
486
-	}
487
-
488
-	$prefs = @unserialize($row['prefs']);
489
-	$row = auth_desensibiliser_session($row);
490
-	$infos = [
491
-		'id_auteur' => $row['id_auteur'],
492
-		'login' => $row['login'],
493
-		'cnx' => (isset($prefs['cnx']) && $prefs['cnx'] === 'perma') ? '1' : '0',
494
-		'logo' => recuperer_fond('formulaires/inc-logo_auteur', $row),
495
-	];
496
-
497
-	verifier_visiteur();
498
-
499
-	return auth_administrer('informer_login', [$row['source'], $infos, $row, $serveur], $infos);
471
+    if (
472
+        !$login
473
+        || !($login_base = auth_retrouver_login($login, $serveur))
474
+        || !($row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login_base, $serveur, 'text'), '', '', '', '', $serveur))
475
+    ) {
476
+        // generer de fausses infos, mais credibles, pour eviter une attaque
477
+        // https://core.spip.net/issues/1758 + https://core.spip.net/issues/3691
478
+
479
+        $row = [
480
+            'login' => $login,
481
+            'cnx' => '0',
482
+            'logo' => '',
483
+        ];
484
+
485
+        return $row;
486
+    }
487
+
488
+    $prefs = @unserialize($row['prefs']);
489
+    $row = auth_desensibiliser_session($row);
490
+    $infos = [
491
+        'id_auteur' => $row['id_auteur'],
492
+        'login' => $row['login'],
493
+        'cnx' => (isset($prefs['cnx']) && $prefs['cnx'] === 'perma') ? '1' : '0',
494
+        'logo' => recuperer_fond('formulaires/inc-logo_auteur', $row),
495
+    ];
496
+
497
+    verifier_visiteur();
498
+
499
+    return auth_administrer('informer_login', [$row['source'], $infos, $row, $serveur], $infos);
500 500
 }
501 501
 
502 502
 
@@ -510,21 +510,21 @@  discard block
 block discarded – undo
510 510
  * @return mixed
511 511
  */
512 512
 function auth_identifier_login($login, #[\SensitiveParameter] $password, $serveur = '', bool $phpauth = false) {
513
-	$erreur = '';
514
-	foreach ($GLOBALS['liste_des_authentifications'] as $methode) {
515
-		if ($auth = charger_fonction($methode, 'auth', true)) {
516
-			$auteur = $auth($login, $password, $serveur, $phpauth);
517
-			if (is_array($auteur) && count($auteur)) {
518
-				spip_log("connexion de $login par methode $methode");
519
-				$auteur['auth'] = $methode;
520
-				return $auteur;
521
-			} elseif (is_string($auteur)) {
522
-				$erreur .= "$auteur ";
523
-			}
524
-		}
525
-	}
526
-
527
-	return $erreur;
513
+    $erreur = '';
514
+    foreach ($GLOBALS['liste_des_authentifications'] as $methode) {
515
+        if ($auth = charger_fonction($methode, 'auth', true)) {
516
+            $auteur = $auth($login, $password, $serveur, $phpauth);
517
+            if (is_array($auteur) && count($auteur)) {
518
+                spip_log("connexion de $login par methode $methode");
519
+                $auteur['auth'] = $methode;
520
+                return $auteur;
521
+            } elseif (is_string($auteur)) {
522
+                $erreur .= "$auteur ";
523
+            }
524
+        }
525
+    }
526
+
527
+    return $erreur;
528 528
 }
529 529
 
530 530
 /**
@@ -538,8 +538,8 @@  discard block
 block discarded – undo
538 538
  * @return string
539 539
  */
540 540
 function auth_url_retour_login($auth_methode, $login, $redirect = '', $serveur = '') {
541
-	$securiser_action = charger_fonction('securiser_action', 'inc');
542
-	return $securiser_action('auth', "$auth_methode/$login", $redirect, true);
541
+    $securiser_action = charger_fonction('securiser_action', 'inc');
542
+    return $securiser_action('auth', "$auth_methode/$login", $redirect, true);
543 543
 }
544 544
 
545 545
 /**
@@ -553,8 +553,8 @@  discard block
 block discarded – undo
553 553
  * @return mixed
554 554
  */
555 555
 function auth_terminer_identifier_login($auth_methode, $login, $serveur = '') {
556
-	$args = func_get_args();
557
-	return auth_administrer('terminer_identifier_login', $args);
556
+    $args = func_get_args();
557
+    return auth_administrer('terminer_identifier_login', $args);
558 558
 }
559 559
 
560 560
 /**
@@ -564,29 +564,29 @@  discard block
 block discarded – undo
564 564
  * @return bool
565 565
  */
566 566
 function auth_loger($auteur) {
567
-	if (!is_array($auteur) || $auteur === []) {
568
-		return false;
569
-	}
570
-
571
-	// initialiser et poser le cookie de session
572
-	unset($_COOKIE['spip_session']);
573
-	if (auth_init_droits($auteur) === false) {
574
-		return false;
575
-	}
576
-
577
-	// initialiser les prefs
578
-	$p = $GLOBALS['visiteur_session']['prefs'];
579
-	$p['cnx'] = (isset($auteur['cookie']) && $auteur['cookie'] == 'oui') ? 'perma' : '';
580
-
581
-	sql_updateq(
582
-		'spip_auteurs',
583
-		['prefs' => serialize($p)],
584
-		'id_auteur=' . (int) $auteur['id_auteur']
585
-	);
586
-
587
-	//  bloquer ici le visiteur qui tente d'abuser de ses droits
588
-	verifier_visiteur();
589
-	return true;
567
+    if (!is_array($auteur) || $auteur === []) {
568
+        return false;
569
+    }
570
+
571
+    // initialiser et poser le cookie de session
572
+    unset($_COOKIE['spip_session']);
573
+    if (auth_init_droits($auteur) === false) {
574
+        return false;
575
+    }
576
+
577
+    // initialiser les prefs
578
+    $p = $GLOBALS['visiteur_session']['prefs'];
579
+    $p['cnx'] = (isset($auteur['cookie']) && $auteur['cookie'] == 'oui') ? 'perma' : '';
580
+
581
+    sql_updateq(
582
+        'spip_auteurs',
583
+        ['prefs' => serialize($p)],
584
+        'id_auteur=' . (int) $auteur['id_auteur']
585
+    );
586
+
587
+    //  bloquer ici le visiteur qui tente d'abuser de ses droits
588
+    verifier_visiteur();
589
+    return true;
590 590
 }
591 591
 
592 592
 /**
@@ -596,8 +596,8 @@  discard block
 block discarded – undo
596 596
  * return void
597 597
  **/
598 598
 function auth_deloger() {
599
-	$logout = charger_fonction('logout', 'action');
600
-	$logout();
599
+    $logout = charger_fonction('logout', 'action');
600
+    $logout();
601 601
 }
602 602
 
603 603
 /**
@@ -611,8 +611,8 @@  discard block
 block discarded – undo
611 611
  * @return bool
612 612
  */
613 613
 function auth_autoriser_modifier_login($auth_methode, $serveur = '') {
614
-	$args = func_get_args();
615
-	return auth_administrer('autoriser_modifier_login', $args);
614
+    $args = func_get_args();
615
+    return auth_administrer('autoriser_modifier_login', $args);
616 616
 }
617 617
 
618 618
 /**
@@ -627,8 +627,8 @@  discard block
 block discarded – undo
627 627
  *  message d'erreur ou chaine vide si pas d'erreur
628 628
  */
629 629
 function auth_verifier_login($auth_methode, $new_login, $id_auteur = 0, $serveur = '') {
630
-	$args = func_get_args();
631
-	return auth_administrer('verifier_login', $args, '');
630
+    $args = func_get_args();
631
+    return auth_administrer('verifier_login', $args, '');
632 632
 }
633 633
 
634 634
 /**
@@ -641,8 +641,8 @@  discard block
 block discarded – undo
641 641
  * @return bool
642 642
  */
643 643
 function auth_modifier_login($auth_methode, $new_login, $id_auteur, $serveur = '') {
644
-	$args = func_get_args();
645
-	return auth_administrer('modifier_login', $args);
644
+    $args = func_get_args();
645
+    return auth_administrer('modifier_login', $args);
646 646
 }
647 647
 
648 648
 /**
@@ -657,8 +657,8 @@  discard block
 block discarded – undo
657 657
  *  succès ou échec
658 658
  */
659 659
 function auth_autoriser_modifier_pass($auth_methode, $serveur = '') {
660
-	$args = func_get_args();
661
-	return auth_administrer('autoriser_modifier_pass', $args);
660
+    $args = func_get_args();
661
+    return auth_administrer('autoriser_modifier_pass', $args);
662 662
 }
663 663
 
664 664
 /**
@@ -674,8 +674,8 @@  discard block
 block discarded – undo
674 674
  *  message d'erreur ou chaine vide si pas d'erreur
675 675
  */
676 676
 function auth_verifier_pass($auth_methode, $login, #[\SensitiveParameter] $new_pass, $id_auteur = 0, $serveur = '') {
677
-	$args = func_get_args();
678
-	return auth_administrer('verifier_pass', $args, '');
677
+    $args = func_get_args();
678
+    return auth_administrer('verifier_pass', $args, '');
679 679
 }
680 680
 
681 681
 /**
@@ -691,8 +691,8 @@  discard block
 block discarded – undo
691 691
  *  succes ou echec
692 692
  */
693 693
 function auth_modifier_pass($auth_methode, $login, #[\SensitiveParameter] $new_pass, $id_auteur, $serveur = '') {
694
-	$args = func_get_args();
695
-	return auth_administrer('modifier_pass', $args);
694
+    $args = func_get_args();
695
+    return auth_administrer('modifier_pass', $args);
696 696
 }
697 697
 
698 698
 /**
@@ -708,24 +708,24 @@  discard block
 block discarded – undo
708 708
  * @return void
709 709
  */
710 710
 function auth_synchroniser_distant(
711
-	$auth_methode = true,
712
-	$id_auteur = 0,
713
-	$champs = [],
714
-	$options = [],
715
-	$serveur = ''
711
+    $auth_methode = true,
712
+    $id_auteur = 0,
713
+    $champs = [],
714
+    $options = [],
715
+    $serveur = ''
716 716
 ) {
717
-	$args = func_get_args();
718
-	if ($auth_methode === true || isset($options['all']) && $options['all'] == true) {
719
-		$options['all'] = true; // ajouter une option all=>true pour chaque auth
720
-		$args = [true, $id_auteur, $champs, $options, $serveur];
721
-		foreach ($GLOBALS['liste_des_authentifications'] as $methode) {
722
-			array_shift($args);
723
-			array_unshift($args, $methode);
724
-			auth_administrer('synchroniser_distant', $args);
725
-		}
726
-	} else {
727
-		auth_administrer('synchroniser_distant', $args);
728
-	}
717
+    $args = func_get_args();
718
+    if ($auth_methode === true || isset($options['all']) && $options['all'] == true) {
719
+        $options['all'] = true; // ajouter une option all=>true pour chaque auth
720
+        $args = [true, $id_auteur, $champs, $options, $serveur];
721
+        foreach ($GLOBALS['liste_des_authentifications'] as $methode) {
722
+            array_shift($args);
723
+            array_unshift($args, $methode);
724
+            auth_administrer('synchroniser_distant', $args);
725
+        }
726
+    } else {
727
+        auth_administrer('synchroniser_distant', $args);
728
+    }
729 729
 }
730 730
 
731 731
 
@@ -738,46 +738,46 @@  discard block
 block discarded – undo
738 738
  * @return array|bool
739 739
  */
740 740
 function lire_php_auth($login, #[\SensitiveParameter] $pw, $serveur = '') {
741
-	if (
742
-		!$login
743
-		|| !$login_base = auth_retrouver_login($login, $serveur)
744
-	) {
745
-		return false;
746
-	}
747
-
748
-	$row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login_base, $serveur, 'text'), '', '', '', '', $serveur);
749
-
750
-	if (!$row) {
751
-		if (
752
-			include_spip('inc/auth')
753
-			&& auth_ldap_connect($serveur)
754
-			&& ($auth_ldap = charger_fonction('ldap', 'auth', true))
755
-		) {
756
-			return $auth_ldap($login_base, $pw, $serveur, true);
757
-		}
758
-
759
-		return false;
760
-	}
761
-
762
-	// si pas de source definie
763
-	// ou auth/xxx introuvable, utiliser 'spip' ou autre et avec le login passé par PHP_AUTH_USER
764
-	if (
765
-		!($auth_methode = $row['source'])
766
-		|| !($auth = charger_fonction($auth_methode, 'auth', true))
767
-	) {
768
-		$auth = charger_fonction('spip', 'auth', true);
769
-	}
770
-
771
-	$auteur = '';
772
-	if ($auth) {
773
-		$auteur = $auth($login, $pw, $serveur, true);
774
-	}
775
-	// verifier que ce n'est pas un message d'erreur
776
-	if (is_array($auteur) && count($auteur)) {
777
-		return $auteur;
778
-	}
779
-
780
-	return false;
741
+    if (
742
+        !$login
743
+        || !$login_base = auth_retrouver_login($login, $serveur)
744
+    ) {
745
+        return false;
746
+    }
747
+
748
+    $row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login_base, $serveur, 'text'), '', '', '', '', $serveur);
749
+
750
+    if (!$row) {
751
+        if (
752
+            include_spip('inc/auth')
753
+            && auth_ldap_connect($serveur)
754
+            && ($auth_ldap = charger_fonction('ldap', 'auth', true))
755
+        ) {
756
+            return $auth_ldap($login_base, $pw, $serveur, true);
757
+        }
758
+
759
+        return false;
760
+    }
761
+
762
+    // si pas de source definie
763
+    // ou auth/xxx introuvable, utiliser 'spip' ou autre et avec le login passé par PHP_AUTH_USER
764
+    if (
765
+        !($auth_methode = $row['source'])
766
+        || !($auth = charger_fonction($auth_methode, 'auth', true))
767
+    ) {
768
+        $auth = charger_fonction('spip', 'auth', true);
769
+    }
770
+
771
+    $auteur = '';
772
+    if ($auth) {
773
+        $auteur = $auth($login, $pw, $serveur, true);
774
+    }
775
+    // verifier que ce n'est pas un message d'erreur
776
+    if (is_array($auteur) && count($auteur)) {
777
+        return $auteur;
778
+    }
779
+
780
+    return false;
781 781
 }
782 782
 
783 783
 /**
@@ -793,21 +793,21 @@  discard block
 block discarded – undo
793 793
  * @param string $lien
794 794
  */
795 795
 function ask_php_auth($pb, $raison, $retour = '', $url = '', $re = '', $lien = '') {
796
-	@Header('WWW-Authenticate: Basic realm="espace prive"');
797
-	@Header('HTTP/1.0 401 Unauthorized');
798
-	$corps = '';
799
-	$public = generer_url_public();
800
-	$ecrire = generer_url_ecrire();
801
-	$retour = $retour ?: _T('icone_retour');
802
-	$corps .= "<p>$raison</p>[<a href='$public'>$retour</a>] ";
803
-	if ($url) {
804
-		$corps .= "[<a href='" . generer_url_action('cookie', "essai_auth_http=oui&$url") . "'>$re</a>]";
805
-	}
806
-
807
-	if ($lien) {
808
-		$corps .= " [<a href='$ecrire'>" . _T('login_espace_prive') . '</a>]';
809
-	}
810
-	include_spip('inc/minipres');
811
-	echo minipres($pb, $corps);
812
-	exit;
796
+    @Header('WWW-Authenticate: Basic realm="espace prive"');
797
+    @Header('HTTP/1.0 401 Unauthorized');
798
+    $corps = '';
799
+    $public = generer_url_public();
800
+    $ecrire = generer_url_ecrire();
801
+    $retour = $retour ?: _T('icone_retour');
802
+    $corps .= "<p>$raison</p>[<a href='$public'>$retour</a>] ";
803
+    if ($url) {
804
+        $corps .= "[<a href='" . generer_url_action('cookie', "essai_auth_http=oui&$url") . "'>$re</a>]";
805
+    }
806
+
807
+    if ($lien) {
808
+        $corps .= " [<a href='$ecrire'>" . _T('login_espace_prive') . '</a>]';
809
+    }
810
+    include_spip('inc/minipres');
811
+    echo minipres($pb, $corps);
812
+    exit;
813 813
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -14 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	}
59 59
 
60 60
 	$n = (int) sql_errno();
61
-	spip_log("Erreur base de donnees $n " . sql_error());
61
+	spip_log("Erreur base de donnees $n ".sql_error());
62 62
 
63 63
 	return $n ?: 1;
64 64
 }
@@ -101,19 +101,19 @@  discard block
 block discarded – undo
101 101
 		// erreur SQL a afficher
102 102
 		$raison = minipres(
103 103
 			_T('info_travaux_titre'),
104
-			_T('titre_probleme_technique') . '<p><tt>' . sql_errno() . ' ' . sql_error() . '</tt></p>'
104
+			_T('titre_probleme_technique').'<p><tt>'.sql_errno().' '.sql_error().'</tt></p>'
105 105
 		);
106 106
 	} elseif (@$raison['statut']) {
107 107
 		// un simple visiteur n'a pas acces a l'espace prive
108
-		spip_log('connexion refusee a ' . @$raison['id_auteur']);
108
+		spip_log('connexion refusee a '.@$raison['id_auteur']);
109 109
 		$est_connecte = (!empty($GLOBALS['visiteur_session']['login']) && !empty($GLOBALS['visiteur_session']['statut'])); // idem test balise #URL_LOGOUT
110 110
 		$raison = minipres(
111 111
 			_T('avis_erreur_connexion'),
112 112
 			_T('avis_erreur_visiteur')
113 113
 				// Lien vers le site public
114
-				. '<br /><a href="' . url_de_base() . '">' . _T('login_retour_public') . '</a>'
114
+				. '<br /><a href="'.url_de_base().'">'._T('login_retour_public').'</a>'
115 115
 				// Si la personne est connectée, lien de déconnexion ramenant vers la page de login
116
-				. ($est_connecte ? ' | <a href="' . generer_url_public('', 'action=logout&amp;logout=prive') . '">' . _T('icone_deconnecter') . '</a>' : '')
116
+				. ($est_connecte ? ' | <a href="'.generer_url_public('', 'action=logout&amp;logout=prive').'">'._T('icone_deconnecter').'</a>' : '')
117 117
 		);
118 118
 	} else {
119 119
 		// auteur en fin de droits ...
@@ -201,8 +201,7 @@  discard block
 block discarded – undo
201 201
 	$where = (is_numeric($id_auteur)
202 202
 		/*AND $id_auteur>0*/ // reprise lors des restaurations
203 203
 	) ?
204
-		"id_auteur=$id_auteur" :
205
-		(strlen((string) $GLOBALS['connect_login']) ? 'login=' . sql_quote($GLOBALS['connect_login'], '', 'text') : '');
204
+		"id_auteur=$id_auteur" : (strlen((string) $GLOBALS['connect_login']) ? 'login='.sql_quote($GLOBALS['connect_login'], '', 'text') : '');
206 205
 
207 206
 	if (!$where) {
208 207
 		return '';
@@ -327,7 +326,7 @@  discard block
 block discarded – undo
327 326
  * @return string
328 327
  */
329 328
 function auth_a_loger() {
330
-	$redirect = generer_url_public('login', 'url=' . rawurlencode((string) self('&', true)), true);
329
+	$redirect = generer_url_public('login', 'url='.rawurlencode((string) self('&', true)), true);
331 330
 
332 331
 	// un echec au "bonjour" (login initial) quand le statut est
333 332
 	// inconnu signale sans doute un probleme de cookies
@@ -363,7 +362,7 @@  discard block
 block discarded – undo
363 362
 	$date ??= date('Y-m-d H:i:s');
364 363
 
365 364
 	if (abs(strtotime($date) - $connect_quand) >= 60) {
366
-		sql_updateq('spip_auteurs', ['en_ligne' => $date], 'id_auteur=' . (int) $row['id_auteur']);
365
+		sql_updateq('spip_auteurs', ['en_ligne' => $date], 'id_auteur='.(int) $row['id_auteur']);
367 366
 		$row['en_ligne'] = $date;
368 367
 	}
369 368
 
@@ -471,7 +470,7 @@  discard block
 block discarded – undo
471 470
 	if (
472 471
 		!$login
473 472
 		|| !($login_base = auth_retrouver_login($login, $serveur))
474
-		|| !($row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login_base, $serveur, 'text'), '', '', '', '', $serveur))
473
+		|| !($row = sql_fetsel('*', 'spip_auteurs', 'login='.sql_quote($login_base, $serveur, 'text'), '', '', '', '', $serveur))
475 474
 	) {
476 475
 		// generer de fausses infos, mais credibles, pour eviter une attaque
477 476
 		// https://core.spip.net/issues/1758 + https://core.spip.net/issues/3691
@@ -581,7 +580,7 @@  discard block
 block discarded – undo
581 580
 	sql_updateq(
582 581
 		'spip_auteurs',
583 582
 		['prefs' => serialize($p)],
584
-		'id_auteur=' . (int) $auteur['id_auteur']
583
+		'id_auteur='.(int) $auteur['id_auteur']
585 584
 	);
586 585
 
587 586
 	//  bloquer ici le visiteur qui tente d'abuser de ses droits
@@ -745,7 +744,7 @@  discard block
 block discarded – undo
745 744
 		return false;
746 745
 	}
747 746
 
748
-	$row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login_base, $serveur, 'text'), '', '', '', '', $serveur);
747
+	$row = sql_fetsel('*', 'spip_auteurs', 'login='.sql_quote($login_base, $serveur, 'text'), '', '', '', '', $serveur);
749 748
 
750 749
 	if (!$row) {
751 750
 		if (
@@ -801,11 +800,11 @@  discard block
 block discarded – undo
801 800
 	$retour = $retour ?: _T('icone_retour');
802 801
 	$corps .= "<p>$raison</p>[<a href='$public'>$retour</a>] ";
803 802
 	if ($url) {
804
-		$corps .= "[<a href='" . generer_url_action('cookie', "essai_auth_http=oui&$url") . "'>$re</a>]";
803
+		$corps .= "[<a href='".generer_url_action('cookie', "essai_auth_http=oui&$url")."'>$re</a>]";
805 804
 	}
806 805
 
807 806
 	if ($lien) {
808
-		$corps .= " [<a href='$ecrire'>" . _T('login_espace_prive') . '</a>]';
807
+		$corps .= " [<a href='$ecrire'>"._T('login_espace_prive').'</a>]';
809 808
 	}
810 809
 	include_spip('inc/minipres');
811 810
 	echo minipres($pb, $corps);
Please login to merge, or discard this patch.
ecrire/inc/minipres.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  * @package SPIP\Core\Minipres
18 18
  **/
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -37,19 +37,19 @@  discard block
 block discarded – undo
37 37
  */
38 38
 function install_debut_html($titre = 'AUTO', $onLoad = '', $all_inline = false) {
39 39
 
40
-	if ($onLoad) {
41
-		include_spip('inc/filtres');
42
-		$onLoad = extraire_attribut("<body $onLoad>", 'onload');
43
-	}
40
+    if ($onLoad) {
41
+        include_spip('inc/filtres');
42
+        $onLoad = extraire_attribut("<body $onLoad>", 'onload');
43
+    }
44 44
 
45
-	$options = [
46
-		'all_inline' => $all_inline,
47
-		'onload' => $onLoad,
48
-		'titre' => $titre,
49
-	];
45
+    $options = [
46
+        'all_inline' => $all_inline,
47
+        'onload' => $onLoad,
48
+        'titre' => $titre,
49
+    ];
50 50
 
51
-	$minipage = new Admin();
52
-	return $minipage->installDebutPage($options);
51
+    $minipage = new Admin();
52
+    return $minipage->installDebutPage($options);
53 53
 }
54 54
 
55 55
 /**
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
  * @return string Code HTML
62 62
  */
63 63
 function install_fin_html() {
64
-	$minipage = new Admin();
65
-	return $minipage->installFinPage();
64
+    $minipage = new Admin();
65
+    return $minipage->installFinPage();
66 66
 }
67 67
 
68 68
 
@@ -101,23 +101,23 @@  discard block
 block discarded – undo
101 101
  */
102 102
 function minipres($titre = '', $corps = '', $options = []) {
103 103
 
104
-	// compat signature old
105
-	// minipres($titre='', $corps="", $onload='', $all_inline = false)
106
-	$args = func_get_args();
107
-	if (isset($args[2]) && is_string($args[2])) {
108
-		$options = ['onload' => $args[2]];
109
-	}
110
-	if (isset($args[3])) {
111
-		$options['all_inline'] = $args[3];
112
-	}
104
+    // compat signature old
105
+    // minipres($titre='', $corps="", $onload='', $all_inline = false)
106
+    $args = func_get_args();
107
+    if (isset($args[2]) && is_string($args[2])) {
108
+        $options = ['onload' => $args[2]];
109
+    }
110
+    if (isset($args[3])) {
111
+        $options['all_inline'] = $args[3];
112
+    }
113 113
 
114
-	$options = array_merge([
115
-		'onload' => '',
116
-		'all_inline' => false,
117
-	], $options);
114
+    $options = array_merge([
115
+        'onload' => '',
116
+        'all_inline' => false,
117
+    ], $options);
118 118
 
119
-	$options['titre'] = $titre;
119
+    $options['titre'] = $titre;
120 120
 
121
-	$minipage = new Admin();
122
-	return $minipage->page($corps, $options);
121
+    $minipage = new Admin();
122
+    return $minipage->page($corps, $options);
123 123
 }
Please login to merge, or discard this patch.
ecrire/inc/lang.php 2 patches
Indentation   +256 added lines, -256 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * @package SPIP\Core\Langue
16 16
  **/
17 17
 if (!defined('_ECRIRE_INC_VERSION')) {
18
-	return;
18
+    return;
19 19
 }
20 20
 
21 21
 
@@ -38,35 +38,35 @@  discard block
 block discarded – undo
38 38
  **/
39 39
 function changer_langue($lang, $liste_langues = null) {
40 40
 
41
-	if (empty($lang)) {
42
-		return false;
43
-	}
44
-
45
-	if (is_null($liste_langues)) {
46
-		$liste_langues = ($GLOBALS['meta']['langues_proposees'] ?? '') . ',' . ($GLOBALS['meta']['langues_multilingue'] ?? '');
47
-	} else {
48
-		if (is_array($liste_langues)) {
49
-			$liste_langues = implode(',', $liste_langues);
50
-		}
51
-	}
52
-	$liste_langues = ',' . $liste_langues . ',';
53
-
54
-	// Si la langue demandee n'existe pas, on essaie d'autres variantes
55
-	// Exemple : 'pt-br' => 'pt_br' => 'pt'
56
-	$lang = str_replace('-', '_', trim($lang));
57
-
58
-	if (
59
-		str_contains($liste_langues, (string) ",$lang,")
60
-		|| ($lang = preg_replace(',_.*,', '', $lang)) && str_contains($liste_langues, (string) ",$lang,")
61
-	) {
62
-		$GLOBALS['spip_lang_rtl'] = lang_dir($lang, '', '_rtl');
63
-		$GLOBALS['spip_lang_right'] = $GLOBALS['spip_lang_rtl'] ? 'left' : 'right';
64
-		$GLOBALS['spip_lang_left'] = $GLOBALS['spip_lang_rtl'] ? 'right' : 'left';
65
-
66
-		return $GLOBALS['spip_lang'] = $lang;
67
-	} else {
68
-		return false;
69
-	}
41
+    if (empty($lang)) {
42
+        return false;
43
+    }
44
+
45
+    if (is_null($liste_langues)) {
46
+        $liste_langues = ($GLOBALS['meta']['langues_proposees'] ?? '') . ',' . ($GLOBALS['meta']['langues_multilingue'] ?? '');
47
+    } else {
48
+        if (is_array($liste_langues)) {
49
+            $liste_langues = implode(',', $liste_langues);
50
+        }
51
+    }
52
+    $liste_langues = ',' . $liste_langues . ',';
53
+
54
+    // Si la langue demandee n'existe pas, on essaie d'autres variantes
55
+    // Exemple : 'pt-br' => 'pt_br' => 'pt'
56
+    $lang = str_replace('-', '_', trim($lang));
57
+
58
+    if (
59
+        str_contains($liste_langues, (string) ",$lang,")
60
+        || ($lang = preg_replace(',_.*,', '', $lang)) && str_contains($liste_langues, (string) ",$lang,")
61
+    ) {
62
+        $GLOBALS['spip_lang_rtl'] = lang_dir($lang, '', '_rtl');
63
+        $GLOBALS['spip_lang_right'] = $GLOBALS['spip_lang_rtl'] ? 'left' : 'right';
64
+        $GLOBALS['spip_lang_left'] = $GLOBALS['spip_lang_rtl'] ? 'right' : 'left';
65
+
66
+        return $GLOBALS['spip_lang'] = $lang;
67
+    } else {
68
+        return false;
69
+    }
70 70
 }
71 71
 
72 72
 //
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 // par exemple le francais pour l'espagnol, l'anglais pour l'allemand, etc.
80 80
 
81 81
 function choisir_traduction($trads, $lang = '') {
82
-	$k = approcher_langue($trads, $lang);
82
+    $k = approcher_langue($trads, $lang);
83 83
 
84
-	return $k ? $trads[$k] : array_shift($trads);
84
+    return $k ? $trads[$k] : array_shift($trads);
85 85
 }
86 86
 
87 87
 // retourne son 2e argument si c'est un index du premier
@@ -89,21 +89,21 @@  discard block
 block discarded – undo
89 89
 // la langue X etant consideree comme une approche de X_Y
90 90
 function approcher_langue($trads, $lang = '') {
91 91
 
92
-	if (!$lang) {
93
-		$lang = $GLOBALS['spip_lang'];
94
-	}
95
-
96
-	if (isset($trads[$lang])) {
97
-		return $lang;
98
-	} // cas des langues xx_yy
99
-	else {
100
-		$r = explode('_', (string) $lang);
101
-		if (isset($trads[$r[0]])) {
102
-			return $r[0];
103
-		}
104
-	}
105
-
106
-	return '';
92
+    if (!$lang) {
93
+        $lang = $GLOBALS['spip_lang'];
94
+    }
95
+
96
+    if (isset($trads[$lang])) {
97
+        return $lang;
98
+    } // cas des langues xx_yy
99
+    else {
100
+        $r = explode('_', (string) $lang);
101
+        if (isset($trads[$r[0]])) {
102
+            return $r[0];
103
+        }
104
+    }
105
+
106
+    return '';
107 107
 }
108 108
 
109 109
 /**
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
  *     Nom de la langue, sinon son code.
119 119
  **/
120 120
 function traduire_nom_langue($lang) {
121
-	include_spip('inc/lang_liste');
122
-	include_spip('inc/charsets');
121
+    include_spip('inc/lang_liste');
122
+    include_spip('inc/charsets');
123 123
 
124
-	return html2unicode($GLOBALS['codes_langues'][$lang] ?? $lang);
124
+    return html2unicode($GLOBALS['codes_langues'][$lang] ?? $lang);
125 125
 }
126 126
 
127 127
 //
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
 // hebreu a priori), 'droitier' sinon.
135 135
 // C'est utilise par #LANG_DIR, #LANG_LEFT, #LANG_RIGHT.
136 136
 function lang_dir($lang = '', $droitier = 'ltr', $gaucher = 'rtl') {
137
-	static $lang_rtl = ['ar', 'fa', 'ku', 'prs', 'ps', 'ur', 'he', 'heb', 'hbo', 'yi'];
137
+    static $lang_rtl = ['ar', 'fa', 'ku', 'prs', 'ps', 'ur', 'he', 'heb', 'hbo', 'yi'];
138 138
 
139
-	return in_array(($lang ?: $GLOBALS['spip_lang']), $lang_rtl) ?
140
-		$gaucher : $droitier;
139
+    return in_array(($lang ?: $GLOBALS['spip_lang']), $lang_rtl) ?
140
+        $gaucher : $droitier;
141 141
 }
142 142
 
143 143
 // typo francaise ou anglaise ?
@@ -146,29 +146,29 @@  discard block
 block discarded – undo
146 146
 // sinon determiner la typo en fonction de la langue courante
147 147
 
148 148
 function lang_typo($lang = '') {
149
-	if (!$lang) {
150
-		$lang = $GLOBALS['lang_objet'] ?? $GLOBALS['spip_lang'];
151
-	}
152
-	if (
153
-		$lang == 'eo'
154
-		|| $lang == 'fr'
155
-		|| str_starts_with((string) $lang, 'fr_')
156
-		|| $lang == 'cpf'
157
-	) {
158
-		return 'fr';
159
-	} else {
160
-		return 'en';
161
-	}
149
+    if (!$lang) {
150
+        $lang = $GLOBALS['lang_objet'] ?? $GLOBALS['spip_lang'];
151
+    }
152
+    if (
153
+        $lang == 'eo'
154
+        || $lang == 'fr'
155
+        || str_starts_with((string) $lang, 'fr_')
156
+        || $lang == 'cpf'
157
+    ) {
158
+        return 'fr';
159
+    } else {
160
+        return 'en';
161
+    }
162 162
 }
163 163
 
164 164
 // gestion de la globale $lang_objet pour que les textes soient affiches
165 165
 // avec les memes typo et direction dans l'espace prive que dans le public
166 166
 function changer_typo($lang = '') {
167
-	if ($lang) {
168
-		$GLOBALS['lang_objet'] = $lang;
169
-	} else {
170
-		unset($GLOBALS['lang_objet']);
171
-	}
167
+    if ($lang) {
168
+        $GLOBALS['lang_objet'] = $lang;
169
+    } else {
170
+        unset($GLOBALS['lang_objet']);
171
+    }
172 172
 }
173 173
 
174 174
 //
@@ -178,56 +178,56 @@  discard block
 block discarded – undo
178 178
 // pour 'changer_lang' (langue de l'article, espace prive), c'est en Ajax
179 179
 //
180 180
 function menu_langues($nom_select, $default = '') {
181
-	include_spip('inc/actions');
182
-
183
-	$langues = liste_options_langues($nom_select);
184
-	$ret = '';
185
-	if ($langues === []) {
186
-		return '';
187
-	}
188
-
189
-	if (!$default) {
190
-		$default = $GLOBALS['spip_lang'];
191
-	}
192
-	foreach ($langues as $l) {
193
-		$selected = ($l == $default) ? ' selected=\'selected\'' : '';
194
-		$ret .= "<option value='$l'$selected>[" . $l . '] ' . traduire_nom_langue($l) . "</option>\n";
195
-	}
196
-
197
-	if (!test_espace_prive()) {
198
-		$cible = self();
199
-		$base = '';
200
-	} else {
201
-		$cible = self();
202
-		$base = spip_connect() ? 'base' : '';
203
-	}
204
-
205
-	$change = ' onchange="this.parentNode.parentNode.submit()"';
206
-
207
-	return generer_action_auteur(
208
-		'converser',
209
-		$base,
210
-		$cible,
211
-		(select_langues($nom_select, $change, $ret)
212
-			. "<noscript><div style='display:inline'><input type='submit' class='fondo' value='" . _T('bouton_changer') . "' /></div></noscript>"),
213
-		" method='post'"
214
-	);
181
+    include_spip('inc/actions');
182
+
183
+    $langues = liste_options_langues($nom_select);
184
+    $ret = '';
185
+    if ($langues === []) {
186
+        return '';
187
+    }
188
+
189
+    if (!$default) {
190
+        $default = $GLOBALS['spip_lang'];
191
+    }
192
+    foreach ($langues as $l) {
193
+        $selected = ($l == $default) ? ' selected=\'selected\'' : '';
194
+        $ret .= "<option value='$l'$selected>[" . $l . '] ' . traduire_nom_langue($l) . "</option>\n";
195
+    }
196
+
197
+    if (!test_espace_prive()) {
198
+        $cible = self();
199
+        $base = '';
200
+    } else {
201
+        $cible = self();
202
+        $base = spip_connect() ? 'base' : '';
203
+    }
204
+
205
+    $change = ' onchange="this.parentNode.parentNode.submit()"';
206
+
207
+    return generer_action_auteur(
208
+        'converser',
209
+        $base,
210
+        $cible,
211
+        (select_langues($nom_select, $change, $ret)
212
+            . "<noscript><div style='display:inline'><input type='submit' class='fondo' value='" . _T('bouton_changer') . "' /></div></noscript>"),
213
+        " method='post'"
214
+    );
215 215
 }
216 216
 
217 217
 function select_langues($nom_select, $change, $options, $label = '') {
218
-	static $cpt = 0;
219
-	$id = 'menu_langues' . $cpt++;
220
-
221
-	return
222
-		"<label for='$id'>" . ($label ?: _T('info_langues')) . '</label> ' .
223
-		"<select name='$nom_select' id='$id' "
224
-		. ((test_espace_prive()) ?
225
-			(($nom_select == 'var_lang_ecrire' ? "class='lang_ecrire'" : "class='fondl'")) :
226
-			("class='forml menu_langues'"))
227
-		. $change
228
-		. ">\n"
229
-		. $options
230
-		. '</select>';
218
+    static $cpt = 0;
219
+    $id = 'menu_langues' . $cpt++;
220
+
221
+    return
222
+        "<label for='$id'>" . ($label ?: _T('info_langues')) . '</label> ' .
223
+        "<select name='$nom_select' id='$id' "
224
+        . ((test_espace_prive()) ?
225
+            (($nom_select == 'var_lang_ecrire' ? "class='lang_ecrire'" : "class='fondl'")) :
226
+            ("class='forml menu_langues'"))
227
+        . $change
228
+        . ">\n"
229
+        . $options
230
+        . '</select>';
231 231
 }
232 232
 
233 233
 /**
@@ -249,34 +249,34 @@  discard block
 block discarded – undo
249 249
  */
250 250
 function liste_options_langues($nom_select) {
251 251
 
252
-	switch ($nom_select) {
253
-		# #MENU_LANG
254
-		case 'var_lang':
255
-			# menu de changement de la langue d'un article
256
-			# les langues selectionnees dans la configuration "multilinguisme"
257
-		case 'changer_lang':
258
-			$langues = explode(',', (string) $GLOBALS['meta']['langues_multilingue']);
259
-			break;
260
-		# menu de l'interface (privee, installation et panneau de login)
261
-		# les langues presentes sous forme de fichiers de langue
262
-		# on force la relecture du repertoire des langues pour etre synchrone.
263
-		case 'var_lang_ecrire':
264
-		default:
265
-			$GLOBALS['meta']['langues_proposees'] = '';
266
-			init_langues();
267
-			$langues = explode(',', $GLOBALS['meta']['langues_proposees']);
268
-			break;
252
+    switch ($nom_select) {
253
+        # #MENU_LANG
254
+        case 'var_lang':
255
+            # menu de changement de la langue d'un article
256
+            # les langues selectionnees dans la configuration "multilinguisme"
257
+        case 'changer_lang':
258
+            $langues = explode(',', (string) $GLOBALS['meta']['langues_multilingue']);
259
+            break;
260
+        # menu de l'interface (privee, installation et panneau de login)
261
+        # les langues presentes sous forme de fichiers de langue
262
+        # on force la relecture du repertoire des langues pour etre synchrone.
263
+        case 'var_lang_ecrire':
264
+        default:
265
+            $GLOBALS['meta']['langues_proposees'] = '';
266
+            init_langues();
267
+            $langues = explode(',', $GLOBALS['meta']['langues_proposees']);
268
+            break;
269 269
 
270 270
 # dernier choix possible : toutes les langues = langues_proposees
271 271
 # + langues_multilingues ; mais, ne sert pas
272 272
 #			$langues = explode(',', $GLOBALS['all_langs']);
273
-	}
274
-	if (count($langues) <= 1) {
275
-		return [];
276
-	}
277
-	sort($langues);
273
+    }
274
+    if (count($langues) <= 1) {
275
+        return [];
276
+    }
277
+    sort($langues);
278 278
 
279
-	return $langues;
279
+    return $langues;
280 280
 }
281 281
 
282 282
 
@@ -291,39 +291,39 @@  discard block
 block discarded – undo
291 291
  **/
292 292
 function verifier_lang_url() {
293 293
 
294
-	// quelle langue est demandee ?
295
-	$lang_demandee = (test_espace_prive() ? $GLOBALS['spip_lang'] : $GLOBALS['meta']['langue_site']);
296
-	if (isset($_COOKIE['spip_lang_ecrire'])) {
297
-		$lang_demandee = $_COOKIE['spip_lang_ecrire'];
298
-	}
299
-	if (!test_espace_prive() && isset($_COOKIE['spip_lang'])) {
300
-		$lang_demandee = $_COOKIE['spip_lang'];
301
-	}
302
-	if (isset($_GET['lang'])) {
303
-		$lang_demandee = $_GET['lang'];
304
-	}
305
-
306
-	// Renvoyer si besoin (et si la langue demandee existe)
307
-	if (
308
-		$GLOBALS['spip_lang'] != $lang_demandee
309
-		&& changer_langue($lang_demandee)
310
-		&& $lang_demandee != @$_GET['lang']
311
-	) {
312
-		$destination = parametre_url(self(), 'lang', $lang_demandee, '&');
313
-		// ici on a besoin des var_truc
314
-		foreach ($_GET as $var => $val) {
315
-			if (!strncmp('var_', $var, 4)) {
316
-				$destination = parametre_url($destination, $var, $val, '&');
317
-			}
318
-		}
319
-		include_spip('inc/headers');
320
-		redirige_par_entete($destination);
321
-	}
322
-
323
-	// Subtilite : si la langue demandee par cookie est la bonne
324
-	// alors on fait comme si $lang etait passee dans l'URL
325
-	// (pour criteres {lang}).
326
-	$GLOBALS['lang'] = $_GET['lang'] = $GLOBALS['spip_lang'];
294
+    // quelle langue est demandee ?
295
+    $lang_demandee = (test_espace_prive() ? $GLOBALS['spip_lang'] : $GLOBALS['meta']['langue_site']);
296
+    if (isset($_COOKIE['spip_lang_ecrire'])) {
297
+        $lang_demandee = $_COOKIE['spip_lang_ecrire'];
298
+    }
299
+    if (!test_espace_prive() && isset($_COOKIE['spip_lang'])) {
300
+        $lang_demandee = $_COOKIE['spip_lang'];
301
+    }
302
+    if (isset($_GET['lang'])) {
303
+        $lang_demandee = $_GET['lang'];
304
+    }
305
+
306
+    // Renvoyer si besoin (et si la langue demandee existe)
307
+    if (
308
+        $GLOBALS['spip_lang'] != $lang_demandee
309
+        && changer_langue($lang_demandee)
310
+        && $lang_demandee != @$_GET['lang']
311
+    ) {
312
+        $destination = parametre_url(self(), 'lang', $lang_demandee, '&');
313
+        // ici on a besoin des var_truc
314
+        foreach ($_GET as $var => $val) {
315
+            if (!strncmp('var_', $var, 4)) {
316
+                $destination = parametre_url($destination, $var, $val, '&');
317
+            }
318
+        }
319
+        include_spip('inc/headers');
320
+        redirige_par_entete($destination);
321
+    }
322
+
323
+    // Subtilite : si la langue demandee par cookie est la bonne
324
+    // alors on fait comme si $lang etait passee dans l'URL
325
+    // (pour criteres {lang}).
326
+    $GLOBALS['lang'] = $_GET['lang'] = $GLOBALS['spip_lang'];
327 327
 }
328 328
 
329 329
 
@@ -341,19 +341,19 @@  discard block
 block discarded – undo
341 341
  *     La langue sélectionnée
342 342
  **/
343 343
 function utiliser_langue_site($liste_langues = null) {
344
-	// s'il existe une langue du site (en gros tout le temps en théorie)
345
-	if (
346
-		isset($GLOBALS['meta']['langue_site'])
347
-		&& (!isset($GLOBALS['spip_lang']) || $GLOBALS['spip_lang'] != $GLOBALS['meta']['langue_site'])
348
-	) {
349
-		return changer_langue($GLOBALS['meta']['langue_site'], $liste_langues);//@:install
350
-	}
351
-	// en theorie là, la globale est définie, sinon c'est un problème.
352
-	if (!isset($GLOBALS['spip_lang'])) {
353
-		spip_log('La globale spip_lang est indéfinie dans utiliser_langue_site() !', _LOG_ERREUR);
354
-	}
355
-
356
-	return $GLOBALS['spip_lang'];
344
+    // s'il existe une langue du site (en gros tout le temps en théorie)
345
+    if (
346
+        isset($GLOBALS['meta']['langue_site'])
347
+        && (!isset($GLOBALS['spip_lang']) || $GLOBALS['spip_lang'] != $GLOBALS['meta']['langue_site'])
348
+    ) {
349
+        return changer_langue($GLOBALS['meta']['langue_site'], $liste_langues);//@:install
350
+    }
351
+    // en theorie là, la globale est définie, sinon c'est un problème.
352
+    if (!isset($GLOBALS['spip_lang'])) {
353
+        spip_log('La globale spip_lang est indéfinie dans utiliser_langue_site() !', _LOG_ERREUR);
354
+    }
355
+
356
+    return $GLOBALS['spip_lang'];
357 357
 }
358 358
 
359 359
 /**
@@ -372,38 +372,38 @@  discard block
 block discarded – undo
372 372
  **/
373 373
 function utiliser_langue_visiteur($liste_langues = null) {
374 374
 
375
-	// si on est dans l'espace public et pas de $liste_langues : se limiter a la config langues_multilingue si définie
376
-	if (is_null($liste_langues) && !test_espace_prive() && !empty($GLOBALS['meta']['langues_multilingue'])) {
377
-		$liste_langues = $GLOBALS['meta']['langues_multilingue'];
378
-	}
379
-
380
-	$l = (test_espace_prive() ? 'spip_lang_ecrire' : 'spip_lang');
381
-	if (
382
-		isset($_COOKIE[$l])
383
-		&& changer_langue($l = $_COOKIE[$l], $liste_langues)
384
-	) {
385
-		return $l;
386
-	}
387
-
388
-	if (
389
-		isset($GLOBALS['visiteur_session']['lang'])
390
-		&& changer_langue($l = $GLOBALS['visiteur_session']['lang'], $liste_langues)
391
-	) {
392
-		return $l;
393
-	}
394
-
395
-	if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
396
-		foreach (explode(',', (string) $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $s) {
397
-			if (
398
-				preg_match('#^([a-z]{2,3})(-[a-z]{2,3})?(;q=[0-9.]+)?$#i', trim($s), $r)
399
-				&& changer_langue($l = strtolower($r[1]), $liste_langues)
400
-			) {
401
-				return $l;
402
-			}
403
-		}
404
-	}
405
-
406
-	return utiliser_langue_site($liste_langues);
375
+    // si on est dans l'espace public et pas de $liste_langues : se limiter a la config langues_multilingue si définie
376
+    if (is_null($liste_langues) && !test_espace_prive() && !empty($GLOBALS['meta']['langues_multilingue'])) {
377
+        $liste_langues = $GLOBALS['meta']['langues_multilingue'];
378
+    }
379
+
380
+    $l = (test_espace_prive() ? 'spip_lang_ecrire' : 'spip_lang');
381
+    if (
382
+        isset($_COOKIE[$l])
383
+        && changer_langue($l = $_COOKIE[$l], $liste_langues)
384
+    ) {
385
+        return $l;
386
+    }
387
+
388
+    if (
389
+        isset($GLOBALS['visiteur_session']['lang'])
390
+        && changer_langue($l = $GLOBALS['visiteur_session']['lang'], $liste_langues)
391
+    ) {
392
+        return $l;
393
+    }
394
+
395
+    if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
396
+        foreach (explode(',', (string) $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $s) {
397
+            if (
398
+                preg_match('#^([a-z]{2,3})(-[a-z]{2,3})?(;q=[0-9.]+)?$#i', trim($s), $r)
399
+                && changer_langue($l = strtolower($r[1]), $liste_langues)
400
+            ) {
401
+                return $l;
402
+            }
403
+        }
404
+    }
405
+
406
+    return utiliser_langue_site($liste_langues);
407 407
 }
408 408
 
409 409
 
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
  * @return int
414 414
  */
415 415
 function match_langue($chaine) {
416
-	return preg_match('/^[a-z]{2,3}(_[a-z]{2,3}){0,2}$/', $chaine);
416
+    return preg_match('/^[a-z]{2,3}(_[a-z]{2,3}){0,2}$/', $chaine);
417 417
 }
418 418
 
419 419
 /**
@@ -431,38 +431,38 @@  discard block
 block discarded – undo
431 431
  **/
432 432
 function init_langues() {
433 433
 
434
-	// liste des langues dans les meta, sauf a l'install
435
-	$all_langs = $GLOBALS['meta']['langues_proposees'] ?? '';
436
-
437
-	$tout = [];
438
-	if (!$all_langs) {
439
-		// trouver tous les modules lang/spip_xx.php
440
-		$modules = find_all_in_path('lang/', '/spip_([a-z_]+)\.php$');
441
-		foreach (array_keys($modules) as $name) {
442
-			if (
443
-				preg_match(',^spip_([a-z_]+)\.php$,', $name, $regs)
444
-				&& match_langue($regs[1])
445
-			) {
446
-				$tout[] = $regs[1];
447
-			}
448
-		}
449
-		sort($tout);
450
-		$tout = implode(',', $tout);
451
-		// Si les langues n'ont pas change, ne rien faire
452
-		if ($tout != $all_langs) {
453
-			$GLOBALS['meta']['langues_proposees'] = $tout;
454
-			include_spip('inc/meta');
455
-			ecrire_meta('langues_proposees', $tout);
456
-		}
457
-	}
458
-	if (!isset($GLOBALS['meta']['langue_site'])) {
459
-		// Initialisation : le francais si dispo, sinon la premiere langue trouvee
460
-		$GLOBALS['meta']['langue_site'] = $tout =
461
-			(!$all_langs || str_contains(',' . _LANGUE_PAR_DEFAUT . ',', (string) ",$all_langs,"))
462
-				? _LANGUE_PAR_DEFAUT
463
-				: substr((string) $all_langs, 0, strpos((string) $all_langs, ','));
464
-		ecrire_meta('langue_site', $tout);
465
-	}
434
+    // liste des langues dans les meta, sauf a l'install
435
+    $all_langs = $GLOBALS['meta']['langues_proposees'] ?? '';
436
+
437
+    $tout = [];
438
+    if (!$all_langs) {
439
+        // trouver tous les modules lang/spip_xx.php
440
+        $modules = find_all_in_path('lang/', '/spip_([a-z_]+)\.php$');
441
+        foreach (array_keys($modules) as $name) {
442
+            if (
443
+                preg_match(',^spip_([a-z_]+)\.php$,', $name, $regs)
444
+                && match_langue($regs[1])
445
+            ) {
446
+                $tout[] = $regs[1];
447
+            }
448
+        }
449
+        sort($tout);
450
+        $tout = implode(',', $tout);
451
+        // Si les langues n'ont pas change, ne rien faire
452
+        if ($tout != $all_langs) {
453
+            $GLOBALS['meta']['langues_proposees'] = $tout;
454
+            include_spip('inc/meta');
455
+            ecrire_meta('langues_proposees', $tout);
456
+        }
457
+    }
458
+    if (!isset($GLOBALS['meta']['langue_site'])) {
459
+        // Initialisation : le francais si dispo, sinon la premiere langue trouvee
460
+        $GLOBALS['meta']['langue_site'] = $tout =
461
+            (!$all_langs || str_contains(',' . _LANGUE_PAR_DEFAUT . ',', (string) ",$all_langs,"))
462
+                ? _LANGUE_PAR_DEFAUT
463
+                : substr((string) $all_langs, 0, strpos((string) $all_langs, ','));
464
+        ecrire_meta('langue_site', $tout);
465
+    }
466 466
 }
467 467
 
468 468
 /**
@@ -476,10 +476,10 @@  discard block
 block discarded – undo
476 476
  *     Code html de la balise <html>
477 477
  **/
478 478
 function html_lang_attributes() {
479
-	$lang = $GLOBALS['spip_lang'];
480
-	$dir = lang_dir($lang);
479
+    $lang = $GLOBALS['spip_lang'];
480
+    $dir = lang_dir($lang);
481 481
 
482
-	return "<html class='$dir $lang no-js' xmlns='http://www.w3.org/1999/xhtml' lang='$lang' dir='$dir'>\n";
482
+    return "<html class='$dir $lang no-js' xmlns='http://www.w3.org/1999/xhtml' lang='$lang' dir='$dir'>\n";
483 483
 }
484 484
 
485 485
 
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
  * @return string
494 494
  */
495 495
 function aide_lang_dir($spip_lang, $spip_lang_rtl) {
496
-	return ($spip_lang != 'he') ? $spip_lang_rtl : '';
496
+    return ($spip_lang != 'he') ? $spip_lang_rtl : '';
497 497
 }
498 498
 
499 499
 
Please login to merge, or discard this patch.
Spacing   +9 added lines, -10 removed lines patch added patch discarded remove patch
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
 	}
44 44
 
45 45
 	if (is_null($liste_langues)) {
46
-		$liste_langues = ($GLOBALS['meta']['langues_proposees'] ?? '') . ',' . ($GLOBALS['meta']['langues_multilingue'] ?? '');
46
+		$liste_langues = ($GLOBALS['meta']['langues_proposees'] ?? '').','.($GLOBALS['meta']['langues_multilingue'] ?? '');
47 47
 	} else {
48 48
 		if (is_array($liste_langues)) {
49 49
 			$liste_langues = implode(',', $liste_langues);
50 50
 		}
51 51
 	}
52
-	$liste_langues = ',' . $liste_langues . ',';
52
+	$liste_langues = ','.$liste_langues.',';
53 53
 
54 54
 	// Si la langue demandee n'existe pas, on essaie d'autres variantes
55 55
 	// Exemple : 'pt-br' => 'pt_br' => 'pt'
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	}
192 192
 	foreach ($langues as $l) {
193 193
 		$selected = ($l == $default) ? ' selected=\'selected\'' : '';
194
-		$ret .= "<option value='$l'$selected>[" . $l . '] ' . traduire_nom_langue($l) . "</option>\n";
194
+		$ret .= "<option value='$l'$selected>[".$l.'] '.traduire_nom_langue($l)."</option>\n";
195 195
 	}
196 196
 
197 197
 	if (!test_espace_prive()) {
@@ -209,21 +209,20 @@  discard block
 block discarded – undo
209 209
 		$base,
210 210
 		$cible,
211 211
 		(select_langues($nom_select, $change, $ret)
212
-			. "<noscript><div style='display:inline'><input type='submit' class='fondo' value='" . _T('bouton_changer') . "' /></div></noscript>"),
212
+			. "<noscript><div style='display:inline'><input type='submit' class='fondo' value='"._T('bouton_changer')."' /></div></noscript>"),
213 213
 		" method='post'"
214 214
 	);
215 215
 }
216 216
 
217 217
 function select_langues($nom_select, $change, $options, $label = '') {
218 218
 	static $cpt = 0;
219
-	$id = 'menu_langues' . $cpt++;
219
+	$id = 'menu_langues'.$cpt++;
220 220
 
221 221
 	return
222
-		"<label for='$id'>" . ($label ?: _T('info_langues')) . '</label> ' .
222
+		"<label for='$id'>".($label ?: _T('info_langues')).'</label> '.
223 223
 		"<select name='$nom_select' id='$id' "
224 224
 		. ((test_espace_prive()) ?
225
-			(($nom_select == 'var_lang_ecrire' ? "class='lang_ecrire'" : "class='fondl'")) :
226
-			("class='forml menu_langues'"))
225
+			(($nom_select == 'var_lang_ecrire' ? "class='lang_ecrire'" : "class='fondl'")) : ("class='forml menu_langues'"))
227 226
 		. $change
228 227
 		. ">\n"
229 228
 		. $options
@@ -346,7 +345,7 @@  discard block
 block discarded – undo
346 345
 		isset($GLOBALS['meta']['langue_site'])
347 346
 		&& (!isset($GLOBALS['spip_lang']) || $GLOBALS['spip_lang'] != $GLOBALS['meta']['langue_site'])
348 347
 	) {
349
-		return changer_langue($GLOBALS['meta']['langue_site'], $liste_langues);//@:install
348
+		return changer_langue($GLOBALS['meta']['langue_site'], $liste_langues); //@:install
350 349
 	}
351 350
 	// en theorie là, la globale est définie, sinon c'est un problème.
352 351
 	if (!isset($GLOBALS['spip_lang'])) {
@@ -458,7 +457,7 @@  discard block
 block discarded – undo
458 457
 	if (!isset($GLOBALS['meta']['langue_site'])) {
459 458
 		// Initialisation : le francais si dispo, sinon la premiere langue trouvee
460 459
 		$GLOBALS['meta']['langue_site'] = $tout =
461
-			(!$all_langs || str_contains(',' . _LANGUE_PAR_DEFAUT . ',', (string) ",$all_langs,"))
460
+			(!$all_langs || str_contains(','._LANGUE_PAR_DEFAUT.',', (string) ",$all_langs,"))
462 461
 				? _LANGUE_PAR_DEFAUT
463 462
 				: substr((string) $all_langs, 0, strpos((string) $all_langs, ','));
464 463
 		ecrire_meta('langue_site', $tout);
Please login to merge, or discard this patch.
ecrire/inc/pipelines.php 2 patches
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@  discard block
 block discarded – undo
15 15
  * @package SPIP\Core\Pipelines
16 16
  **/
17 17
 if (!defined('_ECRIRE_INC_VERSION')) {
18
-	return;
18
+    return;
19 19
 }
20 20
 if (test_espace_prive()) {
21
-	include_spip('inc/pipelines_ecrire');
21
+    include_spip('inc/pipelines_ecrire');
22 22
 }
23 23
 
24 24
 
@@ -44,26 +44,26 @@  discard block
 block discarded – undo
44 44
  * @return string          Contenu qui sera inséré dans le head HTML
45 45
  **/
46 46
 function f_jQuery($texte) {
47
-	$x = '';
48
-	$jquery_plugins = pipeline(
49
-		'jquery_plugins',
50
-		[
51
-			'javascript/jquery.js',
52
-			'javascript/jquery.form.js',
53
-			'javascript/jquery.autosave.js',
54
-			'javascript/jquery.placeholder-label.js',
55
-			'javascript/ajaxCallback.js',
56
-			'javascript/js.cookie.js',
57
-		]
58
-	);
59
-	foreach (array_unique($jquery_plugins) as $script) {
60
-		if ($script = find_in_path(supprimer_timestamp($script))) {
61
-			$script = timestamp($script);
62
-			$x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n";
63
-		}
64
-	}
65
-
66
-	return $x . $texte;
47
+    $x = '';
48
+    $jquery_plugins = pipeline(
49
+        'jquery_plugins',
50
+        [
51
+            'javascript/jquery.js',
52
+            'javascript/jquery.form.js',
53
+            'javascript/jquery.autosave.js',
54
+            'javascript/jquery.placeholder-label.js',
55
+            'javascript/ajaxCallback.js',
56
+            'javascript/js.cookie.js',
57
+        ]
58
+    );
59
+    foreach (array_unique($jquery_plugins) as $script) {
60
+        if ($script = find_in_path(supprimer_timestamp($script))) {
61
+            $script = timestamp($script);
62
+            $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n";
63
+        }
64
+    }
65
+
66
+    return $x . $texte;
67 67
 }
68 68
 
69 69
 /**
@@ -80,33 +80,33 @@  discard block
 block discarded – undo
80 80
  * @return string         Contenu de la page envoyée au navigateur
81 81
  **/
82 82
 function f_tidy($texte) {
83
-	/**
84
-	 * Indentation à faire ?
85
-	 *
86
-	 * - true : actif.
87
-	 * - false par défaut.
88
-	 */
89
-
90
-	if (
91
-		$GLOBALS['xhtml']
92
-		&& $GLOBALS['html']
93
-		&& strlen($texte)
94
-		&& !headers_sent()
95
-	) {
96
-		# Compatibilite ascendante
97
-		if (!is_string($GLOBALS['xhtml'])) {
98
-			$GLOBALS['xhtml'] = 'tidy';
99
-		}
100
-
101
-		if (!$f = charger_fonction($GLOBALS['xhtml'], 'inc', true)) {
102
-			spip_log("tidy absent, l'indenteur SPIP le remplace");
103
-			$f = charger_fonction('sax', 'xml');
104
-		}
105
-
106
-		return $f($texte);
107
-	}
108
-
109
-	return $texte;
83
+    /**
84
+     * Indentation à faire ?
85
+     *
86
+     * - true : actif.
87
+     * - false par défaut.
88
+     */
89
+
90
+    if (
91
+        $GLOBALS['xhtml']
92
+        && $GLOBALS['html']
93
+        && strlen($texte)
94
+        && !headers_sent()
95
+    ) {
96
+        # Compatibilite ascendante
97
+        if (!is_string($GLOBALS['xhtml'])) {
98
+            $GLOBALS['xhtml'] = 'tidy';
99
+        }
100
+
101
+        if (!$f = charger_fonction($GLOBALS['xhtml'], 'inc', true)) {
102
+            spip_log("tidy absent, l'indenteur SPIP le remplace");
103
+            $f = charger_fonction('sax', 'xml');
104
+        }
105
+
106
+        return $f($texte);
107
+    }
108
+
109
+    return $texte;
110 110
 }
111 111
 
112 112
 
@@ -125,24 +125,24 @@  discard block
 block discarded – undo
125 125
  * @return string         Contenu de la page envoyée au navigateur
126 126
  **/
127 127
 function f_insert_head($texte) {
128
-	if (!$GLOBALS['html']) {
129
-		return $texte;
130
-	}
131
-	include_spip('public/admin'); // pour strripos
132
-
133
-	if (
134
-		!($pos = stripos($texte, '</head>'))
135
-		&& !($pos = stripos($texte, '<body>'))
136
-	) {
137
-		$pos = 0;
138
-	}
139
-
140
-	if (!str_contains(substr($texte, 0, $pos), '<!-- insert_head -->')) {
141
-		$insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n";
142
-		$texte = substr_replace($texte, $insert, $pos, 0);
143
-	}
144
-
145
-	return $texte;
128
+    if (!$GLOBALS['html']) {
129
+        return $texte;
130
+    }
131
+    include_spip('public/admin'); // pour strripos
132
+
133
+    if (
134
+        !($pos = stripos($texte, '</head>'))
135
+        && !($pos = stripos($texte, '<body>'))
136
+    ) {
137
+        $pos = 0;
138
+    }
139
+
140
+    if (!str_contains(substr($texte, 0, $pos), '<!-- insert_head -->')) {
141
+        $insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n";
142
+        $texte = substr_replace($texte, $insert, $pos, 0);
143
+    }
144
+
145
+    return $texte;
146 146
 }
147 147
 
148 148
 
@@ -158,34 +158,34 @@  discard block
 block discarded – undo
158 158
  * @return string         Contenu de la page envoyée au navigateur
159 159
  **/
160 160
 function f_admin($texte) {
161
-	if (defined('_VAR_PREVIEW') && _VAR_PREVIEW && $GLOBALS['html']) {
162
-		include_spip('inc/filtres'); // pour http_img_pack
163
-		$x = "<div class='spip-previsu' "
164
-			. http_style_background('preview-32.png', '', 32)
165
-			. '>'
166
-			. _T('previsualisation')
167
-			. '</div>';
168
-		if (!$pos = stripos($texte, '</body>')) {
169
-			$pos = strlen($texte);
170
-		}
171
-		$texte = substr_replace($texte, $x, $pos, 0);
172
-		// pas de preview en fenetre enfant
173
-		$x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes((string) $GLOBALS['meta']['adresse_site']) . "';}</script>";
174
-		if ((!$pos = stripos($texte, '<head')) || (!$pos = strpos($texte, '>', $pos))) {
175
-			$pos = -1;
176
-		}
177
-		$texte = substr_replace($texte, $x, $pos + 1, 0);
178
-	}
179
-
180
-	if (isset($GLOBALS['affiche_boutons_admin']) && $GLOBALS['affiche_boutons_admin']) {
181
-		include_spip('public/admin');
182
-		$texte = affiche_boutons_admin($texte);
183
-	}
184
-	if (_request('var_mode') == 'noajax') {
185
-		$texte = preg_replace(',(class=[\'"][^\'"]*)ajax([^\'"]*[\'"]),Uims', "\\1\\2", $texte);
186
-	}
187
-
188
-	return $texte;
161
+    if (defined('_VAR_PREVIEW') && _VAR_PREVIEW && $GLOBALS['html']) {
162
+        include_spip('inc/filtres'); // pour http_img_pack
163
+        $x = "<div class='spip-previsu' "
164
+            . http_style_background('preview-32.png', '', 32)
165
+            . '>'
166
+            . _T('previsualisation')
167
+            . '</div>';
168
+        if (!$pos = stripos($texte, '</body>')) {
169
+            $pos = strlen($texte);
170
+        }
171
+        $texte = substr_replace($texte, $x, $pos, 0);
172
+        // pas de preview en fenetre enfant
173
+        $x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes((string) $GLOBALS['meta']['adresse_site']) . "';}</script>";
174
+        if ((!$pos = stripos($texte, '<head')) || (!$pos = strpos($texte, '>', $pos))) {
175
+            $pos = -1;
176
+        }
177
+        $texte = substr_replace($texte, $x, $pos + 1, 0);
178
+    }
179
+
180
+    if (isset($GLOBALS['affiche_boutons_admin']) && $GLOBALS['affiche_boutons_admin']) {
181
+        include_spip('public/admin');
182
+        $texte = affiche_boutons_admin($texte);
183
+    }
184
+    if (_request('var_mode') == 'noajax') {
185
+        $texte = preg_replace(',(class=[\'"][^\'"]*)ajax([^\'"]*[\'"]),Uims', "\\1\\2", $texte);
186
+    }
187
+
188
+    return $texte;
189 189
 }
190 190
 
191 191
 /**
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
  * @return array $flux  Description et contenu de l'inclusion
204 204
  **/
205 205
 function f_recuperer_fond($flux) {
206
-	if (!test_espace_prive()) {
207
-		return $flux;
208
-	}
206
+    if (!test_espace_prive()) {
207
+        return $flux;
208
+    }
209 209
 
210
-	return f_afficher_blocs_ecrire($flux);
210
+    return f_afficher_blocs_ecrire($flux);
211 211
 }
212 212
 
213 213
 /**
@@ -221,30 +221,30 @@  discard block
 block discarded – undo
221 221
  * @return string         Contenu de la page envoyée au navigateur
222 222
  */
223 223
 function f_queue($texte) {
224
-	// eviter une inclusion si rien a faire
225
-	if (
226
-		_request('action') == 'cron'
227
-		|| queue_sleep_time_to_next_job() > 0
228
-		|| defined('_DEBUG_BLOCK_QUEUE')
229
-	) {
230
-		return $texte;
231
-	}
232
-
233
-	include_spip('inc/queue');
234
-	$code = queue_affichage_cron();
235
-
236
-	// si rien a afficher
237
-	// ou si on est pas dans une page html, on ne sait rien faire de mieux
238
-	if (!$code || !isset($GLOBALS['html']) || !$GLOBALS['html']) {
239
-		return $texte;
240
-	}
241
-
242
-	// inserer avant le </body> fermant si on peut, a la fin de la page sinon
243
-	if (($p = strpos($texte, '</body>')) !== false) {
244
-		$texte = substr($texte, 0, $p) . $code . substr($texte, $p);
245
-	} else {
246
-		$texte .= $code;
247
-	}
248
-
249
-	return $texte;
224
+    // eviter une inclusion si rien a faire
225
+    if (
226
+        _request('action') == 'cron'
227
+        || queue_sleep_time_to_next_job() > 0
228
+        || defined('_DEBUG_BLOCK_QUEUE')
229
+    ) {
230
+        return $texte;
231
+    }
232
+
233
+    include_spip('inc/queue');
234
+    $code = queue_affichage_cron();
235
+
236
+    // si rien a afficher
237
+    // ou si on est pas dans une page html, on ne sait rien faire de mieux
238
+    if (!$code || !isset($GLOBALS['html']) || !$GLOBALS['html']) {
239
+        return $texte;
240
+    }
241
+
242
+    // inserer avant le </body> fermant si on peut, a la fin de la page sinon
243
+    if (($p = strpos($texte, '</body>')) !== false) {
244
+        $texte = substr($texte, 0, $p) . $code . substr($texte, $p);
245
+    } else {
246
+        $texte .= $code;
247
+    }
248
+
249
+    return $texte;
250 250
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		}
64 64
 	}
65 65
 
66
-	return $x . $texte;
66
+	return $x.$texte;
67 67
 }
68 68
 
69 69
 /**
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	}
139 139
 
140 140
 	if (!str_contains(substr($texte, 0, $pos), '<!-- insert_head -->')) {
141
-		$insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n";
141
+		$insert = "\n".pipeline('insert_head', '<!-- f_insert_head -->')."\n";
142 142
 		$texte = substr_replace($texte, $insert, $pos, 0);
143 143
 	}
144 144
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		}
171 171
 		$texte = substr_replace($texte, $x, $pos, 0);
172 172
 		// pas de preview en fenetre enfant
173
-		$x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes((string) $GLOBALS['meta']['adresse_site']) . "';}</script>";
173
+		$x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='".addslashes((string) $GLOBALS['meta']['adresse_site'])."';}</script>";
174 174
 		if ((!$pos = stripos($texte, '<head')) || (!$pos = strpos($texte, '>', $pos))) {
175 175
 			$pos = -1;
176 176
 		}
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 
242 242
 	// inserer avant le </body> fermant si on peut, a la fin de la page sinon
243 243
 	if (($p = strpos($texte, '</body>')) !== false) {
244
-		$texte = substr($texte, 0, $p) . $code . substr($texte, $p);
244
+		$texte = substr($texte, 0, $p).$code.substr($texte, $p);
245 245
 	} else {
246 246
 		$texte .= $code;
247 247
 	}
Please login to merge, or discard this patch.
ecrire/inc/texte.php 2 patches
Indentation   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  **/
19 19
 
20 20
 if (!defined('_ECRIRE_INC_VERSION')) {
21
-	return;
21
+    return;
22 22
 }
23 23
 
24 24
 include_spip('inc/texte_mini');
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
  * @return array Tablea ('','')
36 36
  */
37 37
 function definir_raccourcis_alineas() {
38
-	return ['', ''];
38
+    return ['', ''];
39 39
 }
40 40
 
41 41
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
  * @return string
49 49
  */
50 50
 function traiter_tableau($bloc) {
51
-	return $bloc;
51
+    return $bloc;
52 52
 }
53 53
 
54 54
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
  * @return string
63 63
  */
64 64
 function traiter_listes($texte) {
65
-	return $texte;
65
+    return $texte;
66 66
 }
67 67
 
68 68
 /**
@@ -78,16 +78,16 @@  discard block
 block discarded – undo
78 78
  */
79 79
 function traiter_raccourcis($letexte) {
80 80
 
81
-	// Appeler les fonctions de pre_traitement
82
-	$letexte = pipeline('pre_propre', $letexte);
81
+    // Appeler les fonctions de pre_traitement
82
+    $letexte = pipeline('pre_propre', $letexte);
83 83
 
84
-	// APPELER ICI UN PIPELINE traiter_raccourcis ?
85
-	// $letexte = pipeline('traiter_raccourcis', $letexte);
84
+    // APPELER ICI UN PIPELINE traiter_raccourcis ?
85
+    // $letexte = pipeline('traiter_raccourcis', $letexte);
86 86
 
87
-	// Appeler les fonctions de post-traitement
88
-	$letexte = pipeline('post_propre', $letexte);
87
+    // Appeler les fonctions de post-traitement
88
+    $letexte = pipeline('post_propre', $letexte);
89 89
 
90
-	return $letexte;
90
+    return $letexte;
91 91
 }
92 92
 
93 93
 /*************************************************************************************************************************
@@ -103,22 +103,22 @@  discard block
 block discarded – undo
103 103
  * @return string
104 104
  */
105 105
 function echappe_js($t, $class = ' class = "echappe-js"') {
106
-	foreach (['script', 'iframe'] as $tag) {
107
-		if (
108
-			stripos($t, (string) "<$tag") !== false
109
-			&& preg_match_all(',<' . $tag . '.*?($|</' . $tag . '.),isS', $t, $r, PREG_SET_ORDER)
110
-		) {
111
-			foreach ($r as $regs) {
112
-				$t = str_replace(
113
-					$regs[0],
114
-					"<code$class>" . nl2br(spip_htmlspecialchars($regs[0])) . '</code>',
115
-					$t
116
-				);
117
-			}
118
-		}
119
-	}
120
-
121
-	return $t;
106
+    foreach (['script', 'iframe'] as $tag) {
107
+        if (
108
+            stripos($t, (string) "<$tag") !== false
109
+            && preg_match_all(',<' . $tag . '.*?($|</' . $tag . '.),isS', $t, $r, PREG_SET_ORDER)
110
+        ) {
111
+            foreach ($r as $regs) {
112
+                $t = str_replace(
113
+                    $regs[0],
114
+                    "<code$class>" . nl2br(spip_htmlspecialchars($regs[0])) . '</code>',
115
+                    $t
116
+                );
117
+            }
118
+        }
119
+    }
120
+
121
+    return $t;
122 122
 }
123 123
 
124 124
 
@@ -147,55 +147,55 @@  discard block
 block discarded – undo
147 147
  *     Code protégé
148 148
  **/
149 149
 function interdire_scripts($arg, $mode_filtre = null) {
150
-	// on memorise le resultat sur les arguments non triviaux
151
-	static $dejavu = [];
152
-
153
-	// Attention, si ce n'est pas une chaine, laisser intact
154
-	if (!$arg || !is_string($arg) || !strstr($arg, '<')) {
155
-		return $arg;
156
-	}
157
-
158
-	if (is_null($mode_filtre) || !in_array($mode_filtre, [-1, 0, 1])) {
159
-		$mode_filtre = $GLOBALS['filtrer_javascript'];
160
-	}
161
-
162
-	if (isset($dejavu[$mode_filtre][$arg])) {
163
-		return $dejavu[$mode_filtre][$arg];
164
-	}
165
-
166
-	// echapper les tags asp/php
167
-	$t = str_replace('<' . '%', '&lt;%', $arg);
168
-
169
-	// echapper le php
170
-	$t = str_replace('<' . '?', '&lt;?', $t);
171
-
172
-	// echapper le < script language=php >
173
-	$t = preg_replace(',<(script\b[^>]+\blanguage\b[^\w>]+php\b),UimsS', '&lt;\1', $t);
174
-
175
-	// Pour le js, trois modes : parano (-1), prive (0), ok (1)
176
-	switch ($mode_filtre) {
177
-		case 0:
178
-			if (!_DIR_RESTREINT) {
179
-				$t = echappe_js($t);
180
-			}
181
-			break;
182
-		case -1:
183
-			$t = echappe_js($t);
184
-			break;
185
-	}
186
-
187
-	// pas de <base href /> svp !
188
-	$t = preg_replace(',<(base\b),iS', '&lt;\1', $t);
189
-
190
-	// Reinserer les echappements des modeles
191
-	if (defined('_PROTEGE_JS_MODELES')) {
192
-		$t = echappe_retour($t, 'javascript' . _PROTEGE_JS_MODELES);
193
-	}
194
-	if (defined('_PROTEGE_PHP_MODELES')) {
195
-		$t = echappe_retour($t, 'php' . _PROTEGE_PHP_MODELES);
196
-	}
197
-
198
-	return $dejavu[$mode_filtre][$arg] = $t;
150
+    // on memorise le resultat sur les arguments non triviaux
151
+    static $dejavu = [];
152
+
153
+    // Attention, si ce n'est pas une chaine, laisser intact
154
+    if (!$arg || !is_string($arg) || !strstr($arg, '<')) {
155
+        return $arg;
156
+    }
157
+
158
+    if (is_null($mode_filtre) || !in_array($mode_filtre, [-1, 0, 1])) {
159
+        $mode_filtre = $GLOBALS['filtrer_javascript'];
160
+    }
161
+
162
+    if (isset($dejavu[$mode_filtre][$arg])) {
163
+        return $dejavu[$mode_filtre][$arg];
164
+    }
165
+
166
+    // echapper les tags asp/php
167
+    $t = str_replace('<' . '%', '&lt;%', $arg);
168
+
169
+    // echapper le php
170
+    $t = str_replace('<' . '?', '&lt;?', $t);
171
+
172
+    // echapper le < script language=php >
173
+    $t = preg_replace(',<(script\b[^>]+\blanguage\b[^\w>]+php\b),UimsS', '&lt;\1', $t);
174
+
175
+    // Pour le js, trois modes : parano (-1), prive (0), ok (1)
176
+    switch ($mode_filtre) {
177
+        case 0:
178
+            if (!_DIR_RESTREINT) {
179
+                $t = echappe_js($t);
180
+            }
181
+            break;
182
+        case -1:
183
+            $t = echappe_js($t);
184
+            break;
185
+    }
186
+
187
+    // pas de <base href /> svp !
188
+    $t = preg_replace(',<(base\b),iS', '&lt;\1', $t);
189
+
190
+    // Reinserer les echappements des modeles
191
+    if (defined('_PROTEGE_JS_MODELES')) {
192
+        $t = echappe_retour($t, 'javascript' . _PROTEGE_JS_MODELES);
193
+    }
194
+    if (defined('_PROTEGE_PHP_MODELES')) {
195
+        $t = echappe_retour($t, 'php' . _PROTEGE_PHP_MODELES);
196
+    }
197
+
198
+    return $dejavu[$mode_filtre][$arg] = $t;
199 199
 }
200 200
 
201 201
 
@@ -224,66 +224,66 @@  discard block
 block discarded – undo
224 224
  *     texte transformé
225 225
  **/
226 226
 function typo($letexte, $echapper = true, $connect = null, $env = []) {
227
-	// Plus vite !
228
-	if (!$letexte) {
229
-		return $letexte;
230
-	}
231
-
232
-	// les appels directs a cette fonction depuis le php de l'espace
233
-	// prive etant historiquement ecrit sans argment $connect
234
-	// on utilise la presence de celui-ci pour distinguer les cas
235
-	// ou il faut passer interdire_script explicitement
236
-	// les appels dans les squelettes (de l'espace prive) fournissant un $connect
237
-	// ne seront pas perturbes
238
-	$interdire_script = false;
239
-	if (is_null($connect)) {
240
-		$connect = '';
241
-		$interdire_script = true;
242
-		$env['espace_prive'] = test_espace_prive();
243
-	}
244
-
245
-	// Echapper les codes <html> etc
246
-	if ($echapper) {
247
-		$letexte = CollecteurHtmlTag::proteger_balisesHtml($letexte, 'TYPO');
248
-	}
249
-
250
-	//
251
-	// Installer les modeles, notamment images et documents ;
252
-	//
253
-	// NOTE : propre() ne passe pas par ici mais directement par corriger_typo
254
-	// cf. inc/lien
255
-
256
-	$letexte = traiter_modeles($mem = $letexte, false, $echapper ? 'TYPO' : '', $connect ?? '', null, $env);
257
-	if ($letexte != $mem) {
258
-		$echapper = true;
259
-	}
260
-	unset($mem);
261
-
262
-	$letexte = corriger_typo($letexte);
263
-	$letexte = echapper_faux_tags($letexte);
264
-
265
-	// reintegrer les echappements
266
-	if ($echapper) {
267
-		$letexte = CollecteurHtmlTag::retablir_depuisHtmlBase64($letexte, 'TYPO');
268
-	}
269
-
270
-	// Dans les appels directs hors squelette, securiser ici aussi
271
-	if ($interdire_script) {
272
-		$letexte = interdire_scripts($letexte);
273
-	}
274
-
275
-	// Dans l'espace prive on se mefie de tout contenu dangereux
276
-	// https://core.spip.net/issues/3371
277
-	// et aussi dans l'espace public si la globale filtrer_javascript = -1
278
-	// https://core.spip.net/issues/4166
279
-	if (
280
-		$GLOBALS['filtrer_javascript'] == -1
281
-		|| isset($env['espace_prive']) && $env['espace_prive'] && $GLOBALS['filtrer_javascript'] <= 0
282
-	) {
283
-		$letexte = echapper_html_suspect($letexte, [], $connect, $env);
284
-	}
285
-
286
-	return $letexte;
227
+    // Plus vite !
228
+    if (!$letexte) {
229
+        return $letexte;
230
+    }
231
+
232
+    // les appels directs a cette fonction depuis le php de l'espace
233
+    // prive etant historiquement ecrit sans argment $connect
234
+    // on utilise la presence de celui-ci pour distinguer les cas
235
+    // ou il faut passer interdire_script explicitement
236
+    // les appels dans les squelettes (de l'espace prive) fournissant un $connect
237
+    // ne seront pas perturbes
238
+    $interdire_script = false;
239
+    if (is_null($connect)) {
240
+        $connect = '';
241
+        $interdire_script = true;
242
+        $env['espace_prive'] = test_espace_prive();
243
+    }
244
+
245
+    // Echapper les codes <html> etc
246
+    if ($echapper) {
247
+        $letexte = CollecteurHtmlTag::proteger_balisesHtml($letexte, 'TYPO');
248
+    }
249
+
250
+    //
251
+    // Installer les modeles, notamment images et documents ;
252
+    //
253
+    // NOTE : propre() ne passe pas par ici mais directement par corriger_typo
254
+    // cf. inc/lien
255
+
256
+    $letexte = traiter_modeles($mem = $letexte, false, $echapper ? 'TYPO' : '', $connect ?? '', null, $env);
257
+    if ($letexte != $mem) {
258
+        $echapper = true;
259
+    }
260
+    unset($mem);
261
+
262
+    $letexte = corriger_typo($letexte);
263
+    $letexte = echapper_faux_tags($letexte);
264
+
265
+    // reintegrer les echappements
266
+    if ($echapper) {
267
+        $letexte = CollecteurHtmlTag::retablir_depuisHtmlBase64($letexte, 'TYPO');
268
+    }
269
+
270
+    // Dans les appels directs hors squelette, securiser ici aussi
271
+    if ($interdire_script) {
272
+        $letexte = interdire_scripts($letexte);
273
+    }
274
+
275
+    // Dans l'espace prive on se mefie de tout contenu dangereux
276
+    // https://core.spip.net/issues/3371
277
+    // et aussi dans l'espace public si la globale filtrer_javascript = -1
278
+    // https://core.spip.net/issues/4166
279
+    if (
280
+        $GLOBALS['filtrer_javascript'] == -1
281
+        || isset($env['espace_prive']) && $env['espace_prive'] && $GLOBALS['filtrer_javascript'] <= 0
282
+    ) {
283
+        $letexte = echapper_html_suspect($letexte, [], $connect, $env);
284
+    }
285
+
286
+    return $letexte;
287 287
 }
288 288
 
289 289
 // Correcteur typographique
@@ -308,57 +308,57 @@  discard block
 block discarded – undo
308 308
  */
309 309
 function corriger_typo($letexte, $lang = '') {
310 310
 
311
-	// Plus vite !
312
-	if (!$letexte) {
313
-		return $letexte;
314
-	}
315
-
316
-	$letexte = pipeline('pre_typo', $letexte);
317
-
318
-	// Caracteres de controle "illegaux"
319
-	$letexte = corriger_caracteres($letexte);
320
-
321
-	// Proteger les caracteres typographiques a l'interieur des tags html
322
-	if (preg_match_all(_TYPO_BALISE, $letexte, $regs, PREG_SET_ORDER)) {
323
-		foreach ($regs as $reg) {
324
-			$insert = $reg[0];
325
-			// hack: on transforme les caracteres a proteger en les remplacant
326
-			// par des caracteres "illegaux". (cf corriger_caracteres())
327
-			$insert = strtr($insert, _TYPO_PROTEGER, _TYPO_PROTECTEUR);
328
-			$letexte = str_replace($reg[0], $insert, $letexte);
329
-		}
330
-	}
331
-
332
-	// trouver les blocs idiomes et les traiter à part
333
-	$letexte = extraire_idiome($ei = $letexte, $lang, ['echappe_span' => true]);
334
-	$ei = ($ei !== $letexte);
335
-
336
-	// trouver les blocs multi et les traiter a part
337
-	$letexte = extraire_multi($em = $letexte, $lang, ['echappe_span' => true]);
338
-	$em = ($em !== $letexte);
339
-
340
-	// Charger & appliquer les fonctions de typographie
341
-	$typographie = charger_fonction(lang_typo($lang), 'typographie');
342
-	$letexte = $typographie($letexte);
343
-
344
-	// Les citations en une autre langue, s'il y a lieu
345
-	if ($em) {
346
-		$letexte = echappe_retour($letexte, 'multi');
347
-	}
348
-	if ($ei) {
349
-		$letexte = echappe_retour($letexte, 'idiome');
350
-	}
351
-
352
-	// Retablir les caracteres proteges
353
-	$letexte = strtr($letexte, _TYPO_PROTECTEUR, _TYPO_PROTEGER);
354
-
355
-	// pipeline
356
-	$letexte = pipeline('post_typo', $letexte);
357
-
358
-	# un message pour abs_url - on est passe en mode texte
359
-	$GLOBALS['mode_abs_url'] = 'texte';
360
-
361
-	return $letexte;
311
+    // Plus vite !
312
+    if (!$letexte) {
313
+        return $letexte;
314
+    }
315
+
316
+    $letexte = pipeline('pre_typo', $letexte);
317
+
318
+    // Caracteres de controle "illegaux"
319
+    $letexte = corriger_caracteres($letexte);
320
+
321
+    // Proteger les caracteres typographiques a l'interieur des tags html
322
+    if (preg_match_all(_TYPO_BALISE, $letexte, $regs, PREG_SET_ORDER)) {
323
+        foreach ($regs as $reg) {
324
+            $insert = $reg[0];
325
+            // hack: on transforme les caracteres a proteger en les remplacant
326
+            // par des caracteres "illegaux". (cf corriger_caracteres())
327
+            $insert = strtr($insert, _TYPO_PROTEGER, _TYPO_PROTECTEUR);
328
+            $letexte = str_replace($reg[0], $insert, $letexte);
329
+        }
330
+    }
331
+
332
+    // trouver les blocs idiomes et les traiter à part
333
+    $letexte = extraire_idiome($ei = $letexte, $lang, ['echappe_span' => true]);
334
+    $ei = ($ei !== $letexte);
335
+
336
+    // trouver les blocs multi et les traiter a part
337
+    $letexte = extraire_multi($em = $letexte, $lang, ['echappe_span' => true]);
338
+    $em = ($em !== $letexte);
339
+
340
+    // Charger & appliquer les fonctions de typographie
341
+    $typographie = charger_fonction(lang_typo($lang), 'typographie');
342
+    $letexte = $typographie($letexte);
343
+
344
+    // Les citations en une autre langue, s'il y a lieu
345
+    if ($em) {
346
+        $letexte = echappe_retour($letexte, 'multi');
347
+    }
348
+    if ($ei) {
349
+        $letexte = echappe_retour($letexte, 'idiome');
350
+    }
351
+
352
+    // Retablir les caracteres proteges
353
+    $letexte = strtr($letexte, _TYPO_PROTECTEUR, _TYPO_PROTEGER);
354
+
355
+    // pipeline
356
+    $letexte = pipeline('post_typo', $letexte);
357
+
358
+    # un message pour abs_url - on est passe en mode texte
359
+    $GLOBALS['mode_abs_url'] = 'texte';
360
+
361
+    return $letexte;
362 362
 }
363 363
 
364 364
 
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
  * @return string
375 375
  */
376 376
 function paragrapher($letexte, $forcer = true) {
377
-	return $letexte;
377
+    return $letexte;
378 378
 }
379 379
 
380 380
 /**
@@ -386,11 +386,11 @@  discard block
 block discarded – undo
386 386
  * @return string texte
387 387
  **/
388 388
 function traiter_retours_chariots($letexte) {
389
-	$letexte = preg_replace(",\r\n?,S", "\n", $letexte);
390
-	$letexte = preg_replace(',<p[>[:space:]],iS', "\n\n\\0", $letexte);
391
-	$letexte = preg_replace(',</p[>[:space:]],iS', "\\0\n\n", $letexte);
389
+    $letexte = preg_replace(",\r\n?,S", "\n", $letexte);
390
+    $letexte = preg_replace(',<p[>[:space:]],iS', "\n\n\\0", $letexte);
391
+    $letexte = preg_replace(',</p[>[:space:]],iS', "\\0\n\n", $letexte);
392 392
 
393
-	return $letexte;
393
+    return $letexte;
394 394
 }
395 395
 
396 396
 
@@ -416,41 +416,41 @@  discard block
 block discarded – undo
416 416
  *     texte transformé
417 417
  **/
418 418
 function propre($t, $connect = null, $env = []) {
419
-	// les appels directs a cette fonction depuis le php de l'espace
420
-	// prive etant historiquement ecrits sans argment $connect
421
-	// on utilise la presence de celui-ci pour distinguer les cas
422
-	// ou il faut passer interdire_script explicitement
423
-	// les appels dans les squelettes (de l'espace prive) fournissant un $connect
424
-	// ne seront pas perturbes
425
-	// FIXME: Trouver une solution pour avoir un type (string) unique sur $connect.
426
-	$interdire_script = false;
427
-	if (is_null($connect)) {
428
-		$connect = '';
429
-		$interdire_script = true;
430
-		$env['espace_prive'] = true;
431
-	}
432
-
433
-	if (!$t) {
434
-		return strval($t);
435
-	}
436
-
437
-	// Dans l'espace prive on se mefie de tout contenu dangereux
438
-	// avant echappement des balises <html>
439
-	// https://core.spip.net/issues/3371
440
-	// et aussi dans l'espace public si la globale filtrer_javascript = -1
441
-	// https://core.spip.net/issues/4166
442
-	if (
443
-		$interdire_script
444
-		|| $GLOBALS['filtrer_javascript'] == -1
445
-		|| !empty($env['espace_prive']) && $GLOBALS['filtrer_javascript'] <= 0
446
-		|| !empty($env['wysiwyg']) && $env['wysiwyg'] && $GLOBALS['filtrer_javascript'] <= 0
447
-	) {
448
-		$t = echapper_html_suspect($t, ['strict' => false], $connect, $env);
449
-	}
450
-	$t = echappe_html($t);
451
-	$t = expanser_liens($t, $connect ?? '', $env);
452
-	$t = traiter_raccourcis($t);
453
-	$t = echappe_retour_modeles($t, $interdire_script);
454
-
455
-	return $t;
419
+    // les appels directs a cette fonction depuis le php de l'espace
420
+    // prive etant historiquement ecrits sans argment $connect
421
+    // on utilise la presence de celui-ci pour distinguer les cas
422
+    // ou il faut passer interdire_script explicitement
423
+    // les appels dans les squelettes (de l'espace prive) fournissant un $connect
424
+    // ne seront pas perturbes
425
+    // FIXME: Trouver une solution pour avoir un type (string) unique sur $connect.
426
+    $interdire_script = false;
427
+    if (is_null($connect)) {
428
+        $connect = '';
429
+        $interdire_script = true;
430
+        $env['espace_prive'] = true;
431
+    }
432
+
433
+    if (!$t) {
434
+        return strval($t);
435
+    }
436
+
437
+    // Dans l'espace prive on se mefie de tout contenu dangereux
438
+    // avant echappement des balises <html>
439
+    // https://core.spip.net/issues/3371
440
+    // et aussi dans l'espace public si la globale filtrer_javascript = -1
441
+    // https://core.spip.net/issues/4166
442
+    if (
443
+        $interdire_script
444
+        || $GLOBALS['filtrer_javascript'] == -1
445
+        || !empty($env['espace_prive']) && $GLOBALS['filtrer_javascript'] <= 0
446
+        || !empty($env['wysiwyg']) && $env['wysiwyg'] && $GLOBALS['filtrer_javascript'] <= 0
447
+    ) {
448
+        $t = echapper_html_suspect($t, ['strict' => false], $connect, $env);
449
+    }
450
+    $t = echappe_html($t);
451
+    $t = expanser_liens($t, $connect ?? '', $env);
452
+    $t = traiter_raccourcis($t);
453
+    $t = echappe_retour_modeles($t, $interdire_script);
454
+
455
+    return $t;
456 456
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 	foreach (['script', 'iframe'] as $tag) {
107 107
 		if (
108 108
 			stripos($t, (string) "<$tag") !== false
109
-			&& preg_match_all(',<' . $tag . '.*?($|</' . $tag . '.),isS', $t, $r, PREG_SET_ORDER)
109
+			&& preg_match_all(',<'.$tag.'.*?($|</'.$tag.'.),isS', $t, $r, PREG_SET_ORDER)
110 110
 		) {
111 111
 			foreach ($r as $regs) {
112 112
 				$t = str_replace(
113 113
 					$regs[0],
114
-					"<code$class>" . nl2br(spip_htmlspecialchars($regs[0])) . '</code>',
114
+					"<code$class>".nl2br(spip_htmlspecialchars($regs[0])).'</code>',
115 115
 					$t
116 116
 				);
117 117
 			}
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
 	}
165 165
 
166 166
 	// echapper les tags asp/php
167
-	$t = str_replace('<' . '%', '&lt;%', $arg);
167
+	$t = str_replace('<'.'%', '&lt;%', $arg);
168 168
 
169 169
 	// echapper le php
170
-	$t = str_replace('<' . '?', '&lt;?', $t);
170
+	$t = str_replace('<'.'?', '&lt;?', $t);
171 171
 
172 172
 	// echapper le < script language=php >
173 173
 	$t = preg_replace(',<(script\b[^>]+\blanguage\b[^\w>]+php\b),UimsS', '&lt;\1', $t);
@@ -189,10 +189,10 @@  discard block
 block discarded – undo
189 189
 
190 190
 	// Reinserer les echappements des modeles
191 191
 	if (defined('_PROTEGE_JS_MODELES')) {
192
-		$t = echappe_retour($t, 'javascript' . _PROTEGE_JS_MODELES);
192
+		$t = echappe_retour($t, 'javascript'._PROTEGE_JS_MODELES);
193 193
 	}
194 194
 	if (defined('_PROTEGE_PHP_MODELES')) {
195
-		$t = echappe_retour($t, 'php' . _PROTEGE_PHP_MODELES);
195
+		$t = echappe_retour($t, 'php'._PROTEGE_PHP_MODELES);
196 196
 	}
197 197
 
198 198
 	return $dejavu[$mode_filtre][$arg] = $t;
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 define('_TYPO_PROTEGER', "!':;?~%-");
291 291
 define('_TYPO_PROTECTEUR', "\x1\x2\x3\x4\x5\x6\x7\x8");
292 292
 
293
-define('_TYPO_BALISE', ',</?[a-z!][^<>]*[' . preg_quote(_TYPO_PROTEGER) . '][^<>]*>,imsS');
293
+define('_TYPO_BALISE', ',</?[a-z!][^<>]*['.preg_quote(_TYPO_PROTEGER).'][^<>]*>,imsS');
294 294
 
295 295
 /**
296 296
  * Corrige la typographie
Please login to merge, or discard this patch.
ecrire/inc/cookie.php 2 patches
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 
@@ -50,66 +50,66 @@  discard block
 block discarded – undo
50 50
  *     true si le cookie a été posé, false sinon.
51 51
  **/
52 52
 function spip_setcookie(
53
-	string $name = '',
54
-	string $value = '',
55
-	int|array $expires_or_options = 0,
56
-	string $path = '',
57
-	string $domain = '',
58
-	bool $secure = false,
59
-	bool $httponly = false
53
+    string $name = '',
54
+    string $value = '',
55
+    int|array $expires_or_options = 0,
56
+    string $path = '',
57
+    string $domain = '',
58
+    bool $secure = false,
59
+    bool $httponly = false
60 60
 ) {
61
-	if (!is_array($expires_or_options)) {
62
-		# anciens paramètres : spip_setcookie($name = '', $value = '', $expire = 0, $path = 'AUTO', $domain = '', $secure = '')
63
-		$options = [
64
-			'expires' => (int) $expires_or_options,
65
-			'path' => $path,
66
-			'domain' => $domain,
67
-			'secure' => $secure,
68
-			'httponly' => $httponly,
69
-		];
70
-	} else {
71
-		$options = $expires_or_options;
72
-	}
73
-
74
-	// expires
75
-	$options['expires'] ??= 0;
76
-	if (!isset($options['path']) || $options['path'] === 'AUTO') {
77
-		$options['path'] = defined('_COOKIE_PATH') ? constant('_COOKIE_PATH') : preg_replace(',^\w+://[^/]*,', '', url_de_base());
78
-	}
79
-	if (empty($options['domain']) && defined('_COOKIE_DOMAIN') && constant('_COOKIE_DOMAIN')) {
80
-		$options['domain'] = constant('_COOKIE_DOMAIN');
81
-	}
82
-	$options['secure'] ??= false;
83
-	$options['secure'] = ($options['secure'] ?: ($_SERVER['HTTPS'] ?? false));
84
-	if (defined('_COOKIE_SECURE') && constant('_COOKIE_SECURE')) {
85
-		trigger_deprecation('spip', '5.0', 'Using "%s" constant is deprecated, use option "%s" when call "%s" instead (automatic in HTTPS).', '_COOKIE_SECURE', 'secure: true', __FUNCTION__);
86
-		$options['secure'] = true;
87
-	}
88
-	$options['httponly'] ??= false;
89
-	$options['samesite'] = ($options['samesite'] ?? 'Lax') ?: 'Lax';
90
-
91
-	/** @deprecated 5.0 Use option `'httponly' => true` */
92
-	if (defined('_COOKIE_SECURE_LIST')) {
93
-		trigger_deprecation('spip', '5.0', 'Using "%s" constant is deprecated, use option "%s" when call "%s" instead.', '_COOKIE_SECURE_LIST', 'httponly: true', __FUNCTION__);
94
-		if (
95
-			is_array(constant('_COOKIE_SECURE_LIST'))
96
-			&& in_array($name, constant('_COOKIE_SECURE_LIST'))
97
-		) {
98
-			$options['httponly'] = true;
99
-		}
100
-	}
101
-
102
-	// in fine renommer le prefixe si besoin
103
-	if (str_starts_with($name, 'spip_')) {
104
-		$name = $GLOBALS['cookie_prefix'] . '_' . substr($name, 5);
105
-	}
106
-
107
-	#spip_log("cookie('$name', '$value', " . json_encode($options, true) . ")", "cookies");
108
-	$a = @setcookie($name, $value, $options);
109
-
110
-	spip_cookie_envoye(true);
111
-
112
-	return $a;
61
+    if (!is_array($expires_or_options)) {
62
+        # anciens paramètres : spip_setcookie($name = '', $value = '', $expire = 0, $path = 'AUTO', $domain = '', $secure = '')
63
+        $options = [
64
+            'expires' => (int) $expires_or_options,
65
+            'path' => $path,
66
+            'domain' => $domain,
67
+            'secure' => $secure,
68
+            'httponly' => $httponly,
69
+        ];
70
+    } else {
71
+        $options = $expires_or_options;
72
+    }
73
+
74
+    // expires
75
+    $options['expires'] ??= 0;
76
+    if (!isset($options['path']) || $options['path'] === 'AUTO') {
77
+        $options['path'] = defined('_COOKIE_PATH') ? constant('_COOKIE_PATH') : preg_replace(',^\w+://[^/]*,', '', url_de_base());
78
+    }
79
+    if (empty($options['domain']) && defined('_COOKIE_DOMAIN') && constant('_COOKIE_DOMAIN')) {
80
+        $options['domain'] = constant('_COOKIE_DOMAIN');
81
+    }
82
+    $options['secure'] ??= false;
83
+    $options['secure'] = ($options['secure'] ?: ($_SERVER['HTTPS'] ?? false));
84
+    if (defined('_COOKIE_SECURE') && constant('_COOKIE_SECURE')) {
85
+        trigger_deprecation('spip', '5.0', 'Using "%s" constant is deprecated, use option "%s" when call "%s" instead (automatic in HTTPS).', '_COOKIE_SECURE', 'secure: true', __FUNCTION__);
86
+        $options['secure'] = true;
87
+    }
88
+    $options['httponly'] ??= false;
89
+    $options['samesite'] = ($options['samesite'] ?? 'Lax') ?: 'Lax';
90
+
91
+    /** @deprecated 5.0 Use option `'httponly' => true` */
92
+    if (defined('_COOKIE_SECURE_LIST')) {
93
+        trigger_deprecation('spip', '5.0', 'Using "%s" constant is deprecated, use option "%s" when call "%s" instead.', '_COOKIE_SECURE_LIST', 'httponly: true', __FUNCTION__);
94
+        if (
95
+            is_array(constant('_COOKIE_SECURE_LIST'))
96
+            && in_array($name, constant('_COOKIE_SECURE_LIST'))
97
+        ) {
98
+            $options['httponly'] = true;
99
+        }
100
+    }
101
+
102
+    // in fine renommer le prefixe si besoin
103
+    if (str_starts_with($name, 'spip_')) {
104
+        $name = $GLOBALS['cookie_prefix'] . '_' . substr($name, 5);
105
+    }
106
+
107
+    #spip_log("cookie('$name', '$value', " . json_encode($options, true) . ")", "cookies");
108
+    $a = @setcookie($name, $value, $options);
109
+
110
+    spip_cookie_envoye(true);
111
+
112
+    return $a;
113 113
 }
114 114
 
115 115
 /**
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
  * @return bool
126 126
  **/
127 127
 function spip_cookie_envoye($set = '') {
128
-	static $envoye = false;
129
-	if ($set) {
130
-		$envoye = true;
131
-	}
128
+    static $envoye = false;
129
+    if ($set) {
130
+        $envoye = true;
131
+    }
132 132
 
133
-	return $envoye;
133
+    return $envoye;
134 134
 }
135 135
 
136 136
 /**
@@ -149,21 +149,21 @@  discard block
 block discarded – undo
149 149
  *     Préfixe des cookies de SPIP
150 150
  **/
151 151
 function recuperer_cookies_spip($cookie_prefix) {
152
-	$prefix_long = strlen($cookie_prefix);
153
-
154
-	foreach (array_keys($_COOKIE) as $name) {
155
-		if (str_starts_with($name, 'spip_') && substr($name, 0, $prefix_long) != $cookie_prefix) {
156
-			unset($_COOKIE[$name]);
157
-			unset($GLOBALS[$name]);
158
-		}
159
-	}
160
-	foreach ($_COOKIE as $name => $value) {
161
-		if (substr($name, 0, $prefix_long) == $cookie_prefix) {
162
-			$spipname = preg_replace('/^' . $cookie_prefix . '_/', 'spip_', $name);
163
-			$_COOKIE[$spipname] = $value;
164
-			$GLOBALS[$spipname] = $value;
165
-		}
166
-	}
152
+    $prefix_long = strlen($cookie_prefix);
153
+
154
+    foreach (array_keys($_COOKIE) as $name) {
155
+        if (str_starts_with($name, 'spip_') && substr($name, 0, $prefix_long) != $cookie_prefix) {
156
+            unset($_COOKIE[$name]);
157
+            unset($GLOBALS[$name]);
158
+        }
159
+    }
160
+    foreach ($_COOKIE as $name => $value) {
161
+        if (substr($name, 0, $prefix_long) == $cookie_prefix) {
162
+            $spipname = preg_replace('/^' . $cookie_prefix . '_/', 'spip_', $name);
163
+            $_COOKIE[$spipname] = $value;
164
+            $GLOBALS[$spipname] = $value;
165
+        }
166
+    }
167 167
 }
168 168
 
169 169
 
@@ -182,18 +182,18 @@  discard block
 block discarded – undo
182 182
  *
183 183
  **/
184 184
 function exec_test_ajax_dist() {
185
-	switch (_request('js')) {
186
-		// on est appele par <noscript>
187
-		case -1:
188
-			spip_setcookie('spip_accepte_ajax', -1);
189
-			include_spip('inc/headers');
190
-			redirige_par_entete(chemin_image('erreur-xx.svg'));
191
-			break;
192
-
193
-		// ou par ajax
194
-		case 1:
195
-		default:
196
-			spip_setcookie('spip_accepte_ajax', 1);
197
-			break;
198
-	}
185
+    switch (_request('js')) {
186
+        // on est appele par <noscript>
187
+        case -1:
188
+            spip_setcookie('spip_accepte_ajax', -1);
189
+            include_spip('inc/headers');
190
+            redirige_par_entete(chemin_image('erreur-xx.svg'));
191
+            break;
192
+
193
+        // ou par ajax
194
+        case 1:
195
+        default:
196
+            spip_setcookie('spip_accepte_ajax', 1);
197
+            break;
198
+    }
199 199
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 function spip_setcookie(
53 53
 	string $name = '',
54 54
 	string $value = '',
55
-	int|array $expires_or_options = 0,
55
+	int | array $expires_or_options = 0,
56 56
 	string $path = '',
57 57
 	string $domain = '',
58 58
 	bool $secure = false,
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 
102 102
 	// in fine renommer le prefixe si besoin
103 103
 	if (str_starts_with($name, 'spip_')) {
104
-		$name = $GLOBALS['cookie_prefix'] . '_' . substr($name, 5);
104
+		$name = $GLOBALS['cookie_prefix'].'_'.substr($name, 5);
105 105
 	}
106 106
 
107 107
 	#spip_log("cookie('$name', '$value', " . json_encode($options, true) . ")", "cookies");
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	}
160 160
 	foreach ($_COOKIE as $name => $value) {
161 161
 		if (substr($name, 0, $prefix_long) == $cookie_prefix) {
162
-			$spipname = preg_replace('/^' . $cookie_prefix . '_/', 'spip_', $name);
162
+			$spipname = preg_replace('/^'.$cookie_prefix.'_/', 'spip_', $name);
163 163
 			$_COOKIE[$spipname] = $value;
164 164
 			$GLOBALS[$spipname] = $value;
165 165
 		}
Please login to merge, or discard this patch.
ecrire/inc/filtres_ecrire.php 3 patches
Indentation   +372 added lines, -372 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * @package SPIP\Core\Filtres
16 16
  */
17 17
 if (!defined('_ECRIRE_INC_VERSION')) {
18
-	return;
18
+    return;
19 19
 }
20 20
 
21 21
 include_spip('inc/filtres_boites');
@@ -40,25 +40,25 @@  discard block
 block discarded – undo
40 40
  */
41 41
 function parametres_css_prive() {
42 42
 
43
-	$args = [];
44
-	$args['v'] = $GLOBALS['spip_version_code'];
45
-	$args['p'] = substr(md5((string) $GLOBALS['meta']['plugin']), 0, 4);
46
-	$args['themes'] = implode(',', lister_themes_prives());
47
-	$args['ltr'] = $GLOBALS['spip_lang_left'];
48
-	// un md5 des menus : si un menu change il faut maj la css
49
-	$args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : '');
43
+    $args = [];
44
+    $args['v'] = $GLOBALS['spip_version_code'];
45
+    $args['p'] = substr(md5((string) $GLOBALS['meta']['plugin']), 0, 4);
46
+    $args['themes'] = implode(',', lister_themes_prives());
47
+    $args['ltr'] = $GLOBALS['spip_lang_left'];
48
+    // un md5 des menus : si un menu change il faut maj la css
49
+    $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : '');
50 50
 
51
-	$c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2;
51
+    $c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2;
52 52
 
53
-	$couleurs = charger_fonction('couleurs', 'inc');
54
-	parse_str((string) $couleurs($c), $c);
55
-	$args = array_merge($args, $c);
53
+    $couleurs = charger_fonction('couleurs', 'inc');
54
+    parse_str((string) $couleurs($c), $c);
55
+    $args = array_merge($args, $c);
56 56
 
57
-	if (_request('var_mode') == 'recalcul' || defined('_VAR_MODE') && _VAR_MODE == 'recalcul') {
58
-		$args['var_mode'] = 'recalcul';
59
-	}
57
+    if (_request('var_mode') == 'recalcul' || defined('_VAR_MODE') && _VAR_MODE == 'recalcul') {
58
+        $args['var_mode'] = 'recalcul';
59
+    }
60 60
 
61
-	return http_build_query($args);
61
+    return http_build_query($args);
62 62
 }
63 63
 
64 64
 
@@ -81,95 +81,95 @@  discard block
 block discarded – undo
81 81
  * @return string
82 82
  */
83 83
 function chercher_rubrique(
84
-	$titre,
85
-	$id_objet,
86
-	$id_parent,
87
-	$objet,
88
-	$id_secteur,
89
-	$restreint,
90
-	$actionable = false,
91
-	$retour_sans_cadre = false
84
+    $titre,
85
+    $id_objet,
86
+    $id_parent,
87
+    $objet,
88
+    $id_secteur,
89
+    $restreint,
90
+    $actionable = false,
91
+    $retour_sans_cadre = false
92 92
 ) {
93 93
 
94
-	include_spip('inc/autoriser');
95
-	if ((int) $id_objet && !autoriser('modifier', $objet, $id_objet)) {
96
-		return '';
97
-	}
98
-	if (!sql_countsel('spip_rubriques')) {
99
-		return '';
100
-	}
101
-	$chercher_rubrique = charger_fonction('chercher_rubrique', 'inc');
102
-	$form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0);
103
-
104
-	if ($id_parent == 0) {
105
-		$logo = 'racine-24.png';
106
-	} elseif ($id_secteur == $id_parent) {
107
-		$logo = 'secteur-24.png';
108
-	} else {
109
-		$logo = 'rubrique-24.png';
110
-	}
111
-
112
-	$confirm = '';
113
-	if ($objet == 'rubrique') {
114
-		// FIXME: Migration plus adapté vers le plugin Brèves ?
115
-		// si c'est une rubrique-secteur contenant des breves, demander la
116
-		// confirmation du deplacement
117
-		if (
118
-			sql_table_exists('spip_breves')
119
-			&& ($contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . (int) $id_objet))
120
-			&& $contient_breves > 0
121
-		) {
122
-			// FIXME: utiliser singulier_ou_pluriel, migrer dans plugin Brèves
123
-			$scb = ($contient_breves > 1 ? 's' : '');
124
-			$scb = _T(
125
-				'avis_deplacement_rubrique',
126
-				[
127
-					'contient_breves' => $contient_breves,
128
-					'scb' => $scb
129
-				]
130
-			);
131
-			$confirm .= "\n<div class='confirmer_deplacement verdana2'>"
132
-				. "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>"
133
-				. $scb .
134
-				"</label></div></div>\n";
135
-		} else {
136
-			$confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n";
137
-		}
138
-	}
139
-	$form .= $confirm;
140
-	if ($actionable) {
141
-		if (str_contains($form, '<select')) {
142
-			$form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>"
143
-				. '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>'
144
-				. '</div>';
145
-		}
146
-		$form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form;
147
-		if ($action = charger_fonction("editer_$objet", 'action', true)) {
148
-			$form = generer_action_auteur(
149
-				"editer_$objet",
150
-				$id_objet,
151
-				self(),
152
-				$form,
153
-				" method='post' class='submit_plongeur'"
154
-			);
155
-		} else {
156
-			$form = generer_action_auteur(
157
-				'editer_objet',
158
-				"$objet/$id_objet",
159
-				self(),
160
-				$form,
161
-				" method='post' class='submit_plongeur'"
162
-			);
163
-		}
164
-	}
165
-
166
-	if ($retour_sans_cadre) {
167
-		return $form;
168
-	}
169
-
170
-	include_spip('inc/presentation');
171
-
172
-	return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur();
94
+    include_spip('inc/autoriser');
95
+    if ((int) $id_objet && !autoriser('modifier', $objet, $id_objet)) {
96
+        return '';
97
+    }
98
+    if (!sql_countsel('spip_rubriques')) {
99
+        return '';
100
+    }
101
+    $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc');
102
+    $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0);
103
+
104
+    if ($id_parent == 0) {
105
+        $logo = 'racine-24.png';
106
+    } elseif ($id_secteur == $id_parent) {
107
+        $logo = 'secteur-24.png';
108
+    } else {
109
+        $logo = 'rubrique-24.png';
110
+    }
111
+
112
+    $confirm = '';
113
+    if ($objet == 'rubrique') {
114
+        // FIXME: Migration plus adapté vers le plugin Brèves ?
115
+        // si c'est une rubrique-secteur contenant des breves, demander la
116
+        // confirmation du deplacement
117
+        if (
118
+            sql_table_exists('spip_breves')
119
+            && ($contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . (int) $id_objet))
120
+            && $contient_breves > 0
121
+        ) {
122
+            // FIXME: utiliser singulier_ou_pluriel, migrer dans plugin Brèves
123
+            $scb = ($contient_breves > 1 ? 's' : '');
124
+            $scb = _T(
125
+                'avis_deplacement_rubrique',
126
+                [
127
+                    'contient_breves' => $contient_breves,
128
+                    'scb' => $scb
129
+                ]
130
+            );
131
+            $confirm .= "\n<div class='confirmer_deplacement verdana2'>"
132
+                . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>"
133
+                . $scb .
134
+                "</label></div></div>\n";
135
+        } else {
136
+            $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n";
137
+        }
138
+    }
139
+    $form .= $confirm;
140
+    if ($actionable) {
141
+        if (str_contains($form, '<select')) {
142
+            $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>"
143
+                . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>'
144
+                . '</div>';
145
+        }
146
+        $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form;
147
+        if ($action = charger_fonction("editer_$objet", 'action', true)) {
148
+            $form = generer_action_auteur(
149
+                "editer_$objet",
150
+                $id_objet,
151
+                self(),
152
+                $form,
153
+                " method='post' class='submit_plongeur'"
154
+            );
155
+        } else {
156
+            $form = generer_action_auteur(
157
+                'editer_objet',
158
+                "$objet/$id_objet",
159
+                self(),
160
+                $form,
161
+                " method='post' class='submit_plongeur'"
162
+            );
163
+        }
164
+    }
165
+
166
+    if ($retour_sans_cadre) {
167
+        return $form;
168
+    }
169
+
170
+    include_spip('inc/presentation');
171
+
172
+    return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur();
173 173
 }
174 174
 
175 175
 
@@ -183,24 +183,24 @@  discard block
 block discarded – undo
183 183
  * @return bool
184 184
  */
185 185
 function avoir_visiteurs($past = false, $accepter = true) {
186
-	if ($GLOBALS['meta']['forums_publics'] == 'abo') {
187
-		return true;
188
-	}
189
-	if ($accepter && $GLOBALS['meta']['accepter_visiteurs'] != 'non') {
190
-		return true;
191
-	}
192
-	if (sql_countsel('spip_articles', "accepter_forum='abo'")) {
193
-		return true;
194
-	}
195
-	if (!$past) {
196
-		return false;
197
-	}
198
-
199
-	return sql_countsel(
200
-		'spip_auteurs',
201
-		"statut NOT IN ('0minirezo','1comite', '5poubelle')
186
+    if ($GLOBALS['meta']['forums_publics'] == 'abo') {
187
+        return true;
188
+    }
189
+    if ($accepter && $GLOBALS['meta']['accepter_visiteurs'] != 'non') {
190
+        return true;
191
+    }
192
+    if (sql_countsel('spip_articles', "accepter_forum='abo'")) {
193
+        return true;
194
+    }
195
+    if (!$past) {
196
+        return false;
197
+    }
198
+
199
+    return sql_countsel(
200
+        'spip_auteurs',
201
+        "statut NOT IN ('0minirezo','1comite', '5poubelle')
202 202
 	                    AND (statut<>'nouveau' OR prefs NOT IN ('0minirezo','1comite', '5poubelle'))"
203
-	);
203
+    );
204 204
 }
205 205
 
206 206
 /**
@@ -216,18 +216,18 @@  discard block
 block discarded – undo
216 216
  * @return array
217 217
  */
218 218
 function statuts_articles_visibles($statut_auteur) {
219
-	static $auth = [];
220
-	if (!isset($auth[$statut_auteur])) {
221
-		$auth[$statut_auteur] = [];
222
-		$statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut');
223
-		foreach ($statuts as $s) {
224
-			if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) {
225
-				$auth[$statut_auteur][] = $s;
226
-			}
227
-		}
228
-	}
229
-
230
-	return $auth[$statut_auteur];
219
+    static $auth = [];
220
+    if (!isset($auth[$statut_auteur])) {
221
+        $auth[$statut_auteur] = [];
222
+        $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut');
223
+        foreach ($statuts as $s) {
224
+            if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) {
225
+                $auth[$statut_auteur][] = $s;
226
+            }
227
+        }
228
+    }
229
+
230
+    return $auth[$statut_auteur];
231 231
 }
232 232
 
233 233
 /**
@@ -241,38 +241,38 @@  discard block
 block discarded – undo
241 241
  * @return string
242 242
  */
243 243
 function traduire_statut_auteur($statut, $attente = '') {
244
-	$plus = '';
245
-	if ($statut == 'nouveau') {
246
-		if ($attente) {
247
-			$statut = $attente;
248
-			$plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')';
249
-		} else {
250
-			return _T('info_statut_auteur_a_confirmer');
251
-		}
252
-	}
253
-
254
-	$recom = [
255
-		'info_administrateurs' => _T('item_administrateur_2'),
256
-		'info_redacteurs' => _T('intem_redacteur'),
257
-		'info_visiteurs' => _T('item_visiteur'),
258
-		'5poubelle' => _T('texte_statut_poubelle'), // bouh
259
-	];
260
-	if (isset($recom[$statut])) {
261
-		return $recom[$statut] . $plus;
262
-	}
263
-
264
-	// retrouver directement par le statut sinon
265
-	if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) {
266
-		if (isset($recom[$t])) {
267
-			return $recom[$t] . $plus;
268
-		}
269
-
270
-		return _T($t) . $plus;
271
-	}
272
-
273
-	// si on a pas reussi a le traduire, retournons la chaine telle quelle
274
-	// c'est toujours plus informatif que rien du tout
275
-	return $statut;
244
+    $plus = '';
245
+    if ($statut == 'nouveau') {
246
+        if ($attente) {
247
+            $statut = $attente;
248
+            $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')';
249
+        } else {
250
+            return _T('info_statut_auteur_a_confirmer');
251
+        }
252
+    }
253
+
254
+    $recom = [
255
+        'info_administrateurs' => _T('item_administrateur_2'),
256
+        'info_redacteurs' => _T('intem_redacteur'),
257
+        'info_visiteurs' => _T('item_visiteur'),
258
+        '5poubelle' => _T('texte_statut_poubelle'), // bouh
259
+    ];
260
+    if (isset($recom[$statut])) {
261
+        return $recom[$statut] . $plus;
262
+    }
263
+
264
+    // retrouver directement par le statut sinon
265
+    if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) {
266
+        if (isset($recom[$t])) {
267
+            return $recom[$t] . $plus;
268
+        }
269
+
270
+        return _T($t) . $plus;
271
+    }
272
+
273
+    // si on a pas reussi a le traduire, retournons la chaine telle quelle
274
+    // c'est toujours plus informatif que rien du tout
275
+    return $statut;
276 276
 }
277 277
 
278 278
 /**
@@ -283,29 +283,29 @@  discard block
 block discarded – undo
283 283
  * @return string
284 284
  */
285 285
 function afficher_qui_edite($id_objet, $objet): string {
286
-	static $qui = [];
287
-	if (isset($qui[$objet][$id_objet])) {
288
-		return $qui[$objet][$id_objet];
289
-	}
290
-
291
-	include_spip('inc/config');
292
-	if (lire_config('articles_modif', 'non') === 'non') {
293
-		return $qui[$objet][$id_objet] = '';
294
-	}
295
-
296
-	include_spip('inc/drapeau_edition');
297
-	$modif = mention_qui_edite($id_objet, $objet);
298
-	if (!$modif) {
299
-		return $qui[$objet][$id_objet] = '';
300
-	}
301
-
302
-	include_spip('base/objets');
303
-	$infos = lister_tables_objets_sql(table_objet_sql($objet));
304
-	if (isset($infos['texte_signale_edition'])) {
305
-		return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif);
306
-	}
307
-
308
-	return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif);
286
+    static $qui = [];
287
+    if (isset($qui[$objet][$id_objet])) {
288
+        return $qui[$objet][$id_objet];
289
+    }
290
+
291
+    include_spip('inc/config');
292
+    if (lire_config('articles_modif', 'non') === 'non') {
293
+        return $qui[$objet][$id_objet] = '';
294
+    }
295
+
296
+    include_spip('inc/drapeau_edition');
297
+    $modif = mention_qui_edite($id_objet, $objet);
298
+    if (!$modif) {
299
+        return $qui[$objet][$id_objet] = '';
300
+    }
301
+
302
+    include_spip('base/objets');
303
+    $infos = lister_tables_objets_sql(table_objet_sql($objet));
304
+    if (isset($infos['texte_signale_edition'])) {
305
+        return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif);
306
+    }
307
+
308
+    return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif);
309 309
 }
310 310
 
311 311
 /**
@@ -323,53 +323,53 @@  discard block
 block discarded – undo
323 323
  * @return array
324 324
  */
325 325
 function auteurs_lister_statuts($quoi = 'tous', $en_base = true): array {
326
-	if (!defined('AUTEURS_MIN_REDAC')) {
327
-		define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle');
328
-	}
329
-
330
-	switch ($quoi) {
331
-		case 'redacteurs':
332
-			$statut = AUTEURS_MIN_REDAC;
333
-			$statut = explode(',', (string) $statut);
334
-			if ($en_base) {
335
-				$check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut');
336
-				$retire = array_diff($statut, $check);
337
-				$statut = array_diff($statut, $retire);
338
-			}
339
-
340
-			return array_unique($statut);
341
-
342
-		case 'visiteurs':
343
-			$statut = [];
344
-			$exclus = AUTEURS_MIN_REDAC;
345
-			$exclus = explode(',', (string) $exclus);
346
-			if (!$en_base) {
347
-				// prendre aussi les statuts de la table des status qui ne sont pas dans le define
348
-				$statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus);
349
-			}
350
-			$s_complement = array_column(
351
-				sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')),
352
-				'statut'
353
-			);
354
-
355
-			return array_unique([...$statut, ...$s_complement]);
356
-
357
-		default:
358
-		case 'tous':
359
-			$statut = array_values($GLOBALS['liste_des_statuts']);
360
-			$s_complement = array_column(
361
-				sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')),
362
-				'statut'
363
-			);
364
-			$statut = [...$statut, ...$s_complement];
365
-			if ($en_base) {
366
-				$check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut');
367
-				$retire = array_diff($statut, $check);
368
-				$statut = array_diff($statut, $retire);
369
-			}
370
-
371
-			return array_unique($statut);
372
-	}
326
+    if (!defined('AUTEURS_MIN_REDAC')) {
327
+        define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle');
328
+    }
329
+
330
+    switch ($quoi) {
331
+        case 'redacteurs':
332
+            $statut = AUTEURS_MIN_REDAC;
333
+            $statut = explode(',', (string) $statut);
334
+            if ($en_base) {
335
+                $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut');
336
+                $retire = array_diff($statut, $check);
337
+                $statut = array_diff($statut, $retire);
338
+            }
339
+
340
+            return array_unique($statut);
341
+
342
+        case 'visiteurs':
343
+            $statut = [];
344
+            $exclus = AUTEURS_MIN_REDAC;
345
+            $exclus = explode(',', (string) $exclus);
346
+            if (!$en_base) {
347
+                // prendre aussi les statuts de la table des status qui ne sont pas dans le define
348
+                $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus);
349
+            }
350
+            $s_complement = array_column(
351
+                sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')),
352
+                'statut'
353
+            );
354
+
355
+            return array_unique([...$statut, ...$s_complement]);
356
+
357
+        default:
358
+        case 'tous':
359
+            $statut = array_values($GLOBALS['liste_des_statuts']);
360
+            $s_complement = array_column(
361
+                sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')),
362
+                'statut'
363
+            );
364
+            $statut = [...$statut, ...$s_complement];
365
+            if ($en_base) {
366
+                $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut');
367
+                $retire = array_diff($statut, $check);
368
+                $statut = array_diff($statut, $retire);
369
+            }
370
+
371
+            return array_unique($statut);
372
+    }
373 373
 }
374 374
 
375 375
 /**
@@ -385,28 +385,28 @@  discard block
 block discarded – undo
385 385
  */
386 386
 function trouver_rubrique_creer_objet($id_rubrique, $objet) {
387 387
 
388
-	if (!$id_rubrique && defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') && _CHOIX_RUBRIQUE_PAR_DEFAUT) {
389
-		$in = (is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0)
390
-			? ' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])
391
-			: '';
392
-
393
-		// on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement
394
-		if ($objet == 'rubrique') {
395
-			$id_rubrique = 0;
396
-		} else {
397
-			$id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1);
398
-		}
399
-
400
-		if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) {
401
-			// manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises
402
-			$res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0');
403
-			while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) {
404
-				$id_rubrique = $row_rub['id_rubrique'];
405
-			}
406
-		}
407
-	}
408
-
409
-	return $id_rubrique;
388
+    if (!$id_rubrique && defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') && _CHOIX_RUBRIQUE_PAR_DEFAUT) {
389
+        $in = (is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0)
390
+            ? ' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])
391
+            : '';
392
+
393
+        // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement
394
+        if ($objet == 'rubrique') {
395
+            $id_rubrique = 0;
396
+        } else {
397
+            $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1);
398
+        }
399
+
400
+        if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) {
401
+            // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises
402
+            $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0');
403
+            while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) {
404
+                $id_rubrique = $row_rub['id_rubrique'];
405
+            }
406
+        }
407
+    }
408
+
409
+    return $id_rubrique;
410 410
 }
411 411
 
412 412
 /**
@@ -417,25 +417,25 @@  discard block
 block discarded – undo
417 417
  * @return string
418 418
  */
419 419
 function lien_article_virtuel($virtuel) {
420
-	include_spip('inc/lien');
421
-	if (!$virtuel = virtuel_redirige($virtuel)) {
422
-		return '';
423
-	}
424
-
425
-	$joli = $virtuel;
426
-	$parts = parse_url($virtuel);
427
-	if (!empty($parts['query']) && str_contains($parts['query'], ']')) {
428
-		$query = str_replace(['[', ']'], [urlencode('['), urlencode(']')], $parts['query']);
429
-		$virtuel = str_replace('?' . $parts['query'], "?$query", $virtuel);
430
-	}
431
-	if ($virtuel !== $joli) {
432
-		$joli = propre('[' . $joli . ' -> ' . $virtuel . ']');
433
-	}
434
-	else {
435
-		$joli = propre('[->' . $virtuel . ']');
436
-	}
437
-
438
-	return $joli;
420
+    include_spip('inc/lien');
421
+    if (!$virtuel = virtuel_redirige($virtuel)) {
422
+        return '';
423
+    }
424
+
425
+    $joli = $virtuel;
426
+    $parts = parse_url($virtuel);
427
+    if (!empty($parts['query']) && str_contains($parts['query'], ']')) {
428
+        $query = str_replace(['[', ']'], [urlencode('['), urlencode(']')], $parts['query']);
429
+        $virtuel = str_replace('?' . $parts['query'], "?$query", $virtuel);
430
+    }
431
+    if ($virtuel !== $joli) {
432
+        $joli = propre('[' . $joli . ' -> ' . $virtuel . ']');
433
+    }
434
+    else {
435
+        $joli = propre('[->' . $virtuel . ']');
436
+    }
437
+
438
+    return $joli;
439 439
 }
440 440
 
441 441
 
@@ -458,11 +458,11 @@  discard block
 block discarded – undo
458 458
  * @filtre
459 459
  */
460 460
 function bouton_spip_rss($op, $args = [], $lang = '', $title = 'RSS') {
461
-	include_spip('inc/acces');
462
-	$clic = http_img_pack('rss-16.png', 'RSS', '', $title);
461
+    include_spip('inc/acces');
462
+    $clic = http_img_pack('rss-16.png', 'RSS', '', $title);
463 463
 
464
-	$url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true);
465
-	return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>";
464
+    $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true);
465
+    return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>";
466 466
 }
467 467
 
468 468
 
@@ -474,72 +474,72 @@  discard block
 block discarded – undo
474 474
  */
475 475
 function alertes_auteur($id_auteur): string {
476 476
 
477
-	$alertes = [];
478
-
479
-	if (
480
-		isset($GLOBALS['meta']['message_crash_tables'])
481
-		&& autoriser('detruire', null, null, $id_auteur)
482
-	) {
483
-		include_spip('genie/maintenance');
484
-		if ($msg = message_crash_tables()) {
485
-			$alertes[] = $msg;
486
-		}
487
-	}
488
-
489
-	if (
490
-		isset($GLOBALS['meta']['message_crash_plugins'])
491
-		&& $GLOBALS['meta']['message_crash_plugins']
492
-		&& autoriser('configurer', '_plugins', null, $id_auteur)
493
-		&& is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins']))
494
-	) {
495
-		$msg = implode(', ', array_map('joli_repertoire', array_keys($msg)));
496
-		$alertes[] = _T('plugins_erreur', ['plugins' => $msg]);
497
-	}
498
-
499
-	$a = $GLOBALS['meta']['message_alertes_auteurs'] ?? '';
500
-	if ($a && is_array($a = unserialize($a)) && count($a)) {
501
-		$update = false;
502
-		if (isset($a[$GLOBALS['visiteur_session']['statut']])) {
503
-			$alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]);
504
-			unset($a[$GLOBALS['visiteur_session']['statut']]);
505
-			$update = true;
506
-		}
507
-		if (isset($a[''])) {
508
-			$alertes = array_merge($alertes, $a['']);
509
-			unset($a['']);
510
-			$update = true;
511
-		}
512
-		if ($update) {
513
-			ecrire_meta('message_alertes_auteurs', serialize($a));
514
-		}
515
-	}
516
-
517
-	if (
518
-		isset($GLOBALS['meta']['plugin_erreur_activation'])
519
-		&& autoriser('configurer', '_plugins', null, $id_auteur)
520
-	) {
521
-		include_spip('inc/plugin');
522
-		$alertes[] = plugin_donne_erreurs();
523
-	}
524
-
525
-	$alertes = pipeline(
526
-		'alertes_auteur',
527
-		[
528
-			'args' => [
529
-				'id_auteur' => $id_auteur,
530
-				'exec' => _request('exec'),
531
-			],
532
-			'data' => $alertes
533
-		]
534
-	);
535
-
536
-	if ($alertes = array_filter($alertes)) {
537
-		return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" .
538
-		implode(' | ', $alertes)
539
-		. '</div></div>';
540
-	}
541
-
542
-	return '';
477
+    $alertes = [];
478
+
479
+    if (
480
+        isset($GLOBALS['meta']['message_crash_tables'])
481
+        && autoriser('detruire', null, null, $id_auteur)
482
+    ) {
483
+        include_spip('genie/maintenance');
484
+        if ($msg = message_crash_tables()) {
485
+            $alertes[] = $msg;
486
+        }
487
+    }
488
+
489
+    if (
490
+        isset($GLOBALS['meta']['message_crash_plugins'])
491
+        && $GLOBALS['meta']['message_crash_plugins']
492
+        && autoriser('configurer', '_plugins', null, $id_auteur)
493
+        && is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins']))
494
+    ) {
495
+        $msg = implode(', ', array_map('joli_repertoire', array_keys($msg)));
496
+        $alertes[] = _T('plugins_erreur', ['plugins' => $msg]);
497
+    }
498
+
499
+    $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? '';
500
+    if ($a && is_array($a = unserialize($a)) && count($a)) {
501
+        $update = false;
502
+        if (isset($a[$GLOBALS['visiteur_session']['statut']])) {
503
+            $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]);
504
+            unset($a[$GLOBALS['visiteur_session']['statut']]);
505
+            $update = true;
506
+        }
507
+        if (isset($a[''])) {
508
+            $alertes = array_merge($alertes, $a['']);
509
+            unset($a['']);
510
+            $update = true;
511
+        }
512
+        if ($update) {
513
+            ecrire_meta('message_alertes_auteurs', serialize($a));
514
+        }
515
+    }
516
+
517
+    if (
518
+        isset($GLOBALS['meta']['plugin_erreur_activation'])
519
+        && autoriser('configurer', '_plugins', null, $id_auteur)
520
+    ) {
521
+        include_spip('inc/plugin');
522
+        $alertes[] = plugin_donne_erreurs();
523
+    }
524
+
525
+    $alertes = pipeline(
526
+        'alertes_auteur',
527
+        [
528
+            'args' => [
529
+                'id_auteur' => $id_auteur,
530
+                'exec' => _request('exec'),
531
+            ],
532
+            'data' => $alertes
533
+        ]
534
+    );
535
+
536
+    if ($alertes = array_filter($alertes)) {
537
+        return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" .
538
+        implode(' | ', $alertes)
539
+        . '</div></div>';
540
+    }
541
+
542
+    return '';
543 543
 }
544 544
 
545 545
 /**
@@ -549,9 +549,9 @@  discard block
 block discarded – undo
549 549
  * @return string
550 550
  */
551 551
 function filtre_afficher_enfant_rub_dist($id_rubrique) {
552
-	include_spip('inc/presenter_enfants');
552
+    include_spip('inc/presenter_enfants');
553 553
 
554
-	return afficher_enfant_rub((int) $id_rubrique);
554
+    return afficher_enfant_rub((int) $id_rubrique);
555 555
 }
556 556
 
557 557
 /**
@@ -569,15 +569,15 @@  discard block
 block discarded – undo
569 569
  * @return string
570 570
  */
571 571
 function afficher_plus_info($lien, $titre = '+', $titre_lien = '') {
572
-	$titre = attribut_html($titre);
573
-	$icone = "\n<a href='$lien' title='$titre' class='plus_info'>" .
574
-		http_img_pack('information-16.png', $titre) . '</a>';
575
-
576
-	if (!$titre_lien) {
577
-		return $icone;
578
-	} else {
579
-		return $icone . "\n<a href='$lien'>$titre_lien</a>";
580
-	}
572
+    $titre = attribut_html($titre);
573
+    $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" .
574
+        http_img_pack('information-16.png', $titre) . '</a>';
575
+
576
+    if (!$titre_lien) {
577
+        return $icone;
578
+    } else {
579
+        return $icone . "\n<a href='$lien'>$titre_lien</a>";
580
+    }
581 581
 }
582 582
 
583 583
 
@@ -596,20 +596,20 @@  discard block
 block discarded – undo
596 596
  * @return array
597 597
  */
598 598
 function lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien) {
599
-	$res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien);
600
-	if (!(is_countable($res) ? count($res) : 0)) {
601
-		return [];
602
-	}
603
-	$r = reset($res);
604
-	$colonne_id = ($objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet');
605
-	if (isset($r['rang_lien'])) {
606
-		$l = array_column($res, 'rang_lien', $colonne_id);
607
-		asort($l);
608
-		$l = array_keys($l);
609
-	} else {
610
-		// Si les liens qu'on cherche sont ceux de la table de lien, l'info est dans la clé de l'objet
611
-		// Sinon c'est dans "id_objet"
612
-		$l = array_column($res, $colonne_id);
613
-	}
614
-	return $l;
599
+    $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien);
600
+    if (!(is_countable($res) ? count($res) : 0)) {
601
+        return [];
602
+    }
603
+    $r = reset($res);
604
+    $colonne_id = ($objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet');
605
+    if (isset($r['rang_lien'])) {
606
+        $l = array_column($res, 'rang_lien', $colonne_id);
607
+        asort($l);
608
+        $l = array_keys($l);
609
+    } else {
610
+        // Si les liens qu'on cherche sont ceux de la table de lien, l'info est dans la clé de l'objet
611
+        // Sinon c'est dans "id_objet"
612
+        $l = array_column($res, $colonne_id);
613
+    }
614
+    return $l;
615 615
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 		// confirmation du deplacement
117 117
 		if (
118 118
 			sql_table_exists('spip_breves')
119
-			&& ($contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . (int) $id_objet))
119
+			&& ($contient_breves = sql_countsel('spip_breves', 'id_rubrique='.(int) $id_objet))
120 120
 			&& $contient_breves > 0
121 121
 		) {
122 122
 			// FIXME: utiliser singulier_ou_pluriel, migrer dans plugin Brèves
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 			);
131 131
 			$confirm .= "\n<div class='confirmer_deplacement verdana2'>"
132 132
 				. "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>"
133
-				. $scb .
133
+				. $scb.
134 134
 				"</label></div></div>\n";
135 135
 		} else {
136 136
 			$confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n";
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
 	$form .= $confirm;
140 140
 	if ($actionable) {
141 141
 		if (str_contains($form, '<select')) {
142
-			$form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>"
143
-				. '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>'
142
+			$form .= "<div style='text-align: ".$GLOBALS['spip_lang_right'].";'>"
143
+				. '<input class="fondo submit btn" type="submit" value="'._T('bouton_choisir').'"/>'
144 144
 				. '</div>';
145 145
 		}
146
-		$form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form;
146
+		$form = "<input type='hidden' name='editer_$objet' value='oui' />\n".$form;
147 147
 		if ($action = charger_fonction("editer_$objet", 'action', true)) {
148 148
 			$form = generer_action_auteur(
149 149
 				"editer_$objet",
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
 	include_spip('inc/presentation');
171 171
 
172
-	return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur();
172
+	return debut_cadre_couleur($logo, true, '', $titre).$form.fin_cadre_couleur();
173 173
 }
174 174
 
175 175
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	if ($statut == 'nouveau') {
246 246
 		if ($attente) {
247 247
 			$statut = $attente;
248
-			$plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')';
248
+			$plus = ' ('._T('info_statut_auteur_a_confirmer').')';
249 249
 		} else {
250 250
 			return _T('info_statut_auteur_a_confirmer');
251 251
 		}
@@ -258,16 +258,16 @@  discard block
 block discarded – undo
258 258
 		'5poubelle' => _T('texte_statut_poubelle'), // bouh
259 259
 	];
260 260
 	if (isset($recom[$statut])) {
261
-		return $recom[$statut] . $plus;
261
+		return $recom[$statut].$plus;
262 262
 	}
263 263
 
264 264
 	// retrouver directement par le statut sinon
265 265
 	if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) {
266 266
 		if (isset($recom[$t])) {
267
-			return $recom[$t] . $plus;
267
+			return $recom[$t].$plus;
268 268
 		}
269 269
 
270
-		return _T($t) . $plus;
270
+		return _T($t).$plus;
271 271
 	}
272 272
 
273 273
 	// si on a pas reussi a le traduire, retournons la chaine telle quelle
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 
388 388
 	if (!$id_rubrique && defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') && _CHOIX_RUBRIQUE_PAR_DEFAUT) {
389 389
 		$in = (is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0)
390
-			? ' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])
390
+			? ' AND '.sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])
391 391
 			: '';
392 392
 
393 393
 		// on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement
@@ -426,13 +426,13 @@  discard block
 block discarded – undo
426 426
 	$parts = parse_url($virtuel);
427 427
 	if (!empty($parts['query']) && str_contains($parts['query'], ']')) {
428 428
 		$query = str_replace(['[', ']'], [urlencode('['), urlencode(']')], $parts['query']);
429
-		$virtuel = str_replace('?' . $parts['query'], "?$query", $virtuel);
429
+		$virtuel = str_replace('?'.$parts['query'], "?$query", $virtuel);
430 430
 	}
431 431
 	if ($virtuel !== $joli) {
432
-		$joli = propre('[' . $joli . ' -> ' . $virtuel . ']');
432
+		$joli = propre('['.$joli.' -> '.$virtuel.']');
433 433
 	}
434 434
 	else {
435
-		$joli = propre('[->' . $virtuel . ']');
435
+		$joli = propre('[->'.$virtuel.']');
436 436
 	}
437 437
 
438 438
 	return $joli;
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 	$clic = http_img_pack('rss-16.png', 'RSS', '', $title);
463 463
 
464 464
 	$url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true);
465
-	return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>";
465
+	return "<a style='float: ".$GLOBALS['spip_lang_right'].";' href='$url'>$clic</a>";
466 466
 }
467 467
 
468 468
 
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 	);
535 535
 
536 536
 	if ($alertes = array_filter($alertes)) {
537
-		return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" .
537
+		return "<div class='wrap-messages-alertes'><div class='messages-alertes'>".
538 538
 		implode(' | ', $alertes)
539 539
 		. '</div></div>';
540 540
 	}
@@ -570,13 +570,13 @@  discard block
 block discarded – undo
570 570
  */
571 571
 function afficher_plus_info($lien, $titre = '+', $titre_lien = '') {
572 572
 	$titre = attribut_html($titre);
573
-	$icone = "\n<a href='$lien' title='$titre' class='plus_info'>" .
574
-		http_img_pack('information-16.png', $titre) . '</a>';
573
+	$icone = "\n<a href='$lien' title='$titre' class='plus_info'>".
574
+		http_img_pack('information-16.png', $titre).'</a>';
575 575
 
576 576
 	if (!$titre_lien) {
577 577
 		return $icone;
578 578
 	} else {
579
-		return $icone . "\n<a href='$lien'>$titre_lien</a>";
579
+		return $icone."\n<a href='$lien'>$titre_lien</a>";
580 580
 	}
581 581
 }
582 582
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -430,8 +430,7 @@
 block discarded – undo
430 430
 	}
431 431
 	if ($virtuel !== $joli) {
432 432
 		$joli = propre('[' . $joli . ' -> ' . $virtuel . ']');
433
-	}
434
-	else {
433
+	} else {
435 434
 		$joli = propre('[->' . $virtuel . ']');
436 435
 	}
437 436
 
Please login to merge, or discard this patch.
ecrire/inc/math.php 2 patches
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 //
15 15
 if (!defined('_ECRIRE_INC_VERSION')) {
16
-	return;
16
+    return;
17 17
 }
18 18
 
19 19
 //
@@ -22,52 +22,52 @@  discard block
 block discarded – undo
22 22
 
23 23
 function produire_image_math($tex) {
24 24
 
25
-	switch ($GLOBALS['traiter_math']) {
26
-		// Attention: mathml desactiv'e pour l'instant
27
-		case 'mathml':
28
-			$ext = '.xhtml';
29
-			$server = $GLOBALS['mathml_server'];
30
-			break;
31
-		case 'tex':
32
-			$ext = '.png';
33
-			$server = $GLOBALS['tex_server'];
34
-			break;
35
-		default:
36
-			return $tex;
37
-	}
38
-
39
-	// Regarder dans le repertoire local des images TeX et blocs MathML
40
-	if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) {
41
-		@mkdir($dir_tex, _SPIP_CHMOD);
42
-	}
43
-	$fichier = $dir_tex . md5(trim((string) $tex)) . $ext;
44
-
45
-
46
-	// Aller chercher l'image sur le serveur
47
-	if (!@file_exists($fichier) && $server) {
48
-		spip_log($url = $server . '?' . rawurlencode((string) $tex));
49
-		include_spip('inc/distant');
50
-		recuperer_url($url, ['file' => $fichier]);
51
-	}
52
-
53
-
54
-	// Composer la reponse selon presence ou non de l'image
55
-	$tex = entites_html($tex);
56
-	if (@file_exists($fichier)) {
57
-		// MathML
58
-		if ($GLOBALS['traiter_math'] == 'mathml') {
59
-			return implode('', file($fichier));
60
-		} // TeX
61
-		else {
62
-			[, , , $size] = @spip_getimagesize($fichier);
63
-			$alt = "alt=\"$tex\" title=\"$tex\"";
64
-
65
-			return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />";
66
-		}
67
-	} else // pas de fichier
68
-	{
69
-		return "<tt><span class='spip_code' dir='ltr'>$tex</span></tt>";
70
-	}
25
+    switch ($GLOBALS['traiter_math']) {
26
+        // Attention: mathml desactiv'e pour l'instant
27
+        case 'mathml':
28
+            $ext = '.xhtml';
29
+            $server = $GLOBALS['mathml_server'];
30
+            break;
31
+        case 'tex':
32
+            $ext = '.png';
33
+            $server = $GLOBALS['tex_server'];
34
+            break;
35
+        default:
36
+            return $tex;
37
+    }
38
+
39
+    // Regarder dans le repertoire local des images TeX et blocs MathML
40
+    if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) {
41
+        @mkdir($dir_tex, _SPIP_CHMOD);
42
+    }
43
+    $fichier = $dir_tex . md5(trim((string) $tex)) . $ext;
44
+
45
+
46
+    // Aller chercher l'image sur le serveur
47
+    if (!@file_exists($fichier) && $server) {
48
+        spip_log($url = $server . '?' . rawurlencode((string) $tex));
49
+        include_spip('inc/distant');
50
+        recuperer_url($url, ['file' => $fichier]);
51
+    }
52
+
53
+
54
+    // Composer la reponse selon presence ou non de l'image
55
+    $tex = entites_html($tex);
56
+    if (@file_exists($fichier)) {
57
+        // MathML
58
+        if ($GLOBALS['traiter_math'] == 'mathml') {
59
+            return implode('', file($fichier));
60
+        } // TeX
61
+        else {
62
+            [, , , $size] = @spip_getimagesize($fichier);
63
+            $alt = "alt=\"$tex\" title=\"$tex\"";
64
+
65
+            return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />";
66
+        }
67
+    } else // pas de fichier
68
+    {
69
+        return "<tt><span class='spip_code' dir='ltr'>$tex</span></tt>";
70
+    }
71 71
 }
72 72
 
73 73
 
@@ -102,39 +102,39 @@  discard block
 block discarded – undo
102 102
  */
103 103
 function traiter_math($letexte, $source = '', $defaire_amp = false) {
104 104
 
105
-	$collecteurMath = new CollecteurHtmlTag('math', '@<math>(.*)(</math>|$)@iUsS', '');
106
-	$collection = $collecteurMath->collecter($letexte);
107
-	$collection = array_reverse($collection);
108
-
109
-	foreach ($collection as $c) {
110
-		$texte_milieu = $c['match'][1];
111
-
112
-		$traitements = [
113
-			// Les doubles $$x^2$$ en mode 'div'
114
-			['str' => '$$', 'preg' => ',[$][$]([^$]+)[$][$],', 'pre' => "\n<p class=\"spip\" style=\"text-align: center;\">", 'post' => "</p>\n"],
115
-			// Les simples $x^2$ en mode 'span'
116
-			['str' => '$', 'preg' => ',[$]([^$]+)[$],'],
117
-		];
118
-		foreach ($traitements as $t) {
119
-			while (
120
-				str_contains($texte_milieu, $t['str'])
121
-				&& preg_match($t['preg'], $texte_milieu, $regs)
122
-			) {
123
-				$expression = $regs[1];
124
-				if ($defaire_amp) {
125
-					$expression = str_replace('&amp;', '&', $expression);
126
-				}
127
-				$echap = produire_image_math($expression);
128
-				$echap = ($t['pre'] ?? '') . $echap . ($t['post'] ?? '');
129
-				$echap = CollecteurHtmlTag::echappementHtmlBase64($echap, $source);
130
-
131
-				$pos = strpos($texte_milieu, (string) $regs[0]);
132
-				$texte_milieu = substr_replace($texte_milieu, $echap, $pos, strlen($regs[0]));
133
-			}
134
-		}
135
-
136
-		$letexte = substr_replace($letexte, $texte_milieu, $c['pos'], $c['length']);
137
-	}
138
-
139
-	return $letexte;
105
+    $collecteurMath = new CollecteurHtmlTag('math', '@<math>(.*)(</math>|$)@iUsS', '');
106
+    $collection = $collecteurMath->collecter($letexte);
107
+    $collection = array_reverse($collection);
108
+
109
+    foreach ($collection as $c) {
110
+        $texte_milieu = $c['match'][1];
111
+
112
+        $traitements = [
113
+            // Les doubles $$x^2$$ en mode 'div'
114
+            ['str' => '$$', 'preg' => ',[$][$]([^$]+)[$][$],', 'pre' => "\n<p class=\"spip\" style=\"text-align: center;\">", 'post' => "</p>\n"],
115
+            // Les simples $x^2$ en mode 'span'
116
+            ['str' => '$', 'preg' => ',[$]([^$]+)[$],'],
117
+        ];
118
+        foreach ($traitements as $t) {
119
+            while (
120
+                str_contains($texte_milieu, $t['str'])
121
+                && preg_match($t['preg'], $texte_milieu, $regs)
122
+            ) {
123
+                $expression = $regs[1];
124
+                if ($defaire_amp) {
125
+                    $expression = str_replace('&amp;', '&', $expression);
126
+                }
127
+                $echap = produire_image_math($expression);
128
+                $echap = ($t['pre'] ?? '') . $echap . ($t['post'] ?? '');
129
+                $echap = CollecteurHtmlTag::echappementHtmlBase64($echap, $source);
130
+
131
+                $pos = strpos($texte_milieu, (string) $regs[0]);
132
+                $texte_milieu = substr_replace($texte_milieu, $echap, $pos, strlen($regs[0]));
133
+            }
134
+        }
135
+
136
+        $letexte = substr_replace($letexte, $texte_milieu, $c['pos'], $c['length']);
137
+    }
138
+
139
+    return $letexte;
140 140
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -37,15 +37,15 @@  discard block
 block discarded – undo
37 37
 	}
38 38
 
39 39
 	// Regarder dans le repertoire local des images TeX et blocs MathML
40
-	if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) {
40
+	if (!@is_dir($dir_tex = _DIR_VAR.'cache-TeX/')) {
41 41
 		@mkdir($dir_tex, _SPIP_CHMOD);
42 42
 	}
43
-	$fichier = $dir_tex . md5(trim((string) $tex)) . $ext;
43
+	$fichier = $dir_tex.md5(trim((string) $tex)).$ext;
44 44
 
45 45
 
46 46
 	// Aller chercher l'image sur le serveur
47 47
 	if (!@file_exists($fichier) && $server) {
48
-		spip_log($url = $server . '?' . rawurlencode((string) $tex));
48
+		spip_log($url = $server.'?'.rawurlencode((string) $tex));
49 49
 		include_spip('inc/distant');
50 50
 		recuperer_url($url, ['file' => $fichier]);
51 51
 	}
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 			return implode('', file($fichier));
60 60
 		} // TeX
61 61
 		else {
62
-			[, , , $size] = @spip_getimagesize($fichier);
62
+			[,,, $size] = @spip_getimagesize($fichier);
63 63
 			$alt = "alt=\"$tex\" title=\"$tex\"";
64 64
 
65 65
 			return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />";
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 					$expression = str_replace('&amp;', '&', $expression);
126 126
 				}
127 127
 				$echap = produire_image_math($expression);
128
-				$echap = ($t['pre'] ?? '') . $echap . ($t['post'] ?? '');
128
+				$echap = ($t['pre'] ?? '').$echap.($t['post'] ?? '');
129 129
 				$echap = CollecteurHtmlTag::echappementHtmlBase64($echap, $source);
130 130
 
131 131
 				$pos = strpos($texte_milieu, (string) $regs[0]);
Please login to merge, or discard this patch.
ecrire/inc/acces.php 2 patches
Indentation   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -30,41 +30,41 @@  discard block
 block discarded – undo
30 30
  *     Mot de passe
31 31
  **/
32 32
 function creer_pass_aleatoire($longueur = 16, $sel = '') {
33
-	$seed = (int)round(((float)microtime() + 1) * time());
34
-
35
-	mt_srand($seed);
36
-	$s = '';
37
-	$pass = '';
38
-	for ($i = 0; $i < $longueur; $i++) {
39
-		if (!$s) {
40
-			$s = random_int(0, mt_getrandmax());
41
-			if (!$s) {
42
-				$s = random_int(0, mt_getrandmax());
43
-			}
44
-			$s = substr(md5(uniqid($s) . $sel), 0, 16);
45
-		}
46
-		$r = unpack('Cr', pack('H2', $s . $s));
47
-		$x = $r['r'] & 63;
48
-		if ($x < 10) {
49
-			$x = chr($x + 48);
50
-		} else {
51
-			if ($x < 36) {
52
-				$x = chr($x + 55);
53
-			} else {
54
-				if ($x < 62) {
55
-					$x = chr($x + 61);
56
-				} else {
57
-					$x = $x == 63 ? '/' : '.';
58
-				}
59
-			}
60
-		}
61
-		$pass .= $x;
62
-		$s = substr($s, 2);
63
-	}
64
-	$pass = preg_replace('@[./]@', 'a', $pass);
65
-	$pass = preg_replace('@[I1l]@', 'L', $pass);
66
-
67
-	return preg_replace('@[0O]@', 'o', $pass);
33
+    $seed = (int)round(((float)microtime() + 1) * time());
34
+
35
+    mt_srand($seed);
36
+    $s = '';
37
+    $pass = '';
38
+    for ($i = 0; $i < $longueur; $i++) {
39
+        if (!$s) {
40
+            $s = random_int(0, mt_getrandmax());
41
+            if (!$s) {
42
+                $s = random_int(0, mt_getrandmax());
43
+            }
44
+            $s = substr(md5(uniqid($s) . $sel), 0, 16);
45
+        }
46
+        $r = unpack('Cr', pack('H2', $s . $s));
47
+        $x = $r['r'] & 63;
48
+        if ($x < 10) {
49
+            $x = chr($x + 48);
50
+        } else {
51
+            if ($x < 36) {
52
+                $x = chr($x + 55);
53
+            } else {
54
+                if ($x < 62) {
55
+                    $x = chr($x + 61);
56
+                } else {
57
+                    $x = $x == 63 ? '/' : '.';
58
+                }
59
+            }
60
+        }
61
+        $pass .= $x;
62
+        $s = substr($s, 2);
63
+    }
64
+    $pass = preg_replace('@[./]@', 'a', $pass);
65
+    $pass = preg_replace('@[I1l]@', 'L', $pass);
66
+
67
+    return preg_replace('@[0O]@', 'o', $pass);
68 68
 }
69 69
 
70 70
 /**
@@ -73,20 +73,20 @@  discard block
 block discarded – undo
73 73
  * @return string Identifiant
74 74
  */
75 75
 function creer_uniqid() {
76
-	static $seeded;
76
+    static $seeded;
77 77
 
78
-	if (!$seeded) {
79
-		$seed = (int)round(((float)microtime() + 1) * time());
80
-		mt_srand($seed);
81
-		$seeded = true;
82
-	}
78
+    if (!$seeded) {
79
+        $seed = (int)round(((float)microtime() + 1) * time());
80
+        mt_srand($seed);
81
+        $seeded = true;
82
+    }
83 83
 
84
-	$s = random_int(0, mt_getrandmax());
85
-	if (!$s) {
86
-		$s = random_int(0, mt_getrandmax());
87
-	}
84
+    $s = random_int(0, mt_getrandmax());
85
+    if (!$s) {
86
+        $s = random_int(0, mt_getrandmax());
87
+    }
88 88
 
89
-	return uniqid((string) $s, true);
89
+    return uniqid((string) $s, true);
90 90
 }
91 91
 
92 92
 /**
@@ -100,42 +100,42 @@  discard block
 block discarded – undo
100 100
  * @return string Retourne l'alea éphemère actuel au passage
101 101
  */
102 102
 function charger_aleas() {
103
-	if (!isset($GLOBALS['meta']['alea_ephemere'])) {
104
-		include_spip('base/abstract_sql');
105
-		$aleas = sql_allfetsel(
106
-			['nom', 'valeur'],
107
-			'spip_meta',
108
-			sql_in('nom', ['alea_ephemere', 'alea_ephemere_ancien']),
109
-			'',
110
-			'',
111
-			'',
112
-			'',
113
-			'',
114
-			'continue'
115
-		);
116
-		if ($aleas) {
117
-			foreach ($aleas as $a) {
118
-				$GLOBALS['meta'][$a['nom']] = $a['valeur'];
119
-			}
120
-			return $GLOBALS['meta']['alea_ephemere'];
121
-		} else {
122
-			spip_log('aleas indisponibles', 'session');
123
-			return '';
124
-		}
125
-	}
126
-	return $GLOBALS['meta']['alea_ephemere'];
103
+    if (!isset($GLOBALS['meta']['alea_ephemere'])) {
104
+        include_spip('base/abstract_sql');
105
+        $aleas = sql_allfetsel(
106
+            ['nom', 'valeur'],
107
+            'spip_meta',
108
+            sql_in('nom', ['alea_ephemere', 'alea_ephemere_ancien']),
109
+            '',
110
+            '',
111
+            '',
112
+            '',
113
+            '',
114
+            'continue'
115
+        );
116
+        if ($aleas) {
117
+            foreach ($aleas as $a) {
118
+                $GLOBALS['meta'][$a['nom']] = $a['valeur'];
119
+            }
120
+            return $GLOBALS['meta']['alea_ephemere'];
121
+        } else {
122
+            spip_log('aleas indisponibles', 'session');
123
+            return '';
124
+        }
125
+    }
126
+    return $GLOBALS['meta']['alea_ephemere'];
127 127
 }
128 128
 
129 129
 /**
130 130
  * Renouveller l'alea (utilisé pour sécuriser les scripts du répertoire `action/`)
131 131
  **/
132 132
 function renouvelle_alea() {
133
-	charger_aleas();
134
-	ecrire_meta('alea_ephemere_ancien', @$GLOBALS['meta']['alea_ephemere'], 'non');
135
-	$GLOBALS['meta']['alea_ephemere'] = md5(creer_uniqid());
136
-	ecrire_meta('alea_ephemere', $GLOBALS['meta']['alea_ephemere'], 'non');
137
-	ecrire_meta('alea_ephemere_date', time(), 'non');
138
-	spip_log("renouvellement de l'alea_ephemere");
133
+    charger_aleas();
134
+    ecrire_meta('alea_ephemere_ancien', @$GLOBALS['meta']['alea_ephemere'], 'non');
135
+    $GLOBALS['meta']['alea_ephemere'] = md5(creer_uniqid());
136
+    ecrire_meta('alea_ephemere', $GLOBALS['meta']['alea_ephemere'], 'non');
137
+    ecrire_meta('alea_ephemere_date', time(), 'non');
138
+    spip_log("renouvellement de l'alea_ephemere");
139 139
 }
140 140
 
141 141
 
@@ -155,21 +155,21 @@  discard block
 block discarded – undo
155 155
  *     Clé de sécurité.
156 156
  **/
157 157
 function low_sec($id_auteur) {
158
-	// Pas d'id_auteur : low_sec
159
-	if (!$id_auteur = (int) $id_auteur) {
160
-		include_spip('inc/config');
161
-		if (!$low_sec = lire_config('low_sec')) {
162
-			ecrire_meta('low_sec', $low_sec = creer_pass_aleatoire());
163
-		}
164
-	} else {
165
-		$low_sec = sql_getfetsel('low_sec', 'spip_auteurs', 'id_auteur = ' . (int) $id_auteur);
166
-		if (!$low_sec) {
167
-			$low_sec = creer_pass_aleatoire();
168
-			sql_updateq('spip_auteurs', ['low_sec' => $low_sec], 'id_auteur = ' . (int) $id_auteur);
169
-		}
170
-	}
171
-
172
-	return $low_sec;
158
+    // Pas d'id_auteur : low_sec
159
+    if (!$id_auteur = (int) $id_auteur) {
160
+        include_spip('inc/config');
161
+        if (!$low_sec = lire_config('low_sec')) {
162
+            ecrire_meta('low_sec', $low_sec = creer_pass_aleatoire());
163
+        }
164
+    } else {
165
+        $low_sec = sql_getfetsel('low_sec', 'spip_auteurs', 'id_auteur = ' . (int) $id_auteur);
166
+        if (!$low_sec) {
167
+            $low_sec = creer_pass_aleatoire();
168
+            sql_updateq('spip_auteurs', ['low_sec' => $low_sec], 'id_auteur = ' . (int) $id_auteur);
169
+        }
170
+    }
171
+
172
+    return $low_sec;
173 173
 }
174 174
 
175 175
 
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
  * @filtre
203 203
  */
204 204
 function securiser_acces_low_sec($id_auteur, #[\SensitiveParameter] $cle, $dir, $op = '', $args = '') {
205
-	if ($op) {
206
-		$dir .= " $op $args";
207
-	}
205
+    if ($op) {
206
+        $dir .= " $op $args";
207
+    }
208 208
 
209
-	return verifier_low_sec($id_auteur, $cle, $dir);
209
+    return verifier_low_sec($id_auteur, $cle, $dir);
210 210
 }
211 211
 
212 212
 /**
@@ -214,11 +214,11 @@  discard block
 block discarded – undo
214 214
  * @return string
215 215
  */
216 216
 function generer_url_api_low_sec(string $script, string $format, string $fond, string $path, string $args, bool $no_entities = false, ?bool $public = null) {
217
-	$id_auteur = $GLOBALS['visiteur_session']['id_auteur'] ?? 0;
218
-	$cle = afficher_low_sec($id_auteur, "$script/$format $fond $args");
219
-	$path = "$id_auteur/$cle/$format/$fond" . ($path ? "/$path" : '');
217
+    $id_auteur = $GLOBALS['visiteur_session']['id_auteur'] ?? 0;
218
+    $cle = afficher_low_sec($id_auteur, "$script/$format $fond $args");
219
+    $path = "$id_auteur/$cle/$format/$fond" . ($path ? "/$path" : '');
220 220
 
221
-	return generer_url_api($script, $path, $args, $no_entities, $public);
221
+    return generer_url_api($script, $path, $args, $no_entities, $public);
222 222
 }
223 223
 
224 224
 /**
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
  *     Clé
235 235
  **/
236 236
 function afficher_low_sec($id_auteur, $action = '') {
237
-	return substr(md5($action . low_sec($id_auteur)), 0, 8);
237
+    return substr(md5($action . low_sec($id_auteur)), 0, 8);
238 238
 }
239 239
 
240 240
 /**
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
  *     true si les clés corresponde, false sinon
253 253
  **/
254 254
 function verifier_low_sec($id_auteur, #[\SensitiveParameter] $cle, $action = '') {
255
-	return ($cle == afficher_low_sec($id_auteur, $action));
255
+    return ($cle == afficher_low_sec($id_auteur, $action));
256 256
 }
257 257
 
258 258
 /**
@@ -262,10 +262,10 @@  discard block
 block discarded – undo
262 262
  *     Identifiant de l'auteur
263 263
  **/
264 264
 function effacer_low_sec($id_auteur) {
265
-	if (!$id_auteur = (int) $id_auteur) {
266
-		return;
267
-	} // jamais trop prudent ;)
268
-	sql_updateq('spip_auteurs', ['low_sec' => ''], 'id_auteur = ' . (int) $id_auteur);
265
+    if (!$id_auteur = (int) $id_auteur) {
266
+        return;
267
+    } // jamais trop prudent ;)
268
+    sql_updateq('spip_auteurs', ['low_sec' => ''], 'id_auteur = ' . (int) $id_auteur);
269 269
 }
270 270
 
271 271
 
@@ -283,29 +283,29 @@  discard block
 block discarded – undo
283 283
  *     - void sinon.
284 284
  **/
285 285
 function ecrire_acces() {
286
-	$htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME;
287
-	$htpasswd = _DIR_TMP . _AUTH_USER_FILE;
288
-
289
-	// Cette variable de configuration peut etre posee par un plugin
290
-	// par exemple acces_restreint ;
291
-	// si .htaccess existe, outrepasser spip_meta
292
-	if (
293
-		(!isset($GLOBALS['meta']['creer_htpasswd']) || $GLOBALS['meta']['creer_htpasswd'] != 'oui') && !@file_exists($htaccess)
294
-	) {
295
-		spip_unlink($htpasswd);
296
-		spip_unlink($htpasswd . '-admin');
297
-		return;
298
-	}
299
-
300
-	# remarque : ici on laisse passer les "nouveau" de maniere a leur permettre
301
-	# de devenir redacteur le cas echeant (auth http)... a nettoyer
302
-	// attention, il faut au prealable se connecter a la base (necessaire car utilise par install)
303
-	// TODO: factoriser avec auth/spip qui fait deja ce job et generaliser le test auth_ldap_connect()
304
-	if (include_spip('auth/ldap') && auth_ldap_connect()) {
305
-		return;
306
-	}
307
-
308
-	generer_htpasswd_files($htpasswd, "$htpasswd-admin");
286
+    $htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME;
287
+    $htpasswd = _DIR_TMP . _AUTH_USER_FILE;
288
+
289
+    // Cette variable de configuration peut etre posee par un plugin
290
+    // par exemple acces_restreint ;
291
+    // si .htaccess existe, outrepasser spip_meta
292
+    if (
293
+        (!isset($GLOBALS['meta']['creer_htpasswd']) || $GLOBALS['meta']['creer_htpasswd'] != 'oui') && !@file_exists($htaccess)
294
+    ) {
295
+        spip_unlink($htpasswd);
296
+        spip_unlink($htpasswd . '-admin');
297
+        return;
298
+    }
299
+
300
+    # remarque : ici on laisse passer les "nouveau" de maniere a leur permettre
301
+    # de devenir redacteur le cas echeant (auth http)... a nettoyer
302
+    // attention, il faut au prealable se connecter a la base (necessaire car utilise par install)
303
+    // TODO: factoriser avec auth/spip qui fait deja ce job et generaliser le test auth_ldap_connect()
304
+    if (include_spip('auth/ldap') && auth_ldap_connect()) {
305
+        return;
306
+    }
307
+
308
+    generer_htpasswd_files($htpasswd, "$htpasswd-admin");
309 309
 }
310 310
 
311 311
 /**
@@ -314,29 +314,29 @@  discard block
 block discarded – undo
314 314
  * @param string $htpasswd_admin
315 315
  */
316 316
 function generer_htpasswd_files($htpasswd, $htpasswd_admin) {
317
-	if ($generer_htpasswd = charger_fonction('generer_htpasswd_files', 'inc', true)) {
318
-		$generer_htpasswd($htpasswd, $htpasswd_admin);
319
-	}
320
-
321
-	$pwd_all = ''; // login:htpass pour tous
322
-	$pwd_admin = ''; // login:htpass pour les admins
323
-
324
-	$res = sql_select('login, htpass, statut', 'spip_auteurs', "htpass!='' AND login!='' AND " . sql_in('statut', ['1comite', '0minirezo', 'nouveau']));
325
-	while ($row = sql_fetch($res)) {
326
-		if (strlen((string) $row['login']) && strlen((string) $row['htpass'])) {
327
-			$ligne = $row['login'] . ':' . $row['htpass'] . "\n";
328
-			$pwd_all .= $ligne;
329
-			if ($row['statut'] == '0minirezo') {
330
-				$pwd_admin .= $ligne;
331
-			}
332
-		}
333
-	}
334
-
335
-	if ($pwd_all) {
336
-		ecrire_fichier($htpasswd, $pwd_all);
337
-		ecrire_fichier($htpasswd_admin, $pwd_admin);
338
-		spip_log("Ecriture de $htpasswd et $htpasswd_admin", 'htpass');
339
-	}
317
+    if ($generer_htpasswd = charger_fonction('generer_htpasswd_files', 'inc', true)) {
318
+        $generer_htpasswd($htpasswd, $htpasswd_admin);
319
+    }
320
+
321
+    $pwd_all = ''; // login:htpass pour tous
322
+    $pwd_admin = ''; // login:htpass pour les admins
323
+
324
+    $res = sql_select('login, htpass, statut', 'spip_auteurs', "htpass!='' AND login!='' AND " . sql_in('statut', ['1comite', '0minirezo', 'nouveau']));
325
+    while ($row = sql_fetch($res)) {
326
+        if (strlen((string) $row['login']) && strlen((string) $row['htpass'])) {
327
+            $ligne = $row['login'] . ':' . $row['htpass'] . "\n";
328
+            $pwd_all .= $ligne;
329
+            if ($row['statut'] == '0minirezo') {
330
+                $pwd_admin .= $ligne;
331
+            }
332
+        }
333
+    }
334
+
335
+    if ($pwd_all) {
336
+        ecrire_fichier($htpasswd, $pwd_all);
337
+        ecrire_fichier($htpasswd_admin, $pwd_admin);
338
+        spip_log("Ecriture de $htpasswd et $htpasswd_admin", 'htpass');
339
+    }
340 340
 }
341 341
 
342 342
 /**
@@ -350,11 +350,11 @@  discard block
 block discarded – undo
350 350
  *  La chaîne hachée si fonction crypt présente, rien sinon.
351 351
  */
352 352
 function generer_htpass(#[\SensitiveParameter] $pass) {
353
-	if ($generer_htpass = charger_fonction('generer_htpass', 'inc', true)) {
354
-		return $generer_htpass($pass);
355
-	}
353
+    if ($generer_htpass = charger_fonction('generer_htpass', 'inc', true)) {
354
+        return $generer_htpass($pass);
355
+    }
356 356
 
357
-	return '';
357
+    return '';
358 358
 }
359 359
 
360 360
 /**
@@ -367,14 +367,14 @@  discard block
 block discarded – undo
367 367
  * @return boolean
368 368
  */
369 369
 function verifier_htaccess($rep, $force = false) {
370
-	$htaccess = rtrim($rep, '/') . '/' . _ACCESS_FILE_NAME;
371
-	if ((@file_exists($htaccess) || defined('_TEST_DIRS')) && !$force) {
372
-		return true;
373
-	}
374
-
375
-	// directive deny compatible Apache 2.0+
376
-	$deny =
377
-		'# Deny all requests from Apache 2.4+.
370
+    $htaccess = rtrim($rep, '/') . '/' . _ACCESS_FILE_NAME;
371
+    if ((@file_exists($htaccess) || defined('_TEST_DIRS')) && !$force) {
372
+        return true;
373
+    }
374
+
375
+    // directive deny compatible Apache 2.0+
376
+    $deny =
377
+        '# Deny all requests from Apache 2.4+.
378 378
 <IfModule mod_authz_core.c>
379 379
   Require all denied
380 380
 </IfModule>
@@ -383,30 +383,30 @@  discard block
 block discarded – undo
383 383
   Deny from all
384 384
 </IfModule>
385 385
 ';
386
-	// support des vieilles versions Apache 1.x mais uniquement si elles l'annoncent (pas en mode PROD)
387
-	if (
388
-		function_exists('apache_get_version') && ($v = apache_get_version()) && str_starts_with($v, 'Apache/1.')
389
-	) {
390
-		$deny = "deny from all\n";
391
-	}
392
-
393
-	if ($ht = @fopen($htaccess, 'w')) {
394
-		fwrite($ht, $deny);
395
-		fclose($ht);
396
-		@chmod($htaccess, _SPIP_CHMOD & 0666);
397
-		$t = rtrim($rep, '/') . '/.ok';
398
-		if ($ht = @fopen($t, 'w')) {
399
-			@fclose($ht);
400
-			include_spip('inc/distant');
401
-			$t = substr($t, strlen(_DIR_RACINE));
402
-			$t = url_de_base() . $t;
403
-			$ht = recuperer_url($t, ['methode' => 'HEAD', 'taille_max' => 0, 'follow_location' => false]);
404
-			$ht = ($ht['status'] ?? null) === 403;
405
-		}
406
-	}
407
-	spip_log("Creation de $htaccess " . ($ht ? ' reussie' : ' manquee'));
408
-
409
-	return $ht;
386
+    // support des vieilles versions Apache 1.x mais uniquement si elles l'annoncent (pas en mode PROD)
387
+    if (
388
+        function_exists('apache_get_version') && ($v = apache_get_version()) && str_starts_with($v, 'Apache/1.')
389
+    ) {
390
+        $deny = "deny from all\n";
391
+    }
392
+
393
+    if ($ht = @fopen($htaccess, 'w')) {
394
+        fwrite($ht, $deny);
395
+        fclose($ht);
396
+        @chmod($htaccess, _SPIP_CHMOD & 0666);
397
+        $t = rtrim($rep, '/') . '/.ok';
398
+        if ($ht = @fopen($t, 'w')) {
399
+            @fclose($ht);
400
+            include_spip('inc/distant');
401
+            $t = substr($t, strlen(_DIR_RACINE));
402
+            $t = url_de_base() . $t;
403
+            $ht = recuperer_url($t, ['methode' => 'HEAD', 'taille_max' => 0, 'follow_location' => false]);
404
+            $ht = ($ht['status'] ?? null) === 403;
405
+        }
406
+    }
407
+    spip_log("Creation de $htaccess " . ($ht ? ' reussie' : ' manquee'));
408
+
409
+    return $ht;
410 410
 }
411 411
 
412 412
 /**
@@ -424,20 +424,20 @@  discard block
 block discarded – undo
424 424
  *         Valeur de la configuration `creer_htaccess`
425 425
  */
426 426
 function gerer_htaccess() {
427
-	// Cette variable de configuration peut etre posee par un plugin
428
-	// par exemple acces_restreint
429
-	$f = (isset($GLOBALS['meta']['creer_htaccess']) && $GLOBALS['meta']['creer_htaccess'] === 'oui');
430
-	$dirs = sql_allfetsel('extension', 'spip_types_documents');
431
-	$dirs[] = ['extension' => 'distant'];
432
-	foreach ($dirs as $e) {
433
-		if (is_dir($dir = _DIR_IMG . $e['extension'])) {
434
-			if ($f) {
435
-				verifier_htaccess($dir);
436
-			} else {
437
-				spip_unlink($dir . '/' . _ACCESS_FILE_NAME);
438
-			}
439
-		}
440
-	}
441
-
442
-	return $GLOBALS['meta']['creer_htaccess'] ?? '';
427
+    // Cette variable de configuration peut etre posee par un plugin
428
+    // par exemple acces_restreint
429
+    $f = (isset($GLOBALS['meta']['creer_htaccess']) && $GLOBALS['meta']['creer_htaccess'] === 'oui');
430
+    $dirs = sql_allfetsel('extension', 'spip_types_documents');
431
+    $dirs[] = ['extension' => 'distant'];
432
+    foreach ($dirs as $e) {
433
+        if (is_dir($dir = _DIR_IMG . $e['extension'])) {
434
+            if ($f) {
435
+                verifier_htaccess($dir);
436
+            } else {
437
+                spip_unlink($dir . '/' . _ACCESS_FILE_NAME);
438
+            }
439
+        }
440
+    }
441
+
442
+    return $GLOBALS['meta']['creer_htaccess'] ?? '';
443 443
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
  *     Mot de passe
31 31
  **/
32 32
 function creer_pass_aleatoire($longueur = 16, $sel = '') {
33
-	$seed = (int)round(((float)microtime() + 1) * time());
33
+	$seed = (int) round(((float) microtime() + 1) * time());
34 34
 
35 35
 	mt_srand($seed);
36 36
 	$s = '';
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
 			if (!$s) {
42 42
 				$s = random_int(0, mt_getrandmax());
43 43
 			}
44
-			$s = substr(md5(uniqid($s) . $sel), 0, 16);
44
+			$s = substr(md5(uniqid($s).$sel), 0, 16);
45 45
 		}
46
-		$r = unpack('Cr', pack('H2', $s . $s));
46
+		$r = unpack('Cr', pack('H2', $s.$s));
47 47
 		$x = $r['r'] & 63;
48 48
 		if ($x < 10) {
49 49
 			$x = chr($x + 48);
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	static $seeded;
77 77
 
78 78
 	if (!$seeded) {
79
-		$seed = (int)round(((float)microtime() + 1) * time());
79
+		$seed = (int) round(((float) microtime() + 1) * time());
80 80
 		mt_srand($seed);
81 81
 		$seeded = true;
82 82
 	}
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
 			ecrire_meta('low_sec', $low_sec = creer_pass_aleatoire());
163 163
 		}
164 164
 	} else {
165
-		$low_sec = sql_getfetsel('low_sec', 'spip_auteurs', 'id_auteur = ' . (int) $id_auteur);
165
+		$low_sec = sql_getfetsel('low_sec', 'spip_auteurs', 'id_auteur = '.(int) $id_auteur);
166 166
 		if (!$low_sec) {
167 167
 			$low_sec = creer_pass_aleatoire();
168
-			sql_updateq('spip_auteurs', ['low_sec' => $low_sec], 'id_auteur = ' . (int) $id_auteur);
168
+			sql_updateq('spip_auteurs', ['low_sec' => $low_sec], 'id_auteur = '.(int) $id_auteur);
169 169
 		}
170 170
 	}
171 171
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 function generer_url_api_low_sec(string $script, string $format, string $fond, string $path, string $args, bool $no_entities = false, ?bool $public = null) {
217 217
 	$id_auteur = $GLOBALS['visiteur_session']['id_auteur'] ?? 0;
218 218
 	$cle = afficher_low_sec($id_auteur, "$script/$format $fond $args");
219
-	$path = "$id_auteur/$cle/$format/$fond" . ($path ? "/$path" : '');
219
+	$path = "$id_auteur/$cle/$format/$fond".($path ? "/$path" : '');
220 220
 
221 221
 	return generer_url_api($script, $path, $args, $no_entities, $public);
222 222
 }
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
  *     Clé
235 235
  **/
236 236
 function afficher_low_sec($id_auteur, $action = '') {
237
-	return substr(md5($action . low_sec($id_auteur)), 0, 8);
237
+	return substr(md5($action.low_sec($id_auteur)), 0, 8);
238 238
 }
239 239
 
240 240
 /**
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 	if (!$id_auteur = (int) $id_auteur) {
266 266
 		return;
267 267
 	} // jamais trop prudent ;)
268
-	sql_updateq('spip_auteurs', ['low_sec' => ''], 'id_auteur = ' . (int) $id_auteur);
268
+	sql_updateq('spip_auteurs', ['low_sec' => ''], 'id_auteur = '.(int) $id_auteur);
269 269
 }
270 270
 
271 271
 
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
  *     - void sinon.
284 284
  **/
285 285
 function ecrire_acces() {
286
-	$htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME;
287
-	$htpasswd = _DIR_TMP . _AUTH_USER_FILE;
286
+	$htaccess = _DIR_RESTREINT._ACCESS_FILE_NAME;
287
+	$htpasswd = _DIR_TMP._AUTH_USER_FILE;
288 288
 
289 289
 	// Cette variable de configuration peut etre posee par un plugin
290 290
 	// par exemple acces_restreint ;
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 		(!isset($GLOBALS['meta']['creer_htpasswd']) || $GLOBALS['meta']['creer_htpasswd'] != 'oui') && !@file_exists($htaccess)
294 294
 	) {
295 295
 		spip_unlink($htpasswd);
296
-		spip_unlink($htpasswd . '-admin');
296
+		spip_unlink($htpasswd.'-admin');
297 297
 		return;
298 298
 	}
299 299
 
@@ -321,10 +321,10 @@  discard block
 block discarded – undo
321 321
 	$pwd_all = ''; // login:htpass pour tous
322 322
 	$pwd_admin = ''; // login:htpass pour les admins
323 323
 
324
-	$res = sql_select('login, htpass, statut', 'spip_auteurs', "htpass!='' AND login!='' AND " . sql_in('statut', ['1comite', '0minirezo', 'nouveau']));
324
+	$res = sql_select('login, htpass, statut', 'spip_auteurs', "htpass!='' AND login!='' AND ".sql_in('statut', ['1comite', '0minirezo', 'nouveau']));
325 325
 	while ($row = sql_fetch($res)) {
326 326
 		if (strlen((string) $row['login']) && strlen((string) $row['htpass'])) {
327
-			$ligne = $row['login'] . ':' . $row['htpass'] . "\n";
327
+			$ligne = $row['login'].':'.$row['htpass']."\n";
328 328
 			$pwd_all .= $ligne;
329 329
 			if ($row['statut'] == '0minirezo') {
330 330
 				$pwd_admin .= $ligne;
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
  * @return boolean
368 368
  */
369 369
 function verifier_htaccess($rep, $force = false) {
370
-	$htaccess = rtrim($rep, '/') . '/' . _ACCESS_FILE_NAME;
370
+	$htaccess = rtrim($rep, '/').'/'._ACCESS_FILE_NAME;
371 371
 	if ((@file_exists($htaccess) || defined('_TEST_DIRS')) && !$force) {
372 372
 		return true;
373 373
 	}
@@ -394,17 +394,17 @@  discard block
 block discarded – undo
394 394
 		fwrite($ht, $deny);
395 395
 		fclose($ht);
396 396
 		@chmod($htaccess, _SPIP_CHMOD & 0666);
397
-		$t = rtrim($rep, '/') . '/.ok';
397
+		$t = rtrim($rep, '/').'/.ok';
398 398
 		if ($ht = @fopen($t, 'w')) {
399 399
 			@fclose($ht);
400 400
 			include_spip('inc/distant');
401 401
 			$t = substr($t, strlen(_DIR_RACINE));
402
-			$t = url_de_base() . $t;
402
+			$t = url_de_base().$t;
403 403
 			$ht = recuperer_url($t, ['methode' => 'HEAD', 'taille_max' => 0, 'follow_location' => false]);
404 404
 			$ht = ($ht['status'] ?? null) === 403;
405 405
 		}
406 406
 	}
407
-	spip_log("Creation de $htaccess " . ($ht ? ' reussie' : ' manquee'));
407
+	spip_log("Creation de $htaccess ".($ht ? ' reussie' : ' manquee'));
408 408
 
409 409
 	return $ht;
410 410
 }
@@ -430,11 +430,11 @@  discard block
 block discarded – undo
430 430
 	$dirs = sql_allfetsel('extension', 'spip_types_documents');
431 431
 	$dirs[] = ['extension' => 'distant'];
432 432
 	foreach ($dirs as $e) {
433
-		if (is_dir($dir = _DIR_IMG . $e['extension'])) {
433
+		if (is_dir($dir = _DIR_IMG.$e['extension'])) {
434 434
 			if ($f) {
435 435
 				verifier_htaccess($dir);
436 436
 			} else {
437
-				spip_unlink($dir . '/' . _ACCESS_FILE_NAME);
437
+				spip_unlink($dir.'/'._ACCESS_FILE_NAME);
438 438
 			}
439 439
 		}
440 440
 	}
Please login to merge, or discard this patch.