Completed
Push — master ( a07606...4c3c71 )
by cam
02:01
created
ecrire/auth/spip.php 2 patches
Indentation   +327 added lines, -327 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -32,110 +32,110 @@  discard block
 block discarded – undo
32 32
  */
33 33
 function auth_spip_dist($login, $pass, $serveur = '', $phpauth = false) {
34 34
 
35
-	// retrouver le login
36
-	$login = auth_spip_retrouver_login($login);
37
-	// login inconnu, n'allons pas plus loin
38
-	if (!$login) {
39
-		return [];
40
-	}
41
-
42
-	$md5pass = '';
43
-	$shapass = $shanext = '';
44
-
45
-	if (preg_match(',^\{([0-9a-f]{64});([0-9a-f]{64})\}$,i', $pass, $regs)) {
46
-		$shapass = $regs[1];
47
-		$shanext = $regs[2];
48
-	} // compat avec une base mixte md5/sha256 : le js a envoye les 2 hash
49
-	elseif (preg_match(',^\{([0-9a-f]{64});([0-9a-f]{64});([0-9a-f]{32});([0-9a-f]{32})\}$,i', $pass, $regs)) {
50
-		$shapass = $regs[1];
51
-		$shanext = $regs[2];
52
-		$md5pass = $regs[3];
53
-		//$md5next = $regs[4];
54
-	} // si envoi non crypte, crypter maintenant
55
-	elseif ($pass) {
56
-		$row = sql_fetsel(
57
-			'alea_actuel, alea_futur',
58
-			'spip_auteurs',
59
-			'login=' . sql_quote($login, $serveur, 'text'),
60
-			'',
61
-			'',
62
-			'',
63
-			'',
64
-			$serveur
65
-		);
66
-
67
-		if ($row) {
68
-			include_spip('auth/sha256.inc');
69
-			$shapass = spip_sha256($row['alea_actuel'] . $pass);
70
-			$shanext = spip_sha256($row['alea_futur'] . $pass);
71
-			$md5pass = md5($row['alea_actuel'] . $pass);
72
-		}
73
-	}
74
-
75
-	// login inexistant ou mot de passe vide
76
-	if (!$shapass and !$md5pass) {
77
-		return [];
78
-	}
79
-
80
-	$row = sql_fetsel(
81
-		'*',
82
-		'spip_auteurs',
83
-		'login=' . sql_quote($login, $serveur, 'text') . ' AND pass=' . sql_quote(
84
-			$shapass,
85
-			$serveur,
86
-			'text'
87
-		) . " AND statut<>'5poubelle'",
88
-		'',
89
-		'',
90
-		'',
91
-		'',
92
-		$serveur
93
-	);
94
-
95
-	// compat avec les anciennes bases en md5
96
-	if (!$row and $md5pass) {
97
-		$row = sql_fetsel(
98
-			'*',
99
-			'spip_auteurs',
100
-			'login=' . sql_quote($login, $serveur, 'text') . ' AND pass=' . sql_quote(
101
-				$md5pass,
102
-				$serveur,
103
-				'text'
104
-			) . " AND statut<>'5poubelle'",
105
-			'',
106
-			'',
107
-			'',
108
-			'',
109
-			$serveur
110
-		);
111
-	}
112
-
113
-	// login/mot de passe incorrect
114
-	if (!$row) {
115
-		return [];
116
-	}
117
-
118
-	// fait tourner le codage du pass dans la base
119
-	// sauf si phpauth : cela reviendrait a changer l'alea a chaque hit, et aucune action verifiable par securiser_action()
120
-	if ($shanext and !$phpauth) {
121
-		include_spip('inc/acces'); // pour creer_uniqid
122
-		@sql_update('spip_auteurs', [
123
-			'alea_actuel' => 'alea_futur',
124
-			'pass' => sql_quote($shanext, $serveur, 'text'),
125
-			'alea_futur' => sql_quote(creer_uniqid(), $serveur, 'text')
126
-		], 'id_auteur=' . $row['id_auteur'] . ' AND pass IN (' . sql_quote(
127
-			$shapass,
128
-			$serveur,
129
-			'text'
130
-		) . ', ' . sql_quote($md5pass, $serveur, 'text') . ')', '', $serveur);
131
-		// En profiter pour verifier la securite de tmp/
132
-		// Si elle ne fonctionne pas a l'installation, prevenir
133
-		if (!verifier_htaccess(_DIR_TMP) and defined('_ECRIRE_INSTALL')) {
134
-			return false;
135
-		}
136
-	}
137
-
138
-	return $row;
35
+    // retrouver le login
36
+    $login = auth_spip_retrouver_login($login);
37
+    // login inconnu, n'allons pas plus loin
38
+    if (!$login) {
39
+        return [];
40
+    }
41
+
42
+    $md5pass = '';
43
+    $shapass = $shanext = '';
44
+
45
+    if (preg_match(',^\{([0-9a-f]{64});([0-9a-f]{64})\}$,i', $pass, $regs)) {
46
+        $shapass = $regs[1];
47
+        $shanext = $regs[2];
48
+    } // compat avec une base mixte md5/sha256 : le js a envoye les 2 hash
49
+    elseif (preg_match(',^\{([0-9a-f]{64});([0-9a-f]{64});([0-9a-f]{32});([0-9a-f]{32})\}$,i', $pass, $regs)) {
50
+        $shapass = $regs[1];
51
+        $shanext = $regs[2];
52
+        $md5pass = $regs[3];
53
+        //$md5next = $regs[4];
54
+    } // si envoi non crypte, crypter maintenant
55
+    elseif ($pass) {
56
+        $row = sql_fetsel(
57
+            'alea_actuel, alea_futur',
58
+            'spip_auteurs',
59
+            'login=' . sql_quote($login, $serveur, 'text'),
60
+            '',
61
+            '',
62
+            '',
63
+            '',
64
+            $serveur
65
+        );
66
+
67
+        if ($row) {
68
+            include_spip('auth/sha256.inc');
69
+            $shapass = spip_sha256($row['alea_actuel'] . $pass);
70
+            $shanext = spip_sha256($row['alea_futur'] . $pass);
71
+            $md5pass = md5($row['alea_actuel'] . $pass);
72
+        }
73
+    }
74
+
75
+    // login inexistant ou mot de passe vide
76
+    if (!$shapass and !$md5pass) {
77
+        return [];
78
+    }
79
+
80
+    $row = sql_fetsel(
81
+        '*',
82
+        'spip_auteurs',
83
+        'login=' . sql_quote($login, $serveur, 'text') . ' AND pass=' . sql_quote(
84
+            $shapass,
85
+            $serveur,
86
+            'text'
87
+        ) . " AND statut<>'5poubelle'",
88
+        '',
89
+        '',
90
+        '',
91
+        '',
92
+        $serveur
93
+    );
94
+
95
+    // compat avec les anciennes bases en md5
96
+    if (!$row and $md5pass) {
97
+        $row = sql_fetsel(
98
+            '*',
99
+            'spip_auteurs',
100
+            'login=' . sql_quote($login, $serveur, 'text') . ' AND pass=' . sql_quote(
101
+                $md5pass,
102
+                $serveur,
103
+                'text'
104
+            ) . " AND statut<>'5poubelle'",
105
+            '',
106
+            '',
107
+            '',
108
+            '',
109
+            $serveur
110
+        );
111
+    }
112
+
113
+    // login/mot de passe incorrect
114
+    if (!$row) {
115
+        return [];
116
+    }
117
+
118
+    // fait tourner le codage du pass dans la base
119
+    // sauf si phpauth : cela reviendrait a changer l'alea a chaque hit, et aucune action verifiable par securiser_action()
120
+    if ($shanext and !$phpauth) {
121
+        include_spip('inc/acces'); // pour creer_uniqid
122
+        @sql_update('spip_auteurs', [
123
+            'alea_actuel' => 'alea_futur',
124
+            'pass' => sql_quote($shanext, $serveur, 'text'),
125
+            'alea_futur' => sql_quote(creer_uniqid(), $serveur, 'text')
126
+        ], 'id_auteur=' . $row['id_auteur'] . ' AND pass IN (' . sql_quote(
127
+            $shapass,
128
+            $serveur,
129
+            'text'
130
+        ) . ', ' . sql_quote($md5pass, $serveur, 'text') . ')', '', $serveur);
131
+        // En profiter pour verifier la securite de tmp/
132
+        // Si elle ne fonctionne pas a l'installation, prevenir
133
+        if (!verifier_htaccess(_DIR_TMP) and defined('_ECRIRE_INSTALL')) {
134
+            return false;
135
+        }
136
+    }
137
+
138
+    return $row;
139 139
 }
140 140
 
141 141
 /**
@@ -145,41 +145,41 @@  discard block
 block discarded – undo
145 145
  * @return array
146 146
  */
147 147
 function auth_spip_formulaire_login($flux) {
148
-	// faut il encore envoyer md5 ?
149
-	// on regarde si il reste des pass md5 en base pour des auteurs en statut pas poubelle
150
-	// les hash md5 ont une longueur 32, les sha 64
151
-	// en evitant une requete sql a chaque affichage du formulaire login sans session
152
-	// (perf issue pour les sites qui mettent le formulaire de login sur la home)
153
-	$compat_md5 = false;
154
-	if (!isset($GLOBALS['meta']['sha_256_only']) or _request('var_mode')) {
155
-		$compat_md5 = sql_countsel('spip_auteurs', "length(pass)=32 AND statut<>'poubelle'");
156
-		if ($compat_md5 and isset($GLOBALS['meta']['sha_256_only'])) {
157
-			effacer_meta('sha_256_only');
158
-		}
159
-		if (!$compat_md5) {
160
-			ecrire_meta('sha_256_only', 'oui');
161
-		}
162
-	}
163
-
164
-	// javascript qui gere la securite du login en evitant de faire circuler le pass en clair
165
-	$flux['data'] .=
166
-		($compat_md5 ? '<script type="text/javascript" src="' . _DIR_JAVASCRIPT . 'md5.js"></script>' : '')
167
-		. '<script type="text/javascript" src="' . _DIR_JAVASCRIPT . 'login-sha-min.js"></script>'
168
-		. '<script type="text/javascript">/*<![CDATA[*/'
169
-		. "var login_info={'alea_actuel':'" . $flux['args']['contexte']['_alea_actuel'] . "',"
170
-		. "'alea_futur':'" . $flux['args']['contexte']['_alea_futur'] . "',"
171
-		. "'login':'" . $flux['args']['contexte']['var_login'] . "',"
172
-		. "'page_auteur': '" . generer_url_public('informer_auteur') . "',"
173
-		. "'informe_auteur_en_cours':false,"
174
-		. "'attente_informe':0,"
175
-		. "'compat_md5':" . ($compat_md5 ? 'true' : 'false') . '};'
176
-		. "jQuery(function(){
148
+    // faut il encore envoyer md5 ?
149
+    // on regarde si il reste des pass md5 en base pour des auteurs en statut pas poubelle
150
+    // les hash md5 ont une longueur 32, les sha 64
151
+    // en evitant une requete sql a chaque affichage du formulaire login sans session
152
+    // (perf issue pour les sites qui mettent le formulaire de login sur la home)
153
+    $compat_md5 = false;
154
+    if (!isset($GLOBALS['meta']['sha_256_only']) or _request('var_mode')) {
155
+        $compat_md5 = sql_countsel('spip_auteurs', "length(pass)=32 AND statut<>'poubelle'");
156
+        if ($compat_md5 and isset($GLOBALS['meta']['sha_256_only'])) {
157
+            effacer_meta('sha_256_only');
158
+        }
159
+        if (!$compat_md5) {
160
+            ecrire_meta('sha_256_only', 'oui');
161
+        }
162
+    }
163
+
164
+    // javascript qui gere la securite du login en evitant de faire circuler le pass en clair
165
+    $flux['data'] .=
166
+        ($compat_md5 ? '<script type="text/javascript" src="' . _DIR_JAVASCRIPT . 'md5.js"></script>' : '')
167
+        . '<script type="text/javascript" src="' . _DIR_JAVASCRIPT . 'login-sha-min.js"></script>'
168
+        . '<script type="text/javascript">/*<![CDATA[*/'
169
+        . "var login_info={'alea_actuel':'" . $flux['args']['contexte']['_alea_actuel'] . "',"
170
+        . "'alea_futur':'" . $flux['args']['contexte']['_alea_futur'] . "',"
171
+        . "'login':'" . $flux['args']['contexte']['var_login'] . "',"
172
+        . "'page_auteur': '" . generer_url_public('informer_auteur') . "',"
173
+        . "'informe_auteur_en_cours':false,"
174
+        . "'attente_informe':0,"
175
+        . "'compat_md5':" . ($compat_md5 ? 'true' : 'false') . '};'
176
+        . "jQuery(function(){
177 177
 	jQuery('#var_login').change(actualise_auteur);
178 178
 	jQuery('form#formulaire_login').submit(login_submit);
179 179
 });"
