Completed
Push — master ( d593dc...91e0b1 )
by cam
01:24
created
ecrire/inc/admin.php 1 patch
Indentation   +129 added lines, -129 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
 /**
@@ -45,29 +45,29 @@  discard block
 block discarded – undo
45 45
  *     sinon code HTML de la page après le traitement effectué.
46 46
  **/
47 47
 function inc_admin_dist($script, $titre, $comment = '', $anonymous = false) {
48
-	$reprise = true;
49
-	if (
50
-		!isset($GLOBALS['meta'][$script])
51
-		or !isset($GLOBALS['meta']['admin'])
52
-	) {
53
-		$reprise = false;
54
-		$res = debut_admin($script, $titre, $comment);
55
-		if ($res) {
56
-			return $res;
57
-		}
58
-		spip_log("meta: $script " . print_r($_POST, true));
59
-		ecrire_meta($script, serialize($_POST));
60
-	}
48
+    $reprise = true;
49
+    if (
50
+        !isset($GLOBALS['meta'][$script])
51
+        or !isset($GLOBALS['meta']['admin'])
52
+    ) {
53
+        $reprise = false;
54
+        $res = debut_admin($script, $titre, $comment);
55
+        if ($res) {
56
+            return $res;
57
+        }
58
+        spip_log("meta: $script " . print_r($_POST, true));
59
+        ecrire_meta($script, serialize($_POST));
60
+    }
61 61
 
62
-	$res = admin_verifie_session($script, $anonymous);
63
-	if ($res) {
64
-		return $res;
65
-	}
66
-	$base = charger_fonction($script, 'base');
67
-	$base($titre, $reprise);
68
-	fin_admin($script);
62
+    $res = admin_verifie_session($script, $anonymous);
63
+    if ($res) {
64
+        return $res;
65
+    }
66
+    $base = charger_fonction($script, 'base');
67
+    $base($titre, $reprise);
68
+    fin_admin($script);
69 69
 
70
-	return '';
70
+    return '';
71 71
 }
72 72
 
73 73
 /**
@@ -98,35 +98,35 @@  discard block
 block discarded – undo
98 98
  *     Code HTML si message d'erreur, '' sinon;
99 99
  */
100 100
 function admin_verifie_session($script, $anonymous = false) {
101
-	include_spip('base/abstract_sql');
102
-	$pref = sprintf('_%d_', $GLOBALS['visiteur_session']['id_auteur']);
103
-	$signal = fichier_admin($script, "$script$pref");
104
-	$valeur = sql_getfetsel('valeur', 'spip_meta', "nom='admin'");
105
-	if ($valeur === null) {
106
-		ecrire_meta('admin', $signal, 'non');
107
-	} else {
108
-		if (!$anonymous and ($valeur != $signal)) {
109
-			if (
110
-				!preg_match('/^(.*)_(\d+)_/', $GLOBALS['meta']['admin'], $l)
111
-				or intval($l[2]) != $GLOBALS['visiteur_session']['id_auteur']
112
-			) {
113
-				include_spip('inc/minipres');
114
-				spip_log("refus de lancer $script, priorite a $valeur");
101
+    include_spip('base/abstract_sql');
102
+    $pref = sprintf('_%d_', $GLOBALS['visiteur_session']['id_auteur']);
103
+    $signal = fichier_admin($script, "$script$pref");
104
+    $valeur = sql_getfetsel('valeur', 'spip_meta', "nom='admin'");
105
+    if ($valeur === null) {
106
+        ecrire_meta('admin', $signal, 'non');
107
+    } else {
108
+        if (!$anonymous and ($valeur != $signal)) {
109
+            if (
110
+                !preg_match('/^(.*)_(\d+)_/', $GLOBALS['meta']['admin'], $l)
111
+                or intval($l[2]) != $GLOBALS['visiteur_session']['id_auteur']
112
+            ) {
113
+                include_spip('inc/minipres');
114
+                spip_log("refus de lancer $script, priorite a $valeur");
115 115
 
116
-				return minipres(_T('info_travaux_texte'), '', ['status' => 503]);
117
-			}
118
-		}
119
-	}
120
-	$journal = 'spip';
121
-	if (autoriser('configurer')) {
122
-		// c'est une action webmestre, soit par ftp soit par statut webmestre
123
-		$journal = 'webmestre';
124
-	}
125
-	// on pourrait statuer automatiquement les webmestres a l'init d'une action auth par ftp ... ?
116
+                return minipres(_T('info_travaux_texte'), '', ['status' => 503]);
117
+            }
118
+        }
119
+    }
120
+    $journal = 'spip';
121
+    if (autoriser('configurer')) {
122
+        // c'est une action webmestre, soit par ftp soit par statut webmestre
123
+        $journal = 'webmestre';
124
+    }
125
+    // on pourrait statuer automatiquement les webmestres a l'init d'une action auth par ftp ... ?
126 126
 
127
-	spip_log("admin $pref" . ($valeur ? ' (reprise)' : ' (init)'), $journal);
127
+    spip_log("admin $pref" . ($valeur ? ' (reprise)' : ' (init)'), $journal);
128 128
 
129
-	return '';
129
+    return '';
130 130
 }
131 131
 
132 132
 /**
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
  *     Chemin du répertoire.
140 140
  **/
141 141
 function dir_admin() {
142
-	if (autoriser('configurer')) {
143
-		return _DIR_TMP;
144
-	} else {
145
-		return _DIR_TRANSFERT . $GLOBALS['visiteur_session']['login'] . '/';
146
-	}
142
+    if (autoriser('configurer')) {
143
+        return _DIR_TMP;
144
+    } else {
145
+        return _DIR_TRANSFERT . $GLOBALS['visiteur_session']['login'] . '/';
146
+    }
147 147
 }
148 148
 
149 149
 /**
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
  *     Nom du fichier
161 161
  **/
162 162
 function fichier_admin($action, $pref = 'admin_') {
163
-	return $pref .
164
-	substr(md5($action . (time() & ~2047) . $GLOBALS['visiteur_session']['login']), 0, 10);
163
+    return $pref .
164
+    substr(md5($action . (time() & ~2047) . $GLOBALS['visiteur_session']['login']), 0, 10);
165 165
 }
166 166
 
167 167
 /**
@@ -187,73 +187,73 @@  discard block
 block discarded – undo
187 187
  *     sinon chaîne vide si déjà fait.
188 188
  **/