180
-		. '/*]]>*/</script>';
180
+        . '/*]]>*/</script>';
181 181
 
182
-	return $flux;
182
+    return $flux;
183 183
 }
184 184
 
185 185
 
@@ -191,10 +191,10 @@  discard block
 block discarded – undo
191 191
  *   toujours true pour un auteur cree dans SPIP
192 192
  */
193 193
 function auth_spip_autoriser_modifier_login($serveur = '') {
194
-	if (strlen($serveur)) {
195
-		return false;
196
-	} // les fonctions d'ecriture sur base distante sont encore incompletes
197
-	return true;
194
+    if (strlen($serveur)) {
195
+        return false;
196
+    } // les fonctions d'ecriture sur base distante sont encore incompletes
197
+    return true;
198 198
 }
199 199
 
200 200
 /**
@@ -208,25 +208,25 @@  discard block
 block discarded – undo
208 208
  *  message d'erreur si login non valide, chaine vide sinon
209 209
  */
210 210
 function auth_spip_verifier_login($new_login, $id_auteur = 0, $serveur = '') {
211
-	// login et mot de passe
212
-	if (strlen($new_login)) {
213
-		if (strlen($new_login) < _LOGIN_TROP_COURT) {
214
-			return _T('info_login_trop_court_car_pluriel', ['nb' => _LOGIN_TROP_COURT]);
215
-		} else {
216
-			$n = sql_countsel(
217
-				'spip_auteurs',
218
-				'login=' . sql_quote($new_login) . ' AND id_auteur!=' . intval($id_auteur) . " AND statut!='5poubelle'",
219
-				'',
220
-				'',
221
-				$serveur
222
-			);
223
-			if ($n) {
224
-				return _T('info_login_existant');
225
-			}
226
-		}
227
-	}
228
-
229
-	return '';
211
+    // login et mot de passe
212
+    if (strlen($new_login)) {
213
+        if (strlen($new_login) < _LOGIN_TROP_COURT) {
214
+            return _T('info_login_trop_court_car_pluriel', ['nb' => _LOGIN_TROP_COURT]);
215
+        } else {
216
+            $n = sql_countsel(
217
+                'spip_auteurs',
218
+                'login=' . sql_quote($new_login) . ' AND id_auteur!=' . intval($id_auteur) . " AND statut!='5poubelle'",
219
+                '',
220
+                '',
221
+                $serveur
222
+            );
223
+            if ($n) {
224
+                return _T('info_login_existant');
225
+            }
226
+        }
227
+    }
228
+
229
+    return '';
230 230
 }
231 231
 
232 232
 /**
@@ -238,41 +238,41 @@  discard block
 block discarded – undo
238 238
  * @return bool
239 239
  */
240 240
 function auth_spip_modifier_login($new_login, $id_auteur, $serveur = '') {
241
-	if (is_null($new_login) or auth_spip_verifier_login($new_login, $id_auteur, $serveur) != '') {
242
-		return false;
243
-	}
244
-	if (
245
-		!$id_auteur = intval($id_auteur)
246
-		or !$auteur = sql_fetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur)
247
-	) {
248
-		return false;
249
-	}
250
-	if ($new_login == $auteur['login']) {
251
-		return true;
252
-	} // on a rien fait mais c'est bon !
253
-
254
-	include_spip('action/editer_auteur');
255
-
256
-	// vider le login des auteurs a la poubelle qui avaient ce meme login
257
-	if (strlen($new_login)) {
258
-		$anciens = sql_allfetsel(
259
-			'id_auteur',
260
-			'spip_auteurs',
261
-			'login=' . sql_quote($new_login, $serveur, 'text') . " AND statut='5poubelle'",
262
-			'',
263
-			'',
264
-			'',
265
-			'',
266
-			$serveur
267
-		);
268
-		while ($row = array_pop($anciens)) {
269
-			auteur_modifier($row['id_auteur'], ['login' => ''], true); // manque la gestion de $serveur
270
-		}
271
-	}
272
-
273
-	auteur_modifier($id_auteur, ['login' => $new_login], true); // manque la gestion de $serveur
274
-
275
-	return true;
241
+    if (is_null($new_login) or auth_spip_verifier_login($new_login, $id_auteur, $serveur) != '') {
242
+        return false;
243
+    }
244
+    if (
245
+        !$id_auteur = intval($id_auteur)
246
+        or !$auteur = sql_fetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur)
247
+    ) {
248
+        return false;
249
+    }
250
+    if ($new_login == $auteur['login']) {
251
+        return true;
252
+    } // on a rien fait mais c'est bon !
253
+
254
+    include_spip('action/editer_auteur');
255
+
256
+    // vider le login des auteurs a la poubelle qui avaient ce meme login
257
+    if (strlen($new_login)) {
258
+        $anciens = sql_allfetsel(
259
+            'id_auteur',
260
+            'spip_auteurs',
261
+            'login=' . sql_quote($new_login, $serveur, 'text') . " AND statut='5poubelle'",
262
+            '',
263
+            '',
264
+            '',
265
+            '',
266
+            $serveur
267
+        );
268
+        while ($row = array_pop($anciens)) {
269
+            auteur_modifier($row['id_auteur'], ['login' => ''], true); // manque la gestion de $serveur
270
+        }
271
+    }
272
+
273
+    auteur_modifier($id_auteur, ['login' => $new_login], true); // manque la gestion de $serveur
274
+
275
+    return true;
276 276
 }
277 277
 
278 278
 /**
@@ -284,44 +284,44 @@  discard block
 block discarded – undo
284 284
  * @return string
285 285
  */
286 286
 function auth_spip_retrouver_login($login, $serveur = '') {
287
-	if (!strlen($login)) {
288
-		return null;
289
-	} // pas la peine de requeter
290
-	$l = sql_quote($login, $serveur, 'text');
291
-	if (
292
-		$r = sql_getfetsel(
293
-			'login',
294
-			'spip_auteurs',
295
-			"statut<>'5poubelle'" .
296
-			' AND (length(pass)>0)' .
297
-			" AND (login=$l)",
298
-			'',
299
-			'',
300
-			'',
301
-			'',
302
-			$serveur
303
-		)
304
-	) {
305
-		return $r;
306
-	}
307
-	// Si pas d'auteur avec ce login
308
-	// regarder s'il a saisi son nom ou son mail.
309
-	// Ne pas fusionner avec la requete precedente
310
-	// car un nom peut etre homonyme d'un autre login
311
-	else {
312
-		return sql_getfetsel(
313
-			'login',
314
-			'spip_auteurs',
315
-			"statut<>'5poubelle'" .
316
-			' AND (length(pass)>0)' .
317
-			" AND (login<>'' AND (nom=$l OR email=$l))",
318
-			'',
319
-			'',
320
-			'',
321
-			'',
322
-			$serveur
323
-		);
324
-	}
287
+    if (!strlen($login)) {
288
+        return null;
289
+    } // pas la peine de requeter
290
+    $l = sql_quote($login, $serveur, 'text');
291
+    if (
292
+        $r = sql_getfetsel(
293
+            'login',
294
+            'spip_auteurs',
295
+            "statut<>'5poubelle'" .
296
+            ' AND (length(pass)>0)' .
297
+            " AND (login=$l)",
298
+            '',
299
+            '',
300
+            '',
301
+            '',
302
+            $serveur
303
+        )
304
+    ) {
305
+        return $r;
306
+    }
307
+    // Si pas d'auteur avec ce login
308
+    // regarder s'il a saisi son nom ou son mail.
309
+    // Ne pas fusionner avec la requete precedente
310
+    // car un nom peut etre homonyme d'un autre login
311
+    else {
312
+        return sql_getfetsel(
313
+            'login',
314
+            'spip_auteurs',
315
+            "statut<>'5poubelle'" .
316
+            ' AND (length(pass)>0)' .
317
+            " AND (login<>'' AND (nom=$l OR email=$l))",
318
+            '',
319
+            '',
320
+            '',
321
+            '',
322
+            $serveur
323
+        );
324
+    }
325 325
 }
326 326
 
327 327
 
@@ -339,11 +339,11 @@  discard block
 block discarded – undo
339 339
  */
340 340
 function auth_spip_informer_login($infos, $row, $serveur = '') {
341 341
 
342
-	// pour la methode SPIP on a besoin des alea en plus pour encoder le pass avec
343
-	$infos['alea_actuel'] = $row['alea_actuel'];
344
-	$infos['alea_futur'] = $row['alea_futur'];
342
+    // pour la methode SPIP on a besoin des alea en plus pour encoder le pass avec
343
+    $infos['alea_actuel'] = $row['alea_actuel'];
344
+    $infos['alea_futur'] = $row['alea_futur'];
345 345
 
346
-	return $infos;
346
+    return $infos;
347 347
 }
348 348
 
349 349
 /**
@@ -354,10 +354,10 @@  discard block
 block discarded – undo
354 354
  *  toujours true pour un auteur cree dans SPIP
355 355
  */
356 356
 function auth_spip_autoriser_modifier_pass($serveur = '') {
357
-	if (strlen($serveur)) {
358
-		return false;
359
-	} // les fonctions d'ecriture sur base distante sont encore incompletes
360
-	return true;
357
+    if (strlen($serveur)) {
358
+        return false;
359
+    } // les fonctions d'ecriture sur base distante sont encore incompletes
360
+    return true;
361 361
 }
362 362
 
363 363
 
@@ -378,12 +378,12 @@  discard block
 block discarded – undo
378 378
  *  message d'erreur si login non valide, chaine vide sinon
379 379
  */
380 380
 function auth_spip_verifier_pass($login, $new_pass, $id_auteur = 0, $serveur = '') {
381
-	// login et mot de passe
382
-	if (strlen($new_pass) < _PASS_LONGUEUR_MINI) {
383
-		return _T('info_passe_trop_court_car_pluriel', ['nb' => _PASS_LONGUEUR_MINI]);
384
-	}
381
+    // login et mot de passe
382
+    if (strlen($new_pass) < _PASS_LONGUEUR_MINI) {
383
+        return _T('info_passe_trop_court_car_pluriel', ['nb' => _PASS_LONGUEUR_MINI]);
384
+    }
385 385
 
386
-	return '';
386
+    return '';
387 387
 }
388 388
 
389 389
 /**
@@ -397,34 +397,34 @@  discard block
 block discarded – undo
397 397
  * @return bool
398 398
  */
399 399
 function auth_spip_modifier_pass($login, $new_pass, $id_auteur, $serveur = '') {
400
-	if (is_null($new_pass) or auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur) != '') {
401
-		return false;
402
-	}
403
-
404
-	if (
405
-		!$id_auteur = intval($id_auteur)
406
-		or !sql_fetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur)
407
-	) {
408
-		return false;
409
-	}
410
-
411
-	$c = [];
412
-	include_spip('inc/acces');
413
-	include_spip('auth/sha256.inc');
414
-	$htpass = generer_htpass($new_pass);
415
-	$alea_actuel = creer_uniqid();
416
-	$alea_futur = creer_uniqid();
417
-	$pass = spip_sha256($alea_actuel . $new_pass);
418
-	$c['pass'] = $pass;
419
-	$c['htpass'] = $htpass;
420
-	$c['alea_actuel'] = $alea_actuel;
421
-	$c['alea_futur'] = $alea_futur;
422
-	$c['low_sec'] = '';
423
-
424
-	include_spip('action/editer_auteur');
425
-	auteur_modifier($id_auteur, $c, true); // manque la gestion de $serveur
426
-
427
-	return true; // on a bien modifie le pass
400
+    if (is_null($new_pass) or auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur) != '') {
401
+        return false;
402
+    }
403
+
404
+    if (
405
+        !$id_auteur = intval($id_auteur)
406
+        or !sql_fetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur)
407
+    ) {
408
+        return false;
409
+    }
410
+
411
+    $c = [];
412
+    include_spip('inc/acces');
413
+    include_spip('auth/sha256.inc');
414
+    $htpass = generer_htpass($new_pass);
415
+    $alea_actuel = creer_uniqid();
416
+    $alea_futur = creer_uniqid();
417
+    $pass = spip_sha256($alea_actuel . $new_pass);
418
+    $c['pass'] = $pass;
419
+    $c['htpass'] = $htpass;
420
+    $c['alea_actuel'] = $alea_actuel;
421
+    $c['alea_futur'] = $alea_futur;
422
+    $c['low_sec'] = '';
423
+
424
+    include_spip('action/editer_auteur');
425
+    auteur_modifier($id_auteur, $c, true); // manque la gestion de $serveur
426
+
427
+    return true; // on a bien modifie le pass
428 428
 }
429 429
 
430 430
 /**
@@ -438,58 +438,58 @@  discard block
 block discarded – undo
438 438
  * @return void
439 439
  */
440 440
 function auth_spip_synchroniser_distant($id_auteur, $champs, $options = [], $serveur = '') {
441
-	// ne rien faire pour une base distante : on ne sait pas regenerer les htaccess
442
-	if (strlen($serveur)) {
443
-		return;
444
-	}
445
-	// si un login, pass ou statut a ete modifie
446
-	// regenerer les fichier htpass
447
-	if (
448
-		isset($champs['login'])
449
-		or isset($champs['pass'])
450
-		or isset($champs['statut'])
451
-		or (isset($options['all']) and $options['all'])
452
-	) {
453
-		$htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME;
454
-		$htpasswd = _DIR_TMP . _AUTH_USER_FILE;
455
-
456
-		// Cette variable de configuration peut etre posee par un plugin
457
-		// par exemple acces_restreint ;
458
-		// si .htaccess existe, outrepasser spip_meta
459
-		if (
460
-			(!isset($GLOBALS['meta']['creer_htpasswd']) or ($GLOBALS['meta']['creer_htpasswd'] != 'oui'))
461
-			and !@file_exists($htaccess)
462
-		) {
463
-			spip_unlink($htpasswd);
464
-			spip_unlink($htpasswd . '-admin');
465
-
466
-			return;
467
-		}
468
-
469
-		# remarque : ici on laisse passer les "nouveau" de maniere a leur permettre
470
-		# de devenir redacteur le cas echeant (auth http)... a nettoyer
471
-		// attention, il faut au prealable se connecter a la base (necessaire car utilise par install)
472
-
473
-		$p1 = ''; // login:htpass pour tous
474
-		$p2 = ''; // login:htpass pour les admins
475
-		$s = sql_select(
476
-			'login, htpass, statut',
477
-			'spip_auteurs',
478
-			sql_in('statut', ['1comite', '0minirezo', 'nouveau'])
479
-		);
480
-		while ($t = sql_fetch($s)) {
481
-			if (strlen($t['login']) and strlen($t['htpass'])) {
482
-				$p1 .= $t['login'] . ':' . $t['htpass'] . "\n";
483
-				if ($t['statut'] == '0minirezo') {
484
-					$p2 .= $t['login'] . ':' . $t['htpass'] . "\n";
485
-				}
486
-			}
487
-		}
488
-		sql_free($s);
489
-		if ($p1) {
490
-			ecrire_fichier($htpasswd, $p1);
491
-			ecrire_fichier($htpasswd . '-admin', $p2);
492
-			spip_log("Ecriture de $htpasswd et $htpasswd-admin");
493
-		}
494
-	}
441
+    // ne rien faire pour une base distante : on ne sait pas regenerer les htaccess
442
+    if (strlen($serveur)) {
443
+        return;
444
+    }
445
+    // si un login, pass ou statut a ete modifie
446
+    // regenerer les fichier htpass
447
+    if (
448
+        isset($champs['login'])
449
+        or isset($champs['pass'])
450
+        or isset($champs['statut'])
451
+        or (isset($options['all']) and $options['all'])
452
+    ) {
453
+        $htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME;
454
+        $htpasswd = _DIR_TMP . _AUTH_USER_FILE;
455
+
456
+        // Cette variable de configuration peut etre posee par un plugin
457
+        // par exemple acces_restreint ;
458
+        // si .htaccess existe, outrepasser spip_meta
459
+        if (
460
+            (!isset($GLOBALS['meta']['creer_htpasswd']) or ($GLOBALS['meta']['creer_htpasswd'] != 'oui'))
461
+            and !@file_exists($htaccess)
462
+        ) {
463
+            spip_unlink($htpasswd);
464
+            spip_unlink($htpasswd . '-admin');
465
+
466
+            return;
467
+        }
468
+
469
+        # remarque : ici on laisse passer les "nouveau" de maniere a leur permettre
470
+        # de devenir redacteur le cas echeant (auth http)... a nettoyer
471
+        // attention, il faut au prealable se connecter a la base (necessaire car utilise par install)
472
+
473
+        $p1 = ''; // login:htpass pour tous
474
+        $p2 = ''; // login:htpass pour les admins
475
+        $s = sql_select(
476
+            'login, htpass, statut',
477
+            'spip_auteurs',
478
+            sql_in('statut', ['1comite', '0minirezo', 'nouveau'])
479
+        );
480
+        while ($t = sql_fetch($s)) {
481
+            if (strlen($t['login']) and strlen($t['htpass'])) {
482
+                $p1 .= $t['login'] . ':' . $t['htpass'] . "\n";
483
+                if ($t['statut'] == '0minirezo') {
484
+                    $p2 .= $t['login'] . ':' . $t['htpass'] . "\n";
485
+                }
486
+            }
487
+        }
488
+        sql_free($s);
489
+        if ($p1) {
490
+            ecrire_fichier($htpasswd, $p1);
491
+            ecrire_fichier($htpasswd . '-admin', $p2);
492
+            spip_log("Ecriture de $htpasswd et $htpasswd-admin");
493
+        }
494
+    }
495 495
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		$row = sql_fetsel(
57 57
 			'alea_actuel, alea_futur',
58 58
 			'spip_auteurs',
59
-			'login=' . sql_quote($login, $serveur, 'text'),
59
+			'login='.sql_quote($login, $serveur, 'text'),
60 60
 			'',
61 61
 			'',
62 62
 			'',
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 
67 67
 		if ($row) {
68 68
 			include_spip('auth/sha256.inc');
69
-			$shapass = spip_sha256($row['alea_actuel'] . $pass);
70
-			$shanext = spip_sha256($row['alea_futur'] . $pass);
71
-			$md5pass = md5($row['alea_actuel'] . $pass);
69
+			$shapass = spip_sha256($row['alea_actuel'].$pass);
70
+			$shanext = spip_sha256($row['alea_futur'].$pass);
71
+			$md5pass = md5($row['alea_actuel'].$pass);
72 72
 		}
73 73
 	}
74 74
 
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 	$row = sql_fetsel(
81 81
 		'*',
82 82
 		'spip_auteurs',
83
-		'login=' . sql_quote($login, $serveur, 'text') . ' AND pass=' . sql_quote(
83
+		'login='.sql_quote($login, $serveur, 'text').' AND pass='.sql_quote(
84 84
 			$shapass,
85 85
 			$serveur,
86 86
 			'text'
87
-		) . " AND statut<>'5poubelle'",
87
+		)." AND statut<>'5poubelle'",
88 88
 		'',
89 89
 		'',
90 90
 		'',
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
 		$row = sql_fetsel(
98 98
 			'*',
99 99
 			'spip_auteurs',
100
-			'login=' . sql_quote($login, $serveur, 'text') . ' AND pass=' . sql_quote(
100
+			'login='.sql_quote($login, $serveur, 'text').' AND pass='.sql_quote(
101 101
 				$md5pass,
102 102
 				$serveur,
103 103
 				'text'
104
-			) . " AND statut<>'5poubelle'",
104
+			)." AND statut<>'5poubelle'",
105 105
 			'',
106 106
 			'',
107 107
 			'',
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
 			'alea_actuel' => 'alea_futur',
124 124
 			'pass' => sql_quote($shanext, $serveur, 'text'),
125 125
 			'alea_futur' => sql_quote(creer_uniqid(), $serveur, 'text')
126
-		], 'id_auteur=' . $row['id_auteur'] . ' AND pass IN (' . sql_quote(
126
+		], 'id_auteur='.$row['id_auteur'].' AND pass IN ('.sql_quote(
127 127
 			$shapass,
128 128
 			$serveur,
129 129
 			'text'
130
-		) . ', ' . sql_quote($md5pass, $serveur, 'text') . ')', '', $serveur);
130
+		).', '.sql_quote($md5pass, $serveur, 'text').')', '', $serveur);
131 131
 		// En profiter pour verifier la securite de tmp/
132 132
 		// Si elle ne fonctionne pas a l'installation, prevenir
133 133
 		if (!verifier_htaccess(_DIR_TMP) and defined('_ECRIRE_INSTALL')) {
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
 
164 164
 	// javascript qui gere la securite du login en evitant de faire circuler le pass en clair
165 165
 	$flux['data'] .=
166
-		($compat_md5 ? '<script type="text/javascript" src="' . _DIR_JAVASCRIPT . 'md5.js"></script>' : '')
167
-		. '<script type="text/javascript" src="' . _DIR_JAVASCRIPT . 'login-sha-min.js"></script>'
166
+		($compat_md5 ? '<script type="text/javascript" src="'._DIR_JAVASCRIPT.'md5.js"></script>' : '')
167
+		. '<script type="text/javascript" src="'._DIR_JAVASCRIPT.'login-sha-min.js"></script>'
168 168
 		. '<script type="text/javascript">/*<![CDATA[*/'
169
-		. "var login_info={'alea_actuel':'" . $flux['args']['contexte']['_alea_actuel'] . "',"
170
-		. "'alea_futur':'" . $flux['args']['contexte']['_alea_futur'] . "',"
171
-		. "'login':'" . $flux['args']['contexte']['var_login'] . "',"
172
-		. "'page_auteur': '" . generer_url_public('informer_auteur') . "',"
169
+		. "var login_info={'alea_actuel':'".$flux['args']['contexte']['_alea_actuel']."',"
170
+		. "'alea_futur':'".$flux['args']['contexte']['_alea_futur']."',"
171
+		. "'login':'".$flux['args']['contexte']['var_login']."',"
172
+		. "'page_auteur': '".generer_url_public('informer_auteur')."',"
173 173
 		. "'informe_auteur_en_cours':false,"
174 174
 		. "'attente_informe':0,"
175
-		. "'compat_md5':" . ($compat_md5 ? 'true' : 'false') . '};'
175
+		. "'compat_md5':".($compat_md5 ? 'true' : 'false').'};'
176 176
 		. "jQuery(function(){
177 177
 	jQuery('#var_login').change(actualise_auteur);
178 178
 	jQuery('form#formulaire_login').submit(login_submit);
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 		} else {
216 216
 			$n = sql_countsel(
217 217
 				'spip_auteurs',
218
-				'login=' . sql_quote($new_login) . ' AND id_auteur!=' . intval($id_auteur) . " AND statut!='5poubelle'",
218
+				'login='.sql_quote($new_login).' AND id_auteur!='.intval($id_auteur)." AND statut!='5poubelle'",
219 219
 				'',
220 220
 				'',
221 221
 				$serveur
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	}
244 244
 	if (
245 245
 		!$id_auteur = intval($id_auteur)
246
-		or !$auteur = sql_fetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur)
246
+		or !$auteur = sql_fetsel('login', 'spip_auteurs', 'id_auteur='.intval($id_auteur), '', '', '', '', $serveur)
247 247
 	) {
248 248
 		return false;
249 249
 	}
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 		$anciens = sql_allfetsel(
259 259
 			'id_auteur',
260 260
 			'spip_auteurs',
261
-			'login=' . sql_quote($new_login, $serveur, 'text') . " AND statut='5poubelle'",
261
+			'login='.sql_quote($new_login, $serveur, 'text')." AND statut='5poubelle'",
262 262
 			'',
263 263
 			'',
264 264
 			'',
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 		$r = sql_getfetsel(
293 293
 			'login',
294 294
 			'spip_auteurs',
295
-			"statut<>'5poubelle'" .
296
-			' AND (length(pass)>0)' .
295
+			"statut<>'5poubelle'".
296
+			' AND (length(pass)>0)'.
297 297
 			" AND (login=$l)",
298 298
 			'',
299 299
 			'',
@@ -312,8 +312,8 @@  discard block
 block discarded – undo
312 312
 		return sql_getfetsel(
313 313
 			'login',
314 314
 			'spip_auteurs',
315
-			"statut<>'5poubelle'" .
316
-			' AND (length(pass)>0)' .
315
+			"statut<>'5poubelle'".
316
+			' AND (length(pass)>0)'.
317 317
 			" AND (login<>'' AND (nom=$l OR email=$l))",
318 318
 			'',
319 319
 			'',
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 
404 404
 	if (
405 405
 		!$id_auteur = intval($id_auteur)
406
-		or !sql_fetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur)
406
+		or !sql_fetsel('login', 'spip_auteurs', 'id_auteur='.intval($id_auteur), '', '', '', '', $serveur)
407 407
 	) {
408 408
 		return false;
409 409
 	}
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 	$htpass = generer_htpass($new_pass);
415 415
 	$alea_actuel = creer_uniqid();
416 416
 	$alea_futur = creer_uniqid();
417
-	$pass = spip_sha256($alea_actuel . $new_pass);
417
+	$pass = spip_sha256($alea_actuel.$new_pass);
418 418
 	$c['pass'] = $pass;
419 419
 	$c['htpass'] = $htpass;
420 420
 	$c['alea_actuel'] = $alea_actuel;
@@ -450,8 +450,8 @@  discard block
 block discarded – undo
450 450
 		or isset($champs['statut'])
451 451
 		or (isset($options['all']) and $options['all'])
452 452
 	) {
453
-		$htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME;
454
-		$htpasswd = _DIR_TMP . _AUTH_USER_FILE;
453
+		$htaccess = _DIR_RESTREINT._ACCESS_FILE_NAME;
454
+		$htpasswd = _DIR_TMP._AUTH_USER_FILE;
455 455
 
456 456
 		// Cette variable de configuration peut etre posee par un plugin
457 457
 		// par exemple acces_restreint ;
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 			and !@file_exists($htaccess)
462 462
 		) {
463 463
 			spip_unlink($htpasswd);
464
-			spip_unlink($htpasswd . '-admin');
464
+			spip_unlink($htpasswd.'-admin');
465 465
 
466 466
 			return;
467 467
 		}
@@ -479,16 +479,16 @@  discard block
 block discarded – undo
479 479
 		);