189 189
 function debut_admin($script, $action = '', $corps = '') {
190
-	if ((!$action) || !(autoriser('webmestre') or autoriser('chargerftp'))) {
191
-		include_spip('inc/minipres');
190
+    if ((!$action) || !(autoriser('webmestre') or autoriser('chargerftp'))) {
191
+        include_spip('inc/minipres');
192 192
 
193
-		return minipres();
194
-	} else {
195
-		$dir = dir_admin();
196
-		$signal = fichier_admin($script);
197
-		if (@file_exists($dir . $signal)) {
198
-			spip_log("Action admin: $action");
193
+        return minipres();
194
+    } else {
195
+        $dir = dir_admin();
196
+        $signal = fichier_admin($script);
197
+        if (@file_exists($dir . $signal)) {
198
+            spip_log("Action admin: $action");
199 199
 
200
-			return '';
201
-		}
202
-		include_spip('inc/minipres');
200
+            return '';
201
+        }
202
+        include_spip('inc/minipres');
203 203
 
204
-		// Si on est un super-admin, un bouton de validation suffit
205
-		// sauf dans les cas destroy
206
-		if (
207
-			(autoriser('webmestre') or $script === 'repair')
208
-			and $script != 'delete_all'
209
-		) {
210
-			if (_request('validation_admin') == $signal) {
211
-				spip_log("Action super-admin: $action");
204
+        // Si on est un super-admin, un bouton de validation suffit
205
+        // sauf dans les cas destroy
206
+        if (
207
+            (autoriser('webmestre') or $script === 'repair')
208
+            and $script != 'delete_all'
209
+        ) {
210
+            if (_request('validation_admin') == $signal) {
211
+                spip_log("Action super-admin: $action");
212 212
 
213
-				return '';
214
-			}
215
-			$corps .= '<input type="hidden" name="validation_admin" value="' . $signal . '" />';
216
-			$suivant = _T('bouton_valider');
217
-			$js = '';
218
-		} else {
219
-			// cet appel permet d'assurer un copier-coller du nom du repertoire a creer dans tmp (esj)
220
-			// l'insertion du script a cet endroit n'est pas xhtml licite
221
-			// mais evite de l'embarquer dans toutes les pages minipres
222
-			$corps .= http_script('', 'spip_barre.js');
213
+                return '';
214
+            }
215
+            $corps .= '<input type="hidden" name="validation_admin" value="' . $signal . '" />';
216
+            $suivant = _T('bouton_valider');
217
+            $js = '';
218
+        } else {
219
+            // cet appel permet d'assurer un copier-coller du nom du repertoire a creer dans tmp (esj)
220
+            // l'insertion du script a cet endroit n'est pas xhtml licite
221
+            // mais evite de l'embarquer dans toutes les pages minipres
222
+            $corps .= http_script('', 'spip_barre.js');
223 223
 
224
-			$corps .= '<fieldset><legend>'
225
-				. _T('info_authentification_ftp')
226
-				. aider('ftp_auth')
227
-				. "</legend>\n<label for='fichier'>"
228
-				. _T('info_creer_repertoire')
229
-				. "</label>\n"
230
-				. "<span id='signal' class='formo'>" . $signal . '</span>'
231
-				. "<input type='hidden' id='fichier' name='fichier' value='"
232
-				. $signal
233
-				. "' />"
234
-				. _T('info_creer_repertoire_2', ['repertoire' => joli_repertoire($dir)])
235
-				. '</fieldset>';
224
+            $corps .= '<fieldset><legend>'
225
+                . _T('info_authentification_ftp')
226
+                . aider('ftp_auth')
227
+                . "</legend>\n<label for='fichier'>"
228
+                . _T('info_creer_repertoire')
229
+                . "</label>\n"
230
+                . "<span id='signal' class='formo'>" . $signal . '</span>'
231
+                . "<input type='hidden' id='fichier' name='fichier' value='"
232
+                . $signal
233
+                . "' />"
234
+                . _T('info_creer_repertoire_2', ['repertoire' => joli_repertoire($dir)])
235
+                . '</fieldset>';
236 236
 
237
-			$suivant = _T('bouton_recharger_page');
237
+            $suivant = _T('bouton_recharger_page');
238 238
 
239
-			// code volontairement tordu:
240
-			// provoquer la copie dans le presse papier du nom du repertoire
241
-			// en remettant a vide le champ pour que ca marche aussi en cas
242
-			// de JavaScript inactif.
243
-			$js = " onload='var range=document.createRange(); var signal = document.getElementById(\"signal\"); var userSelection = window.getSelection(); range.setStart(signal,0); range.setEnd(signal,1); userSelection.addRange(range);'";
244
-		}
239
+            // code volontairement tordu:
240
+            // provoquer la copie dans le presse papier du nom du repertoire
241
+            // en remettant a vide le champ pour que ca marche aussi en cas
242
+            // de JavaScript inactif.
243
+            $js = " onload='var range=document.createRange(); var signal = document.getElementById(\"signal\"); var userSelection = window.getSelection(); range.setStart(signal,0); range.setEnd(signal,1); userSelection.addRange(range);'";
244
+        }
245 245
 
246
-		// admin/xxx correspond
247
-		// a exec/base_xxx de preference
248
-		// et exec/xxx sinon (compat)
249
-		if (tester_url_ecrire("base_$script")) {
250
-			$script = "base_$script";
251
-		}
252
-		$form = copy_request($script, $corps, $suivant);
253
-		$info_action = _T('info_action', ['action' => "$action"]);
246
+        // admin/xxx correspond
247
+        // a exec/base_xxx de preference
248
+        // et exec/xxx sinon (compat)
249
+        if (tester_url_ecrire("base_$script")) {
250
+            $script = "base_$script";
251
+        }
252
+        $form = copy_request($script, $corps, $suivant);
253
+        $info_action = _T('info_action', ['action' => "$action"]);
254 254
 
255
-		return minipres($info_action, $form, $js);
256
-	}
255
+        return minipres($info_action, $form, $js);
256
+    }
257 257
 }
258 258
 
259 259
 /**
@@ -264,13 +264,13 @@  discard block
 block discarded – undo
264 264
  *     Nom de l'action (en base) qui a été exécutée
265 265
  **/
266 266
 function fin_admin($action) {
267
-	$signal = dir_admin() . fichier_admin($action);
268
-	spip_unlink($signal);
269
-	if ($action != 'delete_all') {
270
-		effacer_meta($action);
271
-		effacer_meta('admin');
272
-		spip_log("efface les meta admin et $action ");
273
-	}
267
+    $signal = dir_admin() . fichier_admin($action);
268
+    spip_unlink($signal);
269
+    if ($action != 'delete_all') {
270
+        effacer_meta($action);
271
+        effacer_meta('admin');
272
+        spip_log("efface les meta admin et $action ");
273
+    }
274 274
 }
275 275
 
276 276
 /**
@@ -289,14 +289,14 @@  discard block
 block discarded – undo
289 289
  *     Code HTML du formulaire
290 290
  **/
291 291
 function copy_request($script, $suite, $submit = '') {
292
-	include_spip('inc/filtres');
293
-	foreach (array_merge($_POST, $_GET) as $n => $c) {
294
-		if (!in_array($n, ['fichier', 'exec', 'validation_admin']) and !is_array($c)) {
295
-			$suite .= "\n<input type='hidden' name='" . spip_htmlspecialchars($n) . "' value='" .
296
-				entites_html($c) .
297
-				"'  />";
298
-		}
299
-	}
292
+    include_spip('inc/filtres');
293
+    foreach (array_merge($_POST, $_GET) as $n => $c) {
294
+        if (!in_array($n, ['fichier', 'exec', 'validation_admin']) and !is_array($c)) {
295
+            $suite .= "\n<input type='hidden' name='" . spip_htmlspecialchars($n) . "' value='" .
296
+                entites_html($c) .
297
+                "'  />";
298
+        }
299
+    }
300 300
 
301
-	return generer_form_ecrire($script, $suite, '', $submit);
301
+    return generer_form_ecrire($script, $suite, '', $submit);
302 302
 }
Please login to merge, or discard this patch.
ecrire/inc/journal.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 
@@ -24,11 +24,11 @@  discard block
 block discarded – undo
24 24
  * @param array $opt
25 25
  */
26 26
 function inc_journal_dist($phrase, $opt = []) {
27
-	if (!strlen($phrase)) {
28
-		return;
29
-	}
30
-	if ($opt) {
31
-		$phrase .= ' :: ' . str_replace("\n", ' ', join(', ', $opt));
32
-	}
33
-	spip_log($phrase, 'journal');
27
+    if (!strlen($phrase)) {
28
+        return;
29
+    }
30
+    if ($opt) {
31
+        $phrase .= ' :: ' . str_replace("\n", ' ', join(', ', $opt));
32
+    }
33
+    spip_log($phrase, 'journal');
34 34
 }
Please login to merge, or discard this patch.
ecrire/inc/actions.php 1 patch
Indentation   +26 added lines, -26 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
 /**
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
  *     URL, code HTML du formulaire ou tableau (action, arg, hash)
44 44
  */
45 45
 function generer_action_auteur($action, $arg = '', $redirect = '', $mode = false, $att = '', $public = false) {
46
-	$securiser_action = charger_fonction('securiser_action', 'inc');
46
+    $securiser_action = charger_fonction('securiser_action', 'inc');
47 47
 
48
-	return $securiser_action($action, $arg, $redirect, $mode, $att, $public);
48
+    return $securiser_action($action, $arg, $redirect, $mode, $att, $public);
49 49
 }
50 50
 
51 51
 /**
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
  *     Code HTML du formulaire
79 79
  */
80 80
 function redirige_action_auteur($action, $arg, $ret, $gra = '', $mode = false, $atts = '', $public = false) {
81
-	$r = ($public ? _DIR_RESTREINT_ABS : _DIR_RESTREINT) . generer_url_ecrire($ret, $gra, true, true);
81
+    $r = ($public ? _DIR_RESTREINT_ABS : _DIR_RESTREINT) . generer_url_ecrire($ret, $gra, true, true);
82 82
 
83
-	return generer_action_auteur($action, $arg, $r, $mode, $atts, $public);
83
+    return generer_action_auteur($action, $arg, $r, $mode, $atts, $public);
84 84
 }
85 85
 
86 86
 /**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
  *     URL, code HTML du formulaire ou tableau (action, arg, hash)
106 106
  */
107 107
 function redirige_action_post($action, $arg, $ret, $gra, $corps, $att = '') {
108
-	$r = _DIR_RESTREINT . generer_url_ecrire($ret, $gra, false, true);
108
+    $r = _DIR_RESTREINT . generer_url_ecrire($ret, $gra, false, true);
109 109
 
110
-	return generer_action_auteur($action, $arg, $r, $corps, $att . " method='post'");
110
+    return generer_action_auteur($action, $arg, $r, $corps, $att . " method='post'");
111 111
 }
112 112
 
113 113
 
@@ -122,26 +122,26 @@  discard block
 block discarded – undo
122 122
  *   passer "text/html" comme $content_type
123 123
  */