480 480
 		while ($t = sql_fetch($s)) {
481 481
 			if (strlen($t['login']) and strlen($t['htpass'])) {
482
-				$p1 .= $t['login'] . ':' . $t['htpass'] . "\n";
482
+				$p1 .= $t['login'].':'.$t['htpass']."\n";
483 483
 				if ($t['statut'] == '0minirezo') {
484
-					$p2 .= $t['login'] . ':' . $t['htpass'] . "\n";
484
+					$p2 .= $t['login'].':'.$t['htpass']."\n";
485 485
 				}
486 486
 			}
487 487
 		}
488 488
 		sql_free($s);
489 489
 		if ($p1) {
490 490
 			ecrire_fichier($htpasswd, $p1);
491
-			ecrire_fichier($htpasswd . '-admin', $p2);
491
+			ecrire_fichier($htpasswd.'-admin', $p2);
492 492
 			spip_log("Ecriture de $htpasswd et $htpasswd-admin");
493 493
 		}
494 494
 	}
Please login to merge, or discard this patch.
ecrire/balise/formulaire_inscription.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 include_spip('base/abstract_sql');
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
  *     Pile complétée du code compilé
44 44
  **/
45 45
 function balise_FORMULAIRE_INSCRIPTION($p) {
46
-	return calculer_balise_dynamique($p, 'FORMULAIRE_INSCRIPTION', []);
46
+    return calculer_balise_dynamique($p, 'FORMULAIRE_INSCRIPTION', []);
47 47
 }
48 48
 
49 49
 /**
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
  *   - chaîne vide sinon.
73 73
  */
74 74
 function balise_FORMULAIRE_INSCRIPTION_stat($args, $context_compil) {
75
-	list($mode, $id, $retour) = array_pad($args, 3, null);
76
-	include_spip('action/inscrire_auteur');
77
-	$mode = tester_statut_inscription($mode, $id);
75
+    list($mode, $id, $retour) = array_pad($args, 3, null);
76
+    include_spip('action/inscrire_auteur');
77
+    $mode = tester_statut_inscription($mode, $id);
78 78
 
79
-	return $mode ? [$mode, $id, $retour] : '';
79
+    return $mode ? [$mode, $id, $retour] : '';
80 80
 }
Please login to merge, or discard this patch.
ecrire/balise/logo_.php 2 patches
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 
@@ -54,84 +54,84 @@  discard block
 block discarded – undo
54 54
  */
55 55
 function balise_LOGO__dist($p) {
56 56
 
57
-	preg_match(',^LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i', $p->nom_champ, $regs);
58
-	$type = strtolower($regs[1]);
59
-	$suite_logo = $regs[2];
60
-
61
-	// cas de #LOGO_SITE_SPIP
62
-	if ($type == 'site_spip') {
63
-		$type = 'site';
64
-		$_id_objet = "\"'0'\"";
65
-	}
66
-
67
-	$id_objet = id_table_objet($type);
68
-	if (!isset($_id_objet)) {
69
-		$_id_objet = champ_sql($id_objet, $p);
70
-	}
71
-
72
-	$fichier = ($p->etoile === '**') ? -1 : 0;
73
-	$coord = [];
74
-	$align = $lien = '';
75
-	$mode_logo = '';
76
-
77
-	if ($p->param and !$p->param[0][0]) {
78
-		$params = $p->param[0];
79
-		array_shift($params);
80
-		foreach ($params as $a) {
81
-			if ($a[0]->type === 'texte') {
82
-				$n = $a[0]->texte;
83
-				if (is_numeric($n)) {
84
-					$coord[] = $n;
85
-				} elseif (in_array($n, ['top', 'left', 'right', 'center', 'bottom'])) {
86
-					$align = $n;
87
-				} elseif (in_array($n, ['auto', 'icone', 'apercu', 'vignette'])) {
88
-					$mode_logo = $n;
89
-				}
90
-			} else {
91
-				$lien = calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle);
92
-			}
93
-		}
94
-	}
95
-
96
-	$coord_x = !$coord ? 0 : intval(array_shift($coord));
97
-	$coord_y = !$coord ? 0 : intval(array_shift($coord));
98
-
99
-	if ($p->etoile === '*') {
100
-		include_spip('balise/url_');
101
-		$lien = generer_generer_url_arg($type, $p, $_id_objet);
102
-	}
103
-
104
-	$connect = $p->id_boucle ? $p->boucles[$p->id_boucle]->sql_serveur : '';
105
-	if ($type == 'document') {
106
-		$qconnect = _q($connect);
107
-		$doc = "quete_document($_id_objet, $qconnect)";
108
-		if ($fichier) {
109
-			$code = "quete_logo_file($doc, $qconnect)";
110
-		} else {
111
-			$code = "quete_logo_document($doc, " . ($lien ? $lien : "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)";
112
-		}
113
-		// (x=non-faux ? y : '') pour affecter x en retournant y
114
-		if ($p->descr['documents']) {
115
-			$code = '(($doublons["documents"] .= ",". '
116
-				. $_id_objet
117
-				. ") ? $code : '')";
118
-		}
119
-	} elseif ($connect) {
120
-		$code = "''";
121
-		spip_log('Les logos distants ne sont pas prevus');
122
-	} else {
123
-		$code = logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $lien, $p, $suite_logo);
124
-	}
125
-
126
-	// demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0}
127
-	if ($coord_x or $coord_y) {
128
-		$code = "filtrer('image_graver',filtrer('image_reduire'," . $code . ", '$coord_x', '$coord_y'))";
129
-	}
130
-
131
-	$p->code = $code;
132
-	$p->interdire_scripts = false;
133
-
134
-	return $p;
57
+    preg_match(',^LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i', $p->nom_champ, $regs);
58
+    $type = strtolower($regs[1]);
59
+    $suite_logo = $regs[2];
60
+
61
+    // cas de #LOGO_SITE_SPIP
62
+    if ($type == 'site_spip') {
63
+        $type = 'site';
64
+        $_id_objet = "\"'0'\"";
65
+    }
66
+
67
+    $id_objet = id_table_objet($type);
68
+    if (!isset($_id_objet)) {
69
+        $_id_objet = champ_sql($id_objet, $p);
70
+    }
71
+
72
+    $fichier = ($p->etoile === '**') ? -1 : 0;
73
+    $coord = [];
74
+    $align = $lien = '';
75
+    $mode_logo = '';
76
+
77
+    if ($p->param and !$p->param[0][0]) {
78
+        $params = $p->param[0];
79
+        array_shift($params);
80
+        foreach ($params as $a) {
81
+            if ($a[0]->type === 'texte') {
82
+                $n = $a[0]->texte;
83
+                if (is_numeric($n)) {
84
+                    $coord[] = $n;
85
+                } elseif (in_array($n, ['top', 'left', 'right', 'center', 'bottom'])) {
86
+                    $align = $n;
87
+                } elseif (in_array($n, ['auto', 'icone', 'apercu', 'vignette'])) {
88
+                    $mode_logo = $n;
89
+                }
90
+            } else {
91
+                $lien = calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle);
92
+            }
93
+        }
94
+    }
95
+
96
+    $coord_x = !$coord ? 0 : intval(array_shift($coord));
97
+    $coord_y = !$coord ? 0 : intval(array_shift($coord));
98
+
99
+    if ($p->etoile === '*') {
100
+        include_spip('balise/url_');
101
+        $lien = generer_generer_url_arg($type, $p, $_id_objet);
102
+    }
103
+
104
+    $connect = $p->id_boucle ? $p->boucles[$p->id_boucle]->sql_serveur : '';
105
+    if ($type == 'document') {
106
+        $qconnect = _q($connect);
107
+        $doc = "quete_document($_id_objet, $qconnect)";
108
+        if ($fichier) {
109
+            $code = "quete_logo_file($doc, $qconnect)";
110
+        } else {
111
+            $code = "quete_logo_document($doc, " . ($lien ? $lien : "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)";
112
+        }
113
+        // (x=non-faux ? y : '') pour affecter x en retournant y
114
+        if ($p->descr['documents']) {
115
+            $code = '(($doublons["documents"] .= ",". '
116
+                . $_id_objet
117
+                . ") ? $code : '')";
118
+        }
119
+    } elseif ($connect) {
120
+        $code = "''";
121
+        spip_log('Les logos distants ne sont pas prevus');
122
+    } else {
123
+        $code = logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $lien, $p, $suite_logo);
124
+    }
125
+
126
+    // demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0}
127
+    if ($coord_x or $coord_y) {
128
+        $code = "filtrer('image_graver',filtrer('image_reduire'," . $code . ", '$coord_x', '$coord_y'))";
129
+    }
130
+
131
+    $p->code = $code;
132
+    $p->interdire_scripts = false;
133
+
134
+    return $p;
135 135
 }
136 136
 
137 137
 /**
@@ -158,20 +158,20 @@  discard block
 block discarded – undo
158 158
  *     Code compilé retournant le chemin du logo ou le code HTML du logo.
159 159
  **/