124 124
 function ajax_retour($corps, $content_type = null) {
125
-	$xml = false;
126
-	if (is_null($content_type) or $content_type === true) {
127
-		$xml = true;
128
-		$content_type = 'text/html';
129
-	} elseif (!$content_type or !is_string($content_type) or strpos($content_type, '/') === false) {
130
-		$content_type = 'text/html';
131
-	}
125
+    $xml = false;
126
+    if (is_null($content_type) or $content_type === true) {
127
+        $xml = true;
128
+        $content_type = 'text/html';
129
+    } elseif (!$content_type or !is_string($content_type) or strpos($content_type, '/') === false) {
130
+        $content_type = 'text/html';
131
+    }
132 132
 
133
-	$e = '';
134
-	if (
135
-		isset($_COOKIE['spip_admin'])
136
-		and ((_request('var_mode') == 'debug') or !empty($GLOBALS['tableau_des_temps']))
137
-	) {
138
-		$e = erreur_squelette();
139
-	}
133
+    $e = '';
134
+    if (
135
+        isset($_COOKIE['spip_admin'])
136
+        and ((_request('var_mode') == 'debug') or !empty($GLOBALS['tableau_des_temps']))
137
+    ) {
138
+        $e = erreur_squelette();
139
+    }
140 140
 
141
-	$c = $GLOBALS['meta']['charset'];
142
-	header('Content-Type: ' . $content_type . '; charset=' . $c);
143
-	$debut = (($xml and strlen(trim($corps))) ? '<' . "?xml version='1.0' encoding='" . $c . "'?" . ">\n" : '');
144
-	$fin = '';
141
+    $c = $GLOBALS['meta']['charset'];
142
+    header('Content-Type: ' . $content_type . '; charset=' . $c);
143
+    $debut = (($xml and strlen(trim($corps))) ? '<' . "?xml version='1.0' encoding='" . $c . "'?" . ">\n" : '');
144
+    $fin = '';
145 145
 
146
-	echo $debut, $corps, $fin, $e;
146
+    echo $debut, $corps, $fin, $e;
147 147
 }
Please login to merge, or discard this patch.
ecrire/inc/filtres_alertes.php 1 patch
Indentation   +81 added lines, -81 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
 /**
@@ -43,22 +43,22 @@  discard block
 block discarded – undo
43 43
  *     Pile complétée par le code à générer
44 44
  */
45 45
 function balise_ALERTE_MESSAGE_dist($p) {
46
-	$_texte = interprete_argument_balise(1, $p);
47
-	$_titre = interprete_argument_balise(2, $p);
48
-	$_class = interprete_argument_balise(3, $p);
49
-	$_role  = interprete_argument_balise(4, $p);
50
-	$_id    = interprete_argument_balise(5, $p);
51
-	$_texte = ($_texte ? $_texte     : "''");
52
-	$_titre = ($_titre ? ", $_titre" : ', null');
53
-	$_class = ($_class ? ", $_class" : ', null');
54
-	$_role  = ($_role  ? ", $_role"  : ', null');
55
-	$_id    = ($_id    ? ", $_id"    : ', null');
46
+    $_texte = interprete_argument_balise(1, $p);
47
+    $_titre = interprete_argument_balise(2, $p);
48
+    $_class = interprete_argument_balise(3, $p);
49
+    $_role  = interprete_argument_balise(4, $p);
50
+    $_id    = interprete_argument_balise(5, $p);
51
+    $_texte = ($_texte ? $_texte     : "''");
52
+    $_titre = ($_titre ? ", $_titre" : ', null');
53
+    $_class = ($_class ? ", $_class" : ', null');
54
+    $_role  = ($_role  ? ", $_role"  : ', null');
55
+    $_id    = ($_id    ? ", $_id"    : ', null');
56 56
 
57
-	$f = chercher_filtre('message_alerte');
58
-	$p->code = "$f($_texte$_titre$_class$_role$_id)";
59
-	$p->interdire_scripts = false;
57
+    $f = chercher_filtre('message_alerte');
58
+    $p->code = "$f($_texte$_titre$_class$_role$_id)";
59
+    $p->interdire_scripts = false;
60 60
 
61
-	return $p;
61
+    return $p;
62 62
 }
63 63
 
64 64
 /**
@@ -86,20 +86,20 @@  discard block
 block discarded – undo
86 86
  *     Pile complétée par le code à générer
87 87
  */
88 88
 function balise_ALERTE_OUVRIR_dist($p) {
89
-	$_titre = interprete_argument_balise(1, $p);
90
-	$_class = interprete_argument_balise(2, $p);
91
-	$_role  = interprete_argument_balise(3, $p);
92
-	$_id    = interprete_argument_balise(4, $p);
93
-	$_titre = ($_titre ? "$_titre"   : 'null');
94
-	$_class = ($_class ? ", $_class" : ', null');
95
-	$_role  = ($_role  ? ", $_role"  : ', null');
96
-	$_id    = ($_id    ? ", $_id"    : ', null');
89
+    $_titre = interprete_argument_balise(1, $p);
90
+    $_class = interprete_argument_balise(2, $p);
91
+    $_role  = interprete_argument_balise(3, $p);
92
+    $_id    = interprete_argument_balise(4, $p);
93
+    $_titre = ($_titre ? "$_titre"   : 'null');
94
+    $_class = ($_class ? ", $_class" : ', null');
95
+    $_role  = ($_role  ? ", $_role"  : ', null');
96
+    $_id    = ($_id    ? ", $_id"    : ', null');
97 97
 
98
-	$f = chercher_filtre('message_alerte_ouvrir');
99
-	$p->code = "$f($_titre$_class$_role$_id)";
100
-	$p->interdire_scripts = false;
98
+    $f = chercher_filtre('message_alerte_ouvrir');
99
+    $p->code = "$f($_titre$_class$_role$_id)";
100
+    $p->interdire_scripts = false;
101 101
 
102
-	return $p;
102
+    return $p;
103 103
 }
104 104
 
105 105
 /**
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
  *     Pile complétée par le code à générer
122 122
  */
123 123
 function balise_ALERTE_FERMER_dist($p) {
124
-	$f = chercher_filtre('message_alerte_fermer');
125
-	$p->code = "$f()";
126
-	$p->interdire_scripts = false;
124
+    $f = chercher_filtre('message_alerte_fermer');
125
+    $p->code = "$f()";
126
+    $p->interdire_scripts = false;
127 127
 
128
-	return $p;
128
+    return $p;
129 129
 }
130 130
 
131 131
 /**
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
  */
161 161
 function message_alerte(string $texte, ?string $titre = null, ?string $class = null, ?string $role = null, ?string $id = null): string {
162 162
 
163
-	$message_alerte_ouvrir = chercher_filtre('message_alerte_ouvrir');
164
-	$message_alerte_fermer = chercher_filtre('message_alerte_fermer');
165
-	$message =
166
-		$message_alerte_ouvrir($titre, $class, $role, $id) .
167
-		$texte .
168
-		$message_alerte_fermer();
163
+    $message_alerte_ouvrir = chercher_filtre('message_alerte_ouvrir');
164
+    $message_alerte_fermer = chercher_filtre('message_alerte_fermer');
165
+    $message =
166
+        $message_alerte_ouvrir($titre, $class, $role, $id) .
167
+        $texte .
168
+        $message_alerte_fermer();
169 169
 
170
-	return $message;
170
+    return $message;
171 171
 }
172 172
 
173 173
 /**
@@ -198,55 +198,55 @@  discard block
 block discarded – undo
198 198
  */
199 199
 function message_alerte_ouvrir(?string $titre = null, ?string $class = null, ?string $role = null, ?string $id = null): string {
200 200
 
201
-	$prive = test_espace_prive();
201
+    $prive = test_espace_prive();
202 202
 
203
-	// Valeurs par défaut
204
-	$role = $role ?? 'alert'; // fallback uniquement si null
205
-	$class = $class ?? 'notice'; // fallback uniquement si null
203
+    // Valeurs par défaut
204
+    $role = $role ?? 'alert'; // fallback uniquement si null
205
+    $class = $class ?? 'notice'; // fallback uniquement si null
206 206
 
207
-	// Type d'alerte : le chercher dans les classes, nettoyer celles-ci, puis le réinjecter
208
-	$types = [
209
-		'notice',
210
-		'error',
211
-		'success',
212
-		'info',
213
-	];
214
-	$type  = array_intersect(explode(' ', $class), $types);
215
-	$type  = reset($type);
216
-	$class = trim(str_replace($types, '', $class) . " $type");
207
+    // Type d'alerte : le chercher dans les classes, nettoyer celles-ci, puis le réinjecter
208
+    $types = [
209
+        'notice',
210
+        'error',
211
+        'success',
212
+        'info',
213
+    ];
214
+    $type  = array_intersect(explode(' ', $class), $types);
215
+    $type  = reset($type);
216
+    $class = trim(str_replace($types, '', $class) . " $type");
217 217
 
218
-	// Classes
219
-	$class_racine = 'msg-alert';
220
-	$clearfix     = ($prive ? 'clearfix' : '');
221
-	$class_alerte = "$class_racine $class";
222
-	$class_texte  = "${class_racine}__text $clearfix";
223
-	$class_titre  = "${class_racine}__heading";
218
+    // Classes
219
+    $class_racine = 'msg-alert';
220
+    $clearfix     = ($prive ? 'clearfix' : '');
221
+    $class_alerte = "$class_racine $class";
222
+    $class_texte  = "${class_racine}__text $clearfix";
223
+    $class_titre  = "${class_racine}__heading";
224 224
 
225
-	// Titre : markup
226
-	$titre = trim($titre);
227
-	if (strlen($titre)) {
228
-		include_spip('inc/filtres');
229
-		// Si besoin on encapsule le titre : un h3 dans le privé, un simple div sinon.
230
-		$cherche_tag = ($prive ? '<h' : '<');
231
-		$wrap_tag    = ($prive ? '<h3>' : '<div>');
232
-		if (strpos($titre, $cherche_tag) !== 0) {
233
-			$titre = wrap($titre, $wrap_tag);
234
-		}
235
-		// puis on ajoute la classe
236
-		$titre = ajouter_class($titre, $class_titre);
237
-	}
225
+    // Titre : markup
226
+    $titre = trim($titre);
227
+    if (strlen($titre)) {
228
+        include_spip('inc/filtres');
229
+        // Si besoin on encapsule le titre : un h3 dans le privé, un simple div sinon.
230
+        $cherche_tag = ($prive ? '<h' : '<');
231
+        $wrap_tag    = ($prive ? '<h3>' : '<div>');
232
+        if (strpos($titre, $cherche_tag) !== 0) {
233
+            $titre = wrap($titre, $wrap_tag);
234
+        }
235
+        // puis on ajoute la classe
236
+        $titre = ajouter_class($titre, $class_titre);
237
+    }
238 238
 
239
-	// Attributs
240
-	$attr_role = ($role ? "role=\"$role\"" : '');
241
-	$attr_id   = ($id   ? "id=\"$id\"" : '');
242
-	$attr_data = ($type ? "data-alert=\"$type\"" : '');
239
+    // Attributs
240
+    $attr_role = ($role ? "role=\"$role\"" : '');
241
+    $attr_id   = ($id   ? "id=\"$id\"" : '');
242
+    $attr_data = ($type ? "data-alert=\"$type\"" : '');
243 243
 
244
-	$message =
245
-		"<div class=\"$class_alerte\" $attr_role $attr_id $attr_data>"
246
-			. $titre
247
-			. "<div class=\"$class_texte\">";
244
+    $message =
245
+        "<div class=\"$class_alerte\" $attr_role $attr_id $attr_data>"
246
+            . $titre
247
+            . "<div class=\"$class_texte\">";
248 248
 
249
-	return $message;
249
+    return $message;
250 250
 }
251 251
 
252 252
 /**
@@ -260,5 +260,5 @@  discard block
 block discarded – undo
260 260
  *     HTML de fin de l'alerte
261 261
  */
262 262
 function message_alerte_fermer(): string {
263
-	return '</div></div>';
263
+    return '</div></div>';
264 264
 }
Please login to merge, or discard this patch.
ecrire/inc/surligne.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Surligne
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -35,43 +35,43 @@  discard block
 block discarded – undo
35 35
  *     Page HTML
36 36
  **/
37 37
 function surligner_mots($page, $surcharge_surligne = '') {
38
-	$surlignejs_engines = [
39
-		[
40
-			',' . str_replace(['/', '.'], ['\/', '\.'], $GLOBALS['meta']['adresse_site']) . ',i',
41
-			',recherche=([^&]+),i'
42
-		], //SPIP
43
-		[',^http://(www\.)?google\.,i', ',q=([^&]+),i'], // Google
44
-		[',^http://(www\.)?search\.yahoo\.,i', ',p=([^&]+),i'], // Yahoo
45
-		[',^http://(www\.)?search\.msn\.,i', ',q=([^&]+),i'], // MSN
46
-		[',^http://(www\.)?search\.live\.,i', ',query=([^&]+),i'], // MSN Live
47
-		[',^http://(www\.)?search\.aol\.,i', ',userQuery=([^&]+),i'], // AOL
48
-		[',^http://(www\.)?ask\.com,i', ',q=([^&]+),i'], // Ask.com
49
-		[',^http://(www\.)?altavista\.,i', ',q=([^&]+),i'], // AltaVista
50
-		[',^http://(www\.)?feedster\.,i', ',q=([^&]+),i'], // Feedster
51
-		[',^http://(www\.)?search\.lycos\.,i', ',q=([^&]+),i'], // Lycos
52
-		[',^http://(www\.)?alltheweb\.,i', ',q=([^&]+),i'], // AllTheWeb
53
-		[',^http://(www\.)?technorati\.com,i', ',([^\?\/]+)(?:\?.*)$,i'], // Technorati
54
-	];
38
+    $surlignejs_engines = [
39
+        [
40
+            ',' . str_replace(['/', '.'], ['\/', '\.'], $GLOBALS['meta']['adresse_site']) . ',i',
41
+            ',recherche=([^&]+),i'
42
+        ], //SPIP
43
+        [',^http://(www\.)?google\.,i', ',q=([^&]+),i'], // Google
44
+        [',^http://(www\.)?search\.yahoo\.,i', ',p=([^&]+),i'], // Yahoo
45
+        [',^http://(www\.)?search\.msn\.,i', ',q=([^&]+),i'], // MSN
46
+        [',^http://(www\.)?search\.live\.,i', ',query=([^&]+),i'], // MSN Live
47
+        [',^http://(www\.)?search\.aol\.,i', ',userQuery=([^&]+),i'], // AOL
48
+        [',^http://(www\.)?ask\.com,i', ',q=([^&]+),i'], // Ask.com
49
+        [',^http://(www\.)?altavista\.,i', ',q=([^&]+),i'], // AltaVista
50
+        [',^http://(www\.)?feedster\.,i', ',q=([^&]+),i'], // Feedster
51
+        [',^http://(www\.)?search\.lycos\.,i', ',q=([^&]+),i'], // Lycos
52
+        [',^http://(www\.)?alltheweb\.,i', ',q=([^&]+),i'], // AllTheWeb
53
+        [',^http://(www\.)?technorati\.com,i', ',([^\?\/]+)(?:\?.*)$,i'], // Technorati
54
+    ];
55 55
 
56 56
 
57
-	$ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
58
-	//avoid a js injection
59
-	if ($surcharge_surligne) {
60
-		$surcharge_surligne = preg_replace(",(?<!\\\\)((?:(?>\\\\){2})*)('),", '$1\\\$2', $surcharge_surligne);
61
-		$surcharge_surligne = str_replace('\\', '\\\\', $surcharge_surligne);
62
-		if ($GLOBALS['meta']['charset'] == 'utf-8') {
63
-			include_spip('inc/charsets');
64
-			if (!is_utf8($surcharge_surligne)) {
65
-				$surcharge_surligne = utf8_encode($surcharge_surligne);
66
-			}
67
-		}
68
-		$surcharge_surligne = preg_replace(',\*$,', '', trim($surcharge_surligne)); # supprimer un * final
69
-	}
70
-	foreach ($surlignejs_engines as $engine) {
71
-		if ($surcharge_surligne || (preg_match($engine[0], $ref) && preg_match($engine[1], $ref))) {
72
-			//good referrer found or var_recherche is not null
73
-			include_spip('inc/filtres');
74
-			$script = "
57
+    $ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
58
+    //avoid a js injection
59
+    if ($surcharge_surligne) {
60
+        $surcharge_surligne = preg_replace(",(?<!\\\\)((?:(?>\\\\){2})*)('),", '$1\\\$2', $surcharge_surligne);
61
+        $surcharge_surligne = str_replace('\\', '\\\\', $surcharge_surligne);
62
+        if ($GLOBALS['meta']['charset'] == 'utf-8') {
63
+            include_spip('inc/charsets');
64
+            if (!is_utf8($surcharge_surligne)) {
65
+                $surcharge_surligne = utf8_encode($surcharge_surligne);
66
+            }
67
+        }
68
+        $surcharge_surligne = preg_replace(',\*$,', '', trim($surcharge_surligne)); # supprimer un * final
69
+    }
70
+    foreach ($surlignejs_engines as $engine) {
71
+        if ($surcharge_surligne || (preg_match($engine[0], $ref) && preg_match($engine[1], $ref))) {
72
+            //good referrer found or var_recherche is not null
73
+            include_spip('inc/filtres');
74
+            $script = "
75 75
       <script type='text/javascript' src='" . url_absolue(find_in_path('javascript/SearchHighlight.js')) . "'></script>
76 76
       <script type='text/javascript'>/*<![CDATA[*/
77 77
       if (window.jQuery)
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
             engines:[/^" . str_replace(['/', '.'], ['\/', '\.'], $GLOBALS['meta']['adresse_site']) . "/i,/recherche=([^&]+)/i],
85 85
             highlight:'.surlignable',
86 86
             nohighlight:'.pas_surlignable'" .
87
-				($surcharge_surligne ? ",
87
+                ($surcharge_surligne ? ",
88 88
             keys:'$surcharge_surligne'" : '') . ',
89 89
             min_length: 3
90 90
           })
@@ -92,14 +92,14 @@  discard block
 block discarded – undo
92 92
       })(jQuery);
93 93
       /*]]>*/</script>
94 94
       ';
95
-			// on l'insere juste avant </head>, sinon tout en bas
96
-			if (is_null($l = strpos($page, '</head>'))) {
97
-				$l = strlen($page);
98
-			}
99
-			$page = substr_replace($page, $script, $l, 0);
100
-			break;
101
-		}
102
-	}
95
+            // on l'insere juste avant </head>, sinon tout en bas
96
+            if (is_null($l = strpos($page, '</head>'))) {
97
+                $l = strlen($page);
98
+            }
99
+            $page = substr_replace($page, $script, $l, 0);
100
+            break;
101
+        }
102
+    }
103 103
 