160 160
 function logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $_lien, $p, $suite) {
161
-	$code = "quete_logo('$id_objet', '" .
162
-		(($suite == '_SURVOL') ? 'off' :
163
-			(($suite == '_NORMAL') ? 'on' : 'ON')) .
164
-		"', $_id_objet," .
165
-		(($suite == '_RUBRIQUE') ?
166
-			champ_sql('id_rubrique', $p) :
167
-			(($type == 'rubrique') ? "quete_parent($_id_objet)" : "''")) .
168
-		', ' . intval($fichier) . ')';
169
-
170
-	if ($fichier) {
171
-		return $code;
172
-	}
173
-
174
-	$align = preg_replace(',\W,', '', $align);
175
-
176
-	return "quete_html_logo($code, '$align', " . ($_lien ? $_lien : "''") . ')';
161
+    $code = "quete_logo('$id_objet', '" .
162
+        (($suite == '_SURVOL') ? 'off' :
163
+            (($suite == '_NORMAL') ? 'on' : 'ON')) .
164
+        "', $_id_objet," .
165
+        (($suite == '_RUBRIQUE') ?
166
+            champ_sql('id_rubrique', $p) :
167
+            (($type == 'rubrique') ? "quete_parent($_id_objet)" : "''")) .
168
+        ', ' . intval($fichier) . ')';
169
+
170
+    if ($fichier) {
171
+        return $code;
172
+    }
173
+
174
+    $align = preg_replace(',\W,', '', $align);
175
+
176
+    return "quete_html_logo($code, '$align', " . ($_lien ? $_lien : "''") . ')';
177 177
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -10 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		if ($fichier) {
109 109
 			$code = "quete_logo_file($doc, $qconnect)";
110 110
 		} else {
111
-			$code = "quete_logo_document($doc, " . ($lien ? $lien : "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)";
111
+			$code = "quete_logo_document($doc, ".($lien ? $lien : "''").", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)";
112 112
 		}
113 113
 		// (x=non-faux ? y : '') pour affecter x en retournant y
114 114
 		if ($p->descr['documents']) {
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
 	// demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0}
127 127
 	if ($coord_x or $coord_y) {
128
-		$code = "filtrer('image_graver',filtrer('image_reduire'," . $code . ", '$coord_x', '$coord_y'))";
128
+		$code = "filtrer('image_graver',filtrer('image_reduire',".$code.", '$coord_x', '$coord_y'))";
129 129
 	}
130 130
 
131 131
 	$p->code = $code;
@@ -158,14 +158,12 @@  discard block
 block discarded – undo
158 158
  *     Code compilé retournant le chemin du logo ou le code HTML du logo.
159 159
  **/
160 160
 function logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $_lien, $p, $suite) {
161
-	$code = "quete_logo('$id_objet', '" .
162
-		(($suite == '_SURVOL') ? 'off' :
163
-			(($suite == '_NORMAL') ? 'on' : 'ON')) .
164
-		"', $_id_objet," .
161
+	$code = "quete_logo('$id_objet', '".
162
+		(($suite == '_SURVOL') ? 'off' : (($suite == '_NORMAL') ? 'on' : 'ON')).
163
+		"', $_id_objet,".
165 164
 		(($suite == '_RUBRIQUE') ?
166
-			champ_sql('id_rubrique', $p) :
167
-			(($type == 'rubrique') ? "quete_parent($_id_objet)" : "''")) .
168
-		', ' . intval($fichier) . ')';
165
+			champ_sql('id_rubrique', $p) : (($type == 'rubrique') ? "quete_parent($_id_objet)" : "''")).
166
+		', '.intval($fichier).')';
169 167
 
170 168
 	if ($fichier) {
171 169
 		return $code;
@@ -173,5 +171,5 @@  discard block
 block discarded – undo
173 171
 
174 172
 	$align = preg_replace(',\W,', '', $align);
175 173
 
176
-	return "quete_html_logo($code, '$align', " . ($_lien ? $_lien : "''") . ')';
174
+	return "quete_html_logo($code, '$align', ".($_lien ? $_lien : "''").')';
177 175
 }
Please login to merge, or discard this patch.
ecrire/balise/url_logout.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
  *     Pile complétée du code compilé
37 37
  **/
38 38
 function balise_URL_LOGOUT($p) {
39
-	return calculer_balise_dynamique($p, 'URL_LOGOUT', []);
39
+    return calculer_balise_dynamique($p, 'URL_LOGOUT', []);
40 40
 }
41 41
 
42 42
 
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
  *   Liste (url) des arguments collectés.
53 53
  */
54 54
 function balise_URL_LOGOUT_stat($args, $context_compil) {
55
-	$url = isset($args[0]) ? $args[0] : '';
55
+    $url = isset($args[0]) ? $args[0] : '';
56 56
 
57
-	return [$url];
57
+    return [$url];
58 58
 }
59 59
 
60 60
 /**
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
  **/
70 70
 function balise_URL_LOGOUT_dyn($cible) {
71 71
 
72
-	if (empty($GLOBALS['visiteur_session']['login']) and empty($GLOBALS['visiteur_session']['statut'])) {
73
-		return '';
74
-	}
72
+    if (empty($GLOBALS['visiteur_session']['login']) and empty($GLOBALS['visiteur_session']['statut'])) {
73
+        return '';
74
+    }
75 75
 
76
-	return generer_url_action('logout', 'logout=public&url=' . rawurlencode($cible ? $cible : self('&')));
76
+    return generer_url_action('logout', 'logout=public&url=' . rawurlencode($cible ? $cible : self('&')));
77 77
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,5 +73,5 @@
 block discarded – undo
73 73
 		return '';
74 74
 	}
75 75
 
76
-	return generer_url_action('logout', 'logout=public&url=' . rawurlencode($cible ? $cible : self('&')));
76
+	return generer_url_action('logout', 'logout=public&url='.rawurlencode($cible ? $cible : self('&')));
77 77
 }
Please login to merge, or discard this patch.
ecrire/balise/menu_lang_ecrire.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
  *     Pile complétée du code compilé
38 38
  **/
39 39
 function balise_MENU_LANG_ECRIRE($p) {
40
-	return calculer_balise_dynamique($p, 'MENU_LANG_ECRIRE', ['lang']);
40
+    return calculer_balise_dynamique($p, 'MENU_LANG_ECRIRE', ['lang']);
41 41
 }
42 42
 
43 43
 /**
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
  *   Liste (lang) des arguments collectés et fournis.
56 56
  */
57 57
 function balise_MENU_LANG_ECRIRE_stat($args, $context_compil) {
58
-	include_spip('inc/lang');
59
-	if (strpos($GLOBALS['meta']['langues_proposees'], ',') === false) {
60
-		return '';
61
-	}
58
+    include_spip('inc/lang');
59
+    if (strpos($GLOBALS['meta']['langues_proposees'], ',') === false) {
60
+        return '';
61
+    }
62 62
 
63
-	return $args;
63
+    return $args;
64 64
 }
65 65
 
66 66
 /**
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
  *     Liste : Chemin du squelette, durée du cache, contexte
77 77
  **/
78 78
 function balise_MENU_LANG_ECRIRE_dyn($opt) {
79
-	return menu_lang_pour_tous('var_lang_ecrire', $opt);
79
+    return menu_lang_pour_tous('var_lang_ecrire', $opt);
80 80
 }
81 81
 
82 82
 /**
@@ -96,30 +96,30 @@  discard block
 block discarded – undo
96 96
  *     Liste : Chemin du squelette, durée du cache, contexte
97 97
  **/
98 98
 function menu_lang_pour_tous($nom, $default) {
99
-	include_spip('inc/lang');
99
+    include_spip('inc/lang');
100 100
 
101
-	if ($GLOBALS['spip_lang'] <> $default) {
102
-		$opt = lang_select($default);  # et remplace
103
-		if ($GLOBALS['spip_lang'] <> $default) {
104
-			$default = '';  # annule tout choix par defaut
105
-			if ($opt) {
106
-				lang_select();
107
-			}
108
-		}
109
-	}
101
+    if ($GLOBALS['spip_lang'] <> $default) {
102
+        $opt = lang_select($default);  # et remplace
103
+        if ($GLOBALS['spip_lang'] <> $default) {
104
+            $default = '';  # annule tout choix par defaut
105
+            if ($opt) {
106
+                lang_select();
107
+            }
108
+        }
109
+    }
110 110
 
111
-	# lien a partir de /
112
-	$cible = parametre_url(self(), 'lang', '', '&');
113
-	$post = generer_url_action('converser', 'redirect=' . rawurlencode($cible), '&');
111
+    # lien a partir de /
112
+    $cible = parametre_url(self(), 'lang', '', '&');
113
+    $post = generer_url_action('converser', 'redirect=' . rawurlencode($cible), '&');
114 114
 
115
-	return [
116
-		'formulaires/menu_lang',
117
-		3600,
118
-		[
119
-			'nom' => $nom,
120
-			'url' => $post,
121
-			'name' => $nom,
122
-			'default' => $default,
123
-		]
124
-	];
115
+    return [
116
+        'formulaires/menu_lang',
117
+        3600,
118
+        [
119
+            'nom' => $nom,
120
+            'url' => $post,
121
+            'name' => $nom,
122
+            'default' => $default,
123
+        ]
124
+    ];
125 125
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 	include_spip('inc/lang');
100 100
 
101 101
 	if ($GLOBALS['spip_lang'] <> $default) {
102
-		$opt = lang_select($default);  # et remplace
102
+		$opt = lang_select($default); # et remplace
103 103
 		if ($GLOBALS['spip_lang'] <> $default) {
104
-			$default = '';  # annule tout choix par defaut
104
+			$default = ''; # annule tout choix par defaut
105 105
 			if ($opt) {
106 106
 				lang_select();
107 107
 			}
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
 	# lien a partir de /
112 112
 	$cible = parametre_url(self(), 'lang', '', '&');
113
-	$post = generer_url_action('converser', 'redirect=' . rawurlencode($cible), '&');
113
+	$post = generer_url_action('converser', 'redirect='.rawurlencode($cible), '&');
114 114
 
115 115
 	return [
116 116
 		'formulaires/menu_lang',
Please login to merge, or discard this patch.
ecrire/balise/menu_lang.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
  *     Pile complétée du code compilé
38 38
  **/
39 39
 function balise_MENU_LANG($p) {
40
-	return calculer_balise_dynamique($p, 'MENU_LANG', ['lang']);
40
+    return calculer_balise_dynamique($p, 'MENU_LANG', ['lang']);
41 41
 }
42 42
 
43 43
 /**
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
  *   Liste (lang) des arguments collectés et fournis.
56 56
  */
57 57
 function balise_MENU_LANG_stat($args, $context_compil) {
58
-	if (strpos($GLOBALS['meta']['langues_multilingue'], ',') === false) {
59
-		return '';
60
-	}
58
+    if (strpos($GLOBALS['meta']['langues_multilingue'], ',') === false) {
59
+        return '';
60
+    }
61 61
 
62
-	return $args;
62
+    return $args;
63 63
 }
64 64
 
65 65
 /**
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
  *     Liste : Chemin du squelette, durée du cache, contexte
76 76
  **/
77 77
 function balise_MENU_LANG_dyn($opt) {
78
-	include_spip('balise/menu_lang_ecrire');
78
+    include_spip('balise/menu_lang_ecrire');
79 79
 
80
-	return menu_lang_pour_tous('var_lang', $opt);
80
+    return menu_lang_pour_tous('var_lang', $opt);
81 81
 }
Please login to merge, or discard this patch.
ecrire/balise/formulaire_admin.php 2 patches
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
  *     Pile complétée du code compilé
43 43
  **/
44 44
 function balise_FORMULAIRE_ADMIN($p) {
45
-	return calculer_balise_dynamique($p, 'FORMULAIRE_ADMIN', []);
45
+    return calculer_balise_dynamique($p, 'FORMULAIRE_ADMIN', []);
46 46
 }
47 47
 
48 48
 /**
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
  *   - chaîne vide sinon.
60 60
  */
61 61
 function balise_FORMULAIRE_ADMIN_stat($args, $context_compil) {
62
-	return $args;
62
+    return $args;
63 63
 }
64 64
 
65 65
 
@@ -84,66 +84,66 @@  discard block
 block discarded – undo
84 84
  **/
85 85
 function balise_FORMULAIRE_ADMIN_dyn($float = '', $debug = '') {
86 86
 
87
-	static $dejafait = false;
87
+    static $dejafait = false;
88 88
 
89
-	if (empty($_COOKIE['spip_admin'])) {
90
-		return '';
91
-	}
89
+    if (empty($_COOKIE['spip_admin'])) {
90
+        return '';
91
+    }
92 92
 
93
-	if (!is_array($debug)) {
94
-		if ($dejafait) {
95
-			return '';
96
-		}
97
-	} else {
98
-		if ($dejafait) {
99
-			if (empty($debug['sourcefile'])) {
100
-				return '';
101
-			}
102
-			foreach ($debug['sourcefile'] as $k => $v) {
103
-				if (strpos($v, 'administration.') !== false) {
104
-					if (isset($debug['resultat'][$k . 'tout'])) {
105
-						return $debug['resultat'][$k . 'tout'];
106
-					}
107
-				}
108
-			}
93
+    if (!is_array($debug)) {
94
+        if ($dejafait) {
95
+            return '';
96
+        }
97
+    } else {
98
+        if ($dejafait) {
99
+            if (empty($debug['sourcefile'])) {
100
+                return '';
101
+            }
102
+            foreach ($debug['sourcefile'] as $k => $v) {
103
+                if (strpos($v, 'administration.') !== false) {
104
+                    if (isset($debug['resultat'][$k . 'tout'])) {
105
+                        return $debug['resultat'][$k . 'tout'];
106
+                    }
107
+                }
108
+            }
109 109
 
110
-			return '';
111
-		}
112
-	}
110
+            return '';
111
+        }
112
+    }
113 113
 
114
-	include_spip('inc/autoriser');
115
-	include_spip('base/abstract_sql');
114
+    include_spip('inc/autoriser');
115
+    include_spip('base/abstract_sql');
116 116
 
117 117
 
118
-	$dejafait = true;
118
+    $dejafait = true;
119 119
 
120
-	// Preparer le #ENV des boutons
120
+    // Preparer le #ENV des boutons
121 121
 
122
-	$env = admin_objet();
122
+    $env = admin_objet();
123 123
 
124
-	// Pas de "modifier ce..." ? -> donner "acces a l'espace prive"
125
-	if (!$env) {
126
-		$env['ecrire'] = _DIR_RESTREINT_ABS;
127
-	}
124
+    // Pas de "modifier ce..." ? -> donner "acces a l'espace prive"
125
+    if (!$env) {
126
+        $env['ecrire'] = _DIR_RESTREINT_ABS;
127
+    }
128 128
 
129
-	$env['divclass'] = $float;
130
-	$env['lang'] = admin_lang();
131
-	$env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul');
132
-	$env['debug'] = ((defined('_VAR_PREVIEW') and _VAR_PREVIEW) ? '' : admin_debug());
133
-	$env['analyser'] = (!$env['debug'] and !$GLOBALS['xhtml']) ? '' : admin_valider();
134
-	$env['inclure'] = ((defined('_VAR_INCLURE') and _VAR_INCLURE) ? 'inclure' : '');
129
+    $env['divclass'] = $float;
130
+    $env['lang'] = admin_lang();
131
+    $env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul');
132
+    $env['debug'] = ((defined('_VAR_PREVIEW') and _VAR_PREVIEW) ? '' : admin_debug());
133
+    $env['analyser'] = (!$env['debug'] and !$GLOBALS['xhtml']) ? '' : admin_valider();
134
+    $env['inclure'] = ((defined('_VAR_INCLURE') and _VAR_INCLURE) ? 'inclure' : '');
135 135
 
136
-	if (empty($GLOBALS['use_cache'])) {
137
-		$env['use_cache'] = ' *';
138
-	}
136
+    if (empty($GLOBALS['use_cache'])) {
137
+        $env['use_cache'] = ' *';
138
+    }
139 139
 
140
-	if (isset($debug['validation'])) {
141
-		$env['xhtml_error'] = $debug['validation'];
142
-	}
140
+    if (isset($debug['validation'])) {
141
+        $env['xhtml_error'] = $debug['validation'];
142
+    }
143 143
 
144
-	$env['_pipelines']['formulaire_admin'] = [];
144
+    $env['_pipelines']['formulaire_admin'] = [];
145 145
 
146
-	return ['formulaires/administration', 0, $env];
146
+    return ['formulaires/administration', 0, $env];
147 147
 }
148 148
 
149 149
 
@@ -161,47 +161,47 @@  discard block
 block discarded – undo
161 161
  *     Tableau de l'environnement calculé
162 162
  **/
163 163
 function admin_objet() {
164
-	include_spip('inc/urls');
165
-	$env = [];
166
-
167
-	$trouver_table = charger_fonction('trouver_table', 'base');
168
-	$objets = urls_liste_objets(false);
169
-	$objets = array_diff($objets, ['rubrique']);
170
-	$objets = array_reverse($objets);
171
-	array_unshift($objets, 'rubrique');
172
-	foreach ($objets as $obj) {
173
-		$type = $obj;
174
-		if (
175
-			$type == objet_type($type, false)
176
-			and $_id_type = id_table_objet($type)
177
-			and isset($GLOBALS['contexte'][$_id_type])
178
-			and $id = $GLOBALS['contexte'][$_id_type]
179
-			and !is_array($id)
180
-			and $id = intval($id)
181
-			and $desc = $trouver_table(table_objet_sql($type))
182
-		) {
183
-			$id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id));
184
-			if ($id) {
185
-				$env[$_id_type] = $id;
186
-				$env['objet'] = $type;
187
-				$env['id_objet'] = $id;
188
-				$env['voir_' . $obj] =
189
-					str_replace('&amp;', '&', generer_url_entite($id, $obj, '', '', false));
190
-				if (
191
-					isset($desc['field']['id_rubrique'])
192
-					and $type != 'rubrique'
193
-				) {
194
-					unset($env['id_rubrique']);
195
-					unset($env['voir_rubrique']);
196
-					if (admin_preview($type, $id, $desc)) {
197
-						$env['preview'] = parametre_url(self(), 'var_mode', 'preview', '&');
198
-					}
199
-				}
200
-			}
201
-		}
202
-	}
203
-
204
-	return $env;
164
+    include_spip('inc/urls');
165
+    $env = [];
166
+
167
+    $trouver_table = charger_fonction('trouver_table', 'base');
168
+    $objets = urls_liste_objets(false);
169
+    $objets = array_diff($objets, ['rubrique']);
170
+    $objets = array_reverse($objets);
171
+    array_unshift($objets, 'rubrique');
172
+    foreach ($objets as $obj) {
173
+        $type = $obj;
174
+        if (
175
+            $type == objet_type($type, false)
176
+            and $_id_type = id_table_objet($type)
177
+            and isset($GLOBALS['contexte'][$_id_type])
178
+            and $id = $GLOBALS['contexte'][$_id_type]
179
+            and !is_array($id)
180
+            and $id = intval($id)
181
+            and $desc = $trouver_table(table_objet_sql($type))
182
+        ) {
183
+            $id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id));
184
+            if ($id) {
185
+                $env[$_id_type] = $id;
186
+                $env['objet'] = $type;
187
+                $env['id_objet'] = $id;
188
+                $env['voir_' . $obj] =
189
+                    str_replace('&amp;', '&', generer_url_entite($id, $obj, '', '', false));
190
+                if (
191
+                    isset($desc['field']['id_rubrique'])
192
+                    and $type != 'rubrique'
193
+                ) {
194
+                    unset($env['id_rubrique']);
195
+                    unset($env['voir_rubrique']);
196
+                    if (admin_preview($type, $id, $desc)) {
197
+                        $env['preview'] = parametre_url(self(), 'var_mode', 'preview', '&');
198
+                    }
199
+                }
200
+            }
201
+        }
202
+    }
203
+
204
+    return $env;
205 205
 }
206 206
 
207 207
 
@@ -219,30 +219,30 @@  discard block
 block discarded – undo
219 219
  *     - Tableau d'un élément sinon.
220 220
  **/
221 221
 function admin_preview($type, $id, $desc = null) {
222
-	if (defined('_VAR_PREVIEW') and _VAR_PREVIEW) {
223
-		return '';
224
-	}
225
-
226
-	if (!$desc) {
227
-		$trouver_table = charger_fonction('trouver_table', 'base');
228
-		$desc = $trouver_table(table_objet_sql($type));
229
-	}
230
-	if (!$desc or !isset($desc['field']['statut'])) {
231
-		return '';
232
-	}
233
-
234
-	include_spip('inc/autoriser');
235
-	if (!autoriser('previsualiser')) {
236
-		return '';
237
-	}
238
-
239
-	$notpub = sql_in('statut', ['prop', 'prive']);
240
-
241
-	if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') {
242
-		$notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')';
243
-	}
244
-
245
-	return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)");
222
+    if (defined('_VAR_PREVIEW') and _VAR_PREVIEW) {
223
+        return '';
224
+    }
225
+
226
+    if (!$desc) {
227
+        $trouver_table = charger_fonction('trouver_table', 'base');
228
+        $desc = $trouver_table(table_objet_sql($type));
229
+    }
230
+    if (!$desc or !isset($desc['field']['statut'])) {
231
+        return '';
232
+    }
233
+
234
+    include_spip('inc/autoriser');
235
+    if (!autoriser('previsualiser')) {
236
+        return '';
237
+    }
238
+
239
+    $notpub = sql_in('statut', ['prop', 'prive']);
240
+
241
+    if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') {
242
+        $notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')';
243
+    }
244
+
245
+    return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)");
246 246
 }
247 247
 
248 248
 
@@ -253,25 +253,25 @@  discard block
 block discarded – undo
253 253
  *     Code de langue
254 254
  **/
255 255
 function admin_lang() {
256
-	$alang = '';
257
-	if (!empty($_COOKIE['spip_admin'])) {
258
-		$email_or_login = preg_replace(',^@,', '', $_COOKIE['spip_admin']);
259
-		$alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login));
260
-		if (!$alang) {
261
-			$alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login));
262
-		}
263
-	}
264
-	if (!$alang) {
265
-		return '';
266
-	}
267
-
268
-	$l = lang_select($alang);
269
-	$alang = $GLOBALS['spip_lang'];
270
-	if ($l) {
271
-		lang_select();
272
-	}
273
-
274
-	return $alang;
256
+    $alang = '';
257
+    if (!empty($_COOKIE['spip_admin'])) {
258
+        $email_or_login = preg_replace(',^@,', '', $_COOKIE['spip_admin']);
259
+        $alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login));
260
+        if (!$alang) {
261
+            $alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login));
262
+        }
263
+    }
264
+    if (!$alang) {
265
+        return '';
266
+    }
267
+
268
+    $l = lang_select($alang);
269
+    $alang = $GLOBALS['spip_lang'];
270
+    if ($l) {
271
+        lang_select();
272
+    }
273
+
274
+    return $alang;
275 275
 }
276 276
 
277 277
 /**
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
  **/
282 282
 function admin_valider() {
283 283
 
284
-	return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ?
285
-		(parametre_url(self(), 'var_mode', 'debug', '&')
286
-			. '&var_mode_affiche=validation') :
287
-		('http://validator.w3.org/check?uri='
288
-			. rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri())));
284
+    return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ?
285
+        (parametre_url(self(), 'var_mode', 'debug', '&')
286
+            . '&var_mode_affiche=validation') :
287
+        ('http://validator.w3.org/check?uri='
288
+            . rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri())));
289 289
 }
290 290
 
291 291
 /**
@@ -294,14 +294,14 @@  discard block
 block discarded – undo
294 294
  * @return string
295 295
  **/
296 296
 function admin_debug() {
297
-	return ((
298
-			(isset($GLOBALS['forcer_debug']) and $GLOBALS['forcer_debug'])
299
-			or (isset($GLOBALS['bouton_admin_debug']) and $GLOBALS['bouton_admin_debug'])
300
-			or (
301
-				defined('_VAR_MODE') and _VAR_MODE == 'debug'
302
-				and isset($_COOKIE['spip_debug']) and $_COOKIE['spip_debug']
303
-			)
304
-		) and autoriser('debug')
305
-	)
306
-		? parametre_url(self(), 'var_mode', 'debug', '&') : '';
297
+    return ((
298
+            (isset($GLOBALS['forcer_debug']) and $GLOBALS['forcer_debug'])
299
+            or (isset($GLOBALS['bouton_admin_debug']) and $GLOBALS['bouton_admin_debug'])
300
+            or (
301
+                defined('_VAR_MODE') and _VAR_MODE == 'debug'
302
+                and isset($_COOKIE['spip_debug']) and $_COOKIE['spip_debug']
303
+            )
304
+        ) and autoriser('debug')
305
+    )
306
+        ? parametre_url(self(), 'var_mode', 'debug', '&') : '';
307 307
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -11 removed lines patch added patch discarded remove patch
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 			}
102 102
 			foreach ($debug['sourcefile'] as $k => $v) {
103 103
 				if (strpos($v, 'administration.') !== false) {
104
-					if (isset($debug['resultat'][$k . 'tout'])) {
105
-						return $debug['resultat'][$k . 'tout'];
104
+					if (isset($debug['resultat'][$k.'tout'])) {
105
+						return $debug['resultat'][$k.'tout'];
106 106
 					}
107 107
 				}
108 108
 			}
@@ -180,12 +180,12 @@  discard block
 block discarded – undo
180 180
 			and $id = intval($id)
181 181
 			and $desc = $trouver_table(table_objet_sql($type))
182 182
 		) {
183
-			$id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id));
183
+			$id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=".intval($id));
184 184
 			if ($id) {
185 185
 				$env[$_id_type] = $id;
186 186
 				$env['objet'] = $type;
187 187
 				$env['id_objet'] = $id;
188
-				$env['voir_' . $obj] =
188
+				$env['voir_'.$obj] =
189 189
 					str_replace('&amp;', '&', generer_url_entite($id, $obj, '', '', false));
190 190
 				if (
191 191
 					isset($desc['field']['id_rubrique'])
@@ -239,10 +239,10 @@  discard block
 block discarded – undo
239 239
 	$notpub = sql_in('statut', ['prop', 'prive']);
240 240
 
241 241
 	if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') {
242
-		$notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')';
242
+		$notpub .= " OR (statut='publie' AND date>".sql_quote(date('Y-m-d H:i:s')).')';
243 243
 	}
244 244
 
245
-	return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)");
245
+	return sql_fetsel('1', table_objet_sql($type), id_table_objet($type).'='.$id." AND ($notpub)");
246 246
 }