104
-	return $page;
104
+    return $page;
105 105
 }
Please login to merge, or discard this patch.
ecrire/inc/acces.php 1 patch
Indentation   +240 added lines, -240 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
 /**
@@ -31,47 +31,47 @@  discard block
 block discarded – undo
31 31
  *     Mot de passe
32 32
  **/
33 33
 function creer_pass_aleatoire($longueur = 16, $sel = '') {
34
-	$seed = (int)round(((float)microtime() + 1) * time());
35
-
36
-	mt_srand($seed);
37
-	srand($seed);
38
-	$s = '';
39
-	$pass = '';
40
-	for ($i = 0; $i < $longueur; $i++) {
41
-		if (!$s) {
42
-			$s = mt_rand();
43
-			if (!$s) {
44
-				$s = rand();
45
-			}
46
-			$s = substr(md5(uniqid($s) . $sel), 0, 16);
47
-		}
48
-		$r = unpack('Cr', pack('H2', $s . $s));
49
-		$x = $r['r'] & 63;
50
-		if ($x < 10) {
51
-			$x = chr($x + 48);
52
-		} else {
53
-			if ($x < 36) {
54
-				$x = chr($x + 55);
55
-			} else {
56
-				if ($x < 62) {
57
-					$x = chr($x + 61);
58
-				} else {
59
-					if ($x == 63) {
60
-						$x = '/';
61
-					} else {
62
-						$x = '.';
63
-					}
64
-				}
65
-			}
66
-		}
67
-		$pass .= $x;
68
-		$s = substr($s, 2);
69
-	}
70
-	$pass = preg_replace('@[./]@', 'a', $pass);
71
-	$pass = preg_replace('@[I1l]@', 'L', $pass);
72
-	$pass = preg_replace('@[0O]@', 'o', $pass);
73
-
74
-	return $pass;
34
+    $seed = (int)round(((float)microtime() + 1) * time());
35
+
36
+    mt_srand($seed);
37
+    srand($seed);
38
+    $s = '';
39
+    $pass = '';
40
+    for ($i = 0; $i < $longueur; $i++) {
41
+        if (!$s) {
42
+            $s = mt_rand();
43
+            if (!$s) {
44
+                $s = rand();
45
+            }
46
+            $s = substr(md5(uniqid($s) . $sel), 0, 16);
47
+        }
48
+        $r = unpack('Cr', pack('H2', $s . $s));
49
+        $x = $r['r'] & 63;
50
+        if ($x < 10) {
51
+            $x = chr($x + 48);
52
+        } else {
53
+            if ($x < 36) {
54
+                $x = chr($x + 55);
55
+            } else {
56
+                if ($x < 62) {
57
+                    $x = chr($x + 61);
58
+                } else {
59
+                    if ($x == 63) {
60
+                        $x = '/';
61
+                    } else {
62
+                        $x = '.';
63
+                    }
64
+                }
65
+            }
66
+        }
67
+        $pass .= $x;
68
+        $s = substr($s, 2);
69
+    }
70
+    $pass = preg_replace('@[./]@', 'a', $pass);
71
+    $pass = preg_replace('@[I1l]@', 'L', $pass);
72
+    $pass = preg_replace('@[0O]@', 'o', $pass);
73
+
74
+    return $pass;
75 75
 }
76 76
 
77 77
 /**
@@ -80,21 +80,21 @@  discard block
 block discarded – undo
80 80
  * @return string Identifiant
81 81
  */
82 82
 function creer_uniqid() {
83
-	static $seeded;
83
+    static $seeded;
84 84
 
85
-	if (!$seeded) {
86
-		$seed = (int)round(((float)microtime() + 1) * time());
87
-		mt_srand($seed);
88
-		srand($seed);
89
-		$seeded = true;
90
-	}
85
+    if (!$seeded) {
86
+        $seed = (int)round(((float)microtime() + 1) * time());
87
+        mt_srand($seed);
88
+        srand($seed);
89
+        $seeded = true;
90
+    }
91 91
 
92
-	$s = mt_rand();
93
-	if (!$s) {
94
-		$s = rand();
95
-	}
92
+    $s = mt_rand();
93
+    if (!$s) {
94
+        $s = rand();
95
+    }
96 96
 
97
-	return uniqid($s, 1);
97
+    return uniqid($s, 1);
98 98
 }
99 99
 
100 100
 /**
@@ -108,42 +108,42 @@  discard block
 block discarded – undo
108 108
  * @return string Retourne l'alea éphemère actuel au passage
109 109
  */
110 110
 function charger_aleas() {
111
-	if (!isset($GLOBALS['meta']['alea_ephemere'])) {
112
-		include_spip('base/abstract_sql');
113
-		$aleas = sql_allfetsel(
114
-			['nom', 'valeur'],
115
-			'spip_meta',
116
-			sql_in('nom', ['alea_ephemere', 'alea_ephemere_ancien']),
117
-			'',
118
-			'',
119
-			'',
120
-			'',
121
-			'',
122
-			'continue'
123
-		);
124
-		if ($aleas) {
125
-			foreach ($aleas as $a) {
126
-				$GLOBALS['meta'][$a['nom']] = $a['valeur'];
127
-			}
128
-			return $GLOBALS['meta']['alea_ephemere'];
129
-		} else {
130
-			spip_log('aleas indisponibles', 'session');
131
-			return '';
132
-		}
133
-	}
134
-	return $GLOBALS['meta']['alea_ephemere'];
111
+    if (!isset($GLOBALS['meta']['alea_ephemere'])) {
112
+        include_spip('base/abstract_sql');
113
+        $aleas = sql_allfetsel(
114
+            ['nom', 'valeur'],
115
+            'spip_meta',
116
+            sql_in('nom', ['alea_ephemere', 'alea_ephemere_ancien']),
117
+            '',
118
+            '',
119
+            '',
120
+            '',
121
+            '',
122
+            'continue'
123
+        );
124
+        if ($aleas) {
125
+            foreach ($aleas as $a) {
126
+                $GLOBALS['meta'][$a['nom']] = $a['valeur'];
127
+            }
128
+            return $GLOBALS['meta']['alea_ephemere'];
129
+        } else {
130
+            spip_log('aleas indisponibles', 'session');
131
+            return '';
132
+        }
133
+    }
134
+    return $GLOBALS['meta']['alea_ephemere'];
135 135
 }
136 136
 
137 137
 /**
138 138
  * Renouveller l'alea (utilisé pour sécuriser les scripts du répertoire `action/`)
139 139
  **/
140 140
 function renouvelle_alea() {
141
-	charger_aleas();
142
-	ecrire_meta('alea_ephemere_ancien', @$GLOBALS['meta']['alea_ephemere'], 'non');
143
-	$GLOBALS['meta']['alea_ephemere'] = md5(creer_uniqid());
144
-	ecrire_meta('alea_ephemere', $GLOBALS['meta']['alea_ephemere'], 'non');
145
-	ecrire_meta('alea_ephemere_date', time(), 'non');
146
-	spip_log("renouvellement de l'alea_ephemere");
141
+    charger_aleas();
142
+    ecrire_meta('alea_ephemere_ancien', @$GLOBALS['meta']['alea_ephemere'], 'non');
143
+    $GLOBALS['meta']['alea_ephemere'] = md5(creer_uniqid());
144
+    ecrire_meta('alea_ephemere', $GLOBALS['meta']['alea_ephemere'], 'non');
145
+    ecrire_meta('alea_ephemere_date', time(), 'non');
146
+    spip_log("renouvellement de l'alea_ephemere");
147 147
 }
148 148
 
149 149
 
@@ -163,21 +163,21 @@  discard block
 block discarded – undo
163 163
  *     Clé de sécurité.
164 164
  **/
165 165
 function low_sec($id_auteur) {
166
-	// Pas d'id_auteur : low_sec
167
-	if (!$id_auteur = intval($id_auteur)) {
168
-		include_spip('inc/config');
169
-		if (!$low_sec = lire_config('low_sec')) {
170
-			ecrire_meta('low_sec', $low_sec = creer_pass_aleatoire());
171
-		}
172
-	} else {
173
-		$low_sec = sql_getfetsel('low_sec', 'spip_auteurs', 'id_auteur = ' . intval($id_auteur));
174
-		if (!$low_sec) {
175
-			$low_sec = creer_pass_aleatoire();
176
-			sql_updateq('spip_auteurs', ['low_sec' => $low_sec], 'id_auteur = ' . intval($id_auteur));
177
-		}
178
-	}
179
-
180
-	return $low_sec;
166
+    // Pas d'id_auteur : low_sec
167
+    if (!$id_auteur = intval($id_auteur)) {
168
+        include_spip('inc/config');
169
+        if (!$low_sec = lire_config('low_sec')) {
170
+            ecrire_meta('low_sec', $low_sec = creer_pass_aleatoire());
171
+        }
172
+    } else {
173
+        $low_sec = sql_getfetsel('low_sec', 'spip_auteurs', 'id_auteur = ' . intval($id_auteur));
174
+        if (!$low_sec) {
175
+            $low_sec = creer_pass_aleatoire();
176
+            sql_updateq('spip_auteurs', ['low_sec' => $low_sec], 'id_auteur = ' . intval($id_auteur));
177
+        }
178
+    }
179
+
180
+    return $low_sec;
181 181
 }
182 182
 
183 183
 /**
@@ -193,27 +193,27 @@  discard block
 block discarded – undo
193 193
  * @return string
194 194
  */
195 195
 function param_low_sec($op, $args = [], $lang = '', $mime = 'rss') {
196
-	$a = $b = '';
197
-	foreach ($args as $val => $var) {
198
-		if ($var) {
199
-			if ($val <> 'statut') {
200
-				$a .= ':' . $val . '-' . $var;
201
-			}
202
-			$b .= $val . '=' . $var . '&';
203
-		}
204
-	}
205
-	$a = substr($a, 1);
206
-	$id = intval(@$GLOBALS['connect_id_auteur']);
207
-
208
-	return $b
209
-	. 'op='
210
-	. $op
211
-	. '&id='
212
-	. $id
213
-	. '&cle='
214
-	. afficher_low_sec($id, "$mime $op $a")
215
-	. (!$a ? '' : "&args=$a")
216
-	. (!$lang ? '' : "&lang=$lang");
196
+    $a = $b = '';
197
+    foreach ($args as $val => $var) {
198
+        if ($var) {
199
+            if ($val <> 'statut') {
200
+                $a .= ':' . $val . '-' . $var;
201
+            }
202
+            $b .= $val . '=' . $var . '&';
203
+        }
204
+    }
205
+    $a = substr($a, 1);
206
+    $id = intval(@$GLOBALS['connect_id_auteur']);
207
+
208
+    return $b
209
+    . 'op='
210
+    . $op
211
+    . '&id='
212
+    . $id
213
+    . '&cle='
214
+    . afficher_low_sec($id, "$mime $op $a")
215
+    . (!$a ? '' : "&args=$a")
216
+    . (!$lang ? '' : "&lang=$lang");
217 217
 }
218 218
 
219 219
 /**
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
  *     Clé
230 230
  **/
231 231
 function afficher_low_sec($id_auteur, $action = '') {
232
-	return substr(md5($action . low_sec($id_auteur)), 0, 8);
232
+    return substr(md5($action . low_sec($id_auteur)), 0, 8);
233 233
 }
234 234
 
235 235
 /**
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
  *     true si les clés corresponde, false sinon
248 248
  **/
249 249
 function verifier_low_sec($id_auteur, $cle, $action = '') {
250
-	return ($cle == afficher_low_sec($id_auteur, $action));
250
+    return ($cle == afficher_low_sec($id_auteur, $action));
251 251
 }
252 252
 
253 253
 /**
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
  *     Identifiant de l'auteur
258 258
  **/
259 259
 function effacer_low_sec($id_auteur) {
260
-	if (!$id_auteur = intval($id_auteur)) {
261
-		return;
262
-	} // jamais trop prudent ;)
263
-	sql_updateq('spip_auteurs', ['low_sec' => ''], 'id_auteur = ' . intval($id_auteur));
260
+    if (!$id_auteur = intval($id_auteur)) {
261
+        return;
262
+    } // jamais trop prudent ;)
263
+    sql_updateq('spip_auteurs', ['low_sec' => ''], 'id_auteur = ' . intval($id_auteur));
264 264
 }
265 265
 
266 266
 /**
@@ -269,14 +269,14 @@  discard block
 block discarded – undo
269 269
  * @return void|bool
270 270
  */
271 271
 function initialiser_sel() {
272
-	if (!isset($GLOBALS['htsalt'])) {
273
-		if (CRYPT_MD5) {
274
-			$GLOBALS['htsalt'] = '$1$' . creer_pass_aleatoire();
275
-		} else {
276
-			$GLOBALS['htsalt'] = '';
277
-		}
278
-	}
279
-	return $GLOBALS['htsalt'];
272
+    if (!isset($GLOBALS['htsalt'])) {
273
+        if (CRYPT_MD5) {
274
+            $GLOBALS['htsalt'] = '$1$' . creer_pass_aleatoire();
275
+        } else {
276
+            $GLOBALS['htsalt'] = '';
277
+        }
278
+    }
279
+    return $GLOBALS['htsalt'];
280 280
 }
281 281
 
282 282
 /**
@@ -293,32 +293,32 @@  discard block
 block discarded – undo
293 293
  *     - void sinon.
294 294
  **/
295 295
 function ecrire_acces() {
296
-	$htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME;
297
-	$htpasswd = _DIR_TMP . _AUTH_USER_FILE;
298
-
299
-	// Cette variable de configuration peut etre posee par un plugin
300
-	// par exemple acces_restreint ;
301
-	// si .htaccess existe, outrepasser spip_meta
302
-	if (
303
-		(!isset($GLOBALS['meta']['creer_htpasswd'])
304
-			or ($GLOBALS['meta']['creer_htpasswd'] != 'oui'))
305
-		and !@file_exists($htaccess)
306
-	) {
307
-		spip_unlink($htpasswd);
308
-		spip_unlink($htpasswd . '-admin');
309
-		return;
310
-	}
311
-
312
-	# remarque : ici on laisse passer les "nouveau" de maniere a leur permettre
313
-	# de devenir redacteur le cas echeant (auth http)... a nettoyer
314
-	// attention, il faut au prealable se connecter a la base (necessaire car utilise par install)
315
-	// TODO: factoriser avec auth/spip qui fait deja ce job et generaliser le test spip_connect_ldap()
316
-
317
-	if (spip_connect_ldap()) {
318
-		return;
319
-	}
320
-
321
-	generer_htpasswd_files($htpasswd, "$htpasswd-admin");
296
+    $htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME;
297
+    $htpasswd = _DIR_TMP . _AUTH_USER_FILE;
298
+
299
+    // Cette variable de configuration peut etre posee par un plugin
300
+    // par exemple acces_restreint ;
301
+    // si .htaccess existe, outrepasser spip_meta
302
+    if (
303
+        (!isset($GLOBALS['meta']['creer_htpasswd'])
304
+            or ($GLOBALS['meta']['creer_htpasswd'] != 'oui'))
305
+        and !@file_exists($htaccess)
306
+    ) {
307
+        spip_unlink($htpasswd);
308
+        spip_unlink($htpasswd . '-admin');
309
+        return;
310
+    }
311
+
312
+    # remarque : ici on laisse passer les "nouveau" de maniere a leur permettre
313
+    # de devenir redacteur le cas echeant (auth http)... a nettoyer
314
+    // attention, il faut au prealable se connecter a la base (necessaire car utilise par install)
315
+    // TODO: factoriser avec auth/spip qui fait deja ce job et generaliser le test spip_connect_ldap()
316
+
317
+    if (spip_connect_ldap()) {
318
+        return;
319
+    }
320
+
321
+    generer_htpasswd_files($htpasswd, "$htpasswd-admin");
322 322
 }
323 323
 
324 324
 /**
@@ -327,29 +327,29 @@  discard block
 block discarded – undo
327 327
  * @param $htpasswd_admin
328 328
  */
329 329
 function generer_htpasswd_files($htpasswd, $htpasswd_admin) {
330
-	if ($generer_htpasswd = charger_fonction('generer_htpasswd_files', 'inc', true)) {
331
-		$generer_htpasswd($htpasswd, $htpasswd_admin);
332
-	}
333
-
334
-	$pwd_all = ''; // login:htpass pour tous
335
-	$pwd_admin = ''; // login:htpass pour les admins
336
-
337
-	$res = sql_select('login, htpass, statut', 'spip_auteurs', "htpass!='' AND login!='' AND " . sql_in('statut', ['1comite', '0minirezo', 'nouveau']));
338
-	while ($row = sql_fetch($res)) {
339
-		if (strlen($row['login']) and strlen($row['htpass'])) {
340
-			$ligne = $row['login'] . ':' . $row['htpass'] . "\n";
341
-			$pwd_all .= $ligne;
342
-			if ($row['statut'] == '0minirezo') {
343
-				$pwd_admin .= $ligne;
344
-			}
345
-		}
346
-	}
347
-
348
-	if ($pwd_all) {
349
-		ecrire_fichier($htpasswd, $pwd_all);
350
-		ecrire_fichier($htpasswd_admin, $pwd_admin);
351
-		spip_log("Ecriture de $htpasswd et $htpasswd_admin", 'htpass');
352
-	}
330
+    if ($generer_htpasswd = charger_fonction('generer_htpasswd_files', 'inc', true)) {
331
+        $generer_htpasswd($htpasswd, $htpasswd_admin);
332
+    }
333
+
334
+    $pwd_all = ''; // login:htpass pour tous
335
+    $pwd_admin = ''; // login:htpass pour les admins
336
+
337
+    $res = sql_select('login, htpass, statut', 'spip_auteurs', "htpass!='' AND login!='' AND " . sql_in('statut', ['1comite', '0minirezo', 'nouveau']));
338
+    while ($row = sql_fetch($res)) {
339
+        if (strlen($row['login']) and strlen($row['htpass'])) {
340
+            $ligne = $row['login'] . ':' . $row['htpass'] . "\n";
341
+            $pwd_all .= $ligne;
342
+            if ($row['statut'] == '0minirezo') {
343
+                $pwd_admin .= $ligne;
344
+            }
345
+        }
346
+    }
347
+
348
+    if ($pwd_all) {
349
+        ecrire_fichier($htpasswd, $pwd_all);
350
+        ecrire_fichier($htpasswd_admin, $pwd_admin);
351
+        spip_log("Ecriture de $htpasswd et $htpasswd_admin", 'htpass');
352
+    }
353 353
 }