247 247
 
248 248
 
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
 	$alang = '';
257 257
 	if (!empty($_COOKIE['spip_admin'])) {
258 258
 		$email_or_login = preg_replace(',^@,', '', $_COOKIE['spip_admin']);
259
-		$alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login));
259
+		$alang = sql_getfetsel('lang', 'spip_auteurs', 'email='.sql_quote($email_or_login));
260 260
 		if (!$alang) {
261
-			$alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login));
261
+			$alang = sql_getfetsel('lang', 'spip_auteurs', 'login='.sql_quote($email_or_login));
262 262
 		}
263 263
 	}
264 264
 	if (!$alang) {
@@ -283,9 +283,8 @@  discard block
 block discarded – undo
283 283
 
284 284
 	return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ?
285 285
 		(parametre_url(self(), 'var_mode', 'debug', '&')
286
-			. '&var_mode_affiche=validation') :
287
-		('http://validator.w3.org/check?uri='
288
-			. rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri())));
286
+			. '&var_mode_affiche=validation') : ('http://validator.w3.org/check?uri='
287
+			. rawurlencode('http://'.$_SERVER['HTTP_HOST'].nettoyer_uri())));
289 288
 }
290 289
 
291 290
 /**
Please login to merge, or discard this patch.
ecrire/balise/url_.php 2 patches
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  **/
20 20
 
21 21
 if (!defined('_ECRIRE_INC_VERSION')) {
22
-	return;
22
+    return;
23 23
 }
24 24
 
25 25
 /**
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
  *     Code compilé
38 38
  **/
39 39
 function generer_generer_url($type, $p) {
40
-	$_id = interprete_argument_balise(1, $p);
40
+    $_id = interprete_argument_balise(1, $p);
41 41
 
42
-	if (!$_id) {
43
-		$primary = id_table_objet($type);
44
-		$_id = champ_sql($primary, $p);
45
-	}
42
+    if (!$_id) {
43
+        $primary = id_table_objet($type);
44
+        $_id = champ_sql($primary, $p);
45
+    }
46 46
 
47
-	return generer_generer_url_arg($type, $p, $_id);
47
+    return generer_generer_url_arg($type, $p, $_id);
48 48
 }
49 49
 
50 50
 /**
@@ -73,28 +73,28 @@  discard block
 block discarded – undo
73 73
  *     Code compilé
74 74
  **/
75 75
 function generer_generer_url_arg($type, $p, $_id) {
76
-	if ($s = trouver_nom_serveur_distant($p)) {
77
-		// si une fonction de generation des url a ete definie pour ce connect l'utiliser
78
-		if (function_exists($f = 'generer_generer_url_' . $s)) {
79
-			return $f($type, $_id, $s);
80
-		}
81
-		if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) {
82
-			return null;
83
-		}
84
-		$s = _q($s);
85
-		# exception des urls de documents sur un serveur distant...
86
-		if ($type == 'document') {
87
-			return
88
-				"quete_meta('adresse_site', $s) . '/' .\n\t" .
89
-				"quete_meta('dir_img', $s) . \n\t" .
90
-				"quete_fichier($_id,$s)";
91
-		}
92
-		$s = ", '', '', $s, quete_meta('type_urls', $s)";
93
-	} else {
94
-		$s = ", '', '', true";
95
-	}
96
-
97
-	return "urlencode_1738(generer_url_entite($_id, '$type'$s))";
76
+    if ($s = trouver_nom_serveur_distant($p)) {
77
+        // si une fonction de generation des url a ete definie pour ce connect l'utiliser
78
+        if (function_exists($f = 'generer_generer_url_' . $s)) {
79
+            return $f($type, $_id, $s);
80
+        }
81
+        if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) {
82
+            return null;
83
+        }
84
+        $s = _q($s);
85
+        # exception des urls de documents sur un serveur distant...
86
+        if ($type == 'document') {
87
+            return
88
+                "quete_meta('adresse_site', $s) . '/' .\n\t" .
89
+                "quete_meta('dir_img', $s) . \n\t" .
90
+                "quete_fichier($_id,$s)";
91
+        }
92
+        $s = ", '', '', $s, quete_meta('type_urls', $s)";
93
+    } else {
94
+        $s = ", '', '', true";
95
+    }
96
+
97
+    return "urlencode_1738(generer_url_entite($_id, '$type'$s))";
98 98
 }
99 99
 
100 100
 
@@ -119,27 +119,27 @@  discard block
 block discarded – undo
119 119
  */
120 120
 function balise_URL__dist($p) {
121 121
 
122
-	$nom = $p->nom_champ;
123
-	if ($nom === 'URL_') {
124
-		$msg = ['zbug_balise_sans_argument', ['balise' => ' URL_']];
125
-		erreur_squelette($msg, $p);
126
-		$p->interdire_scripts = false;
127
-
128
-		return $p;
129
-	} elseif ($f = charger_fonction($nom, 'balise', true)) {
130
-		return $f($p);
131
-	} else {
132
-		$nom = strtolower($nom);
133
-		$code = generer_generer_url(substr($nom, 4), $p);
134
-		$code = champ_sql($nom, $p, $code);
135
-		$p->code = $code;
136
-		if (!$p->etoile) {
137
-			$p->code = "vider_url($code)";
138
-		}
139
-		$p->interdire_scripts = false;
140
-
141
-		return $p;
142
-	}
122
+    $nom = $p->nom_champ;
123
+    if ($nom === 'URL_') {
124
+        $msg = ['zbug_balise_sans_argument', ['balise' => ' URL_']];
125
+        erreur_squelette($msg, $p);
126
+        $p->interdire_scripts = false;
127
+
128
+        return $p;
129
+    } elseif ($f = charger_fonction($nom, 'balise', true)) {
130
+        return $f($p);
131
+    } else {
132
+        $nom = strtolower($nom);
133
+        $code = generer_generer_url(substr($nom, 4), $p);
134
+        $code = champ_sql($nom, $p, $code);
135
+        $p->code = $code;
136
+        if (!$p->etoile) {
137
+            $p->code = "vider_url($code)";
138
+        }
139
+        $p->interdire_scripts = false;
140
+
141
+        return $p;
142
+    }
143 143
 }
144 144
 
145 145
 /**
@@ -163,20 +163,20 @@  discard block
 block discarded – undo
163 163
  */
164 164
 function balise_URL_ARTICLE_dist($p) {
165 165
 
166
-	// Cas particulier des boucles (SYNDIC_ARTICLES)
167
-	if ($p->type_requete == 'syndic_articles') {
168
-		$code = champ_sql('url', $p);
169
-	} else {
170
-		$code = generer_generer_url('article', $p);
171
-	}
166
+    // Cas particulier des boucles (SYNDIC_ARTICLES)
167
+    if ($p->type_requete == 'syndic_articles') {
168
+        $code = champ_sql('url', $p);
169
+    } else {
170
+        $code = generer_generer_url('article', $p);
171
+    }
172 172
 
173
-	$p->code = $code;
174
-	if (!$p->etoile) {
175
-		$p->code = "vider_url($code)";
176
-	}
177
-	$p->interdire_scripts = false;
173
+    $p->code = $code;
174
+    if (!$p->etoile) {
175
+        $p->code = "vider_url($code)";
176
+    }
177
+    $p->interdire_scripts = false;
178 178
 
179
-	return $p;
179
+    return $p;
180 180
 }
181 181
 
182 182
 /**
@@ -196,21 +196,21 @@  discard block
 block discarded – undo
196 196
  *     Pile complétée par le code à générer
197 197
  */
198 198
 function balise_URL_SITE_dist($p) {
199
-	$code = champ_sql('url_site', $p);
200
-	if (strpos($code, '@$Pile[0]') !== false) {
201
-		$code = generer_generer_url('site', $p);
202
-		if ($code === null) {
203
-			return null;
204
-		}
205
-	} else {
206
-		if (!$p->etoile) {
207
-			$code = "calculer_url($code,'','url', \$connect)";
208
-		}
209
-	}
210
-	$p->code = $code;
211
-	$p->interdire_scripts = false;
212
-
213
-	return $p;
199
+    $code = champ_sql('url_site', $p);
200
+    if (strpos($code, '@$Pile[0]') !== false) {
201
+        $code = generer_generer_url('site', $p);
202
+        if ($code === null) {
203
+            return null;
204
+        }
205
+    } else {
206
+        if (!$p->etoile) {
207
+            $code = "calculer_url($code,'','url', \$connect)";
208
+        }
209
+    }
210
+    $p->code = $code;
211
+    $p->interdire_scripts = false;
212
+
213
+    return $p;
214 214
 }
215 215
 
216 216
 // Autres balises URL_*, qui ne concernent pas une table
@@ -229,11 +229,11 @@  discard block
 block discarded – undo
229 229
  *     Pile complétée par le code à générer
230 230
  */
231 231
 function balise_URL_SITE_SPIP_dist($p) {
232
-	$p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')";
233
-	$p->code = 'spip_htmlspecialchars(' . $p->code . ')';
234
-	$p->interdire_scripts = false;
232
+    $p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')";
233
+    $p->code = 'spip_htmlspecialchars(' . $p->code . ')';
234
+    $p->interdire_scripts = false;
235 235
 
236
-	return $p;
236
+    return $p;
237 237
 }
238 238
 
239 239
 
@@ -262,42 +262,42 @@  discard block
 block discarded – undo
262 262
  */
263 263
 function balise_URL_PAGE_dist($p) {
264 264
 
265
-	$code = interprete_argument_balise(1, $p);
266
-	$args = interprete_argument_balise(2, $p);
267
-	if ($args == null) {
268
-		$args = "''";
269
-	}
270
-
271
-	if ($s = trouver_nom_serveur_distant($p)) {
272
-		// si une fonction de generation des url a ete definie pour ce connect l'utiliser
273
-		// elle devra aussi traiter le cas derogatoire type=page
274
-		if (function_exists($f = 'generer_generer_url_' . $s)) {
275
-			if ($args and $args !== "''") {
276
-				$code .= ", $args";
277
-			}
278
-			$code = $f('page', $code, $s);
279
-			$p->code = $code;
280
-			return $p;
281
-		}
282
-		$s = 'connect=' . addslashes($s);
283
-		$args = (($args and $args !== "''") ? "$args . '&$s'" : "'$s'");
284
-	}
285
-
286
-	if (!$code) {
287
-		$noentities = $p->etoile ? "'&'" : '';
288
-		$code = "url_de_base() . preg_replace(',^./,', '', self($noentities))";
289
-	} else {
290
-		if (!$args) {
291
-			$args = "''";
292
-		}
293
-		$noentities = $p->etoile ? ', true' : '';
294
-		$code = "generer_url_public($code, $args$noentities)";
295
-	}
296
-	$p->code = $code;
297
-	spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO);
298
-
299
-	#$p->interdire_scripts = true;
300
-	return $p;
265
+    $code = interprete_argument_balise(1, $p);
266
+    $args = interprete_argument_balise(2, $p);
267
+    if ($args == null) {
268
+        $args = "''";
269
+    }
270
+
271
+    if ($s = trouver_nom_serveur_distant($p)) {
272
+        // si une fonction de generation des url a ete definie pour ce connect l'utiliser
273
+        // elle devra aussi traiter le cas derogatoire type=page
274
+        if (function_exists($f = 'generer_generer_url_' . $s)) {
275
+            if ($args and $args !== "''") {
276
+                $code .= ", $args";
277
+            }
278
+            $code = $f('page', $code, $s);
279
+            $p->code = $code;
280
+            return $p;
281
+        }
282
+        $s = 'connect=' . addslashes($s);
283
+        $args = (($args and $args !== "''") ? "$args . '&$s'" : "'$s'");
284
+    }
285
+
286
+    if (!$code) {
287
+        $noentities = $p->etoile ? "'&'" : '';
288
+        $code = "url_de_base() . preg_replace(',^./,', '', self($noentities))";
289
+    } else {
290
+        if (!$args) {
291
+            $args = "''";
292
+        }
293
+        $noentities = $p->etoile ? ', true' : '';
294
+        $code = "generer_url_public($code, $args$noentities)";
295
+    }
296
+    $p->code = $code;
297
+    spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO);
298
+
299
+    #$p->interdire_scripts = true;
300
+    return $p;
301 301
 }