354 354
 
355 355
 /**
@@ -363,13 +363,13 @@  discard block
 block discarded – undo
363 363
  *  La chaîne hachée si fonction crypt présente, rien sinon.
364 364
  */
365 365
 function generer_htpass($pass) {
366
-	if ($generer_htpass = charger_fonction('generer_htpass', 'inc', true)) {
367
-		return $generer_htpass($pass);
368
-	}
369
-	elseif (function_exists('crypt')) {
370
-		return crypt($pass, initialiser_sel());
371
-	}
372
-	return '';
366
+    if ($generer_htpass = charger_fonction('generer_htpass', 'inc', true)) {
367
+        return $generer_htpass($pass);
368
+    }
369
+    elseif (function_exists('crypt')) {
370
+        return crypt($pass, initialiser_sel());
371
+    }
372
+    return '';
373 373
 }
374 374
 
375 375
 /**
@@ -382,14 +382,14 @@  discard block
 block discarded – undo
382 382
  * @return boolean
383 383
  */
384 384
 function verifier_htaccess($rep, $force = false) {
385
-	$htaccess = rtrim($rep, '/') . '/' . _ACCESS_FILE_NAME;
386
-	if (((@file_exists($htaccess)) or defined('_TEST_DIRS')) and !$force) {
387
-		return true;
388
-	}
389
-
390
-	// directive deny compatible Apache 2.0+
391
-	$deny =
392
-		'# Deny all requests from Apache 2.4+.
385
+    $htaccess = rtrim($rep, '/') . '/' . _ACCESS_FILE_NAME;
386
+    if (((@file_exists($htaccess)) or defined('_TEST_DIRS')) and !$force) {
387
+        return true;
388
+    }
389
+
390
+    // directive deny compatible Apache 2.0+
391
+    $deny =
392
+        '# Deny all requests from Apache 2.4+.
393 393
 <IfModule mod_authz_core.c>
394 394
   Require all denied
395 395
 </IfModule>
@@ -398,32 +398,32 @@  discard block
 block discarded – undo
398 398
   Deny from all
399 399
 </IfModule>
400 400
 ';
401
-	// support des vieilles versions Apache 1.x mais uniquement si elles l'annoncent (pas en mode PROD)
402
-	if (
403
-		function_exists('apache_get_version')
404
-		and $v = apache_get_version()
405
-		and strncmp($v, 'Apache/1.', 9) == 0
406
-	) {
407
-		$deny = "deny from all\n";
408
-	}
409
-
410
-	if ($ht = @fopen($htaccess, 'w')) {
411
-		fputs($ht, $deny);
412
-		fclose($ht);
413
-		@chmod($htaccess, _SPIP_CHMOD & 0666);
414
-		$t = rtrim($rep, '/') . '/.ok';
415
-		if ($ht = @fopen($t, 'w')) {
416
-			@fclose($ht);
417
-			include_spip('inc/distant');
418
-			$t = substr($t, strlen(_DIR_RACINE));
419
-			$t = url_de_base() . $t;
420
-			$ht = recuperer_url($t, ['methode' => 'HEAD', 'taille_max' => 0, 'follow_location' => false]);
421
-			$ht = ($ht['status'] ?? null) === 403;
422
-		}
423
-	}
424
-	spip_log("Creation de $htaccess " . ($ht ? ' reussie' : ' manquee'));
425
-
426
-	return $ht;
401
+    // support des vieilles versions Apache 1.x mais uniquement si elles l'annoncent (pas en mode PROD)
402
+    if (
403
+        function_exists('apache_get_version')
404
+        and $v = apache_get_version()
405
+        and strncmp($v, 'Apache/1.', 9) == 0
406
+    ) {
407
+        $deny = "deny from all\n";
408
+    }
409
+
410
+    if ($ht = @fopen($htaccess, 'w')) {
411
+        fputs($ht, $deny);
412
+        fclose($ht);
413
+        @chmod($htaccess, _SPIP_CHMOD & 0666);
414
+        $t = rtrim($rep, '/') . '/.ok';
415
+        if ($ht = @fopen($t, 'w')) {
416
+            @fclose($ht);
417
+            include_spip('inc/distant');
418
+            $t = substr($t, strlen(_DIR_RACINE));
419
+            $t = url_de_base() . $t;
420
+            $ht = recuperer_url($t, ['methode' => 'HEAD', 'taille_max' => 0, 'follow_location' => false]);
421
+            $ht = ($ht['status'] ?? null) === 403;
422
+        }
423
+    }
424
+    spip_log("Creation de $htaccess " . ($ht ? ' reussie' : ' manquee'));
425
+
426
+    return $ht;
427 427
 }
428 428
 
429 429
 /**
@@ -441,20 +441,20 @@  discard block
 block discarded – undo
441 441
  *         Valeur de la configuration `creer_htaccess`
442 442
  */
443 443
 function gerer_htaccess() {
444
-	// Cette variable de configuration peut etre posee par un plugin
445
-	// par exemple acces_restreint
446
-	$f = (isset($GLOBALS['meta']['creer_htaccess']) and ($GLOBALS['meta']['creer_htaccess'] === 'oui'));
447
-	$dirs = sql_allfetsel('extension', 'spip_types_documents');
448
-	$dirs[] = ['extension' => 'distant'];
449
-	foreach ($dirs as $e) {
450
-		if (is_dir($dir = _DIR_IMG . $e['extension'])) {
451
-			if ($f) {
452
-				verifier_htaccess($dir);
453
-			} else {
454
-				spip_unlink($dir . '/' . _ACCESS_FILE_NAME);
455
-			}
456
-		}
457
-	}
458
-
459
-	return isset($GLOBALS['meta']['creer_htaccess']) ? $GLOBALS['meta']['creer_htaccess'] : '';
444
+    // Cette variable de configuration peut etre posee par un plugin
445
+    // par exemple acces_restreint
446
+    $f = (isset($GLOBALS['meta']['creer_htaccess']) and ($GLOBALS['meta']['creer_htaccess'] === 'oui'));
447
+    $dirs = sql_allfetsel('extension', 'spip_types_documents');
448
+    $dirs[] = ['extension' => 'distant'];
449
+    foreach ($dirs as $e) {
450
+        if (is_dir($dir = _DIR_IMG . $e['extension'])) {
451
+            if ($f) {
452
+                verifier_htaccess($dir);
453
+            } else {
454
+                spip_unlink($dir . '/' . _ACCESS_FILE_NAME);
455
+            }
456
+        }
457
+    }
458
+
459
+    return isset($GLOBALS['meta']['creer_htaccess']) ? $GLOBALS['meta']['creer_htaccess'] : '';
460 460
 }
Please login to merge, or discard this patch.
ecrire/inc/couleurs.php 1 patch
Indentation   +63 added lines, -63 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
 /**
@@ -38,70 +38,70 @@  discard block
 block discarded – undo
38 38
  * @return array|string
39 39
  */
40 40
 function inc_couleurs_dist($choix = null, $ajouter = false) {
41
-	static $couleurs_spip = [
42
-		// Violet soutenu
43
-		9 => ['couleur_theme' => '#9a6ef2'],
44
-		// Violet rosé
45
-		4 => ['couleur_theme' => '#c464cb'],
46
-		// Rose interface SPIP
47
-		2 => ['couleur_theme' =>  '#F02364'],
48
-		// Rouge
49
-		8 => ['couleur_theme' => '#ff4524'],
50
-		// Orange
51
-		3 => ['couleur_theme' => '#c97500'],
52
-		// Vert SPIP
53
-		1 => ['couleur_theme' => '#9dba00'],
54
-		// Vert Troglo
55
-		7 => ['couleur_theme' => '#419a2c'],
56
-		// Bleu-vert
57
-		12 => ['couleur_theme' => '#269681'],
58
-		//  Bleu pastel
59
-		5 => ['couleur_theme' => '#3190ae'],
60
-		//  Bleu Kermesse
61
-		11 => ['couleur_theme' => '#288bdd'],
62
-		//  Gris bleuté
63
-		6 => ['couleur_theme' => '#7d90a2'],
64
-		//  Gris
65
-		10 => ['couleur_theme' => '#909090'],
66
-	];
41
+    static $couleurs_spip = [
42
+        // Violet soutenu
43
+        9 => ['couleur_theme' => '#9a6ef2'],
44
+        // Violet rosé
45
+        4 => ['couleur_theme' => '#c464cb'],
46
+        // Rose interface SPIP
47
+        2 => ['couleur_theme' =>  '#F02364'],
48
+        // Rouge
49
+        8 => ['couleur_theme' => '#ff4524'],
50
+        // Orange
51
+        3 => ['couleur_theme' => '#c97500'],
52
+        // Vert SPIP
53
+        1 => ['couleur_theme' => '#9dba00'],
54
+        // Vert Troglo
55
+        7 => ['couleur_theme' => '#419a2c'],
56
+        // Bleu-vert
57
+        12 => ['couleur_theme' => '#269681'],
58
+        //  Bleu pastel
59
+        5 => ['couleur_theme' => '#3190ae'],
60
+        //  Bleu Kermesse
61
+        11 => ['couleur_theme' => '#288bdd'],
62
+        //  Gris bleuté
63
+        6 => ['couleur_theme' => '#7d90a2'],
64
+        //  Gris
65
+        10 => ['couleur_theme' => '#909090'],
66
+    ];
67 67
 
68
-	if (is_numeric($choix)) {
69
-		$c = $couleurs_spip[$choix];
70
-		// compat < SPIP 3.3
71
-		include_spip('inc/filtres_images_mini');
72
-		$c['couleur_foncee'] = $c['couleur_theme'];
73
-		$c['couleur_claire'] = '#' . couleur_eclaircir($c['couleur_theme'], .5);
68
+    if (is_numeric($choix)) {
69
+        $c = $couleurs_spip[$choix];
70
+        // compat < SPIP 3.3
71
+        include_spip('inc/filtres_images_mini');
72
+        $c['couleur_foncee'] = $c['couleur_theme'];
73
+        $c['couleur_claire'] = '#' . couleur_eclaircir($c['couleur_theme'], .5);
74 74
 
75
-		return
76
-			'couleur_theme=' . substr($c['couleur_theme'], 1)
77
-			// compat < SPIP 3.3
78
-			. '&couleur_claire=' . substr($c['couleur_claire'], 1)
79
-			. '&couleur_foncee=' . substr($c['couleur_foncee'], 1);
80
-	} else {
81
-		if (is_array($choix)) {
82
-			// compat < SPIP 3.3
83
-			$compat_spip_33 = function ($c) {
84
-				if (!isset($c['couleur_theme'])) {
85
-					$c['couleur_theme'] = $c['couleur_foncee'];
86
-					unset($c['couleur_foncee']);
87
-					unset($c['couleur_claire']);
88
-					unset($c['couleur_lien']);
89
-					unset($c['couleur_lien_off']);
90
-				}
91
-				return $c;
92
-			};
93
-			if ($ajouter) {
94
-				foreach ($choix as $c) {
95
-					$couleurs_spip[] = $compat_spip_33($c);
96
-				}
75
+        return
76
+            'couleur_theme=' . substr($c['couleur_theme'], 1)
77
+            // compat < SPIP 3.3
78
+            . '&couleur_claire=' . substr($c['couleur_claire'], 1)
79
+            . '&couleur_foncee=' . substr($c['couleur_foncee'], 1);
80
+    } else {
81
+        if (is_array($choix)) {
82
+            // compat < SPIP 3.3
83
+            $compat_spip_33 = function ($c) {
84
+                if (!isset($c['couleur_theme'])) {
85
+                    $c['couleur_theme'] = $c['couleur_foncee'];
86
+                    unset($c['couleur_foncee']);
87
+                    unset($c['couleur_claire']);
88
+                    unset($c['couleur_lien']);
89
+                    unset($c['couleur_lien_off']);
90
+                }
91
+                return $c;
92
+            };
93
+            if ($ajouter) {
94
+                foreach ($choix as $c) {
95
+                    $couleurs_spip[] = $compat_spip_33($c);
96
+                }
97 97
 
98
-				return $couleurs_spip;
99
-			} else {
100
-				$choix = array_map($compat_spip_33, $choix);
101
-				return $couleurs_spip = $choix;
102
-			}
103
-		}
104
-	}
98
+                return $couleurs_spip;
99
+            } else {
100
+                $choix = array_map($compat_spip_33, $choix);
101
+                return $couleurs_spip = $choix;
102
+            }
103
+        }
104
+    }
105 105
 
106
-	return $couleurs_spip;
106
+    return $couleurs_spip;
107 107
 }
Please login to merge, or discard this patch.
ecrire/inc/iconifier.php 1 patch
Indentation   +7 added lines, -7 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('inc/actions');
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
  *     - ou tableau d'information sur le squelette.
37 37
  */
38 38
 function inc_iconifier_dist($objet, $id, $script, $visible = false, $flag_modif = true) {
39
-	// compat avec anciens appels
40
-	$objet = objet_type($objet);
39
+    // compat avec anciens appels
40
+    $objet = objet_type($objet);
41 41
 
42
-	return recuperer_fond(
43
-		'prive/objets/editer/logo',
44
-		['objet' => $objet, 'id_objet' => $id, 'editable' => $flag_modif]
45
-	);
42
+    return recuperer_fond(
43
+        'prive/objets/editer/logo',
44
+        ['objet' => $objet, 'id_objet' => $id, 'editable' => $flag_modif]
45
+    );
46 46
 }
Please login to merge, or discard this patch.
ecrire/inc/preselectionner_parent_nouvel_objet.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 if (!defined('_AUTO_SELECTION_RUBRIQUE')) {
17
-	define('_AUTO_SELECTION_RUBRIQUE', false);
17
+    define('_AUTO_SELECTION_RUBRIQUE', false);
18 18
 }
19 19
 
20 20
 
@@ -28,39 +28,39 @@  discard block
 block discarded – undo
28 28
  * @return string
29 29
  */
30 30
 function inc_preselectionner_parent_nouvel_objet_dist($objet, $row) {
31
-	if (!_AUTO_SELECTION_RUBRIQUE) {
32
-		return '';
33
-	}
31
+    if (!_AUTO_SELECTION_RUBRIQUE) {
32
+        return '';
33
+    }
34 34
 
35
-	if (!isset($row['id_rubrique'])) {
36
-		return '';
37
-	}
35
+    if (!isset($row['id_rubrique'])) {
36
+        return '';
37
+    }
38 38
 
39
-	$id_rubrique = '';
40
-	if ($GLOBALS['connect_id_rubrique']) {
41
-		// si admin restreint : sa rubrique
42
-		$id_rubrique = $GLOBALS['connect_id_rubrique'][0];
43
-	} elseif (
44
-		is_int(_AUTO_SELECTION_RUBRIQUE)
45
-		and sql_fetsel('id_rubrique', 'spip_rubriques', 'id_rubrique=' . intval(_AUTO_SELECTION_RUBRIQUE))
46
-	) {
47
-		$id_rubrique = _AUTO_SELECTION_RUBRIQUE;
48
-	} else {
49
-		// sinon la derniere rubrique cree
50
-		$row_rub = sql_fetsel('id_rubrique', 'spip_rubriques', '', '', 'id_rubrique DESC', '0,1');
51
-		$id_rubrique = $row_rub['id_rubrique'];
52
-	}
53
-	// si le choix ne convient pas, on cherche dans un secteur
54
-	if (!autoriser('creer' . $objet . 'dans', 'rubrique', $id_rubrique)) {
55
-		$id_rubrique = '';
56
-		// manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises
57
-		$res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0');
58
-		while (!$id_rubrique and $row_rub = sql_fetch($res)) {
59
-			if (autoriser('creer' . $objet . 'dans', 'rubrique', $row_rub['id_rubrique'])) {
60
-				$id_rubrique = $row_rub['id_rubrique'];
61
-			}
62
-		}
63
-	}
39
+    $id_rubrique = '';
40
+    if ($GLOBALS['connect_id_rubrique']) {
41
+        // si admin restreint : sa rubrique
42
+        $id_rubrique = $GLOBALS['connect_id_rubrique'][0];
43
+    } elseif (
44
+        is_int(_AUTO_SELECTION_RUBRIQUE)
45
+        and sql_fetsel('id_rubrique', 'spip_rubriques', 'id_rubrique=' . intval(_AUTO_SELECTION_RUBRIQUE))
46
+    ) {
47
+        $id_rubrique = _AUTO_SELECTION_RUBRIQUE;
48
+    } else {
49
+        // sinon la derniere rubrique cree
50
+        $row_rub = sql_fetsel('id_rubrique', 'spip_rubriques', '', '', 'id_rubrique DESC', '0,1');
51
+        $id_rubrique = $row_rub['id_rubrique'];
52
+    }
53
+    // si le choix ne convient pas, on cherche dans un secteur
54
+    if (!autoriser('creer' . $objet . 'dans', 'rubrique', $id_rubrique)) {
55
+        $id_rubrique = '';
56
+        // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises
57
+        $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0');
58
+        while (!$id_rubrique and $row_rub = sql_fetch($res)) {
59
+            if (autoriser('creer' . $objet . 'dans', 'rubrique', $row_rub['id_rubrique'])) {
60
+                $id_rubrique = $row_rub['id_rubrique'];
61
+            }
62
+        }
63
+    }
64 64
 
65
-	return $id_rubrique;
65
+    return $id_rubrique;
66 66
 }
Please login to merge, or discard this patch.