302 302
 
303 303
 
@@ -324,24 +324,24 @@  discard block
 block discarded – undo
324 324
  */
325 325
 function balise_URL_ECRIRE_dist($p) {
326 326
 
327
-	$code = interprete_argument_balise(1, $p);
328
-	if (!$code) {
329
-		$fonc = "''";
330
-	} else {
331
-		$fonc = $code;
332
-		$args = interprete_argument_balise(2, $p);
333
-		if ($args === null) {
334
-			$args = "''";
335
-		}
336
-		$noentities = $p->etoile ? ', true' : '';
337
-		if (($args != "''") or $noentities) {
338
-			$fonc .= ",$args$noentities";
339
-		}
340
-	}
341
-	$p->code = 'generer_url_ecrire(' . $fonc . ')';
342
-	$p->interdire_scripts = false;
343
-
344
-	return $p;
327
+    $code = interprete_argument_balise(1, $p);
328
+    if (!$code) {
329
+        $fonc = "''";
330
+    } else {
331
+        $fonc = $code;
332
+        $args = interprete_argument_balise(2, $p);
333
+        if ($args === null) {
334
+            $args = "''";
335
+        }
336
+        $noentities = $p->etoile ? ', true' : '';
337
+        if (($args != "''") or $noentities) {
338
+            $fonc .= ",$args$noentities";
339
+        }
340
+    }
341
+    $p->code = 'generer_url_ecrire(' . $fonc . ')';
342
+    $p->interdire_scripts = false;
343
+
344
+    return $p;
345 345
 }
346 346
 
347 347
 
@@ -367,24 +367,24 @@  discard block
 block discarded – undo
367 367
  *     Pile complétée par le code à générer
368 368
  */
369 369
 function balise_URL_ACTION_AUTEUR_dist($p) {
370
-	$p->descr['session'] = true;
371
-
372
-	$p->code = interprete_argument_balise(1, $p);
373
-
374
-	$args = interprete_argument_balise(2, $p);
375
-	if ($args != "''" && $args !== null) {
376
-		$p->code .= ',' . $args;
377
-	}
378
-	$redirect = interprete_argument_balise(3, $p);
379
-	if ($redirect != "''" && $redirect !== null) {
380
-		if ($args == "''" || $args === null) {
381
-			$p->code .= ",''";
382
-		}
383
-		$p->code .= ',' . $redirect;
384
-	}
385
-
386
-	$p->code = 'generer_action_auteur(' . $p->code . ')';
387
-	$p->interdire_scripts = false;
388
-
389
-	return $p;
370
+    $p->descr['session'] = true;
371
+
372
+    $p->code = interprete_argument_balise(1, $p);
373
+
374
+    $args = interprete_argument_balise(2, $p);
375
+    if ($args != "''" && $args !== null) {
376
+        $p->code .= ',' . $args;
377
+    }
378
+    $redirect = interprete_argument_balise(3, $p);
379
+    if ($redirect != "''" && $redirect !== null) {
380
+        if ($args == "''" || $args === null) {
381
+            $p->code .= ",''";
382
+        }
383
+        $p->code .= ',' . $redirect;
384
+    }
385
+
386
+    $p->code = 'generer_action_auteur(' . $p->code . ')';
387
+    $p->interdire_scripts = false;
388
+
389
+    return $p;
390 390
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 function generer_generer_url_arg($type, $p, $_id) {
76 76
 	if ($s = trouver_nom_serveur_distant($p)) {
77 77
 		// si une fonction de generation des url a ete definie pour ce connect l'utiliser
78
-		if (function_exists($f = 'generer_generer_url_' . $s)) {
78
+		if (function_exists($f = 'generer_generer_url_'.$s)) {
79 79
 			return $f($type, $_id, $s);
80 80
 		}
81 81
 		if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) {
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 		# exception des urls de documents sur un serveur distant...
86 86
 		if ($type == 'document') {
87 87
 			return
88
-				"quete_meta('adresse_site', $s) . '/' .\n\t" .
89
-				"quete_meta('dir_img', $s) . \n\t" .
88
+				"quete_meta('adresse_site', $s) . '/' .\n\t".
89
+				"quete_meta('dir_img', $s) . \n\t".
90 90
 				"quete_fichier($_id,$s)";
91 91
 		}
92 92
 		$s = ", '', '', $s, quete_meta('type_urls', $s)";
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
  */
231 231
 function balise_URL_SITE_SPIP_dist($p) {
232 232
 	$p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')";
233
-	$p->code = 'spip_htmlspecialchars(' . $p->code . ')';
233
+	$p->code = 'spip_htmlspecialchars('.$p->code.')';
234 234
 	$p->interdire_scripts = false;
235 235
 
236 236
 	return $p;
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	if ($s = trouver_nom_serveur_distant($p)) {
272 272
 		// si une fonction de generation des url a ete definie pour ce connect l'utiliser
273 273
 		// elle devra aussi traiter le cas derogatoire type=page
274
-		if (function_exists($f = 'generer_generer_url_' . $s)) {
274
+		if (function_exists($f = 'generer_generer_url_'.$s)) {
275 275
 			if ($args and $args !== "''") {
276 276
 				$code .= ", $args";
277 277
 			}
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 			$p->code = $code;
280 280
 			return $p;
281 281
 		}
282
-		$s = 'connect=' . addslashes($s);
282
+		$s = 'connect='.addslashes($s);
283 283
 		$args = (($args and $args !== "''") ? "$args . '&$s'" : "'$s'");
284 284
 	}
285 285
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 		$code = "generer_url_public($code, $args$noentities)";
295 295
 	}
296 296
 	$p->code = $code;
297
-	spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO);
297
+	spip_log("Calcul url page : connect vaut $s ca donne :".$p->code." args $args", _LOG_INFO);
298 298
 
299 299
 	#$p->interdire_scripts = true;
300 300
 	return $p;
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 			$fonc .= ",$args$noentities";
339 339
 		}
340 340
 	}
341
-	$p->code = 'generer_url_ecrire(' . $fonc . ')';
341
+	$p->code = 'generer_url_ecrire('.$fonc.')';
342 342
 	$p->interdire_scripts = false;
343 343
 
344 344
 	return $p;
@@ -373,17 +373,17 @@  discard block
 block discarded – undo
373 373
 
374 374
 	$args = interprete_argument_balise(2, $p);
375 375
 	if ($args != "''" && $args !== null) {
376
-		$p->code .= ',' . $args;
376
+		$p->code .= ','.$args;
377 377
 	}
378 378
 	$redirect = interprete_argument_balise(3, $p);
379 379
 	if ($redirect != "''" && $redirect !== null) {
380 380
 		if ($args == "''" || $args === null) {
381 381
 			$p->code .= ",''";
382 382
 		}
383
-		$p->code .= ',' . $redirect;
383
+		$p->code .= ','.$redirect;
384 384
 	}
385 385
 
386
-	$p->code = 'generer_action_auteur(' . $p->code . ')';
386
+	$p->code = 'generer_action_auteur('.$p->code.')';
387 387
 	$p->interdire_scripts = false;
388 388
 
389 389
 	return $p;
Please login to merge, or discard this patch.
ecrire/balise/formulaire_ecrire_auteur.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 include_spip('base/abstract_sql');
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
  *     Pile complétée du code compilé
42 42
  **/
43 43
 function balise_FORMULAIRE_ECRIRE_AUTEUR($p) {
44
-	return calculer_balise_dynamique($p, 'FORMULAIRE_ECRIRE_AUTEUR', ['id_auteur', 'id_article', 'email']);
44
+    return calculer_balise_dynamique($p, 'FORMULAIRE_ECRIRE_AUTEUR', ['id_auteur', 'id_article', 'email']);
45 45
 }
46 46
 
47 47
 /**
@@ -59,44 +59,44 @@  discard block
 block discarded – undo
59 59
  *   - chaîne vide sinon (erreur ou non affichage).
60 60
  */
61 61
 function balise_FORMULAIRE_ECRIRE_AUTEUR_stat($args, $context_compil) {
62
-	include_spip('inc/filtres');
63
-	// Pas d'id_auteur ni d'id_article ? Erreur de contexte
64
-	$id = intval($args[1]);
65
-	if (!$args[0] and !$id) {
66
-		$msg = [
67
-			'zbug_champ_hors_motif',
68
-			[
69
-				'champ' => 'FORMULAIRE_ECRIRE_AUTEUR',
70
-				'motif' => 'AUTEURS/ARTICLES'
71
-			]
72
-		];
62
+    include_spip('inc/filtres');
63
+    // Pas d'id_auteur ni d'id_article ? Erreur de contexte
64
+    $id = intval($args[1]);
65
+    if (!$args[0] and !$id) {
66
+        $msg = [
67
+            'zbug_champ_hors_motif',
68
+            [
69
+                'champ' => 'FORMULAIRE_ECRIRE_AUTEUR',
70
+                'motif' => 'AUTEURS/ARTICLES'
71
+            ]
72
+        ];
73 73
 
74
-		erreur_squelette($msg, $context_compil);
74
+        erreur_squelette($msg, $context_compil);
75 75
 
76
-		return '';
77
-	}
78
-	// Si on est dans un contexte article,
79
-	// sortir tous les mails des auteurs de l'article
80
-	if (!$args[0] and $id) {
81
-		$r = '';
82
-		$s = sql_allfetsel(
83
-			'email',
84
-			'spip_auteurs AS A LEFT JOIN spip_auteurs_liens AS L ON (A.id_auteur=L.id_auteur AND L.objet=\'article\')',
85
-			"A.email != '' AND L.id_objet=$id"
86
-		);
87
-		foreach ($s as $row) {
88
-			if (email_valide($row['email'])) {
89
-				$r .= ', ' . $row['email'];
90
-			}
91
-		}
92
-		$args[2] = substr($r, 2);
93
-	}
76
+        return '';
77
+    }
78
+    // Si on est dans un contexte article,
79
+    // sortir tous les mails des auteurs de l'article
80
+    if (!$args[0] and $id) {
81
+        $r = '';
82
+        $s = sql_allfetsel(
83
+            'email',
84
+            'spip_auteurs AS A LEFT JOIN spip_auteurs_liens AS L ON (A.id_auteur=L.id_auteur AND L.objet=\'article\')',
85
+            "A.email != '' AND L.id_objet=$id"
86
+        );
87
+        foreach ($s as $row) {
88
+            if (email_valide($row['email'])) {
89
+                $r .= ', ' . $row['email'];
90
+            }
91
+        }
92
+        $args[2] = substr($r, 2);
93
+    }
94 94
 
95
-	// On ne peut pas ecrire a un auteur dont le mail n'est pas valide
96
-	if (!$args[2] or !email_valide($args[2])) {
97
-		return '';
98
-	}
95
+    // On ne peut pas ecrire a un auteur dont le mail n'est pas valide
96
+    if (!$args[2] or !email_valide($args[2])) {
97
+        return '';
98
+    }
99 99
 
100
-	// OK
101
-	return $args;
100
+    // OK
101
+    return $args;
102 102
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@
 block discarded – undo
86 86
 		);
87 87
 		foreach ($s as $row) {
88 88
 			if (email_valide($row['email'])) {
89
-				$r .= ', ' . $row['email'];
89
+				$r .= ', '.$row['email'];
90 90
 			}
91 91
 		}
92 92
 		$args[2] = substr($r, 2);
Please login to merge, or discard this patch